ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ::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 16 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 103 of file Template.php.

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

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

Referenced by __construct().

422  {
423  $tmp = explode(':', $template, 2);
424  return (count($tmp) === 2) ? array($tmp[0], $tmp[1]) : array(null, $tmp[0]);
425  }
Create styles array
The data for the language used.
+ 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 443 of file Template.php.

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

◆ 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().

264  {
265  if ($this->theme['module'] === null) { // no module involved
266  return array();
267  }
268 
269  // setup directories & namespaces
270  $themeDir = \SimpleSAML\Module::getModuleDir($this->theme['module']).'/themes/'.$this->theme['name'];
271  $subdirs = scandir($themeDir);
272  if (!$subdirs) { // no subdirectories in the theme directory, nothing to do here
273  // this is probably wrong, log a message
274  \SimpleSAML\Logger::warning('Emtpy theme directory for theme "'.$this->theme['name'].'".');
275  return array();
276  }
277 
278  $themeTemplateDirs = array();
279  foreach ($subdirs as $entry) {
280  // discard anything that's not a directory. Expression is negated to profit from lazy evaluation
281  if (!($entry !== '.' && $entry !== '..' && is_dir($themeDir.'/'.$entry))) {
282  continue;
283  }
284 
285  // set correct name for the default namespace
286  $ns = ($entry === 'default') ? \Twig_Loader_Filesystem::MAIN_NAMESPACE : $entry;
287  $themeTemplateDirs[] = array($ns => $themeDir.'/'.$entry);
288  }
289  return $themeTemplateDirs;
290  }
static getModuleDir($module)
Retrieve the base directory for a module.
Definition: Module.php:122
static warning($string)
Definition: Logger.php:179
Create styles array
The data for the language used.
const MAIN_NAMESPACE
Identifier of the main namespace.
Definition: Filesystem.php:20
+ 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 339 of file Template.php.

340  {
341  $languages = $this->translator->getLanguage()->getLanguageList();
342  $langmap = null;
343  if (count($languages) > 1) {
344  $parameterName = $this->getTranslator()->getLanguage()->getLanguageParameterName();
345  $langmap = array();
346  foreach ($languages as $lang => $current) {
347  $lang = strtolower($lang);
348  $langname = $this->translator->getLanguage()->getLanguageLocalizedName($lang);
349  $url = false;
350  if (!$current) {
351  $url = htmlspecialchars(\SimpleSAML\Utils\HTTP::addURLParameters(
352  '',
353  array($parameterName => $lang)
354  ));
355  }
356  $langmap[$lang] = array(
357  'name' => $langname,
358  'url' => $url,
359  );
360  }
361  }
362  return $langmap;
363  }
getTranslator()
Return the internal translator object used by this template.
Definition: Template.php:506
Attribute-related utility methods.
Create styles array
The data for the language used.
$url

◆ getAttributeTranslation()

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

Definition at line 535 of file Template.php.

536  {
537  return $this->translator->getAttributeTranslation($name);
538  }
if($format !==null) $name
Definition: metadata.php:146

◆ 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.

547  {
548  return $this->translator->getLanguage()->getLanguage();
549  }

◆ 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.

571  {
572  return \SimpleSAML\Locale\Language::getLanguageCookie();
573  }

◆ getLanguageList()

SimpleSAML_XHTML_Template::getLanguageList ( )
private

Wraps Language->getLanguageList.

Definition at line 591 of file Template.php.

592  {
593  return $this->translator->getLanguage()->getLanguageList();
594  }

◆ 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 299 of file Template.php.

References $module, and is.

Referenced by setupTwigTemplatepaths().

300  {
301  if (!\SimpleSAML\Module::isModuleEnabled($module)) {
302  throw new InvalidArgumentException('The module \''.$module.'\' is not enabled.');
303  }
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.');
309 
310  }
311  return $templatedir;
312  }
Sum of both Ranges is
Definition: 03formulas.php:77
$module
Current module, if any.
Definition: Template.php:71
Attribute-related utility methods.
+ 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 ::getTag() instead.

Definition at line 603 of file Template.php.

604  {
605  return $this->translator->getTag($tag);
606  }
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 ::getPreferredTranslation().

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

Definition at line 615 of file Template.php.

616  {
617  return $this->translator->getPreferredTranslation($translations);
618  }

◆ 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().

507  {
508  return $this->translator;
509  }
+ Here is the caller graph for this function:

◆ 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.

518  {
519  return $this->twig;
520  }

◆ 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.

627  {
628  $data = $this->data;
629 
630  $filename = $this->findTemplatePath($file);
631 
632  include($filename);
633  }
findTemplatePath($template, $throw_exception=true)
Find template path.
Definition: Template.php:443
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.

