Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Functions

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