<?php
// $Id$
-include_once(drupal_get_path("module", "context_ui") ."/context_ui_admin.inc");
-
/**
* Implementation of hook_block()
*/
else {
// Rebuild context_ui "cache".
if ($_GET['q'] == 'admin/build/modules') {
+ include_once(drupal_get_path("module", "context_ui") ."/context_ui_admin.inc");
context_ui_rebuild();
}
}
/**
- * Implementation ofhook_form_alter()
+ * Implementation of hook_form_alter()
*/
function context_ui_form_alter($form_id, &$form) {
if ($form['#node']) {
}
/*
+ * Page callback for context_ui admin landing page.
+ */
+function context_ui_admin() {
+ include_once(drupal_get_path("module", "context_ui") ."/context_ui_admin.inc");
+
+ // rebuild blocks
+ _block_rehash();
+
+ // rebuild default contexts
+ context_ui_rebuild();
+
+ // User defined contexts
+ $output = "<h3>". t('User context definitions') ."</h3>";
+ $contexts = context_ui_tree('ui');
+ if ($contexts) {
+ $output .= theme('context_ui_admin', $contexts);
+ }
+ else {
+ $output .= "<p>". t('Please !add_context to get started.', array('!add_context' => l(t('add a context'), 'admin/build/context/add'))) ."</p>";
+ }
+
+ // Module defined contexts
+ $output .= "<h3>". t('Module context definitions') ."</h3>";
+ $contexts = context_ui_tree('system');
+ if ($contexts) {
+ $output .= theme('context_ui_admin', $contexts);
+ }
+ else {
+ $output .= "<p>". t('There are currently no module defined contexts.') ."</p>";
+ }
+
+ return $output;
+}
+
+/*
+ * Generates the omnibus context definition editing form.
+ * Note: submission and validation handlers are in context_ui_admin.inc
+ *
+ * @param $op
+ * The type of form to build. Either "add", "view" or "edit"
+ * @param $cid
+ * The db context identifier - required when $op == "edit"
+ *
+ * @return
+ * A Drupal form array.
+ */
+function context_ui_form($op, $cid = NULL) {
+ include_once(drupal_get_path("module", "context_ui") ."/context_ui_admin.inc");
+
+ drupal_add_css(drupal_get_path("module", "context_ui") ."/context_ui.css");
+ drupal_add_js(drupal_get_path("module", "context_ui") ."/context_ui.js");
+
+ switch ($op) {
+ case 'view':
+ if (is_numeric($cid) && $context = context_ui_context('load', $cid)) {
+ drupal_set_title(t('View %title', array('%title' => $context->value)));
+ }
+ else {
+ drupal_goto('admin/build/context'); return;
+ }
+ break;
+ case 'edit':
+ if (is_numeric($cid) && $context = context_ui_context('load', $cid)) {
+ if (!$context->system) {
+ drupal_set_title(t('Edit %title', array('%title' => $context->value)));
+ }
+ else {
+ drupal_goto('admin/build/context'); return;
+ }
+ }
+ break;
+ }
+
+ // Core context definition
+ $form = array();
+ $form['value'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Value'),
+ '#required' => true,
+ '#maxlength' => 30,
+ '#description' => t('A system name for this context. May only contain lowercase letters, underscores, and numbers. Example: <b>science_blog</b>'),
+ );
+ $form['key'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Key'),
+ '#default_value' => 'section',
+ '#required' => true,
+ '#maxlength' => 30,
+ '#description' => t('The type of context information provided in this namespace. Example: <b>section</b>'),
+ );
+ $form['space'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Namespace'),
+ '#default_value' => 'context_ui',
+ '#required' => true,
+ '#maxlength' => 30,
+ '#description' => t('The namespace for this context definition. Example: <b>context_ui</b>'),
+ );
+
+ $form['items'] = array(
+ '#title' => t('Context Items'),
+ '#tree' => true,
+ '#type' => 'fieldset',
+ );
+
+ // Generate settings for context item associations
+ foreach (context_ui_types('full') as $type => $item) {
+ $form['items'][$type] = array(
+ '#title' => $item['title'],
+ '#description' => $item['description'],
+ '#type' => 'checkboxes',
+ '#size' => 8,
+ '#multiple' => true,
+ '#options' => $item['options'],
+ '#prefix' => '<div class="context-ui-item clear-block">',
+ '#suffix' => '</div>',
+ );
+ }
+
+ // Control block visibility
+ global $theme_key;
+ $block_options =
+ $block_defaults = array();
+ $blocks = _context_ui_get_blocks();
+ $regions = system_region_list($theme_key);
+ // $blocks in [0] have not been assigned a region
+ foreach ($blocks[0] as $block) {
+ if (!isset($context->block[$block->bid])) {
+ $block_options[$block->bid] = $block->label ." ($block->bid)";
+ }
+ }
+
+ $form['block'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Blocks'),
+ '#tree' => true,
+ '#description' => t('Control block visibility using context. Selected blocks will be shown when this context is set provided that custom block visibility settings and/or throttling do not hide them. Grayed out blocks are those provided by Drupal\'s standard block settings. These settings apply to the current theme and any enabled themes with regions in common.'),
+ );
+ $form['block']['selector'] = array(
+ '#type' => 'item',
+ '#tree' => true,
+ '#prefix' => '<div class="context-ui-block-selector">',
+ '#suffix' => '</div>',
+ 'blocks' => array(
+ '#type' => 'select',
+ '#multiple' => true,
+ '#size' => 12,
+ '#title' => t('Blocks'),
+ '#options' => $block_options,
+ ),
+ 'regions' => array(
+ '#type' => 'select',
+ '#title' => t('Regions'),
+ '#options' => $regions,
+ ),
+ 'add' => array(
+ '#type' => 'markup',
+ '#value' => "<input id='edit-block-selector-add' class='form-submit' type='button' value='+ ". t('Add') ."'/>",
+ ),
+ );
+ $form['block']['regions'] = array(
+ '#type' => 'item',
+ '#tree' => true,
+ '#prefix' => '<div class="context-ui-block-regions">',
+ '#suffix' => '</div>',
+ '#value' => theme('context_ui_block_ui', $regions, $context),
+ );
+ foreach (array_keys($regions) as $region) {
+ $defaults = array();
+ $midpoint = false;
+ foreach (_context_ui_get_blocks($region, $context) as $block) {
+ if ($block->type == 'context_ui') {
+ $defaults[] = $block->bid;
+ }
+ else if (!$midpoint) {
+ $midpoint = true;
+ $defaults[] = 'system';
+ }
+ }
+ if (!$defaults) {
+ $defaults = array('system');
+ }
+ $defaults = implode(',', $defaults);
+ $form['block']['regions'][$region] = array(
+ '#type' => 'hidden',
+ '#default_value' => $defaults,
+ );
+ }
+
+ if ($op == 'view') {
+ $form[] = array(
+ '#type' => 'item',
+ '#value' => l(t('Back'), 'admin/build/context'),
+ );
+ }
+
+ if ($op != 'view') {
+ $form[] = array(
+ '#type' => 'submit',
+ '#value' => t('Save'),
+ );
+ }
+
+ if ($op == 'edit') {
+ $form[] = array(
+ '#type' => 'submit',
+ '#value' => t('Delete'),
+ );
+ }
+
+ if ($op == 'view' || $op == 'edit') {
+ if ($context) {
+ $form['value']['#default_value'] = $context->value;
+ $form['key']['#default_value'] = $context->key;
+ $form['space']['#default_value'] = $context->space;
+ $form['cid'] = array(
+ '#type' => 'value',
+ '#value' => $cid,
+ );
+ $form['system'] = array(
+ '#type' => 'value',
+ '#value' => $context->system,
+ );
+ if ($op == 'view' || $context->system) {
+ $form['value']['#disabled'] =
+ $form['key']['#disabled'] =
+ $form['space']['#disabled'] =
+ $form['block']['selector']['blocks']['#disabled'] =
+ $form['block']['selector']['regions']['#disabled'] = true;
+ }
+ // Set default values for each item type (except blocks)
+ foreach (context_ui_types() as $type) {
+ if (is_array($context->{$type})) {
+ $defaults = array();
+ foreach ($context->{$type} as $id) {
+ $defaults[$id] = $id;
+ }
+ $form['items'][$type]['#default_value'] = $defaults;
+ }
+ $form['items'][$type]['#disabled'] = $op == 'view' ? true : false;
+ }
+ // Blocks must be selected by region
+ if (is_array($context->block)) {
+ foreach ($regions as $region => $label) {
+ if (is_array($form['block'][$region])) {
+ $defaults = array();
+ foreach ($form['block'][$region]['#options'] as $block => $label) {
+ if (array_search($block, $context->block) !== false) {
+ $defaults[$block] = $block;
+ }
+ }
+ $form['block'][$region]['#default_value'] = $defaults;
+ }
+ $form['block'][$region]['#disabled'] = $op == 'view' ? true : false;
+ }
+ }
+ }
+ else {
+ return drupal_goto('admin/build/context');
+ }
+ }
+
+ return $form;
+}
+
+/*
+ * Provide a form to confirm deletion of a context definition.
+ */
+function context_ui_delete_confirm($cid) {
+ include_once(drupal_get_path("module", "context_ui") ."/context_ui_admin.inc");
+
+ $context = context_ui_context('load', $cid);
+ if (!$context) {
+ return drupal_goto('admin/build/context');
+ }
+ $form['cid'] = array('#type' => 'value', '#value' => $cid);
+ $form = confirm_form($form,
+ t('Are you sure you want to delete %title?', array('%title' => $context->value)),
+ 'admin/build/context',
+ t('This action cannot be undone.'),
+ t('Delete'), t('Cancel')
+ );
+ return $form;
+}
+
+/*
+ * hook_submit()
+ */
+function context_ui_delete_confirm_submit($form_id, $form) {
+ context_ui_context('delete', $form['cid']);
+ context_ui_rebuild();
+ return 'admin/build/context';
+}
+
+/*
+ * Provides a form with an exported context definition for use in modules.
+ *
+ * @param $cid
+ * A context id.
+ *
+ * @return
+ * A FormAPI array.
+ */
+function context_ui_export($cid = NULL) {
+ include_once(drupal_get_path("module", "context_ui") ."/context_ui_admin.inc");
+
+ if (is_numeric($cid) && $context = context_ui_context('load', $cid)) {
+ drupal_set_title(t('Export %title', array('%title' => $context->value)));
+
+ // help text -- too bad the help module in 5 doesn't take wildcards
+ $help = t('You can use exported contexts in your modules by returning an array of defined contexts in <code>hook_context_define()</code>.');
+
+ // prune system specific information and cast for Drupal's AOP (array oriented programming)
+ unset($context->cid);
+ unset($context->status);
+ unset($context->system);
+ $context = (array) $context;
+
+ // clean up blocks
+ foreach ($context['block'] as $bid => $block) {
+ unset($block->bid);
+ $context['block'][$bid] = (array) $block;
+ }
+
+ // export
+ $export = '$items[] = '. var_export($context, true) .';';
+
+ // build the form
+ $form = array();
+ $form['help'] = array(
+ '#type' => 'item',
+ '#value' => $help,
+ );
+ $form['export'] = array(
+ '#type' => 'textarea',
+ '#rows' => 24,
+ '#default_value' => $export,
+ );
+ return $form;
+ }
+ else {
+ drupal_goto('admin/build/context'); return;
+ }
+}
+
+/**
* Sets a space-key-value context that has been associated with the provided item.
*
* @param $type
}
return $blocks[$region];
}
+
+/*
+ * Helper function to sort block objects by weight
+ */
+function _context_ui_block_compare($a, $b) {
+ // Enabled blocks
+ return ($a->weight - $b->weight);
+}
\ No newline at end of file
}
/*
- * Page callback for context_ui admin landing page.
- */
-function context_ui_admin() {
- // rebuild blocks
- _block_rehash();
-
- // rebuild default contexts
- context_ui_rebuild();
-
- $output = '';
-
- // User defined contexts
- $output .= "<h3>". t('User context definitions') ."</h3>";
- $contexts = context_ui_tree('ui');
- if ($contexts) {
- $output .= theme('context_ui_admin', $contexts);
- }
- else {
- $output .= "<p>". t('Please !add_context to get started.', array('!add_context' => l(t('add a context'), 'admin/build/context/add'))) ."</p>";
- }
-
- // Module defined contexts
- $output .= "<h3>". t('Module context definitions') ."</h3>";
- $contexts = context_ui_tree('system');
- if ($contexts) {
- $output .= theme('context_ui_admin', $contexts);
- }
- else {
- $output .= "<p>". t('There are currently no module defined contexts.') ."</p>";
- }
-
- return $output;
-}
-
-/*
* Generates the main context_ui admin page with a tiered context listing.
*/
function theme_context_ui_admin($context_tree) {
}
/*
- * Generates the omnibus context definition editing form.
- *
- * @param $op
- * The type of form to build. Either "add", "view" or "edit"
- * @param $cid
- * The db context identifier - required when $op == "edit"
- *
- * @return
- * A Drupal form array.
- */
-function context_ui_form($op, $cid = NULL) {
- drupal_add_css(drupal_get_path("module", "context_ui") ."/context_ui.css");
- drupal_add_js(drupal_get_path("module", "context_ui") ."/context_ui.js");
-
- switch ($op) {
- case 'view':
- if (is_numeric($cid) && $context = context_ui_context('load', $cid)) {
- drupal_set_title(t('View %title', array('%title' => $context->value)));
- }
- else {
- drupal_goto('admin/build/context'); return;
- }
- break;
- case 'edit':
- if (is_numeric($cid) && $context = context_ui_context('load', $cid)) {
- if (!$context->system) {
- drupal_set_title(t('Edit %title', array('%title' => $context->value)));
- }
- else {
- drupal_goto('admin/build/context'); return;
- }
- }
- break;
- }
-
- // Core context definition
- $form = array();
- $form['value'] = array(
- '#type' => 'textfield',
- '#title' => t('Value'),
- '#required' => true,
- '#maxlength' => 30,
- '#description' => t('A system name for this context. May only contain lowercase letters, underscores, and numbers. Example: <b>science_blog</b>'),
- );
- $form['key'] = array(
- '#type' => 'textfield',
- '#title' => t('Key'),
- '#default_value' => 'section',
- '#required' => true,
- '#maxlength' => 30,
- '#description' => t('The type of context information provided in this namespace. Example: <b>section</b>'),
- );
- $form['space'] = array(
- '#type' => 'textfield',
- '#title' => t('Namespace'),
- '#default_value' => 'context_ui',
- '#required' => true,
- '#maxlength' => 30,
- '#description' => t('The namespace for this context definition. Example: <b>context_ui</b>'),
- );
-
- $form['items'] = array(
- '#title' => t('Context Items'),
- '#tree' => true,
- '#type' => 'fieldset',
- );
-
- // Generate settings for context item associations
- foreach (context_ui_types('full') as $type => $item) {
- $form['items'][$type] = array(
- '#title' => $item['title'],
- '#description' => $item['description'],
- '#type' => 'checkboxes',
- '#size' => 8,
- '#multiple' => true,
- '#options' => $item['options'],
- '#prefix' => '<div class="context-ui-item clear-block">',
- '#suffix' => '</div>',
- );
- }
-
- // Control block visibility
- global $theme_key;
- $block_options =
- $block_defaults = array();
- $blocks = _context_ui_get_blocks();
- $regions = system_region_list($theme_key);
- // $blocks in [0] have not been assigned a region
- foreach ($blocks[0] as $block) {
- if (!isset($context->block[$block->bid])) {
- $block_options[$block->bid] = $block->label ." ($block->bid)";
- }
- }
-
- $form['block'] = array(
- '#type' => 'fieldset',
- '#title' => t('Blocks'),
- '#tree' => true,
- '#description' => t('Control block visibility using context. Selected blocks will be shown when this context is set provided that custom block visibility settings and/or throttling do not hide them. Grayed out blocks are those provided by Drupal\'s standard block settings. These settings apply to the current theme and any enabled themes with regions in common.'),
- );
- $form['block']['selector'] = array(
- '#type' => 'item',
- '#tree' => true,
- '#prefix' => '<div class="context-ui-block-selector">',
- '#suffix' => '</div>',
- 'blocks' => array(
- '#type' => 'select',
- '#multiple' => true,
- '#size' => 12,
- '#title' => t('Blocks'),
- '#options' => $block_options,
- ),
- 'regions' => array(
- '#type' => 'select',
- '#title' => t('Regions'),
- '#options' => $regions,
- ),
- 'add' => array(
- '#type' => 'markup',
- '#value' => "<input id='edit-block-selector-add' class='form-submit' type='button' value='+ ". t('Add') ."'/>",
- ),
- );
- $form['block']['regions'] = array(
- '#type' => 'item',
- '#tree' => true,
- '#prefix' => '<div class="context-ui-block-regions">',
- '#suffix' => '</div>',
- '#value' => theme('context_ui_block_ui', $regions, $context),
- );
- foreach (array_keys($regions) as $region) {
- $defaults = array();
- $midpoint = false;
- foreach (_context_ui_get_blocks($region, $context) as $block) {
- if ($block->type == 'context_ui') {
- $defaults[] = $block->bid;
- }
- else if (!$midpoint) {
- $midpoint = true;
- $defaults[] = 'system';
- }
- }
- if (!$defaults) {
- $defaults = array('system');
- }
- $defaults = implode(',', $defaults);
- $form['block']['regions'][$region] = array(
- '#type' => 'hidden',
- '#default_value' => $defaults,
- );
- }
-
- if ($op == 'view') {
- $form[] = array(
- '#type' => 'item',
- '#value' => l(t('Back'), 'admin/build/context'),
- );
- }
-
- if ($op != 'view') {
- $form[] = array(
- '#type' => 'submit',
- '#value' => t('Save'),
- );
- }
-
- if ($op == 'edit') {
- $form[] = array(
- '#type' => 'submit',
- '#value' => t('Delete'),
- );
- }
-
- if ($op == 'view' || $op == 'edit') {
- if ($context) {
- $form['value']['#default_value'] = $context->value;
- $form['key']['#default_value'] = $context->key;
- $form['space']['#default_value'] = $context->space;
- $form['cid'] = array(
- '#type' => 'value',
- '#value' => $cid,
- );
- $form['system'] = array(
- '#type' => 'value',
- '#value' => $context->system,
- );
- if ($op == 'view' || $context->system) {
- $form['value']['#disabled'] =
- $form['key']['#disabled'] =
- $form['space']['#disabled'] =
- $form['block']['selector']['blocks']['#disabled'] =
- $form['block']['selector']['regions']['#disabled'] = true;
- }
- // Set default values for each item type (except blocks)
- foreach (context_ui_types() as $type) {
- if (is_array($context->{$type})) {
- $defaults = array();
- foreach ($context->{$type} as $id) {
- $defaults[$id] = $id;
- }
- $form['items'][$type]['#default_value'] = $defaults;
- }
- $form['items'][$type]['#disabled'] = $op == 'view' ? true : false;
- }
- // Blocks must be selected by region
- if (is_array($context->block)) {
- foreach ($regions as $region => $label) {
- if (is_array($form['block'][$region])) {
- $defaults = array();
- foreach ($form['block'][$region]['#options'] as $block => $label) {
- if (array_search($block, $context->block) !== false) {
- $defaults[$block] = $block;
- }
- }
- $form['block'][$region]['#default_value'] = $defaults;
- }
- $form['block'][$region]['#disabled'] = $op == 'view' ? true : false;
- }
- }
- }
- else {
- return drupal_goto('admin/build/context');
- }
- }
-
- return $form;
-}
-
-/*
* hook_validate()
*/
function context_ui_form_validate($form_id, $form_values) {
- $context = new stdClass();
- if ($context->value = $form_values['value']) {
- $context->space = $form_values['space'];
- $context->key = $form_values['key'];
- if (!preg_match('!^[a-z0-9_]+$!', $context->value)) {
- form_set_error('value', t('The context name can only consist of lowercase letters, underscores, and numbers.'));
+ if ($form_values['value']) {
+ foreach (array('value', 'key', 'space') as $elem) {
+ if (!preg_match('!^[a-z0-9_]+$!', $form_values[$elem])) {
+ form_set_error($elem, t('The context !elem can only consist of lowercase letters, underscores, and numbers.', array('!elem' => $elem)));
+ }
}
}
}
}
/*
- * Provides a form with an exported context definition for use in modules.
- *
- * @param $cid
- * A context id.
- *
- * @return
- * A FormAPI array.
- */
-function context_ui_export($cid = NULL) {
- if (is_numeric($cid) && $context = context_ui_context('load', $cid)) {
- drupal_set_title(t('Export %title', array('%title' => $context->value)));
-
- // help text -- too bad the help module in 5 doesn't take wildcards
- $help = t('You can use exported contexts in your modules by returning an array of defined contexts in <code>hook_context_define()</code>.');
-
- // prune system specific information and cast for Drupal's AOP (array oriented programming)
- unset($context->cid);
- unset($context->status);
- unset($context->system);
- $context = (array) $context;
-
- // clean up blocks
- foreach ($context['block'] as $bid => $block) {
- unset($block->bid);
- $context['block'][$bid] = (array) $block;
- }
-
- // export
- $export = '$items[] = '. var_export($context, true) .';';
-
- // build the form
- $form = array();
- $form['help'] = array(
- '#type' => 'item',
- '#value' => $help,
- );
- $form['export'] = array(
- '#type' => 'textarea',
- '#rows' => 24,
- '#default_value' => $export,
- );
- return $form;
- }
- else {
- drupal_goto('admin/build/context'); return;
- }
-}
-
-/*
* Provides simple operations (load/insert/update/etc.) on a core context space/key/value definition.
*
* @param $op
}
/*
- * Provide a form to confirm deletion of a context definition.
- */
-function context_ui_delete_confirm($cid) {
- $context = context_ui_context('load', $cid);
- if (!$context) {
- return drupal_goto('admin/build/context');
- }
- $form['cid'] = array('#type' => 'value', '#value' => $cid);
- $form = confirm_form($form,
- t('Are you sure you want to delete %title?', array('%title' => $context->value)),
- 'admin/build/context',
- t('This action cannot be undone.'),
- t('Delete'), t('Cancel')
- );
- return $form;
-}
-
-/*
- * hook_submit()
- */
-function context_ui_delete_confirm_submit($form_id, $form) {
- context_ui_context('delete', $form['cid']);
- // rebuild cache
- context_ui_rebuild();
- return 'admin/build/context';
-}
-
-/*
* Helper function to generate a list of database and module provided views.
*/
function _context_ui_get_views() {
return $views;
}
-/*
+/**
* Helper function to generate a list of blocks from a specified region. If provided a context object,
* will generate a full list of blocks for that region distinguishing between system blocks and
* context-provided blocks.
return $region ? $blocks[$region] : $blocks;
}
-
-/*
- * Helper function to sort block objects by weight
- */
-function _context_ui_block_compare($a, $b) {
- // Enabled blocks
- return ($a->weight - $b->weight);
-}
<?php
-// $ID$
+// $Id$
/**
* Functional Test for Context UI
function get_info() {
return array(
'name' => t('Context UI functional tests'),
- 'desc' => t('Sets all possible context types and checks for integrity.') ,
+ 'desc' => t('Create a context and test context on node view.') ,
'group' => 'Context UI Tests',
);
}
}
function tearDown() {
+ include_once(drupal_get_path("module", "context_ui") ."/context_ui_admin.inc");
+ context_ui_context('delete', $this->context);
+
$this->drupalModuleDisable('context');
$this->drupalModuleDisable('context_ui');
}
function testCreateContext() {
+
// User setup
$user = $this->drupalCreateUserRolePerm(array('administer site configuration', 'access content', 'create page content'));
$this->drupalLoginUser($user);
// Create context
- $edit = array();
- $edit['space'] = $this->randomName(15);
- $edit['key'] = $this->randomName(15);
- $edit['value'] = $this->randomID(15); // Why no uppercase?
+ $context = new stdClass();
+ $context->space = $this->randomID(15);
+ $context->key = $this->randomID(15);
+ $context->value = $this->randomID(15);
+ $this->context = $context;
+
+ $edit = array('space' => $context->space, 'key' => $context->key, 'value' => $context->value);
$edit['items-node-page'] = 'page';
$this->drupalPostRequest('admin/build/context/add', $edit, 'Save');
$this->assertWantedRaw(t('The context %title was saved successfully.', array('%title' => $edit['value'])), 'Context saved');
- // Load context
- $c = array('space' => $edit['space'], 'key' => $edit['key'], 'value' => $edit['value']);
- $context = context_ui_context('load', (object)$c);
- $this->assertIsA($context, 'stdClass', 'Context found in database. %s');
-
// Create Page content
$edit = array();
$edit['title'] = $this->randomName(32);
$edit['body'] = $this->randomName(32);
$this->drupalPostRequest('node/add/page', $edit, 'Submit');
- // View context, and test context setting
+ // View context and test context setting
node_view(node_load(array('title' => $edit['title'])), FALSE, TRUE);
$this->assertIdentical(context_get($context->space, $context->key), $context->value , 'Custom context was set');
- // Delete context
- context_ui_context('delete', $context);
- $no_context = context_ui_context('load', $context);
- $this->assertFalse($no_context);
}
}