Commit d3b06159 authored by merlinofchaos's avatar merlinofchaos

Checkpoint checking. UI is getting better, but it is also getting further away...

Checkpoint checking. UI is getting better, but it is also getting further away from what currently runs, so when this is done a bunch of refactoring is going to have to happen.
parent dc3ec4ee
......@@ -48,14 +48,14 @@
background-color: #eee;
}
.views-tabset .views-display .top {
.views-display .top {
padding: 2px 5px;
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 2px solid black;
}
.views-tabset .views-display .top .display-description {
.views-display .top .display-description {
margin-left: 1em;
font-style: italic;
overflow: hide;
......@@ -78,13 +78,16 @@
.views-display .tab-section .links {
float: right;
font-size: 6pt;
}
.views-display .tab-section .links a {
font-size: small;
font-size: 6pt;
font-style: italic;
}
.views-display .form-submit {
.views-display .form-submit,
#views-ajax-pad .form-submit {
margin: 0;
}
......@@ -122,6 +125,17 @@
#views-ajax-pad .form-buttons {
float: right;
margin: 0;
padding: 0;
}
#views-ajax-pad .form-buttons .form-submit {
margin: 0 .5em 0 0;
padding: 0;
}
#views-ajax-pad .form-item {
margin-top: 0;
}
#views-ajax-pad {
......@@ -131,3 +145,47 @@
html.js #views-ajax-pad {
display: block;
}
#views-ajax-pad .views-override .form-submit {
float: right;
margin: 0 .5em 0 1em;
}
#views-ajax-pad .views-override .description {
margin-bottom: .25em;
}
#views-ajax-pad .views-left-10 {
float: left;
width: 10%;
}
#views-ajax-pad .views-left-20 {
float: left;
width: 20%;
}
#views-ajax-pad .views-left-25 {
float: left;
width: 25%;
}
#views-ajax-pad .views-left-30 {
float: left;
width: 30%;
}
#views-ajax-pad .views-left-40 {
float: left;
width: 40%;
}
#views-ajax-pad .views-left-50 {
float: left;
width: 50%;
}
#views-ajax-pad .views-radio-box {
overflow: auto;
max-height: 180px;
}
This diff is collapsed.
......@@ -92,6 +92,44 @@ function views_ajax_form($form_id) {
views_ajax_render($output, $title, $url);
}
/**
* Sometimes we need to render a form but explicitly not process it.
*/
function views_render_ajax_form($form_id) {
$args = func_get_args();
// Insert a placeholder for the form state so we can then assign a reference to it.
array_splice($args, 1, 0, array(NULL));
// Create the empty form state object.
$form_state = array('storage' => NULL, 'submitted' => FALSE, 'post' => $_POST, 'ajax' => TRUE);
// Replace the URL with the empty form state object as a reference:
$args[1] = &$form_state;
$form = call_user_func_array('drupal_retrieve_form', $args);
// Prepare the form. My Drupal 5 code didn't do this, so I'm not sure
// if it is necessary in D6 or not.
$form_build_id = 'form-'. md5(mt_rand());
$form['#build_id'] = $form_build_id;
drupal_prepare_form($form_id, $form, $form_state);
// Process the form our own selves so we don't get some extra batch handling
// that we don't want.
$form['#post'] = array();
$form_state['values'] = array();
$form = form_builder($form_id, $form, $form_state);
// Render the form and return the object data.
$output = new stdClass();
$output->display = theme('status_messages');
$output->display .= drupal_render_form($form_id, $form);
$output->title = empty($form['#title']) ? '' : $form['#title'];
$output->url = empty($form['#url']) ? url($_GET['q'], array('absolute' => TRUE)) : $form['#url'];
return $output;
}
/**
* @}
*/
\ No newline at end of file
......@@ -52,9 +52,7 @@ function _views_fetch_data($table = NULL) {
// @todo: We can probably cache the views_data longer than just the current page run.
$cache = module_invoke_all('views_data');
if (module_exists('devel')) {
dsm('Views data build time: ' . (microtime() - $start) * 1000 . ' ms');
}
vpr('Views data build time: ' . (microtime() - $start) * 1000 . ' ms');
}
if (!$table) {
......@@ -79,9 +77,7 @@ function _views_fetch_plugin_data($type = NULL, $plugin = NULL) {
$cache = views_discover_plugins();
if (module_exists('devel')) {
dsm('Views plugins build time: ' . (microtime() - $start) * 1000 . ' ms');
}
vpr('Views plugins build time: ' . (microtime() - $start) * 1000 . ' ms');
}
if (!$type && !$plugin) {
......
......@@ -51,7 +51,7 @@ function views_get_table_join($table, $primary_table) {
return $handler;
}
// DEBUG -- identify missing handlers
dsm("missing join: $table $primary_table");
vpr("Missing join: $table $primary_table");
}
/**
......
This diff is collapsed.
......@@ -131,6 +131,7 @@ class view extends views_db_object {
return TRUE;
}
// Ensure the requested display exists.
if (empty($this->display[$display_id])) {
$display_id = 'default';
if (empty($this->display[$display_id])) {
......@@ -139,23 +140,33 @@ class view extends views_db_object {
}
}
// Instantiate all displays
foreach (array_keys($this->display) as $id) {
$display = &$this->display[$id];
$display->handler = views_get_plugin('display', $display->display_plugin);
if (!empty($display->handler)) {
// Initialize the new display handler with data.
$display->handler->init($this, $display);
// If this is NOT the default display handler, let it know which is
// since it may well utilize some data from the default.
// This assumes that the 'default' handler is always first. It always
// is. Make sure of it.
if ($id != 'default') {
$display->handler->default_display = &$this->display['default']->handler;
}
}
}
// Set the current display.
$this->current_display = $display_id;
// Fetch the display handler data and instantiate an object.
$display = &$this->display[$this->current_display];
$display->handler = views_get_plugin('display', $display->display_plugin);
if (empty($display->handler)) {
// Ensure requested display has a working handler.
if (empty($this->display[$display_id]->handler)) {
return FALSE;
}
// init the new display handler with data.
$display->handler->init($this, $display);
// If this is NOT the default display handler, let it know which is
// since it may well utilize some data from the default.
if ($this->current_display != 'default') {
$display->handler->default_display = $this->display['default'];
}
// Create a shortcut
$display = &$this->display[$display_id];
// Set a shortcut
$this->display_handler = &$display->handler;
......@@ -171,10 +182,10 @@ class view extends views_db_object {
*/
function init_style() {
if (!isset($this->style_plugin)) {
$this->style_plugin = $this->display[$this->current_display]->style_plugin;
$this->style_plugin = $this->display[$this->current_display]->get_option('style_plugin');
}
dsm("Init_style: $this->style_plugin");
vpr("Init_style: $this->style_plugin");
$this->style_handler = views_get_plugin('style', $this->style_plugin);
if (empty($this->style_handler)) {
return FALSE;
......@@ -820,14 +831,12 @@ class views_db_object {
*
* @param $type
* The plugin type from the views plugin data. Defaults to 'page'.
* @param $style
* The style plugin from the views plugin data. Defaults to 'default'.
*
* @return
* The key to the display in $view->display, so that the new display
* can be easily located.
*/
function add_display($type = 'page', $style = 'default') {
function add_display($type = 'page') {
if (empty($type)) {
return FALSE;
}
......@@ -851,13 +860,7 @@ class views_db_object {
// Create the new display object
$display = new views_display;
$display->display_title = $title;
$display->display_plugin = $type;
$display->style_plugin = $style;
$display->id = $id;
// @todo Should the display plugin have some kind of constructor
// to fill in default values here? That seems very logical.
$display->construct($type, $id, $title);
// Add the new display object to the view.
$this->display[$id] = $display;
......@@ -914,6 +917,16 @@ class views_display extends views_db_object {
function views_display($init = TRUE) {
parent::init($init);
}
function construct($type, $id, $title) {
$this->display_plugin = $type;
$this->id = $id;
$this->display_title = $title;
// Create a handler to fill in default values.
$handler = views_get_plugin('display', $type);
$handler->construct($this);
}
}
/**
......
......@@ -338,6 +338,7 @@ function node_views_plugins() {
'handler' => 'views_row_plugin_node_view',
'theme' => 'views_view_row_node',
'base' => array('node'), // only works with 'node' as base.
'uses options' => TRUE,
),
),
);
......
<?php
// $Id$
/**
* @file views-view-row-node.tpl.php
* Default simple view template to display a list of rows.
*
* @ingroup views_templates
*/
?>
<?php print $node; ?>
\ No newline at end of file
......@@ -103,83 +103,6 @@ function views_schema() {
'not null' => TRUE,
'description' => t('The type of the display. Usually page, block or embed, but is pluggable so may be other things.'),
),
'access' => array(
'type' => 'varchar',
'length' => 255,
'description' => t('A serialized array describing who can access this display of the view.'),
'serialize' => TRUE,
'serialized default' => 'a:0:{}',
),
'style_plugin' => array(
'type' => 'varchar',
'length' => '64',
'default' => '',
'not null' => TRUE,
'description' => t('The output type of the display. Usually list, table, teasers or nodes, but is pluggable so may be other things.'),
),
'title' => array(
'type' => 'varchar',
'length' => '255',
'default' => '',
'not null' => TRUE,
'description' => t('The title of the view use for this display.'),
),
'header' => array(
'type' => 'blob',
'description' => t('Text to display for the header.'),
),
'header_format' => array(
'type' => 'int',
'default' => FILTER_FORMAT_DEFAULT,
'description' => t('The output format for the header.'),
),
'header_hide_empty' => array(
'type' => 'int',
'default' => 1,
'size' => 'tiny',
'description' => t('If true, hide the header when the view has no records to display.'),
),
'footer' => array(
'type' => 'blob',
'description' => t('Text to display for the footer.'),
),
'footer_format' => array(
'type' => 'int',
'default' => FILTER_FORMAT_DEFAULT,
'description' => t('The output format for the footer.'),
),
'footer_hide_empty' => array(
'type' => 'int',
'default' => 1,
'size' => 'tiny',
'description' => t('If true, hide the footer when the view has no records to display.'),
),
'empty' => array(
'type' => 'blob',
'description' => t('Text to display if the view produces no records.'),
),
'empty_format' => array(
'type' => 'int',
'default' => FILTER_FORMAT_DEFAULT,
'description' => t('The output format for the empty text.'),
),
'use_pager' => array(
'type' => 'int',
'default' => 1,
'size' => 'tiny',
'description' => t('If true, this display will utilize the pager.'),
),
'url' => array(
'type' => 'varchar',
'length' => '255',
'description' => t('The URL of the display, if applicable.'),
),
'block' => array(
'type' => 'int',
'size' => 'tiny',
'default' => 0,
'description' => t('True if the display responds to hook_block; false otherwise.'),
),
'position' => array(
'type' => 'int',
'default' => 0,
......@@ -191,18 +114,6 @@ function views_schema() {
'serialize' => TRUE,
'serialized default' => 'a:0:{}',
),
'style_options' => array(
'type' => 'blob',
'description' => t('A serialized array of options for this display\'s style plugin; it contains options that are generally only pertinent to that type.'),
'serialize' => TRUE,
'serialized default' => 'a:0:{}',
),
'filter_options' => array(
'type' => 'blob',
'description' => t('A serialized array of options for this display\'s exposed filters.'),
'serialize' => TRUE,
'serialized default' => 'a:0:{}',
),
),
'indexes' => array('vid' => array('vid', 'position')),
);
......
......@@ -321,7 +321,7 @@ function views_get_handler($table, $field, $key) {
return _views_prepare_handler($data[$field][$key], $data, $field);
}
// DEBUG -- identify missing handlers
dsm("Missing handler: $table $field $key");
vpr("Missing handler: $table $field $key");
}
/**
......@@ -352,6 +352,73 @@ function views_fetch_base_table_names() {
return $base_tables;
}
/**
* Fetch a list of all base tables available
*
* @return
* A keyed array of in the form of 'base_table' => 'Description'.
*/
function views_fetch_field_names($base, $type) {
static $fields = array();
if (empty($fields)) {
$data = views_fetch_data();
$start = microtime();
foreach ($data as $table => $table_data) {
$bases = array();
$strings = array();
foreach ($table_data as $field => $info) {
// Collect table data from this table
if ($field == 'table') {
// calculate what tables this table can join to.
if (!empty($info['join'])) {
$bases = array_keys($info['join']);
}
// And if this table IS a base table it obviously joins to itself.
if (!empty($info['base'])) {
$bases[] = $table;
}
continue;
}
foreach (array('field', 'sort', 'filter', 'argument') as $key) {
if (!empty($info[$key])) {
foreach (array('title', 'group', 'help') as $string) {
// First, try the lowest possible level
if (!empty($info[$key][$string])) {
$strings[$field][$key][$string] = $info[$key][$string];
}
// Then try the field level
elseif (!empty($info[$string])) {
$strings[$field][$key][$string] = $info[$string];
}
// Finally, try the table level
elseif (!empty($table_data['table'][$string])) {
$strings[$field][$key][$string] = $table_data['table'][$string];
}
else {
$strings[$field][$key][$string] = t("Error: missing @component", array('@component' => $string));
}
}
}
}
}
foreach ($bases as $base_name) {
foreach ($strings as $field => $field_strings) {
foreach ($field_strings as $type_name => $type_strings) {
$fields[$base_name][$type_name]["$table.$field"] = t('@group: @field<div class="description">@help</div>', array('@group' => $type_strings['group'], '@field' => $type_strings['title'], '@help' => $type_strings['help']));
}
}
}
}
// vsm('Views UI data build time: ' . (microtime() - $start) * 1000 . ' ms');
}
if (isset($fields[$base][$type])) {
asort($fields[$base][$type]);
return $fields[$base][$type];
}
return array();
}
// -----------------------------------------------------------------------
// Views plugin functions
......@@ -379,7 +446,7 @@ function views_get_plugin($type, $plugin) {
* @return
* A keyed array of in the form of 'base_table' => 'Description'.
*/
function views_fetch_plugin_names($type) {
function views_fetch_plugin_names($type, $key = NULL, $empty = FALSE) {
static $plugins = array();
if (empty($plugins)) {
$data = views_fetch_plugin_data();
......@@ -390,10 +457,15 @@ function views_fetch_plugin_names($type) {
continue;
}
foreach ($plugs as $id => $plugin) {
// Skip plugins that don't conform to our key.
if ($key && (($empty && empty($plugin[$key])) || (!$empty && !empty($plugin[$key])))) {
continue;
}
if (empty($plugin['no ui'])) {
$plugins[$plugin_type][$id] = $plugin['title'];
}
}
asort($plugins[$plugin_type]);
}
}
......@@ -500,7 +572,7 @@ function views_discover_default_views() {
* @endcode
*/
function views_get_page_views() {
return views_get_applicable_views('uses_hook_menu');
return views_get_applicable_views('uses hook menu');
}
/**
......@@ -518,7 +590,7 @@ function views_get_page_views() {
* @endcode
*/
function views_get_block_views() {
return views_get_applicable_views('uses_hook_block');
return views_get_applicable_views('uses hook block');
}
/**
......@@ -612,3 +684,28 @@ class views_object {
}
}
}
/**
* Provide debug output for Views. This relies on devel.module
*/
function views_debug($message) {
if (module_exists('devel')) {
drupal_set_content('footer', dpr($message, TRUE));
}
}
/**
* Shortcut to views_debug()
*/
function vpr($message) {
views_debug($message);
}
/**
* Debug messages
*/
function vsm($message) {
if (module_exists('devel')) {
dsm($message);
}
}
\ No newline at end of file
......@@ -81,6 +81,10 @@ function views_ui_menu() {
'page callback' => 'views_ui_rearrange_section',
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/add-item/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_add_item',
'page arguments' => array(3, 5),
);
// display specific parameters
$items['admin/build/views/%views_ui_js/display/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_edit_display',
......@@ -152,5 +156,14 @@ function views_ui_js_load($js) {
function views_ui_cache_set($view) {
views_include('cache');
$view->changed = TRUE; // let any future object know that this view has changed.
// Unset handlers; we don't want to write these into the cache
unset($view->display_handler);
unset($view->current_display);
unset($view->default_display);
foreach (array_keys($view->display) as $id) {
unset($view->display[$id]->handler);
unset($view->display[$id]->default_display);
}
views_object_cache_set('view', $view->name, $view);
}
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