From d42f26f3c20669741d1c2ceac2f24d0c945efa91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Pe=CC=81rez=20Crespo?= <jaime.perez@uninett.no> Date: Fri, 23 Nov 2018 17:15:06 +0100 Subject: [PATCH] Create a new "configpage" hook for those modules that need to inject anything in the configuration page. This allows us to change the signature of the hook, so that we pass it the \SimpleSAML\XHTML\Template object and then the hook can not only add data to be passed to the twig template, but also add its own translation domain. This was needed because many modules were putting their translations inside "core", and when moving those to the modules themselves, the new translation system cannot perform the translation because only the translations for the current module in use are loaded (in the config page, that's the core module). Therefore, we needed a way to get the Localization instance from the template, and a way to pass that to the hook so that the hook can register the translations for its own module. --- lib/SimpleSAML/Locale/Localization.php | 4 ++-- lib/SimpleSAML/XHTML/Template.php | 11 +++++++++ .../dictionaries/consentadmin.definition.json | 3 +++ .../consentadmin.translation.json | 5 ++++ .../consentAdmin/hooks/hook_configpage.php | 19 +++++++++++++++ modules/consentAdmin/hooks/hook_frontpage.php | 17 -------------- .../dictionaries/frontpage.definition.json | 18 --------------- modules/core/www/frontpage_config.php | 4 ++++ .../cron/dictionaries/cron.definition.json | 3 +++ .../cron/dictionaries/cron.translation.json | 5 ++++ modules/cron/hooks/hook_configpage.php | 19 +++++++++++++++ modules/cron/hooks/hook_frontpage.php | 17 -------------- modules/cron/locales/en/LC_MESSAGES/cron.po | 2 ++ modules/cron/locales/es/LC_MESSAGES/cron.po | 2 ++ modules/cron/locales/nb/LC_MESSAGES/cron.po | 2 ++ modules/cron/locales/nn/LC_MESSAGES/cron.po | 2 ++ .../dictionaries/memcachestat.definition.json | 3 +++ .../memcachestat.translation.json | 5 ++++ .../memcacheMonitor/hooks/hook_configpage.php | 19 +++++++++++++++ .../memcacheMonitor/hooks/hook_frontpage.php | 17 -------------- .../locales/en/LC_MESSAGES/memcacheMonitor.po | 2 ++ .../locales/es/LC_MESSAGES/memcacheMonitor.po | 2 ++ .../locales/nb/LC_MESSAGES/memcacheMonitor.po | 2 ++ .../locales/nn/LC_MESSAGES/memcacheMonitor.po | 2 ++ .../dictionaries/strings.definition.json | 5 ++++ .../dictionaries/strings.translation.json | 7 ++++++ modules/sanitycheck/hooks/hook_configpage.php | 18 +++++++++++++++ modules/sanitycheck/hooks/hook_frontpage.php | 16 ------------- .../{messages.po => sanitycheck.po} | 2 ++ .../locales/es/LC_MESSAGES/sanitycheck.po | 8 +++++++ .../{messages.po => sanitycheck.po} | 0 .../locales/nb/LC_MESSAGES/sanitycheck.po | 8 +++++++ .../locales/nn/LC_MESSAGES/sanitycheck.po | 8 +++++++ .../dictionaries/statistics.definition.json | 8 +++++++ .../dictionaries/statistics.translation.json | 12 ++++++++++ modules/statistics/hooks/hook_configpage.php | 23 +++++++++++++++++++ modules/statistics/hooks/hook_frontpage.php | 21 ----------------- .../locales/en/LC_MESSAGES/statistics.po | 5 ++++ .../locales/es/LC_MESSAGES/statistics.po | 5 ++++ .../locales/nb/LC_MESSAGES/statistics.po | 5 ++++ .../locales/nn/LC_MESSAGES/statistics.po | 5 ++++ 41 files changed, 233 insertions(+), 108 deletions(-) create mode 100644 modules/consentAdmin/hooks/hook_configpage.php delete mode 100644 modules/consentAdmin/hooks/hook_frontpage.php create mode 100644 modules/cron/hooks/hook_configpage.php delete mode 100644 modules/cron/hooks/hook_frontpage.php create mode 100644 modules/memcacheMonitor/hooks/hook_configpage.php delete mode 100644 modules/memcacheMonitor/hooks/hook_frontpage.php create mode 100644 modules/sanitycheck/dictionaries/strings.definition.json create mode 100644 modules/sanitycheck/dictionaries/strings.translation.json create mode 100644 modules/sanitycheck/hooks/hook_configpage.php delete mode 100644 modules/sanitycheck/hooks/hook_frontpage.php rename modules/sanitycheck/locales/en/LC_MESSAGES/{messages.po => sanitycheck.po} (56%) create mode 100644 modules/sanitycheck/locales/es/LC_MESSAGES/sanitycheck.po rename modules/sanitycheck/locales/it/LC_MESSAGES/{messages.po => sanitycheck.po} (100%) create mode 100644 modules/sanitycheck/locales/nb/LC_MESSAGES/sanitycheck.po create mode 100644 modules/sanitycheck/locales/nn/LC_MESSAGES/sanitycheck.po create mode 100644 modules/statistics/dictionaries/statistics.definition.json create mode 100644 modules/statistics/dictionaries/statistics.translation.json create mode 100644 modules/statistics/hooks/hook_configpage.php delete mode 100644 modules/statistics/hooks/hook_frontpage.php create mode 100644 modules/statistics/locales/en/LC_MESSAGES/statistics.po create mode 100644 modules/statistics/locales/es/LC_MESSAGES/statistics.po create mode 100644 modules/statistics/locales/nb/LC_MESSAGES/statistics.po create mode 100644 modules/statistics/locales/nn/LC_MESSAGES/statistics.po diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index 66427da45..822a71f96 100644 --- a/lib/SimpleSAML/Locale/Localization.php +++ b/lib/SimpleSAML/Locale/Localization.php @@ -126,7 +126,7 @@ class Localization } - /* + /** * Add a new translation domain from a module * (We're assuming that each domain only exists in one place) * @@ -142,7 +142,7 @@ class Localization } - /* + /** * Add a new translation domain * (We're assuming that each domain only exists in one place) * diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 903076ff6..b055ef4a7 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -583,6 +583,17 @@ class Template extends Response } + /** + * Return the internal localization object used by this template. + * + * @return \SimpleSAML\Locale\Localization The localization object that will be used with this template. + */ + public function getLocalization() + { + return $this->localization; + } + + /** * Get the current instance of Twig in use. * diff --git a/modules/consentAdmin/dictionaries/consentadmin.definition.json b/modules/consentAdmin/dictionaries/consentadmin.definition.json index 01a48eddb..7864ff142 100644 --- a/modules/consentAdmin/dictionaries/consentadmin.definition.json +++ b/modules/consentAdmin/dictionaries/consentadmin.definition.json @@ -58,5 +58,8 @@ }, "consentadmin_purpose": { "en": "The purpose of the service is" + }, + "link_consentAdmin": { + "en": "Consent administration" } } diff --git a/modules/consentAdmin/dictionaries/consentadmin.translation.json b/modules/consentAdmin/dictionaries/consentadmin.translation.json index 18af92357..fcc1ef52f 100644 --- a/modules/consentAdmin/dictionaries/consentadmin.translation.json +++ b/modules/consentAdmin/dictionaries/consentadmin.translation.json @@ -598,5 +598,10 @@ "cs": "\u00da\u010del slu\u017eby je", "eu": "Zerbitzuaren xedea hau da", "el": "\u039f \u03c3\u03ba\u03bf\u03c0\u03cc\u03c2 \u03c4\u03b7\u03c2 \u03c5\u03c0\u03b7\u03c1\u03b5\u03c3\u03af\u03b1\u03c2 \u03b5\u03af\u03bd\u03b1\u03b9" + }, + "link_consentAdmin": { + "es": "AdministraciĂłn del consentimiento", + "no": "Samtykke administrasjon", + "nn": "Samtykke administrasjon" } } diff --git a/modules/consentAdmin/hooks/hook_configpage.php b/modules/consentAdmin/hooks/hook_configpage.php new file mode 100644 index 000000000..f4db9b01d --- /dev/null +++ b/modules/consentAdmin/hooks/hook_configpage.php @@ -0,0 +1,19 @@ +<?php +/** + * Hook to add the consentAdmin module to the config page. + * + * @param \SimpleSAML\XHTML\Template The template that we should alter in this hook. + */ + +function consentAdmin_hook_configpage(\SimpleSAML\XHTML\Template &$template) +{ + $template->data['links_config']['consentAdmin'] = [ + 'href' => SimpleSAML\Module::getModuleURL('consentAdmin/consentAdmin.php'), + 'text' => '{consentAdmin:consentadmin:link_consentAdmin}', + ]; + + $config = \SimpleSAML\Configuration::getInstance(); + if ($config->getBoolean('usenewui', false)) { + $template->getLocalization()->addModuleDomain('consentAdmin'); + } +} diff --git a/modules/consentAdmin/hooks/hook_frontpage.php b/modules/consentAdmin/hooks/hook_frontpage.php deleted file mode 100644 index 87edf27d2..000000000 --- a/modules/consentAdmin/hooks/hook_frontpage.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Hook to add the consentAdmin module to the frontpage. - * - * @param array &$links The links on the frontpage, split into sections. - */ - -function consentAdmin_hook_frontpage(&$links) -{ - assert(is_array($links)); - assert(array_key_exists('links', $links)); - - $links['config'][] = [ - 'href' => SimpleSAML\Module::getModuleURL('consentAdmin/consentAdmin.php'), - 'text' => '{core:frontpage:link_consentAdmin}', - ]; -} diff --git a/modules/core/dictionaries/frontpage.definition.json b/modules/core/dictionaries/frontpage.definition.json index 57163f5d4..98efa68a1 100644 --- a/modules/core/dictionaries/frontpage.definition.json +++ b/modules/core/dictionaries/frontpage.definition.json @@ -110,27 +110,9 @@ "link_cleardiscochoices": { "en": "Delete my choices of IdP in the IdP discovery services" }, - "link_sanitycheck": { - "en": "Sanity check of your SimpleSAMLphp setup" - }, - "link_consentAdmin": { - "en": "Consent Administration" - }, - "link_memcacheMonitor": { - "en": "MemCache Statistics" - }, "link_oauth": { "en": "OAuth Consumer Registry" }, - "link_cron": { - "en": "Cron module information page" - }, - "link_statistics": { - "en": "Show statistics" - }, - "link_statistics_metadata": { - "en": "Show statistics metadata" - }, "link_metarefresh": { "en": "Metarefresh: fetch metadata" }, diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php index 02accc6fb..d01ade0c3 100644 --- a/modules/core/www/frontpage_config.php +++ b/modules/core/www/frontpage_config.php @@ -53,6 +53,8 @@ $allLinks = [ 'federation' => &$links_federation, ]; \SimpleSAML\Module::callHooks('frontpage', $allLinks); +\SimpleSAML\Logger::debug('The "frontpage" hook has been deprecated for the configuration page. Implement the '.' + "configpage" hook instead.'); // Check for updates. Store the remote result in the session so we // don't need to fetch it on every access to this page. @@ -197,4 +199,6 @@ $t->data['requiredmap'] = [ $t->data['version'] = $config->getVersion(); $t->data['directory'] = dirname(dirname(dirname(dirname(__FILE__)))); +\SimpleSAML\Module::callHooks('configpage', $t); + $t->show(); diff --git a/modules/cron/dictionaries/cron.definition.json b/modules/cron/dictionaries/cron.definition.json index 74696abe0..176150693 100644 --- a/modules/cron/dictionaries/cron.definition.json +++ b/modules/cron/dictionaries/cron.definition.json @@ -22,5 +22,8 @@ }, "cron_report_title": { "en": "Cron report" + }, + "link_cron": { + "en": "Cron module information page" } } \ No newline at end of file diff --git a/modules/cron/dictionaries/cron.translation.json b/modules/cron/dictionaries/cron.translation.json index 95d78122a..db5bfa4a2 100644 --- a/modules/cron/dictionaries/cron.translation.json +++ b/modules/cron/dictionaries/cron.translation.json @@ -254,5 +254,10 @@ "af": "Cron verslag", "pt-br": "Relat\u00f3rio do cron", "el": "\u0391\u03bd\u03b1\u03c6\u03bf\u03c1\u03ac cron" + }, + "link_cron": { + "es": "Informe de cron", + "no": "Informasjon om cron", + "nn": "Informasjon om cron" } } diff --git a/modules/cron/hooks/hook_configpage.php b/modules/cron/hooks/hook_configpage.php new file mode 100644 index 000000000..474c6acbc --- /dev/null +++ b/modules/cron/hooks/hook_configpage.php @@ -0,0 +1,19 @@ +<?php +/** + * Hook to add the cron module to the config page. + * + * @param \SimpleSAML\XHTML\Template &$template The template that we should alter in this hook. + */ + +function cron_hook_configpage(\SimpleSAML\XHTML\Template &$template) +{ + $template->data['links_config']['cron'] = [ + 'href' => SimpleSAML\Module::getModuleURL('cron/croninfo.php'), + 'text' => '{cron:cron:link_cron}', + ]; + + $config = \SimpleSAML\Configuration::getInstance(); + if ($config->getBoolean('usenewui', false)) { + $template->getLocalization()->addModuleDomain('cron'); + } +} diff --git a/modules/cron/hooks/hook_frontpage.php b/modules/cron/hooks/hook_frontpage.php deleted file mode 100644 index c9e2eb2dc..000000000 --- a/modules/cron/hooks/hook_frontpage.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Hook to add the modinfo module to the frontpage. - * - * @param array &$links The links on the frontpage, split into sections. - */ - -function cron_hook_frontpage(&$links) -{ - assert(is_array($links)); - assert(array_key_exists('links', $links)); - - $links['config'][] = [ - 'href' => SimpleSAML\Module::getModuleURL('cron/croninfo.php'), - 'text' => '{core:frontpage:link_cron}', - ]; -} diff --git a/modules/cron/locales/en/LC_MESSAGES/cron.po b/modules/cron/locales/en/LC_MESSAGES/cron.po index 21c02a769..aa2e95e78 100644 --- a/modules/cron/locales/en/LC_MESSAGES/cron.po +++ b/modules/cron/locales/en/LC_MESSAGES/cron.po @@ -63,3 +63,5 @@ msgstr "Here are the result for the cron job execution:" msgid "Cron result page" msgstr "Cron result page" +msgid "{cron:cron:link_cron}" +msgstr "Cron module information page" diff --git a/modules/cron/locales/es/LC_MESSAGES/cron.po b/modules/cron/locales/es/LC_MESSAGES/cron.po index a8a03ec8a..5a8b9dbe1 100644 --- a/modules/cron/locales/es/LC_MESSAGES/cron.po +++ b/modules/cron/locales/es/LC_MESSAGES/cron.po @@ -63,3 +63,5 @@ msgstr "Aqui están los resultados de las tareas en la ejecuciĂłn del cron:" msgid "Cron result page" msgstr "Página de resultado del cron" +msgid "{cron:cron:link_cron}" +msgstr "Informe de cron" diff --git a/modules/cron/locales/nb/LC_MESSAGES/cron.po b/modules/cron/locales/nb/LC_MESSAGES/cron.po index f6ba2ef3c..aaec4ad38 100644 --- a/modules/cron/locales/nb/LC_MESSAGES/cron.po +++ b/modules/cron/locales/nb/LC_MESSAGES/cron.po @@ -63,3 +63,5 @@ msgstr "Her er resultatene fra kjøring av cron-jobben:" msgid "Cron result page" msgstr "Cron resultatside" +msgid "{cron:cron:link_cron}" +msgstr "Informasjon om cron" diff --git a/modules/cron/locales/nn/LC_MESSAGES/cron.po b/modules/cron/locales/nn/LC_MESSAGES/cron.po index b782c3ad5..5aeba2dd6 100644 --- a/modules/cron/locales/nn/LC_MESSAGES/cron.po +++ b/modules/cron/locales/nn/LC_MESSAGES/cron.po @@ -63,3 +63,5 @@ msgstr "Her er resultata frĂĄ køyring av cron-jobben:" msgid "Cron result page" msgstr "Cron resultatside" +msgid "{cron:cron:link_cron}" +msgstr "Informasjon om cron" diff --git a/modules/memcacheMonitor/dictionaries/memcachestat.definition.json b/modules/memcacheMonitor/dictionaries/memcachestat.definition.json index 885b47508..77817ff06 100644 --- a/modules/memcacheMonitor/dictionaries/memcachestat.definition.json +++ b/modules/memcacheMonitor/dictionaries/memcachestat.definition.json @@ -142,5 +142,8 @@ }, "reclaimed": { "en": "Number of times an entry was stored using memory from an expired entry" + }, + "link_memcacheMonitor": { + "en": "Memcache statistics" } } diff --git a/modules/memcacheMonitor/dictionaries/memcachestat.translation.json b/modules/memcacheMonitor/dictionaries/memcachestat.translation.json index fbc7157e7..e2361455c 100644 --- a/modules/memcacheMonitor/dictionaries/memcachestat.translation.json +++ b/modules/memcacheMonitor/dictionaries/memcachestat.translation.json @@ -549,5 +549,10 @@ "cs": "Celkov\u00e9 dostupn\u00e9 \u00falo\u017ei\u0161t\u011b", "eu": "Ustiatutako biltegiraketa guztira", "el": "\u0394\u03b9\u03b1\u03b8\u03ad\u03c3\u03b9\u03bc\u03bf\u03c2 \u03c7\u03ce\u03c1\u03bf\u03c2 \u03b1\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7\u03c2" + }, + "link_memcacheMonitor": { + "es": "EstadĂsticas de memcache", + "no": "Memcache statistikker", + "nn": "Memcache statistikkar" } } diff --git a/modules/memcacheMonitor/hooks/hook_configpage.php b/modules/memcacheMonitor/hooks/hook_configpage.php new file mode 100644 index 000000000..9e9689b08 --- /dev/null +++ b/modules/memcacheMonitor/hooks/hook_configpage.php @@ -0,0 +1,19 @@ +<?php +/** + * Hook to add the memcacheMonitor module to the config page. + * + * @param \SimpleSAML\XHTML\Template &$template The template that we should alter in this hook. + */ + +function memcacheMonitor_hook_configpage(\SimpleSAML\XHTML\Template &$template) +{ + $template->data['links_config']['memcacheMonitor'] = [ + 'href' => SimpleSAML\Module::getModuleURL('memcacheMonitor/memcachestat.php'), + 'text' => '{memcacheMonitor:memcachestat:link_memcacheMonitor}', + ]; + + $config = \SimpleSAML\Configuration::getInstance(); + if ($config->getBoolean('usenewui', false)) { + $template->getLocalization()->addModuleDomain('memcacheMonitor'); + } +} diff --git a/modules/memcacheMonitor/hooks/hook_frontpage.php b/modules/memcacheMonitor/hooks/hook_frontpage.php deleted file mode 100644 index 9329d5531..000000000 --- a/modules/memcacheMonitor/hooks/hook_frontpage.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Hook to add the simple consenet admin module to the frontpage. - * - * @param array &$links The links on the frontpage, split into sections. - */ - -function memcacheMonitor_hook_frontpage(&$links) -{ - assert(is_array($links)); - assert(array_key_exists('links', $links)); - - $links['config'][] = [ - 'href' => SimpleSAML\Module::getModuleURL('memcacheMonitor/memcachestat.php'), - 'text' => '{core:frontpage:link_memcacheMonitor}', - ]; -} diff --git a/modules/memcacheMonitor/locales/en/LC_MESSAGES/memcacheMonitor.po b/modules/memcacheMonitor/locales/en/LC_MESSAGES/memcacheMonitor.po index bab82dd3f..29afe1b3b 100644 --- a/modules/memcacheMonitor/locales/en/LC_MESSAGES/memcacheMonitor.po +++ b/modules/memcacheMonitor/locales/en/LC_MESSAGES/memcacheMonitor.po @@ -264,3 +264,5 @@ msgstr "CPU Seconds (System)" msgid "Total connections" msgstr "Total connections" +msgid "{memcacheMonitor:memcachestat:link_memcacheMonitor}" +msgstr "Memcache statistics" diff --git a/modules/memcacheMonitor/locales/es/LC_MESSAGES/memcacheMonitor.po b/modules/memcacheMonitor/locales/es/LC_MESSAGES/memcacheMonitor.po index 0f9197c69..e9e23f7be 100644 --- a/modules/memcacheMonitor/locales/es/LC_MESSAGES/memcacheMonitor.po +++ b/modules/memcacheMonitor/locales/es/LC_MESSAGES/memcacheMonitor.po @@ -129,3 +129,5 @@ msgstr "Segundos de CPU (Sistema)" msgid "Total connections" msgstr "Total de conexiones" +msgid "{memcacheMonitor:memcachestat:link_memcacheMonitor}" +msgstr "EstadĂsticas de memcache" diff --git a/modules/memcacheMonitor/locales/nb/LC_MESSAGES/memcacheMonitor.po b/modules/memcacheMonitor/locales/nb/LC_MESSAGES/memcacheMonitor.po index 0fca4b31e..accddc927 100644 --- a/modules/memcacheMonitor/locales/nb/LC_MESSAGES/memcacheMonitor.po +++ b/modules/memcacheMonitor/locales/nb/LC_MESSAGES/memcacheMonitor.po @@ -129,3 +129,5 @@ msgstr "CPU Sekunder (system)" msgid "Total connections" msgstr "Totalt antall forbindelser" +msgid "{memcacheMonitor:memcachestat:link_memcacheMonitor}" +msgstr "Memcache statistikker" diff --git a/modules/memcacheMonitor/locales/nn/LC_MESSAGES/memcacheMonitor.po b/modules/memcacheMonitor/locales/nn/LC_MESSAGES/memcacheMonitor.po index d50527933..b54c51531 100644 --- a/modules/memcacheMonitor/locales/nn/LC_MESSAGES/memcacheMonitor.po +++ b/modules/memcacheMonitor/locales/nn/LC_MESSAGES/memcacheMonitor.po @@ -129,3 +129,5 @@ msgstr "CPU-sekund (system)" msgid "Total connections" msgstr "Opne tilkoplingar (totalt)" +msgid "{memcacheMonitor:memcachestat:link_memcacheMonitor}" +msgstr "Memcache statistikkar" diff --git a/modules/sanitycheck/dictionaries/strings.definition.json b/modules/sanitycheck/dictionaries/strings.definition.json new file mode 100644 index 000000000..38aa732b3 --- /dev/null +++ b/modules/sanitycheck/dictionaries/strings.definition.json @@ -0,0 +1,5 @@ +{ + "link_sanitycheck": { + "en": "Sanity check of your SimpleSAMLphp setup" + } +} \ No newline at end of file diff --git a/modules/sanitycheck/dictionaries/strings.translation.json b/modules/sanitycheck/dictionaries/strings.translation.json new file mode 100644 index 000000000..a3940e048 --- /dev/null +++ b/modules/sanitycheck/dictionaries/strings.translation.json @@ -0,0 +1,7 @@ +{ + "link_sanitycheck": { + "es": "Comprobaciones básicas de la instalaciĂłn", + "no": "Sjekk din installasjon", + "nn": "Sjekk din installasjon" + } +} \ No newline at end of file diff --git a/modules/sanitycheck/hooks/hook_configpage.php b/modules/sanitycheck/hooks/hook_configpage.php new file mode 100644 index 000000000..18b20e114 --- /dev/null +++ b/modules/sanitycheck/hooks/hook_configpage.php @@ -0,0 +1,18 @@ +<?php +/** + * Hook to add the sanitycheck link to the config page. + * + * @param \SimpleSAML\XHTML\Template The template that we should alter in this hook. + */ +function sanitycheck_hook_configpage(\SimpleSAML\XHTML\Template &$template) +{ + $template->data['links_config']['sanitycheck'] = [ + 'href' => SimpleSAML\Module::getModuleURL('sanitycheck/index.php'), + 'text' => '{sanitycheck:strings:link_sanitycheck}', + ]; + + $config = \SimpleSAML\Configuration::getInstance(); + if ($config->getBoolean('usenewui', false)) { + $template->getLocalization()->addModuleDomain('sanitycheck'); + } +} diff --git a/modules/sanitycheck/hooks/hook_frontpage.php b/modules/sanitycheck/hooks/hook_frontpage.php deleted file mode 100644 index 95dddf7aa..000000000 --- a/modules/sanitycheck/hooks/hook_frontpage.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Hook to add the modinfo module to the frontpage. - * - * @param array &$links The links on the frontpage, split into sections. - */ -function sanitycheck_hook_frontpage(&$links) -{ - assert(is_array($links)); - assert(array_key_exists('links', $links)); - - $links['config']['sanitycheck'] = [ - 'href' => SimpleSAML\Module::getModuleURL('sanitycheck/index.php'), - 'text' => '{core:frontpage:link_sanitycheck}', - ]; -} diff --git a/modules/sanitycheck/locales/en/LC_MESSAGES/messages.po b/modules/sanitycheck/locales/en/LC_MESSAGES/sanitycheck.po similarity index 56% rename from modules/sanitycheck/locales/en/LC_MESSAGES/messages.po rename to modules/sanitycheck/locales/en/LC_MESSAGES/sanitycheck.po index 2b50d34d1..7f1cd2174 100644 --- a/modules/sanitycheck/locales/en/LC_MESSAGES/messages.po +++ b/modules/sanitycheck/locales/en/LC_MESSAGES/sanitycheck.po @@ -4,3 +4,5 @@ msgstr "These checks failed:" msgid "These checks succeeded:" msgstr "These checks succeeded:" +msgid "{sanitycheck:strings:link_sanitycheck}" +msgstr "Sanity check of your SimpleSAMLphp setup" \ No newline at end of file diff --git a/modules/sanitycheck/locales/es/LC_MESSAGES/sanitycheck.po b/modules/sanitycheck/locales/es/LC_MESSAGES/sanitycheck.po new file mode 100644 index 000000000..0a98c4369 --- /dev/null +++ b/modules/sanitycheck/locales/es/LC_MESSAGES/sanitycheck.po @@ -0,0 +1,8 @@ +msgid "These checks failed:" +msgstr "Las siguientes comprobaciones han fallado:" + +msgid "These checks succeeded:" +msgstr "Las siguientes comprobaciones fueron satisfactorias:" + +msgid "{sanitycheck:strings:link_sanitycheck}" +msgstr "Comprobaciones básicas de la instalaciĂłn" diff --git a/modules/sanitycheck/locales/it/LC_MESSAGES/messages.po b/modules/sanitycheck/locales/it/LC_MESSAGES/sanitycheck.po similarity index 100% rename from modules/sanitycheck/locales/it/LC_MESSAGES/messages.po rename to modules/sanitycheck/locales/it/LC_MESSAGES/sanitycheck.po diff --git a/modules/sanitycheck/locales/nb/LC_MESSAGES/sanitycheck.po b/modules/sanitycheck/locales/nb/LC_MESSAGES/sanitycheck.po new file mode 100644 index 000000000..c582429c3 --- /dev/null +++ b/modules/sanitycheck/locales/nb/LC_MESSAGES/sanitycheck.po @@ -0,0 +1,8 @@ +msgid "These checks failed:" +msgstr "Disse sjekkene har feila:" + +msgid "These checks succeeded:" +msgstr "Disse sjekkene var suksessfulle:" + +msgid "{sanitycheck:strings:link_sanitycheck}" +msgstr "Sjekk din installasjon" diff --git a/modules/sanitycheck/locales/nn/LC_MESSAGES/sanitycheck.po b/modules/sanitycheck/locales/nn/LC_MESSAGES/sanitycheck.po new file mode 100644 index 000000000..f49cb0226 --- /dev/null +++ b/modules/sanitycheck/locales/nn/LC_MESSAGES/sanitycheck.po @@ -0,0 +1,8 @@ +msgid "These checks failed:" +msgstr "These checks failed:" + +msgid "These checks succeeded:" +msgstr "Desse sjekkane var suksessfulle:" + +msgid "{sanitycheck:strings:link_sanitycheck}" +msgstr "Sjekk din installasjon" diff --git a/modules/statistics/dictionaries/statistics.definition.json b/modules/statistics/dictionaries/statistics.definition.json new file mode 100644 index 000000000..065b7b4d3 --- /dev/null +++ b/modules/statistics/dictionaries/statistics.definition.json @@ -0,0 +1,8 @@ +{ + "link_statistics": { + "en": "Show statistics" + }, + "link_statistics_metadata": { + "en": "Show statistics metadata" + } +} \ No newline at end of file diff --git a/modules/statistics/dictionaries/statistics.translation.json b/modules/statistics/dictionaries/statistics.translation.json new file mode 100644 index 000000000..1f51b3838 --- /dev/null +++ b/modules/statistics/dictionaries/statistics.translation.json @@ -0,0 +1,12 @@ +{ + "link_statistics": { + "es": "Mostrar estadĂsticas", + "no": "Vis statistikker", + "nn": "Vis statistikkar" + }, + "link_statistics_metadata": { + "es": "Mostrar metadatos de las estadĂsticas", + "no": "Vis metadata om statistikker", + "nn": "Vis metadata om statistikkar" + } +} diff --git a/modules/statistics/hooks/hook_configpage.php b/modules/statistics/hooks/hook_configpage.php new file mode 100644 index 000000000..33a93f1b1 --- /dev/null +++ b/modules/statistics/hooks/hook_configpage.php @@ -0,0 +1,23 @@ +<?php +/** + * Hook to add the statistics module to the config page. + * + * @param \SimpleSAML\XHTML\Template &$template The template that we should alter in this hook. + */ +function statistics_hook_configpage(\SimpleSAML\XHTML\Template &$template) +{ + $template->data['links_config']['statistics'] = [ + 'href' => SimpleSAML\Module::getModuleURL('statistics/showstats.php'), + 'text' => '{statistics:statistics:link_statistics}', + ]; + $template->data['links_config']['statisticsmeta'] = [ + 'href' => SimpleSAML\Module::getModuleURL('statistics/statmeta.php'), + 'text' => '{statistics:statistics:link_statistics_metadata}', + 'shorttext' => ['en' => 'Statistics metadata', 'no' => 'Statistikk metadata'], + ]; + + $config = \SimpleSAML\Configuration::getInstance(); + if ($config->getBoolean('usenewui', false)) { + $template->getLocalization()->addModuleDomain('statistics'); + } +} diff --git a/modules/statistics/hooks/hook_frontpage.php b/modules/statistics/hooks/hook_frontpage.php deleted file mode 100644 index 462a300bf..000000000 --- a/modules/statistics/hooks/hook_frontpage.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Hook to add the modinfo module to the frontpage. - * - * @param array &$links The links on the frontpage, split into sections. - */ -function statistics_hook_frontpage(&$links) -{ - assert(is_array($links)); - assert(array_key_exists('links', $links)); - - $links['config']['statistics'] = [ - 'href' => SimpleSAML\Module::getModuleURL('statistics/showstats.php'), - 'text' => '{core:frontpage:link_statistics}', - ]; - $links['config']['statisticsmeta'] = [ - 'href' => SimpleSAML\Module::getModuleURL('statistics/statmeta.php'), - 'text' => '{core:frontpage:link_statistics_metadata}', - 'shorttext' => ['en' => 'Statistics metadata', 'no' => 'Statistikk metadata'], - ]; -} diff --git a/modules/statistics/locales/en/LC_MESSAGES/statistics.po b/modules/statistics/locales/en/LC_MESSAGES/statistics.po new file mode 100644 index 000000000..9c5a14b57 --- /dev/null +++ b/modules/statistics/locales/en/LC_MESSAGES/statistics.po @@ -0,0 +1,5 @@ +msgid "{statistics:statistics:link_statistics" +msgstr "Show statistics" + +msgid "{statistics:statistics:link_statistics_metadata" +msgstr "Show statistics metadata" \ No newline at end of file diff --git a/modules/statistics/locales/es/LC_MESSAGES/statistics.po b/modules/statistics/locales/es/LC_MESSAGES/statistics.po new file mode 100644 index 000000000..23f72c387 --- /dev/null +++ b/modules/statistics/locales/es/LC_MESSAGES/statistics.po @@ -0,0 +1,5 @@ +msgid "{statistics:statistics:link_statistics" +msgstr "Mostrar estadĂsticas" + +msgid "{statistics:statistics:link_statistics_metadata" +msgstr "Mostrar metadatos de las estadĂsticas" \ No newline at end of file diff --git a/modules/statistics/locales/nb/LC_MESSAGES/statistics.po b/modules/statistics/locales/nb/LC_MESSAGES/statistics.po new file mode 100644 index 000000000..c2686f160 --- /dev/null +++ b/modules/statistics/locales/nb/LC_MESSAGES/statistics.po @@ -0,0 +1,5 @@ +msgid "{statistics:statistics:link_statistics" +msgstr "Vis statistikker" + +msgid "{statistics:statistics:link_statistics_metadata" +msgstr "Vis metadata om statistikker" diff --git a/modules/statistics/locales/nn/LC_MESSAGES/statistics.po b/modules/statistics/locales/nn/LC_MESSAGES/statistics.po new file mode 100644 index 000000000..30cd4a568 --- /dev/null +++ b/modules/statistics/locales/nn/LC_MESSAGES/statistics.po @@ -0,0 +1,5 @@ +msgid "{statistics:statistics:link_statistics" +msgstr "Vis statistikkar" + +msgid "{statistics:statistics:link_statistics_metadata" +msgstr "Vis metadata om statistikkar" -- GitLab