ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SimpleSAML_XHTML_Template Class Reference
+ Collaboration diagram for SimpleSAML_XHTML_Template:

Public Member Functions

 __construct (\SimpleSAML_Configuration $configuration, $template, $defaultDictionary=null)
 Constructor. More...
 
 show ()
 Show the template to the user. More...
 
 getTranslator ()
 Return the internal translator object used by this template. More...
 
 getTwig ()
 Get the current instance of Twig in use. More...
 
 getAttributeTranslation ($name)
 
 getLanguage ()
 
 setLanguage ($language, $setLanguageCookie=true)
 
 getTag ($tag)
 
 getTranslation ($translations)
 Temporary wrapper for \SimpleSAML\Locale\Translate::getPreferredTranslation(). More...
 
 includeInlineTranslation ($tag, $translation)
 Wraps Translate->includeInlineTranslation() More...
 
 includeLanguageFile ($file, $otherConfig=null)
 
 t ( $tag, $replacements=array(), $fallbackdefault=true, $oldreplacements=array(), $striptags=false)
 Wrap Language->t to translate tag into the current language, with a fallback to english. More...
 

Static Public Member Functions

static getLanguageCookie ()
 
static setLanguageCookie ($language)
 
static lang_merge ($def, $lang)
 Merge two translation arrays. More...
 
static noop ($tag)
 Behave like Language->noop to mark a tag for translation but actually do it later. More...
 

Data Fields

 $data = array()
 

Private Member Functions

 normalizeTemplateName ($templateName)
 Normalize the name of the template to one of the possible alternatives. More...
 
 setupTwigTemplatepaths ()
 Set up the places where twig can look for templates. More...
 
 setupTwig ()
 Setup twig. More...
 
 findThemeTemplateDirs ()
 Add overriding templates from the configured theme. More...
 
 getModuleTemplateDir ($module)
 Get the template directory of a module, if it exists. More...
 
 generateLanguageBar ()
 Generate an array for its use in the language bar, indexed by the ISO 639-2 codes of the languages available, containing their localized names and the URL that should be used in order to change to that language. More...
 
 twigDefaultContext ()
 Set some default context. More...
 
 findModuleAndTemplateName ($template)
 Find module the template is in, if any. More...
 
 findTemplatePath ($template, $throw_exception=true)
 Find template path. More...
 
 getLanguageList ()
 Wraps Language->getLanguageList. More...
 
 includeAtTemplateBase ($file)
 Includes a file relative to the template base directory. More...
 
 isLanguageRTL ()
 Wrap Language->isLanguageRTL. More...
 

Private Attributes

 $translator
 
 $localization
 
 $configuration
 
 $template = 'default.php'
 
 $twig
 
 $twig_template
 
 $module
 Current module, if any. More...
 
 $controller
 
 $theme
 

Detailed Description

Definition at line 14 of file Template.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleSAML_XHTML_Template::__construct ( \SimpleSAML_Configuration  $configuration,
  $template,
  $defaultDictionary = null 
)

Constructor.

Parameters
SimpleSAML_Configuration$configurationConfiguration object
string$templateWhich template file to load
string | null$defaultDictionaryThe default dictionary where tags will come from.

Definition at line 100 of file Template.php.

101 {
102 $this->configuration = $configuration;
103 $this->template = $template;
104 // TODO: do not remove the slash from the beginning, change the templates instead!
105 $this->data['baseurlpath'] = ltrim($this->configuration->getBasePath(), '/');
106
107 // parse module and template name
108 list($this->module) = $this->findModuleAndTemplateName($template);
109
110 // parse config to find theme and module theme is in, if any
111 list($this->theme['module'], $this->theme['name']) = self::findModuleAndTemplateName(
112 $this->configuration->getString('theme.use', 'default')
113 );
114
115 // initialize internationalization system
116 $this->translator = new SimpleSAML\Locale\Translate($configuration, $defaultDictionary);
117 $this->localization = new \SimpleSAML\Locale\Localization($configuration);
118
119 // check if we need to attach a theme controller
120 $controller = $this->configuration->getString('theme.controller', false);
121 if ($controller && class_exists($controller) &&
122 class_implements($controller, '\SimpleSAML\XHTML\TemplateControllerInterface')
123 ) {
124 $this->controller = new $controller();
125 }
126
127 $this->twig = $this->setupTwig();
128 }
setupTwig()
Setup twig.
Definition: Template.php:194
findModuleAndTemplateName($template)
Find module the template is in, if any.
Definition: Template.php:427
$this data['403_header']

