示例#1
0
 function _createRSS()
 {
     global $_CONFIG, $objDatabase;
     $this->_arrSettings =& $this->_getSettings();
     $arrMedia = array();
     $objMedium = $objDatabase->Execute("\n            SELECT tblMedium.id,\n                   tblMedium.title,\n                   tblMedium.author,\n                   tblMedium.description,\n                   tblMedium.source,\n                   tblMedium.size,\n                   tblMedium.date_added,\n                   tblCategory.id AS categoryId,\n                   tblCategory.title AS categoryTitle\n            FROM " . DBPREFIX . "module_podcast_medium AS tblMedium\n            LEFT JOIN " . DBPREFIX . "module_podcast_rel_medium_category AS tblRel ON tblRel.medium_id=tblMedium.id\n            LEFT JOIN " . DBPREFIX . "module_podcast_category AS tblCategory ON tblCategory.id=tblRel.category_id\n            WHERE tblMedium.status=1\n            ORDER BY tblMedium.date_added DESC");
     if ($objMedium !== false) {
         while (!$objMedium->EOF) {
             if (!isset($arrMedia[$objMedium->fields['id']])) {
                 $arrMedia[$objMedium->fields['id']] = array('title' => $objMedium->fields['title'], 'author' => $objMedium->fields['author'], 'description' => $objMedium->fields['description'], 'source' => str_replace(array('%domain%', '%offset%'), array($_CONFIG['domainUrl'], ASCMS_PATH_OFFSET), $objMedium->fields['source']), 'size' => $objMedium->fields['size'], 'date_added' => $objMedium->fields['date_added'], 'categories' => array());
             }
             if (!empty($objMedium->fields['id'])) {
                 $arrMedia[$objMedium->fields['id']]['categories'][$objMedium->fields['categoryId']] = $objMedium->fields['categoryTitle'];
             }
             $objMedium->MoveNext();
         }
     }
     $objRSSWriter = new \RSSWriter();
     $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
     $objRSSWriter->channelTitle = $this->_arrSettings['feed_title'];
     $objRSSWriter->channelLink = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/index.php?section=Podcast';
     $objRSSWriter->channelDescription = $this->_arrSettings['feed_description'];
     $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
     if (!empty($this->_arrSettings['feed_image'])) {
         $objRSSWriter->channelImageUrl = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . intval($_SERVER['SERVER_PORT'])) . $this->_arrSettings['feed_image'];
         $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle;
         $objRSSWriter->channelImageLink = $objRSSWriter->channelLink;
     }
     $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
     $itemLink = "http://" . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . "/index.php?section=Podcast&id=";
     $categoryLink = "http://" . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . "/index.php?section=Podcast&cid=";
     // create podcast feed
     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/podcast.xml';
     foreach ($arrMedia as $mediumId => $arrMedium) {
         $arrCategories = array();
         foreach ($arrMedium['categories'] as $categoryId => $categoryTitle) {
             array_push($arrCategories, array('domain' => htmlspecialchars($categoryLink . $categoryId, ENT_QUOTES, CONTREXX_CHARSET), 'title' => htmlspecialchars($categoryTitle, ENT_QUOTES, CONTREXX_CHARSET)));
         }
         $objRSSWriter->addItem(htmlspecialchars($arrMedium['title'], ENT_QUOTES, CONTREXX_CHARSET), $itemLink . $mediumId, htmlspecialchars($arrMedium['description'], ENT_QUOTES, CONTREXX_CHARSET), htmlspecialchars($arrMedium['author'], ENT_QUOTES, CONTREXX_CHARSET), $arrCategories, '', array('url' => htmlspecialchars($arrMedium['source'], ENT_QUOTES, CONTREXX_CHARSET), 'length' => !empty($arrMedium['size']) ? $arrMedium['size'] : 'N/A', 'type' => 'application/x-video'), '', $arrMedium['date_added']);
     }
     $status = $objRSSWriter->write();
     if (count($objRSSWriter->arrErrorMsg) > 0) {
         $this->_strErrMessage .= implode('<br />', $objRSSWriter->arrErrorMsg);
     }
     if (count($objRSSWriter->arrWarningMsg) > 0) {
         $this->_strErrMessage .= implode('<br />', $objRSSWriter->arrWarningMsg);
     }
     return $status;
 }
