Example #1
0
 function SetProps()
 {
     global $site;
     global $userInfo;
     global $errInvalidWFSFile;
     // Get WFS reader
     $serverAdmin = new MgServerAdmin();
     $serverAdmin->Open($userInfo);
     $wfsReader = $serverAdmin->GetDocument('Wfs:OgcWfsService.config');
     // Set WFS metadata
     $wfsData = "";
     $chunk = "";
     do {
         $chunkSize = $wfsReader->Read($chunk, 4096);
         $wfsData = $wfsData . $chunk;
     } while ($chunkSize != 0);
     $keywordsStr = "";
     foreach ($this->keywords as $keyword) {
         $keywordsStr = $keywordsStr . '<item>' . $keyword . '</item>';
     }
     $this->serviceMetadata[WFS_KEYWORDS_ITEM] = $keywordsStr;
     foreach ($this->serviceMetadata as $serviceItem => $serviceVal) {
         $itemPos = strpos($wfsData, $serviceItem);
         if ($itemPos === false) {
             throw new Exception($errInvalidWFSFile);
         }
         $valStartPos = strpos($wfsData, '>', $itemPos);
         $valEndPos = strpos($wfsData, '</Define>', $itemPos);
         if ($valStartPos === false || $valEndPos === false || $valStartPos >= $valEndPos) {
             throw new Exception($errInvalidWFSFile);
         }
         $wfsData = substr_replace($wfsData, $serviceVal, $valStartPos + 1, $valEndPos - $valStartPos - 1);
     }
     // Save wfs config
     $wfsByteSource = new MgByteSource($wfsData, strlen($wfsData));
     $wfsByteSource->SetMimeType($wfsReader->GetMimeType());
     $serverAdmin->SetDocument('Wfs:OgcWfsService.config', $wfsByteSource->GetReader());
     $serverAdmin->Close();
 }