You are here

class FrxFieldTable in Forena Reports 7.4

Same name and namespace in other branches
  1. 6.2 templates/FrxFieldTable.inc \FrxFieldTable
  2. 7.2 templates/FrxFieldTable.inc \FrxFieldTable
  3. 7.3 templates/FrxFieldTable.inc \FrxFieldTable

@file FrxFieldTable Template that displays a table of column/value vertically.

Hierarchy

Expanded class hierarchy of FrxFieldTable

2 string references to 'FrxFieldTable'
forena_forena_controls in ./forena.module
Self register controls with forena.
FrxFieldTable::generate in renderers/FrxFieldTable.inc
Generate the template from the configuration.

File

renderers/FrxFieldTable.inc, line 6
FrxFieldTable Template that displays a table of column/value vertically.

View source
class FrxFieldTable extends FrxRenderer {
  public $templateName = 'Table of Fields';

  /**
   * Extract table configuration from the HTML
   * @see FrxRenderer::scrapeConfig()
   */
  public function scrapeConfig() {
    $config = array();
    $this
      ->extractTemplateHTML($this->reportDocDomNode, $config, array(
      'table',
    ));
    $tds = $this
      ->extractXPathInnerHTML('*//td', $this->reportDocDomNode, FALSE);
    $ths = $this
      ->extractXPathInnerHTML('*//th', $this->reportDocDomNode, FALSE);
    $columns = array_combine($ths, $tds);
    $i = 0;
    foreach ($columns as $label => $token) {
      $i++;
      $key = trim($token, '{}');
      $config['columns'][$key] = array(
        'contents' => $token,
        'label' => $label,
        'include' => 1,
        'weight' => $i,
      );
    }
    return $config;
  }
  public function generate($xml, &$config) {
    $config['foreach'] = '*';
    $config['class'] = 'FrxFieldTable';
    $div = $this
      ->blockDiv($config);
    $columns = $this
      ->columns($xml);

    // PUt on the header
    $this
      ->removeChildren($div);
    $this
      ->addFragment($div, $config['header']);
    $table = $this
      ->setFirstNode($div, 4, 'table');
    $r = 0;
    if ($config['columns']) {
      foreach ($config['columns'] as $key => $col) {
        if ($col['include']) {
          $r++;
          $tbody = $this
            ->addNode($table, 6, 'tbody');
          $tr = $this
            ->addNode($tbody, 8, 'tr');
          $th_attrs = array();
          if ($r == 1) {
            $th_attrs = array(
              'style' => 'width: 25em;',
            );
          }
          $th = $this
            ->addNode($tr, 10, 'th', $col['label']);
          $td = $this
            ->addNode($tr, 10, 'td', $col['contents']);
        }
      }
    }

    // Decide to inlcude columns
    $found_columns = $this
      ->columns($xml);
    if (!$found_columns) {
      $found_columns = $this
        ->columns($xml, '/*');
      $attrs = array();
    }
    $include_column = 0;
    $weight = 0;
    if (!@$config['columns']) {
      $include_column = 1;
    }
    else {
      $weight = count($config['columns']);
    }
    foreach ($found_columns as $column => $label) {
      $token = '{' . $column . '}';
      if (!isset($config['columns'][$column])) {
        $weight++;
        $config['columns'][$column] = array(
          'contents' => $token,
          'include' => $include_column,
          'label' => $label,
          'weight' => $weight,
        );
      }
    }
  }

