Skip to content

Commit 81aff10

Browse files
authored
Merge pull request #1 from nikosev/hotfix-livesearch
Fix livesearch in discopower
2 parents 903cc8b + ed59a2a commit 81aff10

9 files changed

Lines changed: 55 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
9+
### Added
10+
11+
- Add `login_with` key in discopower definitions
12+
13+
### Fixed
14+
15+
- Load JavaScript scripts with the new way
16+
- Fix undefined index error for `idps_in_searchable_list_index`
17+
- Load jQuery CSS script
18+
19+
### Changed
20+
21+
- Move `ribbon_text` definition to config file
22+
723
## [v3.0.0](https://github.com/rciam/simplesamlphp-module-themevanilla/compare/v2.3.1...v3.0.0) - 2019-09-20
824

925
### Added

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ If you want to make any changes in the footer you need to modify the template
202202
### Header ribbon
203203

204204
The text in the header ribbon can be altered by changing the `ribbon_text`
205-
definition in `dictionaries/default.definition.json` file.
205+
definition in `module_themevanilla.php` file.
206206
If you want to hide the ribbon, set `ribbon_text` to `""`.
207207

208208
### CSS
@@ -256,10 +256,12 @@ You can read more about themes in a SimpleSAMLphp installation from the
256256

257257
This table matches the theme version with the supported SimpleSAMLphp version.
258258

259-
| Theme | SimpleSAMLphp |
260-
|:------:|:--------------:|
261-
| v2.3.1 | v1.14 |
262-
| v3.0.0 | v1.17 |
259+
| Theme | SimpleSAMLphp | Discopower |
260+
| :---: | :-----------: | :--------: |
261+
| v1.x | v1.14 | - |
262+
| v2.x | v1.14 | - |
263+
| v3.x | v1.17 | - |
264+
| v4.x | - | v0.9.2 |
263265

264266
## License
265267

config-example/module_themevanilla.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
2+
23
/**
34
* This is example configuration of SimpleSAMLphp themevanila.
45
* Copy this file to default config directory and edit the properties.
56
*
67
* copy command (from SimpleSAML base dir)
78
* cp modules/themevanilla/module_themevanilla.php config/
89
*/
10+
911
$config = array(
1012
'cookiePolicy' => array(
1113
array('type' => 'Session State', 'provider' => 'aai.rciam.eu', 'name' => 'rciam_proxy_authtoken, rciam_google_proxy_authtoken, rciam_google_proxy_authtoken, rciam_facebook_proxy_authtoken, rciam_linkedin_proxy_authtoken, rciam_orcid_proxy_authtoken', 'thirdParty' => false, 'category' => 'Session', 'purpose' => 'Preserve user authentication token to prevent session fixation attacks'),
@@ -17,7 +19,6 @@
1719
array('type' => 'Preferences', 'provider' => 'aai.rciam.eu', 'name' => 'i18next', 'thirdParty' => false, 'category' => 'Session', 'purpose' => 'Preserve preferred language for RCIAM AAI OpenID Connect Provider'),
1820
array('type' => 'Session State', 'provider' => 'aai.rciam.eu', 'name' => 'JSESSIONID', 'thirdParty' => false, 'category' => 'Session', 'purpose' => 'Preserve user session ID to retrieve session information')
1921
),
20-
'enable_cookies_banner' => false
22+
'enable_cookies_banner' => false,
23+
'ribbon_text' => '',
2124
);
22-
23-
?>

dictionaries/default.definition.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@
1010
},
1111
"logo_link_url": {
1212
"en": "https://www.example.com"
13-
},
14-
"ribbon_text": {
15-
"en": "Demo"
1613
}
1714
}

dictionaries/discopower.definition.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@
2525
},
2626
"cookies_link_url": {
2727
"en": "../themevanilla/policy.php"
28+
},
29+
"login_with": {
30+
"en": "Log in with"
2831
}
2932
}

dictionaries/userid_error.definition.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"en": "Sorry, we were not able to log you in"
44
},
55
"friendly_description": {
6-
"en": "<strong>What is the problem?</strong> %IDP% does not return a persistent identifier to help us uniquely identify you."
6+
"en": "<strong>What is the problem?</strong> %IDPNAME% does not return a persistent identifier to help us uniquely identify you."
77
},
88
"resolution_description": {
99
"en": "<strong>What can you do?</strong> At the moment, the only way to log in is to <a href=\"%RETRY_URL%\">use a different account</a>. For future use, you may ask your institution administrator to release the required information, by sending them a print screen of this error, or asking them to contact our support at <a href=\"mailto:support@example.org\">support@example.org</a>."

themes/ssp/default/includes/header.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

3-
3+
$themeConfig = SimpleSAML\Configuration::getConfig('module_themevanilla.php');
4+
$ribbonText = $themeConfig->getValue('ribbon_text');
45

56
/**
67
* Support the htmlinject hook, which allows modules to change header, pre and post body on all pages.
@@ -127,9 +128,9 @@
127128

128129
<div class="header">
129130
<?php
130-
if (strpos($this->t('{themevanilla:default:ribbon_text}'), 'not translated') === FALSE || $this->t('{themevanilla:default:ribbon_text}')) {
131+
if (!empty($ribbonText)) {
131132
echo '<div class="corner-ribbon red">';
132-
echo $this->t('{themevanilla:default:ribbon_text}');
133+
echo $ribbonText;
133134
echo '</div>';
134135
}
135136
?>

themes/ssp/discopower/disco.tpl.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,26 @@
2525

2626
$this->data['header'] = $this->t('selectidp');
2727
$this->data['header'] = $this->t($this->data['header']);
28-
$this->data['jquery'] = ['core' => true, 'ui' => true, 'css' => true];
28+
$this->data['jquery'] = ['core' => true, 'ui' => false, 'css' => false];
2929

30-
31-
$this->data['head'] = '<script type="text/javascript" src="'.
32-
SimpleSAML\Module::getModuleURL('discopower/assets/js/jquery.livesearch.js').'"></script>'."\n";
33-
$this->data['head'] .= '<script type="text/javascript" src="'.
34-
SimpleSAML\Module::getModuleURL('discopower/assets/js/' . $this->data['score'].'.js') . '"></script>'."\n";
35-
36-
$this->data['head'] .= $this->data['search'];
30+
$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="'.
31+
SimpleSAML\Module::getModuleURL('discopower/assets/css/uitheme1.12.1/jquery-ui.min.css').'" />';
3732

3833
if (!empty($faventry)) $this->data['autofocus'] = 'favouritesubmit';
3934

4035
$this->includeAtTemplateBase('includes/header.php');
4136

37+
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
38+
SimpleSAML\Module::getModuleURL('discopower/assets/js/jquery-1.12.4.min.js').'"></script>'."\n";
39+
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
40+
SimpleSAML\Module::getModuleURL('discopower/assets/js/jquery-ui-1.12.1.min.js').'"></script>'."\n";
41+
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
42+
SimpleSAML\Module::getModuleURL('discopower/assets/js/jquery.livesearch.js').'"></script>'."\n";
43+
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
44+
SimpleSAML\Module::getModuleURL('discopower/assets/js/tablist.js').'"></script>'."\n";
45+
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
46+
SimpleSAML\Module::getModuleURL('discopower/assets/js/' . $this->data['score'].'.js') . '"></script>'."\n";
47+
4248
function showEntry($t, $metadata, $favourite = FALSE, $withIcon = FALSE) {
4349

4450
$basequerystring = '?' .
@@ -134,7 +140,7 @@ function getTranslatedName($t, $metadata) {
134140
<input type="hidden" name="returnIDParam" value="' . htmlspecialchars($this->data['returnIDParam']) . '" />
135141
<input type="hidden" name="idpentityid" value="' . htmlspecialchars($faventry['entityid']) . '" />
136142
<input type="submit" name="formsubmit" id="favouritesubmit" class="ssp-btn ssp-btn__action text-uppercase" value="'
137-
. $this->t('login_at') . ' ' . htmlspecialchars(getTranslatedName($this, $faventry)) . '" />
143+
. $this->t('{themevanilla:discopower:login_with}') . ' ' . htmlspecialchars(getTranslatedName($this, $faventry)) . '" />
138144
</form>
139145
</div>
140146
<div class="row text-center ssp-modal-or">' . (strpos($this->t('{themevanilla:discopower:or}'), 'not translated') === FALSE ? $this->t('{themevanilla:discopower:or}') : '') . '</div>
@@ -198,7 +204,7 @@ function getTranslatedName($t, $metadata) {
198204
$list_items .= (showEntry($this, $idpentry, FALSE, TRUE));
199205
}
200206
}
201-
if($idps_in_searchable_list_index < $idps_with_logos_index) {
207+
if(!empty($idps_in_searchable_list_index) && $idps_in_searchable_list_index < $idps_with_logos_index) {
202208
$or = '<div class="text-center ssp-line-or-line ssp-line-or-line--top"><span class="ssp-line-or-line__or">' . (strpos($this->t('{themevanilla:discopower:or}'), 'not translated') === FALSE ? $this->t('{themevanilla:discopower:or}') : '') . '</span></div>';
203209
echo $top . $or . $list_open . $list_items . $close_list . $close;
204210
}

themes/ssp/userid/error.tpl.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99

1010
$this->includeAtTemplateBase('includes/header.php');
1111
$retryUrl = $this->data['parameters']['%BASEDIR%'] . 'saml2/idp/initSLO.php?RelayState=' . urlencode($this->data['parameters']['%RESTARTURL%']);
12+
$translationParams = [
13+
'%IDPNAME%' => $this->data['parameters']['%IDPNAME%'],
14+
];
1215
?>
1316
<div class="row">
1417
<div class="col-sm-12">
1518
<?php
1619
$friendly_title = '<h2>' . (strpos($this->t('{themevanilla:userid_error:friendly_title}'), 'not translated') === FALSE ? $this->t('{themevanilla:userid_error:friendly_title}') : '') . '</h2>';
1720
echo $friendly_title;
1821
?>
19-
<p><?php echo $this->t('{themevanilla:userid_error:friendly_description}', $this->data['parameters']); ?></p>
22+
<p><?php echo $this->t('{themevanilla:userid_error:friendly_description}', $translationParams); ?></p>
2023
<p><?php echo $this->t('{themevanilla:userid_error:resolution_description}', array('%RETRY_URL%' => $retryUrl)); ?></p>
2124
</div>
2225
</div>

0 commit comments

Comments
 (0)