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 article language version collection and item class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GenericDB_Model
  7:  * @author Jann Dieckmann
  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:  * Article language version collection
 18:  *
 19:  * @package Core
 20:  * @subpackage GenericDB_Model
 21:  */
 22: class cApiArticleLanguageVersionCollection extends cApiArticleLanguageCollection {
 23: 
 24:     /**
 25:      * Create a new collection of items.
 26:      *
 27:      * @param string $select
 28:      *         where clause to use for selection
 29:      * @see ItemCollection::select()
 30:      */
 31:     public function __construct($select = false) {
 32: 
 33:         $sTable = cRegistry::getDbTableName('art_lang_version');
 34:         $sPrimaryKey = 'idartlangversion';
 35:         ItemCollection::__construct($sTable, $sPrimaryKey);
 36: 
 37:         $this->_setItemClass('cApiArticleLanguageVersion');
 38: 
 39:         // set the join partners so that joins can be used via link() method
 40:         $this->_setJoinPartner('cApiArticleCollection');
 41:         $this->_setJoinPartner('cApiLanguageCollection');
 42:         $this->_setJoinPartner('cApiTemplateConfigurationCollection');
 43: 
 44:         if ($select !== false) {
 45:             $this->select($select);
 46:         }
 47:     }
 48: 
 49:     /**
 50:      * Creates an article language item entry.
 51:      *
 52:      * @global object $auth
 53:      * @param mixed[] $parameters{
 54:      *  @type int $idart
 55:      *  @type int $idlang
 56:      *  @type int $idartlang
 57:      *  @type string $title
 58:      *  @type string $urlname
 59:      *  @type string $pagetitle
 60:      *  @type string $summary
 61:      *  @type int $artspec
 62:      *  @type string $created
 63:      *  @type int $iscurrentverseion
 64:      *  @type string $author
 65:      *  @type string $lastmodified
 66:      *  @type string $modifiedby
 67:      *  @type string $published
 68:      *  @type string $publishedby
 69:      *  @type int $online
 70:      *  @type int $redirect
 71:      *  @type string $redirect_url
 72:      *  @type int $external_redirect
 73:      *  @type int $artsort
 74:      *  @type int $timemgmt
 75:      *  @type string $datestart
 76:      *  @type string $dateend
 77:      *  @type int $status
 78:      *  @type int $time_move_cat
 79:      *  @type int $time_target_cat
 80:      *  @type int $time_online_move
 81:      *  @type int $locked
 82:      *  @type mixed $free_use_01
 83:      *  @type mixed $free_use_02
 84:      *  @type mixed $free_use_03
 85:      *  @type int $searchable
 86:      *  @type float $sitemapprio
 87:      *  @type string $changefreq
 88:      * }
 89:      * @return cApiArticleLanguageVersion
 90:      */
 91:     public function create(array $parameters) {
 92:         global $auth;
 93: 
 94:         if (empty($parameters['author'])) {
 95:             $parameters['author'] = $auth->auth['uname'];
 96:         }
 97:         if (empty($parameters['created'])) {
 98:             $parameters['created'] = date('Y-m-d H:i:s');
 99:         }
100:         if (empty($parameters['lastmodified'])) {
101:             $parameters['lastmodified'] = date('Y-m-d H:i:s');
102:         }
103: 
104:         $parameters['urlname'] = (trim($parameters['urlname']) == '') ? trim($parameters['title']) : trim($parameters['urlname']);
105: 
106:         // set version
107:         $parameters['version'] = 1;
108:         $sql = 'SELECT MAX(version) AS maxversion FROM ' . cRegistry::getDbTableName('art_lang_version') . ' WHERE idartlang = %d;';
109:         $sql = $this->db->prepare($sql, $parameters['idartlang']);
110:         $this->db->query($sql);
111:         if ($this->db->nextRecord()) {
112:             $parameters['version'] = $this->db->f('maxversion');
113:             ++$parameters['version'];
114:         }
115: 
116:         $item = $this->createNewItem();
117: 
118:         // populate item w/ values
119:         foreach (array_keys($parameters) as $key) {
120:             // skip columns idcontent & version
121:             if ($key == 'iscurrentversion') {
122:                 continue;
123:             }
124:             $item->set($key, $parameters[$key]);
125:         }
126:         $item->markAsCurrentVersion($parameters['iscurrentversion']);
127:         $item->store();
128: 
129:         return $item;
130:     }
131: 
132:     /**
133:      * Returns id (idartlangversion) of articlelanguageversion by article
134:      * language id and version
135:      *
136:      * @param int $idArtLang
137:      * @param int $version
138:      * @return int
139:      */
140:     public function getIdByArticleIdAndLanguageId($idArtLang, $version) {
141: 
142:         $id = NULL;
143: 
144:         $where = 'idartlang = ' . $idArtLang . ' AND version = ' . $version;
145: 
146:         $artLangVersionColl = new cApiArticleLanguageVersionCollection();
147:         $artLangVersionColl->select($where);
148: 
149:         while($item = $artLangVersionColl->next()){
150:             $id = $item->get('idartlangversion');
151:         }
152: 
153:         return isset($id) ? $id : 0;
154: 
155:     }
156: }
157: 
158: /**
159:  * CONTENIDO API - Article Version Object
160:  *
161:  * This object represents a CONTENIDO article version
162:  *
163:  * Create object with
164:  * $obj = new cApiArticleLanguageVersion(idartlangversion);
165:  * or with
166:  * $obj = new cApiArticleLanguageVersion();
167:  * $obj->loadByArticleLanguageIdAndVersion(idartlang, version);
168:  *
169:  * You can now read the article version properties with
170:  * $obj->getField(property);
171:  *
172:  * List of article version properties:
173:  *
174:  * idartlang - Language dependant article id
175:  * idart - Language indepenant article id
176:  * idclient - Id of the client
177:  * idtplcfg - Template configuration id
178:  * title - Internal Title
179:  * pagetitle - HTML Title
180:  * summary - Article summary
181:  * created - Date created
182:  * version - Version number
183:  * iscurrentversion - 0 = false, 1 = true
184:  * lastmodified - Date lastmodiefied
185:  * author - Article author (username)
186:  * online - On-/offline
187:  * redirect - Redirect
188:  * redirect_url - Redirect URL
189:  * artsort - Article sort key
190:  * timemgmt - Time management
191:  * datestart - Time management start date
192:  * dateend - Time management end date
193:  * status - Article status
194:  * free_use_01 - Free to use
195:  * free_use_02 - Free to use
196:  * free_use_03 - Free to use
197:  * time_move_cat - Move category after time management
198:  * time_target_cat - Move category to this cat after time management
199:  * time_online_move - Set article online after move
200:  * external_redirect - Open article in new window
201:  * locked - Article is locked for editing
202:  * searchable - Whether article should be found via search
203:  * sitemapprio - The priority for the sitemap
204:  *
205:  * You can extract article version content with the
206:  * $obj->getContent(contype [, number]) method.
207:  *
208:  * To extract the first headline you can use:
209:  *
210:  * $headline = $obj->getContent("htmlhead", 1);
211:  *
212:  * If the second parameter is ommitted the method returns an array with all
213:  * available
214:  * content of this type. The array has the following schema:
215:  *
216:  * array(number => content);
217:  *
218:  * $headlines = $obj->getContent("htmlhead");
219:  *
220:  * $headlines[1] First headline
221:  * $headlines[2] Second headline
222:  * $headlines[6] Sixth headline
223:  *
224:  * Legal content type string are defined in the CONTENIDO system table
225:  * 'con_type'.
226:  * Default content types are:
227:  *
228:  * NOTE: This parameter is case insesitive, you can use html or cms_HTML or
229:  * CmS_HtMl.
230:  * Your don't need start with cms, but it won't crash if you do so.
231:  *
232:  * htmlhead - HTML Headline
233:  * html - HTML Text
234:  * headline - Headline (no HTML)
235:  * text - Text (no HTML)
236:  * img - Upload id of the element
237:  * imgdescr - Image description
238:  * link - Link (URL)
239:  * linktarget - Linktarget (_self, _blank, _top ...)
240:  * linkdescr - Linkdescription
241:  * swf - Upload id of the element
242:  *
243:  * @package Core
244:  * @subpackage GenericDB_Model
245:  */
246: class cApiArticleLanguageVersion extends cApiArticleLanguage {
247: 
248:     /**
249:      * Config array
250:      *
251:      * @var array
252:      */
253:     public $tab;
254: 
255:     /**
256:      * Article Version content
257:      *
258:      * @var array
259:      */
260:     public $content = NULL;
261: 
262:     /**
263:      * Constructor Function
264:      *
265:      * @param mixed $id
266:      *         Specifies the ID of item to load
267:      * @param bool $fetchContent
268:      *         Flag to fetch content
269:      */
270:     public function __construct($id = false, $fetchContent = false) {
271: 
272:         $sTable = cRegistry::getDbTableName('art_lang_version');
273:         $sPrimaryKey = 'idartlangversion';
274:         Item::__construct($sTable, $sPrimaryKey);
275: 
276:         $this->setFilters(array(), array());
277:         if ($id !== false) {
278:             $this->loadByPrimaryKey($id);
279:             if (true === $fetchContent) {
280:                 $this->_getArticleVersionContent();
281:             }
282:         }
283:     }
284: 
285:     /**
286:      * Set iscurrentversion = 0 in the current version and set iscurrentversion = 1 in this version
287:      *
288:      * @param int $iscurrentversion
289:      *         0 = false, 1 = true
290:      */
291:     public function markAsCurrentVersion($isCurrentVersion){
292:         $attributes = array(
293:             'idartlang' => $this->get('idartlang'),
294:             'iscurrentversion' => $isCurrentVersion
295:         );
296:         if ($isCurrentVersion == 1) {
297:             $artLangVersion = new cApiArticleLanguageVersion();
298:             if ($artLangVersion->loadByMany($attributes)) {
299:                 $artLangVersion->set('iscurrentversion', 0);
300:                 $artLangVersion->store();
301:             }
302:             $this->set('iscurrentversion', 1);
303:         } else {
304:             $this->set('iscurrentversion', 0);
305:         }
306:         $this->store();
307: 
308:     }
309: 
310:     /**
311:      * Set this ArticleVersion with its ContentVersions as current:
312:      * Copy data from this ArticleLanguageVersion to ArticleLanguage
313:      * Update Contents in ArticleLanguage
314:      * Set property iscurrentversion = 1 in this ArticleLanguageVersion
315:      * and 0 in the current ArticleLanguageVersions
316:      *
317:      * @param string $type
318:      *         meta, content or complete
319:      */
320:     public function markAsCurrent($type = ''){
321: 
322:         if ($type == 'complete') {
323:            // Prepare data and update ArticleLanguage
324:             $parameters = $this->toArray();
325:             $artLang = new cApiArticleLanguage($parameters['idartlang']);
326:             unset($parameters['idartlang']);
327:             unset($parameters['idartlangversion']);
328:             unset($parameters['iscurrentversion']);
329:             unset($parameters['version']);
330:             foreach ($parameters as $key => $value) {
331:                 $artLang->set($key, $value);
332:             }
333:             $artLang->store();
334:         }
335: 
336:         if ($type == 'content' || $type == 'complete') {
337: 
338:             $where = 'idartlang = ' . $this->get('idartlang');
339:             $contentVersionColl = new cApiContentVersionCollection();
340: 
341:             // Update Contents if contents are versioned
342:             $contents = $contentVersionColl->getIdsByWhereClause($where);
343:             if (isset($contents)) {
344:                 $sql = 'SELECT a.idcontent
345:                         FROM `%s` AS a
346:                         WHERE a.idartlang = %d AND a.idcontent NOT IN
347:                             (SELECT DISTINCT b.idcontent
348:                             FROM `%s` AS b
349:                             WHERE (b.deleted < 1 OR b.deleted IS NULL)
350:                             AND (b.idtype, b.typeid, b.version) IN
351:                                 (SELECT idtype, typeid, max(version)
352:                                 FROM `%s`
353:                                 WHERE idartlang = %d AND version <= %d
354:                                 GROUP BY idtype, typeid))';
355:                 $this->db->query(
356:                     $sql,
357:                     cRegistry::getDbTableName('content'),
358:                     $this->get('idartlang'),
359:                     cRegistry::getDbTableName('content_version'),
360:                     cRegistry::getDbTableName('content_version'),
361:                     $this->get('idartlang'), $this->get('version')
362:                 );
363:                 $contentColl = new cApiContentCollection();
364:                 while ($this->db->nextRecord()) {
365:                     $contentColl->delete($this->db->f('idcontent'));
366:                 }
367:                 $contentVersion = new cApiContentVersion();
368:                 $ctype = new cApiType();
369:                 $this->_getArticleVersionContent();
370:                 foreach ($this->content AS $typeName => $typeids) {
371:                     foreach ($typeids AS $typeid => $value) {
372:                         $ctype->loadByType($typeName);
373:                         $contentParameters = array(
374:                             'idartlang' => $this->get('idartlang'),
375:                             'idtype' => $ctype->get('idtype'),
376:                             'typeid' => $typeid,
377:                             'version' => $this->get('version')
378:                         );
379:                         $contentVersion->loadByArticleLanguageIdTypeTypeIdAndVersion($contentParameters);
380:                         $contentVersion->markAsCurrent();
381:                     }
382:                 }
383:             }
384:         }
385: 
386:         if ($type == 'meta' || $type == 'complete') {
387: 
388:             // mark meta tags versions as current
389:             $metaTagVersion = new cApiMetaTagVersion();
390:             $sql = 'SELECT idmetatagversion AS id
391:                     FROM `%s`
392:                     WHERE idartlang = %d AND version IN (
393:                         SELECT max(version)
394:                         FROM `%s`
395:                         WHERE idartlang = %d AND version <= %d)';
396:             $this->db->query(
397:                 $sql,
398:                 cRegistry::getDbTableName('meta_tag_version'),
399:                 $this->get('idartlang'),
400:                 cRegistry::getDbTableName('meta_tag_version'),
401:                 $this->get('idartlang'),
402:                 $this->get('version')
403:             );
404:             while ($this->db->nextRecord()) {
405:                     $metaTagVersionIds[] = $this->db->f('id');
406:             }
407:             if (isset($metaTagVersionIds)) {
408:                 foreach ($metaTagVersionIds AS $id) {
409:                     $metaTagVersion->loadBy('idmetatagversion', $id);
410:                     $metaTagVersion->markAsCurrent();
411:                 }
412:             }
413:         }
414: 
415:         // Set this ArticleVersion as current and make article index
416:         $this->markAsCurrentVersion(1);
417:         conMakeArticleIndex($this->get('idartlang'), $this->get('idart'));
418:         $purge = new cSystemPurge();
419:         $purge->clearArticleCache($this->get('idartlang'));
420:     }
421: 
422:     /**
423:      * Create a copy of this article language version with its contents,
424:      * the copy is the new editable article language version
425:      *
426:      * @param string $type
427:      *         meta, content or complete
428:      */
429:     public function markAsEditable($type = '') {
430: 
431:         // create new editable Version
432:         $parameters = $this->toArray();
433:         $parameters['lastmodified'] = date('Y-m-d H:i:s');
434:         unset($parameters['idartlangversion']);
435:         $artLangVersionColl = new cApiArticleLanguageVersionCollection();
436:         $artLangVersion = $artLangVersionColl->create($parameters);
437: 
438:         if ($type == 'content' || $type == 'complete') {
439:             // fetch content for new editable version
440:             $artLangVersion->loadByArticleLanguageIdAndVersion($artLangVersion->get('idartlang'), $artLangVersion->get('version'), true);
441:             $contentVersion = new cApiContentVersion();
442:             $apiType = new cApiType();
443:             $this->_getArticleVersionContent();
444: 
445:             // get all Content Versions
446:             $mergedContent = array();
447:             foreach ($this->content AS $typeName => $typeids) {
448:                 foreach ($typeids AS $typeid => $value) {
449:                     $mergedContent[$typeName][$typeid] = '';
450:                 }
451:             }
452:             foreach ($artLangVersion->content AS $typeName => $typeids) {
453:                 foreach ($typeids AS $typeid => $value) {
454:                     $mergedContent[$typeName][$typeid] = '';
455:                 }
456:             }
457:             // set new Content Versions
458:             foreach ($mergedContent AS $typeName => $typeids) {
459:                 foreach ($typeids AS $typeid => $value) {
460:                     $apiType->loadByType($typeName);
461:                     if (isset($this->content[$typeName][$typeid])) {
462:                         $contentParameters = array(
463:                             'idartlang' => $this->get('idartlang'),
464:                             'idtype' => $apiType->get('idtype'),
465:                             'typeid' => $typeid,
466:                             'version' => $this->get('version')
467:                         );
468:                         $contentVersion->loadByArticleLanguageIdTypeTypeIdAndVersion($contentParameters);
469: 
470:                         if (isset($contentVersion)) {
471:                             $contentVersion->markAsEditable($artLangVersion->get('version'), 0);
472:                         }
473:                     } else { // muss bleiben, um contents zu löschen;
474:                     //      vorsicht bei "als entwurf nutzen" wenn artikelversion jünger als contentversion
475:                         $contentParameters = array(
476:                             'idartlang' => $artLangVersion->get('idartlang'),
477:                             'idtype' => $apiType->get('idtype'),
478:                             'typeid' => $typeid,
479:                             'version' => $artLangVersion->get('version'),
480:                             'author' => $this->get('author'),
481:                             'deleted' => 1
482:                         );
483:                         $contentVersionColl = new cApiContentVersionCollection();
484:                         $contentVersionColl->create($contentParameters);
485:                     }
486:                 }
487:             }
488:         }
489: 
490:         if ($type == 'meta' || $type == 'complete') {
491: 
492:             // set new meta tag versions
493:             $metaTagVersion = new cApiMetaTagVersion();
494:             $sql = 'SELECT idmetatagversion AS id
495:                     FROM `%s`
496:                     WHERE idartlang = %d AND version IN (
497:                         SELECT max(version)
498:                         FROM `%s`
499:                         WHERE idartlang = %d AND version <= %d);';
500:             $this->db->query(
501:                 $sql,
502:                 cRegistry::getDbTableName('meta_tag_version'),
503:                 $this->get('idartlang'),
504:                 cRegistry::getDbTableName('meta_tag_version'),
505:                 $this->get('idartlang'),
506:                 $this->get('version')
507:             );
508:             while ($this->db->nextRecord()) {
509:                     $metaTagVersionIds[] = $this->db->f('id');
510:             }
511:             if (!empty($metaTagVersionIds)) {
512:                 foreach ($metaTagVersionIds AS $id) {
513:                     $metaTagVersion->loadBy('idmetatagversion', $id);
514:                     $metaTagVersion->markAsEditable($artLangVersion->get('version'));
515:                 }
516:             } else  { // use published meta tags
517:                 $metaTagColl = new cApiMetaTagCollection();
518:                 $metaTag = new cApiMetaTag();
519:                 $ids = $metaTagColl->getIdsByWhereClause('idartlang = ' . $this->get('idartlang'));
520:                 foreach ($ids AS $id) {
521:                     $metaTag->loadByPrimaryKey($id);
522:                     $metaTag->markAsEditable($artLangVersion->get('version'));
523:                 }
524:             }
525:         }
526: 
527:     }
528: 
529:     /**
530:      * Load data by article language id and version
531:      *
532:      * @param int $idArtLang
533:      *         Article language id
534:      * @param int $version
535:      *         version number
536:      * @param bool $fetchContent
537:      *         Flag to fetch content
538:      * @return bool
539:      *         true on success, otherwise false
540:      */
541:     public function loadByArticleLanguageIdAndVersion($idArtLang, $version, $fetchContent = false) {
542:         $result = true;
543:         if (!$this->isLoaded()) {
544:             $props = array(
545:                 'idartlang' => $idArtLang,
546:                 'version' => $version
547:             );
548:             $recordSet = $this->_oCache->getItemByProperties($props);
549:             if ($recordSet) {
550:                 // entry in cache found, load entry from cache
551:                 $this->loadByRecordSet($recordSet);
552:             } else {
553:                 $idArtLangVersion = $this->_getIdArtLangVersion($idArtLang, $version);
554:                 $result = $this->loadByPrimaryKey($idArtLangVersion);
555:             }
556:         }
557: 
558:         if (true === $fetchContent) {
559:             $this->_getArticleVersionContent();
560:         }
561: 
562:         return $result;
563:     }
564: 
565:     /**
566:      * Extract 'idartlangversion' for a specified 'idartlang' and 'version'
567:      *
568:      * @param int $idArtLang
569:      *         Article language id
570:      * @param int $version
571:      *         version number
572:      * @return int
573:      *         Article language version id
574:      */
575:     protected function _getIdArtLangVersion($idArtLang, $version) {
576: 
577:         $id = NULL;
578: 
579:         $where = 'idartlang = ' . $idArtLang . ' AND version = ' . $version;
580: 
581:         $artLangVersionColl = new cApiArticleLanguageVersionCollection();
582:         $artLangVersionColl->select($where);
583: 
584:         while($item = $artLangVersionColl->next()){
585:             $id = $item->get('idartlangversion');
586:         }
587: 
588:         return isset($id) ? $id : 0;
589: 
590:     }
591: 
592:     /**
593:      * Load the articles version content and store it in the 'content' property of the
594:      * article version object: $article->content[type][number] = value;
595:      *
596:      */
597:     protected function _getArticleVersionContent() {
598: 
599:         if (NULL !== $this->content) {
600:             return;
601:         }
602: 
603:         $sql = 'SELECT b.type as type, a.typeid as typeid, a.value as value, a.version as version
604:                 FROM `%s` AS a
605:                 INNER JOIN `%s` as b
606:                     ON b.idtype = a.idtype
607:                 WHERE (a.idtype, a.typeid, a.version) IN
608:                     (SELECT idtype, typeid, max(version)
609:                     FROM %s
610:                     WHERE idartlang = %d AND version <= %d
611:                     GROUP BY idtype, typeid)
612:                 AND a.idartlang = %d
613:                 AND (a.deleted < 1 OR a.deleted IS NULL)
614:                 ORDER BY a.idtype, a.typeid;';
615: 
616:         $this->db->query(
617:             $sql,
618:             cRegistry::getDbTableName('content_version'),
619:             cRegistry::getDbTableName('type'),
620:             cRegistry::getDbTableName('content_version'),
621:             $this->get('idartlang'), $this->get('version'),
622:             $this->get('idartlang')
623:         );
624: 
625:         $this->content = array();
626:         while ($this->db->nextRecord()) {
627:             $this->content[strtolower($this->db->f('type'))][$this->db->f('typeid')] = $this->db->f('value');
628:         }
629: 
630:     }
631: 
632:     /**
633:      * Get content(s) from an article version.
634:      *
635:      * Returns the specified content element or an array("id"=>"value") if the
636:      * second parameter is omitted.
637:      *
638:      * Legal content type string are defined in the CONTENIDO system table
639:      * 'con_type'.
640:      * Default content types are:
641:      *
642:      * NOTE: Parameter is case insensitive, you can use html or cms_HTML or
643:      * CmS_HtMl.
644:      * You don't need to start with cms, but it won't crash if you do so.
645:      *
646:      * htmlhead - HTML Headline
647:      * html - HTML Text
648:      * headline - Headline (no HTML)
649:      * text - Text (no HTML)
650:      * img - Upload id of the element
651:      * imgdescr - Image description
652:      * link - Link (URL)
653:      * linktarget - Linktarget (_self, _blank, _top ...)
654:      * linkdescr - Linkdescription
655:      * swf - Upload id of the element
656:      *
657:      * @param string $type
658:      *         CMS_TYPE - Legal cms type string
659:      * @param int|NULL $id
660:      *         Id of the content
661:      * @return string|array
662:      *         data
663:      */
664:     public function getContent($type = '', $id = NULL) {
665:         if (NULL === $this->content) {
666:             // get content for the loaded article version
667:             $this->_getArticleVersionContent();
668:         }
669: 
670:         return parent::getContent($type, $id);
671:     }
672: 
673: }
674: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0