Commit b7059adb authored by merlinofchaos's avatar merlinofchaos

A basic analyzer to help find problems, though it needs more analyzing. Plus,...

A basic analyzer to help find problems, though it needs more analyzing. Plus, new theming information that will really help people figure out exactly what templates they can use to affect their output.
parent e01ef45a
......@@ -473,6 +473,13 @@ div.changed div.view-changed {
padding-left: 10px;
}
#views-ajax-pad pre {
overflow: auto;
border: 1px solid #333;
background-color: #f0f0f0;
padding: .5em;
}
form#views-add-display-form {
margin-bottom: 0em;
}
......
......@@ -798,13 +798,10 @@ function template_preprocess_views_ui_edit_tab(&$vars) {
$vars['categories'] = $categories;
// Fetch style plugin info because it has some effect on how/what we render.
$style_plugin = views_get_plugin('style', $display->handler->get_option('style_plugin'));
if ($style_plugin) {
$style_plugin->init($view, $display);
}
$style_plugin = $display->handler->get_plugin();
$vars['fields'] = '';
if ($style_plugin->uses_fields()) {
if ($style_plugin && $style_plugin->uses_fields()) {
$vars['fields'] = theme('views_ui_edit_item', 'field', $view, $display);
}
......@@ -971,18 +968,20 @@ function views_ui_standard_form_buttons(&$form, &$form_state, $form_id, $name =
// remove default validate handler
$form['#validate'] = array();
// but be sure submit button validates!
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => $name,
'#submit' => array($form_id . '_submit'),
'#validate' => array('views_ui_standard_submit', $form_id . '_validate'),
);
if (empty($form_state['ok_button'])) {
// but be sure submit button validates!
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => $name,
'#submit' => array($form_id . '_submit'),
'#validate' => array('views_ui_standard_submit', $form_id . '_validate'),
);
}
$cancel_submit = function_exists($form_id . '_cancel') ? $form_id . '_cancel' : 'views_ui_standard_cancel';
$form['buttons']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#value' => empty($form_state['ok_button']) ? t('Cancel') : t('Ok'),
'#submit' => array($cancel_submit),
'#validate' => array(),
);
......@@ -1218,7 +1217,7 @@ function views_ui_remove_display_form_restore($form, &$form_state) {
}
/**
* Page callback to edit details of a view.
* Page callback to display analysis information on a view.
*/
function views_ui_analyze_view($js, $view) {
views_include('ajax');
......@@ -1276,12 +1275,11 @@ function views_ui_views_analyze($view) {
$ret[] = views_ui_analysis(t('This view has only a default display and therefore will not be placed anywhere on your site; perhaps you want to add a page or a block display.'), 'warning');
}
return $ret;
}
/**
* Form constructor callback to edit details of a view
* Form constructor callback to display analysis information on a view
*/
function views_ui_analyze_view_form(&$form_state) {
$view = &$form_state['view'];
......@@ -1326,9 +1324,9 @@ function views_ui_analyze_view_form(&$form_state) {
'#value' => $output,
);
// Inform the standard button function that we want an OK button.
$form_state['ok_button'] = TRUE;
views_ui_standard_form_buttons($form, $form_state, 'views_ui_analyze_view_form');
unset($form['buttons']['submit']);
$form['buttons']['cancel']['#value'] = t('Ok');
return $form;
}
......
......@@ -147,6 +147,38 @@ class views_handler_field extends views_handler {
$value = $values->{$this->field_alias};
return check_plain($value);
}
/**
* Call out to the theme() function, which probably just calls render() but
* allows sites to override output fairly easily.
*/
function theme($values) {
return theme($this->theme_functions(), $this->view, $this, $values);
}
function theme_functions() {
$themes = array();
$hook = 'views_view_field';
$display = $this->view->display[$this->view->current_display];
if (!empty($display)) {
$themes[] = $hook . '__' . $this->view->name . '__' . $display->id . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->name . '__' . $display->id;
$themes[] = $hook . '__' . $display->id . '__' . $this->options['id'];
$themes[] = $hook . '__' . $display->id;
if ($display->id != $display->display_plugin) {
$themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin;
$themes[] = $hook . '__' . $display->display_plugin . '__' . $this->options['id'];
$themes[] = $hook . '__' . $display->display_plugin;
}
}
$themes[] = $hook . '__' . $this->view->name . '__' . $this->options['id'];
$themes[] = $hook;
return $themes;
}
}
/**
......
This diff is collapsed.
......@@ -1186,12 +1186,6 @@ class views_plugin_row_node_view extends views_plugin_row {
'#default_value' => $this->options['links'],
);
}
/**
* Override the behavior of the render() function.
*/
function render($row) {
return theme(array('views_view_row_node__' . $this->view->name, 'views_view_row_node'), $this->view, $this->options, $row);
}
}
/**
......
......@@ -270,7 +270,7 @@ class views_plugin_row_search_view extends views_plugin_row {
* Override the behavior of the render() function.
*/
function render($row) {
return theme(array('views_view_row_search__' . $this->view->name, 'views_view_row_search'), $this->view, $this->options, $row);
return theme($this->theme_functions(), $this->view, $this->options, $row);
}
}
......
......@@ -22,10 +22,10 @@ function _views_theme_functions($hook, $view, $display = NULL) {
$themes = array();
if ($display) {
$themes[] = $hook . '__' . $display->id . '__' . $view->name;
$themes[] = $hook . '__' . $view->name . '__' . $display->id;
$themes[] = $hook . '__' . $display->id;
if ($display->id != $display->display_plugin) {
$themes[] = $hook . '__' . $display->display_plugin . '__' . $view->name;
$themes[] = $hook . '__' . $view->name . '__' . $display->display_plugin;
$themes[] = $hook . '__' . $display->display_plugin;
}
}
......@@ -137,17 +137,9 @@ function template_preprocess_views_view_fields(&$vars) {
// Loop through the fields for this view.
foreach ($view->field as $id => $field) {
if (!empty($field['handler']) && is_object($field['handler'])) {
$themes = array(
'views_view_field__' . $view->name . '__' . $field['handler']->field_alias,
'views_view_field__' . $view->name,
'views_view_field__' . $id,
'views_view_field',
);
$object = new stdClass();
// Add the field into a variable named after the field. field_alias will be unique.
$object->content = theme($themes, $view, $field, $vars['row']);
$object->content = $field['handler']->theme($vars['row']);
if (isset($field['handler']->field_alias) && isset($vars['row']->{$field['handler']->field_alias})) {
$object->raw = $vars['row']->{$field['handler']->field_alias};
}
......@@ -172,7 +164,7 @@ function template_preprocess_views_view_fields(&$vars) {
* this: @code { $row->{$field->field_alias} @endcode
*/
function theme_views_view_field($view, $field, $row) {
return $field['handler']->render($row);
return $field->render($row);
}
/**
......@@ -246,14 +238,14 @@ function template_preprocess_views_view_table(&$vars) {
foreach ($result as $num => $row) {
if (!empty($fields[$field]['handler']) && is_object($fields[$field]['handler'])) {
$handler = &$fields[$field]['handler'];
$themes = array(
'views_view_field__' . $view->name . '__' . $handler->field_alias,
'views_view_field__' . $view->name,
'views_view_field__' . $handler->field_alias,
'views_view_field',
);
$field_output = $handler->theme($row);
// Don't bother with separators and stuff if the field does not show up.
if (!$field_output) {
continue;
}
// Add the field into a variable named after the field. field_alias will be unique.
// Place the field into the column, along with an optional separator.
if (isset($vars['rows'][$num][$column])) {
if (!empty($options['info'][$column]['separator'])) {
$vars['rows'][$num][$column] .= $options['info'][$column]['separator'];
......@@ -263,7 +255,7 @@ function template_preprocess_views_view_table(&$vars) {
$vars['rows'][$num][$column] = '';
}
$vars['rows'][$num][$column] .= theme($themes, $view, $fields[$field], $row);
$vars['rows'][$num][$column] .= $field_output;
}
}
}
......
......@@ -34,21 +34,6 @@ function views_theme() {
);
// Default view themes
$hooks['views_view'] = $base + array(
'template' => 'views-view',
'pattern' => 'views_view__',
'arguments' => $arguments['display'],
);
$hooks['views_view_rows'] = $base + array(
'template' => 'views-view-rows',
'pattern' => 'views_view_rows__',
'arguments' => $arguments['style'],
);
$hooks['views_view_row'] = $base + array(
'template' => 'views-view-row',
'pattern' => 'views_view_row__',
'arguments' => $arguments['row'],
);
$hooks['views_view_field'] = $base + array(
'pattern' => 'views_view_field__',
'arguments' => array('view' => NULL, 'field' => NULL, 'row' => NULL),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment