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: if ($returnAsArray == true) {
312: array_push($articles, $article);
313: } else {
314: $this->_fillTeaserTemplateEntry($article, $template);
315: }
316: }
317: }
318:
319: $code = '';
320:
321:
322: if ($returnAsArray == false && file_exists($this->_cfgClient[$this->_client]['path']['frontend'] . 'templates/' . $this->_settings['teaser_style'])) {
323: $code = $template->generate($this->_cfgClient[$this->_client]['path']['frontend'] . 'templates/' . $this->_settings['teaser_style'], true);
324: return $code;
325: } else if ($returnAsArray == true) {
326: return $articles;
327: }
328: }
329:
330: 331: 332: 333: 334: 335: 336: 337:
338: private function _fillTeaserTemplateEntry(cApiArticleLanguage $article, cTemplate &$template) {
339: global $contenido;
340:
341:
342:
343: $title = $this->_getArtContent($article, $this->_settings['teaser_source_head'], $this->_settings['teaser_source_head_count']);
344: $text = $this->_getArtContent($article, $this->_settings['teaser_source_text'], $this->_settings['teaser_source_text_count']);
345: $imageId = $this->_getArtContent($article, $this->_settings['teaser_source_image'], $this->_settings['teaser_source_image_count']);
346: $date = $this->_getArtContent($article, $this->_settings['teaser_source_date'], $this->_settings['teaser_source_date_count']);
347: $idArt = $article->getField('idart');
348: $published = $article->getField('published');
349: $online = $article->getField('online');
350:
351: if ($online == 1 || $contenido) {
352:
353:
354:
355:
356: if ($this->_settings['teaser_filter'] != '') {
357: $iPosText = strrpos(conHtmlEntityDecode($text), $this->_settings['teaser_filter']);
358: $iPosHead = strrpos(conHtmlEntityDecode($title), $this->_settings['teaser_filter']);
359: if (is_bool($iPosText) && !$iPosText && is_bool($iPosHead) && !$iPosHead) {
360: return false;
361: }
362: }
363:
364:
365: if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/', $published, $results)) {
366: $published = $results[3] . '.' . $results[2] . '.' . $results[1];
367: }
368:
369:
370: $title = trim(strip_tags($title));
371: $text = trim(strip_tags($text));
372: if (strlen($text) > $this->_settings['teaser_character_limit']) {
373: $text = capiStrTrimAfterWord($text, $this->_settings['teaser_character_limit']) . '...';
374: }
375:
376:
377:
378: if ((int) $imageId > 0) {
379: $image = $this->_getImage($imageId, $this->_settings['teaser_image_width'], $this->_settings['teaser_image_height'], $this->_settings['teaser_image_crop']);
380: $template->set('d', 'IMAGE', $image['element']);
381: $template->set('d', 'IMAGE_SRC', $image['src']);
382: } else if (strip_tags($imageId) != $imageId && strlen($imageId) > 0) {
383: $image = $this->_extractImage($imageId);
384: if (strlen($image) > 0) {
385: $template->set('d', 'IMAGE', $image['element']);
386: $template->set('d', 'IMAGE_SRC', $image['src']);
387: } else {
388: $template->set('d', 'IMAGE', '');
389: $template->set('d', 'IMAGE_SRC', '');
390: }
391: } else {
392: $template->set('d', 'IMAGE_SRC', '');
393: $template->set('d', 'IMAGE', '');
394: }
395:
396:
397: $date = strip_tags($date);
398:
399:
400: $template->set('d', 'TITLE', $title);
401: $template->set('d', 'TEXT', $text);
402:
403: $template->set('d', 'IDART', $idArt);
404: $template->set('d', 'ART_URL', 'front_content.php?idart=' . $idArt);
405: $template->set('d', 'PUBLISHED', $published);
406: $template->set('d', 'PUBLISHED_MANUAL', $date);
407:
408: if ($date != '') {
409: $template->set('d', 'PUBLISHED_COMBINED', $date);
410: } else {
411: $template->set('d', 'PUBLISHED_COMBINED', $published);
412: }
413:
414: foreach (self::$_translations as $translationString) {
415: $template->set('d', $translationString, mi18n($translationString));
416: }
417:
418: if ($this->iteration == 0) {
419: $template->set('d', 'ACTIVE', 'active');
420: } else {
421: $template->set('d', 'ACTIVE', '');
422: }
423: $this->iteration++;
424:
425: $template->next();
426: }
427:
428: return true;
429: }
430:
431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441:
442: private function _getArtContent(cApiArticleLanguage &$article, $contentTypeName, $ids) {
443: $this->_initCmsTypes();
444:
445: $return = '';
446:
447:
448: foreach (explode(',', $ids) as $currentId) {
449: if ($this->_forwardTypes[$contentTypeName] != "") {
450: $contentTypeName = $this->_forwardTypes[$contentTypeName];
451: }
452: $return .= ' ' . $article->getContent($contentTypeName, $currentId);
453: }
454:
455: return $return;
456: }
457:
458: 459: 460: 461: 462: 463: 464: 465:
466: private function ($content) {
467: $image = array();
468:
469:
470: $regEx = "/<img[^>]*?>.*?/i";
471:
472: $match = array();
473: preg_match($regEx, $content, $match);
474:
475:
476: $regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
477: $img = array();
478: preg_match($regEx, $match[0], $img);
479:
480:
481: $pos = strrpos($img[4], $this->_cfgClient[$this->_client]['upload']);
482: if (!is_bool($pos)) {
483:
484:
485: $file = $this->_cfgClient[$this->_client]['path']['frontend'] . $img[4];
486: $image = $this->_getImage($file, $this->_settings['teaser_image_width'], $this->_settings['teaser_image_height'], $this->_settings['teaser_image_crop'], true);
487: }
488:
489: return $image;
490: }
491:
492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505:
506: private function _getImage($image, $maxX, $maxY, $cropped, $isFile = false) {
507: $content = '';
508: $return = array();
509:
510: if ($cropped == 'true') {
511: $cropped = true;
512: } else {
513: $cropped = false;
514: }
515:
516:
517: if ($isFile == false) {
518: $upload = new cApiUpload($image);
519: $dirname = $upload->get('dirname');
520: $filename = $upload->get('filename');
521: if (!empty($dirname) && !empty($filename)) {
522: $teaserImage = $this->_cfgClient[$this->_client]['path']['frontend'] . 'upload/' . $dirname . $filename;
523: }
524: } else {
525: $teaserImage = $image;
526: }
527:
528:
529: if (file_exists($teaserImage)) {
530:
531: $imgSrc = cApiImgScale($teaserImage, $maxX, $maxY, $cropped);
532:
533: if ($this->_useXHTML == 'true') {
534: $letter = ' /';
535: } else {
536: $letter = '';
537: }
538:
539:
540: $content = '<img alt="" src="' . $imgSrc . '" class="teaser_image"' . $letter . '>' . $content;
541: }
542:
543: $return['element'] = $content;
544: $return['src'] = $imgSrc;
545:
546: return $return;
547: }
548:
549: 550: 551: 552: 553: 554:
555: public function generateEditCode() {
556: $this->_initCmsTypes();
557:
558: $template = new cTemplate();
559:
560: $template->set('s', 'ID', $this->_id);
561: $template->set('s', 'IDARTLANG', $this->_idArtLang);
562: $template->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
563:
564: $templateTabs = new cTemplate();
565: $templateTabs->set('s', 'PREFIX', $this->_prefix);
566:
567:
568: $templateTabs->set('d', 'TAB_ID', 'general');
569: $templateTabs->set('d', 'TAB_CLASS', 'general');
570: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabGeneral());
571: $templateTabs->next();
572:
573:
574: $templateTabs->set('d', 'TAB_ID', 'advanced');
575: $templateTabs->set('d', 'TAB_CLASS', 'advanced');
576: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabAdvanced());
577: $templateTabs->next();
578:
579:
580: $templateTabs->set('d', 'TAB_ID', 'manual');
581: $templateTabs->set('d', 'TAB_CLASS', 'manual');
582: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabManual());
583: $templateTabs->next();
584:
585: $codeTabs = $templateTabs->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
586:
587:
588: $templateTop = new cTemplate();
589: $templateTop->set('s', 'ICON', 'images/isstart0.gif');
590: $templateTop->set('s', 'ID', $this->_id);
591: $templateTop->set('s', 'PREFIX', $this->_prefix);
592: $templateTop->set('s', 'HEADLINE', i18n('Teaser settings'));
593: $codeTop = $templateTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
594:
595:
596: $tabMenu = array(
597: 'general' => i18n('Automatic'),
598: 'advanced' => i18n('Manual'),
599: 'manual' => i18n('Settings')
600: );
601:
602:
603: $templateBottom = new cTemplate();
604: $templateBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
605: $templateBottom->set('s', 'ID', $this->_id);
606: $templateBottom->set('s', 'PREFIX', $this->_prefix);
607: $templateBottom->set('s', 'IDARTLANG', $this->_idArtLang);
608: $templateBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
609: $templateBottom->set('s', 'SETTINGS', json_encode($this->_settings));
610: $templateBottom->set('s', 'JS_CLASS_SCRIPT', $this->_cfg['path']['contenido_fullhtml'] . 'scripts/content_types/cmsTeaser.js');
611: $templateBottom->set('s', 'JS_CLASS_NAME', 'Con.cContentTypeTeaser');
612: $codeBottom = $templateBottom->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_bottom.html', true);
613:
614:
615: $code = $this->generateViewCode();
616: $code .= $this->_encodeForOutput($codeTop);
617: $code .= $this->_generateTabMenuCode($tabMenu);
618: $code .= $this->_encodeForOutput($codeTabs);
619: $code .= $this->_generateActionCode();
620: $code .= $this->_encodeForOutput($codeBottom);
621:
622: return $code;
623: }
624:
625: 626: 627: 628: 629: 630:
631: private function _initCmsTypes() {
632: if (!empty($this->_cmsTypes)) {
633: return;
634: }
635:
636: $this->_cmsTypes = array();
637:
638: $sql = 'SELECT * FROM ' . $this->_cfg['tab']['type'] . ' ORDER BY type';
639: $db = cRegistry::getDb();
640: $db->query($sql);
641: while ($db->nextRecord()) {
642:
643: if (in_array($db->f('type'), $this->_ignoreTypes)) {
644: continue;
645: }
646: $this->_cmsTypes[$db->f('idtype')] = $db->f('type');
647: }
648: }
649:
650: 651: 652: 653: 654:
655: private function _generateTabGeneral() {
656:
657: $wrapper = new cHTMLDiv();
658: $wrapperContent = array();
659:
660:
661:
662: $wrapperContent[] = new cHTMLLabel(i18n('Teaser title'), 'teaser_title_' . $this->_id);
663: $wrapperContent[] = new cHTMLTextbox('teaser_title_' . $this->_id, $this->_settings['teaser_title'], '', '', 'teaser_title_' . $this->_id);
664: $wrapperContent[] = new cHTMLLabel(i18n('Source category'), 'teaser_category_' . $this->_id);
665: $wrapperContent[] = buildCategorySelect('teaser_category_' . $this->_id, $this->_settings['teaser_category'], 0);
666: $wrapperContent[] = new cHTMLLabel(i18n('Number of articles'), 'teaser_count_' . $this->_id);
667: $wrapperContent[] = $this->_generateCountSelect();
668:
669: $wrapperContent[] = new cHTMLLabel(i18n("Include start article"), 'teaser_start_' . $this->_id);
670: $wrapperContent[] = new cHTMLCheckbox('teaser_start_' . $this->_id, '', 'teaser_start_' . $this->_id, ($this->_settings['teaser_start'] == 'true'));
671:
672: $wrapperContent[] = new cHTMLLabel(i18n("Teaser sort"), 'teaser_sort_' . $this->_id);
673: $wrapperContent[] = $this->_generateSortSelect();
674: $wrapperContent[] = new cHTMLLabel(i18n("Sort order"), 'teaser_sort_order_' . $this->_id);
675: $wrapperContent[] = $this->_generateSortOrderSelect();
676:
677: $wrapper->setContent($wrapperContent);
678: return $wrapper->render();
679: }
680:
681: 682: 683: 684: 685: 686: 687:
688: private function _generateCountSelect() {
689: $htmlSelect = new cHTMLSelectElement('teaser_count_' . $this->_id, '', 'teaser_count_' . $this->_id);
690:
691:
692: $htmlSelectOption = new cHTMLOptionElement(i18n('Please choose'), '', true);
693: $htmlSelect->appendOptionElement($htmlSelectOption);
694:
695:
696:
697: for ($i = 1; $i <= 20; $i++) {
698: $htmlSelectOption = new cHTMLOptionElement($i, $i, false);
699: $htmlSelect->appendOptionElement($htmlSelectOption);
700: }
701:
702:
703: $htmlSelect->setDefault($this->_settings['teaser_count']);
704:
705: return $htmlSelect->render();
706: }
707:
708: 709: 710: 711: 712: 713:
714: private function _generateStyleSelect() {
715: $htmlSelect = new cHTMLSelectElement('teaser_style_' . $this->_id, '', 'teaser_style_' . $this->_id);
716:
717:
718: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
719: $htmlSelect->appendOptionElement($htmlSelectOption);
720:
721:
722: $htmlSelectOption = new cHTMLOptionElement(i18n("Slider style"), 'cms_teaser_slider.html', false);
723: $htmlSelect->appendOptionElement($htmlSelectOption);
724:
725: $htmlSelectOption = new cHTMLOptionElement(i18n("Image style"), 'cms_teaser_image.html', false);
726: $htmlSelect->appendOptionElement($htmlSelectOption);
727:
728: $htmlSelectOption = new cHTMLOptionElement(i18n("Text style"), 'cms_teaser_text.html', false);
729: $htmlSelect->appendOptionElement($htmlSelectOption);
730:
731: $htmlSelectOption = new cHTMLOptionElement(i18n("Blog style"), 'cms_teaser_blog.html', false);
732: $htmlSelect->appendOptionElement($htmlSelectOption);
733:
734: $additionalOptions = getEffectiveSettingsByType('cms_teaser');
735: foreach ($additionalOptions as $sLabel => $sTemplate) {
736: $htmlSelectOption = new cHTMLOptionElement($sLabel, $sTemplate, false);
737: $htmlSelect->appendOptionElement($htmlSelectOption);
738: }
739:
740:
741: $htmlSelect->setDefault($this->_settings['teaser_style']);
742:
743: return $htmlSelect->render();
744: }
745:
746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760:
761: private function _generateTypeSelect($selectName, $selected, $value) {
762:
763: $inputName = str_replace('_' . $this->_id, '_count_' . $this->_id, $selectName);
764:
765: $htmlInput = new cHTMLTextbox($inputName, $value, '', '', $inputName, false, '', '', 'teaser_type_count');
766:
767:
768: $htmlSelect = new cHTMLSelectElement($selectName, '', $selectName);
769: $htmlSelect->setClass('teaser_type_select');
770:
771: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
772: $htmlSelect->addOptionElement(0, $htmlSelectOption);
773:
774:
775:
776: foreach ($this->_cmsTypes as $key => $value) {
777: $htmlSelectOption = new cHTMLOptionElement($value, $value, false);
778: $htmlSelect->addOptionElement($key, $htmlSelectOption);
779: }
780:
781:
782: $htmlSelect->setDefault($selected);
783:
784: return $htmlSelect->render() . $htmlInput->render();
785: }
786:
787: 788: 789: 790: 791: 792:
793: private function _generateTabAdvanced() {
794:
795: $wrapper = new cHTMLDiv();
796: $wrapperContent = array();
797:
798:
799:
800: $wrapperContent[] = new cHTMLLabel(i18n('Manual teaser'), 'teaser_manual_' . $this->_id);
801: $wrapperContent[] = new cHTMLCheckbox('teaser_manual_' . $this->_id, '', 'teaser_manual_' . $this->_id, ($this->_settings['teaser_manual'] == 'true'));
802:
803:
804:
805: $wrapperContent[] = new cHTMLLabel(i18n('Category'), 'teaser_cat_' . $this->_id);
806: $wrapperContent[] = buildCategorySelect('teaser_cat_' . $this->_id, 0, 0);
807: $wrapperContent[] = new cHTMLLabel(i18n('Article'), 'teaser_art_' . $this->_id);
808: $wrapperContent[] = buildArticleSelect('teaser_art_' . $this->_id, 0, 0);
809:
810: $wrapperContent[] = new cHTMLLabel(i18n('Add'), 'add_art_' . $this->_id);
811: $image = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/but_art_new.gif');
812: $image->setAttribute('id', 'add_art_' . $this->_id);
813: $image->appendStyleDefinition('cursor', 'pointer');
814: $wrapperContent[] = $image;
815:
816: $wrapperContent[] = new cHTMLParagraph(i18n('Included articles'), 'head_sub');
817: $selectElement = new cHTMLSelectElement('teaser_manual_art_' . $this->_id, '', 'teaser_manual_art_' . $this->_id, false, '', '', 'manual');
818: $selectElement->setAttribute('size', '4');
819: $selectElement->setAttribute('multiple', 'multiple');
820:
821: if (is_array($this->_settings['teaser_manual_art'])) {
822: foreach ($this->_settings['teaser_manual_art'] as $index => $idArt) {
823: $option = new cHTMLOptionElement($this->_getArtName($idArt), $idArt, true);
824: $selectElement->addOptionElement($index, $option);
825: }
826: } else {
827:
828: $artName = $this->_getArtName($this->_settings['teaser_manual_art']);
829: if ($artName != i18n('Unknown article')) {
830: $option = new cHTMLOptionElement($artName, $this->_settings['teaser_manual_art'], true);
831: $selectElement->addOptionElement(0, $option);
832: }
833: }
834: $wrapperContent[] = $selectElement;
835:
836: $wrapperContent[] = new cHTMLLabel(i18n("Delete"), 'del_art_' . $this->_id);
837: $image = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/delete.gif');
838: $image->setAttribute('id', 'del_art_' . $this->_id);
839: $image->appendStyleDefinition('cursor', 'pointer');
840: $wrapperContent[] = $image;
841:
842: $wrapper->setContent($wrapperContent);
843: return $wrapper->render();
844: }
845:
846: 847: 848: 849: 850: 851:
852: private function _generateSortSelect() {
853: $htmlSelect = new cHTMLSelectElement('teaser_sort_' . $this->_id, '', 'teaser_sort_' . $this->_id);
854:
855:
856: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
857: $htmlSelect->appendOptionElement($htmlSelectOption);
858:
859:
860: $htmlSelectOption = new cHTMLOptionElement(i18n("Sort sequence"), 'sortsequence', false);
861: $htmlSelect->appendOptionElement($htmlSelectOption);
862:
863: $htmlSelectOption = new cHTMLOptionElement(i18n("Creation date"), 'creationdate', false);
864: $htmlSelect->appendOptionElement($htmlSelectOption);
865:
866: $htmlSelectOption = new cHTMLOptionElement(i18n("Published date"), 'publisheddate', false);
867: $htmlSelect->appendOptionElement($htmlSelectOption);
868:
869: $htmlSelectOption = new cHTMLOptionElement(i18n("Modification date"), 'modificationdate', false);
870: $htmlSelect->appendOptionElement($htmlSelectOption);
871:
872:
873: $htmlSelect->setDefault($this->_settings['teaser_sort']);
874:
875: return $htmlSelect->render();
876: }
877:
878: 879: 880: 881: 882: 883:
884: private function _generateSortOrderSelect() {
885: $htmlSelect = new cHTMLSelectElement('teaser_sort_order_' . $this->_id, '', 'teaser_sort_order_' . $this->_id);
886:
887:
888: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
889: $htmlSelect->appendOptionElement($htmlSelectOption);
890:
891:
892: $htmlSelectOption = new cHTMLOptionElement(i18n("Ascending"), 'asc', false);
893: $htmlSelect->appendOptionElement($htmlSelectOption);
894:
895: $htmlSelectOption = new cHTMLOptionElement(i18n("Descending"), 'desc', false);
896: $htmlSelect->appendOptionElement($htmlSelectOption);
897:
898:
899: $htmlSelect->setDefault($this->_settings['teaser_sort_order']);
900:
901: return $htmlSelect->render();
902: }
903:
904: 905: 906: 907: 908:
909: private function _generateCropSelect() {
910: $htmlSelect = new cHTMLSelectElement('teaser_image_crop_' . $this->_id, '', 'teaser_image_crop_' . $this->_id);
911:
912:
913: $htmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
914: $htmlSelect->appendOptionElement($htmlSelectOption);
915:
916:
917: $htmlSelectOption = new cHTMLOptionElement(i18n("Scaled"), 'false', false);
918: $htmlSelect->appendOptionElement($htmlSelectOption);
919:
920: $htmlSelectOption = new cHTMLOptionElement(i18n("Cropped"), 'true', false);
921: $htmlSelect->appendOptionElement($htmlSelectOption);
922:
923:
924: $htmlSelect->setDefault($this->_settings['teaser_image_crop']);
925:
926: return $htmlSelect->render();
927: }
928:
929: 930: 931: 932: 933: 934:
935: private function _generateTabManual() {
936:
937: $wrapper = new cHTMLDiv();
938: $wrapperContent = array();
939:
940: $wrapperContent[] = new cHTMLParagraph(i18n("Content visualisation"), 'head_sub');
941: $wrapperContent[] = new cHTMLLabel(i18n("Teaser visualisation"), 'teaser_style');
942: $wrapperContent[] = $this->_generateStyleSelect();
943: $wrapperContent[] = new cHTMLLabel(i18n("Teaser filter"), 'teaser_filter_' . $this->_id);
944: $wrapperContent[] = new cHTMLTextbox('teaser_filter_' . $this->_id, $this->_settings['teaser_filter'], '', '', 'teaser_filter_' . $this->_id);
945: $wrapperContent[] = new cHTMLLabel(i18n('Character length'), 'teaser_character_limit_' . $this->_id);
946: $wrapperContent[] = new cHTMLTextbox('teaser_character_limit_' . $this->_id, $this->_settings['teaser_character_limit'], '', '', 'teaser_character_limit_' . $this->_id);
947:
948: $wrapperContent[] = new cHTMLParagraph(i18n("Pictures"), 'head_sub');
949: $wrapperContent[] = new cHTMLLabel(i18n('Image width'), 'teaser_image_width_' . $this->_id);
950: $wrapperContent[] = new cHTMLTextbox('teaser_image_width_' . $this->_id, $this->_settings['teaser_image_width'], '', '', 'teaser_image_width_' . $this->_id);
951: $wrapperContent[] = new cHTMLLabel(i18n('Image height'), 'teaser_image_height_' . $this->_id);
952: $wrapperContent[] = new cHTMLTextbox('teaser_image_height_' . $this->_id, $this->_settings['teaser_image_height'], '', '', 'teaser_image_height_' . $this->_id);
953: $wrapperContent[] = new cHTMLLabel(i18n('Image scale'), 'teaser_image_crop_' . $this->_id);
954: $wrapperContent[] = $this->_generateCropSelect();
955:
956: $wrapperContent[] = new cHTMLParagraph(i18n("Content types"), 'head_sub');
957: $wrapperContent[] = new cHTMLLabel(i18n("Headline source"), 'teaser_source_head_' . $this->_id);
958: $wrapperContent[] = $this->_generateTypeSelect('teaser_source_head_' . $this->_id, $this->_settings['teaser_source_head'], $this->_settings['teaser_source_head_count']);
959: $wrapperContent[] = new cHTMLLabel(i18n("Text source"), 'teaser_source_text_' . $this->_id);
960: $wrapperContent[] = $this->_generateTypeSelect('teaser_source_text_' . $this->_id, $this->_settings['teaser_source_text'], $this->_settings['teaser_source_text_count']);
961: $wrapperContent[] = new cHTMLLabel(i18n('Image source'), 'teaser_source_image_' . $this->_id);
962: $wrapperContent[] = $this->_generateTypeSelect('teaser_source_image_' . $this->_id, $this->_settings['teaser_source_image'], $this->_settings['teaser_source_image_count']);
963: $wrapperContent[] = new cHTMLLabel(i18n('Date source'), 'teaser_source_date_' . $this->_id);
964: $wrapperContent[] = $this->_generateTypeSelect('teaser_source_date_' . $this->_id, $this->_settings['teaser_source_date'], $this->_settings['teaser_source_date_count']);
965:
966: $wrapper->setContent($wrapperContent);
967: return $wrapper->render();
968: }
969:
970: 971: 972: 973: 974: 975:
976: private function _getArtName($idArt) {
977: $article = new cApiArticleLanguage();
978: $article->loadByArticleAndLanguageId((int) $idArt, $this->_lang);
979:
980: $title = $article->get('title');
981: if ($article->isLoaded() && !empty($title)) {
982: return $article->get('title');
983: } else {
984: return i18n('Unknown article');
985: }
986: }
987:
988: }