Commit 7938bc88 authored by merlinofchaos's avatar merlinofchaos

Minor style and documentation update; schema update

parent 582713d9
......@@ -32,14 +32,31 @@ class views_query {
* or OR.
*/
var $where = array();
/**
* The default operator to use when connecting the WHERE groups. May be
* AND or OR.
*/
var $group_operator = 'AND';
/**
* A simple array of order by clauses.
*/
var $orderby = array();
/**
* A simple array of group by clauses.
*/
var $groupby = array();
var $where_args = array();
/**
* The table header to use for tablesort. This matters because tablesort
* needs to modify the query and needs the header.
*/
var $header = array();
/**
* A flag as to whether or not to make the primary field distinct.
*/
var $distinct = FALSE;
/*
......@@ -75,7 +92,7 @@ class views_query {
}
// ----------------------------------------------------------------
// Utility sets
// Utility methods to set flags and data.
/*
* Set the base field to be distinct.
......@@ -337,13 +354,13 @@ class views_query {
foreach (array_reverse($add) as $table => $join) {
$this->queue_table($table, $relationship, $this->adjust_join($join, $relationship));
}
return true;
return TRUE;
}
// Have we been this way?
if (isset($traced[$join->left_table])) {
// we looped. Broked.
return false;
return FALSE;
}
// Do we have to add this table?
......@@ -608,7 +625,7 @@ class views_query {
* @param $get_count
* Provide a countquery if this is true, otherwise provide a normal query.
*/
function query($get_count = false) {
function query($get_count = FALSE) {
// Check query distinct value.
if (empty($this->no_distinct) && $this->distinct && !empty($this->fields)) {
$this->fields[$this->primary_field]['distinct'] = TRUE;
......
......@@ -14,6 +14,7 @@ class view {
var $field = array();
var $sort = array();
var $filter = array();
var $relationship = array();
var $base_table = 'node';
......@@ -70,6 +71,7 @@ class view {
$this->_load_row('field');
$this->_load_row('sort');
$this->_load_row('filter');
$this->_load_row('relationship');
}
/**
......@@ -100,6 +102,7 @@ class view {
db_query("DELETE from {views_fields} WHERE vid = %d", $this->vid);
db_query("DELETE from {views_sorts} WHERE vid = %d", $this->vid);
db_query("DELETE from {views_filters} WHERE vid = %d", $this->vid);
db_query("DELETE from {views_relationships} WHERE vid = %d", $this->vid);
}
_views_save_query('views_view', $this, !empty($this->vid) ? 'vid' : FALSE);
......@@ -108,6 +111,7 @@ class view {
$this->_save_rows('field');
$this->_save_rows('sort');
$this->_save_rows('filter');
$this->_save_rows('relationship');
cache_clear_all('views_urls', 'cache_views');
cache_clear_all(); // clear the page cache as well.
......@@ -132,6 +136,7 @@ class view {
db_query("DELETE FROM {views_fields} where vid = %d", $view->vid);
db_query("DELETE FROM {views_sorts} where vid = %d", $view->vid);
db_query("DELETE FROM {views_filters} where vid = %d", $view->vid);
db_query("DELETE FROM {views_relationships} where vid = %d", $view->vid);
cache_clear_all('views_query:' . $view->name, 'cache_views');
cache_clear_all(); // In Drupal 5.0 and later this clears the page cache only.
......@@ -210,6 +215,13 @@ class views_display {
var $filters_location = ''; // 'view', 'block'
}
class views_relationship {
var $relationship = '';
var $link = '';
var $position = 0;
}
// build an insert/update query based upon schema info.
function _views_save_query($table, &$object, $update = NULL) {
$schema = drupal_get_schema($table);
......
......@@ -244,6 +244,11 @@ function views_schema() {
'length' => '255',
'description' => t('The name of the field.'),
),
'relationship' => array(
'type' => 'varchar',
'length' => '255',
'description' => t('The relationship this field belongs to.'),
),
'handler' => array(
'type' => 'varchar',
'length' => '255',
......@@ -283,6 +288,11 @@ function views_schema() {
'length' => '255',
'description' => t('The name of the field.'),
),
'relationship' => array(
'type' => 'varchar',
'length' => '255',
'description' => t('The relationship this field belongs to.'),
),
'order' => array(
'type' => 'varchar',
'length' => '4',
......@@ -338,6 +348,11 @@ function views_schema() {
'length' => '255',
'description' => t('The name of the field.'),
),
'relationship' => array(
'type' => 'varchar',
'length' => '255',
'description' => t('The relationship this field belongs to.'),
),
'operator' => array(
'type' => 'varchar',
'length' => '255',
......@@ -369,6 +384,35 @@ function views_schema() {
'indexes' => array('vid' => array('vid', 'position')),
);
$schema['views_relationships'] = array(
'description' => t('Stores information about each filter attached to a view.'),
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => t('The view this display is attached to.'),
),
'position' => array(
'type' => 'int',
'default' => 0,
'description' => t('The order in which this information is loaded.'),
),
'relationship' => array(
'type' => 'varchar',
'length' => '255',
'description' => t('The actual relationship used.'),
),
'link' => array(
'type' => 'varchar',
'length' => '255',
'description' => t('The relationship this links back to.'),
),
),
'indexes' => array('vid' => array('vid', 'position')),
);
// This is unfortunately cut & pasted from system.module since cache has no way of
// telling us what the proper schema is.
$schema['cache_views'] = array(
......
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