1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: $teaserIndex = 5;
18:
19: $cfgClient = cRegistry::getClientConfig();
20: $client = cRegistry::getClientId();
21: $filename = $cfgClient[$client]['xml']['frontendpath'] . 'rss.xml';
22:
23: $labelRssTitle = mi18n("LABEL_RSS_TITLE");
24: $labelRssLink = mi18n("LABEL_RSS_LINK");
25: $labelRssDescription = mi18n("LABEL_RSS_DESCRIPTION");
26: $labelRssConfiguration = mi18n("LABEL_RSS_CONFIGURATION");
27: $labelRssH1 = mi18n("LABEL_RSS_H1");
28: $labelRssLogo = mi18n("LABEL_RSS_LOGO");
29: $labelRssSource = mi18n("LABEL_RSS_SOURCE");
30:
31: $rssTitle = "CMS_TEXT[1]";
32: $rssLink = "CMS_TEXT[2]";
33: $rssDescription = "CMS_HTML[1]";
34: $rssConfiguration = '';
35: $rssLogo = "CMS_IMGEDITOR[1]";
36: $rssLogoDisplay = "CMS_IMG[1]";
37: $rssSource = $filename;
38:
39: $tpl = cSmartyFrontend::getInstance();
40: $tpl->assign('label_rss_title', $labelRssTitle);
41: $tpl->assign('label_rss_link', $labelRssLink);
42: $tpl->assign('label_rss_description', $labelRssDescription);
43: $tpl->assign('label_rss_configuration', $labelRssConfiguration);
44: $tpl->assign('label_rss_h1', $labelRssH1);
45: $tpl->assign('label_rss_logo', $labelRssLogo);
46: $tpl->assign('label_rss_source', $labelRssSource);
47: $tpl->assign('rss_title', $rssTitle);
48: $tpl->assign('rss_source', $rssSource);
49: $tpl->assign('rss_link', $rssLink);
50: $tpl->assign('rss_logo', $rssLogo);
51: $tpl->assign('rss_logo_display', $rssLogoDisplay);
52: $tpl->assign('rss_description', $rssDescription);
53: $tpl->assign('rss_configuration', $rssConfiguration);
54: $tpl->display('rss_edit.tpl');
55:
56: echo "CMS_TEASER[5]";
57:
58: $art = new cApiArticleLanguage(cRegistry::getArticleLanguageId());
59: $contentValue = $art->getContent("TEASER", $teaserIndex);
60:
61: $teaser = new cContentTypeTeaser($contentValue, $teaserIndex, array());
62: $articles = $teaser->getConfiguredArticles();
63: $configuration = $teaser->getConfiguration();
64:
65: $xmlString = '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"></rss>';
66: function addCData($cdata_text)
67: {
68: $node= dom_import_simplexml($this);
69: $no = $node->ownerDocument;
70: $node->appendChild($no->createCDATASection($cdata_text));
71: }
72:
73: $rssFeed = new SimpleXMLElement($xmlString);
74: $rssChannel = $rssFeed->addChild('channel');
75: $rssChannel->title = $art->getContent("CMS_TEXT", 1);
76: $rssChannel->link = $art->getContent("CMS_TEXT", 2);
77: $rssChannel->description = conHtmlEntityDecode(strip_tags($art->getContent("CMS_HTML", 1)));;
78:
79: $imgId = $art->getContent("CMS_IMG", 1);
80:
81: if ((int) $imgId > 0) {
82: $upload = new cApiUpload($imgId);
83: $rssLogo = $cfgClient[$client]['path']['htmlpath'] . 'upload/' . $upload->get('dirname') . $upload->get('filename');
84:
85: $rssImage = $rssChannel->addChild('image');
86: $rssImage->url = $rssLogo;
87: $rssImage->title = $art->getContent("CMS_TEXT", 1);
88: $rssImage->link = $art->getContent("CMS_TEXT", 2);
89: }
90:
91: foreach ($articles as $article) {
92: $child = $rssChannel->addChild('item');
93: $title = strip_tags($article->getContent('HTMLHEAD', 1));
94: $text = strip_tags($article->getContent('HTML', 1));
95: $text = cApiStrTrimAfterWord($text, $configuration['teaser_character_limit']);
96: $link = $cfgClient[$client]['path']['htmlpath'] . $article->getLink();
97:
98: $child->title = conHtmlEntityDecode(conHtmlSpecialChars($title));
99: $child->link = conHtmlEntityDecode($link);
100: $child->description = conHtmlEntityDecode($text);
101: $child->pubDate = date('D, d M Y H:i:s T', strtotime($article->getField('published')));
102: }
103:
104: $result = mi18n("LABEL_RSS_CREATION_FAILED");
105: if (isset($cfgClient[$client]['xml']['frontendpath'])) {
106: if (false === cFileHandler::exists($cfgClient[$client]['xml']['frontendpath'])) {
107: cDirHandler::create($cfgClient[$client]['xml']['frontendpath'], true);
108: }
109:
110: $success = $rssFeed->asXML($filename);
111: if (false !== $success) {
112: $result = mi18n("LABEL_RSS_CREATED");
113: }
114:
115: }
116:
117: $tpl = cSmartyFrontend::getInstance();
118: $tpl->assign('RESULT_MSG', $result);
119: $tpl->display('result.tpl');
120:
121: ?>