示例#2
0
 /**
  * Writes RSS feed containing the latest N messages of each category the feed-directory. This is done for every language seperately.
  *
  * @global  array
  * @global  array
  * @global  FWLanguage
  */
 function writeCategoryRSS()
 {
     global $_CONFIG, $_ARRAYLANG;
     if (intval($this->_arrSettings['blog_rss_activated'])) {
         $arrCategories = $this->createCategoryArray();
         //Iterate over all languages
         foreach ($this->_arrLanguages as $intLanguageId => $arrLanguageValues) {
             $arrEntries = $this->createEntryArray($intLanguageId);
             //If there exist entries in this language go on, otherwise skip
             if (count($arrEntries) > 0) {
                 //Iterate over all categories
                 foreach ($arrCategories as $intCategoryId => $arrCategoryTranslation) {
                     //If the category is activated in this language, find assigned messages
                     if ($arrCategoryTranslation[$intLanguageId]['is_active']) {
                         $intNumberOfMessages = 0;
                         //Counts found messages for this category
                         $objRSSWriter = new \RSSWriter();
                         $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
                         $objRSSWriter->channelTitle = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_BLOG_LIB_RSS_MESSAGES_TITLE'];
                         $objRSSWriter->channelLink = \Cx\Core\Routing\Url::fromModuleAndCmd('Blog', '', $intLanguageId)->toString();
                         $objRSSWriter->channelDescription = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_BLOG_LIB_RSS_MESSAGES_TITLE'] . ' (' . $arrCategoryTranslation[$intLanguageId]['name'] . ')';
                         $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
                         //Function doesn't exist
                         //$objRSSWriter->channelLanguage = \FWLanguage::getLanguageParameter($intLanguageId, 'lang');
                         $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
                         //Find assigned messages
                         $entryUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Blog', 'details', $intLanguageId);
                         foreach ($arrEntries as $intEntryId => $arrEntryValues) {
                             if ($this->categoryMatches($intCategoryId, $arrEntryValues['categories'][$intLanguageId])) {
                                 //Message is in category, add to feed
                                 $entryUrl->setParam('id', $intEntryId);
                                 $objRSSWriter->addItem(html_entity_decode($arrEntryValues['subject'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xhtml($entryUrl->toString()), htmlspecialchars($arrEntryValues['translation'][$intLanguageId]['content'], ENT_QUOTES, CONTREXX_CHARSET), htmlspecialchars($arrEntryValues['user_name'], ENT_QUOTES, CONTREXX_CHARSET), '', '', '', '', $arrEntryValues['time_created_ts'], '');
                                 $intNumberOfMessages++;
                                 //Check for message-limit
                                 if ($intNumberOfMessages >= intval($this->_arrSettings['blog_rss_messages'])) {
                                     break;
                                 }
                             }
                         }
                         $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/blog_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml';
                         $objRSSWriter->write();
                         \Cx\Lib\FileSystem\FileSystem::makeWritable(\Env::get('cx')->getWebsiteFeedPath() . '/blog_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml');
                     }
                 }
             }
         }
     }
 }
示例#3
0
 /**
  * Writes RSS feed containing the latest N messages of each category the feed-directory. This is done for every language seperately.
  *
  * @global     array
  * @global     array
  */
 function writeCategoryRSS()
 {
     global $_CONFIG, $_ARRAYLANG;
     if (intval($this->_arrSettings['data_rss_activated'])) {
         $strItemLink = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/index.php?section=Data&amp;cmd=details&amp;id=';
         $arrCategories = $this->createCategoryArray();
         //Iterate over all languages
         foreach ($this->_arrLanguages as $intLanguageId => $arrLanguageValues) {
             $arrEntries = $this->createEntryArray($intLanguageId);
             //If there exist entries in this language go on, otherwise skip
             if (count($arrEntries) > 0) {
                 //Iterate over all categories
                 foreach ($arrCategories as $intCategoryId => $arrCategoryTranslation) {
                     //If the category is activated in this language, find assigned messages
                     if ($arrCategoryTranslation[$intLanguageId]['is_active']) {
                         $intNumberOfMessages = 0;
                         //Counts found messages for this category
                         $objRSSWriter = new \RSSWriter();
                         $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
                         $objRSSWriter->channelTitle = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_DATA_LIB_RSS_MESSAGES_TITLE'];
                         $objRSSWriter->channelLink = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/index.php?section=Data';
                         $objRSSWriter->channelDescription = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_DATA_LIB_RSS_MESSAGES_TITLE'] . ' (' . $arrCategoryTranslation[$intLanguageId]['name'] . ')';
                         $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
                         $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
                         //Find assigned messages
                         foreach ($arrEntries as $intEntryId => $arrEntryValues) {
                             if ($this->categoryMatches($intCategoryId, $arrEntryValues['categories'][$intLanguageId])) {
                                 //Message is in category, add to feed
                                 $objRSSWriter->addItem(htmlspecialchars($arrEntryValues['subject'], ENT_QUOTES, CONTREXX_CHARSET), $strItemLink . $intEntryId, htmlspecialchars($arrEntryValues['translation'][$intLanguageId]['content'], ENT_QUOTES, CONTREXX_CHARSET), htmlspecialchars($arrEntryValues['user_name'], ENT_QUOTES, CONTREXX_CHARSET), '', '', '', '', $arrEntryValues['time_created_ts'], '');
                                 $intNumberOfMessages++;
                                 //Check for message-limit
                                 if ($intNumberOfMessages >= intval($this->_arrSettings['data_rss_messages'])) {
                                     break;
                                 }
                             }
                         }
                         $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/data_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml';
                         $objRSSWriter->write();
                         \Cx\Lib\FileSystem\FileSystem::makeWritable(\Env::get('cx')->getWebsiteFeedPath() . '/data_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml');
                     }
                 }
             }
         }
     }
 }
示例#4
0
 protected function createRSS($langId)
 {
     global $_CONFIG, $objDatabase;
     $_FRONTEND_LANGID = $langId;
     if (intval($this->arrSettings['news_feed_status']) == 1) {
         $arrNews = array();
         require_once ASCMS_FRAMEWORK_PATH . '/RSSWriter.class.php';
         $objRSSWriter = new RSSWriter();
         $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
         $objRSSWriter->channelTitle = $this->arrSettings['news_feed_title'];
         $objRSSWriter->channelLink = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . '?section=news';
         $objRSSWriter->channelDescription = $this->arrSettings['news_feed_description'];
         $objRSSWriter->channelLanguage = FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang');
         $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
         if (!empty($this->arrSettings['news_feed_image'])) {
             $objRSSWriter->channelImageUrl = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . intval($_SERVER['SERVER_PORT'])) . $this->arrSettings['news_feed_image'];
             $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle;
             $objRSSWriter->channelImageLink = $objRSSWriter->channelLink;
         }
         $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
         $itemLink = "http://" . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . '?section=news&amp;cmd=details&amp;newsid=';
         $query = "\n                SELECT      tblNews.id,\n                            tblNews.date,\n                            tblNews.title,\n                            tblNews.text,\n                            tblNews.redirect,\n                            tblNews.source,\n                            tblNews.catid AS categoryId,\n                            tblNews.teaser_frames AS teaser_frames,\n                            tblNews.teaser_text,\n                            tblCategory.name AS category\n                FROM        " . DBPREFIX . "module_news AS tblNews\n                INNER JOIN  " . DBPREFIX . "module_news_categories AS tblCategory\n                USING       (catid)\n                WHERE       tblNews.status=1\n                    AND     tblNews.lang = " . $_FRONTEND_LANGID . "\n                    AND     (tblNews.startdate <= CURDATE() OR tblNews.startdate = '0000-00-00 00:00:00')\n                    AND     (tblNews.enddate >= CURDATE() OR tblNews.enddate = '0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' ? " AND tblNews.frontend_access_id=0 " : '') . "ORDER BY tblNews.date DESC";
         if (($objResult = $objDatabase->SelectLimit($query, 20)) !== false && $objResult->RecordCount() > 0) {
             while (!$objResult->EOF) {
                 if (empty($objRSSWriter->channelLastBuildDate)) {
                     $objRSSWriter->channelLastBuildDate = date('r', $objResult->fields['date']);
                 }
                 $arrNews[$objResult->fields['id']] = array('date' => $objResult->fields['date'], 'title' => $objResult->fields['title'], 'text' => empty($objResult->fields['redirect']) ? (!empty($objResult->fields['teaser_text']) ? nl2br($objResult->fields['teaser_text']) . '<br /><br />' : '') . $objResult->fields['text'] : (!empty($objResult->fields['teaser_text']) ? nl2br($objResult->fields['teaser_text']) : ''), 'redirect' => $objResult->fields['redirect'], 'source' => $objResult->fields['source'], 'category' => $objResult->fields['category'], 'teaser_frames' => explode(';', $objResult->fields['teaser_frames']), 'categoryId' => $objResult->fields['categoryId']);
                 $objResult->MoveNext();
             }
         }
         // create rss feed
         $objRSSWriter->xmlDocumentPath = ASCMS_FEED_PATH . '/news_' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '.xml';
         foreach ($arrNews as $newsId => $arrNewsItem) {
             $objRSSWriter->addItem(contrexx_raw2xml($arrNewsItem['title']), empty($arrNewsItem['redirect']) ? $itemLink . $newsId . (isset($arrNewsItem['teaser_frames'][0]) ? '&amp;teaserId=' . $arrNewsItem['teaser_frames'][0] : '') : htmlspecialchars($arrNewsItem['redirect'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xml($arrNewsItem['text']), '', array('domain' => "http://" . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . '?section=news&amp;category=' . $arrNewsItem['categoryId'], 'title' => $arrNewsItem['category']), '', '', '', $arrNewsItem['date'], array('url' => htmlspecialchars($arrNewsItem['source'], ENT_QUOTES, CONTREXX_CHARSET), 'title' => contrexx_raw2xml($arrNewsItem['title'])));
         }
         $status = $objRSSWriter->write();
         // create headlines rss feed
         $objRSSWriter->removeItems();
         $objRSSWriter->xmlDocumentPath = ASCMS_FEED_PATH . '/news_headlines_' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '.xml';
         foreach ($arrNews as $newsId => $arrNewsItem) {
             $objRSSWriter->addItem(contrexx_raw2xml($arrNewsItem['title']), $itemLink . $newsId . (isset($arrNewsItem['teaser_frames'][0]) ? "&amp;teaserId=" . $arrNewsItem['teaser_frames'][0] : ""), '', '', array('domain' => 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . '?section=news&amp;category=' . $arrNewsItem['categoryId'], 'title' => $arrNewsItem['category']), '', '', '', $arrNewsItem['date']);
         }
         $statusHeadlines = $objRSSWriter->write();
         $objRSSWriter->feedType = 'js';
         $objRSSWriter->xmlDocumentPath = ASCMS_FEED_PATH . '/news_' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '.js';
         $objRSSWriter->write();
         /*
         if (count($objRSSWriter->arrErrorMsg) > 0) {
             $this->strErrMessage .= implode('<br />', $objRSSWriter->arrErrorMsg);
         }
         if (count($objRSSWriter->arrWarningMsg) > 0) {
             $this->strErrMessage .= implode('<br />', $objRSSWriter->arrWarningMsg);
         }
         */
     } else {
         @unlink(ASCMS_FEED_PATH . '/news_' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '.xml');
         @unlink(ASCMS_FEED_PATH . '/news_headlines_' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '.xml');
         @unlink(ASCMS_FEED_PATH . '/news_' . FWLanguage::getLanguageParameter($_FRONTEND_LANGID, 'lang') . '.js');
     }
 }
示例#5
0
 /**
  * Create the RSS-Feed
  */
 function createRSS()
 {
     global $_CONFIG, $objDatabase, $_FRONTEND_LANGID;
     // languages
     $arrLanguages = \FWLanguage::getLanguageArray();
     if (intval($this->arrSettings['news_feed_status']) == 1) {
         if (count($arrLanguages > 0)) {
             $categoryDetails = $this->getCategoryLocale(null, array_keys($arrLanguages));
             foreach ($arrLanguages as $LangId => $arrLanguage) {
                 if ($arrLanguage['frontend'] == 1) {
                     $objRSSWriter = new \RSSWriter();
                     $query = "\n                            SELECT      tblNews.id,\n                                        tblNews.date,\n                                        tblNews.redirect,\n                                        tblNews.source,\n                                        tblNews.teaser_frames AS teaser_frames,\n                                        tblLocale.lang_id,\n                                        tblLocale.title,\n                                        tblLocale.text,\n                                        tblLocale.teaser_text\n                            FROM        " . DBPREFIX . "module_news AS tblNews\n                            INNER JOIN  " . DBPREFIX . "module_news_locale AS tblLocale ON tblLocale.news_id = tblNews.id\n                            WHERE       tblNews.status=1\n                                AND     tblLocale.is_active = 1\n                                AND     tblLocale.lang_id = " . $LangId . "                                \n                                AND     (tblNews.startdate <= '" . date('Y-m-d') . "' OR tblNews.startdate = '0000-00-00 00:00:00')\n                                AND     (tblNews.enddate >= '" . date('Y-m-d') . "' OR tblNews.enddate = '0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' ? " AND tblNews.frontend_access_id=0 " : '') . "ORDER BY tblNews.date DESC";
                     $arrNews = array();
                     if (($objResult = $objDatabase->SelectLimit($query, 20)) !== false && $objResult->RecordCount() > 0) {
                         while (!$objResult->EOF) {
                             if (empty($objRSSWriter->channelLastBuildDate)) {
                                 $objRSSWriter->channelLastBuildDate = date('r', $objResult->fields['date']);
                             }
                             $teaserText = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['teaser_text']);
                             $text = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['text']);
                             $redirect = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['redirect']);
                             \LinkGenerator::parseTemplate($teaserText, true);
                             \LinkGenerator::parseTemplate($text, true);
                             \LinkGenerator::parseTemplate($redirect, true);
                             $arrNews[$objResult->fields['id']] = array('date' => $objResult->fields['date'], 'title' => $objResult->fields['title'], 'text' => empty($redirect) ? (!empty($teaserText) ? nl2br($teaserText) . '<br /><br />' : '') . $text : (!empty($teaserText) ? nl2br($teaserText) : ''), 'redirect' => $redirect, 'source' => $objResult->fields['source'], 'teaser_frames' => explode(';', $objResult->fields['teaser_frames']), 'categoryIds' => $this->getNewsRelCategories($objResult->fields['id']));
                             $objResult->MoveNext();
                         }
                     } else {
                         continue;
                     }
                     $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
                     $objRSSWriter->channelTitle = contrexx_raw2xml($this->arrSettings['news_feed_title'][$LangId]);
                     $objRSSWriter->channelDescription = contrexx_raw2xml($this->arrSettings['news_feed_description'][$LangId]);
                     $objRSSWriter->channelLink = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . '?section=News';
                     $objRSSWriter->channelLanguage = \FWLanguage::getLanguageParameter($LangId, 'lang');
                     $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
                     if (!empty($this->arrSettings['news_feed_image'])) {
                         $objRSSWriter->channelImageUrl = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . $this->arrSettings['news_feed_image'];
                         $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle;
                         $objRSSWriter->channelImageLink = $objRSSWriter->channelLink;
                     }
                     $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
                     $itemLink = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . '?section=News&amp;cmd=';
                     // create rss feed
                     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml';
                     foreach ($arrNews as $newsId => $arrNewsItem) {
                         list($cmdDetail, $categories) = $this->getRssNewsLinks($LangId, $arrNewsItem['categoryIds'], $categoryDetails[$LangId]);
                         $objRSSWriter->addItem(contrexx_raw2xml($arrNewsItem['title']), empty($arrNewsItem['redirect']) ? $itemLink . $cmdDetail . '&amp;newsid=' . $newsId . (isset($arrNewsItem['teaser_frames'][0]) ? '&amp;teaserId=' . $arrNewsItem['teaser_frames'][0] : '') : htmlspecialchars($arrNewsItem['redirect'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xml($arrNewsItem['text']), '', $categories, '', '', '', $arrNewsItem['date'], array('url' => htmlspecialchars($arrNewsItem['source'], ENT_QUOTES, CONTREXX_CHARSET), 'title' => contrexx_raw2xml($arrNewsItem['title'])));
                     }
                     $objRSSWriter->write();
                     // create headlines rss feed
                     $objRSSWriter->removeItems();
                     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_headlines_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml';
                     foreach ($arrNews as $newsId => $arrNewsItem) {
                         list($cmdDetail, $categories) = $this->getRssNewsLinks($LangId, $arrNewsItem['categoryIds'], $categoryDetails[$LangId]);
                         $objRSSWriter->addItem(contrexx_raw2xml($arrNewsItem['title']), $itemLink . $cmdDetail . '&amp;newsid=' . $newsId . (isset($arrNewsItem['teaser_frames'][0]) ? '&amp;teaserId=' . $arrNewsItem['teaser_frames'][0] : ''), '', '', $categories, '', '', '', $arrNewsItem['date']);
                     }
                     $objRSSWriter->write();
                     $objRSSWriter->feedType = 'js';
                     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.js';
                     $objRSSWriter->write();
                     if (count($objRSSWriter->arrErrorMsg) > 0) {
                         $this->strErrMessage .= implode('<br />', $objRSSWriter->arrErrorMsg);
                     }
                     if (count($objRSSWriter->arrWarningMsg) > 0) {
                         $this->strErrMessage .= implode('<br />', $objRSSWriter->arrWarningMsg);
                     }
                 }
             }
         }
     } else {
         if (count($arrLanguages > 0)) {
             foreach ($arrLanguages as $LangId => $arrLanguage) {
                 if ($arrLanguage['frontend'] == 1) {
                     @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml');
                     @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_headlines_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml');
                     @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.js');
                 }
             }
         }
     }
 }
 /**
  * Create's new rss feed for the calendar module
  *
  * @global array $_CONFIG
  * @global object $objDatabase
  */
 function creatFeed()
 {
     global $_CONFIG, $objDatabase;
     $this->getFrontendLanguages();
     $this->getSettings();
     $this->objEventManager->getEventlist();
     foreach ($this->arrFrontendLanguages as $langKey => $arrFrontendLanguage) {
         $objRSSWriter = new \RSSWriter();
         $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
         $objRSSWriter->channelTitle = contrexx_raw2xml($this->arrSettings['rssFeedTitle']);
         $objRSSWriter->channelLink = contrexx_raw2xml($this->domainUrl . 'index.php?section=' . $this->moduleName);
         $objRSSWriter->channelDescription = contrexx_raw2xml($this->arrSettings['rssFeedDescription']);
         $objRSSWriter->channelLanguage = contrexx_raw2xml($arrFrontendLanguage['lang']);
         $objRSSWriter->channelCopyright = contrexx_raw2xml('Copyright ' . date('Y') . ', ' . $this->domainUrl);
         if (!empty($this->arrSettings['rssFeedImage'])) {
             $objRSSWriter->channelImageUrl = $this->arrSettings['rssFeedImage'];
             $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle;
             $objRSSWriter->channelImageLink = $objRSSWriter->channelLink;
         }
         $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
         $objRSSWriter->channelLastBuildDate = date('r', time());
         foreach ($this->objEventManager->eventList as $eventKey => $objEvent) {
             $objFWUser = \FWUser::getFWUserObject();
             $showIn = explode(',', $objEvent->showIn);
             if (in_array($arrFrontendLanguage['id'], $showIn)) {
                 $itemTitle = contrexx_raw2xml(html_entity_decode($objEvent->arrData['title'][$arrFrontendLanguage['id']], ENT_QUOTES, CONTREXX_CHARSET));
                 $itemLink = $objEvent->type == 0 ? $this->domainUrl . $this->objEventManager->_getDetailLink($objEvent) : $objEvent->arrData['redirect'][$arrFrontendLanguage['id']];
                 $itemLink = contrexx_raw2xml(html_entity_decode($itemLink));
                 $itemDescription = contrexx_raw2xml($objEvent->arrData['description'][$arrFrontendLanguage['id']]);
                 if ($objUser = $objFWUser->objUser->getUser(intval($objEvent->author))) {
                     $itemAuthor = $objUser->getEmail();
                 } else {
                     $itemAuthor = "unknown";
                 }
                 $itemAuthor = contrexx_raw2xml($itemAuthor);
                 $itemCategory = array();
                 $itemComments = null;
                 $itemEnclosure = array();
                 $itemGuid = array();
                 $itemPubDate = $objEvent->startDate->getTimestamp();
                 $itemSource = array();
                 $objRSSWriter->addItem($itemTitle, $itemLink, $itemDescription, $itemAuthor, $itemCategory, $itemComments, $itemEnclosure, $itemGuid, $itemPubDate, $itemSource);
             }
         }
         $objRSSWriter->feedType = 'xml';
         $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/calendar_all_' . $arrFrontendLanguage['lang'] . '.' . $objRSSWriter->feedType;
         $objRSSWriter->write();
     }
 }
示例#7
0
 function _createRSS()
 {
     global $_CONFIG, $objDatabase;
     $this->_arrSettings =& $this->_getSettings();
     $arrMedia = array();
     $objMedium = $objDatabase->Execute("\n            SELECT tblMedium.id,\n                   tblMedium.title,\n                   tblMedium.author,\n                   tblMedium.description,\n                   tblMedium.source,\n                   tblMedium.size,\n                   tblMedium.date_added,\n                   tblCategory.id AS categoryId,\n                   tblCategory.title AS categoryTitle\n            FROM " . DBPREFIX . "module_podcast_medium AS tblMedium\n            LEFT JOIN " . DBPREFIX . "module_podcast_rel_medium_category AS tblRel ON tblRel.medium_id=tblMedium.id\n            LEFT JOIN " . DBPREFIX . "module_podcast_category AS tblCategory ON tblCategory.id=tblRel.category_id\n            WHERE tblMedium.status=1\n            ORDER BY tblMedium.date_added DESC");
     if ($objMedium !== false) {
         while (!$objMedium->EOF) {
             if (!isset($arrMedia[$objMedium->fields['id']])) {
                 $arrMedia[$objMedium->fields['id']] = array('title' => $objMedium->fields['title'], 'author' => $objMedium->fields['author'], 'description' => $objMedium->fields['description'], 'source' => str_replace(array('%domain%', '%offset%'), array($_CONFIG['domainUrl'], \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath()), $objMedium->fields['source']), 'size' => $objMedium->fields['size'], 'date_added' => $objMedium->fields['date_added'], 'categories' => array());
             }
             if (!empty($objMedium->fields['id'])) {
                 $arrMedia[$objMedium->fields['id']]['categories'][$objMedium->fields['categoryId']] = $objMedium->fields['categoryTitle'];
             }
             $objMedium->MoveNext();
         }
     }
     $objRSSWriter = new \RSSWriter();
     $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
     $objRSSWriter->channelTitle = $this->_arrSettings['feed_title'];
     $objRSSWriter->channelLink = \Cx\Core\Routing\Url::fromModuleAndCmd('Podcast')->toString();
     $objRSSWriter->channelDescription = $this->_arrSettings['feed_description'];
     $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl'];
     if (!empty($this->_arrSettings['feed_image'])) {
         $channelImageUrl = \Cx\Core\Routing\Url::fromDocumentRoot();
         $channelImageUrl->setMode('backend');
         $channelImageUrl->setPath(substr($this->_arrSettings['feed_image'], strlen(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath()) + 1));
         $objRSSWriter->channelImageUrl = $channelImageUrl;
         $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle;
         $objRSSWriter->channelImageLink = $objRSSWriter->channelLink;
     }
     $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
     // create podcast feed
     $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/podcast.xml';
     foreach ($arrMedia as $mediumId => $arrMedium) {
         $arrCategories = array();
         foreach ($arrMedium['categories'] as $categoryId => $categoryTitle) {
             array_push($arrCategories, array('domain' => htmlspecialchars(\Cx\Core\Routing\Url::fromModuleAndCmd('Podcast', '', '', array('cid' => $categoryId))->toString(), ENT_QUOTES, CONTREXX_CHARSET), 'title' => htmlspecialchars($categoryTitle, ENT_QUOTES, CONTREXX_CHARSET)));
         }
         $objRSSWriter->addItem(htmlspecialchars($arrMedium['title'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xhtml(\Cx\Core\Routing\Url::fromModuleAndCmd('Podcast', '', '', array('id' => $mediumId))->toString()), htmlspecialchars($arrMedium['description'], ENT_QUOTES, CONTREXX_CHARSET), htmlspecialchars($arrMedium['author'], ENT_QUOTES, CONTREXX_CHARSET), $arrCategories, '', array('url' => htmlspecialchars($arrMedium['source'], ENT_QUOTES, CONTREXX_CHARSET), 'length' => !empty($arrMedium['size']) ? $arrMedium['size'] : 'N/A', 'type' => 'application/x-video'), '', $arrMedium['date_added']);
     }
     $status = $objRSSWriter->write();
     if (count($objRSSWriter->arrErrorMsg) > 0) {
         $this->_strErrMessage .= implode('<br />', $objRSSWriter->arrErrorMsg);
     }
     if (count($objRSSWriter->arrWarningMsg) > 0) {
         $this->_strErrMessage .= implode('<br />', $objRSSWriter->arrWarningMsg);
     }
     return $status;
 }