Index: zeitgeist.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/zeitgeist/zeitgeist.module,v
retrieving revision 1.9.4.3
diff -u -r1.9.4.3 zeitgeist.module
--- zeitgeist.module	26 Aug 2007 20:44:52 -0000	1.9.4.3
+++ zeitgeist.module	27 Aug 2007 15:04:55 -0000
@@ -61,6 +61,7 @@
 define('ZGVARLATESTCOUNT', 'zeitgeist_latest_count'); // How many recent searches are displayed in their block ?
 define('ZGVARTOPCOUNT',    'zeitgeist_top_count');    // How many top queries are displayed in their block ?
 define('ZGVARTOPSPAN',     'zeitgeist_top_span');     // ZG span for the top queries block
+define('ZGVARPAGEHEIGHT',  'zeitgeist_page_height');  // Number of rows on the zeitgeist pager  
 define('ZGVARHISTORY',     'zeitgeist_history');      // How long does the module keep its historical data.
 define('ZGVARNOFOLLOW',    'zeitgeist_nofollow');     // Emit a rel=nofollow attribute in feature blocks
 define('ZGVARTYPE',        'zeitgeist_type');         // Display search type in "recent searches" blocks
@@ -75,6 +76,7 @@
 define('ZGDEFTOPSPAN',     ZGSPANMONTH);              // Default for ZGVARTOPSPAN
 define('ZGDEFHISTORY',     0);                        // Default means forever
 define('ZGDEFNOFOLLOW',    1);                        // Default is true
+define('ZGDEFPAGEHEIGHT',  20);                       // Number of rows on the zeitgeist pager  
 define('ZGDEFTYPE',        ZGDISPLAYTYPEADMIN);       // Default is admin only
 define('ZGDEFVALIDATION',  ZGVALIDATEDISPLAY);        // Default is validate upon display
 define('ZGDEFRECORDEMPTY', 1);                        // Defaut is true: record empty queries
@@ -131,6 +133,16 @@
       'callback'           => 'drupal_get_form',
       'callback arguments' => array('zeitgeist_admin_settings'),
       'type'               => MENU_NORMAL_ITEM,
+      'access'             => user_access('administer search'),
+      );
+    $items[] = array
+      (
+      'path'               => 'admin/logs/zeitgeist',
+      'title'              => t('Zeitgeist'),
+      'description'        => t('Feel the Zeitgeist'),
+      'callback'           => 'zeitgeist_page',
+      'type'               => MENU_NORMAL_ITEM,
+      'access'             => user_access('administer search'),
       );
     }
 
@@ -171,9 +183,17 @@
     '#title'              => t('Number of days of history'),
     '#description'        => t('Historical data are kept for that number of days. 0 means forever. Pruning is performed by cron on a daily basis'),
     '#default_value'      => variable_get(ZGVARHISTORY, ZGDEFHISTORY),
-    '#size'               => 4, // this is good until 2037, should be enough for all 4.7 needs.
+    '#size'               => 4, // this is good until 2037, should be enough for all 5.x needs.
     '#max_length'         => 4,
     );
+  $form[ZGVARPAGEHEIGHT]  = array
+    (
+    '#type'               => 'textfield',
+    '#title'              => t('Height of the zeitgeist pager'),
+    '#default_value'      => variable_get(ZGVARPAGEHEIGHT, ZGDEFPAGEHEIGHT),
+    '#size'               => 3,
+    '#max_length'         => 3,
+    );
   $form[ZGVARTYPE]        = array
     (
     '#type'               => 'radios',
@@ -732,4 +752,47 @@
       $ret = true;
     }
   return $ret;
+  }
+  
+/**
+ * Sample basic stats page. Note that you can obtain much more finely
+ * tuned results for human-sensible time spans using _zeitgeist_stats
+ * and you won't even need to query the DB yourself !
+ *
+ * @return string HTML
+ */
+function zeitgeist_page()
+  {
+  $height = variable_get(ZGVARPAGEHEIGHT, ZGDEFPAGEHEIGHT); // pager height
+
+  $sq = 'SELECT zg.search, count(zg.ts) cnt '
+    . 'FROM {zeitgeist} zg '
+    . 'WHERE '
+    . " (zg.category = 'node') "
+    . 'GROUP BY 1 '
+    . 'ORDER BY 2 DESC, 1 ASC ';
+
+  $sq_count = 'SELECT count(DISTINCT zg.search) cnt '
+    . 'FROM {zeitgeist} zg '
+    . 'WHERE '
+    . " (zg.category = 'node') ";
+
+  $q = pager_query($sq, $height, 0, $sq_count);
+  $ar = array();
+  $cnt = 0;
+  while ($o = db_fetch_object($q))
+    {
+    $ar[] = "$o->cnt - " . l($o->search, "search/node/$o->search");
+    $cnt += $o->cnt;
+    } 
+  $ret .= theme('item_list', $ar);
+  $ret .= '<p>' . t('For a total of %cnt hits for these %height searches.', 
+    array
+      (
+      '%cnt' => $cnt,
+      '%height' => $height,
+      )
+    ) . "</p>\n";
+  $ret .= theme('pager');
+  return $ret;
   }
\ No newline at end of file
