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