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 cApiFrameFileCollection extends ItemCollection {
25:
26: 27: 28:
29: public function __construct() {
30: global $cfg;
31: parent::__construct($cfg['tab']['framefiles'], 'idframefile');
32: $this->_setItemClass('cApiFrameFile');
33:
34:
35: $this->_setJoinPartner('cApiAreaCollection');
36: $this->_setJoinPartner('cApiFileCollection');
37: }
38:
39: 40: 41: 42: 43: 44: 45:
46: public function create($area, $idframe, $idfile) {
47: $item = $this->createNewItem();
48:
49: if (is_string($area)) {
50: $c = new cApiArea();
51: $c->loadBy('name', $area);
52:
53: if ($c->isLoaded()) {
54: $area = $c->get('idarea');
55: } else {
56: $area = 0;
57: cWarning(__FILE__, __LINE__, "Could not resolve area [$area] passed to method [create], assuming 0");
58: }
59: }
60:
61: $item->set('idarea', $area);
62: $item->set('idfile', $idfile);
63: $item->set('idframe', $idframe);
64:
65: $item->store();
66:
67: return $item;
68: }
69: }
70:
71: 72: 73: 74: 75: 76:
77: class cApiFrameFile extends Item {
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: public function setField($name, $value, $bSafe = true) {
105: switch ($name) {
106: case 'idarea':
107: $value = (int) $value;
108: break;
109: case 'idfile':
110: $value = (int) $value;
111: break;
112: case 'idframe':
113: $value = (int) $value;
114: break;
115: }
116:
117: return parent::setField($name, $value, $bSafe);
118: }
119:
120: }
121: