You are here

class Frx in Forena Reports 7.5

Same name and namespace in other branches
  1. 7.3 Frx.inc \Frx
  2. 7.4 Frx.inc \Frx

Hierarchy

Expanded class hierarchy of Frx

17 files declare their use of Frx
BlockEditor.php in src/Editor/BlockEditor.php
DataContext.php in src/Context/DataContext.php
DataContext.php The FrxData class holds all of the data contexts during the report rendering process. The general idea is that during the report render, data objects are pushed on the stack with the id's of the block or foreach objects that…
DataFile.php in src/File/DataFile.php
DataManager.php in src/DataManager.php
DataManager.inc Enter description here ... @author davidmetzler
DocRaptorPDF.php in src/DocumentFormats/DocRaptorPDF.php
PrincePDF PDF document via Prince XML @author davidmetzler

... See full list

2 string references to 'Frx'
FrxSection::generate in src/Renderer/FrxSection.php
Build the template
ReportEditor::blockLinks in src/Editor/ReportEditor.php

File

./Frx.inc, line 19
Frx.incL General Forena Reporting Class

View source
class Frx {

  /**
   * Helper method to return current url parameters.
   * @return unknown
   */
  public static function parms() {
    $parms = $_GET;
    unset($parms['q']);
    return $parms;
  }

  /**
   * Temporary dom object used for for fragment importing and manipulation.
   * We use a singleton here to reduce the memory footprint.
   * @return DOMDocument
   */
  public static function tempDOM() {
    static $o = '';
    if (!$o) {
      $o = new DOMDocument('1.0', 'UTF-8');
      @$o
        ->load('<?xml version="1.0" encoding="UTF-8"?>
         <!DOCTYPE root [
         <!ENTITY nbsp "&#160;">
         ]>');
    }
    return $o;
  }

  /**
   * Skin Factory
   * @return Skin
   */
  public static function Skin() {
    static $o = '';
    if (!$o) {
      $o = new Skin();
    }
    return $o;
  }

  /**
   * Data Factory
   */
  public static function Data() {
    static $o = '';
    if (!$o) {
      $o = new DataContext();
    }
    return $o;
  }

  /**
   * File singleton factory
   * @return ReportFile
   */
  public static function File() {
    static $o = '';
    if (!$o) {
      $o = new \Drupal\forena\File\ReportFile();
    }
    return $o;
  }

  /**
   * File singleton factory
   * @return FrxDataFile
   */
  public static function DataFile() {
    static $o = '';
    if (!$o) {
      $o = new \Drupal\forena\File\DataFile();
    }
    return $o;
  }

  /**
   * File singleton factory
   * @return Menu
   */
  public static function Menu() {
    static $o = '';
    if (!$o) {
      $o = new Menu();
    }
    return $o;
  }

  /**
   *
   * @param  $config array of field configuration;
   * @return ReportFields
   */
  public static function Fields($config = array()) {
    $o = new ReportFields($config);
    return $o;
  }

  /**
   *
   * Enter description here ...
   * @param unknown_type $type
   * @return DocumentTypeBase
   */
  public static function Document($type = 'web') {
    static $doc_types = '';
    static $objects = '';

    // Invoke doc_type hook to see which document types are there.
    if (!$doc_types) {
      $doc_types = module_invoke_all('forena_document_types');
    }
    if (!$type) {
      $type = 'web';
    }
    if (isset($doc_types[$type]) && class_exists(@$doc_types[$type]['class'])) {
      if (!@$doc_types[$type]['object']) {
        $class = $doc_types[$type]['class'];
        $o = new $class();
        $o->format = $type;
        $doc_types[$type]['object'] = $o;
      }
      else {
        $o = $doc_types[$type]['object'];
      }
      return $o;
    }
    else {
      drupal_set_message(t('Unsupported document type: %s', array(
        '%s' => $type,
      )), 'error');
      drupal_not_found();
      exit;
    }
  }

  /**
   * Returns list of document types supported.
   * @param unknown_type $all
   */
  public static function documentTypes($all = FALSE) {
    static $supported_doctypes = '';
    if (!$supported_doctypes || $all) {
      $doc_types = module_invoke_all('forena_document_types');
      if (!$all) {
        unset($doc_types['web']);
      }
      $supported_doctypes = array();
      foreach ($doc_types as $type => $doc) {
        $supported_doctypes[$type] = $type;
      }
    }
    return $supported_doctypes;
  }

  /**
   * Retreive the classes from other modules.
   * @param string $class
   * @return Ambigous <string, unknown>
   */
  public static function Controls($class = '') {
    static $instances = '';
    if (!$instances) {
      foreach (module_list() as $module) {
        $function = $module . '_forena_controls';
        if (function_exists($function)) {
          $returned_controls = $function();
          if ($returned_controls) {
            foreach ((array) $returned_controls as $k => $c) {
              $c['module'] = $module;
              if (isset($c['file'])) {
                $c['file'] = drupal_get_path('module', $c['module']) . '/' . trim($c['file'], '/');
                include_once $c['file'];
              }
              if (class_exists($c['class'])) {
                $instances[$k] = new $c['class']();
              }
            }
          }
        }
      }
    }

    // Return class if we asked for one.
    if ($class) {
      return @$instances[$class];
    }
    return $instances;
  }

  /**
   * Returns an object of the template class
   * that has a method named templates.
   * @return RendererBase
   */
  public static function Template($class) {
    return Frx::Controls($class);
  }

  /**
   * Forena Repository manager
   * Class factory
   * @return DataManager
   */
  public static function DataManager() {
    static $o = '';
    if (!$o) {
      $o = new DataManager();
    }
    return $o;
  }

  /**
   * General wrapper procedure for reporting erros
   *
   * @param string $short_message Message that will be displayed to the users
   * @param string $log Message that will be recorded in the logs.
   */
  public static function error($short_message = '', $log = '') {
    if ($short_message) {
      drupal_set_message(check_markup($short_message), 'error', FALSE);
    }
    if ($log) {
      watchdog('forena', $log, NULL, WATCHDOG_ERROR);
    }
  }

  /**
   * Debug handler
   * Enter description here ...
   * @param unknown_type $short_message
   * @param unknown_type $log
   */
  public static function debug($short_message = '', $log = '') {
    if ($log) {
      watchdog('forena debug', $log, NULL);
    }
    if ($short_message) {
      drupal_set_message(check_markup($short_message));
    }
  }

  /**
   * Factory for token replacement syntax engine object
   * @param $regexp string regular expression for finding tokens
   * @param $trim string to trim off the end of tokens.
   * @return TokenReplacerBase
   */
  public static function SyntaxEngine($regexp, $trim) {
    return new TokenReplacerBase($regexp, $trim);
  }

  /**
   * Factory method to return instance object
   * @param unknown_type $parent
   * @param unknown_type $key
   * @return object
   */
  public static function getDriver($parent, $key) {
    static $objects = '';
    $o = NULL;
    if (!$objects) {
      $objects = array();
    }
    $plugins = Frx::drivers($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;

    // Instantiate the class if it exists
    if ($context) {
      $o = Frx::getDriver('FrxContext', $context);
    }

    // Otherwise instantiate the data class.
    if (!$o) {
      $o = Frx::Data();
    }
    return $o;
  }

  /**
   * Loads all of the include files that
   */
  public static function drivers($parent = '') {
    static $drivers = '';
    if (!$drivers) {
      $drivers = 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 (isset($p['file'])) {
                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)) {
                $drivers[] = $p;
              }
              else {
                $drivers[$key] = $p;
              }
            }
          }
        }
      }
      foreach ($drivers as $p) {
        if (isset($p['file'])) {
          include_once trim($p['file'], '/');
        }
      }
    }

    // Return the plugins if a parent was requested.
    $ret_plugins = array();
    if ($parent) {
      foreach ($drivers as $key => $p) {
        if (@$p[parent] == $parent) {
          $ret_plugins[$key] = $p;
        }
      }
    }
    return $ret_plugins;
  }

  /**
   *
   * @param  $report_name
   * @return ReportEditor <string, ReportEditor>
   */
  public static function Editor($report_name = '', $edit = TRUE) {
    static $o = '';
    if (!$o || !$edit) {
      $o = new ReportEditor($report_name, $edit);
    }
    else {
      if ($report_name) {
        $o
          ->load($report_name, $edit);
      }
    }
    return $o;
  }

  /**
   *
   * @param $block_name
   * @return BlockEditor
   */
  public static function BlockEditor($block_name = '', $edit = TRUE) {
    static $o = '';
    if (!$o) {
      $o = new BlockEditor($block_name, $edit);
    }
    else {
      if ($block_name) {
        $o
          ->load($block_name, $edit);
      }
    }
    return $o;
  }
  static function supportedFormats() {
    $controls = Frx::Controls();
    $supported_formats = array();
    $f = array();
    foreach ($controls as $k => $r) {
      $provider = $r;
      if ($provider && method_exists($provider, 'formats')) {
        $f = $provider
          ->formats();
        $supported_formats = array_merge($supported_formats, $f);
      }
    }
    return $supported_formats;
  }

  /**
   * Load the formatters for all initialized repositories.
   *
   */
  public static function formatter($fkey) {

    // Get all repositories
    $repos = Frx::DataManager()->repositories;
    $formats = array();
    foreach ($repos as $k => $r) {
      $provider = isset($r['data']) ? $r['data'] : NULL;
      if ($provider && method_exists($provider, 'formats')) {
        $f = $provider
          ->formats();
        if (isset($f[$fkey]) && method_exists($provider, $fkey)) {

          // We found an object with the advertised method return it
          return $provider;
        }
      }
    }

    //Did not find the formater in the data provider

    //Look to see if it's in a control class
    $controls = Frx::Controls();
    foreach ($controls as $k => $r) {
      $provider = $r;
      if ($provider && method_exists($provider, 'formats')) {
        $f = $provider
          ->formats();
        if (isset($f[$fkey]) && method_exists($provider, $fkey)) {

          // We found an object with the advertised method return it
          return $provider;
        }
      }
    }
    return $formats;
  }
  public static function format($value, $format, $format_str, $teng = '') {
    $fo = Frx::formatter($format);
    if ($fo) {
      $ret = $fo
        ->{$format}($value, $format_str, $teng);
    }
    else {
      $ret = $value;
    }
    return $ret;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Frx::BlockEditor public static function
Frx::Context public static function Factory object to get the context based on a name. IF the context doesn't exist we assume the default data context (FrxData).
Frx::Controls public static function Retreive the classes from other modules.
Frx::Data public static function Data Factory
Frx::DataFile public static function File singleton factory
Frx::DataManager public static function Forena Repository manager Class factory
Frx::debug public static function Debug handler Enter description here ...
Frx::Document public static function Enter description here ...
Frx::documentTypes public static function Returns list of document types supported.
Frx::drivers public static function Loads all of the include files that
Frx::Editor public static function
Frx::error public static function General wrapper procedure for reporting erros
Frx::Fields public static function
Frx::File public static function File singleton factory
Frx::format public static function
Frx::formatter public static function Load the formatters for all initialized repositories.
Frx::getDriver public static function Factory method to return instance object
Frx::Menu public static function File singleton factory
Frx::parms public static function Helper method to return current url parameters.
Frx::Skin public static function Skin Factory
Frx::supportedFormats static function
Frx::SyntaxEngine public static function Factory for token replacement syntax engine object
Frx::tempDOM public static function Temporary dom object used for for fragment importing and manipulation. We use a singleton here to reduce the memory footprint.
Frx::Template public static function Returns an object of the template class that has a method named templates.