Skip to content
Snippets Groups Projects
Commit 178682bf authored by Olav Morken's avatar Olav Morken
Browse files

Template: remove the following parameters from the t()-method: $fallbacktag,...

Template: remove the following parameters from the t()-method: $fallbacktag, $fallbackdefault, $striptags

Backwards compatibility with the previous style is preserved, but will write a
warning to the log.

Uses of $fallbacktag should be replaced with calls to the getTag()-method.
The $fallbackdefault and $striptags parameters didn't have any in-tree users.


git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@748 44740490-163a-0410-bde0-09ae8108e29a
parent 448b85d4
No related branches found
No related tags found
No related merge requests found
......@@ -209,17 +209,32 @@ class SimpleSAML_XHTML_Template {
/**
* Include text in the current language.
*
* @param $tag A name tag of the string that should be returned.
* @param $fallbacktag If set to true and string was not found in any languages, return the tag it self.
* @param $fallbackdefault If not found in selected language fallback to default language.
* @param $replacements An associative array of keys that should be replaced with values in the translated string.
* @param $striptags Should HTML tags be stripped from the translation
* @param $tag A name tag of the string that should be returned.
* @param $replacements An associative array of keys that should be replaced with values in the translated string.
*/
public function t($tag, $fallbacktag = TRUE, $fallbackdefault = true, $replacements = array(), $striptags = false) {
public function t($tag, $replacements = array(), $fallbackdefault = true, $oldreplacements = array(), $striptags = false) {
if(!is_array($replacements)) {
/* Old style call to t(...). Print warning to log. */
$backtrace = debug_backtrace();
$where = $backtrace[0]['file'] . ':' . $backtrace[0]['line'];
SimpleSAML_Logger::warning('Deprecated use of SimpleSAML_Template::t(...) at ' . $where .
'. Please update the code to use the new style of parameters.');
/* For backwards compatibility. */
if(!$replacements && $this->getTag($tag) === NULL) {
SimpleSAML_Logger::warning('Code which uses $fallbackdefault === FALSE shouls be' .
' updated to use the getTag-method instead.');
return NULL;
}
$replacements = $oldreplacements;
}
if (empty($this->langtext) || !is_array($this->langtext)) {
SimpleSAML_Logger::error('Template: No language text loaded. Looking up [' . $tag . ']');
return $this->t_not_translated($tag, $fallbacktag);
return $this->t_not_translated($tag, TRUE);
}
$selected_language = $this->getLanguage();
......@@ -230,7 +245,7 @@ class SimpleSAML_XHTML_Template {
if($tagData === NULL) {
/* Tag not found. */
SimpleSAML_Logger::info('Template: Looking up [' . $tag . ']: not translated at all.');
return $this->t_not_translated($tag, $fallbacktag);
return $this->t_not_translated($tag, TRUE);
}
/**
......@@ -242,16 +257,16 @@ class SimpleSAML_XHTML_Template {
$translated = $tagData[$selected_language];
/**
* Look up translation of tag in the default language, only if fallbackdefault = true (method parameter)
* Look up translation of tag in the default language
*/
} elseif($fallbackdefault && array_key_exists($default_language, $tagData)) {
} elseif(array_key_exists($default_language, $tagData)) {
SimpleSAML_Logger::info('Template: Looking up [' . $tag . ']: not found in language [' . $selected_language . '] using default [' . $default_language . '].');
$translated = $tagData[$default_language];
/**
* Look up translation of tag in the base language, only if fallbackdefault = true (method parameter)
* Look up translation of tag in the base language
*/
} elseif($fallbackdefault && array_key_exists($base_language, $tagData)) {
} elseif(array_key_exists($base_language, $tagData)) {
SimpleSAML_Logger::info('Template: Looking up [' . $tag . ']: not found in language default [' . $default_language . '] using base [' . $base_language . '].');
$translated = $tagData[$base_language];
......
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