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