/[drupal]/contributions/modules/graphstat/modules/graphstat.node.inc
ViewVC logotype

Diff of /contributions/modules/graphstat/modules/graphstat.node.inc

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

revision 1.1, Sun Jan 25 21:08:34 2009 UTC revision 1.1.2.1, Sun Jan 25 21:08:34 2009 UTC
# Line 0  Line 1 
1    <?php
2    // $Id: graphstat_statistics.inc,v 1.2.2.1 2009/01/25 14:32:28 profix898 Exp $
3    
4    require_once(drupal_get_path('module', 'graphstat') .'/modules/graphstat.system.inc');
5    
6    /**
7     * Implementation of hook_graphstat().
8     */
9    function graphstat_node_graphstat() {
10      $graphs = array();
11    
12      // Node type distribution
13      $node_types = array();
14      $result = db_query("SELECT type, COUNT(nid) AS nodes FROM {node} WHERE nid <> 0 GROUP BY type ORDER BY nodes DESC", $_SERVER['HTTP_HOST']);
15      while ($object = db_fetch_object($result)) {
16        $node_types[] = db_result(db_query("SELECT name FROM {node_type} WHERE type = '%s'", $object->type));
17      }
18    
19      $graphs['nodes'] = array(
20        '#title' => t('Nodes'),
21        'graph_node_types' => array(
22          '#type' => 'pie',
23          '#title' => t('Node Type Distribution'),
24          '#legend' => $node_types,
25          '#description' => t('Number of nodes for each node type.')
26        ),
27        'graph_nodes_details' => array(
28          '#type' => 'bars',
29          '#title' => t('Number of Nodes (last 2 weeks)'),
30          '#xlabel' => t('Date (MM/DD/YYYY)'),
31          '#ylabel' => t('# Nodes'),
32          '#legend' => array(t('total'), t('published'), t('queued')),
33          '#description' => t('Number of total/published/queued nodes in the last two weeks.')
34        )
35      );
36    
37      return $graphs;
38    }
39    
40    /**
41     * Implementation of hook_graphstat_data().
42     */
43    function graphstat_node_graphstat_data() {
44      $data = array();
45    
46      // Node type distribution
47      $data['nodes']['graph_node_types'] = array(0 => array(''));
48      $result = db_query("SELECT type, COUNT(nid) AS nodes FROM {node} WHERE nid <> 0 GROUP BY type ORDER BY nodes DESC", $_SERVER['HTTP_HOST']);
49      while ($object = db_fetch_object($result)) {
50        $data['nodes']['graph_node_types'][0][] = $object->nodes;
51      }
52    
53      // Node details (total, published, queued) of the last two weeks
54      $start_date = time() - (60*60*24*14);
55      $nodes_details_total = graphstat_statistics_tablehistory('node', 'nid', '', 14, $start_date);
56      $nodes_details_published = graphstat_statistics_tablehistory('node', 'nid', ' AND status=1', 14, $start_date);
57      $nodes_details_queued = graphstat_statistics_tablehistory('node', 'nid', ' AND moderate=1', 14, $start_date);
58      $nodes_details_all = array();
59      foreach (array_keys($nodes_details_total) as $date) {
60        $data['nodes']['graph_nodes_details'][] = array(
61          $date,
62          $nodes_details_total[$date],
63          $nodes_details_published[$date],
64          $nodes_details_queued[$date]
65        );
66      }
67    
68      return $data;
69    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2