Commit d69aa078 authored by merlinofchaos's avatar merlinofchaos

Restore summary functionality

parent 4fc76df7
......@@ -210,6 +210,17 @@ function views_ui_edit_view_form_submit($form, &$form_state) {
// Clear the page cache.
cache_clear_all();
// Remove this view from cache so we can edit it properly.
views_object_cache_clear('view', $form_state['view']->name);
}
/**
* Submit handler for the edit view form.
*/
function views_ui_edit_view_form_cancel($form, &$form_state) {
// Remove this view from cache so edits will be lost.
views_object_cache_clear('view', $form_state['view']->name);
}
/**
......@@ -371,15 +382,24 @@ function views_ui_display_tab($view, &$display) {
}
}
// 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);
}
$left .= '</dl>';
$middle .= '<dl>';
$middle .= views_ui_add_info('relationship', $view, $display);
$middle .= views_ui_add_info('argument', $view, $display);
$middle .= views_ui_add_info('filter', $view, $display);
if ($style_plugin->uses_fields()) {
$middle .= views_ui_add_info('field', $view, $display);
}
$middle .= '</dl>';
$right .= '<dl>';
$right .= views_ui_add_info('field', $view, $display);
$right .= views_ui_add_info('filter', $view, $display);
$right .= views_ui_add_info('sort', $view, $display);
$right .= '</dl>';
......
......@@ -863,19 +863,19 @@ class views_handler_argument extends views_handler {
*/
function default_summary($order) {
$this->view->build_info['summary'] = TRUE;
$this->view->build_info['summary_level'] = $this->data->position;
$this->view->build_info['summary_level'] = $this->data->id;
// Change the display style to the summary style for this
// argument.
$this->view->style_plugin = $this->style_plugin;
$this->view->style_options = $this->style_options;
$this->view->style_plugin = $this->data->style_plugin;
$this->view->style_options = $this->data->style_options;
// Clear out the normal primary field and whatever else may have
// been added and let the summary do the work.
$this->query->clear_fields();
$this->summary_query();
$argument->handler->summary_sort($order);
$this->summary_sort($order);
// Summaries have their own sorting and fields, so tell the View not
// to build these.
......@@ -936,7 +936,7 @@ class views_handler_argument extends views_handler {
* The order selected in the UI.
*/
function summary_sort($order) {
$query->add_orderby(NULL, NULL, $order, $this->base_alias);
$this->query->add_orderby(NULL, NULL, $order, $this->base_alias);
}
/**
......
......@@ -34,20 +34,13 @@ function views_views_plugins() {
'handler' => 'views_display_plugin_block',
'uses hook block' => TRUE,
),
/*
'embed' => array(
'title' => t('Embedded'),
'help' => t('Creates a view that is used from other code. By itself an embedded view does not do anything.'),
'handler' => 'views_display_plugin',
),
*/
),
'style' => array(
'default' => array(
'title' => t('Unformatted'),
'help' => t('Displays rows one after another.'),
'handler' => 'views_style_plugin_default',
'theme' => 'views_view_summary',
'theme' => 'views_view_unformatted',
'uses row plugin' => TRUE,
),
'list' => array(
......@@ -83,14 +76,6 @@ function views_views_plugins() {
'theme' => 'views_view_row',
'uses fields' => TRUE,
),
'fields_summary' => array(
'title' => t('Summary'),
'help' => t('Displays the link to the argument and the row count.'),
'handler' => 'views_row_plugin_summary',
'theme' => 'views_view_row_summary',
'summary' => TRUE, // only shows up as a summary style
'uses fields' => TRUE,
),
),
);
......@@ -1102,10 +1087,26 @@ class views_style_plugin extends views_object {
}
}
/**
* Return TRUE if this style also uses a row plugin.
*/
function uses_row_plugin() {
return !empty($this->definition['uses row plugin']);
}
/**
* Return TRUE if this style also uses fields.
*/
function uses_fields() {
// If we use a row plugin, ask the row plugin. Chances are, we don't
// care, it does.
if ($this->uses_row_plugin()) {
return $this->row_plugin->uses_fields();
}
// Otherwise, maybe we do.
return !empty($this->definition['uses fields']);
}
/**
* Static member function to set default options.
*/
......@@ -1153,7 +1154,7 @@ class views_style_plugin_default extends views_style_plugin {
// @todo: Include separator as an option.
$rows .= $this->row_plugin->render($row);
}
return theme(array('views_view_rows__' . $this->view->name, 'views_view_rows'), $this->view, $rows);
return theme(array('views_view_unformatted__' . $this->view->name, 'views_view_unformatted'), $this->view, $rows);
}
}
......@@ -1195,7 +1196,7 @@ class views_style_plugin_list extends views_style_plugin {
// @todo: Include separator as an option.
$rows .= $this->row_plugin->render($row);
}
return theme(array('views_view_rows__' . $this->view->name, 'views_view_rows'), $this->view, $rows);
return theme(array('views_view_list__' . $this->view->name, 'views_view_list'), $this->view, $rows);
}
}
......@@ -1255,7 +1256,8 @@ class views_style_plugin_summary extends views_style_plugin {
$rows = array();
while ($row = db_fetch_object($this->view->result)) {
// @todo: Include separator as an option.
$rows[] = $this->row_plugin->render($row);
// $rows[] = theme(array('views_view_row_summary__' . $this->view->name, 'views_view_row_summary'), $this->view, $row);
$rows[] = $row;
}
return theme(array('views_view_summary__' . $this->view->name, 'views_view_summary'), $this->view, $rows);
}
......@@ -1288,6 +1290,10 @@ class views_row_plugin extends views_object {
$this->options = $display->handler->get_option('row_options');
}
function uses_fields() {
return !empty($this->definition['uses fields']);
}
/**
* Render a row object. This usually passes through to a theme template
* of some form, but not always.
......@@ -1297,16 +1303,6 @@ class views_row_plugin extends views_object {
}
}
/**
* Default plugin to view a single row of a table. This is really just a wrapper around
* a theme function.
*/
class views_row_plugin_summary extends views_object {
function render($row) {
return theme(array('views_view_row_summary__' . $this->view->name, 'views_view_row_summary'), $this->view, $row);
}
}
/**
* @}
*/
......@@ -285,7 +285,9 @@ class view extends views_db_object {
$argument_title = '';
// build arguments.
$position = -1;
foreach ($this->argument as $id => $arg) {
$position++;
$argument = &$this->argument[$id];
if (!is_object($argument->handler)) {
......@@ -293,11 +295,11 @@ class view extends views_db_object {
continue;
}
if (isset($this->args[$id]) && $argument->handler->validate($this->args[$id])) {
if (isset($this->args[$position]) && $argument->handler->validate($this->args[$position])) {
// handle argument that is present.
// @todo: Do we want to put in argument placeholders here
// So that we can try to cache queries with arguments too?
$argument->handler->argument = $this->args[$id];
$argument->handler->argument = $this->args[$position];
$argument->handler->query();
// Test to see if we should use this argument's title
......@@ -621,8 +623,9 @@ class view extends views_db_object {
* keys from view::db_objects()
*/
function _save_rows($key) {
$count = 0;
foreach ($this->$key as $position => $object) {
$object->position = $position;
$object->position = ++$count;
$object->vid = $this->vid;
$object->save_row();
}
......
......@@ -69,7 +69,7 @@ function node_views_data() {
),
// Information for accepting a nid as an argument
'argument' => array(
'handler' => 'views_handler_argument_nid',
'handler' => 'views_handler_argument_node_nid',
'arguments' => array('title'),
),
// Information for accepting a nid as a filter
......@@ -320,7 +320,7 @@ class views_handler_argument_node_nid extends views_handler_argument {
return t('No title');
}
return check_plain();
return check_plain($title);
}
}
......@@ -432,12 +432,12 @@ function node_views_plugins() {
*
* @ingroup views_row_plugins
*/
class views_row_plugin_node_view extends views_object {
class views_row_plugin_node_view extends views_row_plugin {
/**
* Override the behavior of the render() function.
*/
function render(&$view, $row) {
return theme(array('views_view_row_node__' . $view->name, 'views_view_row_node'), $view, $row);
function render($row) {
return theme(array('views_view_row_node__' . $this->view->name, 'views_view_row_node'), $this->view, $row);
}
}
......
......@@ -68,14 +68,15 @@ function theme_views_view_field($view, $field, $row) {
/**
* Preprocess theme function to print a single record from a row, with fields
*/
function template_preprocess_views_view_row_summary(&$vars) {
function template_preprocess_views_view_summary(&$vars) {
$view = $vars['view'];
$row = $vars['row'];
$argument = $view->argument[$view->build_info['summary_level']]->handler;
$vars['link'] = $argument->summary_name($row);
$vars['url'] = $argument->summary_link($row, $view->get_url());
$vars['count'] = intval($row->{$argument->count_alias});
foreach ($vars['rows'] as $id => $row) {
$vars['rows'][$id]->link = $argument->summary_name($row);
$vars['rows'][$id]->url = $argument->summary_link($row, $view->get_url());
$vars['rows'][$id]->count = intval($row->{$argument->count_alias});
}
}
/**
......
......@@ -7,4 +7,4 @@
* @ingroup views_templates
*/
?>
<a href="<?php print $url; ?>"><?php print $link; ?></a> (<?php print $count?>)
......@@ -10,7 +10,7 @@
<div class="item-list">
<ul>
<?php foreach ($rows as $row): ?>
<li><?php print $row?></li>
<li><a href="<?php print $row->url; ?>"><?php print $row->link; ?></a> (<?php print $row->count?>)
<?php endforeach; ?>
</ul>
</div>
......@@ -289,6 +289,7 @@ function views_include_handlers() {
views_include('handlers');
views_include('cache');
views_include('plugins');
_views_include_handlers();
$finished = TRUE;
}
......
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