diff --git a/.gitignore b/.gitignore index 5638289..25a7fd3 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ Temporary Items *.swo **/css **/.sass-cache +**/*.un~ diff --git a/CHANGELOG.md b/CHANGELOG.md index 64efe8c..5f9e8d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v3.0.0](https://github.com/rciam/simplesamlphp-module-themevanilla/compare/v2.3.1...v3.0.0) - 2019-09-20 + +### Added +- Add languages (Xhosa, Zulu, Afrikaans). + +### Changed +- Rename disco-tpl.php->disco.tpl.php as needed by simplesamlphp>1.14. +- Update translation functionality as needed by simplesamlphp>1.14. + ## [v2.3.1](https://github.com/rciam/simplesamlphp-module-themevanilla/compare/v2.3.0...v2.3.1) - 2019-09-12 ### Fixed diff --git a/README.md b/README.md index 1b0162b..245c6c2 100644 --- a/README.md +++ b/README.md @@ -247,19 +247,19 @@ To modify the cookie banner and cookie policy page, you must edit the following and to modify the table in cookie policy page: `/config/module_themevanilla.php`. -## Compatibility Note - -If you want to use the theme with **SimpleSAMLphp version greater than 1.14**, you -need to rename the template of the discopower module: -``` -themes/ssp/discopower/disco-tpl.php -> themes/ssp/discopower/disco.tpl.php -``` - ## About SimpleSAMLphp themes You can read more about themes in a SimpleSAMLphp installation from the [official documentation](https://simplesamlphp.org/docs/stable/simplesamlphp-theming). +## Compatibility matrix + +This table matches the theme version with the supported SimpleSAMLphp version. + +| Theme | SimpleSAMLphp | +|:------:|:--------------:| +| v2.3.1 | v1.14 | +| v3.0.0 | v1.17 | ## License diff --git a/templates/policy.tpl.php b/templates/policy.tpl.php index 9394a33..10dfa70 100644 --- a/templates/policy.tpl.php +++ b/templates/policy.tpl.php @@ -1,5 +1,5 @@ getValue('cookiePolicy'); $this->data['header'] = (strpos($this->t('{themevanilla:policy:page_title}'), 'not translated') === FALSE ? $this->t('{themevanilla:policy:page_title}') : ''); $this->includeAtTemplateBase('includes/header.php'); diff --git a/themes/ssp/consent/consentform.php b/themes/ssp/consent/consentform.php index 999a664..9772b0e 100644 --- a/themes/ssp/consent/consentform.php +++ b/themes/ssp/consent/consentform.php @@ -19,55 +19,33 @@ * Template form for giving consent. * * Parameters: - * - 'srcMetadata': Metadata/configuration for the source. - * - 'dstMetadata': Metadata/configuration for the destination. * - 'yesTarget': Target URL for the yes-button. This URL will receive a POST request. - * - 'yesData': Parameters which should be included in the yes-request. * - 'noTarget': Target URL for the no-button. This URL will receive a GET request. - * - 'noData': Parameters which should be included in the no-request. - * - 'attributes': The attributes which are about to be released. * - 'sppp': URL to the privacy policy of the destination, or FALSE. * * @package SimpleSAMLphp */ -assert('is_array($this->data["srcMetadata"])'); -assert('is_array($this->data["dstMetadata"])'); -assert('is_string($this->data["yesTarget"])'); -assert('is_array($this->data["yesData"])'); -assert('is_string($this->data["noTarget"])'); -assert('is_array($this->data["noData"])'); -assert('is_array($this->data["attributes"])'); -assert('is_array($this->data["hiddenAttributes"])'); -assert('$this->data["sppp"] === false || is_string($this->data["sppp"])'); +assert(is_string($this->data['yesTarget'])); +assert(is_string($this->data['noTarget'])); +assert($this->data['sppp'] === false || is_string($this->data['sppp'])); + +// Needed for present_attributes_ssp() +$globalConfig = \SimpleSAML\Configuration::getInstance(); +$t = new \SimpleSAML\XHTML\Template($globalConfig, 'consent:consentform.php'); // Parse parameters -if (array_key_exists('name', $this->data['srcMetadata'])) { - $srcName = $this->data['srcMetadata']['name']; -} elseif (array_key_exists('OrganizationDisplayName', $this->data['srcMetadata'])) { - $srcName = $this->data['srcMetadata']['OrganizationDisplayName']; -} else { - $srcName = $this->data['srcMetadata']['entityid']; -} +$dstName = $this->data['dstName']; +$srcName = $this->data['srcName']; -if (is_array($srcName)) { - $srcName = $this->t($srcName); -} +$id = $_REQUEST['StateId']; +$state = \SimpleSAML\Auth\State::loadState($id, 'consent:request'); -if (array_key_exists('name', $this->data['dstMetadata'])) { - $dstName = $this->data['dstMetadata']['name']; -} elseif (array_key_exists('OrganizationDisplayName', $this->data['dstMetadata'])) { - $dstName = $this->data['dstMetadata']['OrganizationDisplayName']; +if (array_key_exists('consent:hiddenAttributes', $state)) { + $t->data['hiddenAttributes'] = $state['consent:hiddenAttributes']; } else { - $dstName = $this->data['dstMetadata']['entityid']; -} - -if (is_array($dstName)) { - $dstName = $this->t($dstName); + $t->data['hiddenAttributes'] = []; } -$srcName = htmlspecialchars($srcName); -$dstName = htmlspecialchars($dstName); - $attributes = $this->data['attributes']; $this->data['header'] = $this->t('{consent:consent:consent_header}'); @@ -75,28 +53,30 @@ $this->includeAtTemplateBase('includes/header.php'); ?> +

