Commit 603de193 authored by metzlerd's avatar metzlerd
Browse files

Partial Debug of forena.

parent af7092a4
......@@ -70,7 +70,7 @@ class FrxDataProvider{
$temp = array_merge($tokens, $clause_tokens);
//check for duplicates in block tokens
if ($clause_tokens) foreach ($clause_tokens as $ct) {
if (!$temp[$ct]) {
if (!isset($temp[$ct])) {
array_push($tokens, $ct);
}
}
......
......@@ -213,7 +213,7 @@ class FrxReport {
$path = 'frx:field[@id="' . $key . '"]';
$formatters = $this->fields->xpath($path);
if ($formatters) foreach ($formatters as $formatter) {
if (((string)$formatter['block'] == $this->block) || (!(string)$formatter['block'])) {
if ((isset($formatter['block']) &&(string)$formatter['block'] == $this->block) || (!(string)$formatter['block'])) {
//@TODO: Replace the default extraction with something that will get sub elements of the string
$default = (string)$formatter;
......@@ -237,7 +237,8 @@ class FrxReport {
if ($link) {
$link = $this->teng->replace($link, $data, TRUE);
list($url, $query) = explode('?', $link);
@list($url, $query) = explode('?', $link);
drupal_set_message($url);
$value = l(htmlspecialchars_decode($value), $url, array('query' => $query, 'attributes' => array('target' => $target)));
}
return $value;
......
......@@ -108,7 +108,7 @@ class FrxSyntaxEngine {
if (is_array($data)) {
$retvar = $data[$key];
$retvar = @$data[$key];
}
elseif (is_object($data)) {
......
......@@ -186,7 +186,7 @@ function forena_delete_report($report_name) {
$do = unlink($info['basename']);
if ($do) {
db_delete('forenea_reports')
->condition('report_name',$report_name)
->condition('report_name', $report_name)
->execute();
}
else {
......@@ -246,14 +246,14 @@ function forena_db_sync($subdir='') {
}
function forena_filter_element($fmt) {
global $user;
$element['format'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Input formats'),
);
// Get a list of formats that the current user has access to.
global $user;
$element['format'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Input formats'),
);
// Get a list of formats that the current user has access to.
$formats = filter_formats($user);
foreach ($formats as $format) {
$options[$format->format] = $format->name;
......@@ -280,7 +280,7 @@ function forena_filter_element($fmt) {
'#attributes' => array('class' => array('filter-help')),
'#weight' => 11,
);
return $element['format'];
return $element['format'];
}
/**
......@@ -353,12 +353,12 @@ function forena_settings_submit($form, &$form_state) {
}
$save_count = forena_db_sync();
drupal_set_message(t(' Imported %s forms into the database', array('%s' => $save_count)));
drupal_set_message(t('Imported %s forms into the database', array('%s' => $save_count)));
menu_cache_clear();
}
function forenea_general_form($form_state, $new_report='') {
function forenea_general_form($formid, $form_state, $new_report='') {
$desc = forena_report_desc();
$name = $desc['name'];
$add_new_rpt;
......@@ -377,35 +377,44 @@ function forenea_general_form($form_state, $new_report='') {
* @param $form_state
* @return the form
*/
function forena_layout_form($form_state, $new_report='') {
function forena_layout_form($formid, $form_state, $new_report='') {
$desc = forena_report_desc();
$name = $desc['name'];
$add_new_rpt;
//determine if this is an add new report request
if ($new_report == 'add') {
if ($new_report) {
$add_new_rpt = TRUE;
}
else $add_new_rpt = FALSE;
$filename = $desc['filename'];
$format = @$desc['format'];
//drupal_set_message("name: ". $name);
if ($name) {
if ($desc['exists'] || $add_new_rpt) {
if ((isset($desc['exists']) && $desc['exists']) || $add_new_rpt) {
//set the name to empty string for new reports
if ($add_new_rpt) $name = '';
$r = forena_get_report($name);
drupal_set_title($r->title);
$form = array();
$title = (string)$r->title;
// Get the attributes to save them away
if ($r) $attributes = $r->get_attributes_by_id();
if ($add_new_rpt) {
$title = '';
$options = '';
$attributes ='';
$frx_options = array('form' => '');
$category='';
$head = '';
$body = '';
}
else {
$title = (string)$r->title;
drupal_set_title(filter_xss($r->title));
$frx_options = isset($r->options) ? $r->options : array('form' => '');
$attributes = isset($r->attributes) ? $r->get_attributes_by_id(): '';
$category = isset($r->category) ? (string)$r->category : '' ;
$body = isset($r->body) ? $r->body->asXML() : '';
$head = isset($r->rpt_xml) ? $r->rpt_xml->head : '';
}
$form = array();
if ($r) $frx_options = $r->options;
$category = (string)$r->category;
if ($r) $body = $r->body->asXML();
//array of xml attributes that are required to have a value
$required = array('id' => TRUE, 'label' => TRUE);
......@@ -420,7 +429,7 @@ function forena_layout_form($form_state, $new_report='') {
$form['head'] = array(
'#type' => 'value',
'#value' => $r->rpt_xml->head,
'#value' => $head,
);
$form['attributes'] = array(
......@@ -490,7 +499,7 @@ function forena_layout_form($form_state, $new_report='') {
foreach ($doclist as $key => $value) {
if (is_object(forena_get_doctypes($value))) {
$options[$value] = strtoupper($value);
if ($r) $doc = $r->rpt_xml->head->xpath('frx:docgen/frx:doc[@type="' . $value . '"]');
$doc = isset($r) ? $r->rpt_xml->head->xpath('frx:docgen/frx:doc[@type="' . $value . '"]') : '';
if ($doc && $doclist[$value]) {
$default[$value] = $value;
}
......@@ -567,6 +576,7 @@ function forena_layout_form_validate($form, &$form_state) {
* submits it to forena_save_report.
*/
function forena_layout_form_submit($form, &$form_state) {
$nodes = array();
$values = $form_state['values'];
$report_name = $values['report_name'];
......@@ -585,7 +595,7 @@ function forena_layout_form_submit($form, &$form_state) {
$xml .= '/>' . "\n";
$xml .= ' <frx:parameters>' . "\n";
if ($h) $parms = $h->xpath('//frx:parm');
$parms = $h ? $h->xpath('//frx:parm') : array();
if ($parms) foreach ($parms as $parm) {
$xml .= ' ' . $parm[0]->asXML() . "\n";
}
......@@ -669,7 +679,7 @@ function forena_doc_formats_settings() {
* @param $form_state
* @return a form to edit the fields of the report
*/
function forena_fields_form($form_state) {
function forena_fields_form($formid, $form_state) {
$desc = forena_report_desc();
$name = $desc['name'];
$filename = $desc['filename'];
......@@ -850,7 +860,7 @@ function forena_fields_form_submit($form, &$form_state) {
* @param unknown_type $form_state
* @return unknown_type
*/
function forena_data_block_form($form_state) {
function forena_data_block_form($formid, $form_state) {
$desc = forena_report_desc();
$name = $desc['name'];
$filename = $desc['filename'];
......@@ -1316,7 +1326,7 @@ function forena_xmlpp($xml, $html_output=FALSE) {
return ($html_output) ? htmlentities($xml) : $xml;
}
function forena_admin_params_form($form_state) {
function forena_admin_params_form($formid, $form_state) {
$desc = forena_report_desc();
$name = $desc['name'];
......@@ -1466,9 +1476,10 @@ function forena_admin_params_form_submit($form, &$form_state) {
* @return An array containing all matching categories
*/
function forena_get_categories($string='') {
$result = db_query("SELECT * FROM {forena_reports} where hidden=0 AND category LIKE '%%%s%%' ORDER BY category, title asc", $string);
$result = db_query("SELECT * FROM {forena_reports} where hidden=0 AND category LIKE :category ORDER BY category, title asc",
array(':category' => $string . '%'));
$categories = array();
while ($row = db_fetch_object($result)) {
foreach ($result as $row) {
$access = TRUE;
$cache = $row->cache;
......
......@@ -123,6 +123,8 @@ function forena_report($name_in, $parms = array()) {
$name = $desc['name'];
$format = isset($desc['format']) ? $desc['format'] : '';
$filename = $desc['filename'];
$css_files = array();
// Determine the data to get.
if (!$parms) $parms = $_GET; else $parms = (array)$parms;
unset($parms['q']);
......@@ -136,13 +138,13 @@ function forena_report($name_in, $parms = array()) {
if ($r_params) {
//put default parameters in parms array
foreach ($r_params as $key => $parm) {
if (!$parms[$key] && $parm['value']) {
if (@!$parms[$key] && @$parm['value']) {
$parms[$key] = $parm['value'];
$reload_params = TRUE;
}
//do not show report if a required parameter does not have a value
//force the user to input a parameter
if ((!$parms[$key]) && (strcmp($parm['require'], "1") == 0) && (!$parm['value'])) {
if ((@!$parms[$key]) && (@strcmp($parm['require'], "1") == 0) && (!$parm['value'])) {
$missing_parms = TRUE;
}
}
......@@ -187,7 +189,7 @@ function forena_report($name_in, $parms = array()) {
if ($r_parms) $output = drupal_get_form('forena_parameters_form') . $output;
//set the title
$title = $r->title;
drupal_set_title($title);
drupal_set_title(filter_xss($title));
//Creating links for downloadable documents.
//build querystring for document href
$q='';
......@@ -271,15 +273,19 @@ function __forena_load_repository(&$repo) {
* @return object The data provider object
*/
function __forena_load_provider($conf, $repo_path) {
@$name = isset($conf['data provider'])? $conf['data_provider'] : $conf['data_engine'];
@$name = isset($conf['data provider'])? $conf['data provider'] : $conf['data_engine'];
forena_define_plugins();
// Instantiate the path
//drupal_set_message("conf: <pre>". print_r($conf, 1) ."</pre> repo_path: <pre>". print_r($repo_path,1) ."</pre>");
if (class_exists($name)) {
$o = new $name($conf, $repo_path);
return $o;
}
else {
drupal_set_message(t('Data provider %s not found', array('%s' => $name)) , 'error');
}
}
......@@ -399,7 +405,6 @@ function forena_invoke_data_provider($data_block, $parameters=array(), $clause='
list($provider, $block) = explode('/', $data_block, 2);
// Get the data
$repos = forena_repository($provider);
if (isset($repos['user callback'])) {
$user_fn = $repos['user callback'];
if (is_callable($user_fn)) $parameters['current_user'] = $user_fn();
......@@ -516,6 +521,7 @@ function forena_get_report($report_name, $data=array()) {
forena_save_report($report_name, $r_text, FALSE);
}
}
return $r;
}
}
......@@ -798,7 +804,7 @@ function forena_parameters_form($form_state) {
$data_source = (string)$node['data_source'];
$data_field = (string)$node['data_field'];
$type = (string)$node['type'];
$value = ($parms[$id]) ? $parms[$id] : (string)$node['value'];
$value = (isset($parms[$id])) ? $parms[$id] : (string)$node['value'];
$desc = (string)$node['desc'];
$label_field = (string)$node['label_field'];
......
......@@ -139,7 +139,7 @@ function forena_menu() {
* Implementation of hook_block_info
*/
function forena_block_info() {
$blocks['forena_reports'] = array('info' => t('My reports'),
$blocks['forena_reports'] = array('info' => t('My reports'),
'status' => 1,
'region' => 'sidebar_first',
'visibility' => 1,
......@@ -172,7 +172,7 @@ function forena_block_view($delta = 0) {
function forena_categories_autocomplete($string='') {
require_once('forena.admin.inc');
$categories = forena_get_categories($string);
print drupal_json($categories);
print drupal_json_output($categories);
}
......@@ -195,7 +195,7 @@ function forena_data_block_autocomplete($string='') {
$data_blocks = array();
}
print drupal_json($data_blocks);
print drupal_json_output($data_blocks);
}
/**
......@@ -210,7 +210,7 @@ function forena_fields_format_autocomplete($string='') {
if ($string == "*") {
$matches = $formats;
print drupal_json($matches);
print drupal_json_output($matches);
return;
}
......@@ -219,7 +219,7 @@ function forena_fields_format_autocomplete($string='') {
$matches[$name] = $value;
}
}
print drupal_json($matches);
print drupal_json_output($matches);
}
/**
* Calls forena_layout_form
......@@ -246,7 +246,7 @@ function forena_admin_params() {
*/
function forena_add_report($new_report) {
require_once('forena.admin.inc');
return drupal_get_form('forena_layout_form', $new_report);
return drupal_get_form('forena_layout_form', TRUE);
}
/**
......@@ -423,12 +423,12 @@ function forena_current_user_name() {
*/
function forena_filter_info() {
$filters['forena_report'] = array(
'title' => t('Embed Forena Reports'),
'description' => t('Allows you to embed a report in a text'),
'process_callback' => '_forena_filter_process',
'cache' => FALSE,
);
$filters['forena_report'] = array(
'title' => t('Embed Forena Reports'),
'description' => t('Allows you to embed a report in a text'),
'process_callback' => '_forena_filter_process',
'cache' => FALSE,
);
return $filters;
}
......
......@@ -46,7 +46,7 @@ class FrxDrupal extends FrxDataProvider {
$rs = db_query($sql);
$xml = new SimpleXMLElement('<table/>');
while ($data = db_fetch_object($rs)) {
foreach ($rs as $data) {
$row_node = $xml->addChild('row');
foreach ($data as $key => $value) {
......@@ -70,7 +70,10 @@ class FrxDrupal extends FrxDataProvider {
* @param unknown_type $data
*/
public function format($value, $key, $data) {
$value = "'" . db_escape_string($value) . "'";
$db = Database::getConnection('default');
if ($db) {
if ($value=='') $value = 'NULL'; else $value = $db -> quote($value);
}
return $value;
}
......
Supports Markdown
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