function clientsQuery::execute in Web Service Clients 6
Same name and namespace in other branches
- 7 clients/clients_views/clientsQuery.inc \clientsQuery::execute()
Execute a call
Overrides views_plugin_query_default::execute
File
- clients/
clients_views/ clientsQuery.inc, line 62 - Using devseed extendr module as a base... http://devseed.svn.cvsdude.com/sandbox/drupal-6/extendr/
Class
- clientsQuery
- For now this is an extension of the views_query, I'm not sure if it should remain so.
Code
function execute(&$view) {
$this->args['extras'] = implode(',', $this->args['extras']);
if (!empty($view->pager['items_per_page'])) {
$this->args['per_page'] = $view->pager['items_per_page'];
}
else {
$this->args['per_page'] = 500;
// upper limit?
}
// What page was requested:
$pager_page_array = isset($_GET['page']) ? explode(',', $_GET['page']) : array();
if (!empty($pager_page_array[$view->pager['element']])) {
$page = intval($pager_page_array[$view->pager['element']]);
$this->args['page'] = $page;
}
$resource = clients_resource_load($view->base_table);
// override $resource with $this->args
// pass params back to resource
$args = array();
/**
* matches view argument names ($view->argument) to
* argument input values ($view->args)
*/
foreach (array_keys($view->argument) as $key => $val) {
$args[$val] = $view->args[$key];
}
if ($view->query->pager->options['items_per_page']) {
$args['limit'] = $view->query->pager->options['items_per_page'];
}
if ($view->query->pager->options['offset']) {
$args['offset'] = $view->query->pager->options['offset'];
}
clients_setparams($resource, $args);
$result = clients_call($resource);
$view->result = $result[0]->data;
/**
* Removed a bunch of pager code here - may need to go back in though should probably be handled in clients module
*/
}