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 cApiMetaTypeCollection extends ItemCollection {
25:
26: 27: 28:
29: public function __construct() {
30: global $cfg;
31: parent::__construct($cfg['tab']['meta_type'], 'idmetatype');
32: $this->_setItemClass('cApiMetaType');
33: }
34:
35: 36: 37: 38: 39: 40: 41: 42: 43:
44: public function create($metatype, $fieldtype, $maxlength, $fieldname) {
45: $oItem = $this->createNewItem();
46:
47: $oItem->set('metatype', $metatype);
48: $oItem->set('fieldtype', $fieldtype);
49: $oItem->set('maxlength', $maxlength);
50: $oItem->set('fieldname', $fieldname);
51: $oItem->store();
52:
53: return $oItem;
54: }
55:
56: }
57:
58: 59: 60: 61: 62: 63:
64: class cApiMetaType extends Item {
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: public function setField($name, $value, $bSafe = true) {
88: if ('maxlength' == $name) {
89: $value = (int) $value;
90: }
91:
92: return parent::setField($name, $value, $bSafe);
93: }
94:
95: }
96: