diff --git a/serendipity_event_commentspice/UTF-8/lang_de.inc.php b/serendipity_event_commentspice/UTF-8/lang_de.inc.php
index 969f2399..f1f801c0 100644
--- a/serendipity_event_commentspice/UTF-8/lang_de.inc.php
+++ b/serendipity_event_commentspice/UTF-8/lang_de.inc.php
@@ -1,10 +1,23 @@
Twitter Namen eingibst wird Deine Timeline in Deinem Kommentar verlinkt.');
+@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_TWITTER_PLACEHOLDER', 'Dein Twittername');
@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_ARTICLE_CHOOSE', '- Bewirb einen Deiner letzten Artikel -');
@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_ARTICLE_RESCENT', '%s schrieb auch');
diff --git a/serendipity_event_commentspice/frontend_commentspice.js b/serendipity_event_commentspice/frontend_commentspice.js
index 24cd0d50..efbf6c9f 100644
--- a/serendipity_event_commentspice/frontend_commentspice.js
+++ b/serendipity_event_commentspice/frontend_commentspice.js
@@ -1,11 +1,13 @@
var inputComentUrl = document.getElementById("serendipity_commentform_url");
var inputComentText = document.getElementById("serendipity_commentform_comment");
+var lastUrlChecked = null;
function fetch_rss() {
var url = inputComentUrl.value;
if(!url.match(/^http/)) return;
+ if (url == lastUrlChecked) return;
var divSelectRss = document.getElementById("serendipity_commentspice_rss");
- if (divSelectRss.style.display!='none') return; // allready done
+ //if (divSelectRss.style.display!='none') return; // allready done
if (window.XMLHttpRequest) { // Mozilla, Safari, Opera, IE7
httpRequest = new XMLHttpRequest();
@@ -28,8 +30,10 @@ function fetch_rss_ready(httpRequest){
var jsonResponse = eval('(' + response + ')');
var divSelectRss = document.getElementById("serendipity_commentspice_rss");
var selectRss = document.getElementById("serendipity_commentform_rss");
- for (idx in jsonResponse) {
- var article = jsonResponse[idx];
+ var articles = jsonResponse.articles;
+ selectRss.options.length = 0;
+ for (idx in articles) {
+ var article = articles[idx];
var option = document.createElement('option');
option.text = article.title;
option.value = article.url;
@@ -41,6 +45,7 @@ function fetch_rss_ready(httpRequest){
}
}
divSelectRss.style.display='';
+ lastUrlChecked = jsonResponse.url;
}
}
diff --git a/serendipity_event_commentspice/img/commentspice.png b/serendipity_event_commentspice/img/commentspice.png
new file mode 100644
index 00000000..ff560d7c
Binary files /dev/null and b/serendipity_event_commentspice/img/commentspice.png differ
diff --git a/serendipity_event_commentspice/img/rss_icon.png b/serendipity_event_commentspice/img/rss_icon.png
new file mode 100644
index 00000000..e8419bf0
Binary files /dev/null and b/serendipity_event_commentspice/img/rss_icon.png differ
diff --git a/serendipity_event_commentspice/img/twitter.png b/serendipity_event_commentspice/img/twitter.png
deleted file mode 100644
index 6949dcf2..00000000
Binary files a/serendipity_event_commentspice/img/twitter.png and /dev/null differ
diff --git a/serendipity_event_commentspice/img/twitter_icon.png b/serendipity_event_commentspice/img/twitter_icon.png
new file mode 100644
index 00000000..f6bd1c02
Binary files /dev/null and b/serendipity_event_commentspice/img/twitter_icon.png differ
diff --git a/serendipity_event_commentspice/img/twitter_small.png b/serendipity_event_commentspice/img/twitter_small.png
deleted file mode 100644
index e58e1f04..00000000
Binary files a/serendipity_event_commentspice/img/twitter_small.png and /dev/null differ
diff --git a/serendipity_event_commentspice/lang_de.inc.php b/serendipity_event_commentspice/lang_de.inc.php
index 1394fd2b..65ce5568 100644
--- a/serendipity_event_commentspice/lang_de.inc.php
+++ b/serendipity_event_commentspice/lang_de.inc.php
@@ -1,10 +1,23 @@
Twitter Namen eingibst wird Deine Timeline in Deinem Kommentar verlinkt.');
+@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_TWITTER_PLACEHOLDER', 'Dein Twittername');
@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_ARTICLE_CHOOSE', '- Bewirb einen Deiner letzten Artikel -');
@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_ARTICLE_RESCENT', '%s schrieb auch');
diff --git a/serendipity_event_commentspice/lang_en.inc.php b/serendipity_event_commentspice/lang_en.inc.php
index 93308934..212ff803 100644
--- a/serendipity_event_commentspice/lang_en.inc.php
+++ b/serendipity_event_commentspice/lang_en.inc.php
@@ -1,7 +1,6 @@
twitter name, your timeline will get linked to your comment.');
+@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_TWITTER_PLACEHOLDER', 'your twittername');
@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_ARTICLE_CHOOSE', '- Promote one of your rescent articles -');
@define('PLUGIN_EVENT_COMMENTSPICE_PROMOTE_ARTICLE_RESCENT', '%s wrote about');
diff --git a/serendipity_event_commentspice/serendipity_event_commentspice.php b/serendipity_event_commentspice/serendipity_event_commentspice.php
index 70e52f2c..3cf0242e 100644
--- a/serendipity_event_commentspice/serendipity_event_commentspice.php
+++ b/serendipity_event_commentspice/serendipity_event_commentspice.php
@@ -15,7 +15,7 @@ include dirname(__FILE__) . '/lang_en.inc.php';
require_once dirname(__FILE__) . '/DbSpice.class.php';
require_once dirname(__FILE__) . '/json/json.php4.include.php';
-@define('PLUGIN_EVENT_COMMENTSPICE_DEBUG', TRUE);
+@define('PLUGIN_EVENT_COMMENTSPICE_DEBUG', FALSE);
class serendipity_event_commentspice extends serendipity_event
{
@@ -33,9 +33,8 @@ class serendipity_event_commentspice extends serendipity_event
'smarty' => '2.6.7',
'php' => '4.1.0'
));
- $propbag->add('version', '0.1');
+ $propbag->add('version', '1.0');
$propbag->add('event_hooks', array(
-// 'frontend_header' => true,
'frontend_footer' => true,
'frontend_comment' => true,
'frontend_display' => true,
@@ -43,9 +42,10 @@ class serendipity_event_commentspice extends serendipity_event
'frontend_saveComment_finish' => true,
'backend_deletecomment' => true,
'external_plugin' => true,
+ 'css' => true,
));
$propbag->add('groups', array('FRONTEND_VIEWS'));
- $propbag->add('configuration', array('twitterinput','twitterinput_nofollow', 'announcerss', 'announcerss_nofollow','plugin_path'));
+ $propbag->add('configuration', array('twitterinput','twitterinput_nofollow', 'announcerss', 'announcerssmax','announcerss_nofollow','plugin_path'));
}
function generate_content(&$title) {
@@ -88,7 +88,7 @@ class serendipity_event_commentspice extends serendipity_event
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_COMMENTSPICE_ANNOUNCE_RSS_MAXSELECT);
$propbag->add('description', PLUGIN_EVENT_COMMENTSPICE_ANNOUNCE_RSS_MAXSELECT_DESC);
- $propbag->add('default', false);
+ $propbag->add('default', 3);
return true;
case 'plugin_path':
@@ -110,13 +110,17 @@ class serendipity_event_commentspice extends serendipity_event
switch($event) {
case 'external_plugin':
switch($eventData) {
- case 'spicetwitter.png':
+ case 'spiceicotwitter.png':
header('Content-Type: image/png');
- echo file_get_contents(dirname(__FILE__). '/img/twitter.png');
+ echo file_get_contents(dirname(__FILE__). '/img/twitter_icon.png');
break;
- case 'spicetwittersmall.png':
+ case 'spiceicorss.png':
header('Content-Type: image/png');
- echo file_get_contents(dirname(__FILE__). '/img/twitter_small.png');
+ echo file_get_contents(dirname(__FILE__). '/img/rss_icon.png');
+ break;
+ case 'commentspice.png':
+ header('Content-Type: image/png');
+ echo file_get_contents(dirname(__FILE__). '/img/commentspice.png');
break;
case 'commentspicefrss':
if (!serendipity_db_bool($this->get_config('announcerss', false))) break;
@@ -130,7 +134,6 @@ class serendipity_event_commentspice extends serendipity_event
case 'frontend_saveComment_finish' :
$this->commentSaved($eventData, $addData);
break;
- //case 'frontend_header':
case 'frontend_footer':
$this->printHeader();
break;
@@ -143,6 +146,9 @@ class serendipity_event_commentspice extends serendipity_event
case 'backend_deletecomment' :
$this->commentDeleted($eventData, $addData);
break;
+ case 'css':
+ $this->writeCss($eventData, $addData);
+ break;
default:
return false;
break;
@@ -157,6 +163,10 @@ class serendipity_event_commentspice extends serendipity_event
}
function cleanup() {
DbSpice::install($this);
+ $announcerssmax = $this->get_config('announcerssmax',3);
+ if (!is_numeric($announcerssmax)) {
+ $this->set_config('announcerssmax',3);
+ }
}
function printHeader() {
global $serendipity;
@@ -278,7 +288,7 @@ class serendipity_event_commentspice extends serendipity_event
$articles[] = $article;
$itemCount = 0;
- $maxItems = 3;
+ $maxItems = $announcerssmax = $this->get_config('announcerssmax',3);
// Iterate the items
while ($item = $rss->getNextItem()) {
if ($itemCount>=$maxItems) break;
@@ -290,8 +300,9 @@ class serendipity_event_commentspice extends serendipity_event
$itemCount++;
}
if ($itemCount==0) return;
-
- echo json_encode($articles);
+ $result['articles'] = $articles;
+ $result['url'] = $comment_url;
+ echo json_encode($result);
}
function commentDeleted($eventData, $addData) {
@@ -317,7 +328,7 @@ class serendipity_event_commentspice extends serendipity_event
return true;
}
$twittername = $spice['twittername'];
- $eventData['comment'] = 'get_config('twitterinput_nofollow', true)?' rel="nofollow"':'') . '> ' . $twittername . '
' . $eventData['comment'];
+ $eventData['comment'] = 'get_config('twitterinput_nofollow', true)?' rel="nofollow"':'') . '> ' . $twittername . '
' . $eventData['comment'];
if ($spice['promo_name'] && $spice['promo_url']) {
$eventData['comment'] .= "
" . sprintf(PLUGIN_EVENT_COMMENTSPICE_PROMOTE_ARTICLE_RESCENT, $eventData['author']) . ": get_config('announcerss_nofollow', false)?' rel="nofollow"':'') . ">{$spice['promo_name']}
"; } @@ -326,31 +337,70 @@ class serendipity_event_commentspice extends serendipity_event function printCommentEditExtras(&$eventData, &$addData) { global $serendipity; - $tag_comment_spice = '