644  {
645  $this->translator->includeInlineTranslation($tag, $translation);
646  }
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

◆ includeLanguageFile()

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

Definition at line 656 of file Template.php.

657  {
658  $this->translator->includeLanguageFile($file, $otherConfig);
659  }
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.

666  {
667  return $this->translator->getLanguage()->isLanguageRTL();
668  }

◆ 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 680 of file Template.php.

681  {
682  foreach ($def as $key => $value) {
683  if (array_key_exists($key, $lang)) {
684  $def[$key] = array_merge($value, $lang[$key]);
685  }
686  }
687  return $def;
688  }
$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
::noop()
Deprecated:
This method will be removed in SSP 2.0. Please use ::noop() instead.

Definition at line 697 of file Template.php.

698  {
699  return $tag;
700  }
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

◆ 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 140 of file Template.php.

Referenced by setupTwig(), and setupTwigTemplatepaths().

141  {
142  if (strripos($templateName, '.twig')) {
143  return $templateName;
144  }
145  $phppos = strripos($templateName, '.php');
146  if ($phppos) {
147  $templateName = substr($templateName, 0, $phppos);
148  }
149  $tplpos = strripos($templateName, '.tpl');
150  if ($tplpos) {
151  $templateName = substr($templateName, 0, $tplpos);
152  }
153  return $templateName.'.twig';
154  }
+ 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 ::setLanguage() instead.

Definition at line 559 of file Template.php.

560  {
561  $this->translator->getLanguage()->setLanguage($language, $setLanguageCookie);
562  }

◆ setLanguageCookie()

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

Definition at line 582 of file Template.php.

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

◆ 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().

198  {
199  $auto_reload = $this->configuration->getBoolean('template.auto_reload', true);
200  $cache = $this->configuration->getString('template.cache', false);
201  // set up template paths
202  $loader = $this->setupTwigTemplatepaths();
203  // abort if twig template does not exist
204  if (!$loader->exists($this->twig_template)) {
205  return false;
206  }
207 
208  // load extra i18n domains
209  if ($this->module) {
210  $this->localization->addModuleDomain($this->module);
211  }
212  if ($this->theme['module'] !== null && $this->theme['module'] !== $this->module) {
213  $this->localization->addModuleDomain($this->theme['module']);
214  }
215 
216  $options = array(
217  'cache' => $cache,
218  'auto_reload' => $auto_reload,
219  'translation_function' => array('\SimpleSAML\Locale\Translate', 'translateSingularNativeGettext'),
220  'translation_function_plural' => array('\SimpleSAML\Locale\Translate', 'translatePluralNativeGettext'),
221  );
222 
223  // set up translation
224  if ($this->localization->i18nBackend === \SimpleSAML\Locale\Localization::GETTEXT_I18N_BACKEND) {
225  $options['translation_function'] = array('\SimpleSAML\Locale\Translate', 'translateSingularGettext');
226  $options['translation_function_plural'] = array(
227  '\SimpleSAML\Locale\Translate',
228  'translatePluralGettext'
229  );
230  } // TODO: add a branch for the old SimpleSAMLphp backend
231 
233  $twig->addExtension(new Twig_Extensions_Extension_I18n());
234 
235  // initialize some basic context
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); // language RTL configuration
241  if ($this->translator->getLanguage()->isLanguageRTL()) {
242  $twig->addGlobal('isRTL', true);
243  }
244  $queryParams = $_GET; // add query parameters, in case we need them in the template
245  if (isset($queryParams[$langParam])) {
246  unset($queryParams[$langParam]);
247  }
248  $twig->addGlobal('queryParams', $queryParams);
249  $twig->addGlobal('templateId', str_replace('.twig', '', $this->normalizeTemplateName($this->template)));
250 
251  if ($this->controller) {
252  $this->controller->setUpTwig($twig);
253  }
254 
255  return $twig;
256  }
$_GET["client_id"]
setupTwigTemplatepaths()
Set up the places where twig can look for templates.
Definition: Template.php:163
Attribute-related utility methods.
normalizeTemplateName($templateName)
Normalize the name of the template to one of the possible alternatives.
Definition: Template.php:140
Create styles array
The data for the language used.
Stores the Twig configuration.
Definition: Environment.php:17
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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|false The twig template loader or false if the template does not exist.
Exceptions
Twig_Error_LoaderIn case a failure occurs.

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

