[fusion-commits] r1866 - in branches/fusion2-mg21: layers/MapGuide/php widgets/Search

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Jul 14 17:42:10 EDT 2009


Author: waltweltonlair
Date: 2009-07-14 17:42:10 -0400 (Tue, 14 Jul 2009)
New Revision: 1866

Modified:
   branches/fusion2-mg21/layers/MapGuide/php/Common.php
   branches/fusion2-mg21/widgets/Search/Search.php
Log:
Fix #236 (Search.php errors) and #268 (Fix some MapGuide PHP script typos involving FormatMessage).

I ported the fixes for the following MapGuide tickets into Fusion:

 * MG ticket 382 (Implement RFC 43 - Support Search and Selection on Double Identity Properties)

     https://trac.osgeo.org/mapguide/changeset/2686 
       - add support for Int64 and Double identity properties

     https://trac.osgeo.org/mapguide/changeset/3009
       - fix additional issues with Single and DateTime identity properties
       - add support for feature classes with multiple identity properties

 * MG ticket 693 (PHP and ASP AJAX viewer fixes needed for simple search on NULL values)

     https://trac.osgeo.org/mapguide/changeset/3317
       - add support for NULL values

 * MG ticket 1028 (Fix some PHP script typos)

     https://trac.osgeo.org/mapguide/changeset/3999
       - fix typos involving FormatMessage / GetLocalizedString


