[mapguide-commits] r9946 - in sandbox/jng/vanilla_swig: Bindings/src/SwigCommon/Php Doc/samples/phpsamples/common Doc/samples/phpsamples/custom_output Doc/samples/phpsamples/interacting_with_layers Doc/samples/phpviewersample Doc/samples/phpviewersample/plot
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Jun 6 05:09:55 PDT 2022
Author: jng
Date: 2022-06-06 05:09:54 -0700 (Mon, 06 Jun 2022)
New Revision: 9946
Modified:
sandbox/jng/vanilla_swig/Bindings/src/SwigCommon/Php/monkey_patch.i
sandbox/jng/vanilla_swig/Doc/samples/phpsamples/common/common.php
sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/createmapimage.php
sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/eplot.php
sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/multiplot.php
sandbox/jng/vanilla_swig/Doc/samples/phpsamples/interacting_with_layers/toggle_roads_label.php
sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/JSON.php
sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/plot/plot.php
sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/utilityfunctions.php
Log:
Fix PHP sample code
Modified: sandbox/jng/vanilla_swig/Bindings/src/SwigCommon/Php/monkey_patch.i
===================================================================
--- sandbox/jng/vanilla_swig/Bindings/src/SwigCommon/Php/monkey_patch.i 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Bindings/src/SwigCommon/Php/monkey_patch.i 2022-06-06 12:09:54 UTC (rev 9946)
@@ -32,7 +32,7 @@
%rename(CreateStateless) MgMap::Create(MgResourceIdentifier*, STRINGPARAM, INT32, INT32, double, double, double, INT32);
%ignore MgResource;
-%ignore MgMapBase::Open(MgResourceService*, CREFSTRING);
+%ignore MgMapBase::Open(MgResourceService*, STRINGPARAM);
/*
%ignore MgConfigurationLoadFailedException::GetExceptionMessage;
Modified: sandbox/jng/vanilla_swig/Doc/samples/phpsamples/common/common.php
===================================================================
--- sandbox/jng/vanilla_swig/Doc/samples/phpsamples/common/common.php 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Doc/samples/phpsamples/common/common.php 2022-06-06 12:09:54 UTC (rev 9946)
@@ -20,7 +20,5 @@
$viewerFilesDirectory = $webRootDirectory . '/viewerfiles';
$schemaDirectory = dirname(__FILE__);
$webconfigFilePath = $webRootDirectory . '/webconfig.ini';
-// Include constants like MgServiceType::ResourceService
-require_once($webRootDirectory . '/mapadmin/constants.php');
?>
\ No newline at end of file
Modified: sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/createmapimage.php
===================================================================
--- sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/createmapimage.php 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/createmapimage.php 2022-06-06 12:09:54 UTC (rev 9946)
@@ -23,11 +23,11 @@
$sessionId = $args['SESSION'];
$xmlSelection = $args['SELECTION'];
$mapName = $args['MAPNAME'];
-$mapScale = $args['SCALE'];
-$imageHeight = $args['HEIGHT'];
-$imageWidth = $args['WIDTH'];
-$mapCenterX = $args['CENTERX'];
-$mapCenterY = $args['CENTERY'];
+$mapScale = doubleval($args['SCALE']);
+$imageHeight = intval($args['HEIGHT']);
+$imageWidth = intval($args['WIDTH']);
+$mapCenterX = doubleval($args['CENTERX']);
+$mapCenterY = doubleval($args['CENTERY']);
try
{
Modified: sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/eplot.php
===================================================================
--- sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/eplot.php 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/eplot.php 2022-06-06 12:09:54 UTC (rev 9946)
@@ -41,8 +41,7 @@
$dwfVersion = new MgDwfVersion("6.01", "1.2");
- $plotSpec = new MgPlotSpecification(8.5, 11, MgPageUnitsType::Inches);
- $plotSpec->SetMargins(0.5, 0.5, 0.5, 0.5);
+ $plotSpec = new MgPlotSpecification(8.5, 11, MgPageUnitsType::Inches, 0.5, 0.5, 0.5, 0.5);
$layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout");
$layout = new MgLayout($layoutRes, "City of Sheboygan", MgPageUnitsType::Inches);
Modified: sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/multiplot.php
===================================================================
--- sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/multiplot.php 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Doc/samples/phpsamples/custom_output/multiplot.php 2022-06-06 12:09:54 UTC (rev 9946)
@@ -41,8 +41,7 @@
$dwfVersion = new MgDwfVersion("6.01", "1.2");
- $plotSpec = new MgPlotSpecification(8.5, 11, MgPageUnitsType::Inches);
- $plotSpec->SetMargins(0.5, 0.5, 0.5, 0.5);
+ $plotSpec = new MgPlotSpecification(8.5, 11, MgPageUnitsType::Inches, 0.5, 0.5, 0.5, 0.5);
$layout = null;
$layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout");
Modified: sandbox/jng/vanilla_swig/Doc/samples/phpsamples/interacting_with_layers/toggle_roads_label.php
===================================================================
--- sandbox/jng/vanilla_swig/Doc/samples/phpsamples/interacting_with_layers/toggle_roads_label.php 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Doc/samples/phpsamples/interacting_with_layers/toggle_roads_label.php 2022-06-06 12:09:54 UTC (rev 9946)
@@ -79,18 +79,15 @@
'&MAPNAME=' . $mgMapName . '">Run again</a></p>';
}
- catch (MgLayerNotFoundException $e)
- {
- echo '<p>Layer not found</p>';
- }
- catch (MgObjectNotFoundException $e)
- {
- echo '<p>Layer not found</p>';
- }
catch (MgException $e)
{
- echo $e->GetExceptionMessage();
- echo $e->GetDetails();
+ if ($e->GetExceptionCode() == MgExceptionCodes::MgLayerNotFoundException ||
+ $e->GetExceptionCode() == MgExceptionCodes::MgObjectNotFoundException) {
+ echo '<p>Layer not found</p>';
+ } else {
+ echo $e->GetExceptionMessage();
+ echo $e->GetDetails();
+ }
}
?>
Modified: sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/JSON.php
===================================================================
--- sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/JSON.php 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/JSON.php 2022-06-06 12:09:54 UTC (rev 9946)
@@ -114,6 +114,8 @@
*/
class Services_JSON
{
+ private int $use;
+
/**
* constructs a new JSON instance
*
@@ -130,7 +132,7 @@
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
- function Services_JSON($use = 0)
+ function __construct($use = 0)
{
$this->use = $use;
}
@@ -153,7 +155,7 @@
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
- $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
+ $bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
switch(true) {
case ((0x7F & $bytes) == $bytes):
@@ -206,17 +208,17 @@
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x07 & (ord($utf8{0}) >> 2))
- . chr((0xC0 & (ord($utf8{0}) << 6))
- | (0x3F & ord($utf8{1})));
+ return chr(0x07 & (ord($utf8[0]) >> 2))
+ . chr((0xC0 & (ord($utf8[0]) << 6))
+ | (0x3F & ord($utf8[1])));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr((0xF0 & (ord($utf8{0}) << 4))
- | (0x0F & (ord($utf8{1}) >> 2)))
- . chr((0xC0 & (ord($utf8{1}) << 6))
- | (0x7F & ord($utf8{2})));
+ return chr((0xF0 & (ord($utf8[0]) << 4))
+ | (0x0F & (ord($utf8[1]) >> 2)))
+ . chr((0xC0 & (ord($utf8[1]) << 6))
+ | (0x7F & ord($utf8[2])));
}
// ignoring UTF-32 for now, sorry
@@ -261,7 +263,7 @@
*/
for ($c = 0; $c < $strlen_var; ++$c) {
- $ord_var_c = ord($var{$c});
+ $ord_var_c = ord($var[$c]);
switch (true) {
case $ord_var_c == 0x08:
@@ -284,18 +286,18 @@
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
- $ascii .= '\\'.$var{$c};
+ $ascii .= '\\'.$var[$c];
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
- $ascii .= $var{$c};
+ $ascii .= $var[$c];
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
+ $char = pack('C*', $ord_var_c, ord($var[$c + 1]));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -305,8 +307,8 @@
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}));
+ ord($var[$c + 1]),
+ ord($var[$c + 2]));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -316,9 +318,9 @@
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}));
+ ord($var[$c + 1]),
+ ord($var[$c + 2]),
+ ord($var[$c + 3]));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -328,10 +330,10 @@
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}));
+ ord($var[$c + 1]),
+ ord($var[$c + 2]),
+ ord($var[$c + 3]),
+ ord($var[$c + 4]));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -341,11 +343,11 @@
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}),
- ord($var{$c + 5}));
+ ord($var[$c + 1]),
+ ord($var[$c + 2]),
+ ord($var[$c + 3]),
+ ord($var[$c + 4]),
+ ord($var[$c + 5]));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
@@ -520,7 +522,7 @@
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
- $ord_chrs_c = ord($chrs{$c});
+ $ord_chrs_c = ord($chrs[$c]);
switch (true) {
case $substr_chrs_c_2 == '\b':
@@ -550,7 +552,7 @@
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
- $utf8 .= $chrs{++$c};
+ $utf8 .= $chrs[++$c];
}
break;
@@ -563,7 +565,7 @@
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
- $utf8 .= $chrs{$c};
+ $utf8 .= $chrs[$c];
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
@@ -610,7 +612,7 @@
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
- if ($str{0} == '[') {
+ if ($str[0] == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
@@ -649,7 +651,7 @@
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
- if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
+ if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
@@ -691,12 +693,12 @@
}
- } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
+ } elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
- array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
+ array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]));
//print("Found start of string at {$c}\n");
- } elseif (($chrs{$c} == $top['delim']) &&
+ } elseif (($chrs[$c] == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
@@ -705,24 +707,24 @@
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
- } elseif (($chrs{$c} == '[') &&
+ } elseif (($chrs[$c] == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
- } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
+ } elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
- } elseif (($chrs{$c} == '{') &&
+ } elseif (($chrs[$c] == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
- } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
+ } elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
Modified: sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/plot/plot.php
===================================================================
--- sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/plot/plot.php 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/plot/plot.php 2022-06-06 12:09:54 UTC (rev 9946)
@@ -42,8 +42,7 @@
// current view of the map.
$dwfVersion = new MgDwfVersion("6.01", "1.2");
- $plotSpec = new MgPlotSpecification(8.5, 11, MgPageUnitsType::Inches);
- $plotSpec->SetMargins(0.5, 0.5, 0.5, 0.5);
+ $plotSpec = new MgPlotSpecification(8.5, 11, MgPageUnitsType::Inches, 0.5, 0.5, 0.5, 0.5);
$mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
Modified: sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/utilityfunctions.php
===================================================================
--- sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/utilityfunctions.php 2022-06-06 11:36:25 UTC (rev 9945)
+++ sandbox/jng/vanilla_swig/Doc/samples/phpviewersample/utilityfunctions.php 2022-06-06 12:09:54 UTC (rev 9946)
@@ -30,9 +30,6 @@
$web_Dir = substr($thisFile, 0, $pos+1);
$configFilePath = $web_Dir . "../webconfig.ini";
- include $web_Dir . "../mapviewerphp/constants.php";
-
-
// Searches the map for a layer with the specified name.
function GetXmlPath()
More information about the mapguide-commits
mailing list