Revision: 1883
Author: andreassolberg
Date: Tue Oct 20 03:18:26 2009
Log: Improved discopower module with better UI. New ui box when idp
preselected. Less javascript requirement. validates to xhtml
http://code.google.com/p/simplesamlphp/source/detail?r=1883
Modified:
/trunk/modules/discopower/templates/disco-tpl.php
/trunk/modules/discopower/www/js/jquery.livesearch.js
/trunk/modules/discopower/www/style.css
=======================================
--- /trunk/modules/discopower/templates/disco-tpl.php Fri Oct 16 03:18:55
2009
+++ /trunk/modules/discopower/templates/disco-tpl.php Tue Oct 20 03:18:26
2009
@@ -15,44 +15,47 @@
$(document).ready(function() {
$("#discotabs").tabs({ selected: ' . $this->data['defaulttab'] . ' });
';
+
$i = 0;
foreach ($this->data['idplist'] AS $tab => $slist) {
- $this->data['head'] .= '$("#query_' . $tab . '").liveUpdate("#list_' .
$tab . '")' .
+ $this->data['head'] .= "\n" . '$("#query_' .
$tab . '").liveUpdate("#list_' . $tab . '")' .
($i++ == 0 ? '.focus()' : '') .
';';
+
+
}
$this->data['head'] .= '
});
- function chooseidp(idp) {
- $("#chosenidp").attr(\'name\', \'idp_\' + idp);
- $("#idpselectform").submit();
- }
-
-
</script>';
# $this->data['autofocus'] = 'preferredidp';
$this->includeAtTemplateBase('includes/header.php');
-foreach ($this->data['idplist'] AS $slist) {
- foreach ($slist AS $idpentry) {
- if (isset($idpentry['name']))
- $this->includeInlineTranslation('idpname_' .
$idpentry['entityid'],
$idpentry['name']);
- if (isset($idpentry['description']))
- $this->includeInlineTranslation('idpdesc_' .
$idpentry['entityid'],
$idpentry['description']);
- }
-}
-
+// foreach ($this->data['idplist'] AS $slist) {
+// foreach ($slist AS $idpentry) {
+// if (isset($idpentry['name']))
+// $this->includeInlineTranslation('idpname_' .
$idpentry['entityid'],
$idpentry['name']);
+// if (isset($idpentry['description']))
+// $this->includeInlineTranslation('idpdesc_' .
$idpentry['entityid'],
$idpentry['description']);
+// }
+// }
+//
function showEntry($t, $metadata, $favourite = FALSE) {
+
+ $basequerystring = '?' .
+ 'entityID=' . urlencode($t->data['entityID']) . '&' .
+ 'return=' . urlencode($t->data['return']) . '&' .
+ 'returnIDParam=' .
urlencode($t->data['returnIDParam']) . '&idpentityid=';
+
$extra = ($favourite ? ' favourite' : '');
- $html = '<li class="metaentry' . $extra . '" onclick="chooseidp(\'' .
htmlspecialchars($metadata['entityid']) . '\')">';
-
- $html .= '' . htmlspecialchars($t->t('idpname_' .
$metadata['entityid'])) . '';
+ $html = '<a class="metaentry' . $extra . '" href="' . $basequerystring
.
urlencode($metadata['entityid']) . '">';
+
+ $html .= '' . htmlspecialchars(getTranslatedName($t, $metadata)) . '';
#print_r($metadata['scopes']);
@@ -62,51 +65,70 @@
if(array_key_exists('icon', $metadata) && $metadata['icon'] !== NULL) {
$iconUrl = SimpleSAML_Utilities::resolveURL($metadata['icon']);
- $html .= '<img style="clear: both; float: left; margin: 1em;
padding:
3px; border: 1px solid #999" src="' . htmlspecialchars($iconUrl) . '" />';
+ $html .= '<img alt="Icon for identity provider"
class="entryicon"
src="' . htmlspecialchars($iconUrl) . '" />';
}
// $html .= '<input id="preferredidp" type="submit" name="idp_' .
// htmlspecialchars($metadata['entityid']) . '" value="' .
// $t->t('select') . '" /></p>';
- $html .= '</li>';
+ $html .= '</a>';
return $html;
}
+?>
-?>
-
-
+
+<?php
+
+function getTranslatedName($t, $metadata) {
+# if (is_null($metadata)) throw new Exception();
+ if (array_key_exists('name', $metadata)) {
+ if (is_array($metadata['name'])) {
+ return $t->getTranslation($metadata['name']);
+ } else {
+ return $metadata['name'];
+ }
+ }
+ return $metadata['entityid'];
+}
+$faventry = NULL;
+foreach( $this->data['idplist'] AS $tab => $slist) {
+ if (!empty($this->data['preferredidp']) &&
array_key_exists($this->data['preferredidp'], $slist))
+ $faventry = $slist[$this->data['preferredidp']];
+}
+if (!empty($faventry)) {
- <!-- <h2><?php echo $this->data['header']; ?></h2> -->
-
- <form id="idpselectform" method="get" action="<?php echo
$this->data['urlpattern']; ?>">
- <input type="hidden" name="entityID" value="<?php echo
htmlspecialchars($this->data['entityID']); ?>" />
- <input type="hidden" name="return" value="<?php echo
htmlspecialchars($this->data['return']); ?>" />
- <input type="hidden" name="returnIDParam" value="<?php echo
htmlspecialchars($this->data['returnIDParam']); ?>" />
-
- <input id="chosenidp" type="hidden" name="<?php echo
htmlspecialchars($this->data['returnIDParam']); ?>" value="1" />
- <!-- <input type="submit" style="" name="formsubmit" id="formsubmit"
value="Submit" /> -->
- </form>
- <p><?php
-
- $checked = '';
- if ($this->data['rememberchecked']) {
- $checked = ' checked="checked"';
- }
- echo $this->t('selectidp_full');
- if($this->data['rememberenabled']) {
- echo('<br /><input type="checkbox"' . $checked . '
name="remember"
value="1" /> ' . $this->t('remember'));
- }
- ?></p>
+ echo('<div class="favourite">');
+ echo($this->t('previous_auth'));
+ echo(' <strong>' . getTranslatedName($this, $faventry) . '</strong>');
+ echo('
+ <form id="idpselectform" method="get" action="' .
$this->data['urlpattern'] . '">
+ <input type="hidden" name="entityID" value="' .
htmlspecialchars($this->data['entityID']) . '" />
+ <input type="hidden" name="return" value="' .
htmlspecialchars($this->data['return']) . '" />
+ <input type="hidden" name="returnIDParam" value="' .
htmlspecialchars($this->data['returnIDParam']) . '" />
+ <input type="hidden" name="idpentityid" value="' .
htmlspecialchars($faventry['entityid']) . '" />
+
+ <input type="submit" style="" name="formsubmit" id="formsubmit"
value="' . $this->t('login_at') . ' ' . getTranslatedName($this,
$faventry) . '" />
+ </form>');
+
+ echo('</div>');
+}
+
+
+?>
+
+
+
+
<div id="discotabs">
@@ -123,47 +145,45 @@
</ul>
- <?php
+<?php
- foreach( $this->data['idplist'] AS $tab => $slist) {
-
- echo '<div id="' . $tab . '">';
-
- if (!empty($slist)) {
-
- // echo 'Favourite :: ' . $this->data['preferredidp'];
- // echo '<pre>';
- // print_r($slist); exit;
-
-
-
- echo(' <div class="inlinesearch">');
- echo(' <p>Incremental search...</p>');
- echo(' <input class="inlinesearchf" type="text"
value=""
name="query_' . $tab . '" id="query_' . $tab . '" />');
- echo(' </div>');
-
- echo(' <ul class="metalist" id="list_' . $tab . '">');
- if (!empty($this->data['preferredidp']) &&
array_key_exists($this->data['preferredidp'], $slist)) {
- $idpentry = $slist[$this->data['preferredidp']];
- echo (showEntry($this, $idpentry, TRUE));
- }
-
- foreach ($slist AS $idpentry) {
- if ($idpentry['entityid'] !=
$this->data['preferredidp']) {
- echo (showEntry($this, $idpentry));
- }
- }
- echo(' </ul>');
- }
- echo '</div>';
-
- }
-
- ?>
-
+foreach( $this->data['idplist'] AS $tab => $slist) {
+
+ echo '<div id="' . $tab . '">';
+
+ if (!empty($slist)) {
+
+ // echo 'Favourite :: ' . $this->data['preferredidp'];
+ // echo '<pre>';
+ // print_r($slist); exit;
+
+ echo(' <div class="inlinesearch">');
+ echo(' <p>Incremental search...</p>');
+ echo(' <form id="idpselectform" action="?" method="get"><input
class="inlinesearchf" type="text" value="" name="query_' . $tab . '"
id="query_' . $tab . '" /></form>');
+ echo(' </div>');
+
+ echo(' <div class="metalist" id="list_' . $tab . '">');
+ if (!empty($this->data['preferredidp']) &&
array_key_exists($this->data['preferredidp'], $slist)) {
+ $idpentry = $slist[$this->data['preferredidp']];
+ echo (showEntry($this, $idpentry, TRUE));
+ }
+
+ foreach ($slist AS $idpentry) {
+ if ($idpentry['entityid'] !=
$this->data['preferredidp']) {
+ echo (showEntry($this, $idpentry));
+ }
+ }
+ echo(' </div>');
+ }
+ echo '</div>';
+
+}
+
+?>
+
</div>
=======================================
--- /trunk/modules/discopower/www/js/jquery.livesearch.js Mon Sep 28
08:19:51 2009
+++ /trunk/modules/discopower/www/js/jquery.livesearch.js Tue Oct 20
03:18:26 2009
@@ -2,7 +2,7 @@
list = jQuery(list);
if ( list.length ) {
- var rows = list.children('li'),
+ var rows = list.children('a'),
cache = rows.map(function(){
return jQuery(this).text().toLowerCase();
});
=======================================
--- /trunk/modules/discopower/www/style.css Mon Sep 28 08:19:51 2009
+++ /trunk/modules/discopower/www/style.css Tue Oct 20 03:18:26 2009
@@ -24,26 +24,27 @@
margin: 0px;
padding: 0px;
}
-ul.metalist {
+div.metalist {
clear: both;
list-style: none;
margin: 1em 2px .5em 2px;
padding: 0px;
}
-li.metaentry {
+a.metaentry {
+ display: block;
border: 1px solid #ccc;
margin: 0px 0px -1px 0px;
padding: .2em 1em .2em 20px;
cursor: pointer;
cursor: hand;
}
-li.metaentry.favourite {
+a.metaentry.favourite {
background-image:url('icons/heart.png');
background-repeat:no-repeat;
background-position:center left;
}
-li.metaentry:hover {
+a.metaentry:hover {
border: 1px solid #ccc;
background: #eee;
@@ -51,3 +52,25 @@
background-repeat:no-repeat;
background-position:center left;
}
+a.metaentry img.entryicon {
+ display: none;
+}
+a.metaentry:hover img.entryicon {
+ display: inline;
+ top: 0px;
+ bottom: 0px;
+ clear: both;
+ float: right;
+ margin: 1em;
+ padding: 3px;
+ border: 1px solid #999;
+}
+
+div.favourite {
+
+ margin: 1em 0px;
+ padding: 1em;
+ border: 1px solid #ccc;
+ background-color: #eee;
+
+}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/simplesamlphp-commits?hl=en
-~----------~----~----~----~------~----~------~--~---