1
0

Cleanup syndication fixed ()

cleans 97d9f5ce31
This commit is contained in:
onli
2015-06-16 21:56:04 +02:00
parent fbc8e55d09
commit bb2c5a63d0
3 changed files with 48 additions and 34 deletions

@ -255,6 +255,11 @@ $tasks = array(array('version' => '0.5.1',
'arguments' => array($dead_dirs_rest),
'desc' => 'The following old dead directories will additionally be removed from your system.<br><pre>' . implode(', ', $dead_dirs_rest) . '</pre>'),
array('version' => '2.0.2',
'function' => 'serendipity_upgrader_rewriteFeedIcon',
'title' => 'Rewrite path of big feedicon',
'desc' => 'Rewrite path of the big feedicon to not include the template path, since that path is not automatically detected'),
);

@ -402,6 +402,17 @@ function serendipity_upgrader_rename_plugins() {
}
function serendipity_upgrader_rewriteFeedIcon() {
global $serendipity;
$path = serendipity_db_query("SELECT value FROM {$serendipity['dbPrefix']}config WHERE name LIKE '%serendipity_plugin_syndication%big_img'", true);
if (is_array($path)) {
$path = $path[0];
}
$path = preg_replace('#' . $serendipity['serendipityHTTPPath'] . 'templates/[^/]*/#', '', $path);
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}config SET value = '" . serendipity_db_escape_string($path) . "' WHERE name LIKE '%serendipity_plugin_syndication%big_img'");
}
function serendipity_upgrader_move_syndication_config() {
global $serendipity;
$optionsToPort = array( 'bannerURL' => 'feedBannerURL',

@ -12,14 +12,14 @@ class serendipity_plugin_syndication extends serendipity_plugin {
$propbag->add('version', '2.2.2');
$propbag->add('configuration', array(
'title',
'big_img',
'feed_format',
'subToMe',
'show_comment_feed',
'seperator',
'iconURL',
'feed_name',
'comment_name',
'seperator',
'subToMe',
'big_img',
'seperator2',
'fb_id',
'custom_url'
@ -124,15 +124,17 @@ class serendipity_plugin_syndication extends serendipity_plugin {
{
global $serendipity;
// temporary fix for serendipity_getTemplateFile() path reset between S9y v.2.0 and 2.0.2 - remove later
$subimg = str_replace($serendipity['serendipityHTTPPath'].'templates/2k11/', '', $this->get_config('big_img', 'empty'), $count); // check and fix correct path
if ($count > 0) $this->set_config('big_img', $subimg); // fix in config
$title = $this->get_config('title');
$small_icon = serendipity_getTemplateFile($this->get_config('iconURL', 'img/xml.gif'));
$iconURL = $this->get_config('iconURL', 'img/xml.gif');
if ($iconURL != 'none') {
$small_icon = serendipity_getTemplateFile($iconURL);
}
$custom_feed = trim($this->get_config('feed_name'));
$custom_comm = trim($this->get_config('comment_name'));
$custom_img = serendipity_getTemplateFile(trim($this->get_config('big_img', 'empty')));
$custom_img = trim($this->get_config('big_img', 'img/subtome.png'));
if ($custom_img != 'none' && $custom_img != "feedburner") {
$custom_img = serendipity_getTemplateFile($custom_img);
}
$subtome = serendipity_db_bool($this->get_config('subToMe', true));
$fbid = $this->get_config('fb_id');
$custom_url = serendipity_db_bool($this->get_config('custom_url', false));
@ -150,7 +152,7 @@ class serendipity_plugin_syndication extends serendipity_plugin {
$icon = $small_icon;
if (!empty($custom_img) && $custom_img != 'default' && $custom_img != 'none' && $custom_img != 'empty') {
if ($subtome) $icon = $custom_img;
$icon = $custom_img;
if ($fbid != "" && $custom_img == 'feedburner') {
$icon = "http://feeds.feedburner.com/~fc/$fbid?bg=99CCFF&amp;fg=444444&amp;anim=0";
}
@ -190,7 +192,7 @@ class serendipity_plugin_syndication extends serendipity_plugin {
}
echo "\n".'<ul id="serendipity_syndication_list" class="plainList">';
echo $this->generateFeedButton($mainFeed, ($icon == $small_icon ? ($useRss ? "RSS $FEED" : "Atom $FEED") : ""), $onclick, $icon);
echo $this->generateFeedButton($mainFeed, ($icon == $small_icon ? ($useRss ? "RSS $FEED" : "Atom $FEED") : ""), $onclick, $icon, $icon == $small_icon);
if ($useRss && $useAtom) {
echo $this->generateFeedButton(serendipity_rewriteURL(PATH_FEEDS .'/atom10.xml'), "Atom $FEED",
@ -206,25 +208,21 @@ class serendipity_plugin_syndication extends serendipity_plugin {
echo "</ul>\n";
}
function generateFeedButton($feed, $label, $onclick, $icon) {
function generateFeedButton($feed, $label, $onclick, $icon, $small = false) {
$link = 'href="'.$feed.'" '. $onclick;
$path = $icon ? $icon : serendipity_getTemplateFile($this->get_config('iconURL', 'img/xml.gif'));
$output = "<li>\n";
if (serendipity_db_bool($this->get_config('subToMe', true))) {
if ($path != 'none' && !empty($path)) {
$output .= '<a class="serendipity_subtome" ' . $link . '><img src="' . $path . '" alt="XML" style="border: 0px" /></a>'."\n";
$output = '<li>';
$class = "";
if ($onclick != "") { # this might be not a good solution, but right now works to add the subtome-class only when subtome is on
$class = "subtome";
}
} else {
if ($path != 'none' && !empty($path)) {
$output .= '<a class="serendipity_xml_icon" ' . $link . '><img src="' . $path . '" alt="XML" style="border: 0px" /></a>'."\n";
if ($small) {
$class .= " serendipity_xml_icon";
}
if ($icon) {
$output .= '<a class="'. $class .'" ' . $link . '><img src="' . $icon . '" alt="XML" style="border: 0px" /></a>'."\n";
}
if (!empty($label)) {
if ($path == 'none') {
$output .= '<a class="serendipity_subtome" ' . $link . '>' . $label . '</a>'."\n";
} else {
$output .= '<a class="serendipity_subtome serendipity_xml_plain" ' . $link . '>' . $label . '</a>'."\n";
}
if (! empty($label)) {
$output .= " <a $link>$label</a>\n";
}
return $output .= "</li>\n";
}