Beispiel #1
0
 /**
  * Split the $message into sections and apply the sections to the template
  *
  * @param string $message If passed, this will be used as the source of the sections
  * @return string The modified message with all the sections replaced
  */
 public function apply_template($message = null)
 {
     if (is_null($message)) {
         $message = $this->message;
     }
     if (empty($this->template)) {
         // no template set. simply return the message
         return $message;
     }
     $tpl = new FUE_Email_Template($this->template);
     $sections = $tpl->get_sections();
     $contents = $tpl->get_contents();
     if (empty($contents)) {
         // nothing to process
         return $message;
     }
     foreach ($sections as $section) {
         $section_body = fue_str_search('{section:' . $section . '}', '{/section}', $message);
         if (!empty($section_body)) {
             $contents = str_replace('{section:' . $section . '}', $section_body[0], $contents);
         }
     }
     // remove unused sections from $contents
     foreach ($sections as $section) {
         $contents = str_replace('{section:' . $section . '}', '', $contents);
     }
     return apply_filters('fue_email_apply_template', $contents, $this);
 }