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 cApiMetaTagCollection extends ItemCollection {
24:
25: 26: 27:
28: public function __construct() {
29: global $cfg;
30: parent::__construct($cfg['tab']['meta_tag'], 'idmetatag');
31: $this->_setItemClass('cApiMetaTag');
32:
33:
34: $this->_setJoinPartner('cApiArticleLanguageCollection');
35: $this->_setJoinPartner('cApiMetaTypeCollection');
36: }
37:
38: 39: 40: 41: 42: 43: 44: 45:
46: public function create($iIdArtLang, $iIdMetaType, $sMetaValue) {
47: $oItem = $this->createNewItem();
48:
49: $oItem->set('idartlang', $iIdArtLang, false);
50: $oItem->set('idmetatype', $iIdMetaType, false);
51: $oItem->set('metavalue', $sMetaValue, false);
52: $oItem->store();
53:
54: return $oItem;
55: }
56:
57: 58: 59: 60: 61: 62: 63:
64: public function fetchByArtLangAndMetaType($iIdArtLang, $iIdMetaType) {
65: $this->select('idartlang=' . (int) $iIdArtLang . ' AND idmetatype=' . (int) $iIdMetaType);
66: return $this->next();
67: }
68:
69: }
70:
71: 72: 73: 74: 75: 76:
77: class cApiMetaTag extends Item {
78:
79: 80: 81: 82: 83: 84:
85: public function __construct($mId = false) {
86: global $cfg;
87: parent::__construct($cfg['tab']['meta_tag'], 'idmetatag');
88: $this->setFilters(array(), array());
89: if ($mId !== false) {
90: $this->loadByPrimaryKey($mId);
91: }
92: }
93:
94: 95: 96: 97: 98: 99:
100: public function updateMetaValue($sMetaValue) {
101: $this->set('metavalue', $sMetaValue, false);
102: return $this->store();
103: }
104:
105: 106: 107: 108: 109: 110: 111: 112: 113:
114: public function setField($name, $value, $bSafe = true) {
115: switch ($name) {
116: case 'idartlang':
117: $value = (int) $value;
118: break;
119: case 'idmetatype':
120: $value = (int) $value;
121: break;
122: }
123:
124: return parent::setField($name, $value, $bSafe);
125: }
126:
127: 128: 129: 130: 131:
132: public function markAsEditable($version) {
133:
134:
135:
136: $metaTagVersionColl = new cApiMetaTagVersionCollection();
137: $metaTagVersionColl->create(
138: $this->getField('idmetatag'),
139: $this->getField('idartlang'),
140: $this->getField('idmetatype'),
141: $this->getField('metavalue'),
142: $version
143: );
144:
145: }
146:
147: }
148: