Fixes region selection when choosing country from list. Fixes also for schools. Close...
authorPascal Corpet <pascal.corpet@m4x.org>
Sun, 13 Jun 2010 21:44:20 +0000 (23:44 +0200)
committerPascal Corpet <pascal.corpet@m4x.org>
Sun, 13 Jun 2010 21:44:20 +0000 (23:44 +0200)
ChangeLog
classes/direnum.php
modules/search.php

index 7bb8b4d..c67e214 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,9 @@ Bug/Wish:
         - #1068: Fixes addresses display on profile                        -JAC
         - #1081: Sorts language alphabetically in skill tab                -Car
 
+    * Search:
+        - #870: Fixes region selection when choosing country from list     -Car
+
     * Survey:
         - #993: Enables survey for oranges                                 -Car
         - #1002: Lets the user set promo interval in both ways             -Car
index a8b9a8e..90fb331 100644 (file)
@@ -94,8 +94,10 @@ class DirEnum
             self::init($type);
         }
         $obj = self::$enumerations[$type];
+        $args = func_get_args();
+        array_shift($args);
         if ($obj->capabilities & DirEnumeration::HAS_OPTIONS) {
-            return call_user_func(array($obj, 'getOptionsIter'));
+            return call_user_func_array(array($obj, 'getOptionsIter'), $args);
         } else {
             return PlIteratorUtils::fromArray(array());
         }
@@ -344,7 +346,7 @@ abstract class DE_WithSuboption extends DirEnumeration
         } else if (array_key_exists($subid, $this->suboptions)) {
             return $this->suboptions[$subid];
         } else {
-            return false;
+            return array();
         }
     }
 
index 7b4b302..7edd6e8 100644 (file)
@@ -243,6 +243,10 @@ class SearchModule extends PLModule
 
     function handler_list(&$page, $type = null, $idVal = null)
     {
+        $page->assign('name', $type);
+        $page->assign('with_text_value', true);
+        $page->assign('onchange', "document.forms.recherche.{$type}Txt.value = this.options[this.selectedIndex].text");
+
         // Give the list of all values possible of type and builds a select input for it
         $ids = null;
 
@@ -270,9 +274,9 @@ class SearchModule extends PLModule
           case 'nationalite':
             $ids = DirEnum::getOptionsIter(DirEnum::NATIONALITIES);
             break;
-        case 'region':
-            if ($isset($_REQUEST['country'])) {
-                $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS, $_REQUEST['country']);
+          case 'region':
+            if (Env::has('country')) {
+                $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS, Env::v('country'));
             } else {
                 $ids = DirEnum::getOptionsIter(DirEnum::ADMINAREAS);
             }
@@ -296,10 +300,7 @@ class SearchModule extends PLModule
         }
         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");
     }
 }