array('object'), 'file' => 'includes/context.theme.inc', ); $theme['ctools_context_list_no_table'] = array( 'arguments' => array('object'), 'file' => 'includes/context.theme.inc', ); $theme['ctools_context_item_form'] = array( 'arguments' => array('form'), 'file' => 'includes/context.theme.inc', ); $theme['ctools_context_item_row'] = array( 'arguments' => array('type', 'form', 'position', 'count', 'with_tr' => TRUE), 'file' => 'includes/context.theme.inc', ); // For the access plugin $theme['ctools_access_admin_add'] = array( 'arguments' => array('form'), 'file' => 'includes/context-admin.inc', ); } /** * Theme the form item for the context entry. */ function theme_ctools_context_item_row($type, $form, $position, $count, $with_tr = TRUE) { $output = ' ' . drupal_render($form['title']) . ''; if (!empty($form['position'])) { $output .= ' ' . drupal_render($form['position']) . ''; } $output .= '' . drupal_render($form['settings']); $output .= drupal_render($form['remove']) . ''; if ($with_tr) { $output = '' . $output . ''; } return $output; } /** * Display the context item. */ function theme_ctools_context_item_form($form) { $output = ''; $type = $form['#ctools_context_type']; $module = $form['#ctools_context_module']; $name = $form['#object_name']; $type_info = ctools_context_info($type); if (!empty($form[$type]) && empty($form['#only_buttons'])) { $count = 0; $rows = ''; foreach (array_keys($form[$type]) as $id) { if (!is_numeric($id)) { continue; } $rows .= theme('ctools_context_item_row', $type, $form[$type][$id], $id, $count++); } $output .= ''; $output .= ''; $output .= ''; $output .= ''; if (!empty($type_info['sortable']) && $count) { $output .= ''; } $output .= ''; $output .= ''; $output .= ''; $output .= ''; $output .= $rows; $output .= ''; $output .= '
' . $type_info['title'] . '' . t('Weight') . '' . t('Operation') . '
'; } if (!empty($form['buttons'])) { // Display the add context item. $row = array(); $row[] = array('data' => drupal_render($form['buttons'][$type]['item']), 'class' => 'title'); $row[] = array('data' => drupal_render($form['buttons'][$type]['add']), 'class' => 'add', 'width' => "60%"); $output .= '
'; $output .= drupal_render($form['buttons'][$type]); $output .= theme('table', array(), array($row), array('id' => $type . '-add-table')); $output .= '
'; } if (!empty($form['description'])) { $output .= drupal_render($form['description']); } if (!empty($type_info['sortable'])) { drupal_add_tabledrag($type . '-table', 'order', 'sibling', 'drag-position'); } return $output; } /** * Create a visible list of all the contexts available on an object. * Assumes arguments, relationships and context objects. * * Contexts must be preloaded. */ function theme_ctools_context_list($object, $header = '') { $titles = array(); $output = ''; $count = 1; // Describe 'built in' contexts. if (!empty($object->base_contexts)) { foreach ($object->base_contexts as $id => $context) { $output .= ''; $output .= '' . t('Built in context') . ''; $desc = check_plain($context->identifier); if (isset($context->keyword)) { $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context->keyword)) . '
'; } if (isset($context->description)) { $desc .= '
' . filter_xss_admin($context->description) . '
'; } $output .= '' . $desc . ''; $output .= ''; $titles[$id] = $context->identifier; $count++; } } // First, make a list of arguments. Arguments are pretty simple. if (!empty($object->arguments)) { foreach ($object->arguments as $argument) { $output .= ''; $output .= '' . t('Argument @count', array('@count' => $count)) . ''; $desc = check_plain($argument['identifier']); if (isset($argument['keyword'])) { $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $argument['keyword'])) . '
'; } $output .= '' . $desc . ''; $output .= ''; $titles[ctools_context_id($argument, 'argument')] = $argument['identifier']; $count++; } } $count = 1; // Then, make a nice list of contexts. if (!empty($object->contexts)) { foreach ($object->contexts as $context) { $output .= ''; $output .= '' . t('Context @count', array('@count' => $count)) . ''; $desc = check_plain($context['identifier']); if (isset($context['keyword'])) { $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context['keyword'])) . '
'; } $output .= '' . $desc . ''; $output .= ''; $titles[ctools_context_id($context)] = $context['identifier']; $count++; } } // And relationships if (!empty($object->relationships)) { foreach ($object->relationships as $relationship) { $output .= ''; $output .= '' . t('From "@title"', array('@title' => $titles[$relationship['context']])) . ''; $desc = check_plain($relationship['identifier']); if (isset($relationship['keyword'])) { $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $relationship['keyword'])) . '
'; } $output .= '' . $desc . ''; $output .= ''; $titles[ctools_context_id($relationship, 'relationship')] = $relationship['identifier']; $count++; } } $head = ''; if ($header) { $head .= ''; $head .= '' . $header . ''; $head .= ''; } return $output ? "$head$output
\n" : "$head
\n"; } /** * ctools_context_list() but not in a table format because tabledrag * won't let us have tables within tables and still drag. */ function theme_ctools_context_list_no_table($object) { ctools_add_css('context'); $titles = array(); $output = ''; $count = 1; // Describe 'built in' contexts. if (!empty($object->base_contexts)) { foreach ($object->base_contexts as $id => $context) { $output .= '
'; $output .= '
' . t('Built in context') . '
'; $desc = check_plain($context->identifier); if (isset($context->keyword)) { $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context->keyword)) . '
'; } if (isset($context->description)) { $desc .= '
' . filter_xss_admin($context->description) . '
'; } $output .= '
' . $desc . '
'; $output .= '
'; $titles[$id] = $context->identifier; $count++; } } // First, make a list of arguments. Arguments are pretty simple. if (!empty($object->arguments)) { foreach ($object->arguments as $argument) { $output .= '
'; $output .= '
' . t('Argument @count', array('@count' => $count)) . '
'; $desc = check_plain($argument['identifier']); if (isset($argument['keyword'])) { $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $argument['keyword'])) . '
'; } $output .= '
' . $desc . '
'; $output .= '
'; $titles[ctools_context_id($argument, 'argument')] = $argument['identifier']; $count++; } } $count = 1; // Then, make a nice list of contexts. if (!empty($object->contexts)) { foreach ($object->contexts as $context) { $output .= '
'; $output .= '
' . t('Context @count', array('@count' => $count)) . '
'; $desc = check_plain($context['identifier']); if (isset($context['keyword'])) { $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context['keyword'])) . '
'; } $output .= '
' . $desc . '
'; $output .= '
'; $titles[ctools_context_id($context)] = $context['identifier']; $count++; } } // And relationships if (!empty($object->relationships)) { foreach ($object->relationships as $relationship) { $output .= '
'; $output .= '
' . t('From "@title"', array('@title' => $titles[$relationship['context']])) . '
'; $desc = check_plain($relationship['identifier']); if (isset($relationship['keyword'])) { $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $relationship['keyword'])) . '
'; } $output .= '
' . $desc . '
'; $output .= '
'; $titles[ctools_context_id($relationship, 'relationship')] = $relationship['identifier']; $count++; } } return $output; }