References $configuration, $controller, $template, data, findModuleAndTemplateName(), and setupTwig().

+ Here is the call graph for this function:

Member Function Documentation

◆ findModuleAndTemplateName()

SimpleSAML_XHTML_Template::findModuleAndTemplateName (   $template)
private

Find module the template is in, if any.

Parameters
string$templateThe relative path from the theme directory to the template file.
Returns
array An array with the name of the module and template

Definition at line 427 of file Template.php.

428 {
429 $tmp = explode(':', $template, 2);
430 return (count($tmp) === 2) ? array($tmp[0], $tmp[1]) : array(null, $tmp[0]);
431 }

Referenced by __construct(), and setupTwigTemplatepaths().

+ Here is the caller graph for this function:

◆ findTemplatePath()

SimpleSAML_XHTML_Template::findTemplatePath (   $template,
  $throw_exception = true 
)
private

Find template path.

This function locates the given template based on the template name. It will first search for the template in the current theme directory, and then the default theme.

The template name may be on the form <module name>:<template path>, in which case it will search for the template file in the given module.

Parameters
string$templateThe relative path from the theme directory to the template file.
Returns
string The absolute path to the template file.
Exceptions
ExceptionIf the template file couldn't be found.

Definition at line 449 of file Template.php.

450 {
451 assert(is_string($template));
452
453 list($templateModule, $templateName) = $this->findModuleAndTemplateName($template);
454 $templateModule = ($templateModule !== null) ? $templateModule : 'default';
455
456 // first check the current theme
457 if ($this->theme['module'] !== null) {
458 // .../module/<themeModule>/themes/<themeName>/<templateModule>/<templateName>
459
460 $filename = \SimpleSAML\Module::getModuleDir($this->theme['module']).
461 '/themes/'.$this->theme['name'].'/'.$templateModule.'/'.$templateName;
462 } elseif ($templateModule !== 'default') {
463 // .../module/<templateModule>/templates/<templateName>
464 $filename = \SimpleSAML\Module::getModuleDir($templateModule).'/templates/'.$templateName;
465 } else {
466 // .../templates/<theme>/<templateName>
467 $filename = $this->configuration->getPathValue('templatedir', 'templates/').$templateName;
468 }
469
470 if (file_exists($filename)) {
471 return $filename;
472 }
473
474 // not found in current theme
476 $_SERVER['PHP_SELF'].' - Template: Could not find template file ['.$template.'] at ['.
477 $filename.'] - now trying the base template'
478 );
479
480 // try default theme
481 if ($templateModule !== 'default') {
482 // .../module/<templateModule>/templates/<templateName>
483 $filename = \SimpleSAML\Module::getModuleDir($templateModule).'/templates/'.$templateName;
484 } else {
485 // .../templates/<templateName>
486 $filename = $this->configuration->getPathValue('templatedir', 'templates/').'/'.$templateName;
487 }
488
489 if (file_exists($filename)) {
490 return $filename;
491 }
492
493 // not found in default template
494 if ($throw_exception) {
495 // log error and throw exception
496 $error = 'Template: Could not find template file ['.$template.'] at ['.$filename.']';
497 \SimpleSAML\Logger::critical($_SERVER['PHP_SELF'].' - '.$error);
498
499 throw new Exception($error);
500 } else {
501 // missing template expected, return NULL
502 return null;
503 }
504 }
$filename
Definition: buildRTE.php:89
static critical($string)
Definition: Logger.php:144
static debug($string)
Definition: Logger.php:211
static getModuleDir($module)
Retrieve the base directory for a module.
Definition: Module.php:39
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

