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