<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>twitter_views.test</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -20,8 +20,8 @@ class twitter_views_plugin_query_twitter extends views_plugin_query {
    * Builds the necessary info to execute the query.
    */
   function build(&amp;$view) {
-    $view-&gt;build_info['query'] = $this-&gt;query();
-    $view-&gt;build_info['count_query'] = $this-&gt;query(TRUE);
+    $view-&gt;build_info['query'] = $this-&gt;query($view);
+    $view-&gt;build_info['count_query'] = $this-&gt;query($view, TRUE);
     $view-&gt;build_info['query_args'] = $this-&gt;get_where_args();
   }
 
@@ -33,64 +33,47 @@ class twitter_views_plugin_query_twitter extends views_plugin_query {
    * $view-&gt;pager['current_page'].
    */
   function execute(&amp;$view) {
-    $query = $this-&gt;query();
+    $query = $view-&gt;build_info['query'];
 
+    if ($query) {
+      $replacements = module_invoke_all('views_query_substitutions', $view);
+      $query = str_replace(array_keys($replacements), $replacements, $query);
 
-    // TODO This has to live somewhere else, f.e. in function query();
-    $params = array();
-    if (!empty($view-&gt;pager['items_per_page'])) {
-      $params['rpp'] = $view-&gt;pager['items_per_page'] &lt;= 100 ? $view-&gt;pager['items_per_page'] : 100;
-    }
-    $params['q'] = $query;
 
-    // Build the rest of the code.
-    $items = array();
-    if ($params) {
-      foreach ($params as $key =&gt; $value) {
-        if ($key == 'q') {
-          array_unshift($items, 'q='. urlencode($value));
-        }
-        else {
-          $items[] = urlencode($key .'='. $value);
-        }
-      }
-    }
-    $params = implode('&amp;', $items);
+      $url = $this-&gt;api_url .'?'. $query;
+      dsm($url);
 
-    $url = $this-&gt;api_url .'?'. $params;
-    dvm($url);
+      $start = views_microtime();
 
-    $start = views_microtime();
+      $results = drupal_http_request($url, array(), 'GET');
 
-    $results = drupal_http_request($url, array(), 'GET');
+      if (_twitter_request_failure($results)) {
+        return FALSE;
+      }
 
-    if (_twitter_request_failure($results)) {
-      return FALSE;
-    }
-    
-    $results = json_decode($results-&gt;data, TRUE);
+      $results = json_decode($results-&gt;data, TRUE);
 
-    if ($results['results']) {
-      $view-&gt;result = $results['results'];
+      if ($results['results']) {
+        $view-&gt;result = $results['results'];
 
-      // $this-&gt;results are arrays.
-      foreach ($view-&gt;result as $key =&gt; $value) {
-        $view-&gt;result[$key] = (object) $value;
-      }
+        // $this-&gt;results are arrays.
+        foreach ($view-&gt;result as $key =&gt; $value) {
+          $view-&gt;result[$key] = (object) $value;
+        }
 
-      // Save the metadata into the object
-      unset($results['results']);
-      foreach ($results as $key =&gt; $value) {
-        $this-&gt;$key = $value;
-      }
-      
-      $this-&gt;execute_time = $this-&gt;completed_in;
+        // Save the metadata into the object
+        unset($results['results']);
+        foreach ($results as $key =&gt; $value) {
+          $this-&gt;$key = $value;
+        }
 
-      // FIXME
-      $this-&gt;total_rows = $this-&gt;results_per_page * 2;
-      $this-&gt;pager['current_page'] = $this-&gt;page -1;
+        $this-&gt;execute_time = $this-&gt;completed_in;
+
+        // FIXME
+        $this-&gt;total_rows = $this-&gt;results_per_page * 2;
+        $this-&gt;pager['current_page'] = $this-&gt;page -1;
+      }
     }
-//     dsm($view-&gt;result);
 
     $view-&gt;execute_time = views_microtime() - $start;
   }
@@ -103,12 +86,33 @@ class twitter_views_plugin_query_twitter extends views_plugin_query {
    * @param $get_count
    *   Provide a countquery if this is true, otherwise provide a normal query.
    */
-  function query($get_count = FALSE) {
+  function query($view, $get_count = FALSE) {
 
     $where = $this-&gt;condition_query();
-    return $where;
+
+    $params = array();
+    if (!empty($view-&gt;pager['items_per_page'])) {
+      $params['rpp'] = $view-&gt;pager['items_per_page'] &lt;= 100 ? $view-&gt;pager['items_per_page'] : 100;
+    }
+    $params['q'] = $where;
+
+    // Build the rest of the code.
+    $items = array();
+    if ($params) {
+      foreach ($params as $key =&gt; $value) {
+        if ($key == 'q') {
+          array_unshift($items, 'q='. urlencode($value));
+        }
+        else {
+          $items[] = urlencode($key .'='. $value);
+        }
+      }
+    }
+    $params = implode('&amp;', $items);
+
+    return $params;
   }
-  
+
   /**
    * Construct the &quot;WHERE&quot; or &quot;HAVING&quot; part of the query.
    *</diff>
      <filename>twitter_views_plugin_query_twitter.inc</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>80e33088e8d072d9089802d644582220a3ba0fe8</id>
    </parent>
  </parents>
  <author>
    <name>Daniel Wehner</name>
    <email>daniel.wehner@erdfisch.de</email>
  </author>
  <url>http://github.com/dereine/twitter_views/commit/69a90ea4dd90f9af9e54bf3a2ca1bc040566dab1</url>
  <id>69a90ea4dd90f9af9e54bf3a2ca1bc040566dab1</id>
  <committed-date>2009-10-31T17:23:30-07:00</committed-date>
  <authored-date>2009-10-31T17:23:30-07:00</authored-date>
  <message>added test file some refactoring</message>
  <tree>21fe7b6f3d996dddf0ba9c2afb6f20e9d503bd3f</tree>
  <committer>
    <name>Daniel Wehner</name>
    <email>daniel.wehner@erdfisch.de</email>
  </committer>
</commit>
