function template_preprocess_views_ui_edit_item in Views (for Drupal 7) 6.2
Same name and namespace in other branches
- 6.3 includes/admin.inc \template_preprocess_views_ui_edit_item()
Add information about a section to a display.
File
Code
function template_preprocess_views_ui_edit_item(&$vars) {
$type = $vars['type'];
$view = $vars['view'];
$display = $vars['display'];
$types = views_object_types();
$vars['overridden'] = FALSE;
$vars['defaulted'] = FALSE;
if ($vars['no_fields']) {
$vars['title'] = $types[$type]['title'];
$vars['item_help_icon'] = theme('advanced_help_topic', 'views', $type);
$vars['rearrange'] = NULL;
$vars['add'] = NULL;
return;
}
$vars['rearrange'] = l('<span>' . t('Rearrange') . '</span>', "admin/build/views/nojs/rearrange/{$view->name}/{$display->id}/{$type}", array(
'attributes' => array(
'class' => 'views-button-rearrange views-ajax-link',
'title' => t('Rearrange'),
),
'html' => true,
));
$vars['add'] = l('<span>' . t('Add') . '</span>', "admin/build/views/nojs/add-item/{$view->name}/{$display->id}/{$type}", array(
'attributes' => array(
'class' => 'views-button-add views-ajax-link',
'title' => t('Add'),
),
'html' => true,
));
if (!$display->handler
->is_default_display()) {
if (!$display->handler
->is_defaulted($types[$type]['plural'])) {
$vars['overridden'] = TRUE;
}
else {
$vars['defaulted'] = TRUE;
}
}
if ($display->display_plugin != 'default') {
$vars['title'] = l($types[$type]['title'], "admin/build/views/nojs/config-type/{$view->name}/{$display->id}/{$type}", array(
'attributes' => array(
'class' => 'views-ajax-link',
),
));
}
else {
$vars['title'] = $types[$type]['title'];
}
$fields = array();
static $relationships = NULL;
if (!isset($relationships)) {
// Get relationship labels
$relationships = array();
// @todo: get_handlers()
$handlers = $display->handler
->get_option('relationships');
if ($handlers) {
foreach ($handlers as $id => $relationship) {
$handler = views_get_handler($relationship['table'], $relationship['field'], 'relationship');
if (empty($handler)) {
continue;
}
$handler
->init($view, $relationship);
$relationships[$id] = $handler
->label();
}
}
}
// @todo: get_handlers()
foreach ($display->handler
->get_option($types[$type]['plural']) as $id => $field) {
$fields[$id] = array();
$handler = views_get_handler($field['table'], $field['field'], $type);
if (empty($handler)) {
$fields[$id]['class'] = 'broken';
$field_name = t('Broken/missing handler: @table > @field', array(
'@table' => $field['table'],
'@field' => $field['field'],
));
$fields[$id]['title'] = l($field_name, "admin/build/views/nojs/config-item/{$view->name}/{$display->id}/{$type}/{$id}", array(
'attributes' => array(
'class' => 'views-ajax-link',
),
'html' => TRUE,
));
$fields[$id]['info'] = '';
continue;
}
$handler
->init($view, $field);
$field_name = $handler
->ui_name(TRUE);
if (!empty($field['relationship']) && !empty($relationships[$field['relationship']])) {
$field_name = '(' . $relationships[$field['relationship']] . ') ' . $field_name;
}
$fields[$id]['title'] = l($field_name, "admin/build/views/nojs/config-item/{$view->name}/{$display->id}/{$type}/{$id}", array(
'attributes' => array(
'class' => 'views-ajax-link',
),
'html' => TRUE,
));
$fields[$id]['class'] = views_ui_item_css($display->id . '-' . $type . '-' . $id);
if (!empty($view->changed_sections[$display->id . '-' . $type . '-' . $id])) {
$fields[$id]['changed'] = TRUE;
}
$fields[$id]['info'] = $handler
->admin_summary();
if ($handler
->has_extra_options()) {
$fields[$id]['links'] = l('<span>' . t('Settings') . '</span>', "admin/build/views/nojs/config-item-extra/{$view->name}/{$display->id}/{$type}/{$id}", array(
'attributes' => array(
'class' => 'views-button-configure views-ajax-link',
'title' => t('Settings'),
),
'html' => true,
));
}
if ($handler
->needs_style_plugin()) {
$style_plugin = views_fetch_plugin_data('style', $handler->options['style_plugin']);
$style_title = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin['title'];
$pid = $id . '-style-plugin';
if (!empty($style_plugin['uses options'])) {
$fields[$pid]['links'] = l('<span>' . t('Change settings for this style') . '</span>', "admin/build/views/nojs/config-style/{$view->name}/{$display->id}/{$type}/{$id}", array(
'attributes' => array(
'class' => 'views-button-configure views-ajax-link',
'title' => t('Settings'),
),
'html' => true,
));
}
$fields[$pid]['title'] = ' ' . t(' Style: !style', array(
'!style' => l($style_title, "admin/build/views/nojs/change-style/{$view->name}/{$display->id}/{$type}/{$id}", array(
'attributes' => array(
'class' => 'views-ajax-link',
),
)),
));
$fields[$pid]['class'] = views_ui_item_css($display->id . '-' . $type . '-' . $pid);
if (!empty($view->changed_sections[$display->id . '-' . $type . '-' . $pid])) {
$fields[$pid]['changed'] = TRUE;
}
$fields[$pid]['info'] = '';
}
}
$vars['fields'] = $fields;
$vars['item_help_icon'] = theme('advanced_help_topic', 'views', $type);
}