Update of /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_entrylinks
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14746/plugins/serendipity_plugin_entrylinks
Modified Files:
serendipity_plugin_entrylinks.php
Log Message:
Add top exits statistics to entry links archive.
New db function _db_concat.
Index: serendipity_plugin_entrylinks.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_plugin_entrylinks/serendipity_plugin_entrylinks.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- serendipity_plugin_entrylinks.php 6 Jun 2004 19:55:54 -0000 1.1
+++ serendipity_plugin_entrylinks.php 6 Jun 2004 20:29:59 -0000 1.2
@@ -26,7 +26,7 @@
$propbag->add('name', PLUGIN_ENTRYLINKS_NAME);
$propbag->add('description', PLUGIN_ENTRYLINKS_BLAHBLAH);
- $propbag->add('configuration', array('title', 'newwin', 'markup'));
+ $propbag->add('configuration', array('title', 'newwin', 'markup', 'show_exits'));
}
function introspect_config_item($name, &$propbag)
@@ -50,6 +50,12 @@
$propbag->add('description', DO_MARKUP_DESCRIPTION);
break;
+ case 'show_exits':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', TOP_EXITS);
+ $propbag->add('description', SHOWS_TOP_EXIT);
+ break;
+
default:
return false;
}
@@ -64,6 +70,8 @@
if (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id'])) {
return false;
+ } else {
+ $id = serendipity_db_escape_string($serendipity['GET']['id']);
}
$target = '';
@@ -73,11 +81,35 @@
$target = ' target="_blank" ';
}
- $references = serendipity_db_query("SELECT link, name FROM {$serendipity['dbPrefix']}references WHERE entry_id = " . serendipity_db_escape_string($serendipity['GET']['id']) . " GROUP BY link");
+
+ $counter = array();
+
+ if ($this->get_config('show_exits', 'true') == 'true') {
+ $exits = serendipity_db_query("SELECT SUM(count) as fullcount, scheme, host, port, path, query, " . serendipity_db_concat("scheme, '://', host, ':', port, path, '?', query") . " AS fulllink FROM {$serendipity['dbPrefix']}exits WHERE entry_id = " . $id . " GROUP BY fulllink");
+ if (is_array($exits)) {
+ foreach($exits AS $key => $row) {
+ $url = sprintf('%s://%s%s%s%s',
+ $row['scheme'],
+ $row['host'],
+ (!empty($row['port']) ? ':' . $row['port'] : ''),
+ $row['path'],
+ (!empty($row['query']) ? '?' . $row['query'] : '')
+ );
+
+ $counter[$url] = $row['fullcount'];
+ }
+ }
+ }
+
+ $references = serendipity_db_query("SELECT link, name FROM {$serendipity['dbPrefix']}references WHERE entry_id = " . $id . " GROUP BY link");
if (is_array($references)) {
$links = '<ul style="margin: 5px; padding: 2px">';
foreach($references AS $key => $row) {
- $links .= '<li><a href="' . $row['link'] . '" ' . $target . '>' . $row['name'] . "</a></li>\n";
+ $count = '';
+ if (isset($counter[$row['link']])) {
+ $count = ' (' . $counter[$row['link']] . ')';
+ }
+ $links .= '<li><a href="' . $row['link'] . '" ' . $target . '>' . $row['name'] . "</a>$count</li>\n";
}
$links .= '</ul>';
|