◆ findThemeTemplateDirs()

SimpleSAML_XHTML_Template::findThemeTemplateDirs ( )
private

Add overriding templates from the configured theme.

Returns
array An array of module => templatedir lookups.

Definition at line 270 of file Template.php.

271 {
272 if ($this->theme['module'] === null) { // no module involved
273 return array();
274 }
275
276 // setup directories & namespaces
277 $themeDir = \SimpleSAML\Module::getModuleDir($this->theme['module']).'/themes/'.$this->theme['name'];
278 $subdirs = scandir($themeDir);
279 if (empty($subdirs)) { // no subdirectories in the theme directory, nothing to do here
280 // this is probably wrong, log a message
281 \SimpleSAML\Logger::warning('Empty theme directory for theme "'.$this->theme['name'].'".');
282 return array();
283 }
284
285 $themeTemplateDirs = array();
286 foreach ($subdirs as $entry) {
287 // discard anything that's not a directory. Expression is negated to profit from lazy evaluation
288 if (!($entry !== '.' && $entry !== '..' && is_dir($themeDir.'/'.$entry))) {
289 continue;
290 }
291
292 // set correct name for the default namespace
293 $ns = ($entry === 'default') ? \Twig_Loader_Filesystem::MAIN_NAMESPACE : $entry;
294 $themeTemplateDirs[] = array($ns => $themeDir.'/'.$entry);
295 }
296 return $themeTemplateDirs;
297 }
static warning($string)
Definition: Logger.php:177
const MAIN_NAMESPACE
Identifier of the main namespace.
Definition: Filesystem.php:20

References SimpleSAML\Module\getModuleDir(), Twig_Loader_Filesystem\MAIN_NAMESPACE, and SimpleSAML\Logger\warning().

Referenced by setupTwigTemplatepaths().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateLanguageBar()

SimpleSAML_XHTML_Template::generateLanguageBar ( )
private

Generate an array for its use in the language bar, indexed by the ISO 639-2 codes of the languages available, containing their localized names and the URL that should be used in order to change to that language.

Returns
array The array containing information of all available languages.

Definition at line 345 of file Template.php.

346 {
347 $languages = $this->translator->getLanguage()->getLanguageList();
348 $langmap = null;
349 if (count($languages) > 1) {
350 $parameterName = $this->getTranslator()->getLanguage()->getLanguageParameterName();
351 $langmap = array();
352 foreach ($languages as $lang => $current) {
353 $lang = strtolower($lang);
354 $langname = $this->translator->getLanguage()->getLanguageLocalizedName($lang);
355 $url = false;
356 if (!$current) {
357 $url = htmlspecialchars(\SimpleSAML\Utils\HTTP::addURLParameters(
358 '',
359 array($parameterName => $lang)
360 ));
361 }
362 $langmap[$lang] = array(
363 'name' => $langname,
364 'url' => $url,
365 );
366 }
367 }
368 return $langmap;
369 }
getTranslator()
Return the internal translator object used by this template.
Definition: Template.php:512
$languages
Definition: cssgen2.php:34
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
Attribute-related utility methods.
$url

◆ getAttributeTranslation()

SimpleSAML_XHTML_Template::getAttributeTranslation (   $name)
Parameters
$name
Returns
string
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::getLanguage() instead.

Definition at line 541 of file Template.php.

542 {
543 return $this->translator->getAttributeTranslation($name);
544 }

◆ getLanguage()

SimpleSAML_XHTML_Template::getLanguage ( )
Returns
string
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::getLanguage() instead.

Definition at line 552 of file Template.php.

553 {
554 return $this->translator->getLanguage()->getLanguage();
555 }

◆ getLanguageCookie()

static SimpleSAML_XHTML_Template::getLanguageCookie ( )
static
Returns
null|string
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::getLanguageCookie() instead.

