]> git.mjollnir.org Git - s9y.git/commitdiff
Allow to configure exit/referrer sidebar plugin's interval
authorgarvinhicking <garvinhicking>
Thu, 7 Jul 2005 14:56:56 +0000 (14:56 +0000)
committergarvinhicking <garvinhicking>
Thu, 7 Jul 2005 14:56:56 +0000 (14:56 +0000)
include/functions.inc.php
include/plugin_internal.inc.php

index 246d0882dca1c6124f001aa1c35df8ed3bd024c8..3c6337c673abd1e399d8418f5ec4569331f207e8 100644 (file)
@@ -96,10 +96,14 @@ function serendipity_fetchTemplates() {
     return $rv;
 }
 
-function serendipity_fetchTemplateInfo($theme) {
+function serendipity_fetchTemplateInfo($theme, $abspath = null) {
     global $serendipity;
 
-    $lines = @file($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/info.txt');
+    if ($abspath === null) {
+        $abspath = $serendipity['serendipityPath'] . $serendipity['templatePath'];
+    }
+
+    $lines = @file($abspath . $theme . '/info.txt');
     if ( !$lines ) {
         return array();
     }
@@ -448,15 +452,15 @@ function serendipity_track_url($list, $url, $entry_id = 0) {
     }
 }
 
-function serendipity_displayTopReferrers($limit = 10, $use_links = true) {
-    serendipity_displayTopUrlList('referrers', $limit, $use_links);
+function serendipity_displayTopReferrers($limit = 10, $use_links = true, $interval = 7) {
+    serendipity_displayTopUrlList('referrers', $limit, $use_links, $interval);
 }
 
-function serendipity_displayTopExits($limit = 10, $use_links = true) {
-    serendipity_displayTopUrlList('exits', $limit, $use_links);
+function serendipity_displayTopExits($limit = 10, $use_links = true, $interval = 7) {
+    serendipity_displayTopUrlList('exits', $limit, $use_links, $interval);
 }
 
-function serendipity_displayTopUrlList($list, $limit, $use_links = true) {
+function serendipity_displayTopUrlList($list, $limit, $use_links = true, $interval = 7) {
     global $serendipity;
 
     if ($limit){
@@ -471,7 +475,7 @@ function serendipity_displayTopUrlList($list, $limit, $use_links = true) {
          */
         $query = "SELECT scheme, host, SUM(count) AS total
                   FROM {$serendipity['dbPrefix']}$list
-                  WHERE day > date_sub(current_date, interval 7 day)
+                  WHERE day > date_sub(current_date, interval " . (int)$interval . " day)
                   GROUP BY host
                   ORDER BY total DESC, host
                   $limit";
index e34391732f3e8df0b0703873eda0d2595f9dcbd8..cf115553526c5d699ff700cc04133382d1ab8360 100644 (file)
@@ -404,7 +404,7 @@ class serendipity_topreferrers_plugin extends serendipity_plugin {
         $propbag->add('stackable',     false);
         $propbag->add('author',        'Serendipity Team');
         $propbag->add('version',       '1.0');
-        $propbag->add('configuration', array('limit', 'use_links'));
+        $propbag->add('configuration', array('limit', 'use_links', 'interval'));
     }
 
     function introspect_config_item($name, &$propbag)
@@ -417,6 +417,13 @@ class serendipity_topreferrers_plugin extends serendipity_plugin {
                 $propbag->add('default',     10);
                 break;
 
+           case 'interval':
+               $propbag->add('type',        'string');
+               $propbag->add('name',        ARCHIVE_FREQUENCY);
+               $propbag->add('description', ARCHIVE_FREQUENCY_DESC);
+                $propbag->add('default',     7);
+                break;
             case 'use_links':
                 $propbag->add('type',        'tristate');
                 $propbag->add('name',        INSTALL_TOP_AS_LINKS);
@@ -448,7 +455,7 @@ class serendipity_topreferrers_plugin extends serendipity_plugin {
             $use_links = serendipity_db_bool($use_links);
         }
 
-        echo serendipity_displayTopReferrers($this->get_config('limit', 10), $use_links);
+        echo serendipity_displayTopReferrers($this->get_config('limit', 10), $use_links, $this->get_config('interval', 7));
     }
 }
 
@@ -462,7 +469,7 @@ class serendipity_topexits_plugin extends serendipity_plugin {
         $propbag->add('stackable',     false);
         $propbag->add('author',        'Serendipity Team');
         $propbag->add('version',       '1.0');
-        $propbag->add('configuration', array('limit', 'use_links'));
+        $propbag->add('configuration', array('limit', 'use_links', 'interval'));
     }
 
     function introspect_config_item($name, &$propbag)
@@ -475,6 +482,13 @@ class serendipity_topexits_plugin extends serendipity_plugin {
                 $propbag->add('default',     10);
                 break;
 
+            case 'interval':
+                $propbag->add('type',        'string');
+                $propbag->add('name',        ARCHIVE_FREQUENCY);
+                $propbag->add('description', ARCHIVE_FREQUENCY_DESC);
+                $propbag->add('default',     7);
+                break;
+                                                                            
             case 'use_links':
                 $propbag->add('type',        'tristate');
                 $propbag->add('name',        INSTALL_TOP_AS_LINKS);
@@ -506,7 +520,7 @@ class serendipity_topexits_plugin extends serendipity_plugin {
             $use_links = serendipity_db_bool($use_links);
         }
 
-        echo serendipity_displayTopExits($this->get_config('limit', 10), $use_links);
+        echo serendipity_displayTopExits($this->get_config('limit', 10), $use_links, $this->get_config('interval', 7));
     }
 }