|
| __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 ::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...
|
|
Definition at line 16 of file Template.php.
◆ __construct()
SimpleSAML_XHTML_Template::__construct |
( |
\SimpleSAML_Configuration |
$configuration, |
|
|
|
$template, |
|
|
|
$defaultDictionary = null |
|
) |
| |
Constructor.
- Parameters
-
SimpleSAML_Configuration | $configuration | Configuration object |
string | $template | Which template file to load |
string | null | $defaultDictionary | The default dictionary where tags will come from. |
Definition at line 103 of file Template.php.
References $configuration, $controller, $template, data, findModuleAndTemplateName(), and setupTwig().
108 $this->
data[
'baseurlpath'] = ltrim($this->configuration->getBasePath(),
'/');
114 list($this->theme[
'module'], $this->theme[
'name']) = self::findModuleAndTemplateName(
115 $this->configuration->getString(
'theme.use',
'default')
120 $this->localization = new \SimpleSAML\Locale\Localization(
$configuration);
123 $controller = $this->configuration->getString(
'theme.controller',
false);
125 class_implements(
$controller,
'\SimpleSAML\XHTML\TemplateControllerInterface')
findModuleAndTemplateName($template)
Find module the template is in, if any.
◆ findModuleAndTemplateName()
SimpleSAML_XHTML_Template::findModuleAndTemplateName |
( |
|
$template | ) |
|
|
private |
Find module the template is in, if any.
- Parameters
-
string | $template | The 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 421 of file Template.php.
Referenced by __construct().
424 return (count($tmp) === 2) ?
array($tmp[0], $tmp[1]) :
array(null, $tmp[0]);
Create styles array
The data for the language used.
◆ 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 | $template | The relative path from the theme directory to the template file. |
- Returns
- string The absolute path to the template file.
- Exceptions
-
Exception | If the template file couldn't be found. |
Definition at line 443 of file Template.php.
445 assert(
'is_string($template)');
448 $templateModule = ($templateModule !== null) ? $templateModule :
'default';
451 if ($this->theme[
'module'] !== null) {
455 '/themes/'.$this->theme[
'name'].
'/'.$templateModule.
'/'.$templateName;
456 } elseif ($templateModule !==
'default') {
461 $filename = $this->configuration->getPathValue(
'templatedir',
'templates/').$templateName;
470 $_SERVER[
'PHP_SELF'].
' - Template: Could not find template file ['.
$template.
'] at ['.
471 $filename.
'] - now trying the base template' 475 if ($templateModule !==
'default') {
480 $filename = $this->configuration->getPathValue(
'templatedir',
'templates/').
'/'.$templateName;
488 if ($throw_exception) {
490 $error =
'Template: Could not find template file ['.$template.
'] at ['.
$filename.
']';
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static getModuleDir($module)
Retrieve the base directory for a module.
findModuleAndTemplateName($template)
Find module the template is in, if any.
◆ findThemeTemplateDirs()
SimpleSAML_XHTML_Template::findThemeTemplateDirs |
( |
| ) |
|
|
private |
Add overriding templates from the configured theme.
- Returns
- array An array of module => templatedir lookups.
Definition at line 263 of file Template.php.
References array, SimpleSAML\Module\getModuleDir(), Twig_Loader_Filesystem\MAIN_NAMESPACE, and SimpleSAML\Logger\warning().
Referenced by setupTwigTemplatepaths().
265 if ($this->theme[
'module'] === null) {
271 $subdirs = scandir($themeDir);
278 $themeTemplateDirs =
array();
279 foreach ($subdirs as $entry) {
281 if (!($entry !==
'.' && $entry !==
'..' && is_dir($themeDir.
'/'.$entry))) {
287 $themeTemplateDirs[] =
array($ns => $themeDir.
'/'.$entry);
289 return $themeTemplateDirs;
static getModuleDir($module)
Retrieve the base directory for a module.
Create styles array
The data for the language used.
const MAIN_NAMESPACE
Identifier of the main namespace.
◆ 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 339 of file Template.php.
341 $languages = $this->translator->getLanguage()->getLanguageList();
343 if (count($languages) > 1) {
344 $parameterName = $this->
getTranslator()->getLanguage()->getLanguageParameterName();
348 $langname = $this->translator->getLanguage()->getLanguageLocalizedName(
$lang);
getTranslator()
Return the internal translator object used by this template.
Attribute-related utility methods.
Create styles array
The data for the language used.
◆ getAttributeTranslation()
SimpleSAML_XHTML_Template::getAttributeTranslation |
( |
|
$name | ) |
|
- Parameters
-
- Returns
- string
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::getLanguage() instead.
Definition at line 535 of file Template.php.
537 return $this->translator->getAttributeTranslation(
$name);
◆ getLanguage()
SimpleSAML_XHTML_Template::getLanguage |
( |
| ) |
|
- Returns
- string
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::getLanguage() instead.
Definition at line 546 of file Template.php.
548 return $this->translator->getLanguage()->getLanguage();
◆ getLanguageCookie()
static SimpleSAML_XHTML_Template::getLanguageCookie |
( |
| ) |
|
|
static |
- Returns
- null|string
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::getLanguageCookie() instead.
Definition at line 570 of file Template.php.
572 return \SimpleSAML\Locale\Language::getLanguageCookie();
◆ getLanguageList()
SimpleSAML_XHTML_Template::getLanguageList |
( |
| ) |
|
|
private |
Wraps Language->getLanguageList.
Definition at line 591 of file Template.php.
593 return $this->translator->getLanguage()->getLanguageList();
◆ 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
-
InvalidArgumentException | If the module is not enabled or it has no templates directory. |
Definition at line 299 of file Template.php.
References $module, and is.
Referenced by setupTwigTemplatepaths().
304 $moduledir = \SimpleSAML\Module::getModuleDir($module); 305 // check if module has a /templates dir, if so, append 306 $templatedir = $moduledir.'/templates
'; 307 if (!is_dir($templatedir)) { 308 throw new InvalidArgumentException('The module \
''.$module.
'\' has no templates directory.
');
$module
Current module, if any.
Attribute-related utility methods.
◆ getTag()
SimpleSAML_XHTML_Template::getTag |
( |
|
$tag | ) |
|
- Parameters
-
- Returns
- array
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::getTag() instead.
Definition at line 603 of file Template.php.
605 return $this->translator->getTag(
$tag);
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
◆ getTranslation()
SimpleSAML_XHTML_Template::getTranslation |
( |
|
$translations | ) |
|
Temporary wrapper for ::getPreferredTranslation().
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::getPreferredTranslation() instead.
Definition at line 615 of file Template.php.
617 return $this->translator->getPreferredTranslation($translations);
◆ getTranslator()
SimpleSAML_XHTML_Template::getTranslator |
( |
| ) |
|
Return the internal translator object used by this template.
- Returns
- The translator that will be used with this template.
Definition at line 506 of file Template.php.
Referenced by present_eptid().
◆ 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 517 of file Template.php.
◆ 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 626 of file Template.php.
findTemplatePath($template, $throw_exception=true)
Find template path.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
◆ includeInlineTranslation()
SimpleSAML_XHTML_Template::includeInlineTranslation |
( |
|
$tag, |
|
|
|
$translation |
|
) |
| |
Wraps Translate->includeInlineTranslation()
- See also
- ::includeInlineTranslation()
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::includeInlineTranslation() instead.
Definition at line 643 of file Template.php.
645 $this->translator->includeInlineTranslation(
$tag, $translation);
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
◆ includeLanguageFile()
SimpleSAML_XHTML_Template::includeLanguageFile |
( |
|
$file, |
|
|
|
$otherConfig = null |
|
) |
| |
- Parameters
-
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::includeLanguageFile() instead.
Definition at line 656 of file Template.php.
658 $this->translator->includeLanguageFile(
$file, $otherConfig);
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
◆ isLanguageRTL()
SimpleSAML_XHTML_Template::isLanguageRTL |
( |
| ) |
|
|
private |
Wrap Language->isLanguageRTL.
Definition at line 665 of file Template.php.
667 return $this->translator->getLanguage()->isLanguageRTL();
◆ lang_merge()
static SimpleSAML_XHTML_Template::lang_merge |
( |
|
$def, |
|
|
|
$lang |
|
) |
| |
|
static |
Merge two translation arrays.
- Parameters
-
array | $def | The array holding string definitions. |
array | $lang | The 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 680 of file Template.php.
◆ 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
- ::noop()
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::noop() instead.
Definition at line 697 of file Template.php.
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
◆ normalizeTemplateName()
SimpleSAML_XHTML_Template::normalizeTemplateName |
( |
|
$templateName | ) |
|
|
private |
Normalize the name of the template to one of the possible alternatives.
- Parameters
-
string | $templateName | The template name to normalize. |
- Returns
- string The filename we need to look for.
Definition at line 140 of file Template.php.
Referenced by setupTwig(), and setupTwigTemplatepaths().
142 if (strripos($templateName,
'.twig')) {
143 return $templateName;
145 $phppos = strripos($templateName,
'.php');
147 $templateName = substr($templateName, 0, $phppos);
149 $tplpos = strripos($templateName,
'.tpl');
151 $templateName = substr($templateName, 0, $tplpos);
153 return $templateName.
'.twig';
◆ setLanguage()
SimpleSAML_XHTML_Template::setLanguage |
( |
|
$language, |
|
|
|
$setLanguageCookie = true |
|
) |
| |
- Parameters
-
| $language | |
bool | $setLanguageCookie | |
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::setLanguage() instead.
Definition at line 559 of file Template.php.
561 $this->translator->getLanguage()->setLanguage($language, $setLanguageCookie);
◆ setLanguageCookie()
static SimpleSAML_XHTML_Template::setLanguageCookie |
( |
|
$language | ) |
|
|
static |
- Parameters
-
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::setLanguageCookie() instead.
Definition at line 582 of file Template.php.
static setLanguageCookie($language)
This method will attempt to set the user-selected language in a cookie.
◆ setupTwig()
SimpleSAML_XHTML_Template::setupTwig |
( |
| ) |
|
|
private |
Setup twig.
Definition at line 197 of file Template.php.
References $_GET, $loader, $options, $twig, array, normalizeTemplateName(), and setupTwigTemplatepaths().
Referenced by __construct().
199 $auto_reload = $this->configuration->getBoolean(
'template.auto_reload',
true);
200 $cache = $this->configuration->getString(
'template.cache',
false);
204 if (!
$loader->exists($this->twig_template)) {
210 $this->localization->addModuleDomain($this->module);
212 if ($this->theme[
'module'] !== null && $this->theme[
'module'] !== $this->module) {
213 $this->localization->addModuleDomain($this->theme[
'module']);
218 'auto_reload' => $auto_reload,
219 'translation_function' =>
array(
'\SimpleSAML\Locale\Translate',
'translateSingularNativeGettext'),
220 'translation_function_plural' =>
array(
'\SimpleSAML\Locale\Translate',
'translatePluralNativeGettext'),
224 if ($this->localization->i18nBackend === \
SimpleSAML\Locale\Localization::GETTEXT_I18N_BACKEND) {
225 $options[
'translation_function'] =
array(
'\SimpleSAML\Locale\Translate',
'translateSingularGettext');
227 '\SimpleSAML\Locale\Translate',
228 'translatePluralGettext' 236 $langParam = $this->configuration->getString(
'language.parameter.name',
'language');
237 $twig->addGlobal(
'languageParameterName', $langParam);
238 $twig->addGlobal(
'localeBackend', $this->configuration->getString(
'language.i18n.backend',
'SimpleSAMLphp'));
239 $twig->addGlobal(
'currentLanguage', $this->translator->getLanguage()->getLanguage());
240 $twig->addGlobal(
'isRTL',
false);
241 if ($this->translator->getLanguage()->isLanguageRTL()) {
242 $twig->addGlobal(
'isRTL',
true);
244 $queryParams =
$_GET;
245 if (isset($queryParams[$langParam])) {
246 unset($queryParams[$langParam]);
248 $twig->addGlobal(
'queryParams', $queryParams);
251 if ($this->controller) {
252 $this->controller->setUpTwig(
$twig);
setupTwigTemplatepaths()
Set up the places where twig can look for templates.
Attribute-related utility methods.
normalizeTemplateName($templateName)
Normalize the name of the template to one of the possible alternatives.
Create styles array
The data for the language used.
Stores the Twig configuration.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
◆ setupTwigTemplatepaths()
SimpleSAML_XHTML_Template::setupTwigTemplatepaths |
( |
| ) |
|
|
private |
Set up the places where twig can look for templates.
- Returns
- Twig_Loader_Filesystem|false The twig template loader or false if the template does not exist.
- Exceptions
-
Definition at line 163 of file Template.php.
References $filename, $loader, $namespace, array, findThemeTemplateDirs(), getModuleTemplateDir(), Twig_Loader_Filesystem\MAIN_NAMESPACE, and normalizeTemplateName().
Referenced by setupTwig().
175 if ($this->theme[
'module']) {
184 $templateDirs[] =
array(
187 foreach ($templateDirs as $entry) {
188 $loader->addPath($entry[key($entry)], key($entry));
if($err=$client->getError()) $namespace
Loads template from the filesystem.
findThemeTemplateDirs()
Add overriding templates from the configured theme.
normalizeTemplateName($templateName)
Normalize the name of the template to one of the possible alternatives.
Create styles array
The data for the language used.
getModuleTemplateDir($module)
Get the template directory of a module, if it exists.
const MAIN_NAMESPACE
Identifier of the main namespace.
◆ show()
SimpleSAML_XHTML_Template::show |
( |
| ) |
|
Show the template to the user.
Definition at line 399 of file Template.php.
401 if ($this->twig !==
false) {
403 if ($this->controller) {
404 $this->controller->display($this->
data);
406 echo $this->twig->render($this->twig_template, $this->
data);
twigDefaultContext()
Set some default context.
findTemplatePath($template, $throw_exception=true)
Find template path.
◆ 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
- ::t()
- Deprecated:
- This method will be removed in SSP 2.0. Please use ::t() instead.
Definition at line 709 of file Template.php.
716 return $this->translator->t(
$tag, $replacements, $fallbackdefault, $oldreplacements, $striptags);
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
◆ twigDefaultContext()
SimpleSAML_XHTML_Template::twigDefaultContext |
( |
| ) |
|
|
private |
Set some default context.
Definition at line 369 of file Template.php.
372 if (!isset($this->
data[
'hideLanguageBar'])) {
373 $this->
data[
'hideLanguageBar'] =
false;
376 $this->
data[
'languageBar'] = null;
377 if ($this->
data[
'hideLanguageBar'] ===
false) {
379 if (is_null($languageBar)) {
380 $this->
data[
'hideLanguageBar'] =
true;
382 $this->
data[
'languageBar'] = $languageBar;
387 if (isset($this->
data[
'header']) && !isset($this->
data[
'pagetitle'])) {
388 $this->
data[
'pagetitle'] = $this->
data[
'header'];
390 if (!isset($this->
data[
'pagetitle'])) {
391 $this->
data[
'pagetitle'] =
'SimpleSAMLphp';
generateLanguageBar()
Generate an array for its use in the language bar, indexed by the ISO 639-2 codes of the languages av...
◆ $configuration
SimpleSAML_XHTML_Template::$configuration |
|
private |
◆ $controller
SimpleSAML_XHTML_Template::$controller |
|
private |
◆ $data
SimpleSAML_XHTML_Template::$data = array() |
◆ $localization
SimpleSAML_XHTML_Template::$localization |
|
private |
◆ $module
SimpleSAML_XHTML_Template::$module |
|
private |
◆ $template
SimpleSAML_XHTML_Template::$template = 'default.php' |
|
private |
◆ $theme
SimpleSAML_XHTML_Template::$theme |
|
private |
◆ $translator
SimpleSAML_XHTML_Template::$translator |
|
private |
◆ $twig
SimpleSAML_XHTML_Template::$twig |
|
private |
◆ $twig_template
SimpleSAML_XHTML_Template::$twig_template |
|
private |
The documentation for this class was generated from the following file:
- libs/composer/vendor/simplesamlphp/simplesamlphp/lib/SimpleSAML/XHTML/Template.php