Definition at line 576 of file Template.php.

577 {
578 return \SimpleSAML\Locale\Language::getLanguageCookie();
579 }

◆ getLanguageList()

SimpleSAML_XHTML_Template::getLanguageList ( )
private

Wraps Language->getLanguageList.

Definition at line 597 of file Template.php.

598 {
599 return $this->translator->getLanguage()->getLanguageList();
600 }

◆ getModuleTemplateDir()

SimpleSAML_XHTML_Template::getModuleTemplateDir (   $module)
private

Get the template directory of a module, if it exists.

Returns
string The templates directory of a module.
Exceptions
InvalidArgumentExceptionIf the module is not enabled or it has no templates directory.

Definition at line 306 of file Template.php.

307 {
308 if (!\SimpleSAML\Module::isModuleEnabled($module)) {
309 throw new InvalidArgumentException('The module \''.$module.'\' is not enabled.');
310 }
311 $moduledir = \SimpleSAML\Module::getModuleDir($module);
312 // check if module has a /templates dir, if so, append
313 $templatedir = $moduledir.'/templates';
314 if (!is_dir($templatedir)) {
315 throw new InvalidArgumentException('The module \''.$module.'\' has no templates directory.');
316 }
317 return $templatedir;
318 }
$module
Current module, if any.
Definition: Template.php:68

References $module.

Referenced by setupTwigTemplatepaths().

+ Here is the caller graph for this function:

◆ getTag()

SimpleSAML_XHTML_Template::getTag (   $tag)
Parameters
$tag
Returns
array
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::getTag() instead.

Definition at line 609 of file Template.php.

610 {
611 return $this->translator->getTag($tag);
612 }
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

◆ getTranslation()

SimpleSAML_XHTML_Template::getTranslation (   $translations)

Temporary wrapper for \SimpleSAML\Locale\Translate::getPreferredTranslation().

Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::getPreferredTranslation() instead.

Definition at line 621 of file Template.php.

622 {
623 return $this->translator->getPreferredTranslation($translations);
624 }

◆ getTranslator()

SimpleSAML_XHTML_Template::getTranslator ( )

Return the internal translator object used by this template.

Returns
\SimpleSAML\Locale\Translate The translator that will be used with this template.

Definition at line 512 of file Template.php.

513 {
514 return $this->translator;
515 }

◆ getTwig()

SimpleSAML_XHTML_Template::getTwig ( )

Get the current instance of Twig in use.

Returns
false|Twig_Environment The Twig instance in use, or false if Twig is not used.

Definition at line 523 of file Template.php.

524 {
525 return $this->twig;
526 }

◆ includeAtTemplateBase()

SimpleSAML_XHTML_Template::includeAtTemplateBase (   $file)
private

Includes a file relative to the template base directory.

This function can be used to include headers and footers etc.

Definition at line 632 of file Template.php.

633 {
635
636 $filename = $this->findTemplatePath($file);
637
638 include($filename);
639 }
findTemplatePath($template, $throw_exception=true)
Find template path.
Definition: Template.php:449

◆ includeInlineTranslation()

SimpleSAML_XHTML_Template::includeInlineTranslation (   $tag,
  $translation 
)

Wraps Translate->includeInlineTranslation()

See also
\SimpleSAML\Locale\Translate::includeInlineTranslation()
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::includeInlineTranslation() instead.

Definition at line 649 of file Template.php.

650 {
651 $this->translator->includeInlineTranslation($tag, $translation);
652 }

◆ includeLanguageFile()

SimpleSAML_XHTML_Template::includeLanguageFile (   $file,
  $otherConfig = null 
)
Parameters
$file
null$otherConfig
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::includeLanguageFile() instead.

Definition at line 662 of file Template.php.

663 {
664 $this->translator->includeLanguageFile($file, $otherConfig);
665 }

◆ isLanguageRTL()

SimpleSAML_XHTML_Template::isLanguageRTL ( )
private

Wrap Language->isLanguageRTL.

Definition at line 671 of file Template.php.

