From 92432704df1eccf5ca67be2127a2bdd21376a2bf Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Thu, 12 Apr 2007 17:03:19 +0000 Subject: [PATCH] Code cleaning Move is_utf8 to platal.inc.php include/platal.inc.php | 7 +++++++ include/xorg.misc.inc.php | 8 -------- modules/search.php | 2 -- modules/search/classes.inc.php | 21 +-------------------- templates/search/index.tpl | 13 +------------ 5 files changed, 9 insertions(+), 42 deletions(-) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1691 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/platal.inc.php | 7 +++++++ include/xorg.misc.inc.php | 8 -------- modules/search.php | 2 -- modules/search/classes.inc.php | 21 +-------------------- templates/search/index.tpl | 13 +------------ 5 files changed, 9 insertions(+), 42 deletions(-) diff --git a/include/platal.inc.php b/include/platal.inc.php index 8b0b211..802f9f1 100644 --- a/include/platal.inc.php +++ b/include/platal.inc.php @@ -109,6 +109,13 @@ set_error_handler('pl_error_handler', E_ALL | E_STRICT); register_shutdown_function('pl_print_errors'); // register_shutdown_function('pl_dump_env'); +/** Check if the string is utf8 + */ +function is_utf8($s) +{ + return @iconv('utf-8', 'utf-8', $s) == $s; +} + function pl_url($path, $query = null, $fragment = null) { global $platal; diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php index 24cad5c..49f9c00 100644 --- a/include/xorg.misc.inc.php +++ b/include/xorg.misc.inc.php @@ -75,14 +75,6 @@ function isvalid_email_redirection($email) !preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email); } -/** Check if the string is utf8 - */ -function is_utf8($s) -{ - return @iconv('utf-8', 'utf-8', $s) == $s; -} - - /** genere une chaine aleatoire de 22 caracteres ou moins * @param $len longueur souhaitée, 22 par défaut * @return la chaine aleatoire qui contient les caractères [A-Za-z0-9+/] diff --git a/modules/search.php b/modules/search.php index 651fe8f..e54df37 100644 --- a/modules/search.php +++ b/modules/search.php @@ -118,7 +118,6 @@ class SearchModule extends PLModule $page->changeTpl('search/index.tpl'); $page->assign('xorg_title','Polytechnique.org - Annuaire'); $page->assign('baseurl', $globals->baseurl); - $page->register_modifier('display_lines', 'display_lines'); } function handler_advanced(&$page, $action = null, $subaction = null) @@ -151,7 +150,6 @@ class SearchModule extends PLModule $page->changeTpl('search/index.tpl', $action == 'mini' ? SIMPLE : SKINNED); $page->addJsLink('ajax.js'); $page->assign('public_directory',0); - $page->register_modifier('display_lines', 'display_lines'); } function handler_autocomplete(&$page, $type = null) diff --git a/modules/search/classes.inc.php b/modules/search/classes.inc.php index 9be8cc4..d4405c0 100644 --- a/modules/search/classes.inc.php +++ b/modules/search/classes.inc.php @@ -69,24 +69,6 @@ else LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = \'active\')'; // }}} -// {{{ function display_lines() - -/** - * This function is a heuristic that approximatively tells - * how many lines of output the contact list will use. - */ -function display_lines($text) -{ - $n = 0; - $tokens = Array('', '
'); - foreach ($tokens as $t) { - $i = -1; - while ( ($i = strpos($text,$t,$i+1))!==false) { $n++; } - } - return $n; -} - -// }}} // {{{ class ThrowError /** handle errors for end-users queries @@ -99,13 +81,12 @@ class ThrowError /** constuctor * @param $explain string the error (in natural language) */ - function ThrowError($explain) + public function __construct($explain) { global $page, $globals; $page->changeTpl('search/index.tpl'); $page->assign('xorg_title','Polytechnique.org - Annuaire'); $page->assign('baseurl', $globals->baseurl); - $page->register_modifier('display_lines', 'display_lines'); $page->trig('Erreur : '.$explain); $page->run(); } diff --git a/templates/search/index.tpl b/templates/search/index.tpl index 9a4457c..93c4649 100644 --- a/templates/search/index.tpl +++ b/templates/search/index.tpl @@ -21,7 +21,7 @@ {**************************************************************************} -{if $formulaire==0 and !$xorg_errors|count} +{if $formulaire eq 0 and !$xorg_errors|count} {if !$simple} {if !$advanced} {include file=search/quick.form.tpl show_js=1} @@ -45,17 +45,6 @@ {/if} {if $smarty.session.auth ge AUTH_COOKIE} -
- {if $smarty.capture.list|smarty:nodefaults|display_lines > 20} -
- {if $advanced} - {include file=search/adv.links.tpl do_title=1} - {else} - {include file=search/quick.form.tpl} - {/if} -
- {/if} -

{icon name=lightbulb title=Astruce}Astuce : {if $search_results_nb} -- 2.1.4