diff --git a/includes/handlers.inc b/includes/handlers.inc index 9bcba88..dcde53a 100644 --- a/includes/handlers.inc +++ b/includes/handlers.inc @@ -1619,6 +1619,8 @@ class views_join { } $output = " $this->type JOIN $right_table $table[alias] ON $left_field = $table[alias].$this->field"; + // Load query tokens replacements. + $replacements = $this->view->substitutions(); // Tack on the extra. if (isset($this->extra)) { @@ -1636,6 +1638,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 4fd5f9b..068a101 100644 --- a/includes/view.inc +++ b/includes/view.inc @@ -91,6 +91,11 @@ class view extends views_db_object { var $override_path = NULL; /** + * Stores all the views substitutions. + */ + var $substitutions = array(); + + /** * Constructor */ function __construct() { @@ -452,6 +457,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 diff --git a/plugins/views_plugin_query_default.inc b/plugins/views_plugin_query_default.inc index f029571..89e6cbe 100644 --- a/plugins/views_plugin_query_default.inc +++ b/plugins/views_plugin_query_default.inc @@ -1118,7 +1118,7 @@ class views_plugin_query_default extends views_plugin_query{ $items = array(); if ($query) { - $replacements = module_invoke_all('views_query_substitutions', $view); + $replacements = $this->view->substitutions(); $query = str_replace(array_keys($replacements), $replacements, $query); $count_query = 'SELECT COUNT(*) FROM (' . str_replace(array_keys($replacements), $replacements, $count_query) . ') count_alias';