| 1 |
<?php
|
| 2 |
// $Id: reptag_callback.inc,v 1.0 2007/07/25 16:14:31 profix898 Exp $
|
| 3 |
|
| 4 |
require_once(drupal_get_path('module', 'reptag') .'/reptag_admin.inc');
|
| 5 |
require_once(drupal_get_path('module', 'reptag') .'/reptag_admin_table.inc');
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Function _reptag_callback().
|
| 9 |
*/
|
| 10 |
function _reptag_callback($op, $param, $nojs = FALSE) {
|
| 11 |
global $user;
|
| 12 |
|
| 13 |
$title = FALSE;
|
| 14 |
$uid = ($param == 'user') ? $user->uid : 0;
|
| 15 |
$multilang = (variable_get('reptag_locale_enable', 0) && (variable_get('language_count', 1) >= 2));
|
| 16 |
|
| 17 |
// Call js callback routines (add, remove, edit, ...)
|
| 18 |
switch ($op) {
|
| 19 |
case 'tagadd':
|
| 20 |
$dialog = TRUE;
|
| 21 |
$title = ($param == 'user') ? t('Add new user tag') : t('Add new site tag');
|
| 22 |
$result = drupal_get_form('_reptag_admin_addedit_form', $uid);
|
| 23 |
break;
|
| 24 |
case 'tagedit':
|
| 25 |
$dialog = TRUE;
|
| 26 |
$title = ($param == 'user') ? t('Edit user tag') : t('Edit site tag');
|
| 27 |
$result = drupal_get_form('_reptag_admin_addedit_form', $param);
|
| 28 |
break;
|
| 29 |
case 'refresh':
|
| 30 |
$_GET['q'] = 'admin/settings/reptag/'. $param;
|
| 31 |
$_GET['page'] = isset($_POST['page']) ? $_POST['page'] : '';
|
| 32 |
$lang = empty($_POST['language']) ? NULL : $_POST['language'];
|
| 33 |
$result = drupal_get_form('_reptag_admin_table_builder', $uid, $lang);
|
| 34 |
break;
|
| 35 |
}
|
| 36 |
|
| 37 |
if (!$nojs) {
|
| 38 |
if ($messages = drupal_get_messages('error')) {
|
| 39 |
drupal_json((object)array('success' => FALSE, 'errors' => $messages['error']));
|
| 40 |
}
|
| 41 |
else {
|
| 42 |
$html = $title ? theme('reptag_dialog', $result, t('Rep[lacement]Tags Dialog: ') . $title) : $result;
|
| 43 |
drupal_json((object)array('success' => TRUE, 'html' => $html));
|
| 44 |
}
|
| 45 |
exit();
|
| 46 |
}
|
| 47 |
|
| 48 |
//
|
| 49 |
drupal_set_title(t('Rep[lacement]Tags: ') . $title);
|
| 50 |
$breadcrumb = drupal_get_breadcrumb();
|
| 51 |
$breadcrumb[] = l(t('Rep[lacement]Tags'), $_REQUEST['destination']);
|
| 52 |
drupal_set_breadcrumb($breadcrumb);
|
| 53 |
$fieldset = array(
|
| 54 |
'#title' => '',
|
| 55 |
'#value' => isset($result) ? $result : $html,
|
| 56 |
'#collapsible' => FALSE,
|
| 57 |
'#collapsed' => FALSE,
|
| 58 |
'#attributes' => array()
|
| 59 |
);
|
| 60 |
|
| 61 |
return theme('fieldset', $fieldset);
|
| 62 |
}
|