/[drupal]/contributions/modules/zeitgeist/zeitgeist.module
ViewVC logotype

Diff of /contributions/modules/zeitgeist/zeitgeist.module

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

revision 1.9.6.4, Sun Jul 5 15:24:12 2009 UTC revision 1.9.6.5, Sun Jul 5 17:59:24 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: zeitgeist.module,v 1.9.6.4 2009/07/05 15:24:12 fgm Exp $
3  /**  /**
4   * @file   * @file
5   * The Zeitgeist module provides history services for search.   * The Zeitgeist module provides history services for search.
# Line 42  Line 42 
42   */   */
43  define('ZGSEARCHFORM',     'search_form');           // The name of the form to trap when recording searches  define('ZGSEARCHFORM',     'search_form');           // The name of the form to trap when recording searches
44  define('ZGTABLE',          '{zeitgeist}');           // The name of the table holding our data  define('ZGTABLE',          '{zeitgeist}');           // The name of the table holding our data
45  define('ZGVERSION',        '$Id: zeitgeist.module,v 1.9.6.3 2008/08/07 19:55:06 fgm Exp $');  define('ZGVERSION',        '$Id: zeitgeist.module,v 1.9.6.4 2009/07/05 15:24:12 fgm Exp $');
46  define('ZGSCHEMAVERSION',  'zg_schema_version');     // read-only  define('ZGSCHEMAVERSION',  'zg_schema_version');     // read-only
47  define('ZGONEDAY',         86400);                   // 24 hours * 60 minutes * 60 seconds  define('ZGONEDAY',         86400);                   // 24 hours * 60 minutes * 60 seconds
48    
# Line 131  function zeitgeist_help($path, $arg) { Line 131  function zeitgeist_help($path, $arg) {
131    
132      case 'admin/help#zeitgeist':      case 'admin/help#zeitgeist':
133        $ret = t('<p>zeitgeist records recent searches when they are performed.</p>        $ret = t('<p>zeitgeist records recent searches when they are performed.</p>
134  <p>It also supplies a block listing the "n" latest searches, and a setting to define the value of "n".</p>');  <p>It also supplies a block listing the "n" latest searches, and a setting to define the value of "n".</p>
135    <p>If Views 2.x is installed, Zeitgeist can be used as a Views data source.');
136        break;        break;
137    
138      default:      default:
# Line 378  function _zeitgeist_admin_settings() { Line 379  function _zeitgeist_admin_settings() {
379  function zeitgeist_form_alter(&$form, $form_state, $form_id) {  function zeitgeist_form_alter(&$form, $form_state, $form_id) {
380    switch ($form_id) {    switch ($form_id) {
381      case 'search_form':      case 'search_form':
       array_unshift($form['#submit'], 'zeitgeist_search_form_submit');  
       break;  
   
382      case 'search_theme_form':      case 'search_theme_form':
383        array_unshift($form['#submit'], 'zeitgeist_search_theme_form_submit');        array_unshift($form['#submit'], 'zeitgeist_' . $form_id . '_submit');
384        break;        break;
385    
386      default:      default:
# Line 1034  function zeitgeist_search_form_submit($f Line 1032  function zeitgeist_search_form_submit($f
1032   */   */
1033  function zeitgeist_search_theme_form_submit($form, &$form_state) {  function zeitgeist_search_theme_form_submit($form, &$form_state) {
1034    $kind = 'node';    $kind = 'node';
   dsm($form_state);  
1035    $form_id = $form_state['values']['form_id'];    $form_id = $form_state['values']['form_id'];
1036    $keys = trim($form_state['values'][$form_id]);    $keys = trim($form_state['values'][$form_id]);
1037    
1038    // dsm(t("Search box (@kind): @keys", array('@kind' => $kind, '@keys' => $keys)));    // dsm(t("Search box (@kind): @keys", array('@kind' => $kind, '@keys' => $keys)));
1039    _zeitgeist_store_search($keys, $kind);    _zeitgeist_store_search($keys, $kind);
1040    }
1041    
1042    /**
1043     * Implement hook_views_api().
1044     *
1045     * @return array
1046     */
1047    function zeitgeist_views_api() {
1048      $ret = array(
1049        'api'  => 2.0,
1050        // 'path' => drupal_get_path('module', 'zeitgeist') . '/views'
1051      );
1052      return $ret;
1053    }
1054    
1055    /**
1056     * Implement hook_views_data().
1057     *
1058     * Describe our data to Views. Note that Views 2.x normally expects any
1059     * base table to have a PK, and ZG doesn't, but no ill consequence seems to
1060     * arise out of this. Please open an issue is a problem is identified.
1061     *
1062     * @return array()
1063     */
1064    function zeitgeist_views_data() {
1065      $data = array();
1066    
1067      $data['zeitgeist'] = array(
1068        'table'    => array(
1069          'group'    => 'ZG', // Do NOT translate!
1070          'base'     => array(
1071            'field'    => 'ts',
1072            'title'    => t('Zeitgeist search log'),
1073            'help'     => t('A list of searches which have been recently applied to this site.'),
1074          ),
1075        ),
1076        'search'   => array(
1077          'title'    => t('Search'),
1078          'help'     => t('The pattern searched for.'),
1079          'field'    => array(
1080            'click sortable' => FALSE,
1081          ),
1082        ),
1083        'category' => array(
1084          'title'    => t('Search kind'),
1085          'help'     => t('The kind of search requested, like "node", or "user".'),
1086          'field'    => array(
1087            'click sortable' => FALSE,
1088          ),
1089        ),
1090        'ts'       => array(
1091          'title'    => t('Timestamp'),
1092          'help'     => t('The instant at which the search was requested.'),
1093          'field'    => array(
1094            'click sortable' => TRUE,
1095            'handler'        => 'views_handler_field_date',
1096          ),
1097          'filter'   => array(
1098            'handler'        => 'views_handler_filter_date',
1099          ),
1100          'sort'     => array(
1101            'handler'        => 'views_handler_sort_date',
1102          ),
1103        ),
1104      );
1105      return $data;
1106  }  }

Legend:
Removed from v.1.9.6.4  
changed lines
  Added in v.1.9.6.5

  ViewVC Help
Powered by ViewVC 1.1.2