* Admin:
- Fold/unfold wiki folders -Car
+ * Banana:
+ - Fold/unfold threads -Car
+
* Core:
- UTF-8 -FRU
- New Backtrace tool -FRU
* Search:
- Search Engine IE7 compatible -FRU
- Add soundex search for quick search -FRU
+ - Add autocompletion for advanced search -Car
* Xnetgrp:
- Direct access to the group forum (if exists) -FRU
## jquery
##
-jquery: htdocs/javascript/jquery.js
+jquery: htdocs/javascript/jquery.js htdocs/javascript/jquery.autocomplete.js
htdocs/javascript/jquery.js:
wget http://jquery.com/src/jquery-latest.pack.js -O htdocs/javascript/jquery.js -q
+htdocs/javascript/jquery.autocomplete.js:
+ wget http://www.dyve.net/jquery/js/jquery.autocomplete.js -O htdocs/javascript/jquery.autocomplete.js -q
################################################################################
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2003-2007 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+.ac_results ul {
+ padding:0px;
+ margin:0px;
+}
+
+.ac_results li {
+ display:block;
+ padding: 2px;
+ background: white;
+ color: black;
+ cursor:pointer;
+}
+.ac_results .over {
+ background: yellow;
+}
+
+/* vim: set et ts=4 sts=4 sw=4: */
'search/ajax/region' => $this->make_hook('region', AUTH_COOKIE, 'user', NO_AUTH),
'search/ajax/grade' => $this->make_hook('grade', AUTH_COOKIE, 'user', NO_AUTH),
'advanced_search.php' => $this->make_hook('redir_advanced', AUTH_PUBLIC),
+ 'search/autocomplete' => $this->make_hook('autocomplete', AUTH_PUBLIC),
);
}
$page->assign('grade', '');
$this->get_diplomas($school);
}
+
+ function handler_autocomplete(&$page, $type = null)
+ {
+ // Autocompletion : according to type required, return
+ // a list of results matching with the number of matches.
+ // The output format is :
+ // result1|nb1
+ // result2|nb2
+ // ...
+ header('Content-Type: text/plain; charset="UTF-8"');
+ $q = $_REQUEST['q'];
+ if (!$q) exit();
+ $unique = 'user_id';
+ $db = 'auth_user_md5';
+ switch ($type) {
+ case 'firstname': $field = 'prenom'; break;
+ case 'name': $field = 'nom'; break;
+ case 'nickname': $field = 'profile_nick'; break;
+ case 'entreprise': $db = 'entreprises'; $field = 'entreprise'; $unique='uid'; break;
+ default: exit();
+ }
+
+ $liste = XDB::iterator('SELECT '.$field.' AS field, COUNT(DISTINCT '.$unique.') AS nb FROM '.$db.' WHERE '.$field.' LIKE {?} GROUP BY '.$field.' LIMIT 11', $q.'%');
+ $nbResults = 0;
+ while ($result = $liste->next()) {
+ $nbResults++;
+ if ($nbResults == 11) {
+ echo '...|1'."\n";
+ } else {
+ echo $result['field'].'|'.$result['nb']."\n";
+ }
+ }
+
+ exit();
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
<h1>Recherche dans l'annuaire</h1>
<form id="recherche" action="search/adv" method="get">
+ {javascript name="jquery"}
+ {javascript name="jquery.autocomplete"}
<script type="text/javascript">{literal}
function launch_form(url) {
var f = document.getElementById('recherche');
f.action = url;
f.submit();
}
+ function format_autocomplete(row) {
+ if (row[1] == 1) {
+ return row[0];
+ }
+ return row[0] + ' ('+ row[1] + ')';
+ }
+ $(document).ready(function() {
+ $(".autocomplete").each(function() {
+ $(this).autocomplete("search/autocomplete/"+this.name,{selectOnly:1,formatItem:format_autocomplete});
+ });
+ });
{/literal}</script>
<table class="bicol" cellpadding="3" summary="Recherche">
<tr>
<td>
<input type="hidden" name="rechercher" value="Chercher"/>
<input type="submit" style="display:none"/>
- <input type="text" name="name" size="32" value="{$smarty.request.name}" />
+ <input type="text" class="autocomplete" name="name" size="32" value="{$smarty.request.name}" />
</td>
</tr>
<tr>
<td>Prénom</td>
<td>
- <input type="text" name="firstname" size="32" value="{$smarty.request.firstname}" />
+ <input class="autocomplete" type="text" name="firstname" size="32" value="{$smarty.request.firstname}" />
</td>
</tr>
<tr>
<td>Surnom</td>
<td>
- <input type="text" name="nickname" size="32" value="{$smarty.request.nickname}" />
+ <input class="autocomplete" type="text" name="nickname" size="32" value="{$smarty.request.nickname}" />
</td>
</tr>
<tr>
</tr>
<tr>
<td>Entreprise</td>
- <td><input type="text" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
+ <td><input type="text" class="autocomplete" name="entreprise" size="32" value="{$smarty.request.entreprise}" /></td>
</tr>
<tr>
<td>Fonction</td>
<link rel="bookmark" href="http://www.polytechnique.org/" title="| Polytechnique.org" />
<link rel="bookmark" href="http://www.polytechnique.fr/eleves/" title="| Site d'élèves" />
+ <link rel="stylesheet" type="text/css" href="css/base.css" media="all"/>
{foreach from=$xorg_css item=css}
<link rel="stylesheet" type="text/css" href="css/{$css}" media="all"/>
{/foreach}