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