164  {
165  $filename = $this->normalizeTemplateName($this->template);
166 
167  // get namespace if any
168  list($namespace, $filename) = self::findModuleAndTemplateName($filename);
169  $this->twig_template = ($namespace !== null) ? '@'.$namespace.'/'.$filename : $filename;
171  $templateDirs = $this->findThemeTemplateDirs();
172  if ($this->module) {
173  $templateDirs[] = array($this->module => $this->getModuleTemplateDir($this->module));
174  }
175  if ($this->theme['module']) {
176  try {
177  $templateDirs[] = array($this->theme['module'] => $this->getModuleTemplateDir($this->theme['module']));
178  } catch (\InvalidArgumentException $e) {
179  // either the module is not enabled or it has no "templates" directory, ignore
180  }
181  }
182 
183  // default, themeless templates are checked last
184  $templateDirs[] = array(
185  \Twig_Loader_Filesystem::MAIN_NAMESPACE => $this->configuration->resolvePath('templates')
186  );
187  foreach ($templateDirs as $entry) {
188  $loader->addPath($entry[key($entry)], key($entry));
189  }
190  return $loader;
191  }
if($err=$client->getError()) $namespace
Loads template from the filesystem.
Definition: Filesystem.php:17
findThemeTemplateDirs()
Add overriding templates from the configured theme.
Definition: Template.php:263
normalizeTemplateName($templateName)
Normalize the name of the template to one of the possible alternatives.
Definition: Template.php:140
Create styles array
The data for the language used.
getModuleTemplateDir($module)
Get the template directory of a module, if it exists.
Definition: Template.php:299
const MAIN_NAMESPACE
Identifier of the main namespace.
Definition: Filesystem.php:20
+ 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 399 of file Template.php.

400  {
401  if ($this->twig !== false) {
402  $this->twigDefaultContext();
403  if ($this->controller) {
404  $this->controller->display($this->data);
405  }
406  echo $this->twig->render($this->twig_template, $this->data);
407  } else {
408  $filename = $this->findTemplatePath($this->template);
409  require($filename);
410  }
411  }
Add some data
twigDefaultContext()
Set some default context.
Definition: Template.php:369
findTemplatePath($template, $throw_exception=true)
Find template path.
Definition: Template.php:443

◆ 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.

715  {
716  return $this->translator->t($tag, $replacements, $fallbackdefault, $oldreplacements, $striptags);
717  }
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

◆ twigDefaultContext()

SimpleSAML_XHTML_Template::twigDefaultContext ( )
private

Set some default context.

Definition at line 369 of file Template.php.

370  {
371  // show language bar by default
372  if (!isset($this->data['hideLanguageBar'])) {
373  $this->data['hideLanguageBar'] = false;
374  }
375  // get languagebar
376  $this->data['languageBar'] = null;
377  if ($this->data['hideLanguageBar'] === false) {
378  $languageBar = $this->generateLanguageBar();
379  if (is_null($languageBar)) {
380  $this->data['hideLanguageBar'] = true;
381  } else {
382  $this->data['languageBar'] = $languageBar;
383  }
384  }
385 
386  // assure that there is a <title> and <h1>
387  if (isset($this->data['header']) && !isset($this->data['pagetitle'])) {
388  $this->data['pagetitle'] = $this->data['header'];
389  }
390  if (!isset($this->data['pagetitle'])) {
391  $this->data['pagetitle'] = 'SimpleSAMLphp';
392  }
393  }
Add some data
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:339

Field Documentation

◆ $configuration

SimpleSAML_XHTML_Template::$configuration
private

Definition at line 45 of file Template.php.

Referenced by __construct().

◆ $controller

SimpleSAML_XHTML_Template::$controller
private

Definition at line 82 of file Template.php.

Referenced by __construct().

◆ $data

SimpleSAML_XHTML_Template::$data = array()

Definition at line 24 of file Template.php.

◆ $localization

SimpleSAML_XHTML_Template::$localization
private

Definition at line 38 of file Template.php.

◆ $module

SimpleSAML_XHTML_Template::$module
private

Current module, if any.

Definition at line 71 of file Template.php.

Referenced by getModuleTemplateDir().

◆ $template

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

Definition at line 52 of file Template.php.

Referenced by __construct().

◆ $theme

SimpleSAML_XHTML_Template::$theme
private

Definition at line 94 of file Template.php.

◆ $translator

SimpleSAML_XHTML_Template::$translator
private

Definition at line 31 of file Template.php.

◆ $twig

SimpleSAML_XHTML_Template::$twig
private

Definition at line 59 of file Template.php.

Referenced by setupTwig().

◆ $twig_template

SimpleSAML_XHTML_Template::$twig_template
private

Definition at line 66 of file Template.php.


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