1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23:
24: class cApiFileCollection extends ItemCollection {
25:
26: 27: 28:
29: public function __construct() {
30: global $cfg;
31: parent::__construct($cfg['tab']['files'], 'idfile');
32: $this->_setItemClass('cApiFile');
33:
34:
35: $this->_setJoinPartner('cApiAreaCollection');
36: }
37:
38: 39: 40: 41: 42: 43: 44:
45: public function create($area, $filename, $filetype = 'main') {
46: $item = parent::createNewItem();
47:
48: if (is_string($area)) {
49: $c = new cApiArea();
50: $c->loadBy('name', $area);
51:
52: if ($c->isLoaded()) {
53: $area = $c->get('idarea');
54: } else {
55: $area = 0;
56: cWarning(__FILE__, __LINE__, "Could not resolve area [$area] passed to method [create], assuming 0");
57: }
58: }
59:
60: $item->set('idarea', $area);
61: $item->set('filename', $filename);
62:
63: if ($filetype != 'main') {
64: $item->set('filetype', 'inc');
65: } else {
66: $item->set('filetype', 'main');
67: }
68:
69: $item->store();
70:
71: return $item;
72: }
73: }
74:
75: 76: 77: 78: 79: 80:
81: class cApiFile extends Item {
82:
83: 84: 85: 86: 87:
88: public function __construct($mId = false) {
89: global $cfg;
90: parent::__construct($cfg['tab']['files'], 'idfile');
91: $this->setFilters(array(
92: 'addslashes'
93: ), array(
94: 'stripslashes'
95: ));
96: if ($mId !== false) {
97: $this->loadByPrimaryKey($mId);
98: }
99: }
100: }
101: