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
    • 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
  • cApiSearchTracking
  • cApiSearchTrackingCollection
  • 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:      * Create a new collection of items.
 28:      *
 29:      * @param string $select where clause to use for selection (see
 30:      *            ItemCollection::select())
 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
 55:      * @param int $idtplcfg
 56:      * @param int $visible
 57:      * @param int $public
 58:      * @param int $status
 59:      * @param string $author
 60:      * @param int $startidartlang
 61:      * @param string $created
 62:      * @param string $lastmodified
 63:      * @return cApiCategoryLanguage
 64:      */
 65:     public function create($idcat, $idlang, $name, $urlname, $urlpath = '', $idtplcfg = 0, $visible = 0, $public = 0, $status = 0, $author = '', $startidartlang = 0, $created = '', $lastmodified = '') {
 66:         global $auth;
 67: 
 68:         if (empty($author)) {
 69:             $author = $auth->auth['uname'];
 70:         }
 71:         if (empty($created)) {
 72:             $created = date('Y-m-d H:i:s');
 73:         }
 74:         if (empty($lastmodified)) {
 75:             $lastmodified = date('Y-m-d H:i:s');
 76:         }
 77: 
 78:         $oItem = parent::createNewItem();
 79: 
 80:         $oItem->set('idcat', $idcat);
 81:         $oItem->set('idlang', $idlang);
 82:         $oItem->set('name', $name);
 83:         $oItem->set('urlname', $urlname);
 84:         $oItem->set('urlpath', $urlpath);
 85:         $oItem->set('idtplcfg', $idtplcfg);
 86:         $oItem->set('visible', $visible);
 87:         $oItem->set('public', $public);
 88:         $oItem->set('status', $status);
 89:         $oItem->set('author', $author);
 90:         $oItem->set('created', $created);
 91:         $oItem->set('lastmodified', $lastmodified);
 92:         $oItem->store();
 93: 
 94:         return $oItem;
 95:     }
 96: 
 97:     /**
 98:      * Returns startidartlang of articlelanguage by category id and language id
 99:      *
100:      * @param int $idcat
101:      * @param int $idlang
102:      * @return int
103:      */
104:     public function getStartIdartlangByIdcatAndIdlang($idcat, $idlang) {
105:         $sql = "SELECT startidartlang FROM `" . $this->table . "` WHERE idcat = " . (int) $idcat . " AND idlang = " . (int) $idlang . " AND startidartlang != 0";
106:         $this->db->query($sql);
107:         return ($this->db->nextRecord()) ? $this->db->f('startidartlang') : 0;
108:     }
109: 
110:     /**
111:      * Returns article id of articlelanguages startarticle by category id and
112:      * language id
113:      *
114:      * @param int $idcat
115:      * @param int $idlang
116:      * @return int
117:      */
118:     public function getStartIdartByIdcatAndIdlang($idcat, $idlang) {
119:         global $cfg;
120:         $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";
121:         $this->db->query($sql);
122:         return ($this->db->nextRecord()) ? $this->db->f('idart') : 0;
123:     }
124: 
125:     /**
126:      * Checks if passed idartlang is a start article.
127:      *
128:      * @param int $idartlang
129:      * @param int $idcat Check category id additionally
130:      * @param int $idlang 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 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:      * @todo should return return value of overloaded method
201:      */
202:     public function setField($name, $value, $safe = true) {
203:         switch ($name) {
204:             case 'name':
205:                 $this->setField('urlname', conHtmlSpecialChars($value, ENT_QUOTES), $safe);
206:                 break;
207:             case 'urlname':
208:                 $value = conHtmlSpecialChars(cApiStrCleanURLCharacters($value), ENT_QUOTES);
209:                 break;
210:             case 'visible':
211:             case 'public':
212:                 $value = ($value == 1) ? 1 : 0;
213:                 break;
214:             case 'idcat':
215:             case 'idlang':
216:             case 'idtplcfg':
217:             case 'status':
218:                 $value = (int) $value;
219:                 break;
220:         }
221: 
222:         parent::setField($name, $value, $safe);
223:     }
224: 
225:     /**
226:      * Assigns the passed template to the category language item.
227:      *
228:      * @param int $idtpl
229:      * @return cApiTemplateConfiguration
230:      */
231:     public function assignTemplate($idtpl) {
232:         $oTplConfColl = new cApiTemplateConfigurationCollection();
233: 
234:         if ($this->get('idtplcfg') != 0) {
235:             // Remove old template first
236:             $oTplConfColl->delete($this->get('idtplcfg'));
237:         }
238: 
239:         $oTplConf = $oTplConfColl->create($idtpl);
240: 
241:         // If there is a preconfiguration of template, copy its settings into
242:         // templateconfiguration
243:         $oTplConfColl->copyTemplatePreconfiguration($idtpl, $oTplConf->get('idtplcfg'));
244: 
245:         $this->set('idtplcfg', $oTplConf->get('idtplcfg'));
246:         $this->store();
247: 
248:         return $oTplConf;
249:     }
250: 
251:     /**
252:      * Returns id of template where this item is configured
253:      *
254:      * @return int
255:      */
256:     public function getTemplate() {
257:         $oTplConf = new cApiTemplateConfiguration($this->get('idtplcfg'));
258:         return $oTplConf->get('idtpl');
259:     }
260: 
261:     /**
262:      * Checks if category language item has a start article
263:      *
264:      * @return bool
265:      */
266:     public function hasStartArticle() {
267:         cInclude('includes', 'functions.str.php');
268:         return strHasStartArticle($this->get('idcat'), $this->get('idlang'));
269:     }
270: 
271:     /**
272:      * Updates lastmodified field and calls parents store method
273:      *
274:      * @return bool
275:      */
276:     public function store() {
277:         $this->set('lastmodified', date('Y-m-d H:i:s'));
278:         return parent::store();
279:     }
280: 
281:     /**
282:      * Returns the link to the current object.
283:      *
284:      * @param int $changeLangId change language id for URL (optional)
285:      * @return string link
286:      */
287:     public function getLink($changeLangId = 0) {
288:         if ($this->isLoaded() === false) {
289:             return '';
290:         }
291: 
292:         $options = array();
293:         $options['idcat'] = $this->get('idcat');
294:         $options['lang'] = ($changeLangId == 0) ? $this->get('idlang') : $changeLangId;
295:         if ($changeLangId > 0) {
296:             $options['changelang'] = $changeLangId;
297:         }
298: 
299:         return cUri::getInstance()->build($options);
300:     }
301: }
302: 
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0