1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 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: 23: 24: 25: 26: 27:
28: class cContentTypeTeaser extends cContentTypeAbstractTabbed {
29:
30: 31: 32: 33: 34: 35:
36: private $_cmsTypes;
37:
38: 39: 40: 41: 42: 43: 44: 45:
46: private $_ignoreTypes = array();
47:
48: 49: 50: 51: 52: 53: 54: 55:
56: private $_forwardTypes = array(
57: "CMS_EASYIMG" => "CMS_IMGEDITOR",
58: "CMS_IMG" => "CMS_IMGEDITOR",
59: "CMS_LINK" => "CMS_LINKEDITOR"
60: );
61:
62: 63: 64: 65: 66: 67: 68:
69: protected static $_translations = array(
70: "MORE"
71: );
72:
73: 74: 75: 76: 77:
78: protected $iteration = 0;
79:
80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91:
92: public function __construct($rawSettings, $id, array $contentTypes) {
93:
94:
95: $this->_type = 'CMS_TEASER';
96: $this->_prefix = 'teaser';
97: $this->_settingsType = self::SETTINGS_TYPE_XML;
98: $this->_formFields = array(
99: 'teaser_title',
100: 'teaser_category',
101: 'teaser_count',
102: 'teaser_style',
103: 'teaser_manual',
104: 'teaser_start',
105: 'teaser_source_head',
106: 'teaser_source_head_count',
107: 'teaser_source_text',
108: 'teaser_source_text_count',
109: 'teaser_source_image',
110: 'teaser_source_image_count',
111: 'teaser_filter',
112: 'teaser_sort',
113: 'teaser_sort_order',
114: 'teaser_character_limit',
115: 'teaser_image_width',
116: 'teaser_image_height',
117: 'teaser_manual_art',
118: 'teaser_image_crop',
119: 'teaser_source_date',
120: 'teaser_source_date_count'
121: );
122:
123:
124: parent::__construct($rawSettings, $id, $contentTypes);
125:
126:
127:
128:
129: if (isset($_POST[$this->_prefix . '_action']) && $_POST[$this->_prefix . '_action'] == 'store' && isset($_POST[$this->_prefix . '_id']) && (int) $_POST[$this->_prefix . '_id'] == $this->_id) {
130: $this->_storeSettings();
131: }
132:
133: $this->_setDefaultValues();
134: }
135:
136: 137: 138: 139: 140: 141: 142: 143:
144: public static function addModuleTranslations(array $translationStrings) {
145: foreach (self::$_translations as $value) {
146: $translationStrings[] = $value;
147: }
148:
149: return $translationStrings;
150: }
151:
152: 153: 154: 155:
156: private function _setDefaultValues() {
157:
158: if ((int) $this->_settings['teaser_character_limit'] == 0) {
159: $this->_settings['teaser_character_limit'] = 120;
160: }
161:
162:
163: if ((int) $this->_settings['teaser_count'] == 0) {
164: $this->_settings['teaser_count'] = 6;
165: }
166:
167:
168: if (strlen($this->_settings['teaser_sort']) == 0) {
169: $this->_settings['teaser_sort'] = 'creationdate';
170: }
171:
172:
173: if (strlen($this->_settings['teaser_style']) == 0) {
174: $this->_settings['teaser_style'] = 'cms_teaser_slider.html';
175: }
176:
177:
178: if ((int) $this->_settings['teaser_image_width'] == 0) {
179: $this->_settings['teaser_image_width'] = 100;
180: }
181:
182:
183: if ((int) $this->_settings['teaser_image_height'] == 0) {
184: $this->_settings['teaser_image_height'] = 75;
185: }
186:
187:
188: if (strlen($this->_settings['teaser_source_head']) == 0) {
189: $this->_settings['teaser_source_head'] = 'CMS_HTMLHEAD';
190: }
191:
192:
193: if (strlen($this->_settings['teaser_source_text']) == 0) {
194: $this->_settings['teaser_source_text'] = 'CMS_HTML';
195: }
196:
197:
198: if (strlen($this->_settings['teaser_source_image']) == 0) {
199: $this->_settings['teaser_source_image'] = 'CMS_IMG';
200: }
201:
202:
203: if (strlen($this->_settings['teaser_source_date']) == 0) {
204: $this->_settings['teaser_source_date'] = 'CMS_DATE';
205: }
206:
207:
208: if (strlen($this->_settings['teaser_sort_order']) == 0) {
209: $this->_settings['teaser_sort_order'] = 'asc';
210: }
211:
212:
213: if (strlen($this->_settings['teaser_image_crop']) == 0 || $this->_settings['teaser_image_crop'] == 'false') {
214: $this->_settings['teaser_image_crop'] = 'false';
215: }
216: }
217:
218: 219: 220: 221: 222: 223: 224:
225: public function generateViewCode() {
226: $code = '";?><?php
227: $teaser = new cContentTypeTeaser(\'%s\', %s, %s);
228: echo $teaser->generateTeaserCode();
229: ?><?php echo "';
230:
231: $code = sprintf($code, str_replace('\'', '\\\'', $this->_rawSettings), $this->_id, 'array()');
232:
233: return $code;
234: }
235:
236: 237: 238: 239: 240:
241: public function getConfiguredArticles() {
242: $articles = array();
243: $articles = $this->generateTeaserCode(true);
244:
245: return $articles;
246: }
247:
248: 249: 250: 251: 252: 253: 254: 255: 256:
257: public function generateTeaserCode($returnAsArray = false) {
258: global $contenido;
259:
260: $articles = array();
261:
262: $template = new cTemplate();
263:
264: $template->set('s', 'TITLE', $this->_settings['teaser_title']);
265:
266:
267: if ($this->_settings['teaser_manual'] == 'true' && count($this->_settings['teaser_manual_art']) > 0) {
268: $manualArts = $this->_settings['teaser_manual_art'];
269: if (!empty($manualArts) && !is_array($manualArts)) {
270: $manualArts = array(
271: $manualArts
272: );
273: }
274: if (is_array($manualArts)) {
275: $i = 0;
276:
277:
278: foreach ($manualArts as $idArt) {
279: $article = new cApiArticleLanguage();
280: $article->loadByArticleAndLanguageId($idArt, $this->_lang);
281:
282:
283: if ($returnAsArray == false && $this->_fillTeaserTemplateEntry($article, $template)) {
284: $i++;
285:
286: if ($i == $this->_settings['teaser_count']) {
287: break;
288: }
289: }
290:
291: if ($returnAsArray == true && $this->_fillTeaserTemplateEntry($article, $template)) {
292: array_push($articles, $article);
293:
294: if ($i == $this->_settings['teaser_count']) {
295: break;
296: }
297: }
298: }
299: }
300: } else {
301:
302:
303:
304: $options = array(
305: 'lang' => $this->_lang,
306: 'client' => $this->_client,
307: 'idcat' => $this->_settings['teaser_category'],
308: 'order' => $this->_settings['teaser_sort'],
309: 'direction' => $this->_settings['teaser_sort_order'],
310: 'limit' => $this->_settings['teaser_count'],
311: 'start' => false,
312: 'offline' => false
313: );
314:
315: if ($this->_settings['teaser_start'] == 'true') {
316: $options['start'] = true;
317: }
318:
319: $artCollector = new cArticleCollector($options);
320:
321: foreach ($artCollector as $article) {
322:
323: $title = trim($this->_getArtContent($article, $this->_settings['teaser_source_head'], $this->_settings['teaser_source_head_count']));
324: $text = trim($this->_getArtContent($article, $this->_settings['teaser_source_text'], $this->_settings['teaser_source_text_count']));
325: $imageId = trim($this->_getArtContent($article, $this->_settings['teaser_source_image'], $this->_settings['teaser_source_image_count']));
326:
327: if (!empty($title) || !empty($text) || !empty($imageId)) {
328: if ($returnAsArray == true) {
329: array_push($articles, $article);
330: } else {
331: $this->_fillTeaserTemplateEntry($article, $template);
332: }
333: }
334: }
335: }
336:
337: $code = '';
338:
339:
340: if ($returnAsArray == false && file_exists($this->_cfgClient[$this->_client]['path']['frontend'] . 'templates/' . $this->_settings['teaser_style']) && count($template->Dyn_replacements) > 0) {
341: $code = $template->generate($this->_cfgClient[$this->_client]['path']['frontend'] . 'templates/' . $this->_settings['teaser_style'], true);
342: return $code;
343: } else if ($returnAsArray == true) {
344: return $articles;
345: }
346: }
347:
348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358:
359: private function _fillTeaserTemplateEntry(cApiArticleLanguage $article, cTemplate &$template) {
360: global $contenido;
361:
362:
363:
364: $title = $this->_getArtContent($article, $this->_settings['teaser_source_head'], $this->_settings['teaser_source_head_count']);
365: $text = $this->_getArtContent($article, $this->_settings['teaser_source_text'], $this->_settings['teaser_source_text_count']);
366: $imageId = $this->_getArtContent($article, $this->_settings['teaser_source_image'], $this->_settings['teaser_source_image_count']);
367: $date = $this->_getArtContent($article, $this->_settings['teaser_source_date'], $this->_settings['teaser_source_date_count']);
368:
369:
370: if ('CMS_DATE' === $this->_settings['teaser_source_date']) {
371: $date = trim($date);
372: $date = new cContentTypeDate($date, 1, array('CMS_DATE'));
373: $date = $date->generateViewCode();
374: } else {
375: $date = trim(strip_tags($date));
376: }
377:
378: $idArt = $article->getField('idart');
379: $published = $article->getField('published');
380: $online = $article->getField('online');
381:
382: if ($online == 1 || $contenido) {
383:
384:
385:
386:
387: if ($this->_settings['teaser_filter'] != '') {
388: $iPosText = strrpos(conHtmlEntityDecode($text), $this->_settings['teaser_filter']);
389: $iPosHead = strrpos(conHtmlEntityDecode($title), $this->_settings['teaser_filter']);
390: if (is_bool($iPosText) && !$iPosText && is_bool($iPosHead) && !$iPosHead) {
391: return false;
392: }
393: }
394:
395:
396: if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/', $published, $results)) {
397: $published = $results[3] . '.' . $results[2] . '.' . $results[1];
398: }
399:
400:
401: $title = trim(strip_tags($title));
402: $text = trim(strip_tags($text));
403: if (strlen($text) > $this->_settings['teaser_character_limit']) {
404: $text = cString::trimAfterWord($text, $this->_settings['teaser_character_limit']) . '...';
405: }
406:
407:
408:
409: if ((int) $imageId > 0) {
410: $image = $this->_getImage($imageId, $this->_settings['teaser_image_width'], $this->_settings['teaser_image_height'], $this->_settings['teaser_image_crop']);
411: $template->set('d', 'IMAGE', $image['element']);
412: $template->set('d', 'IMAGE_SRC', $image['src']);
413: } else if (strip_tags($imageId) != $imageId && strlen($imageId) > 0) {
414: $image = $this->_extractImage($imageId);
415: if (strlen($image['src']) > 0) {
416: $template->set('d', 'IMAGE', $image['element']);
417: $template->set('d', 'IMAGE_SRC', $image['src']);
418: } else {
419: $template->set('d', 'IMAGE', '');
420: $template->set('d', 'IMAGE_SRC', '');
421: }
422: } else {
423: $template->set('d', 'IMAGE_SRC', '');
424: $template->set('d', 'IMAGE', '');
425: }
426:
427:
428: $date = strip_tags($date);
429:
430:
431: $template->set('d', 'TITLE', $title);
432: $template->set('d', 'TEXT', $text);
433:
434: $template->set('d', 'IDART', $idArt);
435: $template->set('d', 'ART_URL', 'front_content.php?idart=' . $idArt);
436: $template->set('d', 'PUBLISHED', $published);
437: $template->set('d', 'PUBLISHED_MANUAL', $date);
438:
439: if ($date != '') {
440: $template->set('d', 'PUBLISHED_COMBINED', $date);
441: } else {
442: $template->set('d', 'PUBLISHED_COMBINED', $published);
443: }
444:
445: foreach (self::$_translations as $translationString) {
446: $template->set('d', $translationString, mi18n($translationString));
447: }
448:
449: if ($this->iteration == 0) {
450: $template->set('d', 'ACTIVE', 'active');
451: } else {
452: $template->set('d', 'ACTIVE', '');
453: }
454: $this->iteration++;
455:
456: $template->next();
457: }
458:
459: return true;
460: }
461:
462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475:
476: private function _getArtContent(cApiArticleLanguage &$article, $contentTypeName, $ids) {
477: $this->_initCmsTypes();
478:
479: $return = '';
480:
481:
482: foreach (explode(',', $ids) as $currentId) {
483: if ($this->_forwardTypes[$contentTypeName] != "") {
484: $contentTypeName = $this->_forwardTypes[$contentTypeName];
485: }
486: $return .= ' ' . $article->getContent($contentTypeName, $currentId);
487: }
488:
489: return $return;
490: }
491:
492: 493: 494: 495: 496: 497: 498: 499: 500:
501: private function ($content) {
502: $image = array();
503:
504:
505: $regEx = "/<img[^>]*?>.*?/i";
506:
507: $match = array();
508: preg_match($regEx, $content, $match);
509:
510:
511: $regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
512: $img = array();
513: preg_match($regEx, $match[0], $img);
514:
515:
516: $pos = strrpos($img[4], $this->_cfgClient[$this->_client]['upload']);
517: if (!is_bool($pos)) {
518:
519:
520: $file = $this->_cfgClient[$this->_client]['path']['frontend'] . $img[4];
521: $image = $this->_getImage($file, $this->_settings['teaser_image_width'], $this->_settings['teaser_image_height'], $this->_settings['teaser_image_crop'], true);
522: }
523:
524: return $image;
525: }
526:
527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545:
546: private function _getImage($image, $maxX, $maxY, $cropped, $isFile = false) {
547: $content = '';
548: $return = array();
549:
550: if ($cropped == 'true') {
551: $cropped = true;
552: } else {
553: $cropped = false;
554: }
555:
556:
557: if ($isFile == false) {
558: $upload = new cApiUpload($image);
559: $dirname = $upload->get('dirname');
560: $filename = $upload->get('filename');
561: if (!empty($dirname) && !empty($filename)) {
562: $teaserImage = $this->_cfgClient[$this->_client]['path']['frontend'] . 'upload/' . $dirname . $filename;
563: }
564: } else {
565: $teaserImage = $image;
566: }
567:
568:
569: if (file_exists($teaserImage)) {
570:
571: $imgSrc = cApiImgScale($teaserImage, $maxX, $maxY, $cropped);
572:
573: if ($this->_useXHTML == 'true') {
574: $letter = ' /';
575: } else {
576: $letter = '';
577: }
578:
579:
580: $content = '<img alt="" src="' . $imgSrc . '" class="teaser_image"' . $letter . '>' . $content;
581: }
582:
583: $return['element'] = $content;
584: $return['src'] = $imgSrc;
585:
586: return $return;
587: }
588:
589: 590: 591: 592: 593: 594:
595: public function generateEditCode() {
596: $this->_initCmsTypes();
597:
598: $template = new cTemplate();
599:
600: $template->set('s', 'ID', $this->_id);
601: $template->set('s', 'IDARTLANG', $this->_idArtLang);
602: $template->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
603:
604: $templateTabs = new cTemplate();
605: $templateTabs->set('s', 'PREFIX', $this->_prefix);
606:
607:
608: $templateTabs->set('d', 'TAB_ID', 'general');
609: $templateTabs->set('d', 'TAB_CLASS', 'general');
610: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabGeneral());
611: $templateTabs->next();
612:
613:
614: $templateTabs->set('d', 'TAB_ID', 'advanced');
615: $templateTabs->set('d', 'TAB_CLASS', 'advanced');
616: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabAdvanced());
617: $templateTabs->next();
618:
619:
620: $templateTabs->set('d', 'TAB_ID', 'manual');
621: $templateTabs->set('d', 'TAB_CLASS', 'manual');
622: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabManual());
623: $templateTabs->next();
624:
625: $codeTabs = $templateTabs->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
626:
627:
628: $templateTop = new cTemplate();
629: $templateTop->set('s', 'ICON', 'images/isstart0.gif');
630: $templateTop->set('s', 'ID', $this->_id);
631: $templateTop->set('s', 'PREFIX', $this->_prefix);
632: $templateTop->set('s', 'HEADLINE', i18n('Teaser settings'));
633: $codeTop = $templateTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
634:
635:
636: $tabMenu = array(
637: 'general' => i18n('Automatic'),
638: 'advanced' => i18n('Manual'),
639: 'manual' => i18n('Settings')
640: );
641:
642:
643: $templateBottom = new cTemplate();
644: $templateBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
645: $templateBottom->set('s', 'ID', $this->_id);
646: $templateBottom->set('s', 'PREFIX', $this->_prefix);
647: $templateBottom->set('s', 'IDARTLANG', $this->_idArtLang);
648: $templateBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
649: $templateBottom->set('s', 'SETTINGS', json_encode($this->_settings));
650: $templateBottom->set('s', 'JS_CLASS_SCRIPT', $this->_cfg['path']['contenido_fullhtml'] . 'scripts/content_types/cmsTeaser.js');
651: $templateBottom->set('s', 'JS_CLASS_NAME', 'Con.cContentTypeTeaser');
652: $codeBottom = $templateBottom->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_bottom.html', true);
653:
654:
655: $code = $this->generateViewCode();
656: $code .= $this->_encodeForOutput($codeTop);
657: $code .= $this->_generateTabMenuCode($tabMenu);
658: $code .= $this->_encodeForOutput($codeTabs);
659: $code .= $this->_generateActionCode();
660: $code .= $this->_encodeForOutput($codeBottom);
661:
662: return $code;
663: }
664:
665: 666: 667: 668: 669: 670:
671: private function _initCmsTypes() {
672: if (!empty($this->_cmsTypes)) {
673: return;
674: }
675:
676: $this->_cmsTypes = array();
677:
678: $sql = 'SELECT * FROM ' . $this->_cfg['tab']['type'] . ' ORDER BY type';
679: $db = cRegistry::getDb();
680: $db->query($sql);
681: while ($db->nextRecord()) {
682:
683: if (in_array($db->f('type'), $this->_ignoreTypes)) {
684: continue;
685: }
686: $this->_cmsTypes[$db->f('idtype')] = $db->f('type');
687: }
688: }
689:
690: 691: 692: 693: 694: 695:
696: private function _generateTabGeneral() {
697:
698: $wrapper = new cHTMLDiv();
699: $wrapperContent = array();
700:
701:
702:
703: $wrapperContent[] = new cHTMLLabel(i18n('Teaser title'), 'teaser_title_' . $this->_id);
704: $wrapperContent[] = new cHTMLTextbox('teaser_title_' . $this->_id, $this->_settings['teaser_title'], '', '', 'teaser_title_' . $this->_id);
705: $wrapperContent[] = new cHTMLLabel(i18n('Source category'), 'teaser_category_' . $this->_id);
706: $wrapperContent[] = buildCategorySelect('teaser_category_' . $this->_id, $this->_settings['teaser_category'], 0);
707: $wrapperContent[] = new cHTMLLabel(i18n('Number of articles'), 'teaser_count_' . $this->_id);
708: $wrapperContent[] = $this->_generateCountSelect();
709:
710: $wrapperContent[] = new cHTMLLabel(i18n("Include start article"), 'teaser_start_' . $this->_id);
711: $wrapperContent[] = new cHTMLCheckbox('teaser_start_' . $this->_id, '', 'teaser_start_' . $this->_id, ($this->_settings['teaser_start'] == 'true'));
712:
713: $wrapperContent[] = new cHTMLLabel(i18n("Teaser sort"), 'teaser_sort_' . $this->_id);
714: $wrapperContent[] = $this->_generateSortSelect();
715: $wrapperContent[] = new cHTMLLabel(i18n("Sort order"), 'teaser_sort_order_' . $this->_id);
716: $wrapperContent[] = $this->_generateSortOrderSelect();
717:
718: $wrapper->setContent($wrapperContent);
719: return $wrapper->render();
720: }
721:
722: 723: 724: 725: 726: 727: 728: 729: 730:
731: private function _generateCountSelect() {
732: $htmlSelect = new cHTMLSelectElement('teaser_count_' . $this->_id, '', 'teaser_count_' . $this->_id);
733:
734:
735: $htmlSelectOption = new cHTMLOptionElement(i18n('Please choose'), '', true);
736: $htmlSelect->appendOptionElement($htmlSelectOption);
737:
738:
739:
740: for ($i = 1; $i <= 20; $i++) {
741: $htmlSelectOption = new cHTMLOptionElement($i, $i, false);
742: $htmlSelect->appendOptionElement($htmlSelectOption);
743: }
744:
745:
746: $htmlSelect->setDefault($this->_settings['teaser_count']);
747:
748: return $htmlSelect->render();
749: }
750:
751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766:
767: private function _generateStyleSelect() {
768: $htmlSelect = new cHTMLSelectElement('teaser_style_' . $this->_id, '', 'teaser_style_' . $this->_id);
769:
770:
771: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
772: $htmlSelect->appendOptionElement($htmlSelectOption);
773:
774:
775: $htmlSelectOption = new cHTMLOptionElement(i18n("Slider style"), 'cms_teaser_slider.html', false);
776: $htmlSelect->appendOptionElement($htmlSelectOption);
777:
778: $htmlSelectOption = new cHTMLOptionElement(i18n("Image style"), 'cms_teaser_image.html', false);
779: $htmlSelect->appendOptionElement($htmlSelectOption);
780:
781: $htmlSelectOption = new cHTMLOptionElement(i18n("Text style"), 'cms_teaser_text.html', false);
782: $htmlSelect->appendOptionElement($htmlSelectOption);
783:
784: $htmlSelectOption = new cHTMLOptionElement(i18n("Blog style"), 'cms_teaser_blog.html', false);
785: $htmlSelect->appendOptionElement($htmlSelectOption);
786:
787: $additionalOptions = getEffectiveSettingsByType('cms_teaser');
788: foreach ($additionalOptions as $sLabel => $sTemplate) {
789: $htmlSelectOption = new cHTMLOptionElement($sLabel, $sTemplate, false);
790: $htmlSelect->appendOptionElement($htmlSelectOption);
791: }
792:
793:
794: $htmlSelect->setDefault($this->_settings['teaser_style']);
795:
796: return $htmlSelect->render();
797: }
798:
799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817:
818: private function _generateTypeSelect($selectName, $selected, $value) {
819:
820: $inputName = str_replace('_' . $this->_id, '_count_' . $this->_id, $selectName);
821:
822: $htmlInput = new cHTMLTextbox($inputName, $value, '', '', $inputName, false, '', '', 'teaser_type_count');
823:
824:
825: $htmlSelect = new cHTMLSelectElement($selectName, '', $selectName);
826: $htmlSelect->setClass('teaser_type_select');
827:
828: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
829: $htmlSelect->addOptionElement(0, $htmlSelectOption);
830:
831:
832:
833: foreach ($this->_cmsTypes as $key => $value) {
834: $htmlSelectOption = new cHTMLOptionElement($value, $value, false);
835: $htmlSelect->addOptionElement($key, $htmlSelectOption);
836: }
837:
838:
839: $htmlSelect->setDefault($selected);
840:
841: return $htmlSelect->render() . $htmlInput->render();
842: }
843:
844: 845: 846: 847: 848: 849: 850:
851: private function _generateTabAdvanced() {
852:
853: $wrapper = new cHTMLDiv();
854: $wrapperContent = array();
855:
856:
857:
858: $wrapperContent[] = new cHTMLLabel(i18n('Manual teaser'), 'teaser_manual_' . $this->_id);
859: $wrapperContent[] = new cHTMLCheckbox('teaser_manual_' . $this->_id, '', 'teaser_manual_' . $this->_id, ($this->_settings['teaser_manual'] == 'true'));
860:
861:
862:
863: $wrapperContent[] = new cHTMLLabel(i18n('Category'), 'teaser_cat_' . $this->_id);
864: $wrapperContent[] = buildCategorySelect('teaser_cat_' . $this->_id, 0, 0);
865: $wrapperContent[] = new cHTMLLabel(i18n('Article'), 'teaser_art_' . $this->_id);
866: $wrapperContent[] = buildArticleSelect('teaser_art_' . $this->_id, 0, 0);
867:
868: $wrapperContent[] = new cHTMLLabel(i18n('Add'), 'add_art_' . $this->_id);
869: $image = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/but_art_new.gif');
870: $image->setAttribute('id', 'add_art_' . $this->_id);
871: $image->appendStyleDefinition('cursor', 'pointer');
872: $wrapperContent[] = $image;
873:
874: $wrapperContent[] = new cHTMLParagraph(i18n('Included articles'), 'head_sub');
875: $selectElement = new cHTMLSelectElement('teaser_manual_art_' . $this->_id, '', 'teaser_manual_art_' . $this->_id, false, '', '', 'manual');
876: $selectElement->setAttribute('size', '4');
877: $selectElement->setAttribute('multiple', 'multiple');
878:
879: if (is_array($this->_settings['teaser_manual_art'])) {
880: foreach ($this->_settings['teaser_manual_art'] as $index => $idArt) {
881: $option = new cHTMLOptionElement($this->_getArtName($idArt), $idArt, true);
882: $selectElement->addOptionElement($index, $option);
883: }
884: } else {
885:
886: $artName = $this->_getArtName($this->_settings['teaser_manual_art']);
887: if ($artName != i18n('Unknown article')) {
888: $option = new cHTMLOptionElement($artName, $this->_settings['teaser_manual_art'], true);
889: $selectElement->addOptionElement(0, $option);
890: }
891: }
892: $wrapperContent[] = $selectElement;
893:
894: $wrapperContent[] = new cHTMLLabel(i18n("Delete"), 'del_art_' . $this->_id);
895: $image = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/delete.gif');
896: $image->setAttribute('id', 'del_art_' . $this->_id);
897: $image->appendStyleDefinition('cursor', 'pointer');
898: $wrapperContent[] = $image;
899:
900: $wrapper->setContent($wrapperContent);
901: return $wrapper->render();
902: }
903:
904: 905: 906: 907: 908: 909:
910: private function _generateSortSelect() {
911: $htmlSelect = new cHTMLSelectElement('teaser_sort_' . $this->_id, '', 'teaser_sort_' . $this->_id);
912:
913:
914: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
915: $htmlSelect->appendOptionElement($htmlSelectOption);
916:
917:
918: $htmlSelectOption = new cHTMLOptionElement(i18n("Sort sequence"), 'sortsequence', false);
919: $htmlSelect->appendOptionElement($htmlSelectOption);
920:
921: $htmlSelectOption = new cHTMLOptionElement(i18n("Creation date"), 'creationdate', false);
922: $htmlSelect->appendOptionElement($htmlSelectOption);
923:
924: $htmlSelectOption = new cHTMLOptionElement(i18n("Published date"), 'publisheddate', false);
925: $htmlSelect->appendOptionElement($htmlSelectOption);
926:
927: $htmlSelectOption = new cHTMLOptionElement(i18n("Modification date"), 'modificationdate', false);
928: $htmlSelect->appendOptionElement($htmlSelectOption);
929:
930:
931: $htmlSelect->setDefault($this->_settings['teaser_sort']);
932:
933: return $htmlSelect->render();
934: }
935:
936: 937: 938: 939: 940: 941:
942: private function _generateSortOrderSelect() {
943: $htmlSelect = new cHTMLSelectElement('teaser_sort_order_' . $this->_id, '', 'teaser_sort_order_' . $this->_id);
944:
945:
946: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
947: $htmlSelect->appendOptionElement($htmlSelectOption);
948:
949:
950: $htmlSelectOption = new cHTMLOptionElement(i18n("Ascending"), 'asc', false);
951: $htmlSelect->appendOptionElement($htmlSelectOption);
952:
953: $htmlSelectOption = new cHTMLOptionElement(i18n("Descending"), 'desc', false);
954: $htmlSelect->appendOptionElement($htmlSelectOption);
955:
956:
957: $htmlSelect->setDefault($this->_settings['teaser_sort_order']);
958:
959: return $htmlSelect->render();
960: }
961:
962: 963: 964: 965: 966: 967:
968: private function _generateCropSelect() {
969: $htmlSelect = new cHTMLSelectElement('teaser_image_crop_' . $this->_id, '', 'teaser_image_crop_' . $this->_id);
970:
971:
972: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
973: $htmlSelect->appendOptionElement($htmlSelectOption);
974:
975:
976: $htmlSelectOption = new cHTMLOptionElement(i18n("Scaled"), 'false', false);
977: $htmlSelect->appendOptionElement($htmlSelectOption);
978:
979: $htmlSelectOption = new cHTMLOptionElement(i18n("Cropped"), 'true', false);
980: $htmlSelect->appendOptionElement($htmlSelectOption);
981:
982:
983: $htmlSelect->setDefault($this->_settings['teaser_image_crop']);
984:
985: return $htmlSelect->render();
986: }
987:
988: 989: 990: 991: 992: 993: 994:
995: private function _generateTabManual() {
996:
997: $wrapper = new cHTMLDiv();
998: $wrapperContent = array();
999:
1000: $wrapperContent[] = new cHTMLParagraph(i18n("Content visualisation"), 'head_sub');
1001: $wrapperContent[] = new cHTMLLabel(i18n("Teaser visualisation"), 'teaser_style');
1002: $wrapperContent[] = $this->_generateStyleSelect();
1003: $wrapperContent[] = new cHTMLLabel(i18n("Teaser filter"), 'teaser_filter_' . $this->_id);
1004: $wrapperContent[] = new cHTMLTextbox('teaser_filter_' . $this->_id, $this->_settings['teaser_filter'], '', '', 'teaser_filter_' . $this->_id);
1005: $wrapperContent[] = new cHTMLLabel(i18n('Character length'), 'teaser_character_limit_' . $this->_id);
1006: $wrapperContent[] = new cHTMLTextbox('teaser_character_limit_' . $this->_id, $this->_settings['teaser_character_limit'], '', '', 'teaser_character_limit_' . $this->_id);
1007:
1008: $wrapperContent[] = new cHTMLParagraph(i18n("Pictures"), 'head_sub');
1009: $wrapperContent[] = new cHTMLLabel(i18n('Image width'), 'teaser_image_width_' . $this->_id);
1010: $wrapperContent[] = new cHTMLTextbox('teaser_image_width_' . $this->_id, $this->_settings['teaser_image_width'], '', '', 'teaser_image_width_' . $this->_id);
1011: $wrapperContent[] = new cHTMLLabel(i18n('Image height'), 'teaser_image_height_' . $this->_id);
1012: $wrapperContent[] = new cHTMLTextbox('teaser_image_height_' . $this->_id, $this->_settings['teaser_image_height'], '', '', 'teaser_image_height_' . $this->_id);
1013: $wrapperContent[] = new cHTMLLabel(i18n('Image scale'), 'teaser_image_crop_' . $this->_id);
1014: $wrapperContent[] = $this->_generateCropSelect();
1015:
1016: $wrapperContent[] = new cHTMLParagraph(i18n("Content types"), 'head_sub');
1017: $wrapperContent[] = new cHTMLLabel(i18n("Headline source"), 'teaser_source_head_' . $this->_id);
1018: $wrapperContent[] = $this->_generateTypeSelect('teaser_source_head_' . $this->_id, $this->_settings['teaser_source_head'], $this->_settings['teaser_source_head_count']);
1019: $wrapperContent[] = new cHTMLLabel(i18n("Text source"), 'teaser_source_text_' . $this->_id);
1020: $wrapperContent[] = $this->_generateTypeSelect('teaser_source_text_' . $this->_id, $this->_settings['teaser_source_text'], $this->_settings['teaser_source_text_count']);
1021: $wrapperContent[] = new cHTMLLabel(i18n('Image source'), 'teaser_source_image_' . $this->_id);
1022: $wrapperContent[] = $this->_generateTypeSelect('teaser_source_image_' . $this->_id, $this->_settings['teaser_source_image'], $this->_settings['teaser_source_image_count']);
1023: $wrapperContent[] = new cHTMLLabel(i18n('Date source'), 'teaser_source_date_' . $this->_id);
1024: $wrapperContent[] = $this->_generateTypeSelect('teaser_source_date_' . $this->_id, $this->_settings['teaser_source_date'], $this->_settings['teaser_source_date_count']);
1025:
1026: $wrapper->setContent($wrapperContent);
1027: return $wrapper->render();
1028: }
1029:
1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037:
1038: private function _getArtName($idArt) {
1039: $article = new cApiArticleLanguage();
1040: $article->loadByArticleAndLanguageId((int) $idArt, $this->_lang);
1041:
1042: $title = $article->get('title');
1043: if ($article->isLoaded() && !empty($title)) {
1044: return $article->get('title');
1045: } else {
1046: return i18n('Unknown article');
1047: }
1048: }
1049:
1050: }
1051: