function forena_db_sync in Forena Reports 7.3
Same name and namespace in other branches
- 6.2 forena.admin.inc \forena_db_sync()
- 6 forena.admin.inc \forena_db_sync()
- 7 forena.admin.inc \forena_db_sync()
- 7.2 forena.admin.inc \forena_db_sync()
Load cache files from the database
1 call to forena_db_sync()
- forena_sync_reports in ./
forena.module - Enter description here ...
File
- ./
forena.module, line 1303
Code
function forena_db_sync($subdir = '') {
static $prefix = '';
static $skins = '';
if (!$subdir) {
$prefix = '';
db_delete('forena_reports')
->execute();
}
$save_count = 0;
$path = forena_report_path() . '/' . $subdir;
$d = dir($path);
if ($d) {
while (false !== ($rpt_file = $d
->read())) {
$src_file = trim($d->path, '/') . '/' . trim($rpt_file, '/');
$dest_file = $path . '/' . trim($rpt_file, '/');
if (is_file($src_file)) {
@(list($base_file, $ext) = explode('.', $rpt_file, 2));
switch ($ext) {
// Load Forena Reports
case 'frx':
$base_file = trim($prefix . '/' . $base_file, '/');
try {
$r_xml = file_get_contents($src_file);
} catch (Exception $e) {
$s = t('unable to load Report %s', $r_xml);
forena_error($s, $s . $e
->getMessage());
}
// Load the report
$r = new FrxReport($r_xml);
$save_count = forena_save_report($base_file, $r_xml, FALSE);
$r
->__destruct();
unset($r);
break;
//load into list of skins
case 'skinfo':
$data = file_get_contents($src_file);
$skin = drupal_parse_info_format($data);
$skin_name = @$skin['name'] ? $skin['name'] : $base_file;
$skins[$base_file] = $skin_name;
break;
}
}
elseif (is_dir($src_file)) {
if (strpos($rpt_file, '.') !== 0) {
$save_prefix = $prefix;
$prefix .= '/' . $rpt_file;
$prefix = trim($prefix, '/');
forena_db_sync($prefix);
$prefix = $save_prefix;
}
}
}
}
if ($d) {
$d
->close();
}
// Done with cache sync.
if (!$subdir) {
// Cache the skins found
asort($skins);
variable_set('forena_skins', $skins);
// Rebuild menus.
menu_rebuild();
}
return $save_count;
}