From: x2003bruneau Date: Mon, 13 Nov 2006 21:20:27 +0000 (+0000) Subject: Replace auto-submits in advance search with AJAX X-Git-Tag: xorg/0.9.12~122 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=3c640222a9ea55ca8b7415fadf5c24e27e4a3ba9;p=platal.git Replace auto-submits in advance search with AJAX git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1075 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/modules/search.php b/modules/search.php index d06b5e3..68760b2 100644 --- a/modules/search.php +++ b/modules/search.php @@ -26,6 +26,8 @@ class SearchModule extends PLModule return array( 'search' => $this->make_hook('quick', AUTH_PUBLIC), 'search/adv' => $this->make_hook('advanced', AUTH_COOKIE), + 'search/ajax/region' => $this->make_hook('region', AUTH_COOKIE, '', NO_AUTH), + 'search/ajax/grade' => $this->make_hook('grade', AUTH_COOKIE, '', NO_AUTH), 'advanced_search.php' => $this->make_hook('redir_advanced', AUTH_PUBLIC), ); } @@ -103,21 +105,30 @@ class SearchModule extends PLModule XDB::iterator('SELECT id,text FROM applis_def ORDER BY text')); $page->assign('choix_secteurs', XDB::iterator('SELECT id,label FROM emploi_secteur ORDER BY label')); + $this->get_diplomas(); + } + + function get_diplomas($school = null) + { + if (is_null($school) && Env::has('school')) { + $school = Env::i('school'); + } - if (Env::has('school')) { - $sql = 'SELECT type FROM applis_def WHERE id='.Env::i('school'); + if (!is_null($school)) { + $sql = 'SELECT type FROM applis_def WHERE id=' . $school; } else { $sql = 'DESCRIBE applis_def type'; } $res = XDB::query($sql); $row = $res->fetchOneRow(); - if (Env::has('school')) { + if (!is_null($school)) { $types = $row[0]; } else { $types = explode('(',$row[1]); $types = str_replace("'","",substr($types[1],0,-1)); } + global $page; $page->assign('choix_diplomas', explode(',',$types)); } @@ -235,8 +246,24 @@ class SearchModule extends PLModule } + $page->addJsLink('ajax.js'); $page->register_modifier('display_lines', 'display_lines'); } + + function handler_region(&$page, $country = null) + { + require_once("geoloc.inc.php"); + $page->ChangeTpl('search/adv.region.form.tpl', NO_SKIN); + $page->assign('region', ""); + $page->assign('country', $country); + } + + function handler_grade(&$page, $school = null) + { + $page->ChangeTpl('search/adv.grade.form.tpl', NO_SKIN); + $page->assign('grade', ''); + $this->get_diplomas($school); + } } ?> diff --git a/templates/search/adv.form.tpl b/templates/search/adv.form.tpl index f35bf4e..881ebd2 100644 --- a/templates/search/adv.form.tpl +++ b/templates/search/adv.form.tpl @@ -152,7 +152,7 @@ Pays - {if $smarty.request.country} {assign var="country" value=$smarty.request.country} {else} @@ -165,17 +165,13 @@ Région ou département - {if $smarty.request.region} {assign var="region" value=$smarty.request.region} {else} {assign var="region" value=""} {/if} - {if $smarty.request.country neq ""} - {geoloc_region country=$smarty.request.country region=$region} - {else} - - {/if} + {include file="search/adv.region.form.tpl" country=$smarty.request.country} @@ -282,7 +278,7 @@ Formation - {iterate item=cs from=$choix_schools} +{section name=diploma loop=$choix_diplomas} + +{/section} + +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/search/adv.region.form.tpl b/templates/search/adv.region.form.tpl new file mode 100644 index 0000000..61a40ae --- /dev/null +++ b/templates/search/adv.region.form.tpl @@ -0,0 +1,29 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2006 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 *} +{* *} +{**************************************************************************} + +{if $country neq ""} + {geoloc_region country=$country region=$region} +{else} + +{/if} + +{* vim:set et sw=2 sts=2 sws=2: *}