function forena_load_cache in Forena Reports 7.3
Same name and namespace in other branches
- 8 forena.common.inc \forena_load_cache()
- 6.2 forena.common.inc \forena_load_cache()
- 6 forena.common.inc \forena_load_cache()
- 7.5 forena.common.inc \forena_load_cache()
- 7 forena.common.inc \forena_load_cache()
- 7.2 forena.common.inc \forena_load_cache()
- 7.4 forena.common.inc \forena_load_cache()
Build cache
Parameters
xhtml $r_xhtml Forena XML report.:
Return value
array data to be stored in the cache field for the report in the database.
1 call to forena_load_cache()
- forena_save_report in ./
forena.common.inc - Save the report file to disk
File
- ./
forena.common.inc, line 24 - Common functions used throughout the project but loaded in this file to keep the module file lean.
Code
function forena_load_cache($r_xhtml) {
$conf = array();
$cache = array();
$blocks = array();
$repos = array();
$nodes = array();
if (is_object($r_xhtml)) {
$head = @$r_xhtml->head;
if ($head) {
$nodes = $head
->xpath('frx:menu');
}
$menu = array();
if ($nodes) {
$m = $nodes[0];
$attrs = $m
->attributes();
foreach ($attrs as $key => $value) {
$menu[$key] = (string) $value;
}
}
if ($menu) {
$cache['menu'] = $menu;
}
$block_xml = $r_xhtml
->xpath('//*[@frx:block]');
// Extract all the blocks and organize by provider
foreach ($block_xml as $key => $block_node) {
$attrs = $block_node
->attributes('urn:FrxReports');
foreach ($attrs as $key => $value) {
if ($key == 'block') {
@(list($provider, $block) = explode('/', $value, 2));
$repos[$provider][] = $block;
}
}
}
if ($repos) {
foreach ($repos as $provider => $blocks) {
$provider = Frx::RepoMan()
->repository($provider);
if (isset($provider->conf)) {
$conf = $provider->conf;
}
$access = array();
foreach ($blocks as $block_name) {
if ($provider && $block_name) {
if (method_exists($provider, 'loadBlock')) {
$conf = $provider->conf;
$block = $provider
->loadBlock($block_name);
if (isset($block['access']) && array_search($block['access'], $access) === FALSE) {
$access[] = $block['access'];
}
}
}
else {
//drupal_set_message('no provider found', 'error');
}
}
if (isset($conf['access callback']) && $access) {
$cache['access'][$conf['access callback']] = $access;
}
}
}
}
return $cache;
}