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

Class ilMailTemplateContext. More...

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

Public Member Functions

 getLanguage ()
 
 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
 

Static Private Member Functions

static getGenericPlaceholders ()
 

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

Reimplemented in ilCourseMailTemplateMemberContext, ilCourseMailTemplateTutorContext, ilScormMailTemplateLPContext, ilSurveyMailTemplateReminderContext, and ilMailTemplateGenericContext.

◆ getGenericPlaceholders()

static ilMailTemplateContext::getGenericPlaceholders ( )
staticfinalprivate
Returns
array

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

58 {
59 global $DIC;
60
61 return array(
62 'mail_salutation' => array(
63 'placeholder' => 'MAIL_SALUTATION',
64 'label' => $DIC->language()->txt('mail_nacc_salutation')
65 ),
66 'first_name' => array(
67 'placeholder' => 'FIRST_NAME',
68 'label' => $DIC->language()->txt('firstname')
69 ),
70 'last_name' => array(
71 'placeholder' => 'LAST_NAME',
72 'label' => $DIC->language()->txt('lastname')
73 ),
74 'login' => array(
75 'placeholder' => 'LOGIN',
76 'label' => $DIC->language()->txt('mail_nacc_login')
77 ),
78 'title' => array(
79 'placeholder' => 'TITLE',
80 'label' => $DIC->language()->txt('mail_nacc_title'),
81 'supportsCondition' => true
82 ),
83 'ilias_url' => array(
84 'placeholder' => 'ILIAS_URL',
85 'label' => $DIC->language()->txt('mail_nacc_ilias_url')
86 ),
87 'client_name' => array(
88 'placeholder' => 'CLIENT_NAME',
89 'label' => $DIC->language()->txt('mail_nacc_client_name')
90 )
91 );
92 }
global $DIC
Definition: saml.php:7

References $DIC.

Referenced by getPlaceholders().

+ 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

Reimplemented in ilCourseMailTemplateMemberContext, ilCourseMailTemplateTutorContext, ilScormMailTemplateLPContext, ilSurveyMailTemplateReminderContext, and ilMailTemplateGenericContext.

Referenced by ilMailTemplateService\createEntry().

+ Here is the caller graph for this function:

◆ getLanguage()

ilMailTemplateContext::getLanguage ( )
Returns
ilLanguage|null

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

22 {
23 global $DIC;
24
25 return $this->language ? $this->language : $DIC->language();
26 }

References $DIC.

Referenced by resolvePlaceholder().

+ Here is the caller graph for this function:

◆ getPlaceholders()

ilMailTemplateContext::getPlaceholders ( )
final

Return an array of placeholders.

Returns
array

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

99 {
100 $placeholders = self::getGenericPlaceholders();
101 $specific = $this->getSpecificPlaceholders();
102
103 return $placeholders + $specific;
104 }
getSpecificPlaceholders()
Return an array of placeholders.

References getGenericPlaceholders(), and getSpecificPlaceholders().

+ Here is the call graph for this function:

◆ getSpecificPlaceholders()

ilMailTemplateContext::getSpecificPlaceholders ( )
abstract

Return an array of placeholders.

Returns
array

Reimplemented in ilMailTemplateGenericContext.

Referenced by getPlaceholders().

+ Here is the caller graph for this function:

◆ getTitle()

ilMailTemplateContext::getTitle ( )
abstract

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

Returns
string

Reimplemented in ilCourseMailTemplateMemberContext, ilCourseMailTemplateTutorContext, ilScormMailTemplateLPContext, ilSurveyMailTemplateReminderContext, and ilMailTemplateGenericContext.

◆ initLanguage()

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

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

197 {
198 $this->initLanguageByIso2Code($user->getLanguage());
199 }
initLanguageByIso2Code($a_code)
Init language by ISO2 code.
getLanguage()
returns a 2char-language-string @access public

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

Referenced by resolvePlaceholder().

+ 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 205 of file class.ilMailTemplateContext.php.

206 {
207 $this->language = ilLanguageFactory::_getLanguage($a_code);
208 $this->language->loadLanguageModule('mail');
209 }
static _getLanguage($a_lang_key='')
Get langauge object.

References ilLanguageFactory\_getLanguage().

Referenced by initLanguage().

+ 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 128 of file class.ilMailTemplateContext.php.

129 {
130 if ($recipient !== null) {
131 $this->initLanguage($recipient);
132 }
133
136
137 $resolved = '';
138
139 switch (true) {
140 case ('mail_salutation' == $placeholder_id && $recipient !== null):
141 switch ($recipient->getGender()) {
142 case 'f':
143 $resolved = $this->getLanguage()->txt('mail_salutation_f');
144 break;
145
146 case 'm':
147 $resolved = $this->getLanguage()->txt('mail_salutation_m');
148 break;
149
150 case 'n':
151 $resolved = $this->getLanguage()->txt('mail_salutation_n');
152 break;
153
154 default:
155 $resolved = $this->getLanguage()->txt('mail_salutation_n');
156 }
157 break;
158
159 case ('first_name' == $placeholder_id && $recipient !== null):
160 $resolved = $recipient->getFirstname();
161 break;
162
163 case ('last_name' == $placeholder_id && $recipient !== null):
164 $resolved = $recipient->getLastname();
165 break;
166
167 case ('login' == $placeholder_id && $recipient !== null):
168 $resolved = $recipient->getLogin();
169 break;
170
171 case ('title' == $placeholder_id && $recipient !== null):
172 $resolved = $recipient->getUTitle();
173 break;
174
175 case 'ilias_url' == $placeholder_id:
176 $resolved = ILIAS_HTTP_PATH . '/login.php?client_id=' . CLIENT_ID;
177 break;
178
179 case 'client_name' == $placeholder_id:
180 $resolved = CLIENT_NAME;
181 break;
182
183 case !in_array($placeholder_id, array_keys(self::getGenericPlaceholders())):
184 $resolved = $this->resolveSpecificPlaceholder($placeholder_id, $context_parameters, $recipient, $html_markup);
185 break;
186 }
187
189
190 return $resolved;
191 }
static getLanguage()
set language
static setLanguage($a_lng)
set language
resolveSpecificPlaceholder($placeholder_id, array $context_parameters, ilObjUser $recipient=null, $html_markup=false)
getLastname()
get lastname @access public
getUTitle()
get user title (note: don't mix up this method with getTitle() that is derived from ilObject and gets...
getFirstname()
get firstname @access public
getLogin()
get login / username @access public
getGender()
get gender @access public

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

+ 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

Reimplemented in ilMailTemplateGenericContext.

Referenced by resolvePlaceholder().

+ Here is the caller graph for this function:

◆ setLanguage()

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

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

32 {
33 $this->language = $language;
34 }

References $language.

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: