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

Diff of /contributions/modules/nedstat/nedstat.module

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

revision 1.1, Thu Apr 30 19:07:24 2009 UTC revision 1.2, Fri May 1 08:28:45 2009 UTC
# Line 21  function nedstat_menu() { Line 21  function nedstat_menu() {
21    
22    $items['admin/settings/nedstat'] = array(    $items['admin/settings/nedstat'] = array(
23      'title' => 'Nedstat settings',      'title' => 'Nedstat settings',
24        'description' => 'Settings for the Nedstat module.',
25        'page callback' => 'drupal_get_form',
26        'page arguments' => array('nedstat_admin_settings'),
27        'access arguments' => array('create nedstat counter'),
28      );
29    
30      $items['admin/settings/nedstat/settings'] = array(
31        'title' => 'General',
32      'description' => 'General settings.',      'description' => 'General settings.',
33      'page callback' => 'drupal_get_form',      'page callback' => 'drupal_get_form',
34      'page arguments' => array('nedstat_admin_settings'),      'page arguments' => array('nedstat_admin_settings'),
35      'access arguments' => array('create nedstat counter'),      'access arguments' => array('create nedstat counter'),
36        'type' => MENU_DEFAULT_LOCAL_TASK,
37    );    );
38    
39    $items['admin/settings/nedstat/menu'] = array(    $items['admin/settings/nedstat/menu'] = array(
40      'title' => 'Nedstat menu settings',      'title' => 'Menu (URL)',
41      'description' => 'Adjust counter names for menu items.',      'description' => 'Adjust counter names for menu items based on the URL.',
42      'page callback' => 'drupal_get_form',      'page callback' => 'drupal_get_form',
43      'page arguments' => array('nedstat_menu_counters'),      'page arguments' => array('nedstat_menu_counters'),
44      'access arguments' => array('create nedstat counter'),      'access arguments' => array('create nedstat counter'),
45        'type' => MENU_LOCAL_TASK,
46    );    );
47    
48    return $items;    return $items;
# Line 290  function nedstat_footer($main = 0) { Line 300  function nedstat_footer($main = 0) {
300  }  }
301    
302  /*  /*
  * Get path of active theme  
  */  
 function nedstat_theme_path($name = '') { // see http://drupal.org/node/194098  
   global $theme;  
   static $path = array();  
   
   if ($name && !isset($path[$name])) {  
     $path[$name] = drupal_get_path('theme', $name);  
   }  
   elseif (!isset($path[$theme])) {  
     $path[$theme] = drupal_get_path('theme', $theme);  
   }  
   
   return $name && isset($path[$name]) ? $path[$name] : $path[$theme];  
 }  
   
 /*  
303   * Edit menu items (code based on stringoverrides module)   * Edit menu items (code based on stringoverrides module)
304   */   */
305  function nedstat_menu_counters() {  function nedstat_menu_counters() {
# Line 347  function nedstat_menu_counters_submit($f Line 340  function nedstat_menu_counters_submit($f
340    
341    foreach ($form_state['values']['counters'] as $index => $counter) {    foreach ($form_state['values']['counters'] as $index => $counter) {
342      if (!empty($counter['path']) && !empty($counter['counter'])) {      if (!empty($counter['path']) && !empty($counter['counter'])) {
343        if (!empty($counter['id']) && $counter['id'] > 0) {        if (!empty($counter['counterid']) && $counter['counterid'] > 0) {
344          nedstat_set_counter_menu($counter['id'], $counter['path'], $counter['counter']);          nedstat_set_counter_menu($counter['counterid'], $counter['path'], $counter['counter']);
345        }        }
346        else {        else {
347          nedstat_set_counter_menu(0, $counter['path'], $counter['counter']);          nedstat_set_counter_menu(0, $counter['path'], $counter['counter']);
348        }        }
349      }      }
350      else if (!empty($counter['id']) && $counter['id'] > 0) {      else if (!empty($counter['counterid']) && $counter['counterid'] > 0) {
351        nedstat_del_counter_menu($counter['id']);        nedstat_del_counter_menu($counter['counterid']);
352      }      }
353    }    }
354    
# Line 370  function nedstat_textbox_combo($delta = Line 363  function nedstat_textbox_combo($delta =
363    $form = array(    $form = array(
364      '#tree' => TRUE,      '#tree' => TRUE,
365    );    );
366    $form['enabled'] = array(    $form['counterid'] = array(
367      '#type' => 'hidden',      '#type' => 'hidden',
368      '#default_value' => $id,      '#default_value' => $id,
369      '#parents' => array('counters', $delta, 'id'),      '#parents' => array('counters', $delta, 'counterid'),
370    );    );
371    $form['path'] = array(    $form['path'] = array(
372      '#type' => 'textfield',      '#type' => 'textfield',
# Line 391  function nedstat_textbox_combo($delta = Line 384  function nedstat_textbox_combo($delta =
384  }  }
385    
386  /**  /**
387   * Theme the enabled box and the two text box strings   * Theme the two text box strings
388   */   */
389  function theme_nedstat_menu_table($form) {  function theme_nedstat_menu_table($form) {
390    
# Line 402  function theme_nedstat_menu_table($form) Line 395  function theme_nedstat_menu_table($form)
395        'data' => array(        'data' => array(
396          array('data' => drupal_render($form[$key]['path']), 'class' => 'nedstat-path'),          array('data' => drupal_render($form[$key]['path']), 'class' => 'nedstat-path'),
397          array('data' => drupal_render($form[$key]['counter']), 'class' => 'nedstat-counter'),          array('data' => drupal_render($form[$key]['counter']), 'class' => 'nedstat-counter'),
398          array('data' => drupal_render($form[$key]['enabled']), 'class' => 'nedstat-enabled'),          array('data' => drupal_render($form[$key]['counterid']), 'class' => 'nedstat-counterid'),
399        ),        ),
400      );      );
401      // Add any attributes on the element to the row, such as the ahah class.      // Add any attributes on the element to the row, such as the ahah class.
# Line 411  function theme_nedstat_menu_table($form) Line 404  function theme_nedstat_menu_table($form)
404      }      }
405    }    }
406    $headers = array(    $headers = array(
407      t('Original'),      t('URL of page'),
408      t('Replacement'),      t('Nedstat counter'),
409    );    );
410    
411    $output  = '';    $output  = '';

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

  ViewVC Help
Powered by ViewVC 1.1.2