672 {
673 return $this->translator->getLanguage()->isLanguageRTL();
674 }

◆ lang_merge()

static SimpleSAML_XHTML_Template::lang_merge (   $def,
  $lang 
)
static

Merge two translation arrays.

Parameters
array$defThe array holding string definitions.
array$langThe array holding translations for every string.
Returns
array The recursive merge of both arrays.
Deprecated:
This method will be removed in SimpleSAMLphp 2.0. Please use array_merge_recursive() instead.

Definition at line 686 of file Template.php.

687 {
688 foreach ($def as $key => $value) {
689 if (array_key_exists($key, $lang)) {
690 $def[$key] = array_merge($value, $lang[$key]);
691 }
692 }
693 return $def;
694 }
$def
Definition: croninfo.php:21
$key
Definition: croninfo.php:18

◆ noop()

static SimpleSAML_XHTML_Template::noop (   $tag)
static

Behave like Language->noop to mark a tag for translation but actually do it later.

See also
\SimpleSAML\Locale\Translate::noop()
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::noop() instead.

Definition at line 703 of file Template.php.

704 {
705 return $tag;
706 }

◆ normalizeTemplateName()

SimpleSAML_XHTML_Template::normalizeTemplateName (   $templateName)
private

Normalize the name of the template to one of the possible alternatives.

Parameters
string$templateNameThe template name to normalize.
Returns
string The filename we need to look for.

Definition at line 137 of file Template.php.

138 {
139 if (strripos($templateName, '.twig')) {
140 return $templateName;
141 }
142 $phppos = strripos($templateName, '.php');
143 if ($phppos) {
144 $templateName = substr($templateName, 0, $phppos);
145 }
146 $tplpos = strripos($templateName, '.tpl');
147 if ($tplpos) {
148 $templateName = substr($templateName, 0, $tplpos);
149 }
150 return $templateName.'.twig';
151 }

Referenced by setupTwig(), and setupTwigTemplatepaths().

+ Here is the caller graph for this function:

◆ setLanguage()

SimpleSAML_XHTML_Template::setLanguage (   $language,
  $setLanguageCookie = true 
)
Parameters
$language
bool$setLanguageCookie
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::setLanguage() instead.

Definition at line 565 of file Template.php.

566 {
567 $this->translator->getLanguage()->setLanguage($language, $setLanguageCookie);
568 }

◆ setLanguageCookie()

static SimpleSAML_XHTML_Template::setLanguageCookie (   $language)
static
Parameters
$language
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::setLanguageCookie() instead.

Definition at line 588 of file Template.php.

589 {
591 }
static setLanguageCookie($language)
This method will attempt to set the user-selected language in a cookie.
Definition: Language.php:401

◆ setupTwig()

SimpleSAML_XHTML_Template::setupTwig ( )
private

Setup twig.

Definition at line 194 of file Template.php.

