ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMailTemplatePlaceholderResolver Class Reference

Class ilMailTemplaceProcessor. More...

+ Collaboration diagram for ilMailTemplatePlaceholderResolver:

Public Member Functions

 __construct (ilMailTemplateContext $context, $a_message)
 ilMailTemplateProcessor constructor. More...
 
 resolve (ilObjUser $user=null, $a_context_params=array(), $replace_empty=true)
 

Protected Attributes

 $context
 
 $message
 

Detailed Description

Class ilMailTemplaceProcessor.

Definition at line 7 of file class.ilMailTemplatePlaceholderResolver.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailTemplatePlaceholderResolver::__construct ( ilMailTemplateContext  $context,
  $a_message 
)

ilMailTemplateProcessor constructor.

Parameters
ilMailTemplateContext$context
string$a_message

Definition at line 24 of file class.ilMailTemplatePlaceholderResolver.php.

References $context.

25  {
26  $this->context = $context;
27  $this->message = $a_message;
28  }

Member Function Documentation

◆ resolve()

ilMailTemplatePlaceholderResolver::resolve ( ilObjUser  $user = null,
  $a_context_params = array(),
  $replace_empty = true 
)
Parameters
ilObjUser | null$user
array$a_context_params
$replace_emptyboolean
Returns
string

Definition at line 37 of file class.ilMailTemplatePlaceholderResolver.php.

References $key, $message, and $result.

38  {
40 
41  foreach ($this->context->getPlaceholders() as $key => $ph_definition) {
42  $result = $this->context->resolvePlaceholder($key, $a_context_params, $user);
43  if (!$replace_empty && strlen($result) == 0) {
44  continue;
45  }
46 
47  $startTag = '\[IF_' . strtoupper($key) . '\]';
48  $endTag = '\[\/IF_' . strtoupper($key) . '\]';
49 
50  if (strlen($result) > 0) {
51  $message = str_replace('[' . $ph_definition['placeholder'] . ']', $result, $message);
52 
53  if (array_key_exists('supportsCondition', $ph_definition) && $ph_definition['supportsCondition']) {
54  $message = preg_replace('/' . $startTag . '(.*?)' . $endTag . '/imsU', '$1', $message);
55  }
56  } else {
57  $message = preg_replace('/[[:space:]]{1,1}\[' . $ph_definition['placeholder'] . '\][[:space:]]{1,1}/ims', ' ', $message);
58  $message = preg_replace('/\[' . $ph_definition['placeholder'] . '\]/ims', '', $message);
59 
60  if (array_key_exists('supportsCondition', $ph_definition) && $ph_definition['supportsCondition']) {
61  $message = preg_replace('/' . $startTag . '.*?' . $endTag . '/imsU', '', $message);
62  }
63  }
64  }
65 
66  return $message;
67  }
$result
$key
Definition: croninfo.php:18

Field Documentation

◆ $context

ilMailTemplatePlaceholderResolver::$context
protected

Definition at line 12 of file class.ilMailTemplatePlaceholderResolver.php.

Referenced by __construct().

◆ $message

ilMailTemplatePlaceholderResolver::$message
protected

Definition at line 17 of file class.ilMailTemplatePlaceholderResolver.php.

Referenced by resolve().


The documentation for this class was generated from the following file: