X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fskills.inc.php;h=31458113e33b6999fbf7c305097c87f2d19af547;hb=e905370aaccddb31d7023cc5488f98accae80802;hp=1f18133988824d2aaa9aaf474be8f87a2b6b693b;hpb=8def9eb54fa949fce13b35a4e26add2a8118e6aa;p=platal.git diff --git a/modules/profile/skills.inc.php b/modules/profile/skills.inc.php index 1f18133..3145811 100644 --- a/modules/profile/skills.inc.php +++ b/modules/profile/skills.inc.php @@ -1,6 +1,6 @@ table = $table; + $this->id = $id; $this->skill_field = $skill; $this->text_field = $text; } - public function value(ProfilePage &$page, $field, $value, &$success) + public function value(ProfilePage $page, $field, $value, &$success) { if (is_null($value)) { $value = array(); - $res = XDB::iterRow("SELECT s.id, s.{$this->text_field}, i.level + $res = XDB::iterRow("SELECT s.{$this->id}, s.{$this->text_field}, i.level FROM profile_{$this->table}_enum AS s - INNER JOIN profile_{$this->table}s AS i ON(s.id = i.{$this->skill_field}) + INNER JOIN profile_{$this->table}s AS i ON (s.{$this->id} = i.{$this->skill_field}) WHERE i.pid = {?}", $page->pid()); while (list($sid, $text, $level) = $res->next()) { @@ -52,7 +54,7 @@ class ProfileSettingSkill implements ProfileSetting if (!isset($skill['text']) || empty($skill['text'])) { $res = XDB::query("SELECT {$this->text_field} FROM profile_{$this->table}_enum - WHERE id = {?}", $id); + WHERE {$this->id} = {?}", $id); $skill['text'] = $res->fetchOneCell(); } } @@ -62,7 +64,7 @@ class ProfileSettingSkill implements ProfileSetting return $value; } - public function save(ProfilePage &$page, $field, $value) + public function save(ProfilePage $page, $field, $value) { XDB::execute("DELETE FROM profile_{$this->table}s WHERE pid = {?}", @@ -79,34 +81,50 @@ class ProfileSettingSkill implements ProfileSetting public function getText($value) { $skills = array(); - foreach ($value as $skill) { - $skills[] = 'Compétance : ' . $skill['text'] . ', niveau : ' . $skill['level']; + + if ($this->table == 'langskill') { + static $levels = array( + 1 => 'connaissance basique', + 2 => 'maîtrise des bases', + 3 => 'maîtrise limitée', + 4 => 'maîtrise générale', + 5 => 'bonne maîtrise', + 6 => 'maîtrise complète' + ); + foreach ($value as $skill) { + $skills[] = $skill['text'] . ' (' . $levels[$skill['level']] . ')'; + } + } else { + foreach ($value as $skill) { + $skills[] = $skill['text'] . ' (' . $skill['level'] . ')'; + } } - return implode(' ; ' , $skills); + + return implode(', ' , $skills); } } -class ProfileSettingSkills extends ProfilePage +class ProfilePageSkills extends ProfilePage { protected $pg_template = 'profile/skill.tpl'; - public function __construct(PlWizard &$wiz) + public function __construct(PlWizard $wiz) { parent::__construct($wiz); - $this->settings['competences'] = new ProfileSettingSkill('skill', 'cid', 'text_fr'); - $this->settings['langues'] = new ProfileSettingSkill('langskill', 'lid', 'langue_fr'); + $this->settings['competences'] = new ProfileSettingSkill('skill', 'id', 'cid', 'text_fr'); + $this->settings['langues'] = new ProfileSettingSkill('langskill', 'iso_639_2b', 'lid', 'language'); } - public function _prepare(PlPage &$page, $id) + public function _prepare(PlPage $page, $id) { $page->assign('comp_list', XDB::iterator("SELECT id, text_fr, FIND_IN_SET('titre',flags) AS title FROM profile_skill_enum")); $page->assign('comp_level', array('initié' => 'initié', 'bonne connaissance' => 'bonne connaissance', 'expert' => 'expert')); - $page->assign('lang_list', XDB::iterator("SELECT id, langue_fr + $page->assign('lang_list', XDB::iterator('SELECT iso_639_2b, language FROM profile_langskill_enum - ORDER BY langue_fr")); + ORDER BY language')); $page->assign('lang_level', array(1 => 'connaissance basique', 2 => 'maîtrise des bases', 3 => 'maîtrise limitée',