class Messaging_Message_Template in Messaging 7
Template for a full message (subject, body, etc..)
Hierarchy
- class \Messaging_Template
- class \Messaging_Message_Template implements Messaging_Message_Render
Expanded class hierarchy of Messaging_Message_Template
File
- messaging_template/
messaging_template.inc, line 417 - Drupal Messaging Framework - Text filtering functions
View source
class Messaging_Message_Template extends Messaging_Template implements Messaging_Message_Render {
public $method = 'default';
/**
* Set message elements
*/
protected function get_parts() {
return array(
'subject',
'body',
);
}
/**
* Get Message_Object with this template linked
*/
public function build_message($options = array()) {
$message = new Messaging_Message($options);
$message
->set_template($this);
return $message;
}
/**
* Set destination (and reset built elements)
*/
function set_destination($destination) {
$this
->add_object('destination', $destination);
$this
->add_object('user', $destination
->get_user());
$this
->reset();
return $this;
}
/**
* Set text format
*/
public function set_format($format) {
$this->format = $format;
$this
->reset();
return $this;
}
/**
* Set sending method
*/
public function set_method($method) {
$this->method = $method;
$this
->reset();
return $this;
}
/*
* Get defaults for elements
*/
protected function element_defaults($name) {
switch ($name) {
case 'subject':
$defaults = array(
'#type' => 'messaging_template_subject',
);
break;
case 'body':
$defaults = array(
'#type' => 'messaging_template_body',
'#parts' => array(
'header',
'content',
'footer',
),
);
break;
case 'header':
case 'content':
case 'footer':
$defaults = array(
'#type' => 'messaging_template_text',
);
break;
default:
$defaults = array();
}
return $defaults + parent::element_defaults($name);
}
/**
* Default texts for this template, may need token replacement
*/
protected function default_text($type, $options) {
switch ($type) {
case 'subject':
return array(
'#tokens' => TRUE,
'#markup' => t('Message from [site:name]', array(), $options),
);
case 'footer':
return array(
'#type' => 'messaging_link',
'#tokens' => TRUE,
'#text' => t('Message from [site:name]', array(), $options),
'#url' => '[site:url]',
);
default:
return parent::default_text($type, $options);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Messaging_Message_Template:: |
public | property | ||
Messaging_Message_Template:: |
public | function | Get Message_Object with this template linked | |
Messaging_Message_Template:: |
protected | function |
Default texts for this template, may need token replacement Overrides Messaging_Template:: |
|
Messaging_Message_Template:: |
protected | function |
Overrides Messaging_Template:: |
|
Messaging_Message_Template:: |
protected | function |
Set message elements Overrides Messaging_Template:: |
|
Messaging_Message_Template:: |
function |
Set destination (and reset built elements) Overrides Messaging_Message_Render:: |
||
Messaging_Message_Template:: |
public | function |
Set text format Overrides Messaging_Message_Render:: |
|
Messaging_Message_Template:: |
public | function |
Set sending method Overrides Messaging_Message_Render:: |
|
Messaging_Template:: |
public | property | ||
Messaging_Template:: |
public | property | ||
Messaging_Template:: |
protected | property | ||
Messaging_Template:: |
protected | property | ||
Messaging_Template:: |
protected | property | ||
Messaging_Template:: |
public | property | ||
Messaging_Template:: |
protected | property | ||
Messaging_Template:: |
function | Add element ready for drupal_render() | ||
Messaging_Template:: |
function | Add item of unknown type | ||
Messaging_Template:: |
function | Add object to the list | ||
Messaging_Template:: |
function | Add string | ||
Messaging_Template:: |
function | Add text object | ||
Messaging_Template:: |
public | function | Build all elements, return array | |
Messaging_Template:: |
public | function | Build a named element | |
Messaging_Template:: |
public | function | Build template parts | |
Messaging_Template:: |
protected | function | Build a message text element | |
Messaging_Template:: |
protected | function | Get default elements | |
Messaging_Template:: |
protected | function | Build a message element with optional text replacement | |
Messaging_Template:: |
protected | function | Perform token replace within an element | |
Messaging_Template:: |
function | Get element from elements or default texts | ||
Messaging_Template:: |
function | Get objects from this template (include parent's ones) | ||
Messaging_Template:: |
function | Get options for texts, translations, etc | ||
Messaging_Template:: |
public | function | Get text element from this template | |
Messaging_Template:: |
function | Get tokens for templates | ||
Messaging_Template:: |
public | function | Render elements, return string | |
Messaging_Template:: |
public | function | Reset built elements | |
Messaging_Template:: |
function | Set language | ||
Messaging_Template:: |
function | Set options | ||
Messaging_Template:: |
function | Set array of options | ||
Messaging_Template:: |
function | Set parent text | ||
Messaging_Template:: |
protected | function | Tokens for this template. Will be stored | |
Messaging_Template:: |
public | function | Do token replacement with this template's objects |