You are here

class Messaging_Template_Part in Messaging 6.3

Each text part to be rendered independently

Hierarchy

Expanded class hierarchy of Messaging_Template_Part

File

messaging_template/messaging_template.inc, line 515
Base classes for messaging templates

View source
class Messaging_Template_Part implements Messaging_Template_Element {

  // Part key and default value
  public $key;
  public $default;
  public $text;

  // Parent template object
  protected $template;

  // Constructor
  function __construct($template, $key, $default = NULL) {
    $this->template = $template;
    $this->key = $key;
    $this->default = $default;
  }

  // Get content as string
  function get_content($method, $language) {
    if (!isset($this->text[$method][$language->language])) {
      if ($part = $this->template
        ->get_part($this->key, NULL, $method, $language)) {
        $text = $part->template;
      }
      else {
        $text = isset($this->default) ? $this->default : '';
      }
      $this->text[$method][$language->language] = $text;
    }
    return $this->text[$method][$language->language];
  }

  // This element needs token replacement
  function needs_replace() {
    return TRUE;
  }

  // Reset text
  function reset($recurse = FALSE) {
    $this->text = NULL;
  }

}

Members