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