Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cApiAction
  • cApiActionCollection
  • cApiActionlog
  • cApiActionlogCollection
  • cApiArea
  • cApiAreaCollection
  • cApiArticle
  • cApiArticleCollection
  • cApiArticleLanguage
  • cApiArticleLanguageCollection
  • cApiArticleLanguageVersion
  • cApiArticleLanguageVersionCollection
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • cApiContentVersion
  • cApiContentVersionCollection
  • cApiDbfs
  • cApiDbfsCollection
  • cApiFile
  • cApiFileCollection
  • cApiFileInformation
  • cApiFileInformationCollection
  • cApiFrameFile
  • cApiFrameFileCollection
  • cApiFrontendGroup
  • cApiFrontendGroupCollection
  • cApiFrontendGroupMember
  • cApiFrontendGroupMemberCollection
  • cApiFrontendPermission
  • cApiFrontendPermissionCollection
  • cApiFrontendUser
  • cApiFrontendUserCollection
  • cApiGroup
  • cApiGroupCollection
  • cApiGroupMember
  • cApiGroupMemberCollection
  • cApiGroupProperty
  • cApiGroupPropertyCollection
  • cApiInUse
  • cApiInUseCollection
  • cApiIso3166
  • cApiIso3166Collection
  • cApiIso6392
  • cApiIso6392Collection
  • cApiKeyword
  • cApiKeywordCollection
  • cApiLanguage
  • cApiLanguageCollection
  • cApiLayout
  • cApiLayoutCollection
  • cApiMailLog
  • cApiMailLogCollection
  • cApiMailLogSuccess
  • cApiMailLogSuccessCollection
  • cApiMetaTag
  • cApiMetaTagCollection
  • cApiMetaTagVersion
  • cApiMetaTagVersionCollection
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiSearchTracking
  • cApiSearchTrackingCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • cApiUserPasswordRequest
  • cApiUserPasswordRequestCollection
  • cApiUserProperty
  • cApiUserPropertyCollection
  • NoteCollection
  • NoteItem
  • TODOCollection
  • TODOItem
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the category language collection and item class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GenericDB_Model
  7:  * @author Timo Hummel
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * Category language collection
 18:  *
 19:  * @package Core
 20:  * @subpackage GenericDB_Model
 21:  */
 22: class cApiCategoryLanguageCollection extends ItemCollection {
 23:     /**
 24:      * Constructor to create an instance of this class.
 25:      *
 26:      * @param bool $select [optional]
 27:      *                     where clause to use for selection (see ItemCollection::select())
 28:      *
 29:      * @throws cDbException
 30:      * @throws cInvalidArgumentException
 31:      */
 32:     public function __construct($select = false) {
 33:         global $cfg;
 34:         parent::__construct($cfg['tab']['cat_lang'], 'idcatlang');
 35:         $this->_setItemClass('cApiCategoryLanguage');
 36: 
 37:         // set the join partners so that joins can be used via link() method
 38:         $this->_setJoinPartner('cApiCategoryCollection');
 39:         $this->_setJoinPartner('cApiLanguageCollection');
 40:         $this->_setJoinPartner('cApiTemplateConfigurationCollection');
 41: 
 42:         if ($select !== false) {
 43:             $this->select($select);
 44:         }
 45:     }
 46: 
 47:     /**
 48:      * Creates a category language entry.
 49:      *
 50:      * @param int    $idcat
 51:      * @param int    $idlang
 52:      * @param string $name
 53:      * @param string $urlname
 54:      * @param string $urlpath        [optional]
 55:      * @param int    $idtplcfg       [optional]
 56:      * @param int    $visible        [optional]
 57:      * @param int    $public         [optional]
 58:      * @param int    $status         [optional]
 59:      * @param string $author         [optional]
 60:      * @param int    $startidartlang [optional]
 61:      * @param string $created        [optional]
 62:      * @param string $lastmodified   [optional]
 63:      *
 64:      * @return cApiCategoryLanguage
 65:      * @throws cDbException
 66:      * @throws cException
 67:      * @throws cInvalidArgumentException
 68:      */
 69:     public function create($idcat, $idlang, $name, $urlname, $urlpath = '', $idtplcfg = 0, $visible = 0, $public = 0, $status = 0, $author = '', $startidartlang = 0, $created = '', $lastmodified = '') {
 70:         global $auth;
 71: 
 72:         if (empty($author)) {
 73:             $author = $auth->auth['uname'];
 74:         }
 75:         if (empty($created)) {
 76:             $created = date('Y-m-d H:i:s');
 77:         }
 78:         if (empty($lastmodified)) {
 79:             $lastmodified = date('Y-m-d H:i:s');
 80:         }
 81: 
 82:         $oItem = $this->createNewItem();
 83: 
 84:         $oItem->set('idcat', $idcat);
 85:         $oItem->set('idlang', $idlang);
 86:         $oItem->set('name', $name);
 87:         $oItem->set('urlname', $urlname);
 88:         $oItem->set('urlpath', $urlpath);
 89:         $oItem->set('idtplcfg', $idtplcfg);
 90:         $oItem->set('visible', $visible);
 91:         $oItem->set('public', $public);
 92:         $oItem->set('status', $status);
 93:         $oItem->set('author', $author);
 94:         $oItem->set('created', $created);
 95:         $oItem->set('lastmodified', $lastmodified);
 96:         $oItem->store();
 97: 
 98:         return $oItem;
 99:     }
100: 
101:     /**
102:      * Returns startidartlang of articlelanguage by category id and language id
103:      *
104:      * @param int $idcat
105:      * @param int $idlang
106:      * @return int
107:      * @throws cDbException
108:      */
109:     public function getStartIdartlangByIdcatAndIdlang($idcat, $idlang) {
110:         $sql = "SELECT startidartlang FROM `" . $this->table . "` WHERE idcat = " . (int) $idcat . " AND idlang = " . (int) $idlang . " AND startidartlang != 0";
111:         $this->db->query($sql);
112:         return ($this->db->nextRecord()) ? $this->db->f('startidartlang') : 0;
113:     }
114: 
115:     /**
116:      * Returns article id of articlelanguages startarticle by category id and
117:      * language id
118:      *
119:      * @param int $idcat
120:      * @param int $idlang
121:      * @return int
122:      * @throws cDbException
123:      */
124:     public function getStartIdartByIdcatAndIdlang($idcat, $idlang) {
125:         global $cfg;
126:         $sql = "SELECT al.idart FROM `" . $cfg['tab']['art_lang'] . "` AS al, `" . $this->table . "` " . "AS cl WHERE cl.idcat = " . (int) $idcat . " AND cl.startidartlang != 0 AND " . "cl.idlang = " . (int) $idlang . " AND cl.idlang = al.idlang AND cl.startidartlang = al.idartlang";
127:         $this->db->query($sql);
128:         return ($this->db->nextRecord()) ? $this->db->f('idart') : 0;
129:     }
130: 
131:     /**
132:      * Checks if passed idartlang is a start article.
133:      *
134:      * @param int $idartlang
135:      * @param int $idcat  [optional]
136:      *                    Check category id additionally
137:      * @param int $idlang [optional]
138:      *                    Check language id additionally
139:      * @return bool
140:      * @throws cDbException
141:      */
142:     public function isStartArticle($idartlang, $idcat = NULL, $idlang = NULL) {
143:         $where = 'startidartlang = ' . (int) $idartlang;
144:         if (is_numeric($idcat)) {
145:             $where .= ' AND idcat = ' . $idcat;
146:         }
147:         if (is_numeric($idlang)) {
148:             $where .= ' AND idlang = ' . $idlang;
149:         }
150:         $where .= ' AND startidartlang != 0';
151: 
152:         $sql = "SELECT startidartlang FROM `" . $this->table . "` WHERE " . $where;
153:         $this->db->query($sql);
154:         return ($this->db->nextRecord() && $this->db->f('startidartlang') != 0);
155:     }
156: }
157: 
158: /**
159:  * Category language item
160:  *
161:  * @package Core
162:  * @subpackage GenericDB_Model
163:  */
164: class cApiCategoryLanguage extends Item
165: {
166:     /**
167:      * Constructor to create an instance of this class.
168:      *
169:      * @param mixed $mId [optional]
170:      *                   Specifies the ID of item to load
171:      *
172:      * @throws cDbException
173:      * @throws cException
174:      */
175:     public function __construct($mId = false) {
176:         global $cfg;
177:         parent::__construct($cfg['tab']['cat_lang'], 'idcatlang');
178:         $this->setFilters(array(), array());
179:         if ($mId !== false) {
180:             $this->loadByPrimaryKey($mId);
181:         }
182:     }
183: 
184:     /**
185:      * Load data by category id and language id
186:      *
187:      * @param int $idcat
188:      *         Category id
189:      * @param int $idlang
190:      *         Language id
191:      *
192:      * @return bool
193:      *         true on success, otherwise false
194:      * 
195:      * @throws cException
196:      */
197:     public function loadByCategoryIdAndLanguageId($idcat, $idlang) {
198:         $aProps = array(
199:             'idcat' => $idcat,
200:             'idlang' => $idlang
201:         );
202:         $aRecordSet = $this->_oCache->getItemByProperties($aProps);
203:         if ($aRecordSet) {
204:             // entry in cache found, load entry from cache
205:             $this->loadByRecordSet($aRecordSet);
206:             return true;
207:         } else {
208:             $where = $this->db->prepare('idcat = %d AND idlang = %d', $idcat, $idlang);
209:             return $this->_loadByWhereClause($where);
210:         }
211:     }
212: 
213:     /**
214:      * Userdefined setter for article language fields.
215:      *
216:      * @param string $name
217:      * @param mixed $value
218:      * @param bool $safe [optional]
219:      *         Flag to run defined inFilter on passed value
220:      *
221:      * @return bool
222:      */
223:     public function setField($name, $value, $safe = true) {
224:         switch ($name) {
225:             case 'name':
226:                 $this->setField('urlname', conHtmlSpecialChars($value, ENT_QUOTES), $safe);
227:                 break;
228:             case 'urlname':
229:                 $value = conHtmlSpecialChars(cString::cleanURLCharacters($value), ENT_QUOTES);
230:                 break;
231:             case 'visible':
232:             case 'public':
233:                 $value = ($value == 1) ? 1 : 0;
234:                 break;
235:             case 'idcat':
236:             case 'idlang':
237:             case 'idtplcfg':
238:             case 'status':
239:                 $value = (int) $value;
240:                 break;
241:         }
242: 
243:         return parent::setField($name, $value, $safe);
244:     }
245: 
246:     /**
247:      * Assigns the passed template to the category language item.
248:      *
249:      * @param int $idtpl
250:      * 
251:      * @return cApiTemplateConfiguration
252:      * 
253:      * @throws cDbException
254:      * @throws cException
255:      * @throws cInvalidArgumentException
256:      */
257:     public function assignTemplate($idtpl) {
258:         $oTplConfColl = new cApiTemplateConfigurationCollection();
259: 
260:         if ($this->get('idtplcfg') != 0) {
261:             // Remove old template first
262:             $oTplConfColl->delete($this->get('idtplcfg'));
263:         }
264: 
265:         $oTplConf = $oTplConfColl->create($idtpl);
266: 
267:         // If there is a preconfiguration of template, copy its settings into
268:         // templateconfiguration
269:         $oTplConfColl->copyTemplatePreconfiguration($idtpl, $oTplConf->get('idtplcfg'));
270: 
271:         $this->set('idtplcfg', $oTplConf->get('idtplcfg'));
272:         $this->store();
273: 
274:         return $oTplConf;
275:     }
276: 
277:     /**
278:      * Returns id of template where this item is configured
279:      *
280:      * @return int
281:      */
282:     public function getTemplate() {
283:         $oTplConf = new cApiTemplateConfiguration($this->get('idtplcfg'));
284:         return $oTplConf->get('idtpl');
285:     }
286: 
287:     /**
288:      * Checks if category language item has a start article
289:      *
290:      * @return bool
291:      */
292:     public function hasStartArticle() {
293:         cInclude('includes', 'functions.str.php');
294:         return strHasStartArticle($this->get('idcat'), $this->get('idlang'));
295:     }
296: 
297:     /**
298:      * Updates lastmodified field and calls parents store method
299:      *
300:      * @return bool
301:      * @throws cDbException
302:      * @throws cInvalidArgumentException
303:      */
304:     public function store() {
305:         $this->set('lastmodified', date('Y-m-d H:i:s'));
306:         return parent::store();
307:     }
308: 
309:     /**
310:      * Returns the link to the current object.
311:      *
312:      * @param int $changeLangId [optional]
313:      *                          change language id for URL (optional)
314:      *
315:      * @return string
316:      *         link
317:      * @throws cInvalidArgumentException
318:      */
319:     public function getLink($changeLangId = 0) {
320:         if ($this->isLoaded() === false) {
321:             return '';
322:         }
323: 
324:         $options = array();
325:         $options['idcat'] = $this->get('idcat');
326:         $options['lang'] = ($changeLangId == 0) ? $this->get('idlang') : $changeLangId;
327:         if ($changeLangId > 0) {
328:             $options['changelang'] = $changeLangId;
329:         }
330: 
331:         return cUri::getInstance()->build($options);
332:     }
333: }
334: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0