diff --git a/includes/handlers.inc b/includes/handlers.inc index 616acda..584c68e 100644 --- a/includes/handlers.inc +++ b/includes/handlers.inc @@ -1295,6 +1295,11 @@ class views_join { } $output = " $this->type JOIN $right_table $table[alias] ON $left_field = $table[alias].$this->field"; + + // Load query tokens replacements. + $replacements = module_invoke_all('views_query_substitutions', $this); + // Tack on the extra. if (isset($this->extra)) { if (is_array($this->extra)) { @@ -1311,6 +1316,9 @@ class views_join { $join_table = $info['table'] . '.'; } + // Apply query token replacements. + $info['value'] = str_replace(array_keys($replacements), $replacements, $info['value']); + // And now deal with the value and the operator. Set $q to // a single-quote for non-numeric values and the // empty-string for numeric values, then wrap all values in $q. diff --git a/includes/view.inc b/includes/view.inc index 9c29efe..c58b43f 100644 --- a/includes/view.inc +++ b/includes/view.inc @@ -59,6 +59,11 @@ class view extends views_db_object { var $current_display; /** + * Stores all the views substitutions. + */ + var $substitutions = array(); + + /** * Constructor */ function view() { @@ -395,6 +400,16 @@ class view extends views_db_object { } /** + * Get's all the substitutions and store them. + */ + function substitutions($reset = FALSE) { + if ($reset || empty($this->substitutions)) { + $this->substitutions = module_invoke_all('views_query_substitutions', $this); + } + return $this->substitutions; + } + + /** * Attach all of the handlers for each type. * * @param $key @@ -764,7 +779,7 @@ class view extends views_db_object { else { $items = array(); if ($query) { - $replacements = module_invoke_all('views_query_substitutions', $this); + $replacements = $this->substitutions(); $query = str_replace(array_keys($replacements), $replacements, $query); $count_query = 'SELECT COUNT(*) FROM (' . str_replace(array_keys($replacements), $replacements, $count_query) . ') count_alias';