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