From f6896a5e2b4512eba09f0ea1c412be39f07cf8f4 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Tue, 12 Dec 2017 11:28:57 +0100 Subject: [PATCH] core: Add a couple more Twig-templates --- modules/consentAdmin/hooks/hook_frontpage.php | 2 +- modules/core/locales/en/LC_MESSAGES/core.po | 24 +++++++ modules/core/templates/authsource_list.twig | 11 ++++ modules/core/templates/frontpage_auth.twig | 23 +++++++ .../core/templates/frontpage_config.tpl.php | 8 +-- modules/core/templates/frontpage_config.twig | 65 +++++++++++++++++++ modules/core/www/authenticate.php | 1 + modules/core/www/frontpage_auth.php | 3 +- modules/core/www/frontpage_config.php | 7 +- modules/cron/hooks/hook_frontpage.php | 2 +- .../memcacheMonitor/hooks/hook_frontpage.php | 2 +- modules/metarefresh/hooks/hook_frontpage.php | 2 +- modules/oauth/hooks/hook_frontpage.php | 3 +- modules/sanitycheck/hooks/hook_frontpage.php | 3 +- modules/statistics/hooks/hook_frontpage.php | 5 +- 15 files changed, 142 insertions(+), 19 deletions(-) create mode 100644 modules/core/templates/authsource_list.twig create mode 100644 modules/core/templates/frontpage_auth.twig create mode 100644 modules/core/templates/frontpage_config.twig diff --git a/modules/consentAdmin/hooks/hook_frontpage.php b/modules/consentAdmin/hooks/hook_frontpage.php index 61c4bd6b1..9659a869f 100644 --- a/modules/consentAdmin/hooks/hook_frontpage.php +++ b/modules/consentAdmin/hooks/hook_frontpage.php @@ -10,6 +10,6 @@ function consentAdmin_hook_frontpage(&$links) { $links['config'][] = array( 'href' => SimpleSAML\Module::getModuleURL('consentAdmin/consentAdmin.php'), - 'text' => '{consentAdmin:consentadmin:consentadmin_header}', + 'text' => '{core:frontpage:link_consentAdmin}', ); } diff --git a/modules/core/locales/en/LC_MESSAGES/core.po b/modules/core/locales/en/LC_MESSAGES/core.po index bf9ee93f8..0c2a4fc64 100644 --- a/modules/core/locales/en/LC_MESSAGES/core.po +++ b/modules/core/locales/en/LC_MESSAGES/core.po @@ -54,6 +54,30 @@ msgstr "OpenID Provider site - Alpha version (test code)" msgid "{core:frontpage:link_doc_install}" msgstr "Installing SimpleSAMLphp" +msgid "{core:frontpage:link_consentAdmin}" +msgstr "Consent Administration" + +msgid "{core:frontpage:link_memcacheMonitor}" +msgstr "MemCache Statistics" + +msgid "{core:frontpage:link_oauth}" +msgstr "OAuth Consumer Registry" + +msgid "{core:frontpage:link_cron}" +msgstr "Cron module information page" + +msgid "{core:frontpage:link_statistics}" +msgstr "Show statistics" + +msgid "{core:frontpage:link_statistics_metadata}" +msgstr "Show statistics metadata" + +msgid "{core:frontpage:link_metarefresh}" +msgstr "Metarefresh: fetch metadata" + +msgid "{core:frontpage:link_santitycheck}" +msgstr "Sanity check of your SimpleSAMLphp setup" + msgid "{core:frontpage:link_diagnostics}" msgstr "Diagnostics on hostname, port and protocol" diff --git a/modules/core/templates/authsource_list.twig b/modules/core/templates/authsource_list.twig new file mode 100644 index 000000000..acf0d57fa --- /dev/null +++ b/modules/core/templates/authsource_list.twig @@ -0,0 +1,11 @@ +{% set pagetitle = 'Test Authentication Sources'|trans %} +{% extends "base.twig" %} + +{% block content %} + <h1>{{ header }}</h1> + <ul> + {% for key, name in sources %} + <li><a href="?as={{ name|escape('url') }}">{{ name|escape('html') }}</a></li> + {% endfor %} + </ul> +{% endblock %} diff --git a/modules/core/templates/frontpage_auth.twig b/modules/core/templates/frontpage_auth.twig new file mode 100644 index 000000000..5767915bb --- /dev/null +++ b/modules/core/templates/frontpage_auth.twig @@ -0,0 +1,23 @@ +{% set pagetitle = '{core:frontpage:page_title}'|trans %} +{% extends "base.twig" %} + +{% block content %} + {% if isadmin %} + <p class="float-r youareadmin">{{ '{core:frontpage:loggedin_as_admin}'|trans }}</p> + {% else %} + <p class="float-r youareadmin"> + <a href="{{ loginurl|escape('url') }}">{{ '{core:frontpage:login_as_admin}'|trans }}</a> + </p> + {% endif %} + + <ul> + {% for key, link in links_auth %} + <li> + <a href="{{ link.href|escape('url') }}">{{ link.text|trans|escape('html') }}</a> + {% if link.deprecated is defined and link.deprecated is not empty %} + <span style="font-weight: bold;">{{ '{core:frontpage:deprecated}'|trans }}</b> + {% endif %} + </li> + {% endfor %} + </ul> +{% endblock %} diff --git a/modules/core/templates/frontpage_config.tpl.php b/modules/core/templates/frontpage_config.tpl.php index 4bf19eff9..aeaa64af1 100644 --- a/modules/core/templates/frontpage_config.tpl.php +++ b/modules/core/templates/frontpage_config.tpl.php @@ -40,11 +40,11 @@ if ($this->data['isadmin']) { $icon_disabled = '<img src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/delete.png" alt="disabled" />'; ?> - <tr class="<?php echo $this->data['enablematrix']['saml20-idp'] ? 'enabled' : 'disabled'; ?>"><td>SAML 2.0 IdP</td> - <td><?php echo $this->data['enablematrix']['saml20-idp'] ? $icon_enabled : $icon_disabled; ?></td></tr> + <tr class="<?php echo $this->data['enablematrix']['saml20idp'] ? 'enabled' : 'disabled'; ?>"><td>SAML 2.0 IdP</td> + <td><?php echo $this->data['enablematrix']['saml20idp'] ? $icon_enabled : $icon_disabled; ?></td></tr> - <tr class="<?php echo $this->data['enablematrix']['shib13-idp'] ? 'enabled' : 'disabled'; ?>"><td>Shib 1.3 IdP</td> - <td><?php echo $this->data['enablematrix']['shib13-idp'] ? $icon_enabled : $icon_disabled; ?></td></tr> + <tr class="<?php echo $this->data['enablematrix']['shib13idp'] ? 'enabled' : 'disabled'; ?>"><td>Shib 1.3 IdP</td> + <td><?php echo $this->data['enablematrix']['shib13idp'] ? $icon_enabled : $icon_disabled; ?></td></tr> </table> </div> diff --git a/modules/core/templates/frontpage_config.twig b/modules/core/templates/frontpage_config.twig new file mode 100644 index 000000000..fc702d908 --- /dev/null +++ b/modules/core/templates/frontpage_config.twig @@ -0,0 +1,65 @@ +{% set pagetitle = '{core:frontpage:page_title}'|trans %} +{% extends "base.twig" %} + +{% block content %} + {% if isadmin %} + <p class="float-r youareadmin">{{ '{core:frontpage:loggedin_as_admin}'|trans }}</p> + {% else %} + <p class="float-r youareadmin"> + <a href="{{ loginurl|escape('url') }}">{{ '{core:frontpage:login_as_admin}'|trans }}</a> + </p> + {% endif %} + + <div style="margin-top: 1em;"> + <code style="background: white; background: #f5f5f5; border: 1px dotted #bbb; padding: 1em; color: #555" >{{ directory }} ({{ version }})</code> + </div> + + {% set icon_enabled = '<img src="/' ~ baseurlpath ~ 'resources/icons/silk/accept.png" alt="enabled" />' %} + {% set icon_disabled = '<img src="/' ~ baseurlpath ~ 'resources/icons/silk/delete.png" alt="disabled" />' %} + + <div style="clear: both" class="enablebox mini"> + <table> + <tr class="{%- if enablematrix.saml20idp %}enabled{% else %}disabled{% endif -%}"> + <td>SAML 2.0 IdP</td> + <td>{%- if enablematrix.saml20idp %}{{ icon_enabled|raw }}{% else %}{{ icon_disabled|raw }}{% endif -%}</td> + </tr> + <tr class="{%- if enablematrix.shib13idp %}enabled{% else %}disabled{% endif -%}"> + <td>Shib 1.3 IdP</td> + <td>{%- if enablematrix.shib13idp %}{{ icon_enabled|raw }}{% else %}{{ icon_disabled|raw }}{% endif -%}</td> + </tr> + </table> + </div> + + <h2>{{ '{core:frontpage:configuration}'|trans }}</h2> + <ul> + {% for key, link in links_config %} + <li><a href="{{ link.href|escape('html') }}">{{ link.text|trans|escape('html') }}</a></li> + {% endfor %} + </ul> + + {% if warnings is defined and warnings is not empty %} + <h2>{{ '{core:frontpage:warnings}'|trans|escape('html') }}</h2> + {% for key, warning in warnings %} + {% if warning is iterable %} + <div class="caution">{{ warning[0]|trans(warning[1], "app")|raw }}</div> + {% else %} + <div class="caution">{{ warning|trans|raw }}</div> + {% endif %} + {% endfor %} + {% endif %} + + {% if isadmin %} + <h2>{{ '{core:frontpage:checkphp}'|trans }}</h2> + <div class="enablebox"> + <table> + {% for key, func in funcmatrix %} + <tr class="{%- if func.enabled %}enabled{% else %}disabled{% endif -%}"> + <td>{%- if func.enabled %}{{ icon_enabled|raw }}{% else %}{{ icon_disabled|raw }}{% endif -%}</td> + <td>{{ requiredmap[func.required]|trans }}</td> + <td>{{ func.descr }}</td> + </tr> + {% endfor %} + </table> + </div> + {% endif %} +{% endblock %} diff --git a/modules/core/www/authenticate.php b/modules/core/www/authenticate.php index 8e04e4a6c..d09947b36 100644 --- a/modules/core/www/authenticate.php +++ b/modules/core/www/authenticate.php @@ -5,6 +5,7 @@ $config = SimpleSAML_Configuration::getInstance(); if (!array_key_exists('as', $_REQUEST)) { $t = new SimpleSAML_XHTML_Template($config, 'core:authsource_list.tpl.php'); + $t->data['header'] = 'Test authentication sources'; $t->data['sources'] = SimpleSAML_Auth_Source::getSources(); $t->show(); exit(); diff --git a/modules/core/www/frontpage_auth.php b/modules/core/www/frontpage_auth.php index 59e0ee8a5..01bd36852 100644 --- a/modules/core/www/frontpage_auth.php +++ b/modules/core/www/frontpage_auth.php @@ -44,14 +44,13 @@ $t->data['pageid'] = 'frontpage_auth'; $t->data['isadmin'] = $isadmin; $t->data['loginurl'] = $loginurl; +$t->data['header'] = $t->t('{core:frontpage:page_title}'); $t->data['links'] = $links; $t->data['links_welcome'] = $links_welcome; $t->data['links_config'] = $links_config; $t->data['links_auth'] = $links_auth; $t->data['links_federation'] = $links_federation; - - $t->show(); diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php index 776b9e074..e12a6704a 100644 --- a/modules/core/www/frontpage_config.php +++ b/modules/core/www/frontpage_config.php @@ -74,6 +74,8 @@ if ($config->getBoolean('admin.checkforupdates', true) && $current !== 'master') curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'SimpleSAMLphp'); curl_setopt($ch, CURLOPT_TIMEOUT, 2); + curl_setopt($ch, CURLOPT_PROXY, $config->getString('proxy', null)); + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $config->getstring('proxy.auth', null)); $response = curl_exec($ch); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) { @@ -93,8 +95,8 @@ if ($config->getBoolean('admin.checkforupdates', true) && $current !== 'master') } $enablematrix = array( - 'saml20-idp' => $config->getBoolean('enable.saml20-idp', false), - 'shib13-idp' => $config->getBoolean('enable.shib13-idp', false), + 'saml20idp' => $config->getBoolean('enable.saml20-idp', false), + 'shib13idp' => $config->getBoolean('enable.shib13-idp', false), ); @@ -172,6 +174,7 @@ $funcmatrix[] = array( $t = new SimpleSAML_XHTML_Template($config, 'core:frontpage_config.tpl.php'); $t->data['pageid'] = 'frontpage_config'; +$t->data['header'] = $t->t('{core:frontpage:page_title}'); $t->data['isadmin'] = $isadmin; $t->data['loginurl'] = $loginurl; $t->data['warnings'] = $warnings; diff --git a/modules/cron/hooks/hook_frontpage.php b/modules/cron/hooks/hook_frontpage.php index d4d11edd0..340b01636 100644 --- a/modules/cron/hooks/hook_frontpage.php +++ b/modules/cron/hooks/hook_frontpage.php @@ -10,7 +10,7 @@ function cron_hook_frontpage(&$links) { $links['config'][] = array( 'href' => SimpleSAML\Module::getModuleURL('cron/croninfo.php'), - 'text' => array('en' => 'Cron module information page'), + 'text' => '{core:frontpage:link_cron}', ); } diff --git a/modules/memcacheMonitor/hooks/hook_frontpage.php b/modules/memcacheMonitor/hooks/hook_frontpage.php index fa0d45038..526359b05 100644 --- a/modules/memcacheMonitor/hooks/hook_frontpage.php +++ b/modules/memcacheMonitor/hooks/hook_frontpage.php @@ -10,7 +10,7 @@ function memcacheMonitor_hook_frontpage(&$links) { $links['config'][] = array( 'href' => SimpleSAML\Module::getModuleURL('memcacheMonitor/memcachestat.php'), - 'text' => array('en' => 'MemCache Statistics'), + 'text' => '{core:frontpage:link_memcacheMonitor}', ); } diff --git a/modules/metarefresh/hooks/hook_frontpage.php b/modules/metarefresh/hooks/hook_frontpage.php index 60e7aef5e..ee378dec9 100644 --- a/modules/metarefresh/hooks/hook_frontpage.php +++ b/modules/metarefresh/hooks/hook_frontpage.php @@ -10,7 +10,7 @@ function metarefresh_hook_frontpage(&$links) { $links['federation'][] = array( 'href' => SimpleSAML\Module::getModuleURL('metarefresh/fetch.php'), - 'text' => array('en' => 'Metarefresh: fetch metadata'), + 'text' => '{core:frontpage:link_metarefresh}', ); } diff --git a/modules/oauth/hooks/hook_frontpage.php b/modules/oauth/hooks/hook_frontpage.php index 2339b3b0c..23ebb76d5 100644 --- a/modules/oauth/hooks/hook_frontpage.php +++ b/modules/oauth/hooks/hook_frontpage.php @@ -11,7 +11,6 @@ function oauth_hook_frontpage(&$links) $links['federation']['oauthregistry'] = array( 'href' => SimpleSAML\Module::getModuleURL('oauth/registry.php'), - 'text' => array('en' => 'OAuth Consumer Registry'), - 'shorttext' => array('en' => 'OAuth Registry'), + 'text' => '{core:frontpage:link_oauth}', ); } diff --git a/modules/sanitycheck/hooks/hook_frontpage.php b/modules/sanitycheck/hooks/hook_frontpage.php index b71360118..bec44d74c 100644 --- a/modules/sanitycheck/hooks/hook_frontpage.php +++ b/modules/sanitycheck/hooks/hook_frontpage.php @@ -11,7 +11,6 @@ function sanitycheck_hook_frontpage(&$links) $links['config']['santitycheck'] = array( 'href' => SimpleSAML\Module::getModuleURL('sanitycheck/index.php'), - 'text' => array('en' => 'Sanity check of your SimpleSAMLphp setup'), - 'shorttext' => array('en' => 'SanityCheck'), + 'text' => '{core:frontpage:link_santitycheck}', ); } diff --git a/modules/statistics/hooks/hook_frontpage.php b/modules/statistics/hooks/hook_frontpage.php index 03a97aa52..a97da1f2c 100644 --- a/modules/statistics/hooks/hook_frontpage.php +++ b/modules/statistics/hooks/hook_frontpage.php @@ -11,12 +11,11 @@ function statistics_hook_frontpage(&$links) $links['config']['statistics'] = array( 'href' => SimpleSAML\Module::getModuleURL('statistics/showstats.php'), - 'text' => array('en' => 'Show statistics', 'no' => 'Vis statistikk'), - 'shorttext' => array('en' => 'Statistics', 'no' => 'Statistikk'), + 'text' => '{core:frontpage:link_statistics}', ); $links['config']['statisticsmeta'] = array( 'href' => SimpleSAML\Module::getModuleURL('statistics/statmeta.php'), - 'text' => array('en' => 'Show statistics metadata', 'no' => 'Vis statistikk metadata'), + 'text' => '{core:frontpage:link_statistics_metadata}', 'shorttext' => array('en' => 'Statistics metadata', 'no' => 'Statistikk metadata'), ); } -- GitLab