Skip to content
Snippets Groups Projects
Commit f295ac59 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Add a method SimpleSAML_XHTML_Template::getTranslator() to retrieve the...

Add a method SimpleSAML_XHTML_Template::getTranslator() to retrieve the SimpleSAML\Locale\Translate instance local to the template, and use it to fix a bug in a template of the consent module.
parent 268cd267
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,13 @@ class SimpleSAML_XHTML_Template
{
public $data = null;
/**
* A translator instance configured to work with this template.
*
* @var \SimpleSAML\Locale\Translate
*/
private $translator;
private $configuration = null;
private $template = 'default.php';
......@@ -31,6 +38,17 @@ class SimpleSAML_XHTML_Template
}
/**
* Return the internal translator object used by this template.
*
* @return \SimpleSAML\Locale\Translate The translator that will be used with this template.
*/
public function getTranslator()
{
return $this->translator;
}
/**
* @deprecated This method will be removed in SSP 2.0. Please use
* SimpleSAML\Locale\Translate::getPreferredTranslation() instead.
......
......@@ -139,6 +139,8 @@ if ($this->data['sppp'] !== false) {
*/
function present_attributes($t, $attributes, $nameParent)
{
$translator = $t->getTranslator();
$alternate = array('odd', 'even');
$i = 0;
$summary = 'summary="' . $t->t('{consent:consent:table_summary}') . '"';
......@@ -155,7 +157,7 @@ function present_attributes($t, $attributes, $nameParent)
foreach ($attributes as $name => $value) {
$nameraw = $name;
$name = $t->getAttributeTranslation($parentStr . $nameraw);
$name = $translator->getAttributeTranslation($parentStr . $nameraw);
if (preg_match('/^child_/', $nameraw)) {
// insert child table
......
......@@ -205,7 +205,7 @@ $template_sp_content = array();
// Init template
$template = new SimpleSAML_XHTML_Template($config, 'consentAdmin:consentadmin.php', 'consentAdmin:consentadmin');
$translator = new \SimpleSAML\Locale\Translate($config, 'consentAdmin:consentadmin');
$translator = $template->getTranslator();
$sp_empty_name = $translator->getTag('sp_empty_name');
$sp_empty_description = $translator->getTag('sp_empty_description');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment