You are here

public function RendererBase::validateTextFormats in Forena Reports 8

Helper function for validating text_format type controls.

Parameters

array $config: Configuration to valiate

array $elements: Form elements to validate

Return value

array key value pair containing lement names and any error messages related to those elements.

1 call to RendererBase::validateTextFormats()
RendererBase::configValidate in src/FrxPlugin/Renderer/RendererBase.php
Default configuration validator. Simply validates header and footer attributes.

File

src/FrxPlugin/Renderer/RendererBase.php, line 556
FrxRenderer.php Base class for FrxAPI custom Renderer @author davidmetzler

Class

RendererBase
Crosstab Renderer

Namespace

Drupal\forena\FrxPlugin\Renderer

Code

public function validateTextFormats(&$config, $elements) {
  $temp_dom = FrxAPI::tempDOM();
  $errors = array();
  foreach ($elements as $element) {
    if (isset($config[$element]['value'])) {
      if ($config[$element]['value']) {
        $body_xml = '<?xml version="1.0" encoding="UTF-8"?>
           <!DOCTYPE root [
           <!ENTITY nbsp "&#160;">
           ]><html xmlns:frx="' . $this->xmlns . '"><body>' . $config[$element]['value'] . '</body></html>';
        @$temp_dom
          ->loadXML($body_xml);
        if (!$temp_dom->documentElement) {
          $errors[$element] = t('Invalid XHTML in %s', array(
            '%s' => $element,
          ));
        }
      }
    }
  }
  return $errors;
}