From d6d7b56f06f36c110728dd3c7d5fb94fae6dcadf Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Thu, 21 Oct 2010 11:20:24 +0000 Subject: [PATCH] Add support for extra attribute dictionaries. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2582 44740490-163a-0410-bde0-09ae8108e29a --- config-templates/config.php | 28 +++++++++++++++++++++++++++- lib/SimpleSAML/XHTML/Template.php | 9 +++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/config-templates/config.php b/config-templates/config.php index 7222376ca..77d0604e5 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -202,7 +202,33 @@ $config = array ( */ 'language.available' => array('en', 'no', 'nn', 'se', 'da', 'de', 'sv', 'fi', 'es', 'fr', 'it', 'nl', 'lb', 'cs', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt-BR', 'tr'), 'language.default' => 'en', - + + /* + * Extra dictionary for attribute names. + * This can be used to define local attributes. + * + * The format of the parameter is a string with <module>:<dictionary>. + * + * Specifying this option will cause us to look for modules/<module>/dictionaries/<dictionary>.definition.json + * The dictionary should look something like: + * + * { + * "firstattribute": { + * "en": "English name", + * "no": "Norwegian name" + * }, + * "secondattribute": { + * "en": "English name", + * "no": "Norwegian name" + * } + * } + * + * Note that all attribute names in the dictionary must in lowercase. + * + * Example: 'attributes.extradictionary' => 'ourmodule:ourattributes', + */ + 'attributes.extradictionary' => NULL, + /* * Which theme directory should be used? */ diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index e92684813..03fe5e286 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -307,6 +307,15 @@ class SimpleSAML_XHTML_Template { $normName = strtolower($name); $normName = str_replace(":", "_", $normName); + /* Check for an extra dictionary. */ + $extraDict = $this->configuration->getString('attributes.extradictionary', NULL); + if ($extraDict !== NULL) { + $dict = $this->getDictionary($extraDict); + if (array_key_exists($normName, $dict)) { + return $this->getTranslation($dict[$normName]); + } + } + /* Search the default attribute dictionary. */ $dict = $this->getDictionary('attributes'); if (array_key_exists('attribute_' . $normName, $dict)) { -- GitLab