| 1 |
<?php |
<?php |
| 2 |
// $Id: nedstat.module,v 1.43.2.6 2008/07/20 19:11:57 sun Exp $ |
// $Id: nedstat.module,v 1.2 2009/05/01 08:28:45 attiks Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 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; |
| 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() { |
| 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 |
|
|
| 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', |
| 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 |
|
|
| 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. |
| 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 = ''; |