Commit f1ccc180 authored by merlinofchaos's avatar merlinofchaos

Assorted code and @todo cleanup

parent d6eb26c3
......@@ -114,9 +114,10 @@ function hook_views_query_substitutions() {
* This must either be in the same directory as the .module file or in a subdirectory
* named 'includes'.
*
* @todo -- this hook is not yet implemented
* Adding output to the view cam be accomplished by placing text on
* $view->attachment_before and $view->attachment_after
*/
function hook_views_pre_view() {
function hook_views_pre_view(&$view, &$display_id, &$args) {
// example code here
}
......@@ -127,9 +128,8 @@ function hook_views_pre_view() {
* This must either be in the same directory as the .module file or in a subdirectory
* named 'includes'.
*
* @todo -- this hook is not yet implemented
*/
function hook_views_post_view() {
function hook_views_query_alter(&$view, &$query) {
// example code here
}
......
......@@ -935,7 +935,7 @@ class views_handler_argument_many_to_one extends views_handler_argument {
function title() {
if (!$this->argument) {
return t('Uncategorized');
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized');
}
if (!empty($this->options['break_phrase'])) {
......@@ -949,11 +949,11 @@ class views_handler_argument_many_to_one extends views_handler_argument {
// @todo -- both of these should check definition for alternate keywords.
if (empty($this->value)) {
return t('Uncategorized');
return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized');
}
if ($this->value === array(-1)) {
return t('Invalid input');
return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : t('Invalid input');
}
return implode($this->operator == 'or' ? ' + ' : ', ', $this->title_query());
......
......@@ -129,7 +129,6 @@ function views1_import($imported) {
$view->name = $imported->name;
$view->description = $imported->description;
$view->view_php = $imported->view_args_php;
if (!empty($imported->page)) {
$view->add_display('page');
......
......@@ -228,13 +228,31 @@ class views_handler_filter extends views_handler {
* that are nicely tailored to the given filter.
*/
function expose_form(&$form, &$form_state) {
// @todo we should break this up into two functions to make it easier
// for child objects to put options in the left or right side without
// having to override this whole thing.
$form['expose']['start_left'] = array(
'#value' => '<div class="views-left-50">',
);
$this->expose_form_left($form, $form_state);
$form['expose']['end_left'] = array(
'#value' => '</div>',
);
$form['expose']['start_checkboxes'] = array(
'#value' => '<div class="form-checkboxes views-left-40 clear-block">',
);
$this->expose_form_right($form, $form_state);
$form['expose']['end_checkboxes'] = array(
'#value' => '</div>',
);
}
/**
* Handle the 'left' side fo the exposed options form.
*/
function expose_form_left(&$form, &$form_state) {
if (!empty($form['operator']['#type'])) {
$form['expose']['operator'] = array(
'#type' => 'textfield',
......@@ -264,14 +282,12 @@ class views_handler_filter extends views_handler {
'#title' => t('Label'),
'#size' => 40,
);
}
$form['expose']['end_left'] = array(
'#value' => '</div>',
);
$form['expose']['start_checkboxes'] = array(
'#value' => '<div class="form-checkboxes views-left-40 clear-block">',
);
/**
* Handle the 'right' side fo the exposed options form.
*/
function expose_form_right(&$form, &$form_state) {
$form['expose']['optional'] = array(
'#type' => 'checkbox',
'#title' => t('Optional'),
......@@ -292,9 +308,6 @@ class views_handler_filter extends views_handler {
'#description' => t('Remember the last setting the user gave this filter.'),
'#default_value' => $this->options['expose']['remember'],
);
$form['expose']['end_checkboxes'] = array(
'#value' => '</div>',
);
}
/**
......
......@@ -351,10 +351,6 @@ class views_plugin_display extends views_plugin {
'link_display' => array('link_display'),
'distinct' => array('distinct'),
// @todo
'php_arg_code' => array('php_arg_code'),
'exposed_options' => array('exposed_options'),
// Force these to cascade properly.
'style_plugin' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'),
'style_options' => array('style_plugin', 'style_options', 'row_plugin', 'row_options'),
......@@ -407,8 +403,6 @@ class views_plugin_display extends views_plugin {
'distinct' => TRUE,
'link_display' => TRUE,
'php_arg_code' => TRUE,
'exposed_options' => TRUE,
'style_plugin' => TRUE,
'style_options' => TRUE,
......@@ -1222,7 +1216,6 @@ class views_plugin_display extends views_plugin {
case 'title':
case 'access':
case 'link_display':
case 'php_arg_code':
case 'use_ajax':
$this->set_option($section, $form_state['values'][$section]);
break;
......
......@@ -428,16 +428,6 @@ class view extends views_db_object {
}
}
// Execute the initial PHP code that a view can have.
if (!empty($this->view_args_php)) {
ob_start();
$result = eval($this->view_args_php);
if (is_array($result)) {
$this->args = $result;
}
ob_end_clean();
}
// Attempt to load from cache.
// @todo Load a build_info from cache.
......@@ -523,6 +513,12 @@ class view extends views_db_object {
$this->query->add_field(NULL, "'". $this->name .':'. $this->current_display ."'", 'view_name');
}
// Let modules modify the query just prior to finalizing it.
foreach (module_implements('views_query_alter') as $module) {
$function = $module . '_views_query_alter';
$function($this, $this->query);
}
$this->build_info['query'] = $this->query->query();
$this->build_info['count_query'] = $this->query->query(TRUE);
$this->build_info['query_args'] = $this->query->get_where_args();
......@@ -658,6 +654,12 @@ class view extends views_db_object {
}
}
// Let modules modify the view just prior to executing it.
foreach (module_implements('views_pre_view') as $module) {
$function = $module . '_views_pre_view';
$function($this, $display_id, $args);
}
// Prepare the view with the information we have.
$this->set_arguments($args);
......
......@@ -8,7 +8,7 @@
<div class="views-edit-view">
<?php if ($locked): ?>
<div class="view-locked">
<?php print t('This view is locked by user !user, and may not be modified. This lock is !age old. Click here to !break.', array('!user' => $locked, '!age' => $lock_age, '!break' => $break)); ?>
<?php print t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to !break.', array('!user' => $locked, '!age' => $lock_age, '!break' => $break)); ?>
</div>
<?php endif; ?>
<div class="views-basic-info<?php if (!empty($view->changed)) { print " changed"; }?>">
......
......@@ -258,7 +258,7 @@ function views_ui_cache_load($name) {
if (!empty($view)) {
// Check to see if someone else is already editing this view.
global $user;
$view->locked = db_fetch_object(db_query("SELECT s.uid, v.updated FROM {views_object_cache} v INNER JOIN {sessions} s ON v.sid = s.sid WHERE s.uid != %d and v.name = '%s' and v.obj = 'view' ORDER BY v.updated ASC", $user->uid, $view->name));
$view->locked = db_fetch_object(db_query("SELECT s.uid, v.updated FROM {views_object_cache} v INNER JOIN {sessions} s ON v.sid = s.sid WHERE s.sid != '%s' and v.name = '%s' and v.obj = 'view' ORDER BY v.updated ASC", session_id(), $view->name));
}
}
......@@ -271,6 +271,10 @@ function views_ui_cache_load($name) {
}
}
function views_ui_check_lock($view) {
}
/**
* Specialized cache function to add a flag to our view, include an appropriate
* include, and cache more easily.
......
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