From 3ffc616138160be0860a9b4b13d55f7ac200ffca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Mon, 22 Mar 2010 10:23:41 +0100 Subject: [PATCH] Rename education_fmt to display_education and make it a Smarty plugin MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- include/education.func.inc.php | 63 ------------------------- plugins/function.display_education.php | 85 ++++++++++++++++++++++++++++++++++ templates/include/minifiche.tpl | 2 +- 3 files changed, 86 insertions(+), 64 deletions(-) create mode 100644 plugins/function.display_education.php diff --git a/include/education.func.inc.php b/include/education.func.inc.php index 4da4acd..16cca57 100644 --- a/include/education.func.inc.php +++ b/include/education.func.inc.php @@ -106,68 +106,5 @@ function education_degree_name() } Platal::page()->register_function('education_degree_name', 'education_degree_name'); -/** formatte une formation pour l'affichage - */ -function education_fmt($name, $url, $degree, $grad_year, $field, $program, $sexe, $long) -{ - $field = strtolower($field); - $txt = ""; - - if ($grad_year || $field || $program) { - $txt .= ""; - } - } - - if (($degree != "Lic.") || ($long)) { - if (($degree != "Ing.") && ($degree != "Dipl.")) { - $txt .= $degree; - } - if ($name) { - $txt .= ' '; - } - if ($url != ' ') { - $txt .= "$name"; - } else { - $txt .= $name; - } - } - $txt .= ""; - - return $txt; -} - -function _education_fmt($params, &$smarty) -{ - $params = new PlDict($params); - $edu = $params->v('edu'); - if (!$params->has('sex')) { - $profile = $params->v('profile'); - $sex = $profile->isFemale(); - } else { - $sex = $params->b('sex'); - } - return education_fmt($edu->school_short, $edu->school_url, $edu->degree_short, $edu->grad_year, - $edu->field, $edu->program, $sex, $params->b('long')); -} -Platal::page()->register_function('education_fmt', '_education_fmt'); - // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?> diff --git a/plugins/function.display_education.php b/plugins/function.display_education.php new file mode 100644 index 0000000..da0ea96 --- /dev/null +++ b/plugins/function.display_education.php @@ -0,0 +1,85 @@ +"; + } + + if (($degree != "Lic.") || ($long)) { + if (($degree != "Ing.") && ($degree != "Dipl.")) { + $txt .= $degree; + } + if ($name) { + $txt .= ' '; + } + if ($url != '') { + $txt .= "$name"; + } else { + $txt .= $name; + } + } + $txt .= ""; + + return $txt; +} + +function smarty_function_display_education($params, &$smarty) +{ + $params = new PlDict($params); + $edu = $params->v('edu'); + if (!$params->has('sex')) { + $profile = $params->v('profile'); + $sex = $profile->isFemale(); + } else { + $sex = $params->b('sex'); + } + return display_education($edu->school_short, $edu->school_url, $edu->degree_short, $edu->grad_year, + $edu->field, $edu->program, $sex, $params->b('long')); +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/templates/include/minifiche.tpl b/templates/include/minifiche.tpl index 0640732..c4f0dfa 100644 --- a/templates/include/minifiche.tpl +++ b/templates/include/minifiche.tpl @@ -64,7 +64,7 @@ {$nat}  {/foreach} {$profile->promo()}{* - *}{iterate from=$profile->getExtraEducations(4) item=edu}, {education_fmt edu=$edu profile=$profile}{/iterate}{* + *}{iterate from=$profile->getExtraEducations(4) item=edu}, {display_education edu=$edu profile=$profile}{/iterate}{* *}{if $dead}, {"décédé"|sex:"décédée":$profile} le {$profile->deathdate|date_format}{/if} -- 2.1.4