function views_xml_backend_plugin_query_xml::execute in Views XML Backend 6
Same name and namespace in other branches
- 7 views_xml_backend_plugin_query_xml.inc \views_xml_backend_plugin_query_xml::execute()
Executes the query and fills the associated view object with according values.
Values to set: $view->result, $view->total_rows, $view->execute_time, $view->pager['current_page'].
$view->result should contain an array of objects.
Parameters
view $view: The view which is executed.
Overrides views_plugin_query::execute
File
- ./
views_xml_backend_plugin_query_xml.inc, line 99 - Query plugin for views_xml_backend.
Class
- views_xml_backend_plugin_query_xml
- @file Query plugin for views_xml_backend.
Code
function execute(&$view) {
$start = microtime(TRUE);
// Avoid notices about $view->execute_time being undefined if the query
// doesn't finish.
$view->execute_time = NULL;
// Make sure that an xml file exists.
// This could happen if you come from the add wizard to the actual views
// edit page.
if (empty($this->options['xml_file'])) {
return FALSE;
}
$data = new stdClass();
try {
$data->contents = $this
->fetch_file($this->options['xml_file']);
} catch (Exception $e) {
drupal_set_message(t('Views XML Backend: ' . $e
->getMessage()), 'error');
return;
}
// Allow other modules to alter the data. Could be used for adding Tidy
// support.
// @todo Document this.
drupal_alter('views_xml_backend_data', $data, $view->name);
// When content is empty, parsing it is pointless.
if (!$data->contents) {
if ($this->options['show_errors']) {
drupal_set_message(t('Views XML Backend: File is empty.'), 'warning');
}
return;
}
$use = $this
->errorStart();
// Go!
$this
->parse($view, $data);
$view->execute_time = microtime(TRUE) - $start;
$this
->errorStop($use, $this->options['show_errors']);
}