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 cApiContentCollection extends ItemCollection {
24: 25: 26: 27: 28:
29: public function __construct() {
30: global $cfg;
31: parent::__construct($cfg['tab']['content'], 'idcontent');
32: $this->_setItemClass('cApiContent');
33:
34:
35: $this->_setJoinPartner('cApiArticleLanguageCollection');
36: $this->_setJoinPartner('cApiTypeCollection');
37: }
38:
39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55:
56: public function create($idArtLang, $idType, $typeId, $value, $version, $author = '', $created = '', $lastmodified = '') {
57: global $auth;
58:
59: if (empty($author)) {
60: $author = $auth->auth['uname'];
61: }
62: if (empty($created)) {
63: $created = date('Y-m-d H:i:s');
64: }
65: if (empty($lastmodified)) {
66: $lastmodified = date('Y-m-d H:i:s');
67: }
68:
69: $oItem = $this->createNewItem();
70:
71: $oItem->set('idartlang', $idArtLang);
72: $oItem->set('idtype', $idType);
73: $oItem->set('typeid', $typeId);
74: $oItem->set('value', $value);
75: $oItem->set('version', $version);
76: $oItem->set('author', $author);
77: $oItem->set('created', $created);
78: $oItem->set('lastmodified', $lastmodified);
79:
80: $oItem->store();
81:
82: return $oItem;
83: }
84:
85: }
86:
87: 88: 89: 90: 91: 92:
93: class cApiContent extends Item
94: {
95: 96: 97: 98: 99: 100: 101: 102: 103:
104: public function __construct($mId = false) {
105: global $cfg;
106: parent::__construct($cfg['tab']['content'], 'idcontent');
107: $this->setFilters(array(), array());
108: if ($mId !== false) {
109: $this->loadByPrimaryKey($mId);
110: }
111: }
112:
113: 114: 115: 116: 117: 118: 119: 120: 121: 122:
123: public function setField($name, $value, $bSafe = true) {
124: switch ($name) {
125: case 'idartlang':
126: case 'idtype':
127: case 'typeid':
128: case 'version':
129: $value = (int) $value;
130: break;
131: }
132:
133: return parent::setField($name, $value, $bSafe);
134: }
135:
136: 137: 138: 139: 140: 141: 142: 143: 144:
145: public function markAsEditable($version, $deleted) {
146: $parameters = $this->values;
147: $parameters['version'] = $version;
148: $contentVersionColl = new cApiContentVersionCollection();
149: $contentVersion = $contentVersionColl->create($parameters);
150: if ($deleted == 1) {
151: $contentVersion->set('deleted', $deleted);
152: }
153: $contentVersion->store();
154: }
155:
156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166:
167: public function loadByArticleLanguageIdTypeAndTypeId($idartlang, $idtype, $typeid) {
168: $aProps = array(
169: 'idartlang' => $idartlang,
170: 'idtype' => $idtype,
171: 'typeid' => $typeid
172: );
173: $aRecordSet = $this->_oCache->getItemByProperties($aProps);
174: if ($aRecordSet) {
175:
176: $this->loadByRecordSet($aRecordSet);
177: return true;
178: } else {
179: $where = $this->db->prepare("idartlang = %d AND idtype = %d AND typeid = %d", $idartlang, $idtype, $typeid);
180: return $this->_loadByWhereClause($where);
181: }
182: }
183:
184: }
185: