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