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