You are here

public function FrxControls::emaildocument in Forena Reports 6

Same name and namespace in other branches
  1. 6.2 plugins/FrxControls.inc \FrxControls::emailDocument()
  2. 7 plugins/FrxControls.inc \FrxControls::emaildocument()
  3. 7.2 plugins/FrxControls.inc \FrxControls::emailDocument()

File

plugins/FrxControls.inc, line 227
contains various methods for extending report formating, layout, transformation and design.

Class

FrxControls
@file contains various methods for extending report formating, layout, transformation and design.

Code

public function emaildocument($body, $options) {
  $doc = new DOMDocument('1.0', 'UTF-8');
  $doc->strictErrorChecking = FALSE;
  $doc
    ->loadHTML($body);
  $xml = simplexml_import_dom($doc);
  $docs = $xml
    ->xpath('.//*[@class="email-document"]');
  foreach ($docs as $doc) {
    $from = $doc
      ->xpath('.//*[@class="email-header-from"]');
    $from = $from ? (string) $from[0] : '';
    $subject = $doc
      ->xpath('.//*[@class="email-header-subject"]');
    $subject = $subject ? (string) $subject[0] : '';
    $to = $doc
      ->xpath('.//*[@class="email-header-to"]');
    $to = $to ? (string) $to[0] : '';
    $body = $doc
      ->xpath('.//*[@class="email-body"]');
    $body = $body ? $body[0]
      ->asXML() : $body;
    $email = array(
      'to' => $to,
      'from' => $from,
      'parms' => array(
        'subject' => $subject,
        'body' => $body,
      ),
    );
    $emails[] = $email;
  }
  $count = count($docs);
  if ($count) {
    $output = drupal_get_form('forena_confirm_email', $emails, $count);
  }
  else {
    $output = $body;
  }
  return $output;
}