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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • 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:     /**
 25:      * Create a new collection of items.
 26:      *
 27:      * @param string $select [optional]
 28:      *         where clause to use for selection (see ItemCollection::select())
 29:      */
 30:     public function __construct($select = false) {
 31:         global $cfg;
 32:         parent::__construct($cfg['tab']['cat_lang'], 'idcatlang');
 33:         $this->_setItemClass('cApiCategoryLanguage');
 34: 
 35:         // set the join partners so that joins can be used via link() method
 36:         $this->_setJoinPartner('cApiCategoryCollection');
 37:         $this->_setJoinPartner('cApiLanguageCollection');
 38:         $this->_setJoinPartner('cApiTemplateConfigurationCollection');
 39: 
 40:         if ($select !== false) {
 41:             $this->select($select);
 42:         }
 43:     }
 44: 
 45:     /**
 46:      * Creates a category language entry.
 47:      *
 48:      * @param int $idcat
 49:      * @param int $idlang
 50:      * @param string $name
 51:      * @param string $urlname
 52:      * @param string $urlpath [optional]
 53:      * @param int $idtplcfg [optional]
 54:      * @param int $visible [optional]
 55:      * @param int $public [optional]
 56:      * @param int $status [optional]
 57:      * @param string $author [optional]
 58:      * @param int $startidartlang [optional]
 59:      * @param string $created [optional]
 60:      * @param string $lastmodified [optional]
 61:      * @return cApiCategoryLanguage
 62:      */
 63:     public function create($idcat, $idlang, $name, $urlname, $urlpath = '', $idtplcfg = 0, $visible = 0, $public = 0, $status = 0, $author = '', $startidartlang = 0, $created = '', $lastmodified = '') {
 64:         global $auth;
 65: 
 66:         if (empty($author)) {
 67:             $author = $auth->auth['uname'];
 68:         }
 69:         if (empty($created)) {
 70:             $created = date('Y-m-d H:i:s');
 71:         }
 72:         if (empty($lastmodified)) {
 73:             $lastmodified = date('Y-m-d H:i:s');
 74:         }
 75: 
 76:         $oItem = $this->createNewItem();
 77: 
 78:         $oItem->set('idcat', $idcat);
 79:         $oItem->set('idlang', $idlang);
 80:         $oItem->set('name', $name);
 81:         $oItem->set('urlname', $urlname);
 82:         $oItem->set('urlpath', $urlpath);
 83:         $oItem->set('idtplcfg', $idtplcfg);
 84:         $oItem->set('visible', $visible);
 85:         $oItem->set('public', $public);
 86:         $oItem->set('status', $status);
 87:         $oItem->set('author', $author);
 88:         $oItem->set('created', $created);
 89:         $oItem->set('lastmodified', $lastmodified);
 90:         $oItem->store();
 91: 
 92:         return $oItem;
 93:     }
 94: 
 95:     /**
 96:      * Returns startidartlang of articlelanguage by category id and language id
 97:      *
 98:      * @param int $idcat
 99:      * @param int $idlang
100:      * @return int
101:      */
102:     public function getStartIdartlangByIdcatAndIdlang($idcat, $idlang) {
103:         $sql = "SELECT startidartlang FROM `" . $this->table . "` WHERE idcat = " . (int) $idcat . " AND idlang = " . (int) $idlang . " AND startidartlang != 0";
104:         $this->db->query($sql);
105:         return ($this->db->nextRecord()) ? $this->db->f('startidartlang') : 0;
106:     }
107: 
108:     /**
109:      * Returns article id of articlelanguages startarticle by category id and
110:      * language id
111:      *
112:      * @param int $idcat
113:      * @param int $idlang
114:      * @return int
115:      */
116:     public function getStartIdartByIdcatAndIdlang($idcat, $idlang) {
117:         global $cfg;
118:         $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";
119:         $this->db->query($sql);
120:         return ($this->db->nextRecord()) ? $this->db->f('idart') : 0;
121:     }
122: 
123:     /**
124:      * Checks if passed idartlang is a start article.
125:      *
126:      * @param int $idartlang
127:      * @param int $idcat [optional]
128:      *         Check category id additionally
129:      * @param int $idlang [optional]
130:      *         Check language id additionally
131:      * @return bool
132:      */
133:     public function isStartArticle($idartlang, $idcat = NULL, $idlang = NULL) {
134:         $where = 'startidartlang = ' . (int) $idartlang;
135:         if (is_numeric($idcat)) {
136:             $where .= ' AND idcat = ' . $idcat;
137:         }
138:         if (is_numeric($idlang)) {
139:             $where .= ' AND idlang = ' . $idlang;
140:         }
141:         $where .= ' AND startidartlang != 0';
142: 
143:         $sql = "SELECT startidartlang FROM `" . $this->table . "` WHERE " . $where;
144:         $this->db->query($sql);
145:         return ($this->db->nextRecord() && $this->db->f('startidartlang') != 0);
146:     }
147: }
148: 
149: /**
150:  * Category language item
151:  *
152:  * @package Core
153:  * @subpackage GenericDB_Model
154:  */
155: class cApiCategoryLanguage extends Item {
156: 
157:     /**
158:      * Constructor Function
159:      *
160:      * @param mixed $mId [optional]
161:      *         Specifies the ID of item to load
162:      */
163:     public function __construct($mId = false) {
164:         global $cfg;
165:         parent::__construct($cfg['tab']['cat_lang'], 'idcatlang');
166:         $this->setFilters(array(), array());
167:         if ($mId !== false) {
168:             $this->loadByPrimaryKey($mId);
169:         }
170:     }
171: 
172:     /**
173:      * Load data by category id and language id
174:      *
175:      * @param int $idcat
176:      *         Category id
177:      * @param int $idlang
178:      *         Language id
179:      * @return bool
180:      *         true on success, otherwise false
181:      */
182:     public function loadByCategoryIdAndLanguageId($idcat, $idlang) {
183:         $aProps = array(
184:             'idcat' => $idcat,
185:             'idlang' => $idlang
186:         );
187:         $aRecordSet = $this->_oCache->getItemByProperties($aProps);
188:         if ($aRecordSet) {
189:             // entry in cache found, load entry from cache
190:             $this->loadByRecordSet($aRecordSet);
191:             return true;
192:         } else {
193:             $where = $this->db->prepare('idcat = %d AND idlang = %d', $idcat, $idlang);
194:             return $this->_loadByWhereClause($where);
195:         }
196:     }
197: 
198:     /**
199:      * Userdefined setter for article language fields.
200:      *
201:      * @todo should return return value of overloaded method
202:      * @param string $name
203:      * @param mixed $value
204:      * @param bool $safe [optional]
205:      *         Flag to run defined inFilter on passed value
206:      */
207:     public function setField($name, $value, $safe = true) {
208:         switch ($name) {
209:             case 'name':
210:                 $this->setField('urlname', conHtmlSpecialChars($value, ENT_QUOTES), $safe);
211:                 break;
212:             case 'urlname':
213:                 $value = conHtmlSpecialChars(cString::cleanURLCharacters($value), ENT_QUOTES);
214:                 break;
215:             case 'visible':
216:             case 'public':
217:                 $value = ($value == 1) ? 1 : 0;
218:                 break;
219:             case 'idcat':
220:             case 'idlang':
221:             case 'idtplcfg':
222:             case 'status':
223:                 $value = (int) $value;
224:                 break;
225:         }
226: 
227:         parent::setField($name, $value, $safe);
228:     }
229: 
230:     /**
231:      * Assigns the passed template to the category language item.
232:      *
233:      * @param int $idtpl
234:      * @return cApiTemplateConfiguration
235:      */
236:     public function assignTemplate($idtpl) {
237:         $oTplConfColl = new cApiTemplateConfigurationCollection();
238: 
239:         if ($this->get('idtplcfg') != 0) {
240:             // Remove old template first
241:             $oTplConfColl->delete($this->get('idtplcfg'));
242:         }
243: 
244:         $oTplConf = $oTplConfColl->create($idtpl);
245: 
246:         // If there is a preconfiguration of template, copy its settings into
247:         // templateconfiguration
248:         $oTplConfColl->copyTemplatePreconfiguration($idtpl, $oTplConf->get('idtplcfg'));
249: 
250:         $this->set('idtplcfg', $oTplConf->get('idtplcfg'));
251:         $this->store();
252: 
253:         return $oTplConf;
254:     }
255: 
256:     /**
257:      * Returns id of template where this item is configured
258:      *
259:      * @return int
260:      */
261:     public function getTemplate() {
262:         $oTplConf = new cApiTemplateConfiguration($this->get('idtplcfg'));
263:         return $oTplConf->get('idtpl');
264:     }
265: 
266:     /**
267:      * Checks if category language item has a start article
268:      *
269:      * @return bool
270:      */
271:     public function hasStartArticle() {
272:         cInclude('includes', 'functions.str.php');
273:         return strHasStartArticle($this->get('idcat'), $this->get('idlang'));
274:     }
275: 
276:     /**
277:      * Updates lastmodified field and calls parents store method
278:      *
279:      * @return bool
280:      */
281:     public function store() {
282:         $this->set('lastmodified', date('Y-m-d H:i:s'));
283:         return parent::store();
284:     }
285: 
286:     /**
287:      * Returns the link to the current object.
288:      *
289:      * @param int $changeLangId [optional]
290:      *         change language id for URL (optional)
291:      * @return string
292:      *         link
293:      */
294:     public function getLink($changeLangId = 0) {
295:         if ($this->isLoaded() === false) {
296:             return '';
297:         }
298: 
299:         $options = array();
300:         $options['idcat'] = $this->get('idcat');
301:         $options['lang'] = ($changeLangId == 0) ? $this->get('idlang') : $changeLangId;
302:         if ($changeLangId > 0) {
303:             $options['changelang'] = $changeLangId;
304:         }
305: 
306:         return cUri::getInstance()->build($options);
307:     }
308: }
309: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0