Modified: branches/fusion2-mg21/layers/MapGuide/php/Common.php
===================================================================
--- branches/fusion2-mg21/layers/MapGuide/php/Common.php	2009-07-14 21:39:52 UTC (rev 1865)
+++ branches/fusion2-mg21/layers/MapGuide/php/Common.php	2009-07-14 21:42:10 UTC (rev 1866)
@@ -175,7 +175,7 @@
 
 function FormatMessage($id, $locale, $params)
 {
-    $text = GetString($id, $locale);
+    $text = GetLocalizedString($id, $locale);
     for($i = 0; $i < count($params); $i++)
     {
         $tag = "{" . $i . "}";

Modified: branches/fusion2-mg21/widgets/Search/Search.php
===================================================================
--- branches/fusion2-mg21/widgets/Search/Search.php	2009-07-14 21:39:52 UTC (rev 1865)
+++ branches/fusion2-mg21/widgets/Search/Search.php	2009-07-14 21:42:10 UTC (rev 1866)
@@ -77,7 +77,7 @@
 
         if($layer == null)
         {
-            trigger_error(FormatMessage("SEARCHLAYERNOTFOUND", $locale, $locale, array($layerName)));
+            trigger_error(FormatMessage("SEARCHLAYERNOTFOUND", $locale, array($layerName)));
         }
 
         //unescape strings
@@ -127,16 +127,11 @@
 
             $classDef = $features->GetClassDefinition();
             $idProps = $classDef->GetIdentityProperties();
-            $multiIds = $idProps->GetCount() > 1;
             $idPropNames = array();
-            $idPropTypes = array();
-            for($j = 0, $count = count($idProps); $j < $count; $j++)
+            for($j = 0; $j < $idProps->GetCount(); $j++)
             {
                 $idProp = $idProps->GetItem($j);
-                if($multiIds)
-                    array_push($idPropNames, $idProp->GetName());
-                else
-                    $idPropName = $idProp->GetName();
+                array_push($idPropNames, $idProp->GetName());
             }
 
             //table headings
@@ -166,52 +161,69 @@
                     $propName = $resProps[$i];
                     $propType = $features->GetPropertyType($resProps[$i]);
                     $val = "";
-                    switch($propType)
+                    if (!$features->IsNull($propName))
                     {
-                        case MgPropertyType::Boolean:
-                            $val = $features->GetBoolean($propName)? "true": "false";
-                            break;
-                        case MgPropertyType::Single:
-                            $val = $features->GetSingle($propName);
-                            break;
-                        case MgPropertyType::Double:
-                            $val = $features->GetDouble($propName);
-                            break;
-                        case MgPropertyType::Int16:
-                            $val = $features->GetInt16($propName);
-                            break;
-                        case MgPropertyType::Int32:
-                            $val = $features->GetInt32($propName);
-                            break;
-                        case MgPropertyType::Int64:
-                            $val = $features->GetInt64($propName);
-                            break;
-                        case MgPropertyType::String:
-                            $val = $features->GetString($propName);
-                            break;
+                        switch($propType)
+                        {
+                            case MgPropertyType::Boolean:
+                                $val = $features->GetBoolean($propName)? "true": "false";
+                                break;
+                            case MgPropertyType::Single:
+                                $val = $features->GetSingle($propName);
+                                break;
+                            case MgPropertyType::Double:
+                                $val = $features->GetDouble($propName);
+                                break;
+                            case MgPropertyType::Int16:
+                                $val = $features->GetInt16($propName);
+                                break;
+                            case MgPropertyType::Int32:
+                                $val = $features->GetInt32($propName);
+                                break;
+                            case MgPropertyType::Int64:
+                                $val = $features->GetInt64($propName);
+                                break;
+                            case MgPropertyType::String:
+                                $val = $features->GetString($propName);
+                                break;
+                            case MgPropertyType::DateTime:
+                                $val = $features->GetDateTime($propName)->ToString();
+                                break;
+                        }
                     }
 
                     // Generate XML to selection this feature
                     //
                     $sel = new MgSelection($map);
-                    if($multiIds)
-                        throw new SearchError(GetLocalizedString("SEARCHNOMULTIPROP", $locale), $searchError);
-                    else
+                    $idProps = new MgPropertyCollection();
+                    foreach ($idPropNames as $id)
                     {
-                        if($i == 0)
-                            $idPropType = $features->GetPropertyType($idPropName);
+                        $idPropType = $features->GetPropertyType($id);
                         switch($idPropType)
                         {
                             case MgPropertyType::Int32:
-                                $sel->AddFeatureIdInt32($layer, $featureClassName, $features->GetInt32($idPropName));
+                                $idProps->Add(new MgInt32Property($id, $features->GetInt32($id)));
                                 break;
                             case MgPropertyType::String:
-                                $sel->AddFeatureIdString($layer, $featureClassName, $features->GetString($idPropName));
+                                $idProps->Add(new MgStringProperty($id, $features->GetString($id)));
                                 break;
+                            case MgPropertyType::Int64:
+                                $idProps->Add(new MgInt64Property($id, $features->GetInt64($id)));
+                                break;
+                            case MgPropertyType::Double:
+                                $idProps->Add(new MgDoubleProperty($id, $features->GetDouble($id)));
+                                break;
+                            case MgPropertyType::Single:
+                                $idProps->Add(new MgSingleProperty($id, $features->GetSingle($id)));
+                                break;
+                            case MgPropertyType::DateTime:
+                                $idProps->Add(new MgDateTimeProperty($id, $features->GetDateTime($id)));
+                                break;
                             default:
                                 throw new SearchError(FormatMessage("SEARCHTYYPENOTSUP", $locale, array($idPropType)), $searchError);
                         }
                     }
+                    $sel->AddFeatureIds($layer, $featureClassName, $idProps);
                     $selText = EscapeForHtml($sel->ToXml(), true);
 
                     echo sprintf("<td class=\"%s\" id=\"%d:%d\" onmousemove=\"SelectRow(%d)\" onclick=\"CellClicked('%s')\">&nbsp;%s</td>\n", !($row%2)? "Search" : "Search2", $row, $i, $row, $selText, $val);
@@ -245,7 +257,6 @@
         OnError($e->title, $e->getMessage());
     }
 
-
     //terminate the html document
     echo "</table></body></html>";
 



More information about the fusion-commits mailing list