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 cApiMetaTypeCollection extends ItemCollection {
24:
25: 26: 27:
28: public function __construct() {
29: global $cfg;
30: parent::__construct($cfg['tab']['meta_type'], 'idmetatype');
31: $this->_setItemClass('cApiMetaType');
32: }
33:
34: 35: 36: 37: 38: 39: 40: 41: 42:
43: public function create($metatype, $fieldtype, $maxlength, $fieldname) {
44: $oItem = $this->createNewItem();
45:
46: $oItem->set('metatype', $metatype);
47: $oItem->set('fieldtype', $fieldtype);
48: $oItem->set('maxlength', $maxlength);
49: $oItem->set('fieldname', $fieldname);
50: $oItem->store();
51:
52: return $oItem;
53: }
54:
55: }
56:
57: 58: 59: 60: 61: 62:
63: class cApiMetaType extends Item {
64:
65: 66: 67: 68: 69: 70:
71: public function __construct($mId = false) {
72: global $cfg;
73: parent::__construct($cfg['tab']['meta_type'], 'idmetatype');
74: $this->setFilters(array(), array());
75: if ($mId !== false) {
76: $this->loadByPrimaryKey($mId);
77: }
78: }
79:
80: 81: 82: 83: 84: 85: 86: 87: 88:
89: public function setField($name, $value, $bSafe = true) {
90: if ('maxlength' == $name) {
91: $value = (int) $value;
92: }
93:
94: return parent::setField($name, $value, $bSafe);
95: }
96:
97: }
98: