summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--context_ui/context_ui.module4
-rw-r--r--context_ui/context_ui_admin.inc16
2 files changed, 16 insertions, 4 deletions
diff --git a/context_ui/context_ui.module b/context_ui/context_ui.module
index a2603c5..12229a6 100644
--- a/context_ui/context_ui.module
+++ b/context_ui/context_ui.module
@@ -16,6 +16,10 @@ function context_ui_exit() {
* Implementation of hook_theme().
*/
function context_ui_theme() {
+ $items['context_ui_export_form'] = array(
+ 'arguments' => array('form' => array()),
+ 'file' => 'context_ui_admin.inc',
+ );
$items['context_ui_item_display'] = array(
'arguments' => array('form' => array()),
'file' => 'context_ui_admin.inc',
diff --git a/context_ui/context_ui_admin.inc b/context_ui/context_ui_admin.inc
index 91cef00..3edb01c 100644
--- a/context_ui/context_ui_admin.inc
+++ b/context_ui/context_ui_admin.inc
@@ -93,6 +93,7 @@ function context_ui_form(&$form_state, $op, $context = NULL) {
// The 'section' value is a field to make context definition creation
// less confusing for basic users.
+ $form['section']['#required'] = FALSE;
$form['section']['#title'] = t('Section');
$form['section']['#description'] = t('Your site\'s section. !advanced', array('!advanced' => l(t('Toggle advanced settings'), $_GET['q'], array('fragment' => 'advanced', 'attributes' => array('class' => 'advanced-toggle')))));
@@ -504,9 +505,6 @@ function context_ui_export(&$form_state, $context) {
$context['block'][$bid] = (array) $block;
}
- // export
- $export = '$items[] = '. var_export($context, true) .';';
-
// build the form
$form = array();
$form['help'] = array(
@@ -516,12 +514,22 @@ function context_ui_export(&$form_state, $context) {
$form['export'] = array(
'#type' => 'textarea',
'#rows' => 24,
- '#default_value' => $export,
+ '#value' => $context,
+ '#theme' => 'context_ui_export_form',
);
return $form;
}
/**
+ * Themes a context value into an export friendly var_export().
+ */
+function theme_context_ui_export_form($form) {
+ $form['#value'] =
+ $form['#default_value'] = '$items[] = '. var_export($form['#value'], true) .';';
+ return theme('textarea', $form);
+}
+
+/**
* Generates an array tree representation of available space/key/value context definitions.
*/
function context_ui_tree($op = '', $reset = FALSE) {