Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
forena
Commits
bbd08f2d
Commit
bbd08f2d
authored
Sep 15, 2013
by
David Metzler
Browse files
Refactor location of context value gets.
parent
82c7f563
Changes
11
Hide whitespace changes
Inline
Side-by-side
Frx.inc
View file @
bbd08f2d
...
...
@@ -210,7 +210,7 @@ class Frx {
}
/**
* Fac
o
try for SQL Query builder object
* Fact
o
ry 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
FrxData.inc
View file @
bbd08f2d
...
...
@@ -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
;
}
...
...
FrxFields.inc
View file @
bbd08f2d
...
...
@@ -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
=
''
;
...
...
FrxReport.inc
View file @
bbd08f2d
...
...
@@ -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
=
''
;
...
...
FrxSyntaxEngine.inc
View file @
bbd08f2d
...
...
@@ -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
;
}
...
...
forena.module
View file @
bbd08f2d
...
...
@@ -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
;
}
...
...
plugins/FrxDrupal.inc
View file @
bbd08f2d
...
...
@@ -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
)
{
...
...
plugins/FrxMSSQL.inc
View file @
bbd08f2d
...
...
@@ -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'
;
...
...
plugins/FrxOracle.inc
View file @
bbd08f2d
...
...
@@ -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'
;
...
...
plugins/FrxPDO.inc
View file @
bbd08f2d
...
...
@@ -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
)
{
...
...
plugins/FrxPostgres.inc
View file @
bbd08f2d
...
...
@@ -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'
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment