You are here

class FrxInclude in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 plugins/FrxInclude.inc \FrxInclude
  2. 7.2 plugins/FrxInclude.inc \FrxInclude
  3. 7.4 renderers/FrxInclude.inc \FrxInclude

@file FrxInclude Include a reference to another report as an asset. @author davidmetzler

Hierarchy

Expanded class hierarchy of FrxInclude

3 string references to 'FrxInclude'
forena_forena_controls in ./forena.module
Self register controls with forena.
FrxRptInclude::generate in templates/FrxRptInclude.inc
Enter description here ...
FrxTemplate::blockDiv in templates/FrxTemplate.inc
Generate generic div tag.

File

renderers/FrxInclude.inc, line 8
FrxInclude Include a reference to another report as an asset. @author davidmetzler

View source
class FrxInclude extends FrxRenderer {
  public function render() {

    // Get data from source
    $attributes = $this
      ->mergedAttributes();
    $output = '';

    // Determine data type
    $include = @$attributes['src'];

    // Reformat URL
    @(list($url, $query_str) = @explode('?', $include));
    $url = $this->teng
      ->replace($url, TRUE);
    $report_url = $url;
    $parts = @explode('/', $url);
    $file = @$parts[count($parts) - 1];
    $parts = explode('.', $file);

    // Determine file extention
    $ext = count($parts) > 1 ? $parts[count($parts) - 1] : '';
    $query = array();
    if ($query_str) {
      parse_str($query_str, $query);
      foreach ($query as $key => $value) {
        $query[$key] = $this->teng
          ->replace($value, TRUE);
      }
    }

    // Build URL
    $options = array(
      'query' => $query,
    );
    $url = url($url, $options);
    if ($this->format == 'web') {
      $output = $this
        ->render_reference($url, $ext, $attributes);
    }
    else {
      $output = forena_report_include(str_replace('reports/', '', $report_url), $query);
    }
    return $output;
  }
  function render_reference($url, $ext, $attributes) {
    $ext = strtolower($ext);
    $attributes = $this->teng
      ->replace($attributes);
    switch ($ext) {
      case 'png':
      case 'gif':
      case 'jpg':
      case 'jpeg':
        $x = new SimpleXMLElement('<img/>');
        $x['src'] = $url;
        if (isset($attributes['height'])) {
          $x['height'] = $attributes['height'];
        }
        if (isset($attributes['width'])) {
          $x['width'] = $attributes['width'];
        }
        break;
      case 'svg':
        $x = new SimpleXMLElement('<embed/>');
        $x['src'] = $url;
        $x['type'] = 'image/svg+xml';
        $x['pluginspage'] = "http://www.adobe.com/svg/viewer/install/";
        if (isset($attributes['height'])) {
          $x['height'] = $attributes['height'];
        }
        if (isset($attributes['width'])) {
          $x['width'] = $attributes['width'];
        }
        break;
      default:
        $x = new SimpleXMLElement('<a>' . $ext . ' document</a>');
        $x['href'] = $url;
    }
    if (isset($attributes['id'])) {
      $x['id'] = $attributes['id'];
    }
    return $x
      ->asXML();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FrxInclude::render public function Overrides FrxRenderer::render
FrxInclude::render_reference function
FrxRenderer::$dataProvider public property
FrxRenderer::$format public property
FrxRenderer::$frxAttributes public property
FrxRenderer::$frxReport public property
FrxRenderer::$htmlAttributes public property
FrxRenderer::$id public property
FrxRenderer::$name public property
FrxRenderer::$reportDocDomNode public property
FrxRenderer::$reportDocNode public property
FrxRenderer::$teng public property
FrxRenderer::addAttributes public static function
FrxRenderer::drupalRender public function Render a drupal form in a forena template
FrxRenderer::initReportNode public function
FrxRenderer::innerXML public function Return the inside xml of the current node
FrxRenderer::mergedAttributes public function Standard php array containing merged attributes Enter description here ...
FrxRenderer::replacedAttributes public function
FrxRenderer::replaceTokens public function
FrxRenderer::__construct public function 1