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: public function create($area, $filename, $filetype = 'main') {
39: $item = parent::createNewItem();
40:
41: if (is_string($area)) {
42: $c = new cApiArea();
43: $c->loadBy('name', $area);
44:
45: if ($c->isLoaded()) {
46: $area = $c->get('idarea');
47: } else {
48: $area = 0;
49: cWarning(__FILE__, __LINE__, "Could not resolve area [$area] passed to method [create], assuming 0");
50: }
51: }
52:
53: $item->set('idarea', $area);
54: $item->set('filename', $filename);
55:
56: if ($filetype != 'main') {
57: $item->set('filetype', 'inc');
58: } else {
59: $item->set('filetype', 'main');
60: }
61:
62: $item->store();
63:
64: return ($item);
65: }
66:
67: }
68:
69: 70: 71: 72: 73: 74:
75: class cApiFile extends Item {
76:
77: 78: 79: 80: 81:
82: public function __construct($mId = false) {
83: global $cfg;
84: parent::__construct($cfg['tab']['files'], 'idfile');
85: $this->setFilters(array(
86: 'addslashes'
87: ), array(
88: 'stripslashes'
89: ));
90: if ($mId !== false) {
91: $this->loadByPrimaryKey($mId);
92: }
93: }
94: }
95: