* 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',
// 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')))));
$context['block'][$bid] = (array) $block;
}
- // export
- $export = '$items[] = '. var_export($context, true) .';';
-
// build the form
$form = array();
$form['help'] = array(
$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) {