* Improved "Remote RSS" plugin's templating output to select
custom template files. Add demo "Nasa Image of the Day" plugin by Grigory F. (garvinhicking)
This commit is contained in:
parent
95d242aa88
commit
e4c5ce7e4a
@ -3,6 +3,10 @@
|
|||||||
Version 1.4 ()
|
Version 1.4 ()
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
* Improved "Remote RSS" plugin's templating output to select
|
||||||
|
custom template files. Add demo "Nasa Image of the Day" plugin
|
||||||
|
by Grigory F. (garvinhicking)
|
||||||
|
|
||||||
* Fix Generic RSS import to not always assume WPXRSS feed.
|
* Fix Generic RSS import to not always assume WPXRSS feed.
|
||||||
(garvinhicking)
|
(garvinhicking)
|
||||||
|
|
||||||
|
@ -33,4 +33,5 @@
|
|||||||
@define('PLUGIN_REMOTERSS_RSSESCAPE', 'Escape HTML output');
|
@define('PLUGIN_REMOTERSS_RSSESCAPE', 'Escape HTML output');
|
||||||
@define('PLUGIN_REMOTERSS_RSSESCAPE_DESC', 'If enabled, HTML in RSS-feeds will be escaped and no XSS is possible. If this option is disabled, HTML in the feeds can be interpretated. This is a possible security issue, if the embedded feed is not yours!');
|
@define('PLUGIN_REMOTERSS_RSSESCAPE_DESC', 'If enabled, HTML in RSS-feeds will be escaped and no XSS is possible. If this option is disabled, HTML in the feeds can be interpretated. This is a possible security issue, if the embedded feed is not yours!');
|
||||||
|
|
||||||
?>
|
@define('PLUGIN_REMOTERSS_TEMPLATE', 'Output Template to use for this feed');
|
||||||
|
@define('PLUGIN_REMOTERSS_TEMPLATE_DESC', 'Here you can choose a template file inside the plugin\'s directory that is used to render the output of the feed in the sidebar. You can add custom template files to the plugin directory. If a template file with the same name is placed inside your own template directory, it will be used instead of the file supplied with the plugin. Selecting any template here other than the defualt one automatically enables Smarty templating.');
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
{foreach from=$remoterss_items.items item="item"}
|
||||||
|
<div class="rss_item">
|
||||||
|
<div class="nasa_caption"><strong>{$item.title}</strong></div>
|
||||||
|
<div class="nasa_image"><a href="{$item.link}"><img width="195" src="{$remoterss_items.nasa_image.url}" /></a></div>
|
||||||
|
<div class="nasa_desc"><em>{$item.description}</em></div>
|
||||||
|
</div>
|
||||||
|
{/foreach}
|
@ -257,13 +257,13 @@ class serendipity_plugin_remoterss extends serendipity_plugin {
|
|||||||
$propbag->add('description', PLUGIN_REMOTERSS_BLAHBLAH);
|
$propbag->add('description', PLUGIN_REMOTERSS_BLAHBLAH);
|
||||||
$propbag->add('stackable', true);
|
$propbag->add('stackable', true);
|
||||||
$propbag->add('author', 'Udo Gerhards, Richard Thomas Harrison');
|
$propbag->add('author', 'Udo Gerhards, Richard Thomas Harrison');
|
||||||
$propbag->add('version', '1.12');
|
$propbag->add('version', '1.13');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '0.8',
|
'serendipity' => '0.8',
|
||||||
'smarty' => '2.6.7',
|
'smarty' => '2.6.7',
|
||||||
'php' => '4.1.0'
|
'php' => '4.1.0'
|
||||||
));
|
));
|
||||||
$propbag->add('configuration', array('sidebartitle', 'feedtype', 'rssuri', 'show_rss_element', 'smarty', 'number', 'use_rss_link', 'escape_rss', 'displaydate', 'dateformat', 'charset', 'target', 'cachetime', 'bulletimg', 'markup'));
|
$propbag->add('configuration', array('sidebartitle', 'feedtype', 'template', 'rssuri', 'show_rss_element', 'smarty', 'number', 'use_rss_link', 'escape_rss', 'displaydate', 'dateformat', 'charset', 'target', 'cachetime', 'bulletimg', 'markup'));
|
||||||
$propbag->add('groups', array('FRONTEND_EXTERNAL_SERVICES'));
|
$propbag->add('groups', array('FRONTEND_EXTERNAL_SERVICES'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,6 +389,23 @@ class serendipity_plugin_remoterss extends serendipity_plugin {
|
|||||||
$propbag->add('default', 'true');
|
$propbag->add('default', 'true');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'template':
|
||||||
|
$select = array('plugin_remoterss.tpl' => 'Default (plugin_remoterss.tpl)', 'plugin_remoterss_nasaiotd.tpl' => 'NASA Image of the day');
|
||||||
|
|
||||||
|
$add_files = glob(dirname(__FILE__) . '/*.tpl');
|
||||||
|
foreach($add_files AS $add_file) {
|
||||||
|
$bn = basename($add_file);
|
||||||
|
if (!isset($select[$bn])) {
|
||||||
|
$select[$bn] = $bn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$propbag->add('type', 'select');
|
||||||
|
$propbag->add('name', PLUGIN_REMOTERSS_TEMPLATE);
|
||||||
|
$propbag->add('description', PLUGIN_REMOTERSS_TEMPLATE_DESC);
|
||||||
|
$propbag->add('select_values', $select);
|
||||||
|
$propbag->add('default', 'plugin_remoterss.tpl');
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -427,6 +444,7 @@ class serendipity_plugin_remoterss extends serendipity_plugin {
|
|||||||
|
|
||||||
$fp = fopen('rss.log', 'a');
|
$fp = fopen('rss.log', 'a');
|
||||||
fwrite($fp, '[' . date('Y-m-d H:i') . '] ' . $msg . "\n");
|
fwrite($fp, '[' . date('Y-m-d H:i') . '] ' . $msg . "\n");
|
||||||
|
echo $msg . "<br />\n";
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,9 +478,12 @@ class serendipity_plugin_remoterss extends serendipity_plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$smarty = serendipity_db_bool($this->get_config('smarty'));
|
$smarty = serendipity_db_bool($this->get_config('smarty'));
|
||||||
|
if ($this->get_config('template') != 'plugin_remoterss.tpl') {
|
||||||
|
$smarty = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (trim($rssuri)) {
|
if (trim($rssuri)) {
|
||||||
$feedcache = $serendipity['serendipityPath'] . 'templates_c/remoterss_cache_' . md5(preg_replace('@[^a-z0-9]*@i', '', $rssuri)) . '.dat';
|
$feedcache = $serendipity['serendipityPath'] . 'templates_c/remoterss_cache_' . md5(preg_replace('@[^a-z0-9]*@i', '', $rssuri) . $this->get_config('template')) . '.dat';
|
||||||
if (!file_exists($feedcache) || filesize($feedcache) == 0 || filemtime($feedcache) < (time() - $cachetime)) {
|
if (!file_exists($feedcache) || filesize($feedcache) == 0 || filemtime($feedcache) < (time() - $cachetime)) {
|
||||||
$this->debug('Cachefile does not existing.');
|
$this->debug('Cachefile does not existing.');
|
||||||
if (!$this->urlcheck($rssuri)) {
|
if (!$this->urlcheck($rssuri)) {
|
||||||
@ -561,7 +582,18 @@ class serendipity_plugin_remoterss extends serendipity_plugin {
|
|||||||
$smarty_items['target'] = $target;
|
$smarty_items['target'] = $target;
|
||||||
|
|
||||||
$serendipity['smarty']->assign_by_ref('remoterss_items', $smarty_items);
|
$serendipity['smarty']->assign_by_ref('remoterss_items', $smarty_items);
|
||||||
$content = $this->parseTemplate('plugin_remoterss.tpl');
|
$tpl = $this->get_config('template');
|
||||||
|
if (empty($tpl)) {
|
||||||
|
$tpl = 'plugin_remoterss.tpl';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Template specifics go here
|
||||||
|
switch($tpl) {
|
||||||
|
case 'plugin_remoterss_nasaiotd.tpl':
|
||||||
|
$smarty_items['nasa_image'] = $c->getData('image');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$content = $this->parseTemplate($tpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->debug('Caching Feed (' . strlen($content) . ' bytes)');
|
$this->debug('Caching Feed (' . strlen($content) . ' bytes)');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user