/[drupal]/contributions/modules/drupalorg/blocks_and_nodes/searchquery.module
ViewVC logotype

Contents of /contributions/modules/drupalorg/blocks_and_nodes/searchquery.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Thu Jan 29 13:54:20 2009 UTC (9 months, 4 weeks ago) by goba
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.4: +7 -1 lines
File MIME type: text/x-php
Reviewed searchquery and redirects modules:
 - Added an actual URL generator, so we can reuse that for generating links to project issues on Drupal
 - Added some phpdoc comments
1 <?php
2 // $Id: searchquery.module,v 1.4 2009/01/26 19:14:02 goba Exp $
3
4 /**
5 * Implementation of hook_nodeapi().
6 */
7 function searchquery_nodeapi(&$node, $op = 'view', $teaser = FALSE, $page = FALSE) {
8 if ($op == 'view' && $page) {
9 $extra = '';
10 switch ($node->nid) {
11 case 48380:
12 $extra = searchquery_list();
13 break;
14 }
15 $node->content['body']['#value'] .= $extra;
16 }
17 }
18
19 /**
20 * Load cached search query list or generate cache.
21 */
22 function searchquery_list() {
23 if ($cache = cache_get('node_48380')) {
24 return $cache->data;
25 }
26
27 $output .= '<div class="column-left"><h2>Anonymous users</h2><ul>';
28 $result = db_query("SELECT message, COUNT(message) AS cnt FROM {watchdog}
29 WHERE type = 'search' AND uid = 0
30 GROUP BY message
31 ORDER BY cnt DESC
32 LIMIT 300");
33
34 while ($s = db_fetch_object($result)) {
35 preg_match('!<em>(.*?)</em>!', $s->message, $matches);
36 $output .= '<li>'. check_plain($matches[1]) .' ('. $s->cnt .')</li>';
37 }
38 $output .= '</ul></div>';
39
40 $output .= '<div class="column-right"><h2>Authenticated users</h2><ul>';
41 $result = db_query("SELECT message, COUNT(message) AS cnt FROM {watchdog}
42 WHERE type = 'search' AND uid != 0
43 GROUP BY message
44 ORDER BY cnt
45 DESC limit 300");
46
47 while ($s = db_fetch_object($result)) {
48 preg_match('!<em>(.*?)</em>!', $s->message, $matches);
49 $output .= '<li>'. check_plain($matches[1]) .' ('. $s->cnt .')</li>';
50 }
51 $output .= '</ul></div>';
52
53 cache_set('node_48380', $output, 'cache', 60*60);
54
55 return $output;
56 }

  ViewVC Help
Powered by ViewVC 1.1.2