diff -urN views_1.1/views.module views 4.7 fused/views.module --- views_1.1/views.module 2006-11-15 17:52:16.000000000 +0100 +++ views 4.7 fused/views.module 2006-11-28 13:57:21.000000000 +0100 @@ -1,6 +1,6 @@ argument) || !empty($view->exposed_filter)) { + if (!empty($view->argument) || !empty($view->exposed_filter) || !empty($view->no_cache)) { return false; } diff -urN views_1.1/views_query.inc views 4.7 fused/views_query.inc --- views_1.1/views_query.inc 2006-11-14 07:52:45.000000000 +0100 +++ views 4.7 fused/views_query.inc 2006-11-28 13:57:21.000000000 +0100 @@ -5,7 +5,7 @@ * This builds a query for the view. */ function _views_build_query(&$view, $args = array()) { - $query = new _views_query(); + $query = new _views_query('node', 'nid', !empty($view->use_alias_prefix) ? $view->use_alias_prefix : ''); // Process static filters _views_view_build_filters($query, $view); @@ -38,12 +38,11 @@ if (!$self_sort) { $sort = true; } - break 2; + break 2; // switch and for case 7: // to trigger empty text, send back an empty query $info['query'] = NULL; return $info; - break 2; // switch and for } } } @@ -91,6 +90,10 @@ foreach($view->exposed_filter as $count => $expose) { if ($filter['id'] == $expose['id']) { $id = $expose['id']; + + if (isset($view->exposed_filter_offset)) { + $count += $view->exposed_filter_offset; + } if (!$expose['operator'] && $_GET["op$count"]) { $filter['operator'] = check_plain($_GET["op$count"]); @@ -130,7 +133,7 @@ else if (is_array($filter['value']) && count($filter['value'])) { if ($filter['operator'] == 'OR' || $filter['operator'] == 'NOR') { $query->ensure_table($table); - $where_args = array_merge(array($table, $field), $filter['value']); + $where_args = array_merge(array($query->use_alias_prefix . $table, $field), $filter['value']); $placeholder = array_fill(0, count($filter['value']), '%s'); if ($filter['operator'] == 'OR') { $query->add_where("%s.%s IN ('". implode("','", $placeholder) ."')", $where_args); @@ -158,7 +161,7 @@ } else { $query->ensure_table("$table"); - $query->add_where("%s.%s %s '%s'", $table, $field, $filter['operator'], $filter['value']); + $query->add_where("%s.%s %s '%s'", $query->use_alias_prefix . $table, $field, $filter['operator'], $filter['value']); } } } @@ -254,9 +257,9 @@ $fieldinfo = $arginfo[$argtype]['handler']('summary', $query, $argtype, $option); if ($fieldinfo['fieldname']) { - $query->add_field("$fieldinfo[field] AS $fieldinfo[fieldname]", ''); + $query->add_field($fieldinfo[field], '', $fieldinfo[fieldname]); } - $query->add_field("count(node.nid) as num_nodes", ''); + $query->add_field('count(node.nid)', '', 'num_nodes'); $query->add_groupby($fieldinfo['field']); $query->set_count_field("DISTINCT($fieldinfo[field])"); if ($self_sort) { @@ -272,20 +275,22 @@ /* * Create the basic query object and fill with default values. */ - function _views_query($views_get_title_table = 'node', $views_get_title_field = 'nid') { + function _views_query($views_get_title_table = 'node', $views_get_title_field = 'nid', $alias_prefix = '') { $this->views_get_title_table = $views_get_title_table; + $this->joins = array(); $this->where = array(); $this->orderby = array(); $this->groupby = array(); $this->tables = array(); $this->where_args = array(); + $this->use_alias_prefix = $alias_prefix; // Joins care about order, so we put our tables in a queue to make sure // the order is correct. $this->tablequeue = array(); if ($views_get_title_field) { - $this->fields = array("$views_get_title_table.$views_get_title_field"); + $this->fields = array($alias_prefix ."$views_get_title_table.$views_get_title_field"); } - $this->count_field = "$views_get_title_table.$views_get_title_field"; + $this->count_field = $alias_prefix ."$views_get_title_table.$views_get_title_field"; $this->header = array(); } @@ -302,10 +307,10 @@ } if ($table) { $this->ensure_table($table); - $table .= "."; + $table = $this->use_alias_prefix . $table ."."; } if ($alias) { - $a = " AS $alias"; + $a = " AS $this->use_alias_prefix$alias"; } if (!in_array("$table$field$a", $this->fields)) { $this->fields[] = "$table$field$a"; @@ -362,7 +367,10 @@ */ function add_orderby($table, $field, $order, $alias = '') { if (!$alias && $table) { - $alias = $table; + $alias = $this->use_alias_prefix . $table; + } + elseif ($alias) { + $alias = $this->use_alias_prefix . $alias; } if ($table) { @@ -374,9 +382,9 @@ } foreach($field as $f) { - $as = $alias . '_' . $f; - $this->add_field($f, $table, $as); - $this->orderby[] = "$as $order"; +// $as = $alias . '_' . $f; +// $this->add_field($f, $table, $as); + $this->orderby[] = "$alias.$f $order"; } } @@ -437,7 +445,7 @@ if ($joininfo) { $this->joins[$table][$i] = $joininfo; } - $this->tablequeue[] = array('table' => $table, 'num' => $i); + $this->tablequeue[] = array('table' => $table, 'num' => $i, 'alias_prefix' => $this->use_alias_prefix); } return $this->tables[$table]; } @@ -453,7 +461,7 @@ else { $this->tables[$table]++; } - $this->tablequeue[] = array('table' => $table, 'num' => $this->tables[$table]); + $this->tablequeue[] = array('table' => $table, 'num' => $this->tables[$table], 'alias_prefix' => $this->use_alias_prefix); } /* @@ -513,9 +521,14 @@ * The name of the table in the global table array. * @param $table_num * The instance number of the table. + * @param $alias_prefix + * An optional prefix for the table alias. */ - function get_table_name($table, $table_num) { - return ($table_num < 2 ? $table : $table . $table_num); + function get_table_name($table, $table_num, $alias_prefix = null) { + if (is_null($alias_prefix)) { + $alias_prefix = $this->use_alias_prefix; + } + return ($table_num < 2 ? $alias_prefix . $table : $alias_prefix . $table . $table_num); } /* @@ -536,15 +549,18 @@ $table_real = (isset($table_data[$table]['name']) ? $table_data[$table]['name'] : $table); $table_num = $tinfo['num']; - $table_alias = $this->get_table_name($table, $table_num); + $table_alias = $this->get_table_name($table, $table_num, $tinfo['alias_prefix']); $joininfo = (!$this->joins[$table][$table_num] ? $table_data[$table]['join'] : $this->joins[$table][$table_num]); + + $left_table_alias = isset($joininfo['left']['alias']) ? $joininfo['left']['alias'] : $tinfo['alias_prefix']; + $left_table_alias .= $joininfo['left']['table']; // the { is a special character which seems to be treated differently // in PHP5 than PHP4 so we do this a little oddly. $join_type = $joininfo['type'] == 'inner' ? 'INNER' : 'LEFT'; - $joins .= " $join_type JOIN {" . $table_real . "} $table_alias ON " . $joininfo['left']['table'] . "." . + $joins .= " $join_type JOIN {" . $table_real . "} $table_alias ON " . $left_table_alias .".". $joininfo['left']['field'] . " = $table_alias." . $joininfo['right']['field']; if (isset($joininfo['extra'])) {