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
ea1e3ba4
Commit
ea1e3ba4
authored
Jul 03, 2014
by
David Metzler
Browse files
Abiltity to add data blocks programattically as well as reference forena
json data blocks.
parent
f45a2748
Changes
4
Hide whitespace changes
Inline
Side-by-side
FrxRepoMan.inc
View file @
ea1e3ba4
...
...
@@ -186,7 +186,7 @@ class FrxRepoMan {
* @param $data_block String name ob block to load
* @return unknown
*/
function
data
(
$data_block
)
{
function
data
(
$data_block
,
$raw_mode
=
FALSE
)
{
list
(
$provider
,
$block_name
)
=
explode
(
'/'
,
$data_block
,
2
);
//Intstantiate the provider
$o
=
$this
->
repository
(
$provider
);
...
...
@@ -210,6 +210,7 @@ class FrxRepoMan {
$block
=
$this
->
loadBlock
(
$data_block
);
$right
=
@
$block
[
'access'
];
if
(
$block
&&
$o
->
access
(
$right
))
{
if
(
$raw_mode
)
$block
[
'options'
][
'return_type'
]
=
'raw'
;
switch
(
$block
[
'type'
])
{
case
'sql'
:
$xml
=
$o
->
sqlData
(
$block
[
'source'
],
@
$block
[
'options'
]);
...
...
forena.module
View file @
ea1e3ba4
...
...
@@ -351,6 +351,13 @@ function forena_menu() {
'type'
=>
MENU_CALLBACK
,
);
$items
[
'forena/json/%'
]
=
array
(
'page callback'
=>
'forena_json'
,
'page arguments'
=>
array
(
2
),
'access arguments'
=>
array
(
'access forena block xml'
),
'type'
=>
MENU_CALLBACK
,
);
$items
[
'forena/fields/format/autocomplete'
]
=
array
(
'page callback'
=>
'forena_fields_format_autocomplete'
,
...
...
@@ -501,6 +508,41 @@ function forena_xml($block_name, $parms=array()) {
return
Frx
::
RepoMan
()
->
data
(
$block_name
);
}
/**
* Get the raw data from a block if supported.
* Note that this may return a simplexml object or a recordset or an
* array depending on the support provided by the product.
* @param unknown $block_name
* @param unknown $parms
* @return Ambigous <unknown, string, NULL>
*/
function
forena_data
(
$block_name
,
$parms
=
array
())
{
include_once
(
'forena.common.inc'
);
drupal_alter
(
'forena_parameters'
,
$block_name
,
$parms
);
//now invoke the data provider with the correct params
Frx
::
Data
()
->
push
(
$parms
,
'parm'
);
return
Frx
::
RepoMan
()
->
data
(
$block_name
,
TRUE
);
}
/**
* Output forena data as JSON objects.
* @param unknown $block_name
* @param string $parms
*/
function
forena_json
(
$block_name
,
$parms
=
NULL
)
{
$block_name
=
str_replace
(
'.'
,
'/'
,
$block_name
);
if
(
$parms
===
NULL
)
{
$parms
=
array_merge
(
$_GET
,
$_POST
);
unset
(
$_parms
[
'q'
]);
}
$data
=
forena_data
(
$block_name
,
$parms
);
$ret
=
array
();
foreach
(
$data
as
$row
)
{
$ret
[]
=
$row
;
}
drupal_json_output
(
$ret
);
}
/**
* Auto complete for formats
* @param $string
...
...
@@ -837,7 +879,7 @@ function forena_permission() {
'design any report'
=>
array
(
'title'
=>
t
(
'Design reports'
)),
'delete report'
=>
array
(
'title'
=>
t
(
'Delete reports'
)),
'perform email merge'
=>
array
(
'title'
=>
t
(
'Peform email merge'
)),
'access forena block xml'
=>
array
(
'title'
=>
t
(
'Access
xml
from data blocks directly'
),
'description'
=>
t
(
'Useful for ajax calls to data blocks'
)),
'access forena block xml'
=>
array
(
'title'
=>
t
(
'Access
data
from data blocks directly'
),
'description'
=>
t
(
'Useful for ajax calls to data blocks'
)),
);
foreach
(
Frx
::
RepoMan
()
->
repositories
as
$repos
=>
$conf
)
{
$name
=
$conf
[
'title'
]
?
$conf
[
'title'
]
:
$repos
;
...
...
plugins/FrxOracle.inc
View file @
ea1e3ba4
...
...
@@ -83,7 +83,7 @@ class FrxOracle extends FrxDataSource {
else
{
$sql
=
$this
->
te
->
replace
(
$sql
);
if
(
$this
->
use_oracle_xml
)
{
if
(
$this
->
use_oracle_xml
&&
@
$options
[
'return_type'
]
!=
'raw'
)
{
$xml
=
$this
->
oracle_xml
(
$sql
,
'table'
);
}
else
{
...
...
@@ -151,11 +151,12 @@ class FrxOracle extends FrxDataSource {
private
function
php_xml
(
$sql
,
$options
=
array
())
{
$db
=
$this
->
db
;
$raw_rows
=
array
();
$xml
=
new
SimpleXMLElement
(
'<table/>'
);
//$rs->debugDumpParams();
$stmt
=
oci_parse
(
$db
,
$sql
);
@
oci_execute
(
$stmt
);
$raw
=
@
$options
[
'return_type'
]
==
'raw'
;
$e
=
oci_error
(
$stmt
);
// For oci_execute errors pass the statement handle
//drupal_set_message(e_display_array($e));
...
...
@@ -181,13 +182,22 @@ class FrxOracle extends FrxDataSource {
$rownum
=
0
;
while
((
$row
=
oci_fetch_array
(
$stmt
,
OCI_ASSOC
+
OCI_RETURN_NULLS
+
OCI_RETURN_LOBS
))
&&
(
!
$use_limit
||
$row
<
$limit
))
{
$rownum
++
;
$row_node
=
$xml
->
addChild
(
'row'
);
$row_node
[
'num'
]
=
$rownum
;
foreach
(
$row
as
$key
=>
$value
)
{
$row_node
->
addChild
(
strtolower
(
$key
),
@
htmlspecialchars
(
$value
));
if
(
$raw
)
{
$raw_rows
[]
=
(
object
)
array_change_key_case
(
$row
);
}
else
{
$row_node
=
$xml
->
addChild
(
'row'
);
$row_node
[
'num'
]
=
$rownum
;
foreach
(
$row
as
$key
=>
$value
)
{
$row_node
->
addChild
(
strtolower
(
$key
),
@
htmlspecialchars
(
$value
));
}
}
}
oci_free_statement
(
$stmt
);
if
(
$raw
)
{
return
$raw_rows
;
}
return
$xml
;
}
...
...
plugins/FrxPDO.inc
View file @
ea1e3ba4
...
...
@@ -112,6 +112,7 @@ class FrxPDO extends FrxDataSource {
return
;
}
if
(
@
$options
[
'return_type'
]
==
'raw'
)
return
$rs
;
$xml
=
new
SimpleXMLElement
(
'<table/>'
);
$e
=
$db
->
errorCode
();
...
...
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