Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8012
Modified Files:
serendipity_functions.inc.php serendipity_config_local.tpl
serendipity_sidebar_items.php
Log Message:
Rewrote top_as_links usage:
The basic config setting will set, if serendipity emits foreign links as
clickable. Default is yes. Currently only is used to decide whether to
display links of commenting users.
The exit plugin will by default show links as clickable. If the option
'top_as_links' in basic config is set, but the plugin config has not been
touched, that config setting will override the plugins config. As soon as
one configures the exit plugin to (not) show links, it will use that setting
regardless of the basic config setting.
The referrer sidebar plugin works the same as the exit plugin, but its
default is to NOT show links.
I think that's quite reasonable and a good compromise between supplying good
visitor handling/usability and not showing foreign URLs. Usually only the
referrer stats are hard to control, and with means of comment moderation you
can already enforce display of comment urls. And with latest changes to
exit.php it cannot be used for exit-spamming anymore.
Index: serendipity_sidebar_items.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_sidebar_items.php,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- serendipity_sidebar_items.php 23 Jul 2004 10:29:19 -0000 1.76
+++ serendipity_sidebar_items.php 26 Jul 2004 13:52:02 -0000 1.77
@@ -117,7 +117,7 @@
{
$propbag->add('name', TOP_REFERRER);
$propbag->add('description', SHOWS_TOP_SITES);
- $propbag->add('configuration', array('limit'));
+ $propbag->add('configuration', array('limit', 'use_links'));
}
function introspect_config_item($name, &$propbag)
@@ -130,6 +130,12 @@
$propbag->add('default', 10);
break;
+ case 'use_links':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', INSTALL_TOP_AS_LINKS);
+ $propbag->add('description', INSTALL_TOP_AS_LINKS_DESC);
+ $propbag->add('default', false);
+
default:
return false;
}
@@ -141,7 +147,16 @@
global $serendipity;
$title = TOP_REFERRER;
- echo serendipity_displayTopReferrers($this->get_config('limit', 10));
+
+ $use_links = $this->get_config('use_links', 'none');
+ if ($use_links == 'none' && !serendipity_get_config_var('top_as_links', false, true)) {
+ // If the user made no selection and he has 'top_as_links' switched off, we will not emit a link!
+ $use_links = false;
+ } elseif (serendipity_db_bool($use_links) === false) {
+ $use_links = false;
+ }
+
+ echo serendipity_displayTopReferrers($this->get_config('limit', 10), $use_links);
}
}
@@ -150,7 +165,7 @@
{
$propbag->add('name', TOP_EXITS);
$propbag->add('description', SHOWS_TOP_EXIT);
- $propbag->add('configuration', array('limit'));
+ $propbag->add('configuration', array('limit', 'use_links'));
}
function introspect_config_item($name, &$propbag)
@@ -163,6 +178,12 @@
$propbag->add('default', 10);
break;
+ case 'use_links':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', INSTALL_TOP_AS_LINKS);
+ $propbag->add('description', INSTALL_TOP_AS_LINKS_DESC);
+ $propbag->add('default', true);
+
default:
return false;
}
@@ -174,7 +195,16 @@
global $serendipity;
$title = TOP_EXITS;
- echo serendipity_displayTopExits($this->get_config('limit', 10));
+
+ $use_links = $this->get_config('use_links', 'none');
+ if ($use_links == 'none' && !serendipity_get_config_var('top_as_links', true)) {
+ // If the user made no selection and he has 'top_as_links' switched off, we will not emit a link!
+ $use_links = false;
+ } elseif (serendipity_db_bool($use_links) === false) {
+ $use_links = false;
+ }
+
+ echo serendipity_displayTopExits($this->get_config('limit', 10), $use_links);
}
}
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.365
retrieving revision 1.366
diff -u -d -r1.365 -r1.366
--- serendipity_functions.inc.php 26 Jul 2004 12:49:07 -0000 1.365
+++ serendipity_functions.inc.php 26 Jul 2004 13:52:02 -0000 1.366
@@ -1594,7 +1594,7 @@
}
/* Link to the user's website, if the URL is valid */
- $showlink = serendipity_get_config_var('top_as_links', false, true);
+ $showlink = serendipity_get_config_var('top_as_links', true);
if (($showlink === true) && (!isset($comment['type']) || $comment['type'] != 'trackback') && !empty($comment['url']) && $comment['url'] != 'http://' && eregi('^https?://', $comment['url'])) {
echo ' (<a href="' . str_replace('"', '"', $comment['url']) . '" ' . serendipity_xhtml_target('_blank') . ' title="' . htmlspecialchars($comment['url']) . '">Link</a>)';
}
@@ -3222,15 +3222,15 @@
}
}
-function serendipity_displayTopReferrers($limit = 10) {
+function serendipity_displayTopReferrers($limit = 10, $use_links = true) {
serendipity_displayTopUrlList('referrers', $limit);
}
-function serendipity_displayTopExits($limit = 10) {
- serendipity_displayTopUrlList('exits', $limit);
+function serendipity_displayTopExits($limit = 10, $use_links = true) {
+ serendipity_displayTopUrlList('exits', $limit, $use_links);
}
-function serendipity_displayTopUrlList($list, $limit) {
+function serendipity_displayTopUrlList($list, $limit, $use_links = true) {
global $serendipity;
/* HACK */
@@ -3254,12 +3254,11 @@
LIMIT $limit";
}
- $link = serendipity_get_config_var('top_as_links', false, true);
$rows = serendipity_db_query($query);
echo "<span class='serendipityReferer'>";
if (is_array($rows)) {
foreach ($rows as $row) {
- if ($link) {
+ if ($use_links) {
printf(
'<a href="%1$s://%2$s" title="%2$s" >%2$s</a> (%3$s)<br />',
$row['scheme'],
Index: serendipity_config_local.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config_local.tpl,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- serendipity_config_local.tpl 5 Jul 2004 06:28:14 -0000 1.41
+++ serendipity_config_local.tpl 26 Jul 2004 13:52:02 -0000 1.42
@@ -37,7 +37,7 @@
$serendipity['XHTML11'] = '{INSTALL_XHTML11|XHTML11|bool|0|255}'; // INSTALL_XHTML11_DESC
$serendipity['enablePopup'] = '{INSTALL_POPUP|enablePopup|bool|1|255}'; // INSTALL_POPUP_DESC
$serendipity['embed'] = '{INSTALL_EMBED|embed|bool||255}'; // INSTALL_EMBED_DESC
-$serendipity['top_as_links'] = '{INSTALL_TOP_AS_LINKS|top_as_links|bool||0|255}'; // INSTALL_TOP_AS_LINKS_DESC
+$serendipity['top_as_links'] = '{INSTALL_SHOW_EXTERNAL_LINKS|top_as_links|bool||1|255}'; // INSTALL_SHOW_EXTERNAL_LINKS_DESC
$serendipity['blockReferer'] = '{INSTALL_BLOCKREF|blockReferer|string|;|255}'; // INSTALL_BLOCKREF_DESC
$serendipity['rewrite'] = '{INSTALL_REWRITE|rewrite|list|none=>Disable URL Rewriting,errordocs=>Use Apache errorhandling,rewrite=>Use Apache mod_rewrite|255}'; // INSTALL_REWRITE_DESC
|