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