function forena_load_cache in Forena Reports 7.5
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 forena.common.inc \forena_load_cache()
- 7.2 forena.common.inc \forena_load_cache()
- 7.3 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.
3 calls to forena_load_cache()
- forena_save_report in ./
forena.common.inc - Save the report file to disk
- ReportEditor::load in src/
Editor/ ReportEditor.php - Load report from file system
- ReportFile::buildCache in src/
File/ ReportFile.php - Should load cache data based on that.
File
- ./
forena.common.inc, line 19 - 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_key => $blocks) {
$provider = Frx::DataManager()
->repository($provider_key);
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);
$obj = @$block['access'];
if (array_search($obj, $access) === FALSE) {
$access[] = $obj;
}
}
}
}
if (isset($conf['access callback']) && $access) {
$cache['access'][$provider_key][$conf['access callback']] = $access;
}
}
}
}
return $cache;
}