Commit 42d2e75b authored by Geoffroy ARNOUD's avatar Geoffroy ARNOUD

#K71, #K11 => Tests ok sur navigateurs

parent ae686605
......@@ -10,7 +10,7 @@
<select name="user_idp" id="userIdPSelection" class="userIdPSelection" tabindex="0">
<?php
// If we use select2, we don't want IDP to be in DOM, but to use AJAX instead
if (!$useSelect2) {
if (!isUseSelect2()) {
echo '<option value="-" '.$defaultSelected.'>'.getLocalString('select_idp').' ...</option>';
printDropDownList($IDProviders, $selectedIDP);
}
......
......@@ -12,9 +12,11 @@
<script type="text/javascript" src="<?php echo $javascriptURL ?>/jquery.js"></script>
<?php
if ($useSelect2) {
if (isUseSelect2()) {
echo '<link rel="stylesheet" href="'. $_SERVER['SCRIPT_NAME'] .'/select2.css" type="text/css" >'.PHP_EOL;
echo '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>'.PHP_EOL;
// Load translations
echo '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/i18n/'.$language.'.js"></script>'.PHP_EOL;
echo '<script type="text/javascript" src="'.$javascriptURL .'/select2Functions.js"></script>'.PHP_EOL;
} elseif ($useImprovedDropDownList) {
echo '<link rel="stylesheet" href="'. $_SERVER['SCRIPT_NAME'] .'/ImprovedDropDown.css" type="text/css">'.PHP_EOL;
......@@ -68,21 +70,7 @@
}
}
// Perform input validation on WAYF form for select2
function select2CheckForm() {
console.log("checkForm ", $('.userIdPSelection option:selected').text());
if (
document.IdPList.user_idp && (
$('.userIdPSelection option:selected').text() == null ||
$('.userIdPSelection option:selected').text() == ''
)
) {
alert(unescape('<?php echo getLocalString('make_selection', 'js') ?>'));
return false;
} else {
return true;
}
}
// Init WAYF
function init(){
......@@ -90,7 +78,9 @@
setFocus();
if (<?php echo ($useSelect2) ? 'true' : 'false' ?>){
<?php if (isUseSelect2()) {
if ($bodyType == "settings" || $bodyType == "WAYF") {
?>
$('.userIdPSelection').select2({
ajax: {
url: <?php echo "'".$apiURL."/idps'" ?>,
......@@ -109,19 +99,33 @@
<?php
if ($developmentMode) {
echo("alert('Exception:', exception);");
}
?>
} ?>
}
},
placeholder: "<?php echo getLocalString('select_idp') ?>",
allowClear: true,
templateResult: formatList,
templateSelection: formatRepoSelection,
language: "<?php echo $language ?>",
templateResult: formatIdp,
templateSelection: formatIdp,
escapeMarkup: function (text) { return text; }
});
} else if (<?php echo ($useImprovedDropDownList) ? 'true' : 'false' ?>){
// Auto-submit when an idp is selected
$('.userIdPSelection').on('select2:select', function (e) {
document.getElementById("IdPList").submit();
});
<?php
} elseif ($bodyType == "notice" && $permanentUserIdP != '') {
?>
$('.userIdPSelectionNotice').select2({
allowClear: false,
templateSelection: formatIdpNotice,
disabled: true,
escapeMarkup: function (text) { return text; }
});
<?php
}
} elseif ($useImprovedDropDownList) {
?>
var searchText = '<?php echo getLocalString('search_idp', 'js') ?>';
$("#userIdPSelection:enabled option[value='-']").text(searchText);
......@@ -133,7 +137,8 @@
noItemsText: '<?php echo getLocalString('no_idp_available', 'js') ?>',
disableRemoteLogos: <?php echo ($disableRemoteLogos) ? 'true' : 'false' ?>
});
}
<?php
} ?>
}
// Call init function when DOM is ready
......@@ -149,37 +154,37 @@
<div class="box">
<div id="header">
<?php if (!empty($logoURL)) {
?>
?>
<a href="<?php echo sprintf($federationURL, $language) ?>"><img src="<?php echo $logoURL ?>" alt="Federation Logo" id="federationLogo"></a>
<?php
} ?>
} ?>
<?php if (!empty($organizationLogoURL)) {
?>
?>
<a href="<?php echo sprintf($organizationURL, $language) ?>"><img src="<?php echo $organizationLogoURL ?>" alt="Organization Logo" id="organisationLogo"></a>
<?php
} ?>
} ?>
</div>
<div id="content">
<ul class="menu">
<?php if (!empty($federationURL) && getLocalString('about_federation') != '') {
?>
?>
<li><a href="<?php echo sprintf($federationURL, $language) ?>"><?php echo getLocalString('about_federation'); ?></a></li>
<?php
} ?>
} ?>
<?php if (!empty($faqURL) && getLocalString('faq') != '') {
?>
?>
<li class="last"><a href="<?php echo sprintf($faqURL, $language) ?>"><?php echo getLocalString('faq') ?></a></li>
<?php
} ?>
} ?>
<?php if (!empty($helpURL) && getLocalString('help') != '') {
?>
?>
<li class="last"><a href="<?php echo sprintf($helpURL, $language) ?>"><?php echo getLocalString('help') ?></a></li>
<?php
} ?>
} ?>
<?php if (!empty($privacyURL) && getLocalString('privacy') != '') {
?>
?>
<li class="last"><a href="<?php echo sprintf($privacyURL, $language) ?>"><?php echo getLocalString('privacy') ?></a></li>
<?php
} ?>
} ?>
</ul>
<!-- Body: Start -->
<?php // Copyright (c) 2019, SWITCH ?>
<?php // Copyright (c) 2019, SWITCH?>
<!-- Identity Provider Selection: Start -->
<h1><?php echo getLocalString('settings'); ?></h1>
<h1><?php echo getLocalString('settings'); ?></h1>
<form id="IdPList" name="IdPList" method="post" onSubmit="return checkForm()" action="<?php echo $actionURL ?>">
<div id="userInputArea">
<p class="promptMessage"><?php echo getLocalString('confirm_permanent_selection'); ?></p>
<p><?php echo getLocalString('permanent_cookie_notice'); ?></p>
<div style="text-align: center">
<select name="permanent_user_idp" id="userIdPSelection">
<option value="<?php echo $permanentUserIdP ?>" logo="<?php echo $permanentUserIdPLogo ?>"><?php echo $permanentUserIdPName ?></option>
<select name="permanent_user_idp" id="userIdPSelection" class="userIdPSelectionNotice" >
<option value="<?php echo $permanentUserIdP ?>" logo="<?php echo $permanentUserIdPLogo ?>"><?php echo $permanentUserIdPName ?></option>
</select>
<input type="submit" accesskey="c" name="clear_user_idp" value="<?php echo getLocalString('delete_permanent_cookie_button') ?>">
<?php if (isValidShibRequest()) : ?>
......@@ -16,7 +16,9 @@
<input type="submit" accesskey="s" name="Select" name="permanent" value="<?php echo getLocalString('goto_sp') ?>">
<?php endif ?>
<p>
<?php $scriptURL = "https://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] ?>
<?php $scriptURL = sprintf("%s://%s%s", isset($_SERVER['HTTPS'])?"https":"http", $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF']);
//"https://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']
?>
<?php $fullURL = "<br /><a href=".$scriptURL.">".$scriptURL."</a>" ?>
<?php echo sprintf(getLocalString('permanent_cookie_note'), $fullURL) ?>
</p>
......@@ -24,7 +26,9 @@
</div>
</form>
<?php if (getLocalString('additional_info') != '') { ?>
<?php if (getLocalString('additional_info') != '') {
?>
<p><?php echo getLocalString('additional_info') ?></p>
<?php } ?>
<?php
} ?>
<!-- Identity Provider Selection: End -->
......@@ -10,7 +10,7 @@
<select name="user_idp" id="userIdPSelection" class="userIdPSelection" tabindex="0">
<?php
// If we use select2, we don't want IDP to be in DOM, but to use AJAX instead
if (!$useSelect2) {
if (!isUseSelect2()) {
echo '<option value="-" '.$defaultSelected.'>'.getLocalString('select_idp').' ...</option>';
printDropDownList($IDProviders, $selectedIDP);
}
......
......@@ -829,6 +829,8 @@ function logInfo($infoMsg)
syslog(LOG_INFO, $infoMsg);
wayfLog("INFO", $infoMsg);
if ($developmentMode && isRunViaCLI()) {
echo $infoMsg;
}
......@@ -844,6 +846,8 @@ function logWarning($warnMsg)
syslog(LOG_WARNING, $warnMsg);
wayfLog("WARN", $warnMsg);
if ($developmentMode && isRunViaCLI()) {
echo $warnMsg;
}
......@@ -859,6 +863,8 @@ function logError($errorMsg)
syslog(LOG_ERR, $errorMsg);
wayfLog("ERROR", $errorMsg);
if ($developmentMode) {
echo $errorMsg;
}
......@@ -872,6 +878,17 @@ function logFatalErrorAndExit($errorMsg)
exit;
}
/******************************************************************************/
// Logs a message to errorLog
function wayfLog($level, $errorMsg)
{
global $developmentMode;
if ($developmentMode) {
error_log(sprintf("[%s] %s", $level, $errorMsg));
}
}
/******************************************************************************/
// Returns true if PATH info indicates a request of type $type
function isRequestType($type)
......@@ -1119,10 +1136,24 @@ function isRunViaInclude()
function printSubmitAction()
{
global $useSelect2;
if ($useSelect2) {
if (isUseSelect2()) {
return "return select2CheckForm()";
} else {
return "return checkForm()";
}
}
/******************************************************************************/
// Getter for useSelect2: we can't only rely on config.php::$useSelect2
// because of embeddedWAYF.
// If SP want's to use Select2, it has to add ?useSelect2=true
function isUseSelect2()
{
global $useSelect2;
if (!isset($_GET["useSelect2"])) {
return $useSelect2;
}
return $_GET["useSelect2"];
}
......@@ -40,19 +40,14 @@ final class IdpObject
public $id;
public $text;
// Attributes required by WAY
public $entityId;
public $SSO;
public $name;
public $names = array();
public $protocols;
public $logo;
/* group */
public $type;
public function __construct($entId, $idp)
{
$this->entityId = $entId;
// $this->entityId = $entId;
$this->id = $entId;
global $language;
......@@ -62,25 +57,14 @@ final class IdpObject
$this->text = (isset($idp[$language]['Name'])) ? $idp[$language]['Name'] : $idp['Name'];
foreach ($idp as $key => $value) {
if ($key == "SSO") {
$this->SSO = $value;
}
if ($key == "Name") {
$this->name = $value;
}
if ($key == "Protocols") {
$this->protocols = $value;
}
if ($key == "Logo") {
if (sizeof($value) > 0) {
$this->logo = getImage($value{"URL"});
}
}
// languages
if (isset($value{"Name"})) {
// Assume it's a language
$this->names{$key} = $value{"Name"};
}
// Group
if ($key == "Type") {
$this->type = $value;
......@@ -108,6 +92,7 @@ final class IdpGroup
{
public $text;
public $children = array();
public $hide;
}
/*
......@@ -124,9 +109,9 @@ final class IdpRepository
{
global $showNumOfPreviouslyUsedIdPs;
if (isset($previouslySelectedIdps) && count($previouslySelectedIdps) > 0) {
$counter = (isset($showNumOfPreviouslyUsedIdPs)) ? $showNumOfPreviouslyUsedIdPs : 3;
for ($n = count($previouslySelectedIdps) - 1; $n >= 0; $n--) {
if ($counter <= 0) {
break;
......@@ -161,10 +146,14 @@ final class IdpRepository
/*
* Groups a given array
*/
private function toGroups($array)
private function toGroups($array, $hideFirstGroup = false)
{
$result = array();
$tmp = array();
$firstGroup = true;
$firstGroupName = $array[0]->type;
foreach ($array as $key => $idpObject) {
$type = $idpObject->type;
......@@ -172,6 +161,7 @@ final class IdpRepository
$group = new IdpGroup();
$group->text = $type;
$tmp[$type] = $group;
$group->hide = $hideFirstGroup && ($type == $firstGroupName);
}
$tmp[$type]->children[] = $idpObject;
}
......@@ -209,10 +199,17 @@ final class IdpRepository
$idpPage = array_slice($array, $from, $pageSize);
$result{"results"} = $this->toGroups($idpPage);
$hideFirstGroup = false;
if (isset($pageNumber) && $pageNumber > 1) {
// Get last from previous page
$lastPageLastGroup = $this->idpObjects[$pageNumber * $pageSize - 1]->type;
$thisPageFirstGroup = $this->idpObjects[$pageNumber * $pageSize]->type;
$hideFirstGroup = ($lastPageLastGroup == $thisPageFirstGroup);
}
$result{"results"} = $this->toGroups($idpPage, $hideFirstGroup);
// When using select2 optgroups, the pagination must be named "paginate"
// $result{"pagination"}{"more"} = (($pageNumber + 1)*$pageSize <= sizeof($array));
$result{"pagination"}{"more"} = (($pageNumber + 1)*$pageSize <= sizeof($array));
return json_encode($result, JSON_UNESCAPED_SLASHES);
......
......@@ -13,14 +13,23 @@ if (!isset($_SERVER['REMOTE_ADDR']) || basename($_SERVER['SCRIPT_NAME']) == 'tem
/*------------------------------------------------*/
// Functions containing HTML code
/*------------------------------------------------*/
function printHeader()
// $bodyType states which screen WAYF is going to display:
// * settings
// * notice
// * WAYF
// * error
// This allows to adapt the content of the header
function printHeader($bodyType)
{
global $langStrings, $language, $imageURL, $javascriptURL, $cssURL, $logoURL;
global $useImprovedDropDownList, $disableRemoteLogos, $organizationLogoURL;
global $federationURL, $organizationURL, $faqURL, $helpURL, $privacyURL;
global $customStrings;
global $developmentMode, $useSelect2, $apiURL;
global $developmentMode, $apiURL;
global $permanentUserIdP, $permanentUserIdPName, $permanentUserIdPLogo;
global $IDProviders;
$permanentUserIdP = getPermanentUserIdp();
include(get_template('header.php'));
}
......@@ -32,7 +41,6 @@ function printWAYF()
{
global $selectedIDP, $language, $IDProviders, $SProviders, $redirectCookieName, $imageURL, $redirectStateCookieName, $showPermanentSetting;
global $customStrings;
global $useSelect2;
if (!isset($showPermanentSetting)) {
$showPermanentSetting = false;
......@@ -92,7 +100,6 @@ function printSettings()
{
global $selectedIDP, $language, $IDProviders, $redirectCookieName;
global $customStrings;
global $useSelect2;
$actionURL = $_SERVER['SCRIPT_NAME'].'?'.htmlentities($_SERVER['QUERY_STRING']);
$defaultSelected = ($selectedIDP == '-') ? 'selected="selected"' : '';
......@@ -105,7 +112,6 @@ function printSettings()
function printDropDownList($IDProviders, $selectedIDP = '')
{
global $language;
global $useSelect2;
$previouslyUsedIdPsHTML = getPreviouslyUsedIdPsHTML();
echo $previouslyUsedIdPsHTML;
......@@ -233,22 +239,21 @@ function printNotice()
$actionURL = $_SERVER['SCRIPT_NAME'].'?'.htmlentities($_SERVER['QUERY_STRING']);
$hiddenUserIdPInput = '';
$permanentUserIdP = '';
$permanentUserIdP = getPermanentUserIdp();
$permanentUserIdPName = '';
$permanentUserIdPLogo = '';
if (
isset($_POST['user_idp'])
&& checkIDPAndShowErrors($_POST['user_idp'])
) {
$permanentUserIdP = $_POST['user_idp'];
} elseif (
isset($_COOKIE[$redirectCookieName])
&& checkIDPAndShowErrors($_COOKIE[$redirectCookieName])
) {
$permanentUserIdP = $_COOKIE[$redirectCookieName];
}
// if (
// isset($_POST['user_idp'])
// && checkIDPAndShowErrors($_POST['user_idp'])
// ) {
// $permanentUserIdP = $_POST['user_idp'];
// } elseif (
// isset($_COOKIE[$redirectCookieName])
// && checkIDPAndShowErrors($_COOKIE[$redirectCookieName])
// ) {
// $permanentUserIdP = $_COOKIE[$redirectCookieName];
// }
if ($permanentUserIdP != '') {
$hiddenUserIdPInput = '<input type="hidden" name="user_idp" value="'.$permanentUserIdP.'">';
......@@ -261,6 +266,26 @@ function printNotice()
include(get_template('notice.php'));
}
function getPermanentUserIdp()
{
global $redirectCookieName;
$permanentUserIdP = '';
if (
isset($_POST['user_idp'])
&& checkIDPAndShowErrors($_POST['user_idp'])
) {
$permanentUserIdP = $_POST['user_idp'];
} elseif (
isset($_COOKIE[$redirectCookieName])
&& checkIDPAndShowErrors($_COOKIE[$redirectCookieName])
) {
$permanentUserIdP = $_COOKIE[$redirectCookieName];
}
return $permanentUserIdP;
}
/******************************************************************************/
// Prints end of HTML page
function printFooter()
......@@ -276,7 +301,7 @@ function printError($message)
global $customStrings;
// Show Header
printHeader();
printHeader("error");
include(get_template('error.php'));
......
......@@ -27,7 +27,7 @@ final class IdpApiTest extends TestCase
require("test.IDProvider.metadata.php");
$repo = new IdpRepository($metadataIDProviders);
$this->assertEquals(
'{"results":[{"text":"Ecole avec accents","children":[{"id":"https://rigal.enpc.fr/idp/shibboleth","text":"\u00c9cole des Ponts ParisTech","entityId":"https://rigal.enpc.fr/idp/shibboleth","SSO":"https://rigal.enpc.fr/idp/profile/Shibboleth/SSO","name":"\u00c9cole des Ponts ParisTech","names":{"en":"\u00c9cole des Ponts ParisTech","fr":"\u00c9cole des Ponts ParisTech"},"protocols":"urn:oasis:names:tc:SAML:1.1:protocol urn:mace:shibboleth:1.0 urn:oasis:names:tc:SAML:2.0:protocol","logo":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAQAAAAEABcxq3DAAAB7ElEQVQoz42Rz2/SYBjHX/rSvmW0sK6WhLLLPIhwdX+C2YWYGdDIMJpF/Z+W6XHxJgtTTCZb0xX5ddOMpWNhbiCQFHugykvXtQIeZjAq030vT57n+X6e7+EB40tUq9WmzgkwTUo+n9l6Xa+f/L2aAti2fXhY43m+WHx/JeBdLufz+Z49fWJZ5/l84T+A1taOjuosy8qywnFctboPgP0vICdLPpYV5vhIJMzz3HA4yr7duRSoVqvn1tnq6mNsDnRdh5CMx++22x1dNyYe13g8njRra+sQQp6f6/f7hvFVEK55PDOtdksQhNRK8s+EQqHQM3qI9tA0EoRAOHzDP+tHCHloz+dmS1XVC5v7ohiGcXCgLt5a7HTasVhsckXX9Wy2G4ncLJUr0Wj0V8LurkTTaGnpNgFhJrM1Aba3cxzHLS/fGY9GiqL8BJrN5snpKULoVXqTdLuPjz9pmgYAUFW12/3iOE46vQkh/PBxH9g2AQDIF4pBURTF4L1EPBAQQvPi3p4CACiXK6IYDIXmE4n4wsJ1lmHe5HaIUqmCv/UfPUwBACRJpih6JZnEeLCx8ZKiUCqVNM2BJMkkCRMP7jcaDdf68xcYY5Zhvg+Hpml6Z7wQuswzC2M86/eTFOU4jmVZjJdxES7D6P32h6voB98GBPZakOIQAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE1LTA3LTIwVDEwOjUwOjIwKzAyOjAwq4YxQQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNS0wNy0yMFQxMDo1MDoyMCswMjowMNrbif0AAAAASUVORK5CYII=","type":"Ecole avec accents"}]}],"pagination":{"more":false}}',
'{"results":[{"text":"Ecole avec accents","children":[{"id":"https://rigal.enpc.fr/idp/shibboleth","text":"\u00c9cole des Ponts ParisTech","name":"\u00c9cole des Ponts ParisTech","logo":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAQAAAAEABcxq3DAAAB7ElEQVQoz42Rz2/SYBjHX/rSvmW0sK6WhLLLPIhwdX+C2YWYGdDIMJpF/Z+W6XHxJgtTTCZb0xX5ddOMpWNhbiCQFHugykvXtQIeZjAq030vT57n+X6e7+EB40tUq9WmzgkwTUo+n9l6Xa+f/L2aAti2fXhY43m+WHx/JeBdLufz+Z49fWJZ5/l84T+A1taOjuosy8qywnFctboPgP0vICdLPpYV5vhIJMzz3HA4yr7duRSoVqvn1tnq6mNsDnRdh5CMx++22x1dNyYe13g8njRra+sQQp6f6/f7hvFVEK55PDOtdksQhNRK8s+EQqHQM3qI9tA0EoRAOHzDP+tHCHloz+dmS1XVC5v7ohiGcXCgLt5a7HTasVhsckXX9Wy2G4ncLJUr0Wj0V8LurkTTaGnpNgFhJrM1Aba3cxzHLS/fGY9GiqL8BJrN5snpKULoVXqTdLuPjz9pmgYAUFW12/3iOE46vQkh/PBxH9g2AQDIF4pBURTF4L1EPBAQQvPi3p4CACiXK6IYDIXmE4n4wsJ1lmHe5HaIUqmCv/UfPUwBACRJpih6JZnEeLCx8ZKiUCqVNM2BJMkkCRMP7jcaDdf68xcYY5Zhvg+Hpml6Z7wQuswzC2M86/eTFOU4jmVZjJdxES7D6P32h6voB98GBPZakOIQAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE1LTA3LTIwVDEwOjUwOjIwKzAyOjAwq4YxQQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNS0wNy0yMFQxMDo1MDoyMCswMjowMNrbif0AAAAASUVORK5CYII=","type":"Ecole avec accents"}],"hide":false}],"pagination":{"more":false}}',
$repo->toJsonByQuery($query, 1)
);
}
......
......@@ -107,6 +107,7 @@ if (isset($_COOKIE[$SPCookieName])) {
// Set Cookie to remember the selection
if (isset($_POST['user_idp']) && checkIDPAndShowErrors($_POST['user_idp'])) {
$IDPArray = appendValueToIdPArray($_POST['user_idp'], $IDPArray);
setcookie($SAMLDomainCookieName, getValueFromIdPArray($IDPArray), time() + ($cookieValidity*24*3600), '/', $commonDomain, $cookieSecurity, $cookieSecurity);
}
......@@ -409,7 +410,7 @@ if (
// Show selection
// Show Header
printHeader();
printHeader("WAYF");
// Show drop down list
printWAYF();
......@@ -615,7 +616,7 @@ if (
// Show confirmatin notice
// Show Header
printHeader();
printHeader("notice");
// Show drop down list
printNotice();
......@@ -627,7 +628,7 @@ if (
} else {
// Show Header
printHeader();
printHeader("settings");
// Show drop down list
printSettings();
......
......@@ -190,6 +190,18 @@
color: #999;
}
/* .select2-results__option .select2-results__option--load-more {
font-family: Verdana, sans-serif;
font-size: 12px;
color: #999;
}
.loading-results {
font-family: Verdana, sans-serif;
font-size: 12px;
color: #999;
} */
.select2-container--default .select2-selection--single .select2-selection__arrow {
height: 26px;
position: absolute;
......@@ -350,6 +362,8 @@
}
.select2-container--default .select2-results__option[aria-disabled=true] {
font-family: Verdana, sans-serif;
font-size: 12px;
color: #999;
}
......@@ -430,6 +444,8 @@
}
.select2-container--classic .select2-selection--single .select2-selection__placeholder {
font-family: Verdana, sans-serif;
font-size: 12px;
color: #999;
}
......
......@@ -31,7 +31,6 @@
var wayf_use_discovery_service = global.wayf_use_discovery_service;
var wayf_use_improved_drop_down_list = global.wayf_use_improved_drop_down_list;
var wayf_use_select2 = global.wayf_use_select2;
//var wayf_use_select2 = true;
var wayf_select2_page_size = global.wayf_select2_page_size;
var wayf_disable_remote_idp_logos = global.wayf_disable_remote_idp_logos;
var wayf_enable_entityid_matching = global.wayf_enable_entityid_matching;
......@@ -77,9 +76,11 @@
var wayf_categories = {
<?php echo $JSONCategoryList ?>
};
<?php if(!isUseSelect2()) { ?>
var wayf_idps = {
<?php echo $JSONIdPList ?>
};
<?php } ?>
var wayf_other_fed_idps = {};
// Functions
......@@ -144,6 +145,8 @@
return false;
}
<?php if(!isUseSelect2()) { ?>
function writeOptGroup(IdPElements, category) {
if (!wayf_categories[category]) {
......@@ -167,6 +170,7 @@
writeHTML('</optgroup>');
}
}
<?php } ?>
function writeHTML(a) {
wayf_html += a;
......@@ -571,6 +575,7 @@
}, 100);
}
}
<?php if(!isUseSelect2()) { ?>
function getOptionHTML(entityID) {
......@@ -661,6 +666,7 @@
enableValueMatching: wayf_enable_entityid_matching
});
}
<?php } else { ?>
function loadJQuerySelect2() {
var head = document.getElementsByTagName('head')[0];
......@@ -706,44 +712,62 @@
var select2Script = document.createElement('script');
select2Script.src = "https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js";
select2Script.type = 'text/javascript';
var select2Translation = document.createElement('script');
select2Translation.src = "<?php echo('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/i18n/'.$language.'.js') ?>";
select2Translation.type = 'text/javascript';
select2Script.onload = function() {
console.log("Select2 JS loaded !");
$('.userIdPSelection').select2({
ajax: {
url: <?php echo "'".$apiURL."/idps'" ?>,
delay: 250,
dataType: 'json',
data: function(params) {
var query = {
search: params.term,
page: params.page || 1
}
// Query parameters will be ?search=[term]&page=[page]
return query;
},
error: function(jqxhr, status, exception) {
console.error('Exception:', exception);
<?php
// Load transalation
select2Translation.onload = function() {
console.log("Select2 JS loaded !");
$('.userIdPSelection').select2({
ajax: {
url: <?php echo "'".$apiURL."/idps'" ?>,
delay: 250,
dataType: 'json',
data: function(params) {
var query = {
search: params.term,
page: params.page || 1
}
// Query parameters will be ?search=[term]&page=[page]
return query;
},
error: function(jqxhr, status, exception) {
console.error('Exception:', exception);
<?php
if ($developmentMode) {
echo("alert('Exception:', exception);");
}
?>
}
},
placeholder: "<?php echo getLocalString('select_idp') ?>",
allowClear: true,
language: "<?php echo $language ?>",