You are here

class FrxSection in Forena Reports 8

Hierarchy

Expanded class hierarchy of FrxSection

1 string reference to 'FrxSection'
forena_forena_controls in ./forena.module
Self register controls with forena.

File

src/FrxPlugin/Template/FrxSection.php, line 6

Namespace

Drupal\forena\Template
View source
class FrxSection extends TemplateBase {
  public $templateName = 'Section';
  public $lastClass = '';
  private $template = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!ENTITY nbsp "&#160;">
]>
<html xmlns:frx="urn:FrxReports">
<head>
<body>
  <div class="FrxSection">
  {template}
  </div>
</body>
</html>
EOF;

  /**
   * [@inheritdoc}
   */
  public function scrapeConfig(\SimpleXMLElement $xml) {

    // Simple section template
    $template = $this
      ->innerXML($xml);
    $this->configuration['template'] = $template;
  }

  /**
   * Generate configuration.
   */
  public function configForm() {
    $config = $this->configuration;
    $form['sections'] = array(
      '#theme' => 'forena_element_draggable',
      '#draggable_id' => 'FrxContainer-sections',
    );
    if (isset($config['sections'])) {
      foreach ($config['sections'] as $id => $section) {
        $ctl = array();
        $ctl['id'] = array(
          '#type' => 'item',
          '#markup' => $id,
          '#title' => 'id',
        );
        $ctl['markup'] = array(
          '#type' => 'value',
          '#value' => $section['markup'],
        );
        $ctl['class_label'] = array(
          '#type' => 'item',
          '#markup' => @$section['class'],
          '#title' => t('Type'),
        );
        $ctl['class'] = array(
          '#type' => 'value',
          '#value' => @$section['class'],
        );

        // $ctl['display'] = array('#type' => 'item', '#title' => 'html',  '#markup' =>$section['markup']);
        $form['sections'][$id] = $ctl;
      }
    }
    return $form;
  }

  /**
   * Validate the configuration
   */
  public function configValidate(&$config) {
  }

  /**
   * Build document from the existing template.
   * @param $xml
   * @param $config
   * @return string
   *   Report fragment.
   */
  public function generate() {
    $doc = new XML();
    $this
      ->pushData($this->configuration, '_template');
    $report = new Report($this->template, $doc);
    $report
      ->render();
    $text = $doc
      ->flush();
    $xml = new \SimpleXMLElement($text);
    return $this
      ->innerXML($xml);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FrxAPI::app public function Returns containing application service
FrxAPI::currentDataContext public function Get the current data context.
FrxAPI::currentDataContextArray public function
FrxAPI::dataManager public function Returns the data manager service
FrxAPI::dataService public function Return Data Service
FrxAPI::documentManager public function Returns the fornea document manager
FrxAPI::error public function Report an error
FrxAPI::getDataContext public function Get the context of a specific id.
FrxAPI::getDocument public function Get the current document
FrxAPI::getReportFileContents public function Load the contents of a file in the report file system.
FrxAPI::popData public function Pop data off of the stack.
FrxAPI::pushData public function Push data onto the Stack
FrxAPI::report public function Run a report with a particular format. 1
FrxAPI::reportFileSystem public function Get the current report file system.
FrxAPI::setDataContext public function Set Data context by id.
FrxAPI::setDocument public function Change to a specific document type.
FrxAPI::skins public function Get list of skins.
FrxSection::$lastClass public property
FrxSection::$template private property
FrxSection::$templateName public property
FrxSection::configForm public function Generate configuration.
FrxSection::configValidate public function Validate the configuration
FrxSection::generate public function Build document from the existing template. Overrides TemplateInterface::generate
FrxSection::scrapeConfig public function [@inheritdoc} Overrides TemplateInterface::scrapeConfig
TemplateBase::$columns public property
TemplateBase::$configuration public property @var array Confiuration of template
TemplateBase::$id public property
TemplateBase::$name public property
TemplateBase::$numeric_columns public property
TemplateBase::$xmlns public property
TemplateBase::columns public function Extract a list of columns from the data context.
TemplateBase::configure public function Overrides TemplateInterface::configure
TemplateBase::innerXML public function Return the inside xml of the current node Overrides FrxAPI::innerXML