- // Give the list of all values possible of type and builds a select input for it
- $field = 'text';
- $id = 'id';
- switch ($type) {
- case 'binet':
- $db = 'binets_def';
- break;
- case 'fonction':
- $db = 'fonctions_def';
- $field = 'fonction_fr';
- break;
- case 'groupex':
- $db = 'groupesx_def';
- break;
- case 'nationalite':
- $db = 'geoloc_pays';
- $field = 'IF(nat=\'\', pays, nat)';
- $id = 'a2';
- break;
- case 'section':
- $db = 'sections';
- break;
- case 'secteur':
- $db = 'emploi_secteur';
- $field = 'label';
- break;
- default: exit();
- }
- if (isset($idVal)) {
- header('Content-Type: text/plain; charset="UTF-8"');
- $result = XDB::query('SELECT '.$field.' AS field FROM '.$db.' WHERE '.$id.' = {?} LIMIT 1',$idVal);
- echo $result->fetchOneCell();
- } else {
- header('Content-Type: text/xml; charset="UTF-8"');
- $list = XDB::iterator('
- SELECT
- '.$field.' AS field,
- '.$id.' AS id
- FROM '.$db.'
- ORDER BY '.$field);
- echo '<select name="'.$type.'">';
- while ($result = $list->next()) {
- echo '<option value="'.$result['id'].'">'.htmlspecialchars($result['field']).'</option>';
- }
- echo '</select>';
- }
-
- exit();
+ // Give the list of all values possible of type and builds a select input for it
+ $ids = null;
+
+ switch ($type) {
+ case 'binet':
+ $ids = DirEnum::getOptionsIter(DirEnum::BINETS);
+ break;
+ case 'networking_type':
+ $ids = DirEnum::getOptionsIter(DirEnum::NETWORKS);
+ break;
+ case 'country':
+ $ids = DirEnum::getOptionsIter(DirEnum::COUNTRIES);
+ $page->assign('onchange', 'changeCountry(this.value)');
+ break;
+ case 'diploma':
+ if (Env::has('school') && Env::i('school') != 0) {
+ $ids = DirEnum::getOptionsIter(DirEnum::EDUDEGREES, Env::i('school'));
+ } else {
+ $ids = DirEnum::getOptionsIter(DirEnum::EDUDEGREES);
+ }
+ break;
+ case 'groupex':
+ $ids = DirEnum::getOptionsIter(DirEnum::GROUPESX);
+ break;
+ case 'nationalite':
+ $ids = DirEnum::getOptionsIter(DirEnum::NATIONALITIES);
+ break;
+ case 'region':
+ if ($isset($_REQUEST['country'])) {
+ $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS, $_REQUEST['country']);
+ } else {
+ $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS);
+ }
+ break;
+ case 'school':
+ $ids = DirEnum::getOptionsIter(DirEnum::EDUSCHOOLS);
+ $page->assign('onchange', 'changeSchool(this.value)');
+ break;
+ case 'section':
+ $ids = DirEnum::getOptionsIter(DirEnum::SECTIONS);
+ break;
+ case 'secteur':
+ $ids = DirEnum::getOptionsIter(DirEnum::SECTORS);
+ break;
+ default: exit();
+ }
+ if (isset($idVal)) {
+ pl_content_headers("text/plain");
+ echo $ids[$idVal];
+ exit();
+ }
+ pl_content_headers("text/xml");
+ $page->changeTpl('include/field.select.tpl', NO_SKIN);
+ $page->assign('name', $type);
+ $page->assign('list', $ids);
+ $page->assign('with_text_value', true);
+ $page->assign('onchange', "document.forms.recherche.{$type}Txt.value = this.options[this.selectedIndex].text");