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: 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: public function create($idArtLang, $idType, $typeId, $value, $version, $author = '', $created = '', $lastmodified = '') {
53: global $auth;
54:
55: if (empty($author)) {
56: $author = $auth->auth['uname'];
57: }
58: if (empty($created)) {
59: $created = date('Y-m-d H:i:s');
60: }
61: if (empty($lastmodified)) {
62: $lastmodified = date('Y-m-d H:i:s');
63: }
64:
65: $oItem = $this->createNewItem();
66:
67: $oItem->set('idartlang', $idArtLang);
68: $oItem->set('idtype', $idType);
69: $oItem->set('typeid', $typeId);
70: $oItem->set('value', $value);
71: $oItem->set('version', $version);
72: $oItem->set('author', $author);
73: $oItem->set('created', $created);
74: $oItem->set('lastmodified', $lastmodified);
75:
76: $oItem->store();
77:
78: return $oItem;
79: }
80:
81: }
82:
83: 84: 85: 86: 87: 88:
89: class cApiContent extends Item {
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: public function setField($name, $value, $bSafe = true) {
114: switch ($name) {
115: case 'idartlang':
116: case 'idtype':
117: case 'typeid':
118: case 'version':
119: $value = (int) $value;
120: break;
121: }
122:
123: parent::setField($name, $value, $bSafe);
124: }
125:
126: 127: 128: 129: 130: 131: 132: 133:
134: public function loadByArticleLanguageIdTypeAndTypeId($idartlang, $idtype, $typeid) {
135: $aProps = array(
136: 'idartlang' => $idartlang,
137: 'idtype' => $idtype,
138: 'typeid' => $typeid
139: );
140: $aRecordSet = $this->_oCache->getItemByProperties($aProps);
141: if ($aRecordSet) {
142:
143: $this->loadByRecordSet($aRecordSet);
144: return true;
145: } else {
146: $where = $this->db->prepare("idartlang = %d AND idtype = %d AND typeid = %d", $idartlang, $idtype, $typeid);
147: return $this->_loadByWhereClause($where);
148: }
149: }
150:
151: }
152: