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