Commit dc76b334 authored by metzlerd's avatar metzlerd
Browse files

Fix PHP Datblock queries.

parent 952fa57a
......@@ -121,7 +121,10 @@ class FrxDataSource{
if (method_exists($o, 'tokens' )) {
$block['tokens'] = $o->tokens();
}
else {
elseif (isset($o->tokens)) {
$block['tokens'] = $o->tokens;
}
else{
$block['tokens'] = array();
}
}
......@@ -381,7 +384,7 @@ class FrxDataSource{
return $xml;
}
public function phpData($o, $method, $parameters = array()) {
public function phpData($o, $method, $parameters) {
$data = NULL;
if (is_object($o) && is_callable(array($o, $method))) {
$data = $o->$method($parameters);
......
......@@ -2074,7 +2074,7 @@ function forena_user_data_blocks($search) {
}
}
}
asort($user_blocks);
if ($user_blocks) asort($user_blocks);
return $user_blocks;
}
......
......@@ -329,7 +329,7 @@ function forena_block_view($delta = 0) {
function forena_categories_autocomplete($string='') {
require_once('forena.admin.inc');
$categories = forena_get_categories($string);
$categories = @forena_get_categories($string);
print drupal_json_output($categories);
}
......@@ -380,7 +380,7 @@ function forena_reports_autocomplete($string='', $string2='') {
if ($callback) foreach ($args as $arg) {
$access = FALSE;
if (function_exists($callback)) {
$a = $callback($arg);
$a = @$callback($arg);
}
if ($a) $access = TRUE;
}
......@@ -416,7 +416,7 @@ function forena_xml($block_name, $parms=array()) {
function forena_fields_format_autocomplete($string='') {
require_once('forena.common.inc');
$matches = array();
$formats = FrxReportGenerator::instance()->supported_formats();
$formats = @FrxReportGenerator::instance()->supported_formats();
if ($string == "*") {
$matches = $formats;
......
......@@ -143,7 +143,6 @@ function forena_query_builder_form($formid, &$form_state) {
}
if (@$block['tokens']) {
$form['parameters'] = array(
'#title' => 'Parameters',
......@@ -257,6 +256,7 @@ function forena_query_preview($form, &$form_state) {
$data = Frx::RepoMan()->sqlData($provider, $sql, $parms);
}
else {
Frx::Data()->push($parms, 'parm');
$block_name = $form_state['storage']['block_name'];
$data = Frx::RepoMan()->data($block_name);
}
......@@ -265,16 +265,27 @@ function forena_query_preview($form, &$form_state) {
if ($data && $t) {
$t->generate($data, $config);
$fields = $t->columns;
$form_state['storage']['fields'] = array_combine($fields, $fields);
$report = $t->asXML();
$rpt = new FrxReport($report, $data);
$form_state['storage']['preview'] = $rpt->render('web');
if ($fields) $fields = array_combine($fields, $fields);
$form_state['storage']['fields'] = $fields;
if ($fields) {
$report = $t->asXML();
$rpt = new FrxReport($report, $data);
$preview = $rpt->render('web');
}
else {
if (is_object($data) && method_exists($data, 'asXML')) {
$preview = '<pre>' . htmlspecialchars($data->asXML()) . '</pre>';
}
else {
$preview = '<pre>' .htmlspecialchars(print_r($data,1)) .'</pre>';
}
}
$form_state['storage']['preview'] = $preview;
}
else {
$form_state['storage']['preview'] = '';
}
if (is_object($data)) $data = $data->asXML();
}
......@@ -418,13 +429,15 @@ function _forena_query_filter_ctl(&$data, &$ctl, $fields) {
*/
function forena_query_update($form, &$form_state) {
$form_state['rebuild'] = TRUE;
switch ($form_state['storage']['step']) {
case 'sql':
forena_query_update_sql($form, $form_state);
break;
case 'builder':
forena_query_update_builder($form, $form_state);
break;
if ($form_state['storage']['block']['type']=='sql') {
switch ($form_state['storage']['step']) {
case 'sql':
forena_query_update_sql($form, $form_state);
break;
case 'builder':
forena_query_update_builder($form, $form_state);
break;
}
}
}
......
......@@ -2,6 +2,7 @@
class FrxDrupalNode {
public $access = 'access content';
public $tokens = array('nid', 'vid');
public function load($parms = array()) {
GLOBAL $language;
......@@ -10,8 +11,8 @@ class FrxDrupalNode {
$vid = isset($parms['vid']) ? $parms['vid']: NULL;
$data = node_load($nid, $vid);
$lang = isset($data->language) ? $data->language : $language->language;
foreach ($data as $key => $val) {
if ($data) foreach ($data as $key => $val) {
if(is_array($val) && isset($val[$lang])) {
$tmp = $val[$lang][0];
$child = $node->addChild($key, $tmp['value']);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment