Copyright (c) 2002, DM Solutions Group Inc. * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ include_once( COMMON."logger/logger.php" ); //global array for the current map file, used in parsing the map file $aszMapFile = array(); //global size of the map file, so we don't have to use count() all the time $nLines = 0; /** * Class TokenizeMapFile * * This class helps the parsing process. Instead of passing * globals variables, we pass a instance of that class to * all functions that parse (parseMapFileString, parseValue). * */ class TokenizedMapFile { var $m_aszMapFile; var $m_nIndex; var $m_nLines; /* * TokenizedMapFile * * @param $aszMapFile Preprocessed array of token provided by ms_TokenizeMapFile */ function TokenizedMapFile($aszMapFile) { $this->m_aszMapFile = $aszMapFile; $this->m_nIndex = 0; $this->m_nLines = count($this->m_aszMapFile); } /** * getNextToken() * * @return Next token from mapfile. Pointer is incremented. */ function &getNextToken() { // Check if we pass end of array // if (!isset($this->m_aszMapFile[$this->m_nIndex])) // return false; $szToken =& $this->m_aszMapFile[$this->m_nIndex]; // Increment pointer $this->m_nIndex = $this->m_nIndex + 1; // If token start by a quote or double quotes // return the token without them. if ($szToken[0] == "\"" || $szToken[0] == "'") { return substr($szToken, 1, -1); } else { return $szToken; } } } /** * The purpose of this class is to provide a factory for sub-classes of * BaseObj. It contains an array of the valid object types. To add new * types, simply add them to the array initialization in the object * factory and create the new class (as a sub-class of BaseObj please) */ class ObjFactory extends Logger { /** * array of supported object types */ var $aObjTypes; /** * Constructor - initialize the valid object types */ function ObjFactory() { $this->Logger( "ObjFactory" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ObjFactory" ); #STRIPED_LOG# */ //implementation $this->aObjTypes = array( "DOC", "WEB", "REFERENCE", "QUERYMAP", "PROJECTION", "LEGEND", "SCALEBAR", "LAYER", "CLASS", "FEATURE", "LABEL", "BITMAPLABEL", "METADATA", "MAP", "JOIN", "SYMBOL", "POINTS", "SYMBOLSTYLE", "STYLE", "OUTPUTFORMAT", "GRID"); //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ObjFactory" ); #STRIPED_LOG# */ } /** * create an object from a name value * * @param szName the name of the object to create * * @return mixed an instance of a subclass of BaseObj or false * if the name isn't supported */ function createObj( $szName ) { $mResult = false; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering createObj($szName)" ); #STRIPED_LOG# */ //implementation if ( in_array( strtoupper($szName), $this->aObjTypes)) { $szEval = "\$mResult = new ".ucfirst(strtolower($szName))."Obj();"; /* #STRIPED_LOG# //$this->log( LOG_ALL, "evaluating $szEval" ); #STRIPED_LOG# */ @eval( $szEval ); } else { $this->error( 0, "unrecognized object $szName, object not created"); } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done createObj($szName)" ); #STRIPED_LOG# */ return $mResult; } } /** * The purpose of this class is to provide a factory for sub-classes of * BaseType. It contains an array of the valid element types. To add new * types, simply add them to the array initialization in the type * factory and create the new class (as a sub-class of BaseType please) */ class TypeFactory extends Logger { /** * array of supported types */ var $aTypes; /** * Constructor - initialize the valid types */ function TypeFactory() { $this->Logger( "TypeFactory" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering TypeFactory" ); #STRIPED_LOG# */ //implementation $this->aTypes = array( "STRING", "STRINGBLOCK", "COLOR", "DOUBLE", "INTEGER", "ENUMERATION", "COMPLEXTYPE", "DIRECTORYNAME", "FILENAME", "EXPRESSION", "COMBOENUMERATIONINTEGER", "FONTSIZE", "COMBOENUMERATIONDOUBLE", "SYMBOL", "FONT", "SHAPEATTR", "SEPARATOR", "METADATAITEM", "SYMBOLPOINTS", "SYMBOLSTYLE", "FORMATOPTIONITEM"); //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done TypeFactory" ); #STRIPED_LOG# */ } /** * create a type object from a name value * * @param szName the name of the type to create * * @return mixed an instance of a subclass of BaseType or false * if the name isn't supported */ function createType( $szName ) { $mResult = false; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering createType($szName)" ); #STRIPED_LOG# */ //implementation if ( in_array( strtoupper($szName), $this->aTypes)) { $szEval = "\$mResult = new ".ucfirst(strtolower($szName))."Type();"; /* #STRIPED_LOG# //$this->log( LOG_ALL, "evaluating $szEval" ); #STRIPED_LOG# */ @eval( $szEval ); } else { $this->error( 0, "unrecognized type $szName, type not created"); } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done =createType($szName)" ); #STRIPED_LOG# */ return $mResult; } } /** * BaseObj is the base class for all the XxxObj classes and provides the * common attributes and methods to be used. It is not intended to be * directly instantiated as each sub-class should implement specific * parsing, serializing and rendering functions * */ class BaseObj extends Logger { /** * elements of this object that have actually been set */ var $maoTypes; /** * sub-objects that exist in this object */ var $maoObjs; /* * array of valid sub-object names */ var $maszValidObjs; /** * name of the object (set by sub-classes) */ var $mszName; /** * title of the the object */ var $mszTitle; /** * index value of this object */ var $mszIndex; /** * original index of this object when the map file was opened or * saved. This value can be used for the restore operation */ var $mnOriginalIndex; /** * */ var $mszMultiplicity; /** * Comment to display before the object */ var $mszComments; var $mszEndingComments; /** * Constructor - initialize instance vars * * */ function BaseObj( ) { $bResult = true; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering BaseObj" ); #STRIPED_LOG# */ //implementation $this->maoTypes = array(); $this->maoObjs = array(); $this->maszValidObjs = array(); $this->mszIndex = ""; $this->mnOriginalIndex = -1; $this->mszMultiplicity = 1; $this->mszComments = ""; $this->mszEndingComments = ""; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done BaseObj" ); #STRIPED_LOG# */ return $bResult; } /** * parse this object out of the contents of a array of strings (MapFile * format) up to the next END and return the remaining elements of the * string * * @param $oTokMapFile Object needed to navigate in mapfile * * @return the remaining elements in the array or false if something went * wrong, in which case look in the global error manager. */ function parseMapFileString( &$oTokMapFile ) { global $gApp; /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "parseMapFileString()" ); #STRIPED_LOG# */ $szComments = ""; // Get next token. $szToken =& $oTokMapFile->getNextToken(); // If reache en of object or getnext token return an error. while( strcasecmp($szToken, "end") != 0 && $szToken !== false) { if ($szToken === FALSE) { //something went terribly wrong $this->error(0, "error parsing map file"); return false; } /* #STRIPED_LOG# //$this->log( LOG_ALL, "processing token ($szToken)"); #STRIPED_LOG# */ if ($szToken[0] == "#") { /* #STRIPED_LOG# //$this->log(LOG_ALL, "found a comment"); #STRIPED_LOG# */ $szComments .= "$szToken\n"; } elseif(strcasecmp($szToken, $this->mszName) == 0) { //skip the line /* #STRIPED_LOG# //$this->log(LOG_ALL, "key matches name, skipping key $szToken"); #STRIPED_LOG# */ $this->mszComments = $szComments; $szComments = ""; } elseif(in_array(strtoupper($szToken), $this->maszValidObjs)) { /* #STRIPED_LOG# //$this->log(LOG_ALL, // "create Object $szToken"); #STRIPED_LOG# */ $oObj = $gApp->createObj($szToken); $oObj->mszIndex = $this->mszIndex. sprintf( "%03d", count($this->maoObjs) ); $oObj->mszComments = $szComments; $szComments = ""; $bResult = $oObj->parseMapFileString( $oTokMapFile ); if($bResult === false) { //something went terribly wrong $this->error(0, "error parsing map file"); return false; } $this->addObj($oObj); } elseif(isset($this->maoTypes[strtoupper($szToken)])) { //okay, its valid /* #STRIPED_LOG# //$this->log(LOG_ALL, "create type $szToken"); #STRIPED_LOG# */ $nResult = $this->maoTypes[strtoupper($szToken)]->parseValue( $oTokMapFile ); if($nResult === false) { //something went terribly wrong $this->error(0, "error parsing map file"); return false; } $this->maoTypes[strtoupper($szToken)]->mszComments = $szComments; $szComments = ""; } else { $this->error( 0, "invalid map file entry $szToken in ". $this->mszName); } $szToken =& $oTokMapFile->getNextToken(); } if (strcmp(strtolower($szToken), "end") == 0) $this->mszEndingComments = $szComments; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done parseMapFileString" ); #STRIPED_LOG# */ //test for failure if(strcmp(strtolower($szToken), "end") != 0) { $this->error(0, "premature end of map file processing ".$this->mszName.", final token was $szToken"); return false; } else { return $szToken; } } /** * addObj adds/updates the attribute and value pair */ function addObj( &$oObj ) { $bResult = false; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering addObj(".$oObj->mszName.")" ); #STRIPED_LOG# */ //implementation if (in_array($oObj->mszName, $this->maszValidObjs)) { /* #STRIPED_LOG# //$this->log(LOG_ALL, "adding object"); #STRIPED_LOG# */ //find the position of the object we are inserting $nInsertPos = array_search($oObj->mszName, $this->maszValidObjs); /* #STRIPED_LOG# //$this->log(LOG_ALL, "position of obj is $nInsertPos"); #STRIPED_LOG# */ $bAtEnd = false; $bValidInsert = true; $nInsertIdx = count($this->maoObjs); $nLast = count($this->maoObjs) - 1; for( $i=0; $i<$nInsertIdx && $bValidInsert; $i++) { //find the position of the current object $oSubObj =& $this->maoObjs[$i]; $nCurPos = array_search($oSubObj->mszName, $this->maszValidObjs); /* #STRIPED_LOG# //$this->log(LOG_ALL, "position of subobj is $nCurPos"); #STRIPED_LOG# */ if($nCurPos > $nInsertPos) { if ($bAtEnd) { $nInsertIdx = $i + 1; } else { $nInsertIdx = $i; } break; } elseif($nCurPos == $nInsertPos) { $bAtEnd = true; //can check to see if multiples allowed here if ($oObj->mszMultiplicity != "*") { $this->error( 0, "multiple instances of ". $oObj->mszName." not allowed" ); $bValidInsert = false; } } } if ($bValidInsert) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "insert is valid at position $nInsertIdx of $nLast" ); #STRIPED_LOG# */ ///// $nLast = count($this->maoObjs) - 1; if ($nInsertIdx == 0) { //pushing at beginning /* #STRIPED_LOG# //$this->log(LOG_ALL, "insert at beginning"); #STRIPED_LOG# */ array_unshift($this->maoObjs, $oObj); } elseif ( $nInsertIdx <= $nLast ) { //insert in the middle /* #STRIPED_LOG# //$this->log(LOG_ALL, "pushing in middle of array" ); #STRIPED_LOG# */ $aoObj = array_slice($this->maoObjs, 0, $nInsertIdx ); array_push( $aoObj, $oObj ); $this->maoObjs = array_merge( $aoObj, array_slice( $this->maoObjs, $nInsertIdx ) ); } else { //pushing on end /* #STRIPED_LOG# //$this->log(LOG_ALL, "pushing on end of array"); #STRIPED_LOG# */ array_push( $this->maoObjs, $oObj ); } $this->reIndexObjs(); $bResult = sprintf( "%s%03d", $this->mszIndex,$nInsertIdx ); } else { $bResult = false; } } else { /* #STRIPED_LOG# //$this->log(LOG_ALL, "not adding object"); #STRIPED_LOG# */ /* #STRIPED_LOG# //$this->log(LOG_ALL, $this->maszValidObjs); #STRIPED_LOG# */ } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_QUIET, "done addObj(".$oObj->mszName."), returning $bResult" ); #STRIPED_LOG# */ return $bResult; } /** * Remove Obj */ function removeObjByIndex( $szIndex ) { /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering removeObjByIndex( $szIndex )"); #STRIPED_LOG# */ //break the index down into 3 char blocks $nIndex = intval(substr( $szIndex, 0, 3)); $szNextIndex = substr( $szIndex, 3 ); /* #STRIPED_LOG# //$this->log( LOG_QUIET, "index is $nIndex, next is $szNextIndex"); #STRIPED_LOG# */ if ($szNextIndex == "") { array_splice($this->maoObjs, $nIndex, 1); $this->reIndexObjs(); $nRet = $nIndex-1; } else { $nRet = $this->maoObjs[$nIndex]->removeObjByIndex($szNextIndex); } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done removeObjByIndex()"); #STRIPED_LOG# */ return $nRet; } /** * Promote object */ function promoteObjByIndex( $szIndex ) { /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering promoteObjByIndex( $szIndex )"); #STRIPED_LOG# */ $nRet = false; //break the index down into 3 char blocks $nIndex = intval(substr( $szIndex, -3)); $oParent = &$this->getObjByIndex(substr($szIndex, 0, -3)); if ($nIndex != 0) { $oPrev = $oParent->maoObjs[$nIndex-1]; // must be same type. if ($oPrev->mszName == $oParent->maoObjs[$nIndex]->mszName) { $oParent->maoObjs[$nIndex-1] = $oParent->maoObjs[$nIndex]; $oParent->maoObjs[$nIndex] = $oPrev; $this->reIndexObjs(); $nRet = $nIndex-1; } } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done promoteObjByIndex()"); #STRIPED_LOG# */ return $nRet; } /** * Demote object */ function demoteObjByIndex( $szIndex ) { /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering demoteObjByIndex( $szIndex )"); #STRIPED_LOG# */ $nRet = false; //break the index down into 3 char blocks $nIndex = intval(substr( $szIndex, -3)); $oParent = &$this->getObjByIndex(substr($szIndex, 0, -3)); if ($nIndex != count($oParent->maoObjs)) { $oNext = $oParent->maoObjs[$nIndex+1]; // must be same type. if ($oNext->mszName == $oParent->maoObjs[$nIndex]->mszName) { $oParent->maoObjs[$nIndex+1] = $oParent->maoObjs[$nIndex]; $oParent->maoObjs[$nIndex] = $oNext; $this->reIndexObjs(); $nRet = $nIndex+1; } } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done demoteObjByIndex()"); #STRIPED_LOG# */ return $nRet; } /** * reindex contained objects and sub-objects */ function reIndexObjs( ) { $nObjs = count($this->maoObjs); for($i=0;$i<$nObjs;$i++) { $this->maoObjs[$i]->mszIndex = $this->mszIndex. sprintf( "%03d", $i); $this->maoObjs[$i]->reIndexObjs(); } } /** * set the original index value to the current index value for this * object and all sub-objects. */ function saveIndexes() { $this->mnOriginalIndex = $this->mszIndex; $nObj = count($this->maoObjs); for ( $i=0; $i<$nObj;$i++) { $this->maoObjs[$i]->saveIndexes(); } } function getIndex() { return $this->mszIndex; } function &getObjByIndex( $szIndex ) { $oObj = false; /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering getObjByIndex( $szIndex )"); #STRIPED_LOG# */ if(trim($szIndex) == "") { /* #STRIPED_LOG# //$this->log( LOG_QUIET, "returning $this->mszName"); #STRIPED_LOG# */ $oObj = &$this; } else { //break the index down into 3 char blocks $nIndex = intval(substr( $szIndex, 0, 3)); $szNextIndex = substr( $szIndex, 3 ); /* #STRIPED_LOG# //$this->log( LOG_QUIET, "index is $nIndex, next is $szNextIndex"); #STRIPED_LOG# */ return $this->maoObjs[$nIndex]->getObjByIndex($szNextIndex); } /* #STRIPED_LOG# //$this->log(LOG_ALL, "returning an object called ".$oObj->mszName); #STRIPED_LOG# */ /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done getObjByIndex()"); #STRIPED_LOG# */ return $oObj; } /** * Reset all attribute to empty */ function clearObject() { foreach($this->maoTypes as $szKey => $oVal) { /* #STRIPED_LOG# //$this->log(LOG_ALL, "Clearing $szKey that is set to $oVal"); #STRIPED_LOG# */ $this->maoTypes[$szKey]->setValue(""); } } /** * Set all current object attribute with * oObj values. */ function restoreObject($oObj) { // reset this object and copy all type from oObj foreach($this->maoTypes as $szKey => $oVal) $this->maoTypes[$szKey] = new BaseType(); foreach($oObj->maoTypes as $oType) { $this->addType($oType); } $this->reIndexObjs(); } /** * addType adds/updates the attribute and value pair */ function addType( $oType ) { $bResult = false; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering addType(".$oType->mszName.")" ); #STRIPED_LOG# */ $this->maoTypes[strtoupper($oType->mszName)] = $oType; $bResult = true; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done addType(".$oType->mszName.")" ); #STRIPED_LOG# */ return $bResult; } /** * getType return the type obj for szName */ function getType( $szName ) { $bResult = false; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering getType(".$szName.")" ); #STRIPED_LOG# */ if (isset($this->maoTypes[strtoupper($szName)])) $bResult = $this->maoTypes[strtoupper($szName)]; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done getType()" ); #STRIPED_LOG# */ return $bResult; } /** * return a string representing this object as an HTML page, every element * will be rendered as HTML which will include FORM inputs */ function renderAsHTML() { $szURI = "http://".$_SERVER['HTTP_HOST']. $_SERVER['PHP_SELF']; $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ //implementation //$this->error( 0, "BaseObj doesn't support rendering to HTML :("); $szResult = "
\n"; $szResult .= "\n"; $szResult .= ""; foreach( $this->maoTypes as $oType) { $szResult .= $oType->renderAsHTML(); } // $szResult .= ""; $szResult .= "
". "". "
\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "
\n"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ return $szResult; } function renderAsMapFileString( $szIndent = "" ) { //this we can do $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation if ($this->mszComments != "") { $szResult .= str_replace("#", "$szIndent#", $this->mszComments); } $szResult .= $szIndent.$this->mszName."\n"; foreach( $this->maoTypes as $oElement ) $szResult .= $oElement->renderAsMapFileString( $szIndent." " ); foreach( $this->maoObjs as $oObj ) $szResult .= $oObj->renderAsMapFileString( $szIndent." " ); if ($this->mszEndingComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszEndingComments); $szResult .= $szIndent."END\n"; /* #STRIPED_LOG# //$this->log( LOG_ALL, "rendering result is:\n$szResult"); #STRIPED_LOG# */ //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } function renderAsTreemenuString( $szLevel = "" ) { $szResult = ""; /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering renderAsTreemenuString($szLevel)"); #STRIPED_LOG# */ $szResult = $szLevel."|images/tree_".strtolower($this->mszName).".gif|@".$this->getIndex()."\n"; foreach( $this->maoObjs as $oObj) { if (is_object( $oObj ) ) $szResult .= $oObj->renderAsTreemenuString( $szLevel."." ); } /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done renderAsTreemenuString($szLevel)"); #STRIPED_LOG# */ return $szResult; } /** * return an array of objects and sub-objects */ function renderAsTreemenuArray( ) { $aMe = array(); $aMe["type"] = strtoupper($this->mszName); $aMe["name"] = ""; if(isset($this->maoTypes['NAME'])) { $aMe["name"] = $this->maoTypes['NAME']->getValue(); } $aMe["icon"] = "images/tree_".strtolower($this->mszName).".gif"; $aMe["index"] = $this->getIndex(); $aMe["children"] = array(); foreach( $this->maoObjs as $oObj) { if (is_object( $oObj ) ) $aMe["children"][$oObj->getIndex()] = &$oObj->renderAsTreemenuArray( ); } return $aMe; } function processFormVars( $szIndex, $aszFormVars ) { $bResult = true; /* #STRIPED_LOG# $this->logFuncStart( LOG_ALL, "entering processFormVars($szIndex, $aszFormVars)" ); #STRIPED_LOG# */ //$this->logFuncStart( LOG_QUIET, "entering processFormVars($szIndex, $aszFormVars)" ); if (trim($szIndex != "") ) { //process on the next sub-object $nIndex = intval(substr( $szIndex, 0, 3)); $szNextIndex = substr( $szIndex, 3 ); /* #STRIPED_LOG# //$this->log( LOG_ALL, "index is $nIndex, next is $szNextIndex" ); #STRIPED_LOG# */ /* #STRIPED_LOG# ////$this->log( LOG_ALL, $this->maoObjs ); #STRIPED_LOG# */ //echo $this->maoObjs[$nIndex]->mszName; //echo count($aszFormVars); $bResult = $this->maoObjs[$nIndex]->processFormVars($szNextIndex, $aszFormVars); } else { //process on this obj. $keys = array_keys($this->maoTypes); foreach( $keys as $key ) { $bResult = $this->maoTypes[$key]->processFormVars($aszFormVars); if (!$bResult) $this->error( 0, "an error occurred setting the value for ". $this->maoTypes[$key]->mszName ); } } //$this->logFuncEnd( LOG_QUIET, "done processFormVars() : $bResult" ); /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } function addNewObject( $szIndex, $szName ) { global $gApp; $bResult = true; /* #STRIPED_LOG# $this->logFuncStart( LOG_ALL, "entering addNewObject( $szIndex, $szName)" ); #STRIPED_LOG# */ if (trim($szIndex != "") ) { //process on the next sub-object $nIndex = intval(substr( $szIndex, 0, 3)); $szNextIndex = substr( $szIndex, 3 ); $bResult = $this->maoObjs[$nIndex]->addNewObject($szNextIndex, $szName); } else { //process on this obj. if (in_array($szName, $this->maszValidObjs)) { $oObj = $gApp->createObj($szName); //add default metadata if available $oMetaData = $gApp->aValidators["METADATA"]; foreach( $oMetaData->maoTypes as $szKey => $oType ) { if ($oType->mxValue == $oObj->mszName) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "default metadata found ".$oType->mszName." ".$oType->mszTitle ); #STRIPED_LOG# */ if (!isset($oMeta)) { $oMeta = $gApp->createObj("METADATA"); } array_push($oMeta->maszMetaData, array( $oType->mszName, $oType->mszTitle )); } } $bResult = $this->addObj( $oObj ); /* #STRIPED_LOG# //$this->log( LOG_ALL, "added new object at index $nIdx"); #STRIPED_LOG# */ if (isset($oMeta)) { $this->maoObjs[$nIdx]->addObj( $oMeta ); } } else { $this->error(0, "$szName is an invalid object for ".$this->mszName ); /* #STRIPED_LOG# //$this->log( LOG_QUIET, array_values($this->maszValidObjs) ); #STRIPED_LOG# */ } } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } /** * dump the object contents */ function dump( ) { echo "
"; echo "ObjDump for ".$this->mszName."
"; echo "Types:
"; echo ""; echo "Sub Objects:
"; echo ""; echo "Allowed Objs:
"; echo ""; echo "
"; } } class DocObj extends BaseObj { // Dummy obj } /** * A WebObj class */ class WebObj extends BaseObj { /** * initialize the class */ function WebObj( ) { $this->BaseObj(); $this->Logger( "WebObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering WebObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "WEB"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done WebObj" ); #STRIPED_LOG# */ } } /** * A SymbolObj class */ class SymbolObj extends BaseObj { /** * initialize the class */ function SymbolObj( ) { $this->BaseObj(); $this->Logger( "SymbolObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering SymbolObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "SYMBOL"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done SymbolObj" ); #STRIPED_LOG# */ } /** * return a string representing this object as an HTML page, every element * will be rendered as HTML which will include FORM inputs */ function renderAsHTML() { //this probably isn't the place to do this. //automatically add sub-objects for POINTS and STYLE //if they don't exist if ( !isset($this->maoObjs["POINTS"]) ) { $this->addNewObject( "", "POINTS" ); } if ( !isset($this->maoObjs["SYMBOLSTYLE"]) ) { $this->addNewObject( "", "SYMBOLSTYLE" ); } $szURI = "http://".$_SERVER['HTTP_HOST']. $_SERVER['PHP_SELF']; $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ //implementation //$this->error( 0, "BaseObj doesn't support rendering to HTML :("); $szResult = "
\n"; $szResult .= "\n"; $szResult .= ""; foreach( $this->maoTypes as $oType) { $szResult .= $oType->renderAsHTML(); } foreach($this->maoObjs as $oObj) { foreach($oObj->maoTypes as $oType) $szResult .= $oType->renderAsHTML(); } $szResult .= "
". "". "
\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "
\n"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ return $szResult; } function renderAsTreemenuString( $szLevel = "" ) { $szResult = ""; /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering renderAsTreemenuString($szLevel)"); #STRIPED_LOG# */ $szResult = $szLevel."|images/tree_".strtolower($this->mszName).".gif|@".$this->getIndex()."\n"; /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done renderAsTreemenuString($szLevel)"); #STRIPED_LOG# */ return $szResult; } function processFormVars( $szIndex, $aszFormVars ) { $bResult = true; /* #STRIPED_LOG# $this->logFuncStart( LOG_ALL, "entering processFormVars($szIndex, $aszFormVars)" ); #STRIPED_LOG# */ if (trim($szIndex != "") ) { //process on the next sub-object $nIndex = intval(substr( $szIndex, 0, 3)); $szNextIndex = substr( $szIndex, 3 ); /* #STRIPED_LOG# //$this->log( LOG_ALL, "index is $nIndex, next is $szNextIndex" ); #STRIPED_LOG# */ /* #STRIPED_LOG# ////$this->log( LOG_ALL, $this->maoObjs ); #STRIPED_LOG# */ //echo $this->maoObjs[$nIndex]->mszName; //echo count($aszFormVars); $bResult = $this->maoObjs[$nIndex]->processFormVars($szNextIndex, $aszFormVars); } else { //process on this obj. $keys = array_keys($this->maoTypes); foreach( $keys as $key ) { $bResult = $this->maoTypes[$key]->processFormVars($aszFormVars); if (!$bResult) $this->error( 0, "an error occurred setting the value for ". $this->maoTypes[$key]->mszName ); } //process automatically on sub-objects also $aszObjKeys = array_keys($this->maoObjs); foreach( $aszObjKeys as $szObjKey ) { $aszTypeKeys = array_keys( $this->maoObjs[$szObjKey]->maoTypes ); foreach( $aszTypeKeys as $szTypeKey ) { $bResult = $this->maoObjs[$szObjKey]->maoTypes[$szTypeKey]->processFormVars($aszFormVars); if (!$bResult) $this->error(0, "an error occurred setting the value for ". $this->maoObjs[$szObjKey]->maoTypes[$szTypeKey]->mszName ); } } } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } } /** * A PointsObj class */ class PointsObj extends BaseObj { /** * initialize the class */ function PointsObj( ) { $this->BaseObj(); $this->Logger( "PointsObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering PointsObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "POINTS"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done PointsObj" ); #STRIPED_LOG# */ } /** * override baseobj implementation because Points are a special case * * @param $oTokMapFile Object needed to navigate in mapfile * @return false if something gone wrong **/ function parseMapFileString(&$oTokMapFile) { /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering parseMapFileString"); #STRIPED_LOG# */ $szToken =& $oTokMapFile->getNextToken(); while(strcasecmp($szToken, "END") != 0 && $szToken !== FALSE) { while (substr($szToken, 0, 1) == "#") $szToken =& $oTokMapFile->getNextToken(); $this->maoTypes['POINTS']->setValue($this->maoTypes['POINTS']->getValue()." ".$szToken ); //process the next token $szToken =& $oTokMapFile->getNextToken(); } /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done parseMapFileString"); #STRIPED_LOG# */ return $szToken; } /** * override default behaviour because if the contents of POINTS is not * defined then don't write the object tag */ function renderAsMapFileString( $szIndent = "" ) { //this we can do $szResult = ""; $szComments = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //make sure there's something to put in the POINTS tag, otherwise just return //an empty string foreach( $this->maoTypes as $oElement ) $szResult .= $oElement->renderAsMapFileString( $szIndent." " ); if ($szResult != "" ) { //implementation if ($this->mszComments != "") { $szComments .= str_replace("#", "$szIndent#", $this->mszComments); } $szResult = $szComments.$szIndent.$this->mszName."\n".$szResult; if ($this->mszEndingComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszEndingComments); $szResult .= $szIndent."END\n"; } /* #STRIPED_LOG# //$this->log( LOG_ALL, "rendering result is:\n$szResult"); #STRIPED_LOG# */ //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } /** * A StyleObj class */ class SymbolStyleObj extends BaseObj { /** * initialize the class */ function SymbolStyleObj( ) { $this->BaseObj(); $this->Logger( "SymbolStyleObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering SymbolStyleObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "SYMBOLSTYLE"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done SymbolStyleObj" ); #STRIPED_LOG# */ } /** * override baseobj implementation because SymbolStyles are a special case * * @param $oTokMapFile Object needed to navigate in mapfile * @return false if something gone wrong **/ function parseMapFileString(&$oTokMapFile) { /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering parseMapFileString"); #STRIPED_LOG# */ $szToken =& $oTokMapFile->getNextToken(); while(strcasecmp($szToken, "END") != 0 && $szToken !== FALSE) { $this->maoTypes['STYLE']->setValue($this->maoTypes['STYLE']->getValue()."\n".$szToken ); //process the next token $szToken =& $oTokMapFile->getNextToken(); } /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done parseMapFileString"); #STRIPED_LOG# */ return $szToken; } /** * override default behaviour because if the contents of STYLE is not * defined then don't write the object tag */ function renderAsMapFileString( $szIndent = "" ) { //this we can do $szResult = ""; $szComments = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //make sure there's something to put in the POINTS tag, otherwise just return //an empty string foreach( $this->maoTypes as $oElement ) $szResult .= $oElement->renderAsMapFileString( $szIndent." " ); if ($szResult != "" ) { //implementation if ($this->mszComments != "") { $szComments .= str_replace("#", "$szIndent#", $this->mszComments); } $szResult = $szComments.$szIndent.$this->mszName."\n".$szResult; if ($this->mszEndingComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszEndingComments); $szResult .= $szIndent."END\n"; } /* #STRIPED_LOG# //$this->log( LOG_ALL, "rendering result is:\n$szResult"); #STRIPED_LOG# */ //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } /** * A StyleObj class */ class StyleObj extends BaseObj { /** * initialize the class */ function StyleObj( ) { $this->BaseObj(); $this->Logger( "StyleObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering StyleObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "STYLE"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done StyleObj" ); #STRIPED_LOG# */ } } /** * A JoinObj class */ class JoinObj extends BaseObj { /** * initialize the class */ function JoinObj( ) { $this->BaseObj(); $this->Logger( "JoinObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering JoinObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "JOIN"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done JoinObj" ); #STRIPED_LOG# */ } } /** * A MapObj class */ class MapObj extends BaseObj { /** * initialize the class */ function MapObj( ) { $this->BaseObj(); $this->Logger( "MapObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering MapObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "MAP"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done MapObj" ); #STRIPED_LOG# */ } function getLayerIndex($szIndex) { /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "Entering getLayerIndex($szIndex)"); #STRIPED_LOG# */ $oLayer = false; $nCnt = 0; foreach($this->maoObjs as $oObj) { if ($oObj->mszName == "LAYER") { if ($oObj->mszIndex == substr($szIndex, 0, 3)) { break; } $nCnt ++; } } /* #STRIPED_LOG# $this->logFuncEnd(LOG_VERBOSE, "getLayerIndex() returning $nCnt."); #STRIPED_LOG# */ return $nCnt; } function getLayerByIndex($nLayerIndex) { /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "Entering getLayerByIndex($nLayerIndex)"); #STRIPED_LOG# */ $oLayer = false; $nCnt = 0; foreach($this->maoObjs as $oObj) { if ($oObj->mszName == "LAYER") { if ($nCnt == $nLayerIndex) { $oLayer = $oObj; break; } $nCnt ++; } } if ($oLayer == false) $this->error(0, "No layer at position $nLayerIndex."); /* #STRIPED_LOG# $this->logFuncEnd(LOG_VERBOSE, "getLayerByIndex() returning."); #STRIPED_LOG# */ return $oLayer; } /** * get the index of the first layer object */ function getFirstLayerIndex() { /* #STRIPED_LOG# //$this->log( LOG_ALL, "getFirstLayerIndex() called" ); #STRIPED_LOG# */ $szIndex = false; foreach($this->maoObjs as $oObj) { if ($oObj->mszName == "LAYER") { $szIndex = $oObj->getIndex(); break; } } /* #STRIPED_LOG# //$this->log( LOG_ALL, "returning index $szIndex" ); #STRIPED_LOG# */ return $szIndex; } } /** * A ReferenceObj class */ class ReferenceObj extends BaseObj { /** * initialize the class */ function ReferenceObj( ) { $this->BaseObj(); $this->Logger( "ReferenceObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ReferenceObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "REFERENCE"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ReferenceObj" ); #STRIPED_LOG# */ } } /** * A QueryMapObj class */ class QueryMapObj extends BaseObj { /** * initialize the class */ function QueryMapObj( ) { $this->BaseObj(); $this->Logger( "QueryMapObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering QueryMapObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "QUERYMAP"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done QueryMapObj" ); #STRIPED_LOG# */ } } /** * A ProjectionObj class */ class ProjectionObj extends BaseObj { /** * protection attributes */ var $maszProjectionAttr; /** * initialize the class */ function ProjectionObj( ) { $this->BaseObj(); $this->Logger( "ProjectionObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ProjectionObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "PROJECTION"; $this->maszProjectionAttr = array(); //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ProjectionObj" ); #STRIPED_LOG# */ } /** * Reset all attribute to empty */ function clearObject() { parent::clearObject(); $this->maszProjectionAttrs = array(); } /** * override parsing the mapfile string * * @param $oTokMapFile Object needed to navigate in mapfile * @return false if something gone wrong */ function parseMapFileString( &$oTokMapFile ) { /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "parseMapFileString()"); #STRIPED_LOG# */ $szToken =& $oTokMapFile->getNextToken(); while(strcasecmp($szToken, "END") != 0 && $szToken !== FALSE) { /* #STRIPED_LOG# //$this->log(LOG_ALL, "parsing token $szToken"); #STRIPED_LOG# */ /* #STRIPED_LOG# //$this->log( LOG_ALL, "inspecting line $szLine" ); #STRIPED_LOG# */ if ($szToken[0] == "\"" || $szToken[0] == "'") { $szToken = substr($szToken, 1, -1); } array_push($this->maszProjectionAttr, $szToken); $szToken =& $oTokMapFile->getNextToken(); } /* #STRIPED_LOG# $this->logFuncEnd( LOG_VERBOSE, "parseMapFileString()"); #STRIPED_LOG# */ return $szToken; } /** * render an HTML input page */ function renderAsHTML() { $szURI = "http://".$_SERVER['HTTP_HOST']. $_SERVER['PHP_SELF']; $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ //implementation //$this->error( 0, "BaseObj doesn't support rendering to HTML :("); /* $szResult = "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "
mszName). ".gif\" WIDTH='20' HEIGHT='20'>". "". $this->mszTitle. "
\n";*/ $szResult = "
\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= ""; // $szResult .= ""; $szResult .= "
". "". "
"; $szResult .= "Project Attributes"; $szResult .= ""; $szResult .= "
\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "
\n"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ return $szResult; } /** * render as a map file string */ function renderAsMapFileString( $szIndent="" ) { $szResult = ""; if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->mszName."\n"; $szComment = ""; foreach($this->maszProjectionAttr as $szProj) { $szProj = str_replace("\r", "", $szProj); $szProj = str_replace("\"", "", $szProj); if (substr($szProj, 0, 1) == "#") { $szResult .= $szIndent." $szProj\n"; } else { $szResult .= $szIndent." \"".$szProj."\" $szComment\n"; } $szComment = ""; } if ($this->mszEndingComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszEndingComments); $szResult .= $szIndent."END\n"; return $szResult; } function processFormVars( $szIndex, $aszFormVars ) { $bResult = true; /* #STRIPED_LOG# $this->logFuncStart( LOG_ALL, "entering processFormVars($szIndex, $aszFormVars)" ); #STRIPED_LOG# */ /* #STRIPED_LOG# //$this->log( LOG_ALL, $aszFormVars ); #STRIPED_LOG# */ //process on this obj.\ if (!isset($aszFormVars["PROJECTION"])) { $bResult = false; } else { $this->maszProjectionAttr = explode("\n", $aszFormVars["PROJECTION"]); } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done processFormVars()" ); #STRIPED_LOG# */ return $bResult; } } /** * A LegendObj class */ class LegendObj extends BaseObj { /** * initialize the class */ function LegendObj( ) { $this->BaseObj(); $this->Logger( "LegendObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering LegendObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "LEGEND"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done LegendObj" ); #STRIPED_LOG# */ } } /** * A ScalebarObj class */ class ScalebarObj extends BaseObj { /** * initialize the class */ function ScalebarObj( ) { $this->BaseObj(); $this->Logger( "ScalebarObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ScalebarObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "SCALEBAR"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ScalebarObj" ); #STRIPED_LOG# */ } } /** * A LayerObj class */ class LayerObj extends BaseObj { /** * initialize the class */ function LayerObj( ) { $this->BaseObj(); $this->Logger( "LayerObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering LayerObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "LAYER"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done LayerObj" ); #STRIPED_LOG# */ } } class OutputFormatObj extends BaseObj { /** * initialize the class */ function OutputFormatObj( ) { $this->BaseObj(); $this->Logger( "OutputFormatObj" ); //implementation $this->mszName = "OUTPUTFORMAT"; $this->maszFormatOption = array(); $this->maszRestricted = array(); $this->maszFormatOptionItemType = array("STRING", "INTEGER", "ENUMERATION"); } /** * Reset all attributes to empty */ function clearObject() { parent::clearObject(); $this->maszFormatOption = array(); $this->maszRestricted = array(); } /** * override baseobj implementation because OutputFormat is a special case * * @param $oTokMapFile Object needed to navigate in mapfile * @return false if something gone wrong **/ function parseMapFileString(&$oTokMapFile) { $szComments = ""; $szToken =& $oTokMapFile->getNextToken(); while($szToken[0] == "#") $szToken =& $oTokMapFile->getNextToken(); //add outputformat elements, with special handling of formatoption: //the formatoption elements are added to an array. while(strcasecmp($szToken, "END") != 0 && $szToken !== FALSE) { if ($szToken[0] == "#") { //found a comment $szComments .= "$szToken\n"; } elseif(strcasecmp($szToken, $this->mszName) == 0) { //skip the empty line $this->mszComments = $szComments; $szComments = ""; } elseif(strcasecmp($szToken, "FORMATOPTION") == 0) { $szValue =& $oTokMapFile->getNextToken(); if ($szValue === FALSE || strcasecmp($szValue, "END") == 0) { // Big error, no value found for formatoption $this->error(ERR_CRITICAL, "No value set for FormatOption ($szToken). Please check your mapfile."); return false; } array_push($this->maszFormatOption, array($szToken, $szValue)); } else //non-formatoption element. { if(isset($this->maoTypes[strtoupper($szToken)])) { //okay, its valid $nResult = $this->maoTypes[strtoupper($szToken)]->parseValue( $oTokMapFile ); if($nResult === false) { //something went terribly wrong $this->error(0, "error parsing map file"); return false; } $this->maoTypes[strtoupper($szToken)]->mszComments = $szComments; $szComments = ""; } else { $this->error( 0, "invalid map file entry $szToken in ". $this->mszName); } } $szToken =& $oTokMapFile->getNextToken(); } /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done parseMapFileString"); #STRIPED_LOG# */ return $szToken; } /** * renderAsMapFileString overrides basobj to handle formatoptions */ function renderAsMapFileString( $szIndent = "" ) { $szResult = ""; if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->mszName."\n"; //outputformat has no subobjects so we just render the internal types foreach( $this->maoTypes as $oElement ) $szResult .= $oElement->renderAsMapFileString( $szIndent." " ); foreach($this->maszFormatOption as $szKey => $aItem) { $szResult .= $szIndent." ".$aItem[0]." \"".$aItem[1]."\"\n"; } if ($this->mszEndingComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszEndingComments); $szResult .= $szIndent."END\n"; /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done renderAsMapFileString"); #STRIPED_LOG# */ return $szResult; } /** * addObj adds a new format option item */ function addNewObject( $szIndex, $szName ) { $bResult = false; //implementation //$bResult = array_push($this->maszFormatOption, array( $szName, "" ) ); array_push($this->maszFormatOption, array( $szName, "" ) ); return $bResult; } /** * Set all current object attribute with * oObj values. */ function restoreObject($oObj) { parent::restoreObject($oObj); // reset this object and copy all type from oObj $this->maszFormatOption = array(); foreach($oObj->maszFormatOption as $oFormatOption) { array_push($this->maszFormatOption, $oFormatOption); } } function processFormVars( $szIndex, $aszFormVars ) { $bResult = true; //process on this obj.\ //handle the rest of the fields parent::processFormVars( $szIndex, $aszFormVars); foreach( $this->maszFormatOption as $szKey => $aItem ) { if (isset($aszFormVars["FORMATOPTION".$szKey])) { $szNewValue = $aszFormVars["FORMATOPTION".$szKey]; if ( trim($szNewValue) == "" ) unset($this->maszFormatOption[$szKey]); else { $this->maszFormatOption[$szKey] = array( "FORMATOPTION", $szNewValue); } } } //pack the array $this->maszFormatOption = array_values($this->maszFormatOption); return $bResult; } /** * render as HTML */ function renderAsHTML() { $szResult = ""; //log entry $szURI = "http://".$_SERVER['HTTP_HOST']. $_SERVER['PHP_SELF']; //implementation $szResult .= "
\n"; $szResult .= "\n"; $szResult .= ""; //do normal types foreach( $this->maoTypes as $oType) { $szResult .= $oType->renderAsHTML(); } //now draw the formatoptions $szResult .= "\n"; $szResult .= "\n"; foreach( $this->maszFormatOption as $szIndex => $aItem) { $szKey = $aItem[0]; $szValue = $aItem[1]; $bFound = false; foreach ($this->maoTypes as $oType) { if ($szKey == $oType->mszTitle) { //$szResult .= $oType->renderAsHTML($szValue, $szIndex); $bFound = true; } } if (!$bFound) { $szResult .= "\n"; $szResult .= "\n\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html string return $szResult; // end renderAsHTML function } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->getName()." ".$this->getValue()."\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } class MetadataItemType extends BaseType { var $mszValueType; var $maszValueType; var $maszApplieTo; var $maszValues; /** * MetadataItemType($szName = "StringType", $mValue = "", $mDefault = "") * * @param $szName * @param $mValue * @param $mDefault * **/ function MetadataItemType ($szName = "MetadataItemType", $mValue = "", $mDefault = "") { $this->BaseType($szName, mValue, mDefault); $this->Logger("MetadataItemType"); /* #STRIPED_LOG# $this->logFuncStart(LOB_VERBOSE, "entering MetadataItemType"); #STRIPED_LOG# */ $this->maszValueType = array("STRING", "INTEGER", "ENUMERATION"); $this->setValueType("STRING"); $this->mszApplieTo = ""; } /** * setValueType( $szValueType) * * @param $szValueType * **/ function setValueType ($szValueType) { if (in_array($szValueType, $this->maszValueType)) { $this->mszValueType = $szValueType; } } /** * setAppliesTo( ) * * @param $aszAppliesTo * **/ function setAppliesTo ($aszAppliesTo) { if (is_array($aszAppliesTo)) $this->maszAppliesTo = $aszAppliesTo; } /** * setEnumValues() * * @param (NONE) * * @return (NONE) **/ function setEnumValues($szValues) { $this->maszValues = explode("|", $szValues); // check for synonyms $nVal = count($this->maszValues); for ($i=0; $i<$nVal; $i++) $this->maszValues[$i] = explode("/", $this->maszValues[$i]); } /** * renderAsHTML($szValue) * * @param (NONE) * * @return (NONE) **/ function renderAsHTML($szNewValue, $szIndex) { $szResult = "\n\n"; $szResult .= "\n\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html string return $szResult; // end renderAsHTML function } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation $szResult = ""; if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); if(is_numeric($this->mxValue)) { $szQuote = ""; } else { $szQuote = "\""; } $szResult .= $szIndent.$this->getName()." $szQuote". $this->getValue()."$szQuote\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } // end SymbolType class } /** * FontType implements a font type that uses an * in HTML */ class FontType extends BaseType { /** * construct a new FontType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function FontType( $szName = "FontType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "FontType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering SymFontTypeolType" ); #STRIPED_LOG# */ //implementation $this->mszType = "FONT"; $this->mszToolIcon = "./font.php?".SID."&szFontName=". $this->getValue(); $this->mszToolLink = "selectFont"; $this->mszToolTip = "select a font"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done FontType" ); #STRIPED_LOG# */ return $bResult; } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation $szResult = ""; if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->getName()." "."\"".$this->getValue()."\"\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags. Also add a symbol preview. * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation if (!$this->mbIsSubType) { $bOpen = ""; $bClose = ""; } else { $bOpen = ""; $bClose = ""; } $szResult = "\n"; $szResult .= "\n\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html string return $szResult; // end renderAsHTML function } // end FontType class } /** * ShapeAttrType implements a shape attribute type that uses an * in HTML */ class ShapeattrType extends BaseType { /** * construct a new ShapeAttrType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function ShapeattrType( $szName = "ShapeAttrType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "ShapeAttrType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ShapeAttrType" ); #STRIPED_LOG# */ //implementation $this->mszType = "SHAPEATTR"; $this->mszToolIcon = "images/icon_attribute_selection.gif"; $this->mszToolLink = "selectShapeAttr"; $this->mszToolTip = "select a shape attribute"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ShapeAttrType" ); #STRIPED_LOG# */ return $bResult; } /** * */ /* function processFormVars( $aszValues ) */ /* { */ /* $bResult = true; */ /* #STRIPED_LOG# /* $this->log( LOG_VERBOSE, "entering processFormVars" ); */ /* $szFieldName = ""; */ /* if ( isset( $aszValues[$this->mszName] ) ) */ /* $szFieldName = stripslashes($aszValues[$this->mszName]); */ /* $szValue = trim( "$szFieldName" ); */ /* #STRIPED_LOG# /* $this->log( LOG_ALL, "Field name is: ".$szValue ); */ /* if ( $szValue != $this->mxDefault ) */ /* $bResult = $this->setValue( $szValue ); */ /* else */ /* #STRIPED_LOG# /* $this->log( LOG_ALL, "skipping, value is default" ); */ /* #STRIPED_LOG# /* $this->log( LOG_ALL, "done processFormVars() : $bResult" ); */ /* return $bResult; */ /* } */ /** * */ function renderAsMapFileString( $szIndent = "" ) { /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ $szResult = ""; if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->getName()." "."\"".$this->getValue()."\"\n"; } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } // end ShapeAttrType class } /** * StringBlockType is also a simple type but uses a \n"; $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html string return $szResult; // end renderAsHTML function } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->getName()." "."\"".$this->getValue()."\"\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } /** * IntegerType */ class IntegerType extends BaseType { /** * construct a new IntegerType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function IntegerType( $szName = "IntegerType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "IntegerType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering IntegerType" ); #STRIPED_LOG# */ //implementation $this->szType = "INTEGER"; //logic to set up initial state if ( is_numeric( $mValue ) ) //if value is specified, use it { $this->setValue( $mValue ); } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done IntegerType" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation if (!$this->mbIsSubType) { $bOpen = ""; $bClose = ""; } else { $bOpen = ""; $bClose = ""; } $szResult = "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html string return $szResult; // end renderAsHTML function } } /** * DoubleType */ class DoubleType extends BaseType { /** * construct a new DoubleType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function DoubleType( $szName = "DoubleType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "DoubleType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering DoubleType" ); #STRIPED_LOG# */ //implementation $this->mszType = "DOUBLE"; //logic to set up initial state if ( is_numeric( $mValue ) ) //if value is specified, use it { $this->setValue( $mValue ); } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done DoubleType" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation if (!$this->mbIsSubType) { $bOpen = ""; $bClose = ""; } else { $bOpen = ""; $bClose = ""; } $szResult = "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html string return $szResult; // end renderAsHTML function } } /** * ColorType */ class ColorType extends BaseType { /** * construct a new ColorType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function ColorType( $szName = "ColorType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "ColorType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ColorType" ); #STRIPED_LOG# */ //implementation $this->mszType = "COLOR"; $this->mszToolIcon = "images/icon_colour.gif"; $this->mszToolLink = "selectColor"; $this->mszToolTip = "select a color"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ColorType" ); #STRIPED_LOG# */ return $bResult; } /** * parse a string into a value, expects the string to be formatted as per * a map file entry for this type. * * @param $oTokMapFile object contaning tokenized mapfile. * * @return fasle if something gone wrong **/ function parseValue( &$oTokMapFile ) { /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering parseValue()" ); #STRIPED_LOG# */ $szRed =& $oTokMapFile->getNextToken(); if ($szRed === FALSE) { $this->error(ERR_CRITICAL, "Error while parsing mapfile. Expecting color values."); return false; } $szGreen =& $oTokMapFile->getNextToken(); if ($szGreen === FALSE) { $this->error(ERR_CRITICAL, "Error while parsing mapfile. Expecting color values."); return false; } $szBlue =& $oTokMapFile->getNextToken(); if ($szBlue === FALSE) { $this->error(ERR_CRITICAL, "Error while parsing mapfile. Expecting color values."); return false; } $this->setValue( "$szRed $szGreen $szBlue" ); /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done parseValue"); #STRIPED_LOG# */ return true; } /** * */ function processFormVars( $aszValues ) { $bResult = true; /* #STRIPED_LOG# //$this->log( LOG_VERBOSE, "entering processFormVars" ); #STRIPED_LOG# */ $szRed = ""; $szGreen = ""; $szBlue = ""; $szRed = trim(stripslashes($aszValues["Red".$this->mszName])); $szGreen = trim(stripslashes($aszValues["Green".$this->mszName])); $szBlue = trim(stripslashes($aszValues["Blue".$this->mszName])); if ($szRed != "" || $szGreen != "" || $szBlue != "" ) { if ($szRed == "") $szRed = 0; if ($szGreen == "") $szGreen = 0; if ($szBlue == "") $szBlue = 0; } $szValue = trim( "$szRed $szGreen $szBlue" ); /* #STRIPED_LOG# //$this->log( LOG_ALL, "color is: ".$szValue ); #STRIPED_LOG# */ // if ( $szValue != $this->mxValue ) // { $bResult = $this->setValue( $szValue ); // } // else // { /* #STRIPED_LOG# // //$this->log( LOG_ALL, "skipping, value is default" ); #STRIPED_LOG# */ // } /* #STRIPED_LOG# //$this->log( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // convert the values to 3 separate RGB values - chose either the value // or default value if (trim($this->mxValue) != "") { list($nRed, $nGreen, $nBlue) = explode( " ", $this->mxValue); } else { $nRed = ""; $nGreen =""; $nBlue = ""; } // implementation if (!$this->mbIsSubType) { $bOpen = ""; $bClose = ""; } else { $bOpen = ""; $bClose = ""; } $szResult = "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html strign return $szResult; // end renderAsHTLM function } } /** * FileNameType */ class FileNameType extends BaseType { /** * construct a new FileNameType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function FileNameType( $szName = "FileNameType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault, $szBaseDir ); $this->Logger( "FileNameType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering FileNameType" ); #STRIPED_LOG# */ //implementation $this->mszType = "FILENAME"; $this->mszToolIcon = "images/icon_browse_file.gif"; $this->mszToolLink = "selectFile"; $this->mszToolTip = "select a file"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done FileNameType" ); #STRIPED_LOG# */ return $bResult; } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation $szResult = ""; if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->getName()." "."\"".$this->getValue()."\"\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } /** * DirectoryNameType */ class DirectoryNameType extends BaseType { /** * construct a new DirectoryNameType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function DirectoryNameType( $szName = "DirectoryNameType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "DirectoryNameType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering DirectoryNameType" ); #STRIPED_LOG# */ //implementation $this->mszType = "DIRECTORYNAME"; $this->mszToolIcon = "images/icon_browse.gif"; $this->mszToolLink = "selectDirectory"; $this->mszToolTip = "select a directory"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done DirectoryNameType" ); #STRIPED_LOG# */ return $bResult; } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation $szResult = ""; if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->getName()." "."\"".$this->getValue()."\"\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } /** * ComplexType */ class ComplextypeType extends BaseType { /** * contained types */ var $maoSubTypes; /** * construct a new ComplexType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function ComplextypeType( $szName = "ComplextypeType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "ComplextypeType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ComplextypeType" ); #STRIPED_LOG# */ //implementation $this->mszType = "COMPLEXTYPE"; $this->maoSubTypes = array(); if ($mValue != "") $this->mxValue = $mValue; else if ($mDefault != "") $this->mxValue = $mDefault; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ComplextypeType" ); #STRIPED_LOG# */ return $bResult; } /** * parse a string into a value, expects the string to be formatted as per * a map file entry for this type. * * @param $oTokMapfile Object that containe tokenized mapfile. * * @return boolean true if the value is valid, false otherwise **/ function parseValue( &$oTokMapFile ) { /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering parseValue()" ); #STRIPED_LOG# */ // For each sub type. Call parsevalue. foreach(array_keys($this->maoSubTypes) as $key) { if ($this->maoSubTypes[$key]->parseValue( $oTokMapFile ) === false) return false; } return true; } /** * Set value for complex type. * * @param $xValue */ function setValue( $xValue ) { $bResult = true; /* #STRIPED_LOG# $this->logFuncStart( LOG_ALL, "setValue( $xValue )" ); #STRIPED_LOG# */ //break up the value $axValues = explode( " ", trim($xValue) ); if ( trim( $xValue ) == "" ) { foreach( array_keys($this->maoSubTypes) as $key ) { $bResult = $bResult && $this->maoSubTypes[$key]->setValue( "" ); } /* #STRIPED_LOG# //$this->log(LOG_ALL, "value reset to default" ); #STRIPED_LOG# */ } else if (count($axValues) != count($this->maoSubTypes)) { $this->error( 0, "wrong value count(".count($axValues). "), should be ".count($this->maoSubTypes) ); $bResult = false; } else { $i=0; foreach( array_keys($this->maoSubTypes) as $key ) { $bResult = $bResult && $this->maoSubTypes[$key]->setValue( $axValues[$i++] ); } } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "setValue() : $bResult" ); #STRIPED_LOG# */ return $bResult; } function renderAsMapFileString( $szIndent = "" ) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "renderAsMapFileString" ); #STRIPED_LOG# */ $szResult = ""; $bSet = false; foreach( $this->maoSubTypes as $oType ) { if ($oType->mxValue != "") { $bSet = true; break; } } if ( $bSet ) { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); /* #STRIPED_LOG# //$this->log( LOG_ALL, "value is set, rendering subtypes" ); #STRIPED_LOG# */ $szResult .= $szIndent; $szResult .= $this->mszName." "; foreach( $this->maoSubTypes as $oType ) $szResult .= $oType->mxValue." "; $szResult .= "\n"; } return $szResult; } /** * */ function processFormVars( $aszValues ) { $bResult = true; /* #STRIPED_LOG# //$this->log( LOG_VERBOSE, "entering processFormVars" ); #STRIPED_LOG# */ /* #STRIPED_LOG# //$this->log(LOG_ALL, $this->maoSubTypes); #STRIPED_LOG# */ foreach( array_keys($this->maoSubTypes) as $key ) { $bResult = $bResult && $this->maoSubTypes[$key]->processFormVars( $aszValues ); } /* #STRIPED_LOG# //$this->log( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } function resetToDefault() { parent::resetToDefault(); foreach ($this->maoSubTypes as $oType) $oType->setValue(""); } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation $szResult = "\n"; $szResult .= "\n"; $szResult .= "
". "". "
\n"; $szResult .= ""; $szResult .= "Format Option"; if (count($this->maszFormatOption) > 1) $szResult .= "s"; $szResult .= ":"; $szResult .= "Delete\n"; if (strlen($szValue) > 100) // if longer than 100 caracters display as textarea { $szResult .= ""; } else { $szResult .= "mszIndex."'>\n"; $szResult .= "\n"; $szResult .= "\n"; return $szResult; } } /** * A ClassObj class */ class ClassObj extends BaseObj { /** * initialize the class */ function ClassObj( ) { $this->BaseObj(); $this->Logger( "ClassObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ClassObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "CLASS"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ClassObj" ); #STRIPED_LOG# */ } } /** * A FeatureObj class */ class FeatureObj extends BaseObj { /** * initialize the class */ function FeatureObj( ) { $this->BaseObj(); $this->Logger( "FeatureObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering FeatureObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "FEATURE"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done FeatureObj" ); #STRIPED_LOG# */ } function renderAsHTML() { //this probably isn't the place to do this. //automatically add sub-objects for POINTS and STYLE //if they don't exist if ( !isset($this->maoObjs["POINTS"]) ) { $this->addNewObject( "", "POINTS" ); } $szURI = "http://".$_SERVER['HTTP_HOST']. $_SERVER['PHP_SELF']; $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ //implementation //$this->error( 0, "BaseObj doesn't support rendering to HTML :("); $szResult = "
\n"; $szResult .= "\n"; $szResult .= ""; foreach( $this->maoTypes as $oType) { $szResult .= $oType->renderAsHTML(); } foreach($this->maoObjs as $oObj) { foreach($oObj->maoTypes as $oType) $szResult .= $oType->renderAsHTML(); } $szResult .= "
". "". "
\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "
\n"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ return $szResult; } function renderAsTreemenuString( $szLevel = "" ) { $szResult = ""; /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering renderAsTreemenuString($szLevel)"); #STRIPED_LOG# */ $szResult = $szLevel."|images/tree_".strtolower($this->mszName).".gif|@".$this->getIndex()."\n"; /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done renderAsTreemenuString($szLevel)"); #STRIPED_LOG# */ return $szResult; } function processFormVars( $szIndex, $aszFormVars ) { $bResult = true; /* #STRIPED_LOG# $this->logFuncStart( LOG_ALL, "entering processFormVars($szIndex, $aszFormVars)" ); #STRIPED_LOG# */ if (trim($szIndex != "") ) { //process on the next sub-object $nIndex = intval(substr( $szIndex, 0, 3)); $szNextIndex = substr( $szIndex, 3 ); /* #STRIPED_LOG# //$this->log( LOG_ALL, "index is $nIndex, next is $szNextIndex" ); #STRIPED_LOG# */ /* #STRIPED_LOG# ////$this->log( LOG_ALL, $this->maoObjs ); #STRIPED_LOG# */ //echo $this->maoObjs[$nIndex]->mszName; //echo count($aszFormVars); $bResult = $this->maoObjs[$nIndex]->processFormVars($szNextIndex, $aszFormVars); } else { //process on this obj. $keys = array_keys($this->maoTypes); foreach( $keys as $key ) { $bResult = $this->maoTypes[$key]->processFormVars($aszFormVars); if (!$bResult) $this->error( 0, "an error occurred setting the value for ". $this->maoTypes[$key]->mszName ); } /* #STRIPED_LOG# //$this->log( LOG_ALL, "obj has ".(count( $this->maoObjs ))." sub objects"); #STRIPED_LOG# */ //process automatically on sub-objects also $aszObjKeys = array_keys($this->maoObjs); foreach( $aszObjKeys as $szObjKey ) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "auto-processing object $szObjKey"); #STRIPED_LOG# */ $aszTypeKeys = array_keys( $this->maoObjs[$szObjKey]->maoTypes ); foreach( $aszTypeKeys as $szTypeKey ) { $bResult = $this->maoObjs[$szObjKey]->maoTypes[$szTypeKey]->processFormVars($aszFormVars); if (!$bResult) $this->error(0, "an error occurred setting the value for ". $this->maoObjs[$szObjKey]->maoTypes[$szTypeKey]->mszName ); } } } /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } } /** * A GridObj class */ class GridObj extends BaseObj { /** * initialize the class */ function GridObj( ) { $this->BaseObj(); $this->Logger( "LabelObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering GridObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "GRID"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done GridObj" ); #STRIPED_LOG# */ } } /** * A LabelObj class */ class LabelObj extends BaseObj { /** * initialize the class */ function LabelObj( ) { $this->BaseObj(); $this->Logger( "LabelObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering LabelObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "LABEL"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done LabelObj" ); #STRIPED_LOG# */ } } /** * A BitmapLabelObj class */ class BitmapLabelObj extends BaseObj { /** * initialize the class */ function BitmapLabelObj( ) { $this->BaseObj(); $this->Logger( "BitmapLabelObj" ); //implementation $this->mszName = "BITMAPLABEL"; } function renderAsMapFileString( $szIndent = "" ) { //this we can do $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation if ($this->mszComments != "") { $szResult .= str_replace("#", "$szIndent#", $this->mszComments); } $szResult .= $szIndent.$this->mszName."\n"; foreach( $this->maoTypes as $oElement ) $szResult .= $oElement->renderAsMapFileString( $szIndent." " ); foreach( $this->maoObjs as $oObj ) $szResult .= $oObj->renderAsMapFileString( $szIndent." " ); if ($this->mszEndingComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszEndingComments); $szResult .= $szIndent."END\n"; /* #STRIPED_LOG# //$this->log( LOG_ALL, "rendering result is:\n$szResult"); #STRIPED_LOG# */ //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } /** * parse this object out of the contents of a array of strings (MapFile * format) up to the next END and return the remaining elements of the * string * * @param $oTokMapFile Object needed to navigate in mapfile * * @return the remaining elements in the array or false if something went * wrong, in which case look in the global error manager. */ function parseMapFileString( &$oTokMapFile ) { global $gApp; /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "parseMapFileString()" ); #STRIPED_LOG# */ $szComments = ""; // Get next token. $szToken =& $oTokMapFile->getNextToken(); // If reache en of object or getnext token return an error. while( strcasecmp($szToken, "end") != 0 && $szToken !== false) { if ($szToken === FALSE) { //something went terribly wrong $this->error(0, "error parsing map file"); return false; } /* #STRIPED_LOG# //$this->log( LOG_ALL, "processing token ($szToken)"); #STRIPED_LOG# */ if ($szToken[0] == "#") { /* #STRIPED_LOG# //$this->log(LOG_ALL, "found a comment"); #STRIPED_LOG# */ $szComments .= "$szToken\n"; } elseif(strcasecmp($szToken, $this->mszName) == 0) { //skip the line /* #STRIPED_LOG# //$this->log(LOG_ALL, "key matches name, skipping key $szToken"); #STRIPED_LOG# */ $this->mszComments = $szComments; $szComments = ""; } elseif(in_array(strtoupper($szToken), $this->maszValidObjs)) { /* #STRIPED_LOG# //$this->log(LOG_ALL, // "create Object $szToken"); #STRIPED_LOG# */ $oObj = $gApp->createObj($szToken); $oObj->mszIndex = $this->mszIndex. sprintf( "%03d", count($this->maoObjs) ); $oObj->mszComments = $szComments; $szComments = ""; $bResult = $oObj->parseMapFileString( $oTokMapFile ); if($bResult === false) { //something went terribly wrong $this->error(0, "error parsing map file"); return false; } $this->addObj($oObj); } elseif(isset($this->maoTypes[strtoupper($szToken)])) { //okay, its valid /* #STRIPED_LOG# //$this->log(LOG_ALL, "create type $szToken"); #STRIPED_LOG# */ $nResult = $this->maoTypes[strtoupper($szToken)]->parseValue( $oTokMapFile ); if($nResult === false) { //something went terribly wrong $this->error(0, "error parsing map file"); return false; } $this->maoTypes[strtoupper($szToken)]->mszComments = $szComments; $szComments = ""; } else { $this->error( 0, "invalid map file entry $szToken in ". $this->mszName); } $szToken =& $oTokMapFile->getNextToken(); } if (strcmp(strtolower($szToken), "end") == 0) $this->mszEndingComments = $szComments; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done parseMapFileString" ); #STRIPED_LOG# */ //test for failure if(strcmp(strtolower($szToken), "end") != 0) { $this->error(0, "premature end of map file processing ".$this->mszName.", final token was $szToken"); return false; } else { return $szToken; } } } /** * A MetaDataObj class */ class MetaDataObj extends BaseObj { /** * array of strings holding meta data */ var $maszMetaData; /** * Valid type */ var $maszMetaDataItemType; /** * Restricted object */ var $maszRestricted; /** * initialize the class */ function MetaDataObj( ) { $this->BaseObj(); $this->Logger( "MetaDataObj" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering MetaDataObj" ); #STRIPED_LOG# */ //implementation $this->mszName = "METADATA"; $this->maszMetaData = array(); $this->maszRestricted = array(); $this->maszMetaDataItemType = array("STRING", "INTEGER", "ENUMERATION"); //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done MetaDataObj" ); #STRIPED_LOG# */ } /** * Reset all attribute to empty */ function clearObject() { parent::clearObject(); $this->maszMetaData = array(); $this->maszRestricted = array(); } function renderAsMapFileString( $szIndent = "" ) { $szResult = ""; /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering renderAsMapFileString"); #STRIPED_LOG# */ if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->mszName."\n"; foreach($this->maszMetaData as $szKey => $aItem) { $szResult .= $szIndent." \"".$aItem[0]."\" \"".$aItem[1]."\"\n"; } if ($this->mszEndingComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszEndingComments); $szResult .= $szIndent."END\n"; /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done renderAsMapFileString"); #STRIPED_LOG# */ return $szResult; } /** * override baseobj implementation because MetaData is a special case * * @param $oTokMapFile Object needed to navigate in mapfile * @return false if something gone wrong **/ function parseMapFileString(&$oTokMapFile) { /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering parseMapFileString"); #STRIPED_LOG# */ $szToken = ""; $szToken =& $oTokMapFile->getNextToken(); while($szToken[0] == "#") $szToken =& $oTokMapFile->getNextToken(); while(strcasecmp($szToken, "END") != 0 && $szToken !== FALSE) { $szValue = ""; $szValue =& $oTokMapFile->getNextToken(); while(strlen($szValue) && $szValue[0] == "#") $szValue =& $oTokMapFile->getNextToken(); if ($szValue === FALSE || strcasecmp($szValue, "END") == 0) { // Big error, no value found for metadata $this->error(ERR_CRITICAL, "No value set for metadata ($szToken). Please check your mapfile."); return false; } array_push($this->maszMetaData, array($szToken, $szValue)); /* #STRIPED_LOG# //$this->log(LOG_ALL, // "Added metadata item '$szKey' = '$szValue'"); #STRIPED_LOG# */ $szToken =& $oTokMapFile->getNextToken(); while($szToken[0] == "#") $szToken =& $oTokMapFile->getNextToken(); } /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done parseMapFileString"); #STRIPED_LOG# */ return $szToken; } /** * addObj adds a new meta data item */ function addNewObject( $szIndex, $szName ) { $bResult = false; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_QUIET, "entering addObj(".$oObj->mszName.")" ); #STRIPED_LOG# */ //implementation array_push($this->maszMetaData, array( $szName, "" ) ); //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_QUIET, "done addObj(".$oObj->mszName.")" ); #STRIPED_LOG# */ return $bResult; } /** * Set all current object attribute with * oObj values. */ function restoreObject($oObj) { // reset this object and copy all type from oObj $this->maszMetaData = array(); foreach($oObj->maszMetaData as $oMetaData) { array_push($this->maszMetaData, $oMetaData); } } function processFormVars( $szIndex, $aszFormVars ) { $bResult = true; /* #STRIPED_LOG# $this->logFuncStart( LOG_ALL, "entering processFormVars($szIndex, $aszFormVars)" ); #STRIPED_LOG# */ /* #STRIPED_LOG# //$this->log( LOG_ALL, $aszFormVars ); #STRIPED_LOG# */ //process on this obj.\ foreach( $this->maszMetaData as $szKey => $aItem ) { if (isset($aszFormVars["KEY".$szKey])) { $szNewKey = $aszFormVars["KEY".$szKey]; $szNewValue = $aszFormVars["META".$szKey]; if ( trim($szNewKey) == "" ) unset($this->maszMetaData[$szKey]); else { $this->maszMetaData[$szKey] = array( $szNewKey, $szNewValue); } /* #STRIPED_LOG# //$this->log( LOG_ALL, "$szNewKey was $szNewValue" ); #STRIPED_LOG# */ } } //pack the array $this->maszMetaData = array_values($this->maszMetaData); /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done processFormVars()" ); #STRIPED_LOG# */ return $bResult; } /** * render as HTML */ function renderAsHTML() { $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ //implementation $szURI = "http://".$_SERVER['HTTP_HOST']. $_SERVER['PHP_SELF']; $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ //implementation //$this->error( 0, "BaseObj doesn't support rendering to HTML :("); /* $szResult = "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "
mszName). ".gif\" WIDTH='20' HEIGHT='20'>". "". $this->mszTitle. "
\n";*/ $szResult = "
\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= "\n\n"; $szResult .= "\n\n"; foreach( $this->maszMetaData as $szIndex => $aItem) { $szKey = $aItem[0]; $szValue = $aItem[1]; $bFound = false; foreach ($this->maoTypes as $oType) { if ($szKey == $oType->mszTitle) { $szResult .= $oType->renderAsHTML($szValue, $szIndex); $bFound = true; } } if (!$bFound) { $szResult .= "\n"; */ $szResult .= "
". "". "
"; $szResult .= "Parameter"; $szResult .= "Value
"; $szResult .= "Delete\n"; $szResult .= " 100) // if longer than 100 caracters display as textarea { $szResult .= ""; } else { $szResult .= "". "
\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "
\n"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ return $szResult; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ return $szResult; } } /*****************************************************************************/ /* BaseType and sub classes */ /*****************************************************************************/ /** * BaseType provides a default implementation for all Type objects. It is * intended to be a virtual class, that is, you should only create sub-classes * of this. BaseType has a name, value and default value. If the default * value is not an empty string, then the value will be set to the default * value * */ class BaseType extends Logger { /** * the name */ var $mszName; /** * the type */ var $mszType; /** * the actual value */ var $mxValue; /** * is a member of another type (for complex types) */ var $mbIsSubType; /** * the display name of the type */ var $mszTitle; /** * set this value to give the tool that sets this type an icon to display */ var $mszToolIcon; /** * set this value to give a type a tool that can set it */ var $mszToolLink; /** * set this value to display text if the icon isn't available. */ var $mszToolTip; /** * Comments to display after the type (end of line) */ var $mszComments; /** * construct a new instance of BaseType * * @param szName string, the name of this Type * @param xValue mixed, the value of this Type * @param xDefault mixed, the default value new objects of this type * should take on */ function BaseType( $szName="BaseType", $xValue="", $xDefault="" ) { $this->Logger( "BaseType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering BaseType($szName, $xValue, $xDefault)" ); #STRIPED_LOG# */ //implementation $this->mszName = $szName; $this->mszType = "BaseType"; $this->mbIsSubType = false; $this->mszToolIcon = ""; $this->mszToolLink = ""; $this->mszToolTip = ""; $this->mszComments = ""; /* #STRIPED_LOG# //$this->log( LOG_ALL, "allo" ); #STRIPED_LOG# */ //logic to set up initial state if ( $xDefault != "" && xValue == "") $this->setValue( $xDefault ); else $this->setValue( $xValue ); /* #STRIPED_LOG# //$this->log( LOG_ALL, "hewllo" ); #STRIPED_LOG# */ //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done BaseType" ); #STRIPED_LOG# */ } /* function __wakeup() { $this->setScope( $this->mszName ); } */ /** * parse a string into a value, expects the string to be formatted as per * a map file entry for this type. * * @param $szValue the value to parse * @return boolean true if the value is valid, false otherwise **/ function parseValue( &$oTokMapFile ) { /* #STRIPED_LOG# $this->logFuncStart(LOG_VERBOSE, "entering parseValue()" ); #STRIPED_LOG# */ //remove start and end quotes $szValue =& $oTokMapFile->getNextToken(); if ($szValue !== false) { $this->setValue( $szValue ); /* #STRIPED_LOG# $this->logFuncEnd(LOG_ALL, "done parseValue"); #STRIPED_LOG# */ return true; } else return false; } /** * set the current value and record the fact that the value is set * * @param mxValue mixed, the value to take on (not validated in BaseType) */ function setValue( $mxValue ) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "setValue($mxValue)" ); #STRIPED_LOG# */ $this->mxValue = $mxValue; return true; } /** * get the current value * * @return mixed, the current value */ function getValue( ) { return $this->mxValue; } /** * process an array of values looking for the name of this object * and use the value in the array to update the value of this * object */ function processFormVars( $aszValues ) { $bResult = true; /* #STRIPED_LOG# //$this->log( LOG_VERBOSE, "entering processFormVars" ); #STRIPED_LOG# */ if ( isset( $aszValues[$this->mszName] ) ) { $szValue = trim(stripslashes($aszValues[$this->mszName])); if ($szValue !== false) $bResult = $this->setValue( $szValue ); else return false; } /* #STRIPED_LOG# //$this->log( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } /** * set the name of this type * * @param szName string, the new namex */ function setName( $szName ) { $this->mszName = $szName; } /** * return the name of this Type * * @return string, the name of this type */ function getName() { return $this->mszName; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation if (!$this->mbIsSubType) { $bOpen = ""; $bClose = ""; } else { $bOpen = ""; $bClose = ""; } $szResult = "
\n"; $szResult .= ""; $szResult .= $bOpen.$this->mszTitle.":$bClose\n"; // $szResult .= "
\n"; $szResult .= "$xValue\" ONCHANGE=\"editFormChanged()\">"; if ($this->mszToolLink != "") { // $szResult .= ""; $szResult .= "\" WIDTH=\"20\" HEIGHT=\"20\">"; } $szResult .= "
"; // $szResult .= ""; $szResult .= "(document.forms[0]['".$this->mszName."'])\">"; // $szResult .= "mszToolIcon."\" BORDER=\"0\""; // $szResult .= "TITLE='".$this->mszToolTip."' ALT='".$this->mszToolTip; $szResult .= "TITLE=\"".$this->mszToolTip."\" ALT=\"".$this->mszToolTip; // $szResult .= "' WIDTH='20' HEIGHT='20'>
"; $szResult .= ""; $szResult .= ""; $szResult .= ""; $szResult .= "\n"; if ($this->mszValueType == "ENUMERATION") { $szResult .= " in HTML */ class StringType extends BaseType { /** * construct a new StringType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function StringType( $szName = "StringType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "StringType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering StringType" ); #STRIPED_LOG# */ //implementation $this->mszType = "STRING"; if ( $this->mszName == "SYMBOL" ) { $this->mszToolIcon = "images/icon_browse.gif"; $this->mszToolLink = "selectSymbol"; $this->mszToolTip = "select a symbol"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done StringType" ); #STRIPED_LOG# */ return $bResult; } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { $szResult = ""; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szResult .= $szIndent.$this->getName()." "."\"".$this->getValue()."\"\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } // end StringType class } /** * SymbolType implements a symbol type that uses an * in HTML */ class SymbolType extends BaseType { /** * construct a new SymbolType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function SymbolType( $szName = "SymbolType", $mValue = "", $mDefault = "") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "SymbolType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering SymbolType" ); #STRIPED_LOG# */ //implementation $this->mszType = "SYMBOL"; $this->mszToolIcon = "images/icon_browse.gif"; $this->mszToolLink = "selectSymbol"; $this->mszToolTip = "select a symbol"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done SymbolType" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags. Also add a symbol preview. * * @return string */ function renderAsHTML( ) { global $gApp; // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation if (!$this->mbIsSubType) { $bOpen = ""; $bClose = ""; } else { $bOpen = ""; $bClose = ""; } $szResult = "
\n"; $szResult .= ""; $szResult .= $bOpen.$this->mszTitle.":$bClose\n"; $szResult .= "\n"; if ($this->mszToolLink != "") { $szResult .= ""; } $szResult .= "
"; $szResult .= "getValue(); if (substr($szSymPath, 0, 1) == ".") { $szPath = dirname($_SESSION["gszMapName"])."/".$szSymPath; } else { $szPath = $szSymPath; } $szPath = realpath($szPath); if (!is_file($szPath)) { $szPath = ""; } } else { $szPath = ""; } $szResult .= "$xValue' onchange=\"symbolChanged(document.forms[0]['".$this->mszName."'], '$szPath')\" onkeyup=\"symbolChanged(document.forms[0]['".$this->mszName."'], '$szPath')\">"; /* * layer type */ $oObj = &$gApp->getObjByIndex($_SESSION["gszIndex"]); $szType = ""; if ($oObj->mszName == "CLASS") { // Get layer $szIndex = substr($_SESSION["gszIndex"], 0, 3); $oLayer = &$gApp->getObjByIndex($szIndex); $oType = $oLayer->getType("TYPE"); $szType = $oType->mxValue; if ($szType == "") $szType = "POINT"; } echo ""; $szResult .= "mxValue; $szResult .= "&szType=$szType\" name=\""; $szResult .= $this->mszName."_PREVIEW\" BORDER=\"0\">
\n"; $szResult .= ""; $szResult .= $bOpen.$this->mszTitle.":$bClose\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= ""; if ($this->mszToolLink != "") { $szResult .= ""; } $szResult .= "
"; $szResult .= "mszName."'])\" onkeyup=\"fontChanged(document.forms[0]['".$this->mszName."'])\">"; $szResult .= ""; $szResult .= "mxValue."\" "; $szResult .= "name=\"".$this->mszName."_PREVIEW\" "; $szResult .= "BORDER=\"0\">
"; $szResult .= "
\n"; $szResult .= "$bOpen"; $szResult .= $this->mszTitle; $szResult .= ":$bClose\n"; $szResult .= "\n"; $szResult .= "
\n"; $szResult .= "$bOpen"; $szResult .= $this->mszTitle; $szResult .= ":$bClose\n"; $szResult .= "\n"; $szResult .= "
\n"; $szResult .= "$bOpen"; $szResult .= $this->mszTitle; $szResult .= ":$bClose\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; if ($this->mszToolLink != "") { $szResult .= ""; } $szResult .= "
"; $szResult .= "Red:"; $szResult .= ""; $szResult .= ""; $szResult .= "Green:"; $szResult .= ""; $szResult .= ""; $szResult .= "Blue:"; $szResult .= ""; $szResult .= ""; $szResult .= "mszToolTip."' ALT='".$this->mszToolTip; $szResult .= "' WIDTH='30' HEIGHT='20'>
\n"; $szResult .= "
\n"; $szResult .= ""; $szResult .= $this->mszTitle; $szResult .= ":\n"; $szResult .= "\n"; $szResult .= "\n"; $szTable1 = "
\n"; $szTable2 = "
\n"; $bTable1 = true; foreach( $this->maoSubTypes as $oType ) { if ($bTable1) { $szTable1 .= $oType->renderAsHTML(); } else { $szTable2 .= $oType->renderAsHTML(); } $bTable1 = !$bTable1; } $szTable1 .= "
\n"; $szTable2 .= "
\n"; $szResult .= "\n$szTable1\n"; $szResult .= "\n$szTable2\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html string return $szResult; // end renderAsHTML function } function addType( $oType ) { $bResult = true; //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering addType" ); #STRIPED_LOG# */ //implementation $oType->mbIsSubType = true; $this->maoSubTypes[$oType->mszName] = $oType; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done addType" ); #STRIPED_LOG# */ return $bResult; } } /** * EnumerationType */ class EnumerationType extends BaseType { /** * */ var $maszValues; /** * construct a new EnumerationType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function EnumerationType( $szName="EnumerationType", $mValue="", $mDefault="") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "EnumerationType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering EnumerationType" ); #STRIPED_LOG# */ //implementation $this->mszType = "ENUMERATION"; $this->maszValues = array(); //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done EnumerationType" ); #STRIPED_LOG# */ return $bResult; } /** * */ function setValue( $mxValue ) { $bResult = false; $bInArray = false; if (is_array( $this->maszValues ) || count( $this->maszValues ) != 0) { foreach ($this->maszValues as $aszValues) if (is_array($aszValues) && in_array( strtoupper($mxValue), $aszValues )) $bInArray = true; } else { //fake it if the valid values haven't been set yet (i.e. any value //or initializing $bInArray = true; } if ( $bInArray == true) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "value okay, using parent to set it" ); #STRIPED_LOG# */ $bResult = parent::setValue($mxValue); } else { $szError = "Invalid value ($mxValue) for ".$this->mszName." should be one of "; foreach ($this->maszValues as $aszValues) if (is_array($aszValues)) $szError .= implode(",", $aszValues); $this->error( 0, $szError); } return $bResult; } /** * overload the set value function to allow the validator to set the value * Logic is that if the value contains | characters, we are actually setting * the 'allowed' values */ function setEnumValues( $mxValue ) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "setting values to $mxValue" ); #STRIPED_LOG# */ $this->maszValues = explode( "|", strtoupper($mxValue) ); // check for synonyms $nVal = count($this->maszValues); for ($i=0; $i<$nVal; $i++) $this->maszValues[$i] = explode("/", $this->maszValues[$i]); } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation if (!$this->mbIsSubType) { $bOpen = ""; $bClose = ""; } else { $bOpen = ""; $bClose = ""; } $szResult = "\n"; $szResult .= "\n"; $szResult .= "$bOpen"; $szResult .= $this->mszTitle; $szResult .= ":$bClose\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html string return $szResult; // end renderAsHTML function } } /** * ExpressionType */ class ExpressionType extends BaseType { /** * construct a new ExpressionType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function ExpressionType( $szName="ExpressionType", $mValue="", $mDefault="") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "ExpressionType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ExpressionType" ); #STRIPED_LOG# */ //implementation $this->mszType = "EXPRESSION"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ExpressionType" ); #STRIPED_LOG# */ return $bResult; } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation $szResult = ""; if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $szStart = substr($this->mxValue, 0, 1); if ($szStart == "(" || $szStart == "/") { $szQuote = ""; } else { $szQuote = "\""; } $szResult .= $szIndent.$this->getName()." ".$szQuote. $this->getValue().$szQuote."\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } /** * ComboenumerationdoubleType */ class ComboenumerationdoubleType extends BaseType { /** * */ var $maszValues; /** * construct a new ComboenumerationdoubleType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function ComboenumerationdoubleType( $szName="ComboenumerationdoubleType", $mValue="", $mDefault="") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "ComboenumerationdoubleType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ComboenumerationdoubleType" ); #STRIPED_LOG# */ //implementation $this->mszType = "COMBOENUMERATIONDOUBLE"; $this->maszValues = array(); //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ComboenumerationdoubleType" ); #STRIPED_LOG# */ return $bResult; } /** * overload the set value function to allow the validator to set the value * Logic is that if the value contains | characters, we are actually setting * the 'allowed' values */ function setEnumValues( $mxValue ) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "setting values to $mxValue" ); #STRIPED_LOG# */ $this->maszValues = explode( "|", strtoupper($mxValue) ); // check for synonyms $nVal = count($this->maszValues); for ($i=0; $i<$nVal; $i++) $this->maszValues[$i] = explode("/", $this->maszValues[$i]); } /** * */ function setValue( $mxValue ) { $bResult = true; $bValid = false; if ( strval(doubleval(trim($mxValue))) != trim($mxValue) && $mxValue != "") { if (is_array( $this->maszValues ) || count( $this->maszValues ) != 0) { foreach ($this->maszValues as $aszValues) if (is_array($aszValues) && in_array( strtoupper($mxValue), $aszValues )) $bValid = true; } } else $bValid = true; if (!$bValid) { $szError = "Invalid value ($mxValue) for ".$this->mszName." should be double or one of "; foreach ($this->maszValues as $aszValues) if (is_array($aszValues)) $szError .= implode(",", $aszValues); $this->error( 0, $szError ); $bResult = false; } else { /* #STRIPED_LOG# //$this->log( LOG_ALL, "value okay, using parent to set it" ); #STRIPED_LOG# */ parent::setValue($mxValue); } return $bResult; } /** * override the processFormVars to look for a possible * combo double value */ function processFormVars( $aszValues ) { $bResult = true; /* #STRIPED_LOG# //$this->log( LOG_VERBOSE, "entering processFormVars" ); #STRIPED_LOG# */ if (isset($aszValues['DBLCMB'.$this->mszName])) { $szCmbValue = stripslashes($aszValues['DBLCMB'.$this->mszName]); if ($szCmbValue != "") { $this->setValue($szCmbValue); } } if (isset($aszValues['DBLVAL'.$this->mszName]) && $aszValues['DBLVAL'.$this->mszName] != "") { $this->setValue($aszValues['DBLVAL'.$this->mszName]); } /* #STRIPED_LOG# //$this->log( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation $szResult = "\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= $this->mszTitle; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n
"; $szResult .= ""; $szResult .= ""; $szResult .= " Or: "; $szResult .= ""; $szResult .= " ". "(double)
\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html strign return $szResult; // end renderAsHTLM function } } /** * ComboenumerationintegerType */ class ComboenumerationintegerType extends BaseType { /** * */ var $maszValues; /** * construct a new ComboenumerationintegerType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function ComboenumerationintegerType( $szName="ComboenumerationintegerType", $mValue="", $mDefault="") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "ComboenumerationintegerType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering ComboenumerationintegerType" ); #STRIPED_LOG# */ //implementation $this->mszType = "COMBOENUMERATIONINTEGER"; $this->maszValues = array(); //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done ComboenumerationintegerType" ); #STRIPED_LOG# */ return $bResult; } /** * overload the set value function to allow the validator to set the value * Logic is that if the value contains | characters, we are actually setting * the 'allowed' values */ function setEnumValues( $mxValue ) { /* #STRIPED_LOG# //$this->log( LOG_ALL, "setting values to $mxValue" ); #STRIPED_LOG# */ $this->maszValues = explode( "|", strtoupper($mxValue) ); // check for synonyms $nVal = count($this->maszValues); for ($i=0; $i<$nVal; $i++) $this->maszValues[$i] = explode("/", $this->maszValues[$i]); } /** * */ function setValue( $mxValue ) { $bResult = true; $bValid = false; if ( strval(intval(trim($mxValue))) != trim($mxValue) && $mxValue != "") { if (is_array( $this->maszValues ) || count( $this->maszValues ) != 0) { foreach ($this->maszValues as $aszValues) if (in_array( strtoupper($mxValue), $aszValues )) $bValid = true; } } else $bValid = true; if (!$bValid) { $szError = "Invalid value ($mxValue) for ".$this->mszName." should be integer or one of "; foreach ($this->maszValues as $aszValues) $szError .= implode(",", $aszValues); $this->error( 0, $szError ); $bResult = false; } else { /* #STRIPED_LOG# //$this->log( LOG_ALL, "value okay, using parent to set it" ); #STRIPED_LOG# */ parent::setValue($mxValue); } return $bResult; } /** * override the processFormVars to look for a possible * combo double value */ function processFormVars( $aszValues ) { $bResult = true; /* #STRIPED_LOG# //$this->log( LOG_VERBOSE, "entering processFormVars" ); #STRIPED_LOG# */ if (isset($aszValues['INTCMB'.$this->mszName])) { $szCmbValue = stripslashes($aszValues['INTCMB'.$this->mszName]); if ($szCmbValue != "") { $this->setValue($szCmbValue); } } if (isset($aszValues['INTVAL'.$this->mszName]) && $aszValues['INTVAL'.$this->mszName] != "") { $this->setValue($aszValues['INTVAL'.$this->mszName]); } /* #STRIPED_LOG# //$this->log( LOG_ALL, "done processFormVars() : $bResult" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation $szResult = "\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= $this->mszTitle; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "
\n"; $szResult .= ""; $szResult .= ""; $szResult .= " Or: "; $szResult .= ""; $szResult .= " ". "(integer)
\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html strign return $szResult; // end renderAsHTLM function } } class FontSizeType extends ComboenumerationintegerType { /** * construct a new FontSizeType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function FontSizeType( $szName="FontSizeType", $mValue="", $mDefault="") { //use base class constructor $this->ComboenumerationintegerType( $szName, $mValue, $mDefault ); $this->Logger( "FontSizeType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering FontSizeType" ); #STRIPED_LOG# */ //implementation $this->mszType = "FONTSIZE"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done FontSizeType" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation $szResult = "\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= $this->mszTitle; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= "
\n"; $szResult .= " (integer)"; $szResult .= "  Or   Bitmap Size: "; $szResult .= "
"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html strign return $szResult; // end renderAsHTLM function } } /** * SeparatorType */ class SeparatorType extends BaseType { /** * construct a new SeparatorType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function SeparatorType( $szName="SeparatorType", $mValue="", $mDefault="") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "SeparatorType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering SeparatorType" ); #STRIPED_LOG# */ //implementation $this->mszType = "SEPARATOR"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done SeparatorType" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation $szResult = "\n"; $szResult .= ""; if (strcasecmp($this->mxValue, "ON") == 0) { $szResult .= ""; $szResult .= "".$this->mszTitle.""; $szResult .= ""; } else { $szResult .= " "; } $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html strign return $szResult; // end renderAsHTLM function } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { $szResult = ""; /* #STRIPED_LOG# //$this->log( LOG_ALL, "separators dont go in a map file"); #STRIPED_LOG# */ return $szResult; } } /** * SymbolpointsType * * display as a html text area but write to map file as POINTS END */ class SymbolpointsType extends BaseType { /** * construct a new SymbolpointsType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function SymbolpointsType( $szName="SymbolpointsType", $mValue="", $mDefault="") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "SymbolpointsType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering SymbolpointsType" ); #STRIPED_LOG# */ //implementation $this->mszType = "SYMBOLPOINTS"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done SymbolpointsType" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation $szResult = "\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= $this->mszTitle; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html strign return $szResult; // end renderAsHTLM function } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $aszPoints = explode( "\n", $this->getValue() ); foreach( $aszPoints as $szPoint ) $szResult .= $szIndent.$szPoint."\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } /** * SymbolstyleType * * display as a html text input but write to map file as STYLE END */ class SymbolstyleType extends BaseType { /** * construct a new SymbolstyleType object * * @param szName string, the name of this type * @param mValue mixed, the value * @param mDefault mixed, the default value */ function SymbolstyleType( $szName="SymbolstyleType", $mValue="", $mDefault="") { //use base class constructor $this->BaseType( $szName, $mValue, $mDefault ); $this->Logger( "SymbolstyleType" ); //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering SymbolstyleType" ); #STRIPED_LOG# */ //implementation $this->mszType = "SYMBOLSTYLE"; //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done SymbolstyleType" ); #STRIPED_LOG# */ return $bResult; } /** * return a string of this Type suitable to be echo'd into HTML forms * formatted into table row tags * * @return string */ function renderAsHTML( ) { // log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsHTML" ); #STRIPED_LOG# */ // implementation $szResult = "\n"; $szResult .= "\n"; $szResult .= ""; $szResult .= $this->mszTitle; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; $szResult .= "\n"; // log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsHTML" ); #STRIPED_LOG# */ // return the html strign return $szResult; // end renderAsHTLM function } /** * render this type as a MapFile string */ function renderAsMapFileString( $szIndent = "" ) { //log entry /* #STRIPED_LOG# $this->logFuncStart( LOG_VERBOSE, "entering renderAsMapFileString" ); #STRIPED_LOG# */ //implementation if($this->mxValue != "") { if ($this->mszComments != "") $szResult .= str_replace("#", "$szIndent#", $this->mszComments); $aszStyles = explode( "\n", $this->getValue() ); foreach( $aszStyles as $szStyle ) $szResult .= $szIndent.$szStyle."\n"; } //log exit /* #STRIPED_LOG# $this->logFuncEnd( LOG_ALL, "done renderAsMapFileString" ); #STRIPED_LOG# */ return $szResult; } } ?>