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

  • cCodeGeneratorAbstract
  • cCodeGeneratorFactory
  • cCodeGeneratorStandard
  • cContentTypeAbstract
  • cContentTypeAbstractTabbed
  • cContentTypeDate
  • cContentTypeFilelist
  • cContentTypeHead
  • cContentTypeHtml
  • cContentTypeHtmlhead
  • cContentTypeImg
  • cContentTypeImgdescr
  • cContentTypeImgeditor
  • cContentTypeLink
  • cContentTypeLinkdescr
  • cContentTypeLinkeditor
  • cContentTypeLinktarget
  • cContentTypeRaw
  • cContentTypeTeaser
  • cContentTypeText
  • cTypeGenerator
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
   1: <?php
   2: 
   3: /**
   4:  * This file contains the cContentTypeTeaser class.
   5:  *
   6:  * @package Core
   7:  * @subpackage ContentType
   8:  * @author Timo Trautmann
   9:  * @author Simon Sprankel
  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: cInclude('includes', 'functions.con.php');
  19: cInclude('includes', 'functions.api.images.php');
  20: 
  21: /**
  22:  * Content type CMS_TEASER which lets the editor select articles in various ways
  23:  * which are displayed as teasers.
  24:  *
  25:  * @package Core
  26:  * @subpackage ContentType
  27:  */
  28: class cContentTypeTeaser extends cContentTypeAbstractTabbed {
  29: 
  30:     /**
  31:      * Array which contains all avariable CMS_Types and its IDs in current
  32:      * CONTENIDO installation (described as hash [idtype => cmstypename]).
  33:      *
  34:      * @var array
  35:      */
  36:     private $_cmsTypes;
  37: 
  38:     /**
  39:      * Content types in this array will be completely ignored by CMS_TEASER.
  40:      *
  41:      * They won't be displayed in the frontend and they won't be shown as an
  42:      * option in the backend.
  43:      *
  44:      * @var array
  45:      */
  46:     private $_ignoreTypes = array();
  47: 
  48:     /**
  49:      * If CMS_TEASER tries to load one of the content types listed as the keys
  50:      * of this array it will load the value of that key instead.
  51:      *
  52:      * These won't be listed as an option in the backend either.
  53:      *
  54:      * @var array
  55:      */
  56:     private $_forwardTypes = array(
  57:         "CMS_EASYIMG" => "CMS_IMGEDITOR",
  58:         "CMS_IMG" => "CMS_IMGEDITOR",
  59:         "CMS_LINK" => "CMS_LINKEDITOR"
  60:     );
  61: 
  62:     /**
  63:      * Placeholders for labels in frontend.
  64:      *
  65:      * Important: This must be a static array!
  66:      *
  67:      * @var array
  68:      */
  69:     protected static $_translations = array(
  70:         "MORE"
  71:     );
  72: 
  73:     /**
  74:      * Variable for detecting current interation.
  75:      *
  76:      * @var int
  77:      */
  78:     protected $iteration = 0;
  79: 
  80:     /**
  81:      * Constructor to create an instance of this class.
  82:      *
  83:      * Initialises class attributes and handles store events.
  84:      *
  85:      * @param string $rawSettings
  86:      *         the raw settings in an XML structure or as plaintext
  87:      * @param int    $id
  88:      *         ID of the content type, e.g. 3 if CMS_DATE[3] is used
  89:      * @param array  $contentTypes
  90:      *         array containing the values of all content types
  91:      *
  92:      * @throws cDbException
  93:      */
  94:     public function __construct($rawSettings, $id, array $contentTypes) {
  95: 
  96:         // set props
  97:         $this->_type = 'CMS_TEASER';
  98:         $this->_prefix = 'teaser';
  99:         $this->_settingsType = self::SETTINGS_TYPE_XML;
 100:         $this->_formFields = array(
 101:             'teaser_title',
 102:             'teaser_category',
 103:             'teaser_count',
 104:             'teaser_style',
 105:             'teaser_manual',
 106:             'teaser_start',
 107:             'teaser_source_head',
 108:             'teaser_source_head_count',
 109:             'teaser_source_text',
 110:             'teaser_source_text_count',
 111:             'teaser_source_image',
 112:             'teaser_source_image_count',
 113:             'teaser_filter',
 114:             'teaser_sort',
 115:             'teaser_sort_order',
 116:             'teaser_character_limit',
 117:             'teaser_image_width',
 118:             'teaser_image_height',
 119:             'teaser_manual_art',
 120:             'teaser_image_crop',
 121:             'teaser_source_date',
 122:             'teaser_source_date_count'
 123:         );
 124: 
 125:         // call parent constructor
 126:         parent::__construct($rawSettings, $id, $contentTypes);
 127: 
 128:         // if form is submitted, store the current teaser settings
 129:         // notice: also check the ID of the content type (there could be more
 130:         // than one content type of the same type on the same page!)
 131:         if (isset($_POST[$this->_prefix . '_action']) && $_POST[$this->_prefix . '_action'] == 'store' && isset($_POST[$this->_prefix . '_id']) && (int) $_POST[$this->_prefix . '_id'] == $this->_id) {
 132:             $this->_storeSettings();
 133:         }
 134: 
 135:         $this->_setDefaultValues();
 136:     }
 137: 
 138:     /**
 139:      * Returns all translation strings for mi18n.
 140:      *
 141:      * @param array $translationStrings
 142:      *         translation strings
 143:      * @return array
 144:      *         updated translation string
 145:      */
 146:     public static function addModuleTranslations(array $translationStrings) {
 147:         foreach (self::$_translations as $value) {
 148:             $translationStrings[] = $value;
 149:         }
 150: 
 151:         return $translationStrings;
 152:     }
 153: 
 154:     /**
 155:      * Sets some default values for teaser in case that there is no value
 156:      * defined.
 157:      */
 158:     private function _setDefaultValues() {
 159:         // character limit is 120 by default
 160:         if ((int) $this->_settings['teaser_character_limit'] == 0) {
 161:             $this->_settings['teaser_character_limit'] = 120;
 162:         }
 163: 
 164:         // teaser cont is 6 by default
 165:         if ((int) $this->_settings['teaser_count'] == 0) {
 166:             $this->_settings['teaser_count'] = 6;
 167:         }
 168: 
 169:         // teasersort is creationdate by default
 170:         if (cString::getStringLength($this->_settings['teaser_sort']) == 0) {
 171:             $this->_settings['teaser_sort'] = 'creationdate';
 172:         }
 173: 
 174:         // teaser style is liststyle by default
 175:         if (cString::getStringLength($this->_settings['teaser_style']) == 0) {
 176:             $this->_settings['teaser_style'] = 'cms_teaser_slider.html';
 177:         }
 178: 
 179:         // teaser image width default
 180:         if ((int) $this->_settings['teaser_image_width'] == 0) {
 181:             $this->_settings['teaser_image_width'] = 100;
 182:         }
 183: 
 184:         // teaser image height default
 185:         if ((int) $this->_settings['teaser_image_height'] == 0) {
 186:             $this->_settings['teaser_image_height'] = 75;
 187:         }
 188: 
 189:         // cms type head default
 190:         if (cString::getStringLength($this->_settings['teaser_source_head']) == 0) {
 191:             $this->_settings['teaser_source_head'] = 'CMS_HTMLHEAD';
 192:         }
 193: 
 194:         // cms type text default
 195:         if (cString::getStringLength($this->_settings['teaser_source_text']) == 0) {
 196:             $this->_settings['teaser_source_text'] = 'CMS_HTML';
 197:         }
 198: 
 199:         // cms type image default
 200:         if (cString::getStringLength($this->_settings['teaser_source_image']) == 0) {
 201:             $this->_settings['teaser_source_image'] = 'CMS_IMG';
 202:         }
 203: 
 204:         // cms type date default
 205:         if (cString::getStringLength($this->_settings['teaser_source_date']) == 0) {
 206:             $this->_settings['teaser_source_date'] = 'CMS_DATE';
 207:         }
 208: 
 209:         // sort order of teaser articles
 210:         if (cString::getStringLength($this->_settings['teaser_sort_order']) == 0) {
 211:             $this->_settings['teaser_sort_order'] = 'asc';
 212:         }
 213: 
 214:         // teaser image crop option
 215:         if (cString::getStringLength($this->_settings['teaser_image_crop']) == 0 || $this->_settings['teaser_image_crop'] == 'false') {
 216:             $this->_settings['teaser_image_crop'] = 'false';
 217:         }
 218:     }
 219: 
 220:     /**
 221:      * Generates the code which should be shown if this content type is shown in
 222:      * the frontend.
 223:      *
 224:      * @return string
 225:      *         escaped HTML code which sould be shown if content type is shown in frontend
 226:      */
 227:     public function generateViewCode() {
 228:         $code = '";?><?php
 229:                     $teaser = new cContentTypeTeaser(\'%s\', %s, %s);
 230:                     echo $teaser->generateTeaserCode();
 231:                  ?><?php echo "';
 232:         // escape ' to avoid accidently ending the string in $code
 233:         $code = sprintf($code, str_replace('\'', '\\\'', $this->_rawSettings), $this->_id, 'array()');
 234: 
 235:         return $code;
 236:     }
 237: 
 238:     /**
 239:      * Function returns idarts of selected articles as array
 240:      *
 241:      * @return array
 242:      * 
 243:      * @throws cDbException
 244:      * @throws cException
 245:      * @throws cInvalidArgumentException
 246:      */
 247:     public function getConfiguredArticles() {
 248:         $articles = array();
 249:         $articles = $this->generateTeaserCode(true);
 250: 
 251:         return $articles;
 252:     }
 253: 
 254:     /**
 255:      * Function is called in edit- and viewmode in order to generate teasercode
 256:      * for output
 257:      *
 258:      * @param bool $returnAsArray [optional]
 259:      *                            modeswitch betwwen template generation and returning result as array
 260:      *
 261:      * @return mixed
 262:      *         string of select box or array of articles
 263:      * 
 264:      * @throws cDbException
 265:      * @throws cException
 266:      * @throws cInvalidArgumentException
 267:      */
 268:     public function generateTeaserCode($returnAsArray = false) {
 269:         global $contenido;
 270: 
 271:         $articles = array();
 272: 
 273:         $template = new cTemplate();
 274:         // set title of teaser
 275:         $template->set('s', 'TEASER_TITLE', $this->_settings['teaser_title']);
 276: 
 277:         // decide if it is a manual or category teaser
 278:         if ($this->_settings['teaser_manual'] == 'true' && count($this->_settings['teaser_manual_art']) > 0) {
 279:             $manualArts = $this->_settings['teaser_manual_art'];
 280:             if (!empty($manualArts) && !is_array($manualArts)) {
 281:                 $manualArts = array(
 282:                     $manualArts
 283:                 );
 284:             }
 285:             if (is_array($manualArts)) {
 286:                 $i = 0;
 287:                 // in manual case get all art to display and generate article
 288:                 // objects manually
 289:                 foreach ($manualArts as $idArt) {
 290:                     $article = new cApiArticleLanguage();
 291:                     $article->loadByArticleAndLanguageId($idArt, $this->_lang);
 292: 
 293:                     // try to fill teaser image
 294:                     if ($returnAsArray == false && $this->_fillTeaserTemplateEntry($article, $template)) {
 295:                         $i++;
 296:                         // break render, if teaser limit is reached
 297:                         if ($i == $this->_settings['teaser_count']) {
 298:                             break;
 299:                         }
 300:                     }
 301: 
 302:                     if ($returnAsArray == true && $this->_fillTeaserTemplateEntry($article, $template)) {
 303:                         array_push($articles, $article);
 304: 
 305:                         if ($i == $this->_settings['teaser_count']) {
 306:                             break;
 307:                         }
 308:                     }
 309:                 }
 310:             }
 311:         } else {
 312:             // in case of automatic teaser use class cArticleCollector
 313:             // for getting all arts in category
 314: 
 315:             $options = array(
 316:                 'lang' => $this->_lang,
 317:                 'client' => $this->_client,
 318:                 'idcat' => $this->_settings['teaser_category'],
 319:                 'order' => $this->_settings['teaser_sort'],
 320:                 'direction' => $this->_settings['teaser_sort_order'],
 321:                 'limit' => $this->_settings['teaser_count'],
 322:                 'start' => false,
 323:                 'offline' => false
 324:             );
 325: 
 326:             if ($this->_settings['teaser_start'] == 'true') {
 327:                 $options['start'] = true;
 328:             }
 329: 
 330:             $artCollector = new cArticleCollector($options);
 331: 
 332:             foreach ($artCollector as $article) {
 333: 
 334:                 $title =  trim($this->_getArtContent($article, $this->_settings['teaser_source_head'], $this->_settings['teaser_source_head_count']));
 335:                 $text =  trim($this->_getArtContent($article, $this->_settings['teaser_source_text'], $this->_settings['teaser_source_text_count']));
 336:                 $imageId = trim($this->_getArtContent($article, $this->_settings['teaser_source_image'], $this->_settings['teaser_source_image_count']));
 337: 
 338:                 if (!empty($title) || !empty($text) || !empty($imageId)) {
 339:                       if ($returnAsArray == true) {
 340:                          array_push($articles, $article);
 341:                     } else {
 342:                          $this->_fillTeaserTemplateEntry($article, $template);
 343:                     }
 344:                    }
 345:             }
 346:         }
 347: 
 348:         $code = '';
 349: 
 350:         // generate teasertemplate
 351:         if ($returnAsArray == false && file_exists($this->_cfgClient[$this->_client]['path']['frontend'] . 'templates/' . $this->_settings['teaser_style']) && count($template->Dyn_replacements) > 0) {
 352:             $code = $template->generate($this->_cfgClient[$this->_client]['path']['frontend'] . 'templates/' . $this->_settings['teaser_style'], true);
 353:             return $code;
 354:         } else if ($returnAsArray == true) {
 355:             return $articles;
 356:         }
 357:     }
 358: 
 359:     /**
 360:      * In edit and view mode this function fills teaser template with
 361:      * informations from a CONTENIDO article object.
 362:      *
 363:      * @param cApiArticleLanguage $article
 364:      *         CONTENIDO Article object
 365:      * @param cTemplate           $template
 366:      *         CONTENIDO Template object (as reference)
 367:      *
 368:      * @return bool
 369:      *         success state of this operation
 370:      * 
 371:      * @throws cDbException
 372:      * @throws cException
 373:      */
 374:     private function _fillTeaserTemplateEntry(cApiArticleLanguage $article, cTemplate &$template) {
 375:         global $contenido;
 376: 
 377:         // get necessary informations for teaser from articles use properties in
 378:         // a Settings for retrieval
 379:         $title = $this->_getArtContent($article, $this->_settings['teaser_source_head'], $this->_settings['teaser_source_head_count']);
 380:         $text = $this->_getArtContent($article, $this->_settings['teaser_source_text'], $this->_settings['teaser_source_text_count']);
 381:         $imageId = $this->_getArtContent($article, $this->_settings['teaser_source_image'], $this->_settings['teaser_source_image_count']);
 382:         $date = $this->_getArtContent($article, $this->_settings['teaser_source_date'], $this->_settings['teaser_source_date_count']);
 383: 
 384:         // check if CMS type is date before trying to parse it as date
 385:         if ('CMS_DATE' === $this->_settings['teaser_source_date']) {
 386:             $date = trim($date);
 387:             $date = new cContentTypeDate($date, 1, array('CMS_DATE'));
 388:             $date = $date->generateViewCode();
 389:         } else {
 390:             $date = trim(strip_tags($date));
 391:         }
 392: 
 393:         $idArt = $article->getField('idart');
 394:         $published = $article->getField('published');
 395:         $online = $article->getField('online');
 396:         $afields = [];
 397:         foreach ($article as $item => $value){
 398:             if ($item === 'values') {
 399:                 foreach ($value as $field => $val){
 400:                     $afields[$field] = $val;
 401:                 }
 402:             }
 403:         }
 404: 
 405:         if ($online == 1 || $contenido) {
 406:             // teaserfilter defines strings which must be contained in text for
 407:             // display.
 408:             // if string is defined check if article contains this string and
 409:             // abort, if article does not contain this string
 410:             if ($this->_settings['teaser_filter'] != '') {
 411:                 $iPosText = cString::findLastPos(conHtmlEntityDecode($text), $this->_settings['teaser_filter']);
 412:                 $iPosHead = cString::findLastPos(conHtmlEntityDecode($title), $this->_settings['teaser_filter']);
 413:                 if (is_bool($iPosText) && !$iPosText && is_bool($iPosHead) && !$iPosHead) {
 414:                     return false;
 415:                 }
 416:             }
 417: 
 418:             // convert date to readable format
 419:             if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/', $published, $results)) {
 420:                 $published = $results[3] . '.' . $results[2] . '.' . $results[1];
 421:             }
 422: 
 423:             // strip tags in teaser text and cut it if it is to long
 424:             $title = trim(strip_tags($title));
 425:             $text = trim(strip_tags($text));
 426:             if (cString::getStringLength($text) > $this->_settings['teaser_character_limit']) {
 427:                 $text = cString::trimAfterWord($text, $this->_settings['teaser_character_limit']) . '...';
 428:             }
 429: 
 430:             // try to get a teaser image directly from cms_img or try to extract
 431:             // if a content type is given, wich contains html
 432:             $cApiUploadMeta = new cApiUploadMeta();
 433:             if ((int) $imageId > 0) {
 434:                 $image = $this->_getImage($imageId, $this->_settings['teaser_image_width'], $this->_settings['teaser_image_height'], $this->_settings['teaser_image_crop']);
 435:                 $template->set('d', 'IMAGE', $image['element']);
 436:                 $template->set('d', 'IMAGE_SRC', $image['src']);
 437:                 $cApiUploadMeta->loadByMany(array('idlang' => cRegistry::getLanguageId(), 'idupl' => $imageId));
 438:                 if($cApiUploadMeta->isLoaded()) {
 439:                     $template->set('d', 'IMAGE_MEDIANAME', $cApiUploadMeta->get('medianame'));
 440:                 } else {
 441:                     $template->set('d', 'IMAGE_MEDIANAME', '');
 442:                 }
 443:             } else if (strip_tags($imageId) != $imageId && cString::getStringLength($imageId) > 0) {
 444:                 $image = $this->_extractImage($imageId);
 445:                 if (cString::getStringLength($image['src']) > 0) {
 446:                     $template->set('d', 'IMAGE', $image['element']);
 447:                     $template->set('d', 'IMAGE_SRC', $image['src']);
 448:                     $cApiUploadMeta->loadByMany(array('idlang' => cRegistry::getArticleLanguageId(), 'idupl' => $imageId));
 449:                     if($cApiUploadMeta->isLoaded()) {
 450:                         $template->set('d', 'IMAGE_MEDIANAME', $cApiUploadMeta->get('medianame'));
 451:                     } else {
 452:                         $template->set('d', 'IMAGE_MEDIANAME', '');
 453:                     }
 454:                 } else {
 455:                     $template->set('d', 'IMAGE', '');
 456:                     $template->set('d', 'IMAGE_SRC', '');
 457:                     $template->set('d', 'IMAGE_MEDIANAME', '');
 458:                 }
 459:             } else {
 460:                 $template->set('d', 'IMAGE_SRC', '');
 461:                 $template->set('d', 'IMAGE', '');
 462:                 $template->set('d', 'IMAGE_MEDIANAME', '');
 463:             }
 464: 
 465:             // strip all tags from manual teaser date
 466:             $date = strip_tags($date);
 467: 
 468:             // set generated values to teaser template
 469:             $template->set('d', 'TITLE', $title);
 470:             $template->set('d', 'TEXT', $text);
 471: 
 472:             $template->set('d', 'IDART', $idArt);
 473:             $template->set('d', 'ART_URL', 'front_content.php?idart=' . $idArt);
 474:             $template->set('d', 'PUBLISHED', $published);
 475:             $template->set('d', 'PUBLISHED_MANUAL', $date);
 476:             foreach ($afields as $field => $value) {
 477:                 $template->set('d', strtoupper($field), $value);
 478:             }
 479: 
 480:             if ($date != '') {
 481:                 $template->set('d', 'PUBLISHED_COMBINED', $date);
 482:             } else {
 483:                 $template->set('d', 'PUBLISHED_COMBINED', $published);
 484:             }
 485: 
 486:             foreach (self::$_translations as $translationString) {
 487:                 $template->set('d', $translationString, mi18n($translationString));
 488:             }
 489: 
 490:             if ($this->iteration == 0) {
 491:                 $template->set('d', 'ACTIVE', 'active');
 492:             } else {
 493:                 $template->set('d', 'ACTIVE', '');
 494:             }
 495:             $this->iteration++;
 496: 
 497:             $template->next();
 498:         }
 499: 
 500:         return true;
 501:     }
 502: 
 503:     /**
 504:      * Teaser allows to get a list of ids in which article content is searched
 505:      * in article like 1,2,5,6 the result with largest character count is
 506:      * returned
 507:      *
 508:      * @param cApiArticleLanguage $article
 509:      *         CONTENIDO article object
 510:      * @param string              $contentTypeName
 511:      *         Name of Content type to extract informations from
 512:      * @param string              $ids
 513:      *         list of ids to search in
 514:      *
 515:      * @return string
 516:      *         largest result of content
 517:      *
 518:      * @throws cDbException
 519:      */
 520:     private function _getArtContent(cApiArticleLanguage &$article, $contentTypeName, $ids) {
 521:         $this->_initCmsTypes();
 522: 
 523:         $return = '';
 524:         // split ids, if there is only one id, array has only one place filled,
 525:         // that is also ok
 526:         foreach (explode(',', $ids) as $currentId) {
 527:             if (!empty($this->_forwardTypes[$contentTypeName])) {
 528:                 $contentTypeName = $this->_forwardTypes[$contentTypeName];
 529:             }
 530:             $return .= ' ' . $article->getContent($contentTypeName, $currentId);
 531:         }
 532: 
 533:         return $return;
 534:     }
 535: 
 536:     /**
 537:      * When a HTML Code is given for a Teaser image try to find a image in this
 538:      * code and generate teaser image on that basis.
 539:      *
 540:      * @param string $content
 541:      *         HTML string to search image in
 542:      * @return string
 543:      *         img tag containing scaled image
 544:      */
 545:     private function _extractImage($content) {
 546:         $image = array();
 547: 
 548:         // search an image tag
 549:         $regEx = "/<img[^>]*?>.*?/i";
 550: 
 551:         $match = array();
 552:         preg_match($regEx, $content, $match);
 553: 
 554:         // if found extract its src content
 555:         $regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
 556:         $img = array();
 557:         preg_match($regEx, $match[0], $img);
 558: 
 559:         // check if this image lies in upload folder
 560:         $pos = cString::findLastPos($img[4], $this->_cfgClient[$this->_client]['upload']);
 561:         if (!is_bool($pos)) {
 562:             // if it is generate full internal path to image and scale it for
 563:             // display using class internal function getImage()
 564:             $file = $this->_cfgClient[$this->_client]['path']['frontend'] . $img[4];
 565:             $image = $this->_getImage($file, $this->_settings['teaser_image_width'], $this->_settings['teaser_image_height'], $this->_settings['teaser_image_crop'], true);
 566:         }
 567: 
 568:         return $image;
 569:     }
 570: 
 571:     /**
 572:      * Function gets path to an image of base of idupload in CONTENIDO,
 573:      * scales this image on basis of teaser settings and returns path to
 574:      * scaled image.
 575:      *
 576:      * It is also possible to give path to image directly, in this case set
 577:      * fourth parameter to true.
 578:      *
 579:      * @param int $image
 580:      *         idupl of image to use for teaser
 581:      * @param int $maxX
 582:      *         maximum image width
 583:      * @param int $maxY
 584:      *         maximum image height
 585:      * @param bool $isFile [optional]
 586:      *         in case of a direct file path retrival from database is not needed
 587:      * @return string
 588:      *         <img> tag contains scaled image
 589:      */
 590:     private function _getImage($image, $maxX, $maxY, $cropped, $isFile = false) {
 591:         $content = '';
 592:         $return = array();
 593: 
 594:         if ($cropped == 'true') {
 595:             $cropped = true;
 596:         } else {
 597:             $cropped = false;
 598:         }
 599: 
 600:         // check if there is a need to get image path
 601:         if ($isFile == false) {
 602:             $upload = new cApiUpload($image);
 603:             $dirname = $upload->get('dirname');
 604:             $filename = $upload->get('filename');
 605:             if (!empty($filename)) {
 606:                 $teaserImage = $this->_cfgClient[$this->_client]['path']['frontend'] . 'upload/' . $dirname . $filename;
 607:             }
 608:         } else {
 609:             $teaserImage = $image;
 610:         }
 611: 
 612:         // scale image if exists and return it
 613:         if (file_exists($teaserImage)) {
 614:             // Scale Image using cApiImgScale
 615:             $imgSrc = cApiImgScale($teaserImage, $maxX, $maxY, $cropped);
 616: 
 617:             if ($this->_useXHTML == 'true') {
 618:                 $letter = ' /';
 619:             } else {
 620:                 $letter = '';
 621:             }
 622: 
 623:             // Put Image into the teasertext
 624:             $content = '<img alt="" src="' . $imgSrc . '" class="teaser_image"' . $letter . '>' . $content;
 625:         }
 626: 
 627:         $return['element'] = $content;
 628:         $return['src'] = $imgSrc;
 629: 
 630:         return $return;
 631:     }
 632: 
 633:     /**
 634:      * Generates the code which should be shown if this content type is edited.
 635:      *
 636:      * @return string
 637:      *         escaped HTML code which should be shown if content type is edited
 638:      * 
 639:      * @throws cDbException
 640:      * @throws cException
 641:      * @throws cInvalidArgumentException
 642:      */
 643:     public function generateEditCode() {
 644:         $this->_initCmsTypes();
 645: 
 646:         $template = new cTemplate();
 647:         // Set some values into javascript for a better handling
 648:         $template->set('s', 'ID', $this->_id);
 649:         $template->set('s', 'IDARTLANG', $this->_idArtLang);
 650:         $template->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
 651: 
 652:         $templateTabs = new cTemplate();
 653:         $templateTabs->set('s', 'PREFIX', $this->_prefix);
 654: 
 655:         // create code for general tab
 656:         $templateTabs->set('d', 'TAB_ID', 'general');
 657:         $templateTabs->set('d', 'TAB_CLASS', 'general');
 658:         $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabGeneral());
 659:         $templateTabs->next();
 660: 
 661:         // create code for advanced tab
 662:         $templateTabs->set('d', 'TAB_ID', 'advanced');
 663:         $templateTabs->set('d', 'TAB_CLASS', 'advanced');
 664:         $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabAdvanced());
 665:         $templateTabs->next();
 666: 
 667:         // create code for manual tab
 668:         $templateTabs->set('d', 'TAB_ID', 'manual');
 669:         $templateTabs->set('d', 'TAB_CLASS', 'manual');
 670:         $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabManual());
 671:         $templateTabs->next();
 672: 
 673:         $codeTabs = $templateTabs->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
 674: 
 675:         // construct the top code of the template
 676:         $templateTop = new cTemplate();
 677:         $templateTop->set('s', 'ICON', 'images/isstart0.gif');
 678:         $templateTop->set('s', 'ID', $this->_id);
 679:         $templateTop->set('s', 'PREFIX', $this->_prefix);
 680:         $templateTop->set('s', 'HEADLINE', i18n('Teaser settings'));
 681:         $codeTop = $templateTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
 682: 
 683:         // define the available tabs
 684:         $tabMenu = array(
 685:             'general' => i18n('Automatic'),
 686:             'advanced' => i18n('Manual'),
 687:             'manual' => i18n('Settings')
 688:         );
 689: 
 690:         // construct the bottom code of the template
 691:         $templateBottom = new cTemplate();
 692:         $templateBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
 693:         $templateBottom->set('s', 'ID', $this->_id);
 694:         $templateBottom->set('s', 'PREFIX', $this->_prefix);
 695:         $templateBottom->set('s', 'IDARTLANG', $this->_idArtLang);
 696:         $templateBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
 697:         $templateBottom->set('s', 'SETTINGS', json_encode($this->_settings));
 698:         $templateBottom->set('s', 'JS_CLASS_SCRIPT', $this->_cfg['path']['contenido_fullhtml'] . 'scripts/content_types/cmsTeaser.js');
 699:         $templateBottom->set('s', 'JS_CLASS_NAME', 'Con.cContentTypeTeaser');
 700:         $codeBottom = $templateBottom->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_bottom.html', true);
 701: 
 702:         // construct the whole template code
 703:         $code = $this->generateViewCode();
 704:         $code .= $this->_encodeForOutput($codeTop);
 705:         $code .= $this->_generateTabMenuCode($tabMenu);
 706:         $code .= $this->_encodeForOutput($codeTabs);
 707:         $code .= $this->_generateActionCode();
 708:         $code .= $this->_encodeForOutput($codeBottom);
 709: 
 710:         return $code;
 711:     }
 712: 
 713:     /**
 714:      * Gets all currenty avariable content types and their ids
 715:      * from database and store it into class variable aCMSTypes.
 716:      * Because this information is used multiple times, this causes a better
 717:      * performance than gettting it seperately
 718:      *
 719:      * @throws cDbException
 720:      */
 721:     private function _initCmsTypes() {
 722:         if (!empty($this->_cmsTypes)) {
 723:             return;
 724:         }
 725: 
 726:         $this->_cmsTypes = array();
 727: 
 728:         $sql = 'SELECT * FROM ' . $this->_cfg['tab']['type'] . ' ORDER BY type';
 729:         $db = cRegistry::getDb();
 730:         $db->query($sql);
 731:         while ($db->nextRecord()) {
 732:             // we do not want certain content types
 733:             if (in_array($db->f('type'), $this->_ignoreTypes)) {
 734:                 continue;
 735:             }
 736:             $this->_cmsTypes[$db->f('idtype')] = $db->f('type');
 737:         }
 738:     }
 739: 
 740:     /**
 741:      * Generates code for the general tab in which various settings can be made.
 742:      *
 743:      * @return string
 744:      *         the code for the general tab
 745:      */
 746:     private function _generateTabGeneral() {
 747:         // define a wrapper which contains the whole content of the general tab
 748:         $wrapper = new cHTMLDiv();
 749:         $wrapperContent = array();
 750: 
 751:         // $wrapperContent[] = new cHTMLParagraph(i18n('General settings'),
 752:         // 'head_sub');
 753:         $wrapperContent[] = new cHTMLLabel(i18n('Teaser title'), 'teaser_title_' . $this->_id);
 754:         $wrapperContent[] = new cHTMLTextbox('teaser_title_' . $this->_id, conHtmlSpecialChars($this->_settings['teaser_title']), '', '', 'teaser_title_' . $this->_id);
 755:         $wrapperContent[] = new cHTMLLabel(i18n('Source category'), 'teaser_category_' . $this->_id);
 756:         $wrapperContent[] = buildCategorySelect('teaser_category_' . $this->_id, $this->_settings['teaser_category'], 0);
 757:         $wrapperContent[] = new cHTMLLabel(i18n('Number of articles'), 'teaser_count_' . $this->_id);
 758:         $wrapperContent[] = new cHTMLTextbox('teaser_count_' . $this->_id, (int) $this->_settings['teaser_count'], '', '', 'teaser_count_' . $this->_id);
 759: 
 760:         $wrapperContent[] = new cHTMLLabel(i18n("Include start article"), 'teaser_start_' . $this->_id);
 761:         $wrapperContent[] = new cHTMLCheckbox('teaser_start_' . $this->_id, '', 'teaser_start_' . $this->_id, ($this->_settings['teaser_start'] == 'true'));
 762: 
 763:         $wrapperContent[] = new cHTMLLabel(i18n("Teaser sort"), 'teaser_sort_' . $this->_id);
 764:         $wrapperContent[] = $this->_generateSortSelect();
 765:         $wrapperContent[] = new cHTMLLabel(i18n("Sort order"), 'teaser_sort_order_' . $this->_id);
 766:         $wrapperContent[] = $this->_generateSortOrderSelect();
 767: 
 768:         $wrapper->setContent($wrapperContent);
 769:         return $wrapper->render();
 770:     }
 771: 
 772:     /**
 773:      * Generats a select box for setting teaser style.
 774:      *
 775:      * Currently four default teaser templates are supported but any number of
 776:      * user templates can be defined as settings of type "cms_teaser" having a
 777:      * label as name and a filename as value.
 778:      *
 779:      * The default templates are:
 780:      * - Slider style (cms_teaser_slider.html)
 781:      * - Image style (cms_teaser_image.html)
 782:      * - Text style (cms_teaser_text.html)
 783:      * - Blog style (cms_teaser_blog.html)
 784:      *
 785:      * @return string
 786:      *         html string of select box
 787:      */
 788:     private function _generateStyleSelect() {
 789:         $htmlSelect = new cHTMLSelectElement('teaser_style_' . $this->_id, '', 'teaser_style_' . $this->_id);
 790: 
 791:         // set please chose option element
 792:         $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
 793:         $htmlSelect->appendOptionElement($htmlSelectOption);
 794: 
 795:         // set other avariable options manually
 796:         $htmlSelectOption = new cHTMLOptionElement(i18n("Slider style"), 'cms_teaser_slider.html', false);
 797:         $htmlSelect->appendOptionElement($htmlSelectOption);
 798: 
 799:         $htmlSelectOption = new cHTMLOptionElement(i18n("Image style"), 'cms_teaser_image.html', false);
 800:         $htmlSelect->appendOptionElement($htmlSelectOption);
 801: 
 802:         $htmlSelectOption = new cHTMLOptionElement(i18n("Text style"), 'cms_teaser_text.html', false);
 803:         $htmlSelect->appendOptionElement($htmlSelectOption);
 804: 
 805:         $htmlSelectOption = new cHTMLOptionElement(i18n("Blog style"), 'cms_teaser_blog.html', false);
 806:         $htmlSelect->appendOptionElement($htmlSelectOption);
 807: 
 808:         $additionalOptions = getEffectiveSettingsByType('cms_teaser');
 809:         foreach ($additionalOptions as $sLabel => $sTemplate) {
 810:             $htmlSelectOption = new cHTMLOptionElement($sLabel, $sTemplate, false);
 811:             $htmlSelect->appendOptionElement($htmlSelectOption);
 812:         }
 813: 
 814:         // set default value
 815:         $htmlSelect->setDefault($this->_settings['teaser_style']);
 816: 
 817:         return $htmlSelect->render();
 818:     }
 819: 
 820:     /**
 821:      * Teaser gets informations from other articles and their content typs.
 822:      *
 823:      * Function builds a select box in which coresponding cms type can be
 824:      * selected after that a text box is rendered for setting id for this
 825:      * content type to get informations from.
 826:      *
 827:      * This function is used three times for source defintion of headline,
 828:      * text and teaserimage.
 829:      *
 830:      * @param string $selectName
 831:      *         name of input elements
 832:      * @param string $selected
 833:      *         value of select box which is selected
 834:      * @param string $value
 835:      *         current value of text box
 836:      * @return string
 837:      *         html string of select box
 838:      */
 839:     private function _generateTypeSelect($selectName, $selected, $value) {
 840:         // make sure that the ID is at the end of the form field name
 841:         $inputName = str_replace('_' . $this->_id, '_count_' . $this->_id, $selectName);
 842:         // generate textbox for content type id
 843:         $htmlInput = new cHTMLTextbox($inputName, $value, '', '', $inputName, false, '', '', 'teaser_type_count');
 844: 
 845:         // generate content type select
 846:         $htmlSelect = new cHTMLSelectElement($selectName, '', $selectName);
 847:         $htmlSelect->setClass('teaser_type_select');
 848: 
 849:         $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
 850:         $htmlSelect->addOptionElement(0, $htmlSelectOption);
 851: 
 852:         // use $this->_cmsTypes as basis for this select box which contains all
 853:         // avariable content types in system
 854:         foreach ($this->_cmsTypes as $key => $value) {
 855:             $htmlSelectOption = new cHTMLOptionElement($value, $value, false);
 856:             $htmlSelect->addOptionElement($key, $htmlSelectOption);
 857:         }
 858: 
 859:         // set default value
 860:         $htmlSelect->setDefault($selected);
 861: 
 862:         return $htmlSelect->render() . $htmlInput->render();
 863:     }
 864: 
 865:     /**
 866:      * Generates code for the advanced tab in which various advanced settings
 867:      * can be made.
 868:      *
 869:      * @return string
 870:      *         the code for the advanced tab
 871:      * 
 872:      * @throws cDbException
 873:      * @throws cException
 874:      */
 875:     private function _generateTabAdvanced() {
 876:         // define a wrapper which contains the whole content of the advanced tab
 877:         $wrapper = new cHTMLDiv();
 878:         $wrapperContent = array();
 879: 
 880:         // $wrapperContent[] = new cHTMLParagraph(i18n('Manual teaser
 881:         // settings'), 'head_sub');
 882:         $wrapperContent[] = new cHTMLLabel(i18n('Manual teaser'), 'teaser_manual_' . $this->_id);
 883:         $wrapperContent[] = new cHTMLCheckbox('teaser_manual_' . $this->_id, '', 'teaser_manual_' . $this->_id, ($this->_settings['teaser_manual'] == 'true'));
 884: 
 885:         // $wrapperContent[] = new cHTMLParagraph(i18n('Add article'),
 886:         // 'head_sub');
 887:         $wrapperContent[] = new cHTMLLabel(i18n('Category'), 'teaser_cat_' . $this->_id);
 888:         $wrapperContent[] = buildCategorySelect('teaser_cat_' . $this->_id, 0, 0);
 889:         $wrapperContent[] = new cHTMLLabel(i18n('Article'), 'teaser_art_' . $this->_id);
 890:         $wrapperContent[] = buildArticleSelect('teaser_art_' . $this->_id, 0, 0);
 891: 
 892:         $wrapperContent[] = new cHTMLLabel(i18n('Add'), 'add_art_' . $this->_id);
 893:         $image = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/but_art_new.gif');
 894:         $image->setAttribute('id', 'add_art_' . $this->_id);
 895:         $image->appendStyleDefinition('cursor', 'pointer');
 896:         $wrapperContent[] = $image;
 897: 
 898:         $wrapperContent[] = new cHTMLParagraph(i18n('Included articles'), 'head_sub');
 899:         $selectElement = new cHTMLSelectElement('teaser_manual_art_' . $this->_id, '', 'teaser_manual_art_' . $this->_id, false, '', '', 'manual');
 900:         $selectElement->setAttribute('size', '4');
 901:         $selectElement->setAttribute('multiple', 'multiple');
 902:         // there can be one or multiple selected articles
 903:         if (is_array($this->_settings['teaser_manual_art'])) {
 904:             foreach ($this->_settings['teaser_manual_art'] as $index => $idArt) {
 905:                 $option = new cHTMLOptionElement($this->_getArtName($idArt), $idArt, true);
 906:                 $selectElement->addOptionElement($index, $option);
 907:             }
 908:         } else {
 909:             // check if the article really exists
 910:             $artName = $this->_getArtName($this->_settings['teaser_manual_art']);
 911:             if ($artName != i18n('Unknown article')) {
 912:                 $option = new cHTMLOptionElement($artName, $this->_settings['teaser_manual_art'], true);
 913:                 $selectElement->addOptionElement(0, $option);
 914:             }
 915:         }
 916:         $wrapperContent[] = $selectElement;
 917: 
 918:         $wrapperContent[] = new cHTMLLabel(i18n("Delete"), 'del_art_' . $this->_id);
 919:         $image = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/delete.gif');
 920:         $image->setAttribute('id', 'del_art_' . $this->_id);
 921:         $image->appendStyleDefinition('cursor', 'pointer');
 922:         $wrapperContent[] = $image;
 923: 
 924:         $wrapper->setContent($wrapperContent);
 925:         return $wrapper->render();
 926:     }
 927: 
 928:     /**
 929:      * Function which generated a select box for setting teaser sort argument.
 930:      *
 931:      * @return string
 932:      *         html string of select box
 933:      */
 934:     private function _generateSortSelect() {
 935:         $htmlSelect = new cHTMLSelectElement('teaser_sort_' . $this->_id, '', 'teaser_sort_' . $this->_id);
 936: 
 937:         // set please chose option element
 938:         $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
 939:         $htmlSelect->appendOptionElement($htmlSelectOption);
 940: 
 941:         // set other avariable options manually
 942:         $htmlSelectOption = new cHTMLOptionElement(i18n("Sort sequence"), 'sortsequence', false);
 943:         $htmlSelect->appendOptionElement($htmlSelectOption);
 944: 
 945:         $htmlSelectOption = new cHTMLOptionElement(i18n("Creation date"), 'creationdate', false);
 946:         $htmlSelect->appendOptionElement($htmlSelectOption);
 947: 
 948:         $htmlSelectOption = new cHTMLOptionElement(i18n("Published date"), 'publisheddate', false);
 949:         $htmlSelect->appendOptionElement($htmlSelectOption);
 950: 
 951:         $htmlSelectOption = new cHTMLOptionElement(i18n("Modification date"), 'modificationdate', false);
 952:         $htmlSelect->appendOptionElement($htmlSelectOption);
 953: 
 954:         // set default value
 955:         $htmlSelect->setDefault($this->_settings['teaser_sort']);
 956: 
 957:         return $htmlSelect->render();
 958:     }
 959: 
 960:     /**
 961:      * Function which generated a select box for setting teaser sort order argument.
 962:      *
 963:      * @return string
 964:      *         html string of select box
 965:      */
 966:     private function _generateSortOrderSelect() {
 967:         $htmlSelect = new cHTMLSelectElement('teaser_sort_order_' . $this->_id, '', 'teaser_sort_order_' . $this->_id);
 968: 
 969:         // set please chose option element
 970:         $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
 971:         $htmlSelect->appendOptionElement($htmlSelectOption);
 972: 
 973:         // set other avariable options manually
 974:         $htmlSelectOption = new cHTMLOptionElement(i18n("Ascending"), 'asc', false);
 975:         $htmlSelect->appendOptionElement($htmlSelectOption);
 976: 
 977:         $htmlSelectOption = new cHTMLOptionElement(i18n("Descending"), 'desc', false);
 978:         $htmlSelect->appendOptionElement($htmlSelectOption);
 979: 
 980:         // set default value
 981:         $htmlSelect->setDefault($this->_settings['teaser_sort_order']);
 982: 
 983:         return $htmlSelect->render();
 984:     }
 985: 
 986:     /**
 987:      * Function which provides select option for cropping teaser images.
 988:      *
 989:      * @return string
 990:      *         html string of select box
 991:      */
 992:     private function _generateCropSelect() {
 993:         $htmlSelect = new cHTMLSelectElement('teaser_image_crop_' . $this->_id, '', 'teaser_image_crop_' . $this->_id);
 994: 
 995:         // set please chose option element
 996:         $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
 997:         $htmlSelect->appendOptionElement($htmlSelectOption);
 998: 
 999:         // set other avariable options manually
1000:         $htmlSelectOption = new cHTMLOptionElement(i18n("Scaled"), 'false', false);
1001:         $htmlSelect->appendOptionElement($htmlSelectOption);
1002: 
1003:         $htmlSelectOption = new cHTMLOptionElement(i18n("Cropped"), 'true', false);
1004:         $htmlSelect->appendOptionElement($htmlSelectOption);
1005: 
1006:         // set default value
1007:         $htmlSelect->setDefault($this->_settings['teaser_image_crop']);
1008: 
1009:         return $htmlSelect->render();
1010:     }
1011: 
1012:     /**
1013:      * Generates code for the manual tab in which various settings for the
1014:      * manual teaser can be made.
1015:      *
1016:      * @return string
1017:      *         the code for the manual tab
1018:      */
1019:     private function _generateTabManual() {
1020:         // define a wrapper which contains the whole content of the manual tab
1021:         $wrapper = new cHTMLDiv();
1022:         $wrapperContent = array();
1023: 
1024:         $wrapperContent[] = new cHTMLParagraph(i18n("Content visualisation"), 'head_sub');
1025:         $wrapperContent[] = new cHTMLLabel(i18n("Teaser visualisation"), 'teaser_style');
1026:         $wrapperContent[] = $this->_generateStyleSelect();
1027:         $wrapperContent[] = new cHTMLLabel(i18n("Teaser filter"), 'teaser_filter_' . $this->_id);
1028:         $wrapperContent[] = new cHTMLTextbox('teaser_filter_' . $this->_id, $this->_settings['teaser_filter'], '', '', 'teaser_filter_' . $this->_id);
1029:         $wrapperContent[] = new cHTMLLabel(i18n('Character length'), 'teaser_character_limit_' . $this->_id);
1030:         $wrapperContent[] = new cHTMLTextbox('teaser_character_limit_' . $this->_id, $this->_settings['teaser_character_limit'], '', '', 'teaser_character_limit_' . $this->_id);
1031: 
1032:         $wrapperContent[] = new cHTMLParagraph(i18n("Pictures"), 'head_sub');
1033:         $wrapperContent[] = new cHTMLLabel(i18n('Image width'), 'teaser_image_width_' . $this->_id);
1034:         $wrapperContent[] = new cHTMLTextbox('teaser_image_width_' . $this->_id, $this->_settings['teaser_image_width'], '', '', 'teaser_image_width_' . $this->_id);
1035:         $wrapperContent[] = new cHTMLLabel(i18n('Image height'), 'teaser_image_height_' . $this->_id);
1036:         $wrapperContent[] = new cHTMLTextbox('teaser_image_height_' . $this->_id, $this->_settings['teaser_image_height'], '', '', 'teaser_image_height_' . $this->_id);
1037:         $wrapperContent[] = new cHTMLLabel(i18n('Image scale'), 'teaser_image_crop_' . $this->_id);
1038:         $wrapperContent[] = $this->_generateCropSelect();
1039: 
1040:         $wrapperContent[] = new cHTMLParagraph(i18n("Content types"), 'head_sub');
1041:         $wrapperContent[] = new cHTMLLabel(i18n("Headline source"), 'teaser_source_head_' . $this->_id);
1042:         $wrapperContent[] = $this->_generateTypeSelect('teaser_source_head_' . $this->_id, $this->_settings['teaser_source_head'], $this->_settings['teaser_source_head_count']);
1043:         $wrapperContent[] = new cHTMLLabel(i18n("Text source"), 'teaser_source_text_' . $this->_id);
1044:         $wrapperContent[] = $this->_generateTypeSelect('teaser_source_text_' . $this->_id, $this->_settings['teaser_source_text'], $this->_settings['teaser_source_text_count']);
1045:         $wrapperContent[] = new cHTMLLabel(i18n('Image source'), 'teaser_source_image_' . $this->_id);
1046:         $wrapperContent[] = $this->_generateTypeSelect('teaser_source_image_' . $this->_id, $this->_settings['teaser_source_image'], $this->_settings['teaser_source_image_count']);
1047:         $wrapperContent[] = new cHTMLLabel(i18n('Date source'), 'teaser_source_date_' . $this->_id);
1048:         $wrapperContent[] = $this->_generateTypeSelect('teaser_source_date_' . $this->_id, $this->_settings['teaser_source_date'], $this->_settings['teaser_source_date_count']);
1049: 
1050:         $wrapper->setContent($wrapperContent);
1051:         return $wrapper->render();
1052:     }
1053: 
1054:     /**
1055:      * Function retrives name of an article by its id from database.
1056:      *
1057:      * @param int $idArt
1058:      *         CONTENIDO article id
1059:      *
1060:      * @return string
1061:      *         name of article
1062:      * 
1063:      * @throws cDbException
1064:      * @throws cException
1065:      */
1066:     private function _getArtName($idArt) {
1067:         $article = new cApiArticleLanguage();
1068:         $article->loadByArticleAndLanguageId((int) $idArt, $this->_lang);
1069: 
1070:         $title = $article->get('title');
1071:         if ($article->isLoaded() && !empty($title)) {
1072:             return $article->get('title');
1073:         } else {
1074:             return i18n('Unknown article');
1075:         }
1076:     }
1077: 
1078: }
1079: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0