Commit bbd08f2d authored by metzlerd's avatar metzlerd
Browse files

Refactor location of context value gets.

parent 82c7f563
......@@ -210,7 +210,7 @@ class Frx {
}
/**
* Facotry for SQL Query builder object
* Factory for SQL Query builder object
* @param $new Boolean value that forces a new object
* @return FrxSQLQueryBuilder
*/
......@@ -223,4 +223,15 @@ class Frx {
return $o;
}
public static function Context($context) {
$o = NULL;
if ($context) {
}
if (!$o) {
$o = Frx::Data();
}
return $o;
}
}
\ No newline at end of file
......@@ -9,7 +9,8 @@
* The static instance function of this object acts as a factory method that allows other code in forena to always be able to operate on the current context of the class.
* @var unknown_type
*/
class FrxData {
require_once('FrxContext.inc');
class FrxData extends FrxContext {
public $id;
private $cur_context; // The data of the xml;
......@@ -62,21 +63,14 @@ class FrxData {
* @param $key
* @return unknown_type
*/
public function getValue($key, $formatter = NULL) {
public function getValue($key, $context = '') {
$retvar = '';
// Default to theo current context
$data = $this->currentContext();
// Determine if we have a . syntax for the id.
$raw_key=$key;
if ($key && strpos($key, '.')) {
@list($id, $path) = explode('.', $key, 2);
if ($this->contextExists($id)) {
$data = $this->getContext($id);
$key = $path;
}
if ($context && $this->contextExists($context)) {
$data = $this->getContext($context);
}
if (is_array($data)) {
$retvar = @$data[$key];
}
......@@ -111,11 +105,6 @@ class FrxData {
}
}
if (is_object($formatter) && method_exists($formatter, 'format')) {
$retvar = $formatter->format($retvar, $key, $data);
}
if (!is_array($retvar)) $retvar = trim((string)$retvar);
return $retvar;
}
......@@ -125,7 +114,7 @@ class FrxData {
* @param String $key
* @param String $value
*/
public function setValue($key, $value) {
public function setValue($key, $value, $context='') {
if (is_array($this->cur_context)) {
$this->cur_context[$key] = $value;
}
......
......@@ -20,7 +20,7 @@ class FrxFields {
* Formatter used by the syntax engine to alter data that gets extracted.
* This invokes the field translation
*/
public function format($value, $key, $data) {
public function format($value, $key) {
// Determine if there is a field overide entry
$default='';
$link ='';
......
......@@ -365,7 +365,7 @@ class FrxReport {
* Formatter used by the syntax engine to alter data that gets extracted.
* This invokes the field translation
*/
public function format($value, $key, $data) {
public function format($value, $key) {
// Determine if there is a field overide entry
$default='';
$link ='';
......
......@@ -56,11 +56,18 @@ class FrxSyntaxEngine {
* @return unknown_type
*/
protected function get_value( $key, $raw=FALSE) {
$f=NULL;
if (!$raw) $f = $this->formatter;
$retvar = Frx::Data()->getValue($key, $f );
return $retvar;
$context = '';
if ($key && strpos($key, '.')) {
@list($key, $path) = explode('.', $key, 2);
$o = Frx::Context($context);
}
else {
$o = Frx::Data();
}
$value = $o->getValue($key, $context);
if (!$raw && $this->formatter)
$value = trim($this->formatter->format($value, $key));
return $value;
}
......
......@@ -948,24 +948,43 @@ function forena_render_report($report, $format='', $data='', $options= array(),
*
*/
function forena_forena_plugins() {
$path = drupal_get_path('module', 'forena');
$plugins[] = array('file' => 'plugins/FrxPDO.inc',
'parent' => 'FrxDataSource',
'class' => 'FrxPDO',
'path' => $path,
);
$plugins[] = array('file' => 'plugins/FrxOracle.inc',
'parent' => 'FrxDataSource',
'class' => 'FrxOracle',
'path' => $path,
);
$plugins[] = array('file' => 'plugins/FrxDrupal.inc',
$plugins[] = array(
'file' => 'plugins/FrxDrupal.inc',
'parent' => 'FrxDataSource',
'class' => 'FrxDrupal',
'path' => $path,
);
$plugins[] = array('file' => 'plugins/FrxFiles.inc',
'parent' => 'FrxDataSource',
'class' => 'FrxFiles',
);
$plugins[] = array('file' => 'plugins/FrxPostgres.inc',
'class' => 'FrxPostgres',
'parent' => 'FrxDataSource'
);
$plugins[] = array('file' => 'plugins/FrxMSSQL.inc',
'parent' => 'FrxDataSource',
'class' => 'FrxMSSQL',
'path' => $path,
);
return $plugins;
}
......
......@@ -144,7 +144,7 @@ class FrxDrupal extends FrxDataSource {
* @param unknown_type $key
* @param unknown_type $data
*/
public function format($value, $key, $data) {
public function format($value, $key) {
$db = Database::getConnection('default');
$value = $this->parmConvert($key, $value);
if ($db) {
......
......@@ -138,7 +138,7 @@ class FrxMSSQL extends FrxDataSource {
* @param unknown_type $key
* @param unknown_type $data
*/
public function format($value, $key, $data) {
public function format($value, $key) {
$value = $this->parmConvert($key, $value);
if ($value===''||$value===NULL) {
$value = 'NULL';
......
......@@ -279,7 +279,7 @@ class FrxOracle extends FrxDataSource {
* @param unknown_type $key
* @param unknown_type $data
*/
public function format($value, $key, $data) {
public function format($value, $key) {
$value = $this->parmConvert($key, $value);
if ($value==='' || $value ===NULL || $value ===array())
$value = 'NULL';
......
......@@ -134,7 +134,7 @@ class FrxPDO extends FrxDataSource {
* @param unknown_type $key
* @param unknown_type $data
*/
public function format($value, $key, $data) {
public function format($value, $key) {
$db = $this->db;
$value = $this->parmConvert($key, $value);
if ($db) {
......
......@@ -130,7 +130,7 @@ class FrxPostgres extends FrxDataSource {
* @param unknown_type $key
* @param unknown_type $data
*/
public function format($value, $key, $data) {
public function format($value, $key) {
$value = $this->parmConvert($key, $value);
if ($value===''||$value===NULL)
$value = 'NULL';
......
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