195 {
196 $auto_reload = $this->configuration->getBoolean('template.auto_reload', true);
197 $cache = $this->configuration->getString('template.cache', false);
198 // set up template paths
199 $loader = $this->setupTwigTemplatepaths();
200 // abort if twig template does not exist
201 if (!$loader->exists($this->twig_template)) {
202 return false;
203 }
204
205 // load extra i18n domains
206 if ($this->module) {
207 $this->localization->addModuleDomain($this->module);
208 }
209 if ($this->theme['module'] !== null && $this->theme['module'] !== $this->module) {
210 $this->localization->addModuleDomain($this->theme['module']);
211 }
212
213 $options = array(
214 'cache' => $cache,
215 'auto_reload' => $auto_reload,
216 'translation_function' => array('\SimpleSAML\Locale\Translate', 'translateSingularNativeGettext'),
217 'translation_function_plural' => array('\SimpleSAML\Locale\Translate', 'translatePluralNativeGettext'),
218 );
219
220 // set up translation
221 if ($this->localization->i18nBackend === \SimpleSAML\Locale\Localization::GETTEXT_I18N_BACKEND) {
222 $options['translation_function'] = array('\SimpleSAML\Locale\Translate', 'translateSingularGettext');
223 $options['translation_function_plural'] = array(
224 '\SimpleSAML\Locale\Translate',
225 'translatePluralGettext'
226 );
227 } // TODO: add a branch for the old SimpleSAMLphp backend
228
229 $twig = new Twig_Environment($loader, $options);
230 $twig->addExtension(new Twig_Extensions_Extension_I18n());
231
232 // initialize some basic context
233 $langParam = $this->configuration->getString('language.parameter.name', 'language');
234 $twig->addGlobal('languageParameterName', $langParam);
235 $twig->addGlobal('localeBackend', $this->configuration->getString('language.i18n.backend', 'SimpleSAMLphp'));
236 $twig->addGlobal('currentLanguage', $this->translator->getLanguage()->getLanguage());
237 $twig->addGlobal('isRTL', false); // language RTL configuration
238 if ($this->translator->getLanguage()->isLanguageRTL()) {
239 $twig->addGlobal('isRTL', true);
240 }
241 $queryParams = $_GET; // add query parameters, in case we need them in the template
242 if (isset($queryParams[$langParam])) {
243 unset($queryParams[$langParam]);
244 }
245 $twig->addGlobal('queryParams', $queryParams);
246 $twig->addGlobal('templateId', str_replace('.twig', '', $this->normalizeTemplateName($this->template)));
247 $twig->addGlobal('isProduction', $this->configuration->getBoolean('production', true));
248
249 // add a filter for translations out of arrays
250 $twig->addFilter(
252 'translateFromArray',
253 array('\SimpleSAML\Locale\Translate', 'translateFromArray'),
254 array('needs_context' => true)
255 )
256 );
257
258 if ($this->controller) {
259 $this->controller->setUpTwig($twig);
260 }
261
262 return $twig;
263 }
$_GET["client_id"]
normalizeTemplateName($templateName)
Normalize the name of the template to one of the possible alternatives.
Definition: Template.php:137
setupTwigTemplatepaths()
Set up the places where twig can look for templates.
Definition: Template.php:160
Stores the Twig configuration.
Definition: Environment.php:18
Represents a template filter.

References $_GET, PHPMailer\PHPMailer\$options, $twig, normalizeTemplateName(), and setupTwigTemplatepaths().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setupTwigTemplatepaths()

SimpleSAML_XHTML_Template::setupTwigTemplatepaths ( )
private

Set up the places where twig can look for templates.

Returns
Twig_Loader_Filesystem The twig template loader or false if the template does not exist.
Exceptions
Twig_Error_LoaderIn case a failure occurs.

Definition at line 160 of file Template.php.

161 {
162 $filename = $this->normalizeTemplateName($this->template);
163
164 // get namespace if any
166 $this->twig_template = ($namespace !== null) ? '@'.$namespace.'/'.$filename : $filename;
167 $loader = new \Twig_Loader_Filesystem();
168 $templateDirs = $this->findThemeTemplateDirs();
169 if ($this->module) {
170 $templateDirs[] = array($this->module => $this->getModuleTemplateDir($this->module));
171 }
172 if ($this->theme['module']) {
173 try {
174 $templateDirs[] = array($this->theme['module'] => $this->getModuleTemplateDir($this->theme['module']));
175 } catch (\InvalidArgumentException $e) {
176 // either the module is not enabled or it has no "templates" directory, ignore
177 }
178 }
179
180 // default, themeless templates are checked last
181 $templateDirs[] = array(
182 \Twig_Loader_Filesystem::MAIN_NAMESPACE => $this->configuration->resolvePath('templates')
183 );
184 foreach ($templateDirs as $entry) {
185 $loader->addPath($entry[key($entry)], key($entry));
186 }
187 return $loader;
188 }
findThemeTemplateDirs()
Add overriding templates from the configured theme.
Definition: Template.php:270
getModuleTemplateDir($module)
Get the template directory of a module, if it exists.
Definition: Template.php:306
Loads template from the filesystem.
Definition: Filesystem.php:18
if($err=$client->getError()) $namespace

