The skill page
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 9 Sep 2007 12:49:57 +0000 (14:49 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 9 Sep 2007 12:49:57 +0000 (14:49 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/profile.php
modules/profile/assign_skill.inc.php [deleted file]
modules/profile/get_skill.inc.php [deleted file]
modules/profile/page.inc.php
modules/profile/skills.inc.php [new file with mode: 0644]
modules/profile/update_skill.inc.php [deleted file]
modules/profile/verif_skill.inc.php [deleted file]
templates/profile/skill.skill.tpl [new file with mode: 0644]
templates/profile/skill.tpl

index 40ef129..abf5de5 100644 (file)
@@ -37,6 +37,7 @@ class ProfileModule extends PLModule
             'profile/ajax/medal'   => $this->make_hook('ajax_medal',   AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/job'     => $this->make_hook('ajax_job',     AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE, 'user', NO_AUTH),
+            'profile/ajax/skill'   => $this->make_hook('ajax_skill',   AUTH_COOKIE, 'user', NO_AUTH),
             'profile/medal'    => $this->make_hook('medal', AUTH_PUBLIC),
             'profile/orange'   => $this->make_hook('p_orange',   AUTH_MDP),
             'profile/usage'    => $this->make_hook('p_usage',    AUTH_MDP),
@@ -398,6 +399,26 @@ class ProfileModule extends PLModule
         $page->assign('sel', $ssect);
     }
 
+    function handler_ajax_skill(&$page, $cat, $id)
+    {
+        $page->changeTpl('profile/skill.skill.tpl', NO_SKIN);
+        $page->assign('ajaxskill', true);
+        $page->assign('cat', $cat);
+        $page->assign('id', $id);
+        if ($cat == 'competences') {
+          $page->assign('levels', array('initié' => 'initié',
+                                        'bonne connaissance' => 'bonne connaissance',
+                                        'expert' => 'expert'));
+        } else {
+          $page->assign('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'));
+        }
+    }
+
     function handler_p_orange(&$page)
     {
         $page->changeTpl('profile/orange.tpl');
diff --git a/modules/profile/assign_skill.inc.php b/modules/profile/assign_skill.inc.php
deleted file mode 100644 (file)
index 9f2adc1..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/***************************************************************************
- *  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                *
- ***************************************************************************/
-
-$page->assign('nb_lg_max', $nb_lg_max);
-$page->assign('nb_cpro_max', $nb_cpro_max);
-$page->assign('nb_lg', $nb_lg);
-$page->assign_by_ref('langue_id', $langue_id);
-$page->assign_by_ref('langue_name', $langue_name);
-$page->assign_by_ref('langue_level', $langue_level);
-$page->assign('nb_cpro', $nb_cpro);
-$page->assign_by_ref('cpro_id', $cpro_id);
-$page->assign_by_ref('cpro_name', $cpro_name);
-$page->assign_by_ref('cpro_level', $cpro_level);
-$page->assign_by_ref('langues_levels',$langues_levels);
-$page->assign_by_ref('langues_def',$langues_def);
-$page->assign_by_ref('comppros_levels',$comppros_levels);
-$page->assign_by_ref('comppros_def',$comppros_def);
-$page->assign_by_ref('comppros_title',$comppros_title);
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/modules/profile/get_skill.inc.php b/modules/profile/get_skill.inc.php
deleted file mode 100644 (file)
index d5a2ee1..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-/***************************************************************************
- *  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                *
- ***************************************************************************/
-
-
-if(Env::has('langue_op')){
-    if(Env::v('langue_op', '')=='retirer'){
-        XDB::execute("DELETE FROM langues_ins WHERE uid = {?} AND lid = {?}", S::v('uid', -1), Env::v('langue_id', ''));
-    } elseif(Env::v('langue_op', '') == 'ajouter'){
-        if(Env::v('langue_id', '') != '')
-            XDB::execute("INSERT INTO langues_ins (uid,lid,level) VALUES ({?}, {?}, {?})", S::v('uid', -1), Env::v('langue_id', ''), Env::v('langue_level', ''));
-    }
-}
-
-if(Env::has('comppros_op')){
-    if(Env::v('comppros_op', '')=='retirer'){
-        XDB::execute("DELETE FROM competences_ins WHERE uid = {?} AND cid = {?}", S::v('uid', -1), Env::v('comppros_id', ''));
-    } elseif(Env::v('comppros_op', '') == 'ajouter') {
-        if(Env::v('comppros_id', '') != '')
-           XDB::execute("INSERT INTO competences_ins (uid,cid,level) VALUES({?}, {?}, {?})", S::v('uid', -1), Env::v('comppros_id', ''), Env::v('comppros_level', ''));
-    }
-}
-
-// nombre maximum autorisé de langues
-$nb_lg_max = 10;
-// nombre maximum autorisé de compétences professionnelles
-$nb_cpro_max = 20;
-
-$res = XDB::iterRow("SELECT ld.id, ld.langue_fr, li.level FROM langues_ins AS li, langues_def AS ld "
-               ."WHERE (li.lid=ld.id AND li.uid= {?}) LIMIT $nb_lg_max", S::v('uid', -1));
-
-$nb_lg = $res->total();
-
-for ($i = 1; $i <= $nb_lg; $i++) {
-    list($langue_id[$i], $langue_name[$i], $langue_level[$i]) = $res->next();
-}
-
-$res = XDB::iterRow("SELECT cd.id, cd.text_fr, ci.level FROM competences_ins AS ci, competences_def AS cd "
-               ."WHERE (ci.cid=cd.id AND ci.uid={?}) LIMIT $nb_cpro_max", S::v('uid', -1));
-
-$nb_cpro = $res->total();
-
-for ($i = 1; $i <= $nb_cpro; $i++) {
-    list($cpro_id[$i], $cpro_name[$i], $cpro_level[$i]) = $res->next();
-}
-//Definitions des tables de correspondances id => nom
-
-$langues_levels = Array(
-    1 => "1",
-    2 => "2",
-    3 => "3",
-    4 => "4",
-    5 => "5",
-    6 => "6"
-);
-
-$res = XDB::iterRow("SELECT id, langue_fr FROM langues_def");
-
-while(list($tmp_lid, $tmp_lg_fr) = $res->next()){
-    $langues_def[$tmp_lid] = $tmp_lg_fr;
-}
-
-$comppros_levels = Array(
-    'initié' => 'initié',
-    'bonne connaissance' => 'bonne connaissance',
-    'expert' => 'expert'
-);
-
-$res = XDB::iterRow("SELECT id, text_fr, FIND_IN_SET('titre',flags) FROM competences_def");
-
-while(list($tmp_id, $tmp_text_fr, $tmp_title) = $res->next()){
-    $comppros_def[$tmp_id] = $tmp_text_fr;
-    $comppros_title[$tmp_id] = $tmp_title;
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
index 143dd9d..f07ef04 100644 (file)
@@ -288,6 +288,7 @@ require_once dirname(__FILE__) . '/addresses.inc.php';
 require_once dirname(__FILE__) . '/groups.inc.php';
 require_once dirname(__FILE__) . '/decos.inc.php';
 require_once dirname(__FILE__) . '/jobs.inc.php';
+require_once dirname(__FILE__) . '/skills.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>
diff --git a/modules/profile/skills.inc.php b/modules/profile/skills.inc.php
new file mode 100644 (file)
index 0000000..a922fc0
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+/***************************************************************************
+ *  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                *
+ ***************************************************************************/
+
+class ProfileSkill implements ProfileSetting
+{
+    private $table;
+    private $skill_field;
+    private $text_field;
+
+    public function __construct($table, $skill, $text)
+    {
+        $this->table = $table;
+        $this->skill_field = $skill;
+        $this->text_field = $text;
+    }
+
+    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
+                                   FROM  {$this->table}_def AS s
+                             INNER JOIN  {$this->table}_ins AS i ON(s.id = i.{$this->skill_field})
+                                  WHERE  i.uid = {?}",
+                                S::i('uid'));
+            while (list($sid, $text, $level) = $res->next()) {
+                $value[$sid] = array('text' => $text, 'level' => $level);
+            }
+        }
+        if (!is_array($value)) {
+            $value = array();
+        } else {
+            foreach ($value as $id=>&$skill) {
+                if (!isset($skill['text']) || empty($skill['text'])) {
+                    $res = XDB::query("SELECT  {$this->text_field}
+                                         FROM  {$this->table}_def
+                                        WHERE  id = {?}", $id);
+                    $skill['text'] = $res->fetchOneCell();
+                }
+            }
+        }
+        ksort($value);
+        $success = true;
+        return $value;
+    }
+
+    public function save(ProfilePage &$page, $field, $value)
+    {
+        XDB::execute("DELETE FROM  {$this->table}_ins
+                            WHERE  uid = {?}",
+                     S::i('uid'));
+        if (!count($value)) {
+            return;
+        }
+        foreach ($value as $id=>&$skill) {
+            XDB::execute("INSERT INTO  {$this->table}_ins (uid, {$this->skill_field}, level)
+                               VALUES  ({?}, {?}, {?})",
+                         S::i('uid'), $id, $skill['level']);
+        }
+    }
+}
+
+class ProfileSkills extends ProfilePage
+{
+    protected $pg_template = 'profile/skill.tpl';
+
+    public function __construct(PlWizard &$wiz)
+    {
+        parent::__construct($wiz);
+        $this->settings['competences'] = new ProfileSkill('competences', 'cid', 'text_fr');
+        $this->settings['langues'] = new ProfileSkill('langues', 'lid', 'langue_fr');
+    }
+
+    public function prepare(PlatalPage &$page)
+    {
+        parent::prepare($page);
+        $page->assign('comp_list', XDB::iterator("SELECT  id, text_fr, FIND_IN_SET('titre',flags) AS title
+                                                    FROM  competences_def"));
+        $page->assign('comp_level', array('initié' => 'initié',
+                                          'bonne connaissance' => 'bonne connaissance',
+                                          'expert' => 'expert'));
+        $page->assign('lang_list', XDB::iterator("SELECT  id, langue_fr
+                                                    FROM  langues_def"));
+        $page->assign('lang_level', 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'));
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/modules/profile/update_skill.inc.php b/modules/profile/update_skill.inc.php
deleted file mode 100644 (file)
index 90ddbd4..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/***************************************************************************
- *  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                *
- ***************************************************************************/
-
-//rien a faire
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/modules/profile/verif_skill.inc.php b/modules/profile/verif_skill.inc.php
deleted file mode 100644 (file)
index 90ddbd4..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/***************************************************************************
- *  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                *
- ***************************************************************************/
-
-//rien a faire
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
diff --git a/templates/profile/skill.skill.tpl b/templates/profile/skill.skill.tpl
new file mode 100644 (file)
index 0000000..5579bc6
--- /dev/null
@@ -0,0 +1,39 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+{if $ajaxskill}
+<?xml version="1.0" encoding="utf-8"?>
+{/if}
+<div id="{$cat}_{$id}" style="clear: both; margin-top: 0.5em">
+  <div style="float: left; width: 50%" class="titre" id="{$cat}_{$id}_title">
+    {$skill.text}
+    <input type="hidden" name="{"`$cat`[`$id`][text]"}" value="{$skill.text}" />
+  </div>
+  <select name="{"`$cat`[`$id`][level]"}">
+    {foreach from=$levels item=level key=lid}
+    <option value="{$lid}" {if $skill.level eq $lid}selected="selected"{/if}>{$level}</option>
+    {/foreach}
+  </select>
+  <a href="javascript:remove('{$cat}', '{$id}')">{icon name=cross title="Supprimer"}</a>
+</div>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 8619657..4bdba40 100644 (file)
 {**************************************************************************}
 
 
+<script type="text/javascript">//<![CDATA[
 {literal}
-<script type="text/javascript">
-  //<![CDATA[
-  function langue_add()
-  {
-    var selectid = document.forms.prof_annu.langue_sel_add.selectedIndex;
-    document.forms.prof_annu.langue_id.value = document.forms.prof_annu.langue_sel_add.options[selectid].value;
-    var selectid_level = document.forms.prof_annu.langue_level_sel_add.selectedIndex;
-    document.forms.prof_annu.langue_level.value = document.forms.prof_annu.langue_level_sel_add.options[selectid_level].value;
-    document.forms.prof_annu.langue_op.value = "ajouter";
-    document.forms.prof_annu.submit();
-  } // function langue_add()
 
-  function langue_del( lid )
-  {
-    document.forms.prof_annu.langue_id.value = lid;
-    document.forms.prof_annu.langue_op.value = "retirer";
-    document.forms.prof_annu.submit();
-  } // function langue_del( id )
+function update(cat)
+{
+  var val  = document.forms.prof_annu[cat + '_sel'].value;
+  var show = true;
+  if (val == '') {
+    show = false;
+  }
+  if (document.getElementById(cat + '_' + val) != null) {
+    show = false;
+  }
+  document.getElementById(cat + '_add').style.display = show ? '' : 'none';
+}
 
-  function comppros_add()
-  {
-    var selectid = document.forms.prof_annu.comppros_sel_add.selectedIndex;
-    document.forms.prof_annu.comppros_id.value = document.forms.prof_annu.comppros_sel_add.options[selectid].value;
-    var selectid_level = document.forms.prof_annu.comppros_level_sel_add.selectedIndex;
-    document.forms.prof_annu.comppros_level.value = document.forms.prof_annu.comppros_level_sel_add.options[selectid_level].value;
-    document.forms.prof_annu.comppros_op.value = "ajouter";
-    document.forms.prof_annu.submit();
-  } // function langue_add()
+function add(cat)
+{
+  var sel  = document.forms.prof_annu[cat + '_sel'];
+  var val  = sel.value;
+  var text = sel.options[sel.selectedIndex].text;
+  $.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val,
+        function(data) {
+          $('#' + cat).append(data);
+          document.getElementById(cat + '_' + val + '_title').innerHTML = text;
+          update(cat);
+        });
+}
+
+function remove(cat, id)
+{
+  $('#' + cat + '_' + id).remove();
+  update(cat);
+}
 
-  function comppros_del( cid )
-  {
-    document.forms.prof_annu.comppros_id.value = cid;
-    document.forms.prof_annu.comppros_op.value = "retirer";
-    document.forms.prof_annu.submit();
-  } // function comppros_del( id )
-  //]]>
-</script>
 {/literal}
+//]]></script>
 
-<div class="blocunite_tab">
-  <table class="bicol"cellspacing="0" cellpadding="0" 
-    summary="Profil: Compétences professionnelles">
-    <tr>
-      <th colspan="3">
-        Compétences professionnelles
-        <input type="hidden" value="" name="comppros_op" />
-        <input type="hidden" value="" name="comppros_id" />
-        <input type="hidden" value="" name="comppros_level" />
-      </th>
-    </tr>
-    <tr>
-      <td colspan="3" class="pflags">
-        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-          <tr>
-            <td class="rouge">
-              <input type="checkbox" name="accesX" checked="checked" disabled="disabled" />
-            </td>
-            <td class="texte">
-              privé
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-    <tr class="impair">
-      <td class="colg">
-        <span class="titre">Domaine</span>
-      </td>
-      <td class="colm">
-        <span class="titre">Niveau</span>
-      </td>
-      <td class="cold" style="width:15%">
-        &nbsp;
-      </td>
-    </tr>
-    {foreach from=$cpro_name key=i item=name}
-    <tr class="{cycle values="pair,impair"}">
-      <td class="colg">
-        <span class="valeur">{$name}</span>
-      </td>
-      <td class="colm">
-        <span class="valeur">&nbsp;&nbsp;{$cpro_level.$i}</span>
-      </td>
-      <td class="cold">
-        <span class="lien"><a href="javascript:comppros_del('{$cpro_id.$i}');">retirer</a></span>
-      </td>
-    </tr>
-    {/foreach}
-    {if $nb_cpro < $nb_cpro_max}
-    <tr class="{cycle values="pair,impair"}">
-      <td class="colg">
-        <select name="comppros_sel_add">
-          <option value=""></option>
-          {foreach from=$comppros_def item=cn key=id}
-          <option value="{$id}">{if $comppros_title.$id}-{else}&nbsp;&nbsp;{/if}&nbsp;{$cn}</option>
-          {/foreach}
-        </select>
-      </td>
-      <td class="colm">
-        <select name="comppros_level_sel_add">
+<table class="bicol" style="margin-bottom: 1em">
+  <tr>
+    <th>
+      Compétences professionnelles
+    </th>
+  </tr>
+  <tr>
+    <td>
+      <div class="flags">
+        <span class="rouge"><input type="checkbox" name="accesX" checked="checked" disabled="disabled" /></span>
+        <span class="texte">privé</span>
+      </div>
+      <div>
+        <span class="titre">Domaine&nbsp;:</span>
+        <select name="competences_sel" onchange="update('competences')">
           <option value=""></option>
-          {foreach from=$comppros_levels item=ln key=l}
-          <option value="{$l}">{$ln}</option>
-          {/foreach}
+          {assign var=ingroup value=false}
+          {iterate from=$comp_list item=comp}
+          {if $comp.title}
+          {if $ingroup}</optgroup>{/if}
+          <optgroup label="{$comp.text_fr}">
+          {/if}
+          <option value="{$comp.id}">{$comp.text_fr}</option>
+          {/iterate}
+          {if $ingroup}</optgroup>{/if}
         </select>
-      </td>
-      <td class="cold">
-        <span class="lien"><a href="javascript:comppros_add();">ajouter</a></span>
-      </td>
-    </tr>
-    {/if}   
-  </table>
-</div>
+        <span id="competences_add" style="display: none">
+          <a href="javascript:add('competences')">{icon name=add title="Ajouter cette compétence"}</a>
+        </span>
+      </div>
+    </td>
+  </tr>
+  <tr class="pair">
+    <td id="competences">
+      {foreach from=$competences item=competence key=id}
+      {include file="profile/skill.skill.tpl" cat='competences' skill=$competence id=$id levels=$comp_level}
+      {/foreach}
+    </td>
+  </tr>
+</table>
 
-<div class="blocunite">
-  <table class="bicol" cellspacing="0" cellpadding="0" 
-    summary="Profil: Compétences linguistiques">
-    <tr>
-      <th colspan="3">
-        Compétences linguistiques
-        <input type="hidden" value="" name="langue_op" />
-        <input type="hidden" value="" name="langue_id" />
-        <input type="hidden" value="" name="langue_level" />
-      </th>
-    </tr>
-    <tr>
-      <td colspan="3" class="pflags">
-        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-          <tr>
-            <td class="rouge">
-              <input type="checkbox" name="accesX" checked="checked" disabled="disabled" />
-            </td>
-            <td class="texte">
-              privé
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-    <tr class="impair">
-      <td class="colg">
-        <span class="titre">Langue</span>
-      </td>
-      <td class="colm">
-        <span class="titre">Niveau</span>
-      </td>
-      <td class="cold" style="width:15%">
-        <span class="lien"><a href="Xorg/FAQ?display=light#niveau_langue" class="popup_800x600">Quel niveau ?</a></span>
-      </td>
-    </tr>
-    {foreach from=$langue_name item=name key=i}
-    <tr class="{cycle values="pair,impair"}">
-      <td class="colg">
-        <span class="valeur">{$name}</span>
-      </td>
-      <td class="colm">
-        <span class="valeur">&nbsp;&nbsp;{if $langue_level.$i == 0}-{else}{$langue_level.$i}{/if}</span>
-      </td>
-      <td class="cold">
-        <span class="lien"><a href="javascript:langue_del('{$langue_id.$i}');">retirer</a></span>
-      </td>
-    </tr>
-    {/foreach}
-    {if $nb_lg < $nb_lg_max}
-    <tr class="{cycle values="pair,impair"}">
-      <td class="colg">
-        <select name="langue_sel_add">
-          <option value=""></option>
-          {foreach from=$langues_def item=n key=i}
-          <option value="{$i}">{$n}</option>
-          {/foreach}
-        </select>
-      </td>
-      <td class="colm">
-        <select name="langue_level_sel_add">
+<table class="bicol">
+  <tr>
+    <th>Compétences linguistiques</th>
+  </tr>
+  <tr>
+    <td>
+      <div class="flags">
+        <span class="rouge"><input type="checkbox" name="accesX" checked="checked" disabled="disabled" /></span>
+        <span class="texte">privé</span>
+      </div>
+      <div>
+        <span class="titre">Domaine&nbsp;:</span>
+        <select name="langues_sel" onchange="update('langues')">
           <option value=""></option>
-          {foreach from=$langues_levels item=l key=i}
-          <option value="{$i}">{$l}</option>
-          {/foreach}
+          {iterate from=$lang_list item=lang}
+          <option value="{$lang.id}">{$lang.langue_fr}</option>
+          {/iterate}
         </select>
-      </td>
-      <td class="cold">
-        <span class="lien"><a href="javascript:langue_add();">ajouter</a></span>
-      </td>
-    </tr>
-    {/if}
-  </table>
-</div>
+        <span id="langues_add" style="display: none">
+          <a href="javascript:add('langues')">{icon name=add title="Ajouter cette langue"}</a>
+        </span>
+      </div>
+    </td>
+  </tr>
+  <tr class="pair">
+    <td id="langues">
+      {foreach from=$langues item=langue key=id}
+      {include file="profile/skill.skill.tpl" cat='langues' skill=$langue id=$id levels=$lang_level}
+      {/foreach}
+    </td>
+  </tr>
+ </table>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}