You are here

class FrxWebDoc in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.4 docformats/FrxWebDoc.inc \FrxWebDoc

@file FrxWebDoc.inc Standard web document manager @author metzlerd

Hierarchy

Expanded class hierarchy of FrxWebDoc

1 string reference to 'FrxWebDoc'
forena_forena_document_types in ./forena.module
Self register document formats with Forena

File

docformats/FrxWebDoc.inc, line 8
FrxWebDoc.inc Standard web document manager @author metzlerd

View source
class FrxWebDoc extends FrxDocument {
  private $title;
  public function render($r, $format, $options = array()) {

    // Set title based on report.
    if ($r->title) {
      $this->title = $r->title;

      //drupal_set_title(filter_xss($r->title));
    }

    // Add Style attribute from header
    // Add css files
    foreach (Frx::Skin()->stylesheets as $type => $sheets) {
      foreach ($sheets as $sheet) {
        switch ($type) {
          case 'all':
          case 'print':
          case 'screen':
            drupal_add_css($sheet, array(
              'media' => $type,
            ));
            break;
        }
      }
    }

    // Add inline styles
    if (isset($r->rpt_xml->head->style)) {
      $sheet = (string) $r->rpt_xml->head->style;
      drupal_add_css($sheet, array(
        'type' => 'inline',
      ));
    }

    // Add javascript files
    foreach (Frx::Skin()->scripts as $script) {
      drupal_add_js($script);
    }

    // @TODO: Refactor to support theming of document links.
    // Build Links for document.
    $formats = '';
    if ($r->html) {

      //Building the document links
      $supported_doctypes = Frx::documentTypes();
      $default_doctypes = variable_get('forena_doc_defaults', array());
      $m = Frx::Menu();
      $link = str_replace('/', '.', $m->base_name);
      if ($m->name) {
        $formats = '<div class="doclinks">';
        if (!$r->formats) {
          $doc_types = $m->doc_defaults;
        }
        else {

          //There were nodes. show the prefered doc types
          $doc_types = array_intersect($m->doc_formats, $r->formats);
        }
        if ($doc_types) {
          foreach ($doc_types as $value) {
            $formats .= @l(strtoupper($value) . ' ', 'report_doc/' . $link . '.' . $value, array(
              'query' => $r->parms,
              'class' => 'doclinks',
            ));
          }
        }
        $formats .= '</div>';
      }
    }

    // Use a theme function to make sure the report gets themed.
    $variables = array(
      'doc_links' => $formats,
      'content' => $this
        ->check_markup($r->html),
    );
    $output = theme('forena_web_report', $variables);
    return $output;
  }
  public function output($output) {
    if ($this->title) {
      drupal_set_title(filter_xss($this->title));
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FrxDocument::$charset public property
FrxDocument::$content_type public property
FrxDocument::$format public property
FrxDocument::check_markup public function Wrapper function for check output to default the right type.
FrxDocument::convertCharset public function
FrxDocument::loadCSSFiles public function
FrxWebDoc::$title private property
FrxWebDoc::output public function Overrides FrxDocument::output
FrxWebDoc::render public function Overrides FrxDocument::render