[fusion-commits] r2657 - in trunk/widgets/Redline: . classes

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Mar 8 03:49:36 PST 2013


Author: jng
Date: 2013-03-08 03:49:35 -0800 (Fri, 08 Mar 2013)
New Revision: 2657

Modified:
   trunk/widgets/Redline/classes/markupeditor.php
   trunk/widgets/Redline/editmarkup.php
   trunk/widgets/Redline/markupmain.php
Log:
#551: Add support for SHP as a redline data store (Can't download/upload SHP redlines yet). Also fix some problems with displaying exception messages.

Modified: trunk/widgets/Redline/classes/markupeditor.php
===================================================================
--- trunk/widgets/Redline/classes/markupeditor.php	2013-03-08 10:39:35 UTC (rev 2656)
+++ trunk/widgets/Redline/classes/markupeditor.php	2013-03-08 11:49:35 UTC (rev 2657)
@@ -57,10 +57,16 @@
         $featureSourceId = $this->GetFeatureSource();
 
         $featureReader = $featureService->SelectFeatures($featureSourceId, 'Markup', null);
+        //HACK: Another leaky abstraction. SHP will always choose FeatId, so once again
+        //use the class definition to determine the identity property name
+        $clsDef = $featureReader->GetClassDefinition();
+        $idProps = $clsDef->GetIdentityProperties();
+        $keyProp = $idProps->GetItem(0);
+        $idName = $keyProp->GetName();
         while ($featureReader->ReadNext())
         {
-            $id = $featureReader->GetInt32('ID');
-            $text = trim($featureReader->GetString('Text'));
+            $id = $featureReader->GetInt32($idName);
+            $text = $featureReader->IsNull('Text') ? '' : trim($featureReader->GetString('Text'));
             $features[$id] = $text;
         }
         $featureReader->Close();
@@ -228,9 +234,15 @@
     {
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
         $featureSourceId = $this->GetFeatureSource();
+        //HACK: Another leaky abstraction. SHP will always choose FeatId, so once again
+        //use the class definition to determine the identity property name
+        $clsDef = $this->GetClassDefinition();
+        $idProps = $clsDef->GetIdentityProperties();
+        $keyProp = $idProps->GetItem(0);
+        $idName = $keyProp->GetName();
 
         $commands = new MgFeatureCommandCollection();
-        $commands->Add(new MgDeleteFeatures('Markup', 'ID = ' . $this->args['MARKUPFEATURE']));
+        $commands->Add(new MgDeleteFeatures('Markup', $idName . ' = ' . $this->args['MARKUPFEATURE']));
 
         $result = $featureService->UpdateFeatures($featureSourceId, $commands, false);
         MarkupEditor::CleanupReaders($result);
@@ -240,12 +252,18 @@
     {
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
         $featureSourceId = $this->GetFeatureSource();
+        //HACK: Another leaky abstraction. SHP will always choose FeatId, so once again
+        //use the class definition to determine the identity property name
+        $clsDef = $this->GetClassDefinition();
+        $idProps = $clsDef->GetIdentityProperties();
+        $keyProp = $idProps->GetItem(0);
+        $idName = $keyProp->GetName();
 
         $propertyValues = new MgPropertyCollection();
         $propertyValues->Add(new MgStringProperty('Text', trim($this->args['UPDATETEXT'])));
 
         $commands = new MgFeatureCommandCollection();
-        $commands->Add(new MgUpdateFeatures('Markup', $propertyValues, 'ID = ' . $this->args['MARKUPFEATURE']));
+        $commands->Add(new MgUpdateFeatures('Markup', $propertyValues, $idName . ' = ' . $this->args['MARKUPFEATURE']));
 
         $result = $featureService->UpdateFeatures($featureSourceId, $commands, false);
         MarkupEditor::CleanupReaders($result);

Modified: trunk/widgets/Redline/editmarkup.php
===================================================================
--- trunk/widgets/Redline/editmarkup.php	2013-03-08 10:39:35 UTC (rev 2656)
+++ trunk/widgets/Redline/editmarkup.php	2013-03-08 11:49:35 UTC (rev 2657)
@@ -19,6 +19,7 @@
     $allowPoint = false;
     $allowLine = false;
     $allowPoly = false;
+    $markupFeatures = array();
 
     SetLocalizedFilesPath(GetLocalizationPath());
     if(isset($_REQUEST['LOCALE'])) {
@@ -99,7 +100,7 @@
     }
     catch (MgException $e)
     {
-        $errorMsg = $e->GetMessage();
+        $errorMsg = $e->GetExceptionMessage();
         $errorDetail = $e->GetDetails();
     }
     catch (Exception $e)
@@ -111,6 +112,7 @@
 <html>
 <head>
     <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<?php if ($errorMsg == null) { ?>
     <title><?=$editLocal?></title>
     <link rel="stylesheet" href="Redline.css" type="text/css">
     <script language="javascript" src="../../layers/MapGuide/MapGuideViewerApi.js"></script>
@@ -351,8 +353,6 @@
 
 <body onLoad="OnLoad()" marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
 
-<?php if ($errorMsg == null) { ?>
-
 <form action="editmarkup.php" method="post" enctype="application/x-www-form-urlencoded" id="editForm" target="_self">
 <table class="RegText" border="0" cellspacing="0" width="100%">
     <tr>
@@ -433,7 +433,8 @@
 <input name="TEXT" type="hidden" value="" id="textInput">
 </form>
 <?php } else { ?>
-
+</head>
+<body>
 <table class="RegText" border="0" cellspacing="0" width="100%%">
     <tr><td class="Title">Error<hr></td></tr>
     <tr><td><?= $errorMsg ?></td></tr>

Modified: trunk/widgets/Redline/markupmain.php
===================================================================
--- trunk/widgets/Redline/markupmain.php	2013-03-08 10:39:35 UTC (rev 2656)
+++ trunk/widgets/Redline/markupmain.php	2013-03-08 11:49:35 UTC (rev 2657)
@@ -111,6 +111,7 @@
 <head>
     <title>Manage Markups</title>
     <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+<?php if ($errorMsg == null) { ?>
     <link rel="stylesheet" href="Redline.css" type="text/css">
     <script language="javascript" src="../../layers/MapGuide/MapGuideViewerApi.js"></script>
     <script language="javascript" src="../../common/browserdetect.js"></script>
@@ -318,8 +319,6 @@
 
 <body onLoad="OnLoad()" marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
 
-<?php if ($errorMsg == null) { ?>
-
 <form action="" method="post" enctype="application/x-www-form-urlencoded" id="markupForm" target="_self">
 <table class="RegText" border="0" cellspacing="0" width="100%">
     <tr><td class="Title"><?=$manageLocal?><hr></td></tr>
@@ -404,7 +403,8 @@
 </form>
 
 <?php } else { ?>
-
+</head>
+<body>
 <table class="RegText" border="0" cellspacing="0" width="100%%">
     <tr><td class="Title">Error<hr></td></tr>
     <tr><td><?= $errorMsg ?></td></tr>



More information about the fusion-commits mailing list