ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMailTemplateContext Class Reference

Class ilMailTemplateContext. More...

+ Inheritance diagram for ilMailTemplateContext:
+ Collaboration diagram for ilMailTemplateContext:

Public Member Functions

 setLanguage ($language)
 
 getId ()
 Returns a unique (in the context of mail template contexts) id. More...
 
 getTitle ()
 Returns a translated title (depending on the current language) which is displayed in the user interface. More...
 
 getDescription ()
 Returns a translated description (depending on the current language) which is displayed in the user interface. More...
 
 getPlaceholders ()
 Return an array of placeholders. More...
 
 getSpecificPlaceholders ()
 Return an array of placeholders. More...
 
 resolveSpecificPlaceholder ($placeholder_id, array $context_parameters, ilObjUser $recipient=null, $html_markup=false)
 
 resolvePlaceholder ($placeholder_id, array $context_parameters, ilObjUser $recipient=null, $html_markup=false)
 

Protected Member Functions

 initLanguage (ilObjUser $user)
 
 initLanguageByIso2Code ($a_code)
 Init language by ISO2 code. More...
 

Protected Attributes

 $language
 

Detailed Description

Member Function Documentation

◆ getDescription()

ilMailTemplateContext::getDescription ( )
abstract

Returns a translated description (depending on the current language) which is displayed in the user interface.

Returns
string

Referenced by ilMailTemplateGenericContext\getId(), and setLanguage().

+ Here is the caller graph for this function:

◆ getId()

ilMailTemplateContext::getId ( )
abstract

Returns a unique (in the context of mail template contexts) id.

Returns
string

Referenced by ilMailTemplateService\createEntry(), and setLanguage().

+ Here is the caller graph for this function:

◆ getPlaceholders()

ilMailTemplateContext::getPlaceholders ( )
final

Return an array of placeholders.

Returns
array

Definition at line 96 of file class.ilMailTemplateContext.php.

References array, getSpecificPlaceholders(), and resolveSpecificPlaceholder().

97  {
98  $placeholders = self::getGenericPlaceholders();
99  $specific = $this->getSpecificPlaceholders();
100 
101  return $placeholders + $specific;
102  }
getSpecificPlaceholders()
Return an array of placeholders.
+ Here is the call graph for this function:

◆ getSpecificPlaceholders()

ilMailTemplateContext::getSpecificPlaceholders ( )
abstract

◆ getTitle()

ilMailTemplateContext::getTitle ( )
abstract

Returns a translated title (depending on the current language) which is displayed in the user interface.

Returns
string

Referenced by ilMailTemplateGenericContext\getId(), and setLanguage().

+ Here is the caller graph for this function:

◆ initLanguage()

ilMailTemplateContext::initLanguage ( ilObjUser  $user)
protected
Parameters
ilObjUser$user

Definition at line 189 of file class.ilMailTemplateContext.php.

References ilObjUser\getLanguage(), and initLanguageByIso2Code().

Referenced by resolvePlaceholder().

190  {
191  $this->initLanguageByIso2Code($user->getLanguage());
192  }
initLanguageByIso2Code($a_code)
Init language by ISO2 code.
getLanguage()
returns a 2char-language-string public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initLanguageByIso2Code()

ilMailTemplateContext::initLanguageByIso2Code (   $a_code)
protected

Init language by ISO2 code.

Parameters
string$a_code

Definition at line 198 of file class.ilMailTemplateContext.php.

References ilLanguageFactory\_getLanguage().

Referenced by initLanguage().

199  {
200  $this->language = ilLanguageFactory::_getLanguage($a_code);
201  $this->language->loadLanguageModule('mail');
202  }
static _getLanguage($a_lang_key='')
Get langauge object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolvePlaceholder()

ilMailTemplateContext::resolvePlaceholder (   $placeholder_id,
array  $context_parameters,
ilObjUser  $recipient = null,
  $html_markup = false 
)
Parameters
string$placeholder_idThe unique (in the context of your class) placeholder id
array$context_parametersThe context parameters given by the mail system (array of key/value pairs)
ilObjUser | null$recipientThe recipient for this mail
bool$html_markupA flag whether or not the return value may contain HTML markup
Returns
string

Definition at line 126 of file class.ilMailTemplateContext.php.

References ilDatePresentation\getLanguage(), initLanguage(), resolveSpecificPlaceholder(), and ilDatePresentation\setLanguage().

127  {
128  if($recipient !== null)
129  {
130  $this->initLanguage($recipient);
131  }
132 
133  $old_lang = ilDatePresentation::getLanguage();
134  ilDatePresentation::setLanguage($this->getLanguage());
135 
136  $resolved = '';
137 
138  switch(true)
139  {
140  case ('mail_salutation' == $placeholder_id && $recipient !== null):
141  switch($recipient->getGender())
142  {
143  case 'f':
144  $resolved = $this->getLanguage()->txt('salutation_f');
145  break;
146 
147  case 'm':
148  $resolved = $this->getLanguage()->txt('salutation_m');
149  break;
150 
151  default:
152  $resolved = $this->getLanguage()->txt('salutation');
153  }
154  break;
155 
156  case ('first_name' == $placeholder_id && $recipient !== null):
157  $resolved = $recipient->getFirstname();
158  break;
159 
160  case ('last_name' == $placeholder_id && $recipient !== null):
161  $resolved = $recipient->getLastname();
162  break;
163 
164  case ('login' == $placeholder_id && $recipient !== null):
165  $resolved = $recipient->getLogin();
166  break;
167 
168  case 'ilias_url' == $placeholder_id:
169  $resolved = ILIAS_HTTP_PATH . '/login.php?client_id=' . CLIENT_ID;
170  break;
171 
172  case 'client_name' == $placeholder_id:
173  $resolved = CLIENT_NAME;
174  break;
175 
176  case !in_array($placeholder_id, array_keys(self::getGenericPlaceholders())):
177  $resolved = $this->resolveSpecificPlaceholder($placeholder_id, $context_parameters, $recipient, $html_markup);
178  break;
179  }
180 
182 
183  return $resolved;
184  }
getLogin()
get login / username public
getFirstname()
get firstname public
resolveSpecificPlaceholder($placeholder_id, array $context_parameters, ilObjUser $recipient=null, $html_markup=false)
static setLanguage($a_lng)
set language
getLastname()
get lastname public
static getLanguage()
set language
getGender()
get gender public
+ Here is the call graph for this function:

◆ resolveSpecificPlaceholder()

ilMailTemplateContext::resolveSpecificPlaceholder (   $placeholder_id,
array  $context_parameters,
ilObjUser  $recipient = null,
  $html_markup = false 
)
abstract
Parameters
string$placeholder_id
array$context_parameters
ilObjUser | null$recipient
bool$html_markup
Returns
string

Referenced by ilCourseMailTemplateMemberContext\getDescription(), ilCourseMailTemplateTutorContext\getDescription(), ilSurveyMailTemplateReminderContext\getDescription(), ilScormMailTemplateLPContext\getDescription(), getPlaceholders(), and resolvePlaceholder().

+ Here is the caller graph for this function:

◆ setLanguage()

ilMailTemplateContext::setLanguage (   $language)
Parameters
ilLanguage | null$language

Definition at line 34 of file class.ilMailTemplateContext.php.

References $language, $lng, array, getDescription(), getId(), and getTitle().

+ Here is the call graph for this function:

Field Documentation

◆ $language

ilMailTemplateContext::$language
protected

Definition at line 16 of file class.ilMailTemplateContext.php.

Referenced by setLanguage().


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