summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryoung hahn2009-12-22 19:29:35 (GMT)
committer young hahn2009-12-22 19:29:35 (GMT)
commit1406e5e86fabd89c7ee87467c732b0a8522c35b3 (patch)
treef2bced79e9b62a70436d0349dc6db8e6a9ad7aef
parent3497a983650b4e84b962f0e51fc262756695d5bf (diff)
Fix for menu callback collision and allow dashes in context names.6.x-3.0-alpha1
-rw-r--r--context_ui/context_ui.admin.inc8
-rw-r--r--context_ui/context_ui.module40
-rw-r--r--context_ui/theme/theme.inc14
3 files changed, 31 insertions, 31 deletions
diff --git a/context_ui/context_ui.admin.inc b/context_ui/context_ui.admin.inc
index 0779b71..4d6ad2e 100644
--- a/context_ui/context_ui.admin.inc
+++ b/context_ui/context_ui.admin.inc
@@ -108,7 +108,7 @@ function context_ui_form(&$form_state, $op, $context = NULL) {
'#required' => TRUE,
'#maxlength' => 255,
'#default_value' => isset($context->name) ? $context->name : '',
- '#description' => t('Example: <code>blog_section</code>') .'<br/>'. t('A system name for this context. May only contain lowercase letters, underscores, and numbers.'),
+ '#description' => t('Example: <code>blog_section</code>') .'<br/>'. t('A system name for this context. May only contain lowercase letters, dashes, underscores, and numbers.'),
'#element_validate' => ($op === 'edit') ? array() : array('context_ui_form_name_validate'),
);
if ($op === 'edit') {
@@ -344,8 +344,8 @@ function context_ui_export(&$form_state, $context) {
*/
function context_ui_form_name_validate($element, &$form_state) {
// Check for string identifier sanity
- if (!preg_match('!^[a-z0-9_]+$!', $element['#value'])) {
- form_set_error('name', t('The context name can only consist of lowercase letters, underscores, and numbers.'));
+ if (!preg_match('!^[a-z0-9_-]+$!', $element['#value'])) {
+ form_set_error('name', t('The context name can only consist of lowercase letters, dashes, underscores, and numbers.'));
}
// Check for name collision
else if ($exists = context_load($element['#value'])) {
@@ -410,7 +410,7 @@ function context_ui_form_submit($form, &$form_state) {
// Send user to delete confirmation page
case 'edit-delete':
if (isset($form_state['values']['context']->name)) {
- $form_state['redirect'] = "admin/build/context/{$form_state['values']['context']->name}/delete";
+ $form_state['redirect'] = "admin/build/context/list/{$form_state['values']['context']->name}/delete";
}
return;
// Process form values and save and/or update the context in the db
diff --git a/context_ui/context_ui.module b/context_ui/context_ui.module
index efcb0d1..296db80 100644
--- a/context_ui/context_ui.module
+++ b/context_ui/context_ui.module
@@ -102,60 +102,60 @@ function context_ui_menu() {
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
- $items['admin/build/context/%context'] = array(
+ $items['admin/build/context/list/%context'] = array(
'page callback' => 'drupal_get_form',
- 'page arguments' => array('context_ui_form', 'edit', 3),
+ 'page arguments' => array('context_ui_form', 'edit', 4),
'type' => MENU_CALLBACK,
);
- $items['admin/build/context/%context/edit'] = array(
+ $items['admin/build/context/list/%context/edit'] = array(
'title' => 'Edit',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('context_ui_form', 'edit', 3),
+ 'page arguments' => array('context_ui_form', 'edit', 4),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
);
- $items['admin/build/context/%context/clone'] = array(
+ $items['admin/build/context/list/%context/clone'] = array(
'title' => 'Clone',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('context_ui_form', 'clone', 3),
+ 'page arguments' => array('context_ui_form', 'clone', 4),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/context/%context/export'] = array(
+ $items['admin/build/context/list/%context/export'] = array(
'title' => 'Export',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('context_ui_export', 3),
+ 'page arguments' => array('context_ui_export', 4),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/context/%context/revert'] = array(
+ $items['admin/build/context/list/%context/revert'] = array(
'title' => 'Revert',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('context_ui_confirm', 'revert', 3),
+ 'page arguments' => array('context_ui_confirm', 'revert', 4),
'access callback' => 'context_ui_task_access',
- 'access arguments' => array(3, 'revert'),
+ 'access arguments' => array(4, 'revert'),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/context/%context/delete'] = array(
+ $items['admin/build/context/list/%context/delete'] = array(
'title' => 'Delete',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('context_ui_confirm', 'delete', 3),
+ 'page arguments' => array('context_ui_confirm', 'delete', 4),
'access callback' => 'context_ui_task_access',
- 'access arguments' => array(3, 'delete'),
+ 'access arguments' => array(4, 'delete'),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/context/%context/disable'] = array(
+ $items['admin/build/context/list/%context/disable'] = array(
'title' => 'Disable',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('context_ui_confirm', 'disable', 3),
+ 'page arguments' => array('context_ui_confirm', 'disable', 4),
'access callback' => 'context_ui_task_access',
- 'access arguments' => array(3, 'disable'),
+ 'access arguments' => array(4, 'disable'),
'type' => MENU_LOCAL_TASK,
);
- $items['admin/build/context/%context/enable'] = array(
+ $items['admin/build/context/list/%context/enable'] = array(
'title' => 'Enable',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('context_ui_confirm', 'enable', 3),
+ 'page arguments' => array('context_ui_confirm', 'enable', 4),
'access callback' => 'context_ui_task_access',
- 'access arguments' => array(3, 'enable'),
+ 'access arguments' => array(4, 'enable'),
'type' => MENU_LOCAL_TASK,
);
diff --git a/context_ui/theme/theme.inc b/context_ui/theme/theme.inc
index ebfcbc8..7d1b0e3 100644
--- a/context_ui/theme/theme.inc
+++ b/context_ui/theme/theme.inc
@@ -89,13 +89,13 @@ function theme_context_ui_admin($form) {
// Context actions
$links = array(
- 'edit' => l(t('Edit'), "admin/build/context/{$context->name}"),
- 'delete' => l(t('Delete'), "admin/build/context/{$context->name}/delete"),
- 'revert' => l(t('Revert'), "admin/build/context/{$context->name}/revert"),
- 'export' => l(t('Export'), "admin/build/context/{$context->name}/export"),
- 'clone' => l(t('Clone'), "admin/build/context/{$context->name}/clone"),
- 'disable' => l(t('Disable'), "admin/build/context/{$context->name}/disable"),
- 'enable' => l(t('Enable'), "admin/build/context/{$context->name}/enable"),
+ 'edit' => l(t('Edit'), "admin/build/context/list/{$context->name}"),
+ 'delete' => l(t('Delete'), "admin/build/context/list/{$context->name}/delete"),
+ 'revert' => l(t('Revert'), "admin/build/context/list/{$context->name}/revert"),
+ 'export' => l(t('Export'), "admin/build/context/list/{$context->name}/export"),
+ 'clone' => l(t('Clone'), "admin/build/context/list/{$context->name}/clone"),
+ 'disable' => l(t('Disable'), "admin/build/context/list/{$context->name}/disable"),
+ 'enable' => l(t('Enable'), "admin/build/context/list/{$context->name}/enable"),
);
foreach (array_keys($links) as $key) {
if (!context_ui_task_access($context, $key)) {