data['consent_accept']; ?>

+
+
+ +data['attributes_html'] = present_attributes_ssp($t, $attributes, ''); -data['sppp'] !== false) { - echo "

" . htmlspecialchars($this->t('{consent:consent:consent_privacypolicy}')) . " "; - echo "" . $dstName . ""; - echo "

"; -} /** * Recursive attribute array listing function * - * @param SimpleSAML_XHTML_Template $t Template object + * @param \SimpleSAML\XHTML\Template $t Template object * @param array $attributes Attributes to be presented * @param string $nameParent Name of parent element * * @return string HTML representation of the attributes */ -function present_attributes($t, $attributes, $nameParent) +function present_attributes_ssp($t, $attributes, $nameParent) { - $alternate = array('ssp-table--tr__odd', 'ssp-table--tr__even'); + $translator = $t->getTranslator(); + + $alternate = ['ssp-table--tr__odd', 'ssp-table--tr__even']; $i = 0; - $summary = 'summary="' . $t->t('{consent:consent:table_summary}') . '"'; + $summary = 'summary="'.$translator->t('{consent:consent:table_summary}').'"'; if (strlen($nameParent) > 0) { $parentStr = strtolower($nameParent) . '_'; @@ -108,14 +88,14 @@ 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 $parentName = preg_replace('/^child_/', '', $nameraw); foreach ($value as $child) { - $str .= "\n" . '' . - present_attributes($t, $child, $parentName) . ''; + $str .= "\n" . ''. + present_attributes_ssp($t, $child, $parentName) . ''; } } else { // insert values directly @@ -123,34 +103,33 @@ function present_attributes($t, $attributes, $nameParent) $str .= "\n" . '
' . htmlspecialchars($name) . '
'; + $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true); if ($isHidden) { - $hiddenId = SimpleSAML\Utils\Random::generateID(); - + $hiddenId = \SimpleSAML\Utils\Random::generateID(); $str .= '
data['idplist'] AS $tab => $slist) { @@ -22,34 +23,17 @@ $faventry = $slist[$this->data['preferredidp']]; } - -if(!array_key_exists('header', $this->data)) { - $this->data['header'] = 'selectidp'; -} +$this->data['header'] = $this->t('selectidp'); $this->data['header'] = $this->t($this->data['header']); -$this->data['jquery'] = array('core' => TRUE, 'ui' => TRUE, 'css' => TRUE); - - -$this->data['head'] = ''; -$this->data['head'] .= ''; - -$this->data['head'] .= ''."\n"; +$this->data['head'] .= ''."\n"; -'; +$this->data['head'] .= $this->data['search']; if (!empty($faventry)) $this->data['autofocus'] = 'favouritesubmit'; @@ -81,7 +65,7 @@ function showEntry($t, $metadata, $favourite = FALSE, $withIcon = FALSE) { } $html = ''; - $html .= 'Identity Provider'; + $html .= 'Identity Provider'; if (isset($label)) { $html .= '' . $label . ''; } @@ -114,15 +98,15 @@ function showEntry($t, $metadata, $favourite = FALSE, $withIcon = FALSE) { function getTranslatedName($t, $metadata) { if (isset($metadata['UIInfo']['DisplayName'])) { $displayName = $metadata['UIInfo']['DisplayName']; - assert('is_array($displayName)'); // Should always be an array of language code -> translation + Assert::isArray($displayName); // Should always be an array of language code -> translation if (!empty($displayName)) { - return $t->getTranslation($displayName); + return $t->getTranslator()->getPreferredTranslation($displayName); } } if (array_key_exists('name', $metadata)) { if (is_array($metadata['name'])) { - return $t->getTranslation($metadata['name']); + return $t->getTranslator()->getPreferredTranslation($metadata['name']); } else { return $metadata['name']; } @@ -229,7 +213,4 @@ function getTranslatedName($t, $metadata) { ?> - - - includeAtTemplateBase('includes/footer.php'); diff --git a/version.txt b/version.txt index aa760a9..1dcd070 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ simplesamlphp-module-themevanilla -version 2.3.1 +version 3.0.0 diff --git a/www/policy.php b/www/policy.php index 11e1e00..10fdeef 100644 --- a/www/policy.php +++ b/www/policy.php @@ -1,7 +1,7 @@ data['pageid'] = 'policy'; $t->show();