[fusion-commits] r1409 - in trunk: MapServer/php common/php
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu May 15 16:21:20 EDT 2008
Author: madair
Date: 2008-05-15 16:21:20 -0400 (Thu, 15 May 2008)
New Revision: 1409
Modified:
trunk/MapServer/php/LegendIcon.php
trunk/common/php/Utilities.php
Log:
closes #66: remove config loading code from LegendIcon.php
Modified: trunk/MapServer/php/LegendIcon.php
===================================================================
--- trunk/MapServer/php/LegendIcon.php 2008-05-15 20:16:20 UTC (rev 1408)
+++ trunk/MapServer/php/LegendIcon.php 2008-05-15 20:21:20 UTC (rev 1409)
@@ -37,55 +37,37 @@
$legendIconCacheFile = "";
if (isset($_SESSION['maps']) && isset($_SESSION['maps'][$mapName])) {
- /* json decode only in PHP 5.2 and later */
- if (function_exists('json_decode')) {
- $configFile = realpath(dirname(__FILE__)."/../../config.json");
- if (file_exists($configFile)) {
- $configStr = file_get_contents($configFile);
- /* replace single quotes with double quotes */
- $configStr = str_replace("'", '"', $configStr);
- /* get rid of new lines, it just complicates things */
- $configStr = str_replace("\n", '', $configStr);
- /* get rid of embedded comments */
- $configStr = preg_replace("/\/\*.*\*\//U", "", $configStr);
- /* the regex after this one can't handle http: as a value, so mangle it. */
- $configStr = preg_replace("/http:/U", "http_", $configStr);
- /* quote unquoted attribute names */
- $configStr = preg_replace("/[^\"]{1}(\w*):/U", "\"$1\":", $configStr);
- /* decode the whole thing */
- $configObj = json_decode($configStr, false);
- /* if the legendIconCache dir is set */
- if (isset($configObj->mapserver->legendIconCacheDir)) {
- $legendIconCacheDir = $configObj->mapserver->legendIconCacheDir;
+ $configObj = $_SESSION['fusionConfig'];
+ /* if the legendIconCache dir is set */
+ if (isset($configObj->mapserver->legendIconCacheDir)) {
+ $legendIconCacheDir = $configObj->mapserver->legendIconCacheDir;
- // check for closing '/'
- $legendIconCacheDir = str_replace( '\\', '/', trim( $legendIconCacheDir ) );
- if ( substr( $legendIconCacheDir, -1 ) != '/' )
- {
- $legendIconCacheDir .= '/';
- }
+ // check for closing '/'
+ $legendIconCacheDir = str_replace( '\\', '/', trim( $legendIconCacheDir ) );
+ if ( substr( $legendIconCacheDir, -1 ) != '/' )
+ {
+ $legendIconCacheDir .= '/';
+ }
- $cacheLegendIcons = true;
- $str = file_get_contents($_SESSION['maps'][$mapName]);
- /* create a unique location for the map icons based on
- * the content of the of map file. If the content changes
- * then the icons should be rebuilt anyway
- */
- $legendIconCacheDir = $legendIconCacheDir.md5($str)."/";
- if (!is_dir($legendIconCacheDir)) {
- mkdir($legendIconCacheDir);
- }
- /* TODO: can we figure out what the content type is? */
- $legendIconCacheFile = $legendIconCacheDir."_".$REQUEST_VARS['layername']."_".$REQUEST_VARS['classindex'].".png";
- /* if the icon exists, return it */
- if (file_exists($legendIconCacheFile)) {
- /* TODO: can we figure out what the content type is? */
- header('Content-type: image/png');
- readfile($legendIconCacheFile);
- exit;
- }
- }
+ $cacheLegendIcons = true;
+ $str = file_get_contents($_SESSION['maps'][$mapName]);
+ /* create a unique location for the map icons based on
+ * the content of the of map file. If the content changes
+ * then the icons should be rebuilt anyway
+ */
+ $legendIconCacheDir = $legendIconCacheDir.md5($str)."/";
+ if (!is_dir($legendIconCacheDir)) {
+ mkdir($legendIconCacheDir);
}
+ /* TODO: can we figure out what the content type is? */
+ $legendIconCacheFile = $legendIconCacheDir."_".$REQUEST_VARS['layername']."_".$REQUEST_VARS['classindex'].".png";
+ /* if the icon exists, return it */
+ if (file_exists($legendIconCacheFile)) {
+ /* TODO: can we figure out what the content type is? */
+ header('Content-type: image/png');
+ readfile($legendIconCacheFile);
+ exit;
+ }
}
$oMap = ms_newMapObj($_SESSION['maps'][$mapName]);
Modified: trunk/common/php/Utilities.php
===================================================================
--- trunk/common/php/Utilities.php 2008-05-15 20:16:20 UTC (rev 1408)
+++ trunk/common/php/Utilities.php 2008-05-15 20:21:20 UTC (rev 1409)
@@ -261,6 +261,7 @@
}
function loadFusionConfig() {
+ /* json decode only in PHP 5.2 and later */
if (function_exists('json_decode')) {
$configFile = realpath(dirname(__FILE__)."/../../config.json");
if (file_exists($configFile)) {
More information about the fusion-commits
mailing list