References $filename, $namespace, findModuleAndTemplateName(), findThemeTemplateDirs(), getModuleTemplateDir(), Twig_Loader_Filesystem\MAIN_NAMESPACE, and normalizeTemplateName().

Referenced by setupTwig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ show()

SimpleSAML_XHTML_Template::show ( )

Show the template to the user.

Definition at line 405 of file Template.php.

406 {
407 if ($this->twig !== false) {
408 $this->twigDefaultContext();
409 if ($this->controller) {
410 $this->controller->display($this->data);
411 }
412 echo $this->twig->render($this->twig_template, $this->data);
413 } else {
414 $filename = $this->findTemplatePath($this->template);
415 require($filename);
416 }
417 }
twigDefaultContext()
Set some default context.
Definition: Template.php:375

◆ t()

SimpleSAML_XHTML_Template::t (   $tag,
  $replacements = array(),
  $fallbackdefault = true,
  $oldreplacements = array(),
  $striptags = false 
)

Wrap Language->t to translate tag into the current language, with a fallback to english.

See also
\SimpleSAML\Locale\Translate::t()
Deprecated:
This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::t() instead.

Definition at line 715 of file Template.php.

721 {
722 return $this->translator->t($tag, $replacements, $fallbackdefault, $oldreplacements, $striptags);
723 }

◆ twigDefaultContext()

SimpleSAML_XHTML_Template::twigDefaultContext ( )
private

Set some default context.

Definition at line 375 of file Template.php.

376 {
377 // show language bar by default
378 if (!isset($this->data['hideLanguageBar'])) {
379 $this->data['hideLanguageBar'] = false;
380 }
381 // get languagebar
382 $this->data['languageBar'] = null;
383 if ($this->data['hideLanguageBar'] === false) {
384 $languageBar = $this->generateLanguageBar();
385 if (is_null($languageBar)) {
386 $this->data['hideLanguageBar'] = true;
387 } else {
388 $this->data['languageBar'] = $languageBar;
389 }
390 }
391
392 // assure that there is a <title> and <h1>
393 if (isset($this->data['header']) && !isset($this->data['pagetitle'])) {
394 $this->data['pagetitle'] = $this->data['header'];
395 }
396 if (!isset($this->data['pagetitle'])) {
397 $this->data['pagetitle'] = 'SimpleSAMLphp';
398 }
399 }
generateLanguageBar()
Generate an array for its use in the language bar, indexed by the ISO 639-2 codes of the languages av...
Definition: Template.php:345

Field Documentation

◆ $configuration

SimpleSAML_XHTML_Template::$configuration
private

Definition at line 42 of file Template.php.

Referenced by __construct().

◆ $controller

SimpleSAML_XHTML_Template::$controller
private

Definition at line 79 of file Template.php.

Referenced by __construct().

◆ $data

SimpleSAML_XHTML_Template::$data = array()

Definition at line 21 of file Template.php.

◆ $localization

SimpleSAML_XHTML_Template::$localization
private

Definition at line 35 of file Template.php.

◆ $module

SimpleSAML_XHTML_Template::$module
private

Current module, if any.

Definition at line 68 of file Template.php.

Referenced by getModuleTemplateDir().

◆ $template

SimpleSAML_XHTML_Template::$template = 'default.php'
private

Definition at line 49 of file Template.php.

Referenced by __construct().

◆ $theme

SimpleSAML_XHTML_Template::$theme
private

Definition at line 91 of file Template.php.

◆ $translator

SimpleSAML_XHTML_Template::$translator
private

Definition at line 28 of file Template.php.

◆ $twig

SimpleSAML_XHTML_Template::$twig
private

Definition at line 56 of file Template.php.

Referenced by setupTwig().

◆ $twig_template

SimpleSAML_XHTML_Template::$twig_template
private

Definition at line 63 of file Template.php.


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