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
7fca73b8
Commit
7fca73b8
authored
Sep 15, 2013
by
David Metzler
Browse files
Implemented ability to include reports based on context parameters.
parent
24b2b27f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Frx.inc
View file @
7fca73b8
...
...
@@ -210,7 +210,7 @@ class Frx {
}
/**
* Fac
t
ory for SQL Query builder object
* Faco
t
ry for SQL Query builder object
* @param $new Boolean value that forces a new object
* @return FrxSQLQueryBuilder
*/
...
...
@@ -223,15 +223,100 @@ class Frx {
return
$o
;
}
/**
* Factory method to return instance object
* @param unknown_type $parent
* @param unknown_type $key
* @return object
*/
public
static
function
PluginInstance
(
$parent
,
$key
)
{
static
$objects
=
''
;
$o
=
NULL
;
if
(
!
$objects
)
{
$objects
=
array
();
}
$plugins
=
Frx
::
plugins
(
$parent
);
if
(
isset
(
$plugins
[
$key
]))
{
$class
=
@
$plugins
[
$key
][
'class'
];
if
(
!
isset
(
$objects
[
$class
]))
{
if
(
class_exists
(
$class
))
$objects
[
$class
]
=
new
$class
();
}
$o
=
$objects
[
$class
];
}
return
$o
;
}
/**
* Factory object to get the context based on a name. IF the context doesn't
* exist we assume the default data context (FrxData).
* @param $context string
* @return FrxContext
*/
public
static
function
Context
(
$context
)
{
$o
=
NULL
;
if
(
$context
)
{
// Instantiate the class if it exists
if
(
$context
)
{
$o
=
Frx
::
PluginInstance
(
'FrxContext'
,
$context
);
}
// Otherwise instantiate the data class.
if
(
!
$o
)
{
$o
=
Frx
::
Data
();
Frx
::
Data
();
}
return
$o
;
}
/**
* Loads all of the include files that
*/
public
static
function
plugins
(
$parent
=
''
)
{
static
$plugins
=
''
;
if
(
!
$plugins
)
{
$plugins
=
array
();
foreach
(
module_list
()
as
$module
)
{
$function
=
$module
.
'_forena_plugins'
;
if
(
function_exists
(
$function
))
{
$returned_plugins
=
$function
();
if
(
$returned_plugins
)
foreach
((
array
)
$returned_plugins
as
$key
=>
$p
)
{
$p
[
'module'
]
=
$module
;
if
(
@
$p
[
'path'
])
{
$p
[
'file'
]
=
rtrim
(
$p
[
'path'
],
'/'
)
.
'/'
.
$p
[
'file'
];
}
else
{
$p
[
'file'
]
=
drupal_get_path
(
'module'
,
$p
[
'module'
])
.
'/'
.
$p
[
'file'
];
}
if
(
is_int
(
$key
))
{
$plugins
[]
=
$p
;
}
else
{
$plugins
[
$key
]
=
$p
;
}
}
}
}
foreach
(
$plugins
as
$p
)
{
if
(
$p
[
'file'
]
)
{
include_once
(
trim
(
$p
[
'file'
],
'/'
));
}
}
}
// Return the plugins if a parent was requested.
$ret_plugins
=
array
();
if
(
$parent
)
{
foreach
(
$plugins
as
$key
=>
$p
)
{
if
(
@
$p
[
parent
]
==
$parent
)
{
$ret_plugins
[
$key
]
=
$p
;
}
}
}
return
$ret_plugins
;
}
}
\ No newline at end of file
FrxDrupalApplication.inc
View file @
7fca73b8
...
...
@@ -181,34 +181,6 @@ class FrxDrupalApplication {
}
}
/**
* Invokes the hooks required for forena plugin registration.
* Each module returns an array structure that defines multiple plugins
*
* class - Indicates the name of the class that will be used to define the plugins behaviors.
*
*/
function
plugins
()
{
static
$plugins
=
''
;
if
(
!
$plugins
)
{
$plugins
=
array
();
foreach
(
module_list
()
as
$module
)
{
$function
=
$module
.
'_forena_plugins'
;
if
(
function_exists
(
$function
))
{
$returned_plugins
=
$function
();
if
(
$returned_plugins
)
foreach
((
array
)
$returned_plugins
as
$p
)
{
$p
[
'module'
]
=
$module
;
$p
[
'file'
]
=
drupal_get_path
(
'module'
,
$p
[
'module'
])
.
'/'
.
$p
[
'file'
];
$plugins
[]
=
$p
;
}
}
}
}
return
$plugins
;
}
/**
* Builds a global array of available controls
* and returns the array.
...
...
FrxRepoMan.inc
View file @
7fca73b8
...
...
@@ -11,35 +11,6 @@ class FrxRepoMan {
private
$repository
;
/**
* Loads all of the include files that
*/
private
function
define_plugins
(
$class
=
''
)
{
static
$plugins
=
''
;
if
(
!
$plugins
)
{
$plugins
=
array
();
foreach
(
module_list
()
as
$module
)
{
$function
=
$module
.
'_forena_plugins'
;
if
(
function_exists
(
$function
))
{
$returned_plugins
=
$function
();
if
(
$returned_plugins
)
foreach
((
array
)
$returned_plugins
as
$p
)
{
$p
[
'module'
]
=
$module
;
$p
[
'file'
]
=
drupal_get_path
(
'module'
,
$p
[
'module'
])
.
'/'
.
$p
[
'file'
];
$plugins
[]
=
$p
;
}
}
}
}
foreach
(
$plugins
as
$p
)
{
if
((
$class
==
''
||
$class
==
$p
[
'class'
]))
{
if
(
$p
[
'file'
]
)
{
include_once
(
trim
(
$p
[
'file'
],
'/'
));
}
}
}
}
//Determine data sources.
public
function
__construct
()
{
global
$_forena_repositories
;
...
...
@@ -143,7 +114,7 @@ class FrxRepoMan {
*/
public
function
load_provider
(
$conf
,
$repo_path
,
$repos_name
)
{
@
$name
=
isset
(
$conf
[
'data provider'
])
?
$conf
[
'data provider'
]
:
$conf
[
'data_engine'
];
$this
->
define_plugins
(
);
Frx
::
plugins
(
'FrxDataSource'
);
// Instantiate the path
if
(
class_exists
(
$name
))
{
$o
=
new
$name
(
$conf
,
$repo_path
,
$repos_name
);
...
...
FrxSyntaxEngine.inc
View file @
7fca73b8
...
...
@@ -58,7 +58,7 @@ class FrxSyntaxEngine {
protected
function
get_value
(
$key
,
$raw
=
FALSE
)
{
$context
=
''
;
if
(
$key
&&
strpos
(
$key
,
'.'
))
{
@
list
(
$
key
,
$path
)
=
explode
(
'.'
,
$key
,
2
);
@
list
(
$
context
,
$key
)
=
explode
(
'.'
,
$key
,
2
);
$o
=
Frx
::
Context
(
$context
);
}
else
{
...
...
forena.module
View file @
7fca73b8
...
...
@@ -800,8 +800,8 @@ function forena_report($name_in, $parms = array(), $print = TRUE) {
require_once
(
'forena.common.inc'
);
$desc
=
Frx
::
Menu
()
->
parseURL
(
$name_in
);
if
(
!
$desc
[
'exists'
])
{
drupal_not
_
found
(
);
exit
;
drupal_
set_message
(
t
(
'Report %s
not
found
'
,
array
(
'%s'
=>
$name_in
)),
'error'
,
FALSE
);
return
''
;
}
...
...
@@ -950,40 +950,47 @@ 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'
,
$plugins
[
'FrxPDO'
]
=
array
(
'file'
=>
'plugins/FrxPDO.inc'
,
'parent'
=>
'FrxDataSource'
,
'class'
=>
'FrxPDO'
,
'path'
=>
$path
,
);
$plugins
[]
=
array
(
'file'
=>
'plugins/FrxOracle.inc'
,
$plugins
[
'FrxOracle'
]
=
array
(
'file'
=>
'plugins/FrxOracle.inc'
,
'parent'
=>
'FrxDataSource'
,
'class'
=>
'FrxOracle'
,
'path'
=>
$path
,
);
$plugins
[]
=
array
(
$plugins
[
'FrxDrupal'
]
=
array
(
'file'
=>
'plugins/FrxDrupal.inc'
,
'parent'
=>
'FrxDataSource'
,
'class'
=>
'FrxDrupal'
,
'path'
=>
$path
,
);
$plugins
[]
=
array
(
'file'
=>
'plugins/FrxFiles.inc'
,
$plugins
[
'FrxFiles'
]
=
array
(
'file'
=>
'plugins/FrxFiles.inc'
,
'parent'
=>
'FrxDataSource'
,
'class'
=>
'FrxFiles'
,
);
$plugins
[]
=
array
(
'file'
=>
'plugins/FrxPostgres.inc'
,
$plugins
[
'FrxPostgres'
]
=
array
(
'file'
=>
'plugins/FrxPostgres.inc'
,
'class'
=>
'FrxPostgres'
,
'parent'
=>
'FrxDataSource'
);
$plugins
[]
=
array
(
'file'
=>
'plugins/FrxMSSQL.inc'
,
$plugins
[
'FrxMSSQL'
]
=
array
(
'file'
=>
'plugins/FrxMSSQL.inc'
,
'parent'
=>
'FrxDataSource'
,
'class'
=>
'FrxMSSQL'
,
'path'
=>
$path
,
);
// Normally you wouldn't do this but I wanted to make the FrxReport sytax work.
$plugins
[
'FrxReport'
]
=
array
(
'file'
=>
'plugins/FrxReportContext.inc'
,
'parent'
=>
'FrxContext'
,
'class'
=>
'FrxReportContext'
,
'path'
=>
$path
,
);
return
$plugins
;
}
...
...
plugins/FrxReportContext.inc
0 → 100644
View file @
7fca73b8
<?php
/**
* Special report embedder
* @author davidmetzler
*
*/
class
FrxReportContext
{
// Get report based on current context and embed it.
public
function
getValue
(
$key
,
$context
)
{
$output
=
forena_report
(
$key
,
NULL
,
FALSE
);
return
$output
;
}
// Undo setter, no possibility to override.
public
function
setValue
(
$value
)
{
}
}
\ No newline at end of file
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