Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • 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
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • 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
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • 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:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Timo Hummel
 10:  * @copyright        four for business AG <www.4fb.de>
 11:  * @license          http://www.contenido.org/license/LIZENZ.txt
 12:  * @link             http://www.4fb.de
 13:  * @link             http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Category language collection
 20:  *
 21:  * @package Core
 22:  * @subpackage GenericDB_Model
 23:  */
 24: class cApiCategoryLanguageCollection extends ItemCollection {
 25: 
 26:     /**
 27:      * Constructor function.
 28:      *
 29:      * @param string $select Select statement (see ItemCollection::select())
 30:      */
 31:     public function __construct($select = false) {
 32:         global $cfg;
 33:         parent::__construct($cfg['tab']['cat_lang'], 'idcatlang');
 34:         $this->_setItemClass('cApiCategoryLanguage');
 35: 
 36:         // set the join partners so that joins can be used via link() method
 37:         $this->_setJoinPartner('cApiCategoryCollection');
 38:         $this->_setJoinPartner('cApiLanguageCollection');
 39:         $this->_setJoinPartner('cApiTemplateConfigurationCollection');
 40: 
 41:         if ($select !== false) {
 42:             $this->select($select);
 43:         }
 44:     }
 45: 
 46:     /**
 47:      * Creates a category language entry.
 48:      *
 49:      * @param int $idcat
 50:      * @param int $idlang
 51:      * @param string $name
 52:      * @param string $urlname
 53:      * @param string $urlpath
 54:      * @param int $idtplcfg
 55:      * @param int $visible
 56:      * @param int $public
 57:      * @param int $status
 58:      * @param string $author
 59:      * @param int $startidartlang
 60:      * @param string $created
 61:      * @param string $lastmodified
 62:      * @return cApiCategoryLanguage
 63:      */
 64:     public function create($idcat, $idlang, $name, $urlname, $urlpath = '', $idtplcfg = 0, $visible = 0, $public = 0, $status = 0, $author = '', $startidartlang = 0, $created = '', $lastmodified = '') {
 65:         global $auth;
 66: 
 67:         if (empty($author)) {
 68:             $author = $auth->auth['uname'];
 69:         }
 70:         if (empty($created)) {
 71:             $created = date('Y-m-d H:i:s');
 72:         }
 73:         if (empty($lastmodified)) {
 74:             $lastmodified = date('Y-m-d H:i:s');
 75:         }
 76: 
 77:         $oItem = parent::createNewItem();
 78: 
 79:         $oItem->set('idcat', $idcat);
 80:         $oItem->set('idlang', $idlang);
 81:         $oItem->set('name', $name);
 82:         $oItem->set('urlname', $urlname);
 83:         $oItem->set('urlpath', $urlpath);
 84:         $oItem->set('idtplcfg', $idtplcfg);
 85:         $oItem->set('visible', $visible);
 86:         $oItem->set('public', $public);
 87:         $oItem->set('status', $status);
 88:         $oItem->set('author', $author);
 89:         $oItem->set('created', $created);
 90:         $oItem->set('lastmodified', $lastmodified);
 91:         $oItem->store();
 92: 
 93:         return $oItem;
 94:     }
 95: 
 96:     /**
 97:      * Returns startidartlang of articlelanguage by category id and language id
 98:      *
 99:      * @param int $idcat
100:      * @param int $idlang
101:      * @return int
102:      */
103:     public function getStartIdartlangByIdcatAndIdlang($idcat, $idlang) {
104:         $sql = "SELECT startidartlang FROM `" . $this->table . "` WHERE idcat = " . (int) $idcat . " AND idlang = " . (int) $idlang . " AND startidartlang != 0";
105:         $this->db->query($sql);
106:         return ($this->db->nextRecord())? $this->db->f('startidartlang') : 0;
107:     }
108: 
109:     /**
110:      * Returns article id of articlelanguages startarticle by category id and
111:      * language id
112:      *
113:      * @param int $idcat
114:      * @param int $idlang
115:      * @return int
116:      */
117:     public function getStartIdartByIdcatAndIdlang($idcat, $idlang) {
118:         global $cfg;
119:         $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";
120:         $this->db->query($sql);
121:         return ($this->db->nextRecord())? $this->db->f('idart') : 0;
122:     }
123: 
124:     /**
125:      * Checks if passed idartlang is a start article.
126:      *
127:      * @param int $idartlang
128:      * @param int $idcat Check category id additionally
129:      * @param int $idlang Check language id additionally
130:      * @return bool
131:      */
132:     public function isStartArticle($idartlang, $idcat = null, $idlang = null) {
133:         $where = 'startidartlang = ' . (int) $idartlang;
134:         if (is_numeric($idcat)) {
135:             $where .= ' AND idcat = ' . $idcat;
136:         }
137:         if (is_numeric($idlang)) {
138:             $where .= ' AND idlang = ' . $idlang;
139:         }
140:         $where .= ' AND startidartlang != 0';
141: 
142:         $sql = "SELECT startidartlang FROM `" . $this->table . "` WHERE " . $where;
143:         $this->db->query($sql);
144:         return ($this->db->nextRecord() && $this->db->f('startidartlang') != 0);
145:     }
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 Specifies the ID of item to load
161:      */
162:     public function __construct($mId = false) {
163:         global $cfg;
164:         parent::__construct($cfg['tab']['cat_lang'], 'idcatlang');
165:         $this->setFilters(array(), array());
166:         if ($mId !== false) {
167:             $this->loadByPrimaryKey($mId);
168:         }
169:     }
170: 
171:     /**
172:      * Load data by category id and language id
173:      *
174:      * @param int $idcat Category id
175:      * @param int $idlang Language id
176:      * @return bool true on success, otherwhise false
177:      */
178:     public function loadByCategoryIdAndLanguageId($idcat, $idlang) {
179:         $aProps = array(
180:             'idcat' => $idcat,
181:             'idlang' => $idlang
182:         );
183:         $aRecordSet = $this->_oCache->getItemByProperties($aProps);
184:         if ($aRecordSet) {
185:             // entry in cache found, load entry from cache
186:             $this->loadByRecordSet($aRecordSet);
187:             return true;
188:         } else {
189:             $where = $this->db->prepare('idcat = %d AND idlang = %d', $idcat, $idlang);
190:             return $this->_loadByWhereClause($where);
191:         }
192:     }
193: 
194:     /**
195:      * Userdefined setter for article language fields.
196:      *
197:      * @param string $name
198:      * @param mixed $value
199:      * @param bool $safe Flag to run defined inFilter on passed value
200:      */
201:     public function setField($name, $value, $safe = true) {
202:         switch ($name) {
203:             case 'name':
204:                 $this->setField('urlname', conHtmlSpecialChars($value, ENT_QUOTES), $safe);
205:                 break;
206:             case 'urlname':
207:                 $value = conHtmlSpecialChars(cApiStrCleanURLCharacters($value), ENT_QUOTES);
208:                 break;
209:             case 'visible':
210:             case 'public':
211:                 $value = ($value == 1)? 1 : 0;
212:                 break;
213:             case 'idcat':
214:             case 'idlang':
215:             case 'idtplcfg':
216:             case 'status':
217:                 $value = (int) $value;
218:                 break;
219:         }
220: 
221:         parent::setField($name, $value, $safe);
222:     }
223: 
224:     /**
225:      * Assigns the passed template to the category language item.
226:      *
227:      * @param int $idtpl
228:      * @return cApiTemplateConfiguration
229:      */
230:     public function assignTemplate($idtpl) {
231:         $oTplConfColl = new cApiTemplateConfigurationCollection();
232: 
233:         if ($this->get('idtplcfg') != 0) {
234:             // Remove old template first
235:             $oTplConfColl->delete($this->get('idtplcfg'));
236:         }
237: 
238:         $oTplConf = $oTplConfColl->create($idtpl);
239: 
240:         // If there is a preconfiguration of template, copy its settings into
241:         // templateconfiguration
242:         $oTplConfColl->copyTemplatePreconfiguration($idtpl, $oTplConf->get('idtplcfg'));
243: 
244:         $this->set('idtplcfg', $oTplConf->get('idtplcfg'));
245:         $this->store();
246: 
247:         return $oTplConf;
248:     }
249: 
250:     /**
251:      * Returns id of template where this item is configured
252:      *
253:      * @return int
254:      */
255:     public function getTemplate() {
256:         $oTplConf = new cApiTemplateConfiguration($this->get('idtplcfg'));
257:         return $oTplConf->get('idtpl');
258:     }
259: 
260:     /**
261:      * Checks if category language item has a start article
262:      *
263:      * @return bool
264:      */
265:     public function hasStartArticle() {
266:         cInclude('includes', 'functions.str.php');
267:         return strHasStartArticle($this->get('idcat'), $this->get('idlang'));
268:     }
269: 
270:     /**
271:      * Updates lastmodified field and calls parents store method
272:      *
273:      * @return bool
274:      */
275:     public function store() {
276:         $this->set('lastmodified', date('Y-m-d H:i:s'));
277:         return parent::store();
278:     }
279: 
280:     /**
281:      * Returns the link to the current object.
282:      * @param integer $changeLangId change language id for URL (optional)
283:      * @return string link
284:      */
285:     public function getLink($changeLangId = 0) {
286:         if ($this->isLoaded() === false) {
287:             return '';
288:         }
289: 
290:         $options = array();
291:         $options['idcat'] = $this->get('idcat');
292:         $options['lang'] = ($changeLangId == 0) ? $this->get('idlang') : $changeLangId;
293:         if ($changeLangId > 0) {
294:             $options['changelang'] = $changeLangId;
295:         }
296: 
297:         return cUri::getInstance()->build($options);
298:     }
299: 
300: }
301: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0