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 cApiFrameFileCollection extends ItemCollection {
24:
25: 26: 27:
28: public function __construct() {
29: global $cfg;
30: parent::__construct($cfg['tab']['framefiles'], 'idframefile');
31: $this->_setItemClass('cApiFrameFile');
32:
33:
34: $this->_setJoinPartner('cApiAreaCollection');
35: $this->_setJoinPartner('cApiFileCollection');
36: }
37:
38: 39: 40: 41: 42: 43: 44:
45: public function create($area, $idframe, $idfile) {
46: $item = $this->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('idfile', $idfile);
62: $item->set('idframe', $idframe);
63:
64: $item->store();
65:
66: return $item;
67: }
68: }
69:
70: 71: 72: 73: 74: 75:
76: class cApiFrameFile extends Item {
77:
78: 79: 80: 81: 82: 83:
84: public function __construct($mId = false) {
85: global $cfg;
86: parent::__construct($cfg['tab']['framefiles'], 'idframefile');
87: $this->setFilters(array(
88: 'addslashes'
89: ), array(
90: 'stripslashes'
91: ));
92: if ($mId !== false) {
93: $this->loadByPrimaryKey($mId);
94: }
95: }
96:
97: 98: 99: 100: 101: 102: 103: 104: 105:
106: public function setField($name, $value, $bSafe = true) {
107: switch ($name) {
108: case 'idarea':
109: $value = (int) $value;
110: break;
111: case 'idfile':
112: $value = (int) $value;
113: break;
114: case 'idframe':
115: $value = (int) $value;
116: break;
117: }
118:
119: return parent::setField($name, $value, $bSafe);
120: }
121:
122: }
123: