Skip to content

Commit

Permalink
Adds RSS feed publication/advertisement (for browsers that support it…
Browse files Browse the repository at this point in the history
…) with an on/off option on the general site configuration page.
  • Loading branch information
dleffler committed Apr 28, 2011
1 parent c1b7b64 commit 07cdc36
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions framework/core/subsystems/expTheme.php
Expand Up @@ -26,6 +26,7 @@ class expTheme {

public function head($config = array()){
echo headerInfo($config);
echo exponent_theme_advertiseRSS();
}

public function foot($params = array()) {
Expand Down
Expand Up @@ -52,6 +52,7 @@
{control type="text" name="sc[ORGANIZATION_NAME]" label="Organization Name" value=$smarty.const.ORGANIZATION_NAME}
{control type="text" name="sc[SITE_TITLE]" label="Site Title" value=$smarty.const.SITE_TITLE}
{control type="checkbox" postfalse=1 name="sc[SEF_URLS]" label="Search Engine Friendly URLSs" checked=$smarty.const.SEF_URLS value=1}
{control type="checkbox" postfalse=1 name="sc[ADVERTISE_RSS]" label="Advertise all RSS Feeds to Web Browsers" checked=$smarty.const.ADVERTISE_RSS value=1}
{control type="dropdown" name="sc[SITE_DEFAULT_SECTION]" label="Default Section (Home Page)" items=$section_dropdown default=$smarty.const.SITE_DEFAULT_SECTION}
{control type="textarea" name="sc[SITE_KEYWORDS]" label="Meta Keywords" value=$smarty.const.SITE_KEYWORDS}
{control type="textarea" name="sc[SITE_DESCRIPTION]" label="Meta Description" value=$smarty.const.SITE_DESCRIPTION}
Expand Down
48 changes: 48 additions & 0 deletions subsystems/theme.php
Expand Up @@ -210,6 +210,7 @@ function exponent_theme_includeCSS($cssfile) {
*/
function exponent_theme_headerInfo($config) {
echo headerInfo($config);
echo exponent_theme_advertiseRSS();
}

function headerInfo($config) {
Expand Down Expand Up @@ -285,6 +286,53 @@ function headerInfo($config) {
return $str;
}

/* exdoc
* Output <link /> elements for each RSS feed on the site
*
* @node Subsystems:Theme
*/
function exponent_theme_advertiseRSS() {
if (defined("ADVERTISE_RSS") && ADVERTISE_RSS == 1){
echo "\n\t<!-- RSS Feeds -->\n";
$rss = new expRss();
$feeds = $rss->getFeeds();
foreach ($feeds as $feed) {
if ($feed->enable_rss) {
$title = empty($feed->feed_title) ? 'RSS' : htmlspecialchars($feed->feed_title, ENT_QUOTES);
$params['module'] = $feed->module;
$params['src'] = $feed->src;
echo "\t".'<link rel="alternate" type="application/rss+xml" title="' . $title . '" href="' . exponent_core_makeRSSLink($params) . "\" />\n";
}
}

// now for the old school module rss feeds
global $db;

$modules = $db->selectObjects("sectionref", "refcount > 0"); // get all the modules being using
$feeds = array();
foreach ($modules as $module) {
if (isset($feeds[$module->source])) continue;
$location->mod = $module->module;
$location->src = $module->source;
$location->int = $module->internal;

if (!controllerExists($module->module)) {
//get the module's config data
$config = $db->selectObject($module->module."_config", "location_data='".serialize($location)."'");
if (!empty($config->enable_rss)) {
$title = empty($config->feed_title) ? 'RSS' : htmlspecialchars($config->feed_title, ENT_QUOTES);
$params['module'] = $module->module;
$params['src'] = $module->source;
if (!empty($module->internal)) $params['int'] = $module->internal;

echo "\t".'<link rel="alternate" type="application/rss+xml" title="' . $title . '" href="' . exponent_core_makeRSSLink($params) . "\" />\n";
$feeds[$module->source] = $title;
}
}
}
}
}

function exponent_theme_footerInfo($params = array()) {
footerInfo($params);
}
Expand Down

0 comments on commit 07cdc36

Please sign in to comment.