View source
<?php
global $forena_application_class;
$forena_application_class = 'FrxHostApplication';
class FrxHostApplication {
private static $instance = '';
public $repositories = array();
public static function instance() {
if (self::$instance) {
return new Application();
}
else {
return self::$instance;
}
}
public function configuration($var_name) {
global $forena_conf;
return $forena_conf[$var_name];
}
public function link($title, $path, $options = array()) {
return '<a href="' . $path . '">' . $title . '</a>';
}
public function theme($r, $doc_type, $title) {
return $r->html;
}
public function add_css($css_file) {
}
public function add_js($js_file) {
}
public function report_link($report_name, $title) {
return $this
->link($title, $path);
}
public function error($short = '', $long = '') {
print 'Error: ' . $short . $long;
}
public function debug($short_message = '', $log = '') {
print 'Debug:' . $message . $log;
}
function report_css($desc, $form, $format = '') {
$css_files = array();
$path = forena_report_path();
if (file_exists($path . '/' . $form . '.css')) {
$css_files[] = $path . '/' . $form . '.css';
}
if ($format && file_exists($path . '/' . $form . '-' . $format . '.css')) {
$css_files[] = $path . '/' . $form . '-' . $format . '.css';
}
$base_file = $path . '/' . $desc['name'];
if ($format && file_exists($base_file . '-' . $format . '.css')) {
$css_files[] = $base_file . '-' . $format . '.css';
}
elseif (file_exists($base_file . '.css')) {
$css_files[] = $base_file . '.css';
}
return $css_files;
}
public function forena_path() {
return 'forena';
}
public function not_found($name) {
}
public function repositories() {
global $_forena_repositories;
return $_forena_repositories;
}
function load_report($report_name) {
$r = null;
if ($report_name) {
$report_path = $this
->configuration('report_repos');
$filename = 'reports/' . $report_name . '.frx';
if (file_exists($filename)) {
$r_text = file_get_contents($filename);
}
return $r_text;
}
}
function controls() {
$controls = array();
$controls[] = array(
'file' => 'plugins/FrxControls.inc',
'class' => 'FrxControls',
);
$controls[] = array(
'file' => 'plugins/FrxSource.inc',
'class' => 'FrxSource',
);
$controls[] = array(
'file' => 'plugins/FrxXMLSource.inc',
'class' => 'FrxXMLSource',
);
$controls[] = array(
'file' => 'plugins/FrxInclude.inc',
'class' => 'FrxInclude',
);
return $controls;
}
function url($path, $options) {
if ($options['query']) {
$query = $options['query'];
if (is_array($query)) {
$q = '';
foreach ($query as $key => $value) {
$q .= '&' . urlencode($key) . '=' . urlencode($value);
}
$query = trim($q, '&');
}
if ($query) {
$path .= '?' . $query;
}
}
return $path;
}
function plugins() {
$plugins[] = array(
'file' => 'plugins/FrxPDO.inc',
'class' => 'FrxPDO',
);
$plugins[] = array(
'file' => 'plugins/FrxOracle.inc',
'class' => 'FrxOracle',
);
$plugins[] = array(
'file' => 'plugins/FrxFiles.inc',
'class' => 'FrxFiles',
);
$plugins[] = array(
'file' => 'plugins/FrxPostgres.inc',
'class' => 'FrxPostgres',
);
$plugins[] = array(
'file' => 'plugins/FrxMSSQL.inc',
'class' => 'FrxMSSQL',
);
return $plugins;
}
function get_doctypes($fkey) {
$controls = $this
->controls();
foreach ($controls as $k => $r) {
$provider = $r;
if ($provider && method_exists($provider, 'doc_types')) {
$f = $provider
->doc_types();
if (isset($f[$fkey]) && method_exists($provider, $f[$fkey])) {
return $provider;
}
}
}
return 0;
}
function supported_templates() {
$controls = $this
->controls();
$supported_templates = array();
foreach ($controls as $k => $r) {
$provider = $r;
if ($provider && method_exists($provider, 'templates')) {
$f = $provider
->templates();
$supported_templates = array_merge($supported_templates, $f);
}
}
return $supported_templates;
}
function supported_doctypes() {
$controls = $this
->controls();
$supported_doctypes = array();
foreach ($controls as $k => $r) {
$provider = $r;
if ($provider && method_exists($provider, 'doc_types')) {
$f = $provider
->doc_types();
$supported_doctypes = array_merge($supported_doctypes, $f);
}
}
$temp = array_keys($supported_doctypes);
$supported_doctypes = array_combine($temp, $temp);
return $supported_doctypes;
}
}