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 article language collection and item class.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       GenericDB_Model
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Bjoern Behrens
 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:  * Article language collection
 20:  *
 21:  * @package Core
 22:  * @subpackage GenericDB_Model
 23:  */
 24: class cApiArticleLanguageCollection extends ItemCollection {
 25:     public function __construct($select = false) {
 26:         global $cfg;
 27:         parent::__construct($cfg['tab']['art_lang'], 'idartlang');
 28:         $this->_setItemClass('cApiArticleLanguage');
 29: 
 30:         // set the join partners so that joins can be used via link() method
 31:         $this->_setJoinPartner('cApiArticleCollection');
 32:         $this->_setJoinPartner('cApiLanguageCollection');
 33:         $this->_setJoinPartner('cApiTemplateConfigurationCollection');
 34: 
 35:         if ($select !== false) {
 36:             $this->select($select);
 37:         }
 38:     }
 39: 
 40:     /**
 41:      * Creates an article language item entry.
 42:      *
 43:      * @global object $auth
 44:      * @param int $idart
 45:      * @param int $idlang
 46:      * @param string $title
 47:      * @param string $urlname
 48:      * @param string $pagetitle
 49:      * @param string $summary
 50:      * @param int $artspec
 51:      * @param string $created
 52:      * @param string $author
 53:      * @param string $lastmodified
 54:      * @param string $modifiedby
 55:      * @param string $published
 56:      * @param string $publishedby
 57:      * @param int $online
 58:      * @param int $redirect
 59:      * @param string $redirect_url
 60:      * @param int $external_redirect
 61:      * @param int $artsort
 62:      * @param int $timemgmt
 63:      * @param string $datestart
 64:      * @param string $dateend
 65:      * @param int $status
 66:      * @param int $time_move_cat
 67:      * @param int $time_target_cat
 68:      * @param int $time_online_move
 69:      * @param int $locked
 70:      * @param mixed $free_use_01
 71:      * @param mixed $free_use_02
 72:      * @param mixed $free_use_03
 73:      * @param int $searchable
 74:      * @param float $sitemapprio
 75:      * @param string $changefreq
 76:      * @return cApiArticleLanguage
 77:      */
 78:     public function create($idart, $idlang, $title, $urlname, $pagetitle, $summary, $artspec = 0, $created = '', $author = '', $lastmodified = '', $modifiedby = '', $published = '', $publishedby = '', $online = 0, $redirect = 0, $redirect_url = '', $external_redirect = 0, $artsort = 0, $timemgmt = 0, $datestart = '', $dateend = '', $status = 0, $time_move_cat = 0, $time_target_cat = 0, $time_online_move = 0, $locked = 0, $free_use_01 = '', $free_use_02 = '', $free_use_03 = '', $searchable = 1, $sitemapprio = 0.5, $changefreq = '') {
 79:         global $auth;
 80: 
 81:         if (empty($author)) {
 82:             $author = $auth->auth['uname'];
 83:         }
 84:         if (empty($created)) {
 85:             $created = date('Y-m-d H:i:s');
 86:         }
 87:         if (empty($lastmodified)) {
 88:             $lastmodified = date('Y-m-d H:i:s');
 89:         }
 90: 
 91:         $urlname = (trim($urlname) == '')? trim($title) : trim($urlname);
 92: 
 93:         $item = parent::createNewItem();
 94: 
 95:         $item->set('idart', $idart);
 96:         $item->set('idlang', $idlang);
 97:         $item->set('title', $title);
 98:         $item->set('urlname', $urlname);
 99:         $item->set('pagetitle', $pagetitle);
100:         $item->set('summary', $summary);
101:         $item->set('artspec', $artspec);
102:         $item->set('created', $created);
103:         $item->set('author', $author);
104:         $item->set('lastmodified', $lastmodified);
105:         $item->set('modifiedby', $modifiedby);
106:         $item->set('published', $published);
107:         $item->set('publishedby', $publishedby);
108:         $item->set('online', $online);
109:         $item->set('redirect', $redirect);
110:         $item->set('redirect_url', $redirect_url);
111:         $item->set('external_redirect', $external_redirect);
112:         $item->set('artsort', $artsort);
113:         $item->set('timemgmt', $timemgmt);
114:         $item->set('datestart', $datestart);
115:         $item->set('dateend', $dateend);
116:         $item->set('status', $status);
117:         $item->set('time_move_cat', $time_move_cat);
118:         $item->set('time_target_cat', $time_target_cat);
119:         $item->set('time_online_move', $time_online_move);
120:         $item->set('locked', $locked);
121:         $item->set('free_use_01', $free_use_01);
122:         $item->set('free_use_02', $free_use_02);
123:         $item->set('free_use_03', $free_use_03);
124:         $item->set('searchable', $searchable);
125:         $item->set('sitemapprio', $sitemapprio);
126:         $item->set('changefreq', $changefreq);
127: 
128:         $item->store();
129: 
130:         return $item;
131:     }
132: 
133:     /**
134:      * Returns id (idartlang) of articlelanguage by article id and language id
135:      *
136:      * @param int $idcat
137:      * @param int $idlang
138:      * @return int
139:      */
140:     public function getIdByArticleIdAndLanguageId($idart, $idlang) {
141:         $sql = "SELECT idartlang FROM `%s` WHERE idart = %d AND idlang = %d";
142:         $this->db->query($sql, $this->table, $idart, $idlang);
143:         return ($this->db->nextRecord())? $this->db->f('idartlang') : 0;
144:     }
145: 
146: }
147: 
148: /**
149:  * CONTENIDO API - Article Object
150:  *
151:  * This object represents a CONTENIDO article
152:  *
153:  * Create object with
154:  * $obj = new cApiArticleLanguage(idartlang);
155:  * or with
156:  * $obj = new cApiArticleLanguage();
157:  * $obj->loadByArticleAndLanguageId(idart, lang);
158:  *
159:  * You can now read the article properties with
160:  * $obj->getField(property);
161:  *
162:  * List of article properties:
163:  *
164:  * idartlang - Language dependant article id
165:  * idart - Language indepenant article id
166:  * idclient - Id of the client
167:  * idtplcfg - Template configuration id
168:  * title - Internal Title
169:  * pagetitle - HTML Title
170:  * summary - Article summary
171:  * created - Date created
172:  * lastmodified - Date lastmodiefied
173:  * author - Article author (username)
174:  * online - On-/offline
175:  * redirect - Redirect
176:  * redirect_url - Redirect URL
177:  * artsort - Article sort key
178:  * timemgmt - Time management
179:  * datestart - Time management start date
180:  * dateend - Time management end date
181:  * status - Article status
182:  * free_use_01 - Free to use
183:  * free_use_02 - Free to use
184:  * free_use_03 - Free to use
185:  * time_move_cat - Move category after time management
186:  * time_target_cat - Move category to this cat after time management
187:  * time_online_move - Set article online after move
188:  * external_redirect - Open article in new window
189:  * locked - Article is locked for editing
190:  * searchable - Whether article should be found via search
191:  * sitemapprio - The priority for the sitemap
192:  *
193:  * You can extract article content with the
194:  * $obj->getContent(contype [, number]) method.
195:  *
196:  * To extract the first headline you can use:
197:  *
198:  * $headline = $obj->getContent("htmlhead", 1);
199:  *
200:  * If the second parameter is ommitted the method returns an array with all
201:  * available
202:  * content of this type. The array has the following schema:
203:  *
204:  * array( number => content );
205:  *
206:  * $headlines = $obj->getContent("htmlhead");
207:  *
208:  * $headlines[1] First headline
209:  * $headlines[2] Second headline
210:  * $headlines[6] Sixth headline
211:  *
212:  * Legal content type string are defined in the CONTENIDO system table
213:  * 'con_type'.
214:  * Default content types are:
215:  *
216:  * NOTE: This parameter is case insesitive, you can use html or cms_HTML or
217:  * CmS_HtMl.
218:  * Your don't need start with cms, but it won't crash if you do so.
219:  *
220:  * htmlhead - HTML Headline
221:  * html - HTML Text
222:  * headline - Headline (no HTML)
223:  * text - Text (no HTML)
224:  * img - Upload id of the element
225:  * imgdescr - Image description
226:  * link - Link (URL)
227:  * linktarget - Linktarget (_self, _blank, _top ...)
228:  * linkdescr - Linkdescription
229:  * swf - Upload id of the element
230:  *
231:  * @package Core
232:  * @subpackage GenericDB_Model
233:  */
234: class cApiArticleLanguage extends Item {
235: 
236:     /**
237:      * Config array
238:      *
239:      * @var array
240:      */
241:     public $tab;
242: 
243:     /**
244:      * Article content
245:      *
246:      * @var array
247:      */
248:     public $content = null;
249: 
250:     /**
251:      * Constructor Function
252:      *
253:      * @param mixed $mId Specifies the ID of item to load
254:      * @param bool $fetchContent Flag to fetch content
255:      */
256:     public function __construct($mId = false, $fetchContent = false) {
257:         global $cfg;
258:         parent::__construct($cfg['tab']['art_lang'], 'idartlang');
259:         $this->setFilters(array(), array());
260:         if ($mId !== false) {
261:             $this->loadByPrimaryKey($mId);
262:             if (true === $fetchContent) {
263:                 $this->_getArticleContent();
264:             }
265:         }
266:     }
267: 
268:     /**
269:      * Load data by article and language id
270:      *
271:      * @param int $idart Article id
272:      * @param int $idlang Language id
273:      * @param bool $fetchContent Flag to fetch content
274:      * @return bool true on success, otherwhise false
275:      */
276:     public function loadByArticleAndLanguageId($idart, $idlang, $fetchContent = false) {
277:         $result = true;
278:         if (!$this->isLoaded()) {
279:             $aProps = array(
280:                 'idart' => $idart,
281:                 'idlang' => $idlang
282:             );
283:             $aRecordSet = $this->_oCache->getItemByProperties($aProps);
284:             if ($aRecordSet) {
285:                 // entry in cache found, load entry from cache
286:                 $this->loadByRecordSet($aRecordSet);
287:             } else {
288:                 $idartlang = $this->_getIdArtLang($idart, $idlang);
289:                 $result = $this->loadByPrimaryKey($idartlang);
290:             }
291:         }
292: 
293:         if (true === $fetchContent) {
294:             $this->_getArticleContent();
295:         }
296: 
297:         return $result;
298:     }
299: 
300:     /**
301:      * Extract 'idartlang' for a specified 'idart' and 'idlang'
302:      *
303:      * @param int $idart Article id
304:      * @param int $idlang Language id
305:      * @return int Language dependant article id
306:      */
307:     protected function _getIdArtLang($idart, $idlang) {
308:         global $cfg;
309: 
310:         $sql = 'SELECT idartlang FROM `%s` WHERE idart = %d AND idlang = %d';
311:         $this->db->query($sql, $cfg['tab']['art_lang'], $idart, $idlang);
312:         $this->db->nextRecord();
313: 
314:         return $this->db->f('idartlang');
315:     }
316: 
317:     /**
318:      * Load the articles content and stores it in the 'content' property of the
319:      * article object.
320:      *
321:      * $article->content[type][number] = value;
322:      */
323:     public function loadArticleContent() {
324:         $this->_getArticleContent();
325:     }
326: 
327:     /**
328:      * Load the articles content and stores it in the 'content' property of the
329:      * article object.
330:      *
331:      * $article->content[type][number] = value;
332:      */
333:     protected function _getArticleContent() {
334:         global $cfg;
335: 
336:         if (null !== $this->content) {
337:             return;
338:         }
339: 
340:         $sql = 'SELECT b.type, a.typeid, a.value FROM `%s` AS a, `%s` AS b ' . 'WHERE a.idartlang = %d AND b.idtype = a.idtype ' . 'ORDER BY a.idtype, a.typeid';
341: 
342:         $this->db->query($sql, $cfg['tab']['content'], $cfg['tab']['type'], $this->get('idartlang'));
343: 
344:         $this->content = array();
345:         while ($this->db->nextRecord()) {
346:             $this->content[strtolower($this->db->f('type'))][$this->db->f('typeid')] = $this->db->f('value');
347:         }
348:     }
349: 
350:     /**
351:      * Get the value of an article property
352:      *
353:      * List of article properties:
354:      *
355:      * idartlang - Language dependant article id
356:      * idart - Language indepenant article id
357:      * idclient - Id of the client
358:      * idtplcfg - Template configuration id
359:      * title - Internal Title
360:      * pagetitle - HTML Title
361:      * summary - Article summary
362:      * created - Date created
363:      * lastmodified - Date lastmodiefied
364:      * author - Article author (username)
365:      * online - On-/offline
366:      * redirect - Redirect
367:      * redirect_url - Redirect URL
368:      * artsort - Article sort key
369:      * timemgmt - Time management
370:      * datestart - Time management start date
371:      * dateend - Time management end date
372:      * status - Article status
373:      * free_use_01 - Free to use
374:      * free_use_02 - Free to use
375:      * free_use_03 - Free to use
376:      * time_move_cat - Move category after time management
377:      * time_target_cat - Move category to this cat after time management
378:      * time_online_move - Set article online after move
379:      * external_redirect - Open article in new window
380:      * locked - Article is locked for editing
381:      * searchable - Whether article should be found via search
382:      * sitemapprio - The priority for the sitemap
383:      *
384:      * @param string $name
385:      * @return string Value of property
386:      */
387:     public function getField($name) {
388:         return $this->values[$name];
389:     }
390: 
391:     /**
392:      * Userdefined setter for article language fields.
393:      *
394:      * @param string $name
395:      * @param mixed $value
396:      * @param bool $bSafe Flag to run defined inFilter on passed value
397:      */
398:     public function setField($name, $value, $bSafe = true) {
399:         switch ($name) {
400:             case 'urlname':
401:                 $value = conHtmlSpecialChars(cApiStrCleanURLCharacters($value), ENT_QUOTES);
402:                 break;
403:             case 'timemgmt':
404:             case 'time_move_cat':
405:             case 'time_online_move':
406:             case 'redirect':
407:             case 'external_redirect':
408:             case 'locked':
409:                 $value = ($value == 1)? 1 : 0;
410:                 break;
411:             case 'idart':
412:             case 'idlang':
413:             case 'artspec':
414:             case 'online':
415:             case 'searchable':
416:             case 'artsort':
417:             case 'status':
418:                 $value = (int) $value;
419:                 break;
420:             case 'redirect_url':
421:                 $value = ($value == 'http://' || $value == '')? '0' : $value;
422:                 break;
423:         }
424: 
425:         parent::setField($name, $value, $bSafe);
426:     }
427: 
428:     /**
429:      * Get content(s) from an article.
430:      *
431:      * Returns the specified content element or an array("id"=>"value") if the
432:      * second parameter is omitted.
433:      *
434:      * Legal content type string are defined in the CONTENIDO system table
435:      * 'con_type'.
436:      * Default content types are:
437:      *
438:      * NOTE: Parameter is case insesitive, you can use html or cms_HTML or
439:      * CmS_HtMl.
440:      * Your don't need start with cms, but it won't crash if you do so.
441:      *
442:      * htmlhead - HTML Headline
443:      * html - HTML Text
444:      * headline - Headline (no HTML)
445:      * text - Text (no HTML)
446:      * img - Upload id of the element
447:      * imgdescr - Image description
448:      * link - Link (URL)
449:      * linktarget - Linktarget (_self, _blank, _top ...)
450:      * linkdescr - Linkdescription
451:      * swf - Upload id of the element
452:      *
453:      * @param string $type CMS_TYPE - Legal cms type string
454:      * @param int|null $id Id of the content
455:      * @return string array data
456:      */
457:     public function getContent($type, $id = null) {
458:         if (null === $this->content) {
459:             $this->_getArticleContent();
460:         }
461: 
462:         if (empty($this->content)) {
463:             return '';
464:         }
465: 
466:         if ($type == '') {
467:             return 'Class ' . get_class($this) . ': content-type must be specified!';
468:         }
469: 
470:         $type = strtolower($type);
471: 
472:         if (!strstr($type, 'cms_')) {
473:             $type = 'cms_' . $type;
474:         }
475: 
476:         if (is_null($id)) {
477:             // return Array
478:             return $this->content[$type];
479:         }
480: 
481:         // return String
482:         return (isset($this->content[$type][$id]))? $this->content[$type][$id] : '';
483:     }
484: 
485:     /**
486:      * Returns all available content types
487:      *
488:      * @throws cException if no content has been loaded
489:      * @return array
490:      */
491:     public function getContentTypes() {
492:         if (empty($this->content)) {
493:             throw new cException('getContentTypes() No content loaded');
494:         }
495:         return array_keys($this->content);
496:     }
497: 
498:     /**
499:      * Returns the link to the current object.
500:      * @param integer $changeLangId change language id for URL (optional)
501:      * @return string link
502:      */
503:     public function getLink($changeLangId = 0) {
504:         if ($this->isLoaded() === false) {
505:             return '';
506:         }
507: 
508:         $options = array();
509:         $options['idart'] = $this->get('idart');
510:         $options['lang'] = ($changeLangId == 0) ? $this->get('idlang') : $changeLangId;
511:         if ($changeLangId > 0) {
512:             $options['changelang'] = $changeLangId;
513:         }
514: 
515:         return cUri::getInstance()->build($options);
516:     }
517: 
518: }
519: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0