class FrxEmailMerge in Forena Reports 8
Email Merge Template
Plugin annotation
@FrxTemplate(id="FrxEmailMerge", name="Email Merge")
Hierarchy
- class \Drupal\forena\Template\TemplateBase implements TemplateInterface uses FrxAPI
- class \Drupal\forena\Template\FrxEmailMerge
Expanded class hierarchy of FrxEmailMerge
File
- src/
FrxPlugin/ Template/ FrxEmailMerge.php, line 12 - FrxEmailMerge Email merge template.
Namespace
Drupal\forena\TemplateView source
class FrxEmailMerge extends TemplateBase {
public $templateName = 'Mail Merge';
public $email_input_format;
public function __construct() {
parent::__construct();
$this->email_input_format = \Drupal::config('forena.settings')
->get('email_input_format');
$this->doc_types = array(
'email',
);
}
public function scrapeConfig(\SimpleXMLElement $xml) {
$config = array();
$config['class'] = get_class($this);
$config['from'] = html_entity_decode($this
->extractXPathInnerHTML("*//*[@class='email-header-from']", $this->reportDocDomNode));
$config['to'] = html_entity_decode($this
->extractXPathInnerHTML("*//*[@class='email-header-to']", $this->reportDocDomNode));
$config['cc'] = html_entity_decode($this
->extractXPathInnerHTML("*//*[@class='email-header-cc']", $this->reportDocDomNode));
$config['bcc'] = html_entity_decode($this
->extractXPathInnerHTML("*//*[@class='email-header-bcc']", $this->reportDocDomNode));
$config['subject'] = $this
->extractXPathInnerHTML("*//*[@class='email-header-subject']", $this->reportDocDomNode);
$config['body']['value'] = $this
->extractXPathInnerHTML("*//*[@class='email-body']", $this->reportDocDomNode);
return $config;
}
public function configForm($config) {
$form_ctl['from'] = array(
'#type' => 'textfield',
'#title' => t('From'),
'#default_value' => @$config['from'],
);
$form_ctl['to'] = array(
'#type' => 'textfield',
'#title' => t('To'),
'#default_value' => @$config['to'],
);
$form_ctl['cc'] = array(
'#type' => 'textfield',
'#title' => t('Cc'),
'#default_value' => @$config['cc'],
);
$form_ctl['bcc'] = array(
'#type' => 'textfield',
'#title' => t('Bcc'),
'#default_value' => @$config['bcc'],
);
$form_ctl['subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#default_value' => @$config['subject'],
);
$form_ctl['body'] = array(
'#type' => 'text_format',
'#title' => t('Message'),
"#format" => $this->email_input_format,
'#default_value' => @$config['body']['value'],
);
return $form_ctl;
}
public function configValidate(&$config) {
$this
->validateTextFormats($config, array(
'body',
));
}
public function generate() {
$config = $this->configuration;
$from = @$config['from'];
$to = @$config['to'];
$cc = @$config['cc'];
$bcc = @$config['bcc'];
$subject = @$config['subject'];
$body = @$config['body'];
$body = $body['value'];
$config['foreach'] = "*";
$div = $this
->blockDiv($config);
$this
->removeChildren($div);
$doc = $this
->addNode($div, 4, 'div', NULL, array(
'class' => 'email-document',
));
$header = $this
->addNode($doc, 6, 'div', NULL, array(
'class' => 'email-header',
));
$table = $this
->addNode($header, 8, 'table');
$tr = $this
->addNode($table, 10, 'tr');
$td = $this
->addNode($tr, 12, 'th', 'From');
$td = $this
->addNode($tr, 12, 'td', htmlentities($from), array(
'class' => 'email-header-from',
));
$tr = $this
->addNode($table, 10, 'tr');
$td = $this
->addNode($tr, 12, 'th', 'To');
$td = $this
->addNode($tr, 12, 'td', htmlentities($to), array(
'class' => 'email-header-to',
));
if ($cc) {
$tr = $this
->addNode($table, 10, 'tr');
$td = $this
->addNode($tr, 12, 'th', 'Cc');
$td = $this
->addNode($tr, 12, 'td', htmlentities($cc), array(
'class' => 'email-header-cc',
));
}
if ($bcc) {
$tr = $this
->addNode($table, 10, 'tr');
$td = $this
->addNode($tr, 12, 'th', 'Bcc');
$td = $this
->addNode($tr, 12, 'td', htmlentities($bcc), array(
'class' => 'email-header-bcc',
));
}
$tr = $this
->addNode($table, 10, 'tr');
$td = $this
->addNode($tr, 12, 'th', 'Subject');
$td = $this
->addNode($tr, 12, 'td', $subject, array(
'class' => 'email-header-subject',
));
$email_body = $this
->addNode($doc, 6, 'div', NULL, array(
'class' => 'email-body',
));
$p = $this
->addFragment($email_body, $body);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FrxAPI:: |
public | function | Returns containing application service | |
FrxAPI:: |
public | function | Get the current data context. | |
FrxAPI:: |
public | function | ||
FrxAPI:: |
public | function | Returns the data manager service | |
FrxAPI:: |
public | function | Return Data Service | |
FrxAPI:: |
public | function | Returns the fornea document manager | |
FrxAPI:: |
public | function | Report an error | |
FrxAPI:: |
public | function | Get the context of a specific id. | |
FrxAPI:: |
public | function | Get the current document | |
FrxAPI:: |
public | function | Load the contents of a file in the report file system. | |
FrxAPI:: |
public | function | Pop data off of the stack. | |
FrxAPI:: |
public | function | Push data onto the Stack | |
FrxAPI:: |
public | function | Run a report with a particular format. | 1 |
FrxAPI:: |
public | function | Get the current report file system. | |
FrxAPI:: |
public | function | Set Data context by id. | |
FrxAPI:: |
public | function | Change to a specific document type. | |
FrxAPI:: |
public | function | Get list of skins. | |
FrxEmailMerge:: |
public | property | ||
FrxEmailMerge:: |
public | property | ||
FrxEmailMerge:: |
public | function | ||
FrxEmailMerge:: |
public | function | ||
FrxEmailMerge:: |
public | function |
Overrides TemplateInterface:: |
|
FrxEmailMerge:: |
public | function |
Overrides TemplateInterface:: |
|
FrxEmailMerge:: |
public | function | ||
TemplateBase:: |
public | property | ||
TemplateBase:: |
public | property | @var array Confiuration of template | |
TemplateBase:: |
public | property | ||
TemplateBase:: |
public | property | ||
TemplateBase:: |
public | property | ||
TemplateBase:: |
public | property | ||
TemplateBase:: |
public | function | Extract a list of columns from the data context. | |
TemplateBase:: |
public | function |
Overrides TemplateInterface:: |
|
TemplateBase:: |
public | function |
Return the inside xml of the current node Overrides FrxAPI:: |