0) { return substr($s, $c + 1); } return $s; } /** * Get namespace from a tag name. * * Example: input is "topp:the_geom" will return "topp". * * @return String * @param $s String */ final protected function getNameSpace($s) { $c = strpos($s, ":"); if ($c > 0) { return substr($s, 0, $c); } return $s; } /** * Retrieves a document from a URL, presumably a * capabilities document, via GET. * * @return String * @param $url String */ final protected function get ($url, $auth=false) { if (!$auth) { $x = new connector($url); } else { $x = new connector($url, $auth); } $xml = $x->file; if(!$xml){ throw new Exception("Unable to open document: " . $url); return null; } return $xml; } /** * Retrieves a document from a URL, presumably a * describe feature type document, via POST * * @return String * @param $url String */ final protected function post ($url, $postData, $auth=false) { $x = new connector(); $x->set("httpType", "post"); $x->set("httpPostData", $postData); $x->set("httpContentType", "XML"); if (!$auth) { $xml = $x->load($url); } else { $xml = $x->load($url, $auth); } if(!$xml){ throw new Exception("Unable to open document: " . $url); return null; } return $xml; } /** * Creates an OWS from an XML, presumably a capabilities document, * which is retrieved from a URL. * * @return Ows * @param $url String, $auth authentication info hash */ final public function createFromUrl ($url, $auth=false) { if (!$auth) { try { $xml = $this->get($url); $myOws = $this->createFromXml($xml); if ($myOws != null) { $myOws->uploadUrl = $url; return $myOws; } return null; } catch (Exception $e) { new mb_exception($e); return null; } return null; } else { try { $xml = $this->get($url, $auth); $myOws = $this->createFromXml($xml, $auth); if ($myOws != null) { $myOws->uploadUrl = $url; return $myOws; } return null; } catch (Exception $e) { new mb_exception($e); return null; } return null; } } } ?>