  /**
   * Template configuration form
   * @parmater $configuration form
   */
  public function configForm($config) {

    // Load header informationi from parent config.
    $form = parent::configForm($config);
    $this
      ->weight_sort($config['columns']);
    $form['columns'] = array(
      '#theme' => 'forena_element_draggable',
      '#draggable_id' => 'FrxTable-columns',
    );
    foreach ($config['columns'] as $key => $col) {
      $ctl = array();
      $ctl['label'] = array(
        '#type' => 'textfield',
        '#size' => 30,
        '#title' => t('Label'),
        '#default_value' => $col['label'],
      );
      $ctl['contents'] = array(
        '#type' => 'textfield',
        '#size' => '30',
        '#title' => t('Data'),
        '#default_value' => $col['contents'],
      );
      $ctl['include'] = array(
        '#type' => 'checkbox',
        '#title' => t('Include'),
        '#default_value' => $col['include'],
        '#ajax' => $this
          ->configAjax(),
      );
      $ctl['weight'] = array(
        "#type" => 'weight',
        '#title' => t('Weight'),
        '#delta' => 50,
        '#default_value' => $col['weight'],
      );
      $form['columns'][$key] = $ctl;
    }
    return $form;
  }
  public function configValidate(&$config) {
    parent::configValidate($config);
    $this
      ->weight_sort($config['columns']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FrxFieldTable::$templateName public property
FrxFieldTable::configForm public function Template configuration form @parmater $configuration form Overrides FrxRenderer::configForm
FrxFieldTable::configValidate public function Default configuration validator. Simply validates header and footer attributes. Overrides FrxRenderer::configValidate
FrxFieldTable::generate public function Generate the template from the configuration. Overrides FrxRenderer::generate
FrxFieldTable::scrapeConfig public function Extract table configuration from the HTML Overrides FrxRenderer::scrapeConfig
FrxRenderer::$blockName public property
FrxRenderer::$blockParms public property
FrxRenderer::$columns public property
FrxRenderer::$dataProvider public property
FrxRenderer::$doc_types public property
FrxRenderer::$dom public property
FrxRenderer::$format public property
FrxRenderer::$frxAttributes public property
FrxRenderer::$frxReport public property @var FrxReport
FrxRenderer::$htmlAttributes public property
FrxRenderer::$id public property
FrxRenderer::$input_format public property
FrxRenderer::$name public property
FrxRenderer::$numeric_columns public property
FrxRenderer::$reportDocDomNode public property
FrxRenderer::$reportDocNode public property
FrxRenderer::$teng public property
FrxRenderer::$xmlns public property
FrxRenderer::$xpathQuery public property
FrxRenderer::addAttributes public static function Helper function for convergint methods to a standard associated array.
FrxRenderer::addFragment function Append a textual XHTML fragment to the dom. We do not use the DOMDocumentFragment optioin because they don't properly import namespaces. .
FrxRenderer::addNode function Add a node to the existing dom element with attributes
FrxRenderer::addText function Add a text node to the current dom node.
FrxRenderer::arrayAttributes public function Puts attributes back in array format prior to rendering.
FrxRenderer::blockDiv public function Generate generic div tag.
FrxRenderer::columns public function Extract a list of columns from the data context.
FrxRenderer::configAjax public function Generate ajax configuration attributes for use in template configurtion forms.
FrxRenderer::drupalRender public function Render a drupal form in a forena template
FrxRenderer::extract public function Extract a configuration var removing it from the array
FrxRenderer::extractChildSource public function Get the textual representations of html for the configuration engine.
FrxRenderer::extractSource public function Get the textual representations of html for the configuration engine.
FrxRenderer::extractTemplateHTML public function Get the textual representations of html for the configuration engine.
FrxRenderer::extractXPath public function Extracts the inner html of all nodes that match a particular xpath expression.
FrxRenderer::extractXPathInnerHTML public function Extracts the inner html of all nodes that match a particular xpath expression.
FrxRenderer::idFromBlock public function Simple function to get id from node.
FrxRenderer::initReportNode public function This function is called to give the renderer the current conetxt in report rendering. It makes sure the renderer has the current DOM nodes dom documnent, and other attributes.
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::removeChildren public function Rmove all the children of a dom node in the current report.
FrxRenderer::removeChildrenExcept public function Removes all chidren from the dome node expect those with a tagname specified by the the $tags argurment
FrxRenderer::render public function Default Render action, which simply does normal forena rendering. You can use renderDomNode at any time to generate the default forena rendering methods. 9
FrxRenderer::renderChildren public function
FrxRenderer::renderDomNode public function Recursive report renderer Walks the nodes rendering the report.
FrxRenderer::replacedAttributes public function Gives the token replaced attributes of a node.
FrxRenderer::replaceTokens public function A helper function to allow replacement of tokens from inside a renderer wihout needing to understand the object
FrxRenderer::resetTemplate public function Starting at the current report node, this function removes all child nodes. It aso removes any FRX attributes on the current as well.
FrxRenderer::setAttributes public function Set FRX attributes.
FrxRenderer::setFirstNode public function Sets the first child element to a node and returns it. IF the node
FrxRenderer::validateTextFormats public function Helper funciton for validating text_format type controls.
FrxRenderer::weight_sort public function Sort a column list by weight.
FrxRenderer::weight_sort_comp public static function
FrxRenderer::xmlToValues public function Convert XML to key value pairs. This is used in support of graping to get specific key/value pairs in an array format suitable for passing off to php libraries.
FrxRenderer::__construct public function 2