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