Index: context_ui/context_ui.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/context/context_ui/Attic/context_ui.admin.inc,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 context_ui.admin.inc
--- context_ui/context_ui.admin.inc 12 Mar 2009 14:22:02 -0000 1.1.2.7
+++ context_ui/context_ui.admin.inc 17 Apr 2009 21:07:33 -0000
@@ -4,40 +4,107 @@
/**
* Page callback for context_ui admin landing page.
*/
-function context_ui_admin() {
- // Add css
- drupal_add_css(drupal_get_path("module", "context_ui") ."/context_ui.css");
-
+function context_ui_list_contexts() {
// rebuild blocks
_block_rehash();
// rebuild context cache
context_invalidate_cache();
- // user defined contexts
- $output = "
". t('Context definitions') ."
";
- $normal = context_contexts();
- if ($normal) {
- ksort($normal);
- $output .= theme('context_ui_admin', $normal);
+ $output = theme('context_ui_list_contexts');
+ return $output;
+}
+
+/**
+ * Preprocess the contexts list theme
+ */
+function template_preprocess_context_ui_list_contexts(&$vars) {
+ $contexts = context_contexts();
+ $conditions = context_conditions();
+ $reactions = context_reactions();
+ ksort($contexts);
+ $vars['contexts'] = array();
+
+ foreach ($contexts as $key => $context) {
+ $identifier = (isset($context->cid) && $context->cid) ? $context->cid : key;
+
+ $item = new stdClass();
+ $item->namespace = $context->namespace;
+ $item->attribute = $context->attribute;
+ $item->name = $context->value;
+ $item->ops = array();
+
+ switch ($context->type) {
+ case CONTEXT_STORAGE_DEFAULT:
+ $item->type = 'Default';
+ $links[0] = l(t('Override'), "admin/build/context/$identifier/clone");
+ $links[2] = l(t('Export'), "admin/build/context/$identifier/export");
+ $links[3] = l(t('Clone'), "admin/build/context/$identifier/clone");
+ break;
+ case CONTEXT_STORAGE_OVERRIDDEN:
+ $item->type = 'Overridden';
+ $links[0] = l(t('Edit'), "admin/build/context/$identifier");
+ $links[2] = l(t('Export'), "admin/build/context/$identifier/export");
+ $links[3] = l(t('Clone'), "admin/build/context/$identifier/clone");
+ $links[4] = l(t('Revert'), "admin/build/context/$identifier/delete");
+ break;
+ case CONTEXT_STORAGE_NORMAL:
+ $item->type = 'Normal';
+ $links[0] = l(t('Edit'), "admin/build/context/$identifier");
+ $links[2] = l(t('Export'), "admin/build/context/$identifier/export");
+ $links[3] = l(t('Clone'), "admin/build/context/$identifier/clone");
+ $links[4] = l(t('Delete'), "admin/build/context/$identifier/delete");
+ }
+ switch ($context->status) {
+ case CONTEXT_STATUS_DISABLED:
+ $item->classes = 'context-disabled';
+ $links[1] = l(t('Enable'), "admin/build/context/$identifier/enable");
+ break;
+ case CONTEXT_STATUS_ENABLED:
+ $item->classes = 'context-enabled';
+ $links[1] = l(t('Disable'), "admin/build/context/$identifier/disable");
+ }
+ $item->ops = implode(' | ', $links);
+
+ foreach ($conditions as $id => $condition) {
+ if (!empty($context->$id)) {
+ $item->conditions[] = $condition['#title'];
+ }
+ }
+ $item->conditions = isset($item->conditions) ? implode(', ', $item->conditions) : t('none');
+
+ foreach ($reactions as $id => $reaction) {
+ if (!empty($context->$id)) {
+ $item->reactions[] = $reaction['#title'];
+ }
+ }
+ $item->reactions = isset($item->reactions) ? implode(', ', $item->reactions) : t('none');
+
+ $item->description = !empty($context->description) ? filter_xss_admin($context->description) : '';
+ $vars['contexts'][] = $item;
}
- else {
- $output .= "". t('Please !add_context to get started.', array('!add_context' => l(t('add a context'), 'admin/build/context/add'))) ."
";
+
+ $getting_started = theme('advanced_help_topic', 'context_ui', 'getting-started', 'title');
+ if (!$getting_started) {
+ $getting_started = t('Install the advanced help module for the getting started');
}
- return $output;
+ $vars['help'] = t('Not sure what to do? Try the "!getting-started" page.', array('!getting-started' => $getting_started));
+ $vars['help_type_icon'] = theme('advanced_help_topic', 'context_ui', 'type');
+
+ drupal_add_css(drupal_get_path("module", "context_ui") ."/css/contexts-list.css");
}
/**
* Recursive function that intelligently populates default values in a
* form from a provided array of data.
- *
+ *
* @param $form
* A form API element to populate with default values.
* @param $data
* A keyed array of data that matches the tree structure of the
* form API branch it should populate.
- *
+ *
* @return
* A form API element populated with default values.
*/
@@ -140,7 +207,7 @@ function context_ui_form(&$form_state, $
}
$form['value']['#description'] = t('A system name for this context. May only contain lowercase letters, underscores, and numbers. Example: science_blog');
-
+
$form['attribute']['#default_value'] = empty($form['attribute']['#default_value']) ? 'section' : $form['attribute']['#default_value'];
$form['attribute']['#description'] = t('The type of context information provided in this namespace. Example: section');
@@ -622,7 +689,7 @@ function context_ui_bulk_export(&$form_s
);
$form['submit'] = array(
- '#type' => 'submit',
+ '#type' => 'submit',
'#value' => t('Export'),
);
@@ -687,89 +754,7 @@ function theme_context_ui_bulk_export_ta
return $output;
}
-/**
- * Generates the main context_ui admin page with a tiered context listing.
- */
-function theme_context_ui_admin($contexts) {
- $rows = $headings = array();
- foreach ($contexts as $key => $context) {
- $row = array();
-
- $namespace = $context->namespace;
- $attribute = $context->attribute;
- $value = $context->value;
- if (isset($context->cid) && $context->cid) {
- $identifier = $context->cid;
- }
- else {
- $identifier = $key;
- }
-
- // If no heading has been printed for this n/a pair, do so
- if (!isset($rows["$namespace-$attribute"])) {
- $row = array(array('data' => "$namespace > $attribute", 'colspan' => 2));
- $rows["$namespace-$attribute"] = $row;
- }
-
- // Add row for context
- $links = array();
- $icon = theme('advanced_help_topic', 'context_ui', 'type');
- switch ($context->type) {
- case CONTEXT_STORAGE_DEFAULT:
- $type = 'Default';
- $links[0] = l(t('Override'), "admin/build/context/$identifier/clone");
- $links[2] = l(t('Export'), "admin/build/context/$identifier/export");
- $links[3] = l(t('Clone'), "admin/build/context/$identifier/clone");
- break;
- case CONTEXT_STORAGE_OVERRIDDEN:
- $type = 'Overridden';
- $links[0] = l(t('Edit'), "admin/build/context/$identifier");
- $links[2] = l(t('Export'), "admin/build/context/$identifier/export");
- $links[3] = l(t('Clone'), "admin/build/context/$identifier/clone");
- $links[4] = l(t('Revert'), "admin/build/context/$identifier/delete");
- break;
- case CONTEXT_STORAGE_NORMAL:
- $type = 'Normal';
- $links[0] = l(t('Edit'), "admin/build/context/$identifier");
- $links[2] = l(t('Export'), "admin/build/context/$identifier/export");
- $links[3] = l(t('Clone'), "admin/build/context/$identifier/clone");
- $links[4] = l(t('Delete'), "admin/build/context/$identifier/delete");
- }
- switch ($context->status) {
- case CONTEXT_STATUS_DISABLED:
- $class = 'disabled';
- $enable = l(t('Enable'), "admin/build/context/$identifier/enable");
- break;
- case CONTEXT_STATUS_ENABLED:
- $class = 'enabled';
- $enable = l(t('Disable'), "admin/build/context/$identifier/disable");
- }
- $links[1] = $enable;
- if ($icon) {
- // These spans are used to work-around advanced help's default styling of
- // floating the help icon left. We would like to display it after the text,
- // so we put a series of floats next to each other.
- $data = "$value ($type $icon)";
- }
- else {
- $data = "$value ($type)";
- }
- $description = !empty($context->description) ? ''. filter_xss_admin($context->description) .'
' : '';
- ksort($links);
- $rows[$key] = array(
- 'data' => array(
- array(
- 'data' => $data . $description,
- 'class' => 'context-name '. ($icon? 'icon' : 'no-icon'),
- ),
- implode(' | ', $links),
- ),
- 'class' => 'context-table-row ' . $class,
- );
- }
- return theme('table', array(t('Context'), t('Operations')), $rows, array('class' => 'context-ui-overview'));
-}
/**
* Generates the AJAX enabled block administration portion of the context_ui admin form.
@@ -843,7 +828,7 @@ function context_ui_form_validate($form,
*/
function context_ui_form_process($form) {
$context = new stdClass();
-
+
// Context ns/attr/value definition
foreach (array('cid', 'system', 'namespace', 'attribute', 'value', 'description') as $item) {
$context->$item = isset($form[$item]) ? $form[$item] : NULL;
Index: context_ui/context_ui.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/context/context_ui/context_ui.css,v
retrieving revision 1.6.2.7
diff -u -p -r1.6.2.7 context_ui.css
--- context_ui/context_ui.css 8 Mar 2009 04:34:10 -0000 1.6.2.7
+++ context_ui/context_ui.css 17 Apr 2009 20:32:43 -0000
@@ -36,48 +36,6 @@
* Context admin listing page =========================================
*/
-table.context-ui-overview a.advanced-help-link {
- position: relative;
- top: 3px;
- margin-left: 3px;
- }
-
-table.context-ui-overview span.context-namespace {
- font-weight:bold;
- }
-
-table.context-ui-overview td.context-name {
- padding-left:30px;
- }
-
-table.context-ui-overview tr.disabled td.context-name {
- color:#999;
- }
-
-table.context-ui-overview tr.context-table-row td.icon strong,
-table.context-ui-overview tr.context-table-row td.icon em,
-table.context-ui-overview tr.context-table-row td.icon span {
- display: block;
- float: left;
- padding-right: 2px;
- }
-
-table.context-ui-overview tr.context-table-row td div.description {
- margin-bottom: 0;
- }
-
-table.context-ui-overview tr.context-table-row td div.description {
- margin-bottom: 0;
- }
-
-table.context-ui-overview tr.context-table-row td.icon strong {
- padding-right: 4px;
- }
-
-table.context-ui-overview tr.context-table-row td.icon a span {
- display: none;
- }
-
h3.context-space small {
display:inline;
padding:.1em .5em; margin-left:1em;
Index: context_ui/context_ui.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/context/context_ui/context_ui.module,v
retrieving revision 1.13.2.48
diff -u -p -r1.13.2.48 context_ui.module
--- context_ui/context_ui.module 17 Mar 2009 18:57:51 -0000 1.13.2.48
+++ context_ui/context_ui.module 17 Apr 2009 19:00:40 -0000
@@ -5,30 +5,29 @@
* 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',
- );
- $items['context_ui_form'] = array(
- 'arguments' => array('form' => array()),
- 'file' => 'context_ui.admin.inc',
- );
- $items['context_ui_block_ui'] = array(
- 'arguments' => array('form' => array()),
- 'file' => 'context_ui.admin.inc',
- );
- $items['context_ui_admin'] = array(
+ $path = drupal_get_path('module', 'context_ui');
+
+ // This is only required for the preprocess function.
+ require_once "./$path/context_ui.admin.inc";
+
+ // Minor code reduction technique.
+ $base = array(
'arguments' => array('form' => array()),
'file' => 'context_ui.admin.inc',
);
- $items['context_ui_bulk_export_table'] = array(
- 'arguments' => array('form' => array()),
- 'file' => 'context_ui.admin.inc',
+
+ $items['context_ui_export_form'] = $base;
+ $items['context_ui_item_display'] = $base;
+ $items['context_ui_form'] = $base;
+ $items['context_ui_block_ui'] = $base;
+ $items['context_ui_bulk_export_table'] = $base;
+
+ // list contexts (admin landing page)
+ $items['context_ui_list_contexts'] = array(
+ 'template' => 'context-ui-list-contexts',
+ 'path' => "$path/theme",
);
+
$items['context_devel'] = array(
'arguments' => array('form' => array()),
);
@@ -72,12 +71,11 @@ function context_ui_menu() {
$items['admin/build/context'] = array(
'title' => 'Context',
'description' => 'Associate menus, views, blocks, etc. with different contexts to structure your site.',
- 'page callback' => 'context_ui_admin',
+ 'page callback' => 'context_ui_list_contexts',
'type' => MENU_NORMAL_ITEM,
);
$items['admin/build/context/list'] = array(
'title' => 'List',
- 'page callback' => 'context_ui_admin',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
@@ -207,13 +205,13 @@ function context_ui_form_block_admin_con
$row[] = $context->namespace;
$row[] = $context->attribute;
$row[] = $context->value;
- $row[] = $block->region;
+ $row[] = $block->region;
$identifier = "{$context->namespace}-{$context->attribute}-{$context->value}";
$options = array(
'fragment' => 'context-ui-blocks',
'query' => 'destination='. $_GET['q'],
);
- if ($context->system) {
+ if ($context->system) {
$row[] = l(t('Override visibility'), "admin/build/context/$identifier/clone", $options);
}
else {
cvs diff: Diffing context_ui/help
Index: context_ui/help/context_ui.help.ini
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/context/context_ui/help/Attic/context_ui.help.ini,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 context_ui.help.ini
--- context_ui/help/context_ui.help.ini 9 Feb 2009 02:36:35 -0000 1.1.2.1
+++ context_ui/help/context_ui.help.ini 17 Apr 2009 18:06:53 -0000
@@ -2,5 +2,10 @@
[advanced help settings]
line break = TRUE
+[getting-started]
+title = "Getting started"
+weight = -45
+
[type]
-title = "Types"
+title = "Context types"
+
cvs diff: Diffing context_ui/tests
cvs diff: Diffing tests