protected function getcapabilities()
 {
     $result = parent::getcapabilities();
     if ($result->cached) {
         return $result;
     }
     $data = $result->data;
     if (empty($data) or floor($result->code / 100) >= 4) {
         jMessage::add('Server Error !', 'Error');
         return $this->serviceException();
     }
     if (preg_match('#ServiceExceptionReport#i', $data)) {
         return $result;
     }
     // Replace qgis server url in the XML (hide real location)
     $sUrl = jUrl::getFull("lizmap~service:index", array("repository" => $this->repository->getKey(), "project" => $this->project->getKey()));
     $sUrl = str_replace('&', '&', $sUrl);
     preg_match('/<get>.*\\n*.+xlink\\:href="(.+)"/i', $data, $matches);
     if (count($matches) < 2) {
         preg_match('/get onlineresource="(.+)"/i', $data, $matches);
     }
     if (count($matches) > 1) {
         $data = str_replace($matches[1], $sUrl, $data);
     }
     $data = str_replace('&amp;&amp;', '&amp;', $data);
     // Add response to cache
     $cacheId = $this->repository->getKey() . '_' . $this->project->getKey() . '_' . $this->param('service');
     $newhash = md5_file(realpath($this->repository->getPath()) . '/' . $this->project->getKey() . ".qgs");
     jCache::set($cacheId . '_hash', $newhash);
     jCache::set($cacheId . '_mime', $result->mime);
     jCache::set($cacheId . '_data', $data);
     return (object) array('code' => 200, 'mime' => $result->mime, 'data' => $data, 'cached' => False);
 }
 protected function getcapabilities()
 {
     $result = parent::getcapabilities();
     if ($result->cached) {
         return $result;
     }
     $data = $result->data;
     if (empty($data) or floor($result->code / 100) >= 4) {
         jMessage::add('Server Error !', 'Error');
         return $this->serviceException();
     }
     if (preg_match('#ServiceExceptionReport#i', $data)) {
         return $result;
     }
     // Remove no interoparable elements
     $data = preg_replace('@<GetPrint[^>]*?>.*?</GetPrint>@si', '', $data);
     $data = preg_replace('@<ComposerTemplates[^>]*?>.*?</ComposerTemplates>@si', '', $data);
     // Replace qgis server url in the XML (hide real location)
     $sUrl = jUrl::getFull("lizmap~service:index", array("repository" => $this->repository->getKey(), "project" => $this->project->getKey()));
     $sUrl = str_replace('&', '&amp;', $sUrl);
     preg_match('/<get>.*\\n*.+xlink\\:href="(.+)"/i', $data, $matches);
     if (count($matches) < 2) {
         preg_match('/get onlineresource="(.+)"/i', $data, $matches);
     }
     if (count($matches) > 1) {
         $data = str_replace($matches[1], $sUrl, $data);
     }
     $data = str_replace('&amp;&amp;', '&amp;', $data);
     if (preg_match('@WMS_Capabilities@i', $data)) {
         // Update namespace
         $schemaLocation = "http://www.opengis.net/wms";
         $schemaLocation .= " http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd";
         $schemaLocation .= " http://www.opengis.net/sld";
         $schemaLocation .= " http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd";
         $schemaLocation .= " http://www.qgis.org/wms";
         $schemaLocation .= " " . $sUrl . "SERVICE=WMS&amp;REQUEST=GetSchemaExtension";
         $data = preg_replace('@xsi:schemaLocation=".*?"@si', 'xsi:schemaLocation="' . $schemaLocation . '"', $data);
         if (!preg_match('@xmlns:qgs@i', $data)) {
             $data = preg_replace('@xmlns="http://www.opengis.net/wms"@', 'xmlns="http://www.opengis.net/wms" xmlns:qgs="http://www.qgis.org/wms"', $data);
             $data = preg_replace('@GetStyles@', 'qgs:GetStyles', $data);
         }
         if (!preg_match('@xmlns:sld@i', $data)) {
             $data = preg_replace('@xmlns="http://www.opengis.net/wms"@', 'xmlns="http://www.opengis.net/wms" xmlns:sld="http://www.opengis.net/sld"', $data);
             $data = preg_replace('@GetLegendGraphic@', 'sld:GetLegendGraphic', $data);
         }
     }
     // Add response to cache
     $cacheId = $this->repository->getKey() . '_' . $this->project->getKey() . '_' . $this->param('service');
     $newhash = md5_file(realpath($this->repository->getPath()) . '/' . $this->project->getKey() . ".qgs");
     jCache::set($cacheId . '_hash', $newhash);
     jCache::set($cacheId . '_mime', $result->mime);
     jCache::set($cacheId . '_data', $data);
     return (object) array('code' => 200, 'mime' => $result->mime, 'data' => $data, 'cached' => False);
 }
 protected function getcapabilities()
 {
     //Get Cache
     $cacheId = $this->repository->getKey() . '_' . $this->project->getKey() . '_WMTS';
     $hash = jCache::get($cacheId . '_hash');
     $newhash = md5_file(realpath($this->repository->getPath()) . '/' . $this->project->getKey() . ".qgs");
     $tileMatrixSetList = jCache::get($cacheId . '_tilematrixsetlist');
     $layers = jCache::get($cacheId . '_layers');
     if (!$tileMatrixSetList || !$layers || $hash != $newhash) {
         $wmsRequest = new lizmapWMSRequest($this->project, array('service' => 'WMS', 'request' => 'GetCapabilities'));
         $wmsResult = $wmsRequest->process();
         $wms = $wmsResult->data;
         $wms_xml = simplexml_load_string($wms);
         $wms_xml->registerXPathNamespace("wms", "http://www.opengis.net/wms");
         $wms_xml->registerXPathNamespace("xlink", "http://www.w3.org/1999/xlink");
         $tileMatrixSetList = lizmapTiler::getTileMatrixSetList($this->project, $wms_xml);
         $cfgLayers = $this->project->getLayers();
         $layers = array();
         foreach ($cfgLayers as $n => $l) {
             if ($l->cached == 'True' && $l->singleTile != 'True' && strtolower($l->name) != 'overview') {
                 $layer = lizmapTiler::getLayerTileInfo($l->name, $this->project, $wms_xml, $tileMatrixSetList);
                 if ($layer) {
                     $layers[] = $layer;
                 }
             }
         }
         jCache::set($cacheId . '_hash', $newhash, 3600);
         jCache::set($cacheId . '_tilematrixsetlist', $tileMatrixSetList, 3600);
         jCache::set($cacheId . '_layers', $layers, 3600);
     }
     $sUrl = jUrl::getFull("lizmap~service:index", array("repository" => $this->repository->getKey(), "project" => $this->project->getKey()));
     $tpl = new jTpl();
     $tpl->assign('url', $sUrl);
     $tpl->assign('repository', $this->param('repository'));
     $tpl->assign('project', $this->param('project'));
     $tpl->assign('tileMatrixSetList', $tileMatrixSetList);
     $tpl->assign('layers', $layers);
     return (object) array('code' => 200, 'mime' => 'text/xml', 'data' => $tpl->fetch('lizmap~wmts_capabilities'), 'cached' => False);
 }
 /**
  * constructor
  * key : the project name
  * rep : the repository has a lizmapRepository class
  */
 public function __construct($key, $rep)
 {
     if (file_exists($rep->getPath() . $key . '.qgs') && file_exists($rep->getPath() . $key . '.qgs.cfg')) {
         $this->key = $key;
         $this->repository = $rep;
         $key_session = $rep->getKey() . '~' . $key;
         $qgs_path = $rep->getPath() . $key . '.qgs';
         $config = null;
         $qgs_xml = null;
         $update_session = false;
         if (isset($_SESSION['_LIZMAP_']) && isset($_SESSION['_LIZMAP_'][$key_session]) && isset($_SESSION['_LIZMAP_'][$key_session]['cfg']) && isset($_SESSION['_LIZMAP_'][$key_session]['cfgmtime']) && $_SESSION['_LIZMAP_'][$key_session]['cfgmtime'] >= filemtime($qgs_path . '.cfg')) {
             $config = $_SESSION['_LIZMAP_'][$key_session]['cfg'];
         } else {
             $config = jFile::read($qgs_path . '.cfg');
             $update_session = true;
         }
         $this->cfg = json_decode($config);
         $configOptions = $this->cfg->options;
         if (isset($_SESSION['_LIZMAP_']) && isset($_SESSION['_LIZMAP_'][$key_session]) && isset($_SESSION['_LIZMAP_'][$key_session]['xml']) && isset($_SESSION['_LIZMAP_'][$key_session]['xmlmtime']) && $_SESSION['_LIZMAP_'][$key_session]['xmlmtime'] >= filemtime($qgs_path)) {
             $qgs_xml = simplexml_load_string($_SESSION['_LIZMAP_'][$key_session]['xml']);
         } else {
             $qgs_xml = simplexml_load_file($qgs_path);
             $update_session = true;
         }
         $this->xml = $qgs_xml;
         $this->data = array('repository' => $rep->getKey(), 'id' => $key, 'title' => ucfirst($key), 'abstract' => '', 'proj' => $configOptions->projection->ref, 'bbox' => join($configOptions->bbox, ', '));
         # get title from WMS properties
         if (property_exists($qgs_xml->properties, 'WMSServiceTitle')) {
             if (!empty($qgs_xml->properties->WMSServiceTitle)) {
                 $this->data['title'] = $qgs_xml->properties->WMSServiceTitle;
             }
         }
         # get abstract from WMS properties
         if (property_exists($qgs_xml->properties, 'WMSServiceAbstract')) {
             $this->data['abstract'] = $qgs_xml->properties->WMSServiceAbstract;
         }
         if ($update_session) {
             if (!isset($_SESSION['_LIZMAP_'])) {
                 $_SESSION['_LIZMAP_'] = array($key_session => array());
             } else {
                 if (!isset($_SESSION['_LIZMAP_'][$key_session])) {
                     $_SESSION['_LIZMAP_'][$key_session] = array();
                 }
             }
             $_SESSION['_LIZMAP_'][$key_session]['xml'] = $qgs_xml->saveXml();
             $_SESSION['_LIZMAP_'][$key_session]['xmlmtime'] = filemtime($qgs_path);
             $_SESSION['_LIZMAP_'][$key_session]['cfg'] = $config;
             $_SESSION['_LIZMAP_'][$key_session]['cfgmtime'] = filemtime($qgs_path . '.cfg');
         }
         # get WMS getCapabilities full URL
         $this->data['wmsGetCapabilitiesUrl'] = jUrl::getFull('lizmap~service:index', array('repository' => $rep->getKey(), 'project' => $key, 'SERVICE' => 'WMS', 'VERSION' => '1.3.0', 'REQUEST' => 'GetCapabilities'));
         // get QGIS project version
         $qgisRoot = $this->xml->xpath('//qgis');
         $qgisRootZero = $qgisRoot[0];
         $qgisProjectVersion = (string) $qgisRootZero->attributes()->version;
         $qgisProjectVersion = explode('-', $qgisProjectVersion);
         $qgisProjectVersion = $qgisProjectVersion[0];
         $qgisProjectVersion = explode('.', $qgisProjectVersion);
         $a = '';
         foreach ($qgisProjectVersion as $k) {
             if (strlen($k) == 1) {
                 $a .= $k . '0';
             } else {
                 $a .= $k;
             }
         }
         $qgisProjectVersion = (int) $a;
         $this->qgisProjectVersion = $qgisProjectVersion;
     }
 }
 /**
  * replaceMediaPathByMediaUrl : replace all "/media/bla" in a text by the getMedia corresponding URL.
  * This method is used as callback in GetFeatureInfoHtml method for the preg_replace_callback
  * @param array $matches Array containing the preg matches
  * @return Replaced text.
  */
 function replaceMediaPathByMediaUrl($matches)
 {
     $return = '';
     $return .= '"';
     $return .= jUrl::getFull('view~media:getMedia', array('repository' => $this->repository->getKey(), 'project' => $this->project->getKey(), 'path' => $matches[2]), 0, $_SERVER['SERVER_NAME']);
     $return .= '"';
     return $return;
 }
示例#6
0
/**
* @package    jelix
* @subpackage jtpl_plugin
* @author     Mickael Fradin
* @contributor Laurent Jouanneau
* @copyright  2009 Mickael Fradin
* @link       http://www.jelix.org
* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
*/
function jtpl_function_xml_jfullurl($tpl, $selector, $params = array(), $domain = null, $escape = true)
{
    echo jUrl::getFull($selector, $params, $escape ? 1 : 0, $domain);
}
 function f($x)
 {
     return jUrl::getFull('lizmap~service:index', array(), 0, trim($x));
 }
示例#8
0
 /**
  * Query the IGN Geoportal API
  * @param text $query A query on IGN BD adresse object
  * @param text $bbox A bounding box in EPSG:4326
  * @return XML.
  */
 function address()
 {
     $rep = $this->getResponse('json');
     $rep->data = array();
     $query = $this->param('query');
     if (!$query) {
         return $rep;
     }
     // Get the project
     $project = filter_var($this->param('project'), FILTER_SANITIZE_STRING);
     if (!$project) {
         return $rep;
     }
     // Get repository data
     $repository = $this->param('repository');
     if (!$repository) {
         return $rep;
     }
     // Get the project object
     $lproj = lizmap::getProject($repository . '~' . $project);
     if (!$lproj) {
         return $rep;
     }
     $configOptions = $lproj->getOptions();
     if (!property_exists($configOptions, 'ignKey') || $configOptions->ignKey == '') {
         return $rep;
     }
     $url = 'http://gpp3-wxs.ign.fr/' . $configOptions->ignKey . '/geoportail/ols?';
     $xls = '<XLS xmlns:xls="http://www.opengis.net/xls" xmlns:gml="http://www.opengis.net/gml" xmlns="http://www.opengis.net/xls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd">';
     $xls .= '<RequestHeader/><Request requestID="1" version="1.2" methodName="LocationUtilityService"><GeocodeRequest returnFreeForm="false"><Address countryCode="StreetAddress">';
     $xls .= '<freeFormAddress>' . $query . '</freeFormAddress>';
     $xls .= '</Address></GeocodeRequest></Request></XLS>';
     $params = array("xls" => $xls, "output" => 'xml');
     $url .= http_build_query($params);
     $curl_handle = curl_init();
     curl_setopt($curl_handle, CURLOPT_URL, $url);
     curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:'));
     curl_setopt($curl_handle, CURLOPT_REFERER, jUrl::getFull('lizmap~ign:address'));
     $content = curl_exec($curl_handle);
     curl_close($curl_handle);
     $rep->content = $content;
     $content = str_replace('xmlns=', 'ns=', $content);
     $content = str_replace('gml:', '', $content);
     $xml = simplexml_load_string($content);
     $results = array();
     $GeocodedAddresses = $xml->xpath('//GeocodedAddress');
     foreach ($GeocodedAddresses as $GeocodedAddress) {
         $result = array();
         $address = array();
         /*
          * bug with gml:*
          */
         $Point = $GeocodedAddress->xpath('Point/pos');
         if (count($Point) != 0) {
             $Point = $Point[0];
             $point = explode(' ', (string) $Point);
             $result['point'] = array($point[1], $point[0]);
         }
         $Address = $GeocodedAddress->xpath('Address');
         if (count($Address) == 0) {
             continue;
         }
         $Address = $Address[0];
         $Building = $Address->xpath('StreetAddress/Building');
         if (count($Building) != 0) {
             $Building = $Building[0];
             $address['number'] = (string) $Building['number'];
         }
         $Street = $Address->xpath('StreetAddress/Street');
         if (count($Street) != 0) {
             $Street = $Street[0];
             $address['street'] = (string) $Street;
         }
         $Places = $Address->xpath('Place');
         foreach ($Places as $Place) {
             $PlaceType = (string) $Place['type'];
             if ($PlaceType == 'Municipality') {
                 $address['municipality'] = (string) $Place;
             } else {
                 if ($PlaceType == 'Departement') {
                     $address['departement'] = (string) $Place;
                 } else {
                     if ($PlaceType == 'Bbox') {
                         $result['bbox'] = explode(';', (string) $Place);
                     }
                 }
             }
         }
         $formatted_address = '';
         if (array_key_exists('number', $address)) {
             $formatted_address = $address['number'] . ' ';
         }
         if (array_key_exists('street', $address) && $address['street'] != '') {
             $formatted_address .= $address['street'] . ', ';
         }
         if (array_key_exists('municipality', $address)) {
             $formatted_address .= $address['municipality'] . ', ';
         }
         if (array_key_exists('departement', $address)) {
             $formatted_address .= $address['departement'];
         }
         $result['formatted_address'] = $formatted_address;
         $results[] = $result;
     }
     $rep->data = $results;
     return $rep;
 }
示例#9
0
 /**
  * Replace a feature attribute value by its html representation
  *
  * @param string $attributeName Feature Attribute name.
  * @param string $attributeValue Feature Attribute value.
  * @param string $repository Lizmap Repository.
  * @param string $project Name of the project.
  * @param string $popupFeatureContent Content of the popup template (created by lizmap plugin) and passed several times. IF false, return only modified attribute.
  * @return string The html for the feature attribute.
  */
 public function getHtmlFeatureAttribute($attributeName, $attributeValue, $repository, $project, $popupFeatureContent = Null)
 {
     // Force $attributeValue to be a string
     $attributeName = (string) $attributeName;
     $attributeValue = (string) $attributeValue;
     if ($attributeValue == 'NULL') {
         $attributeValue = '';
     }
     // Regex to replace links, medias and images
     $urlRegex = '/(ftp|http|https):\\/\\/(\\w+:{0,1}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\\-\\/]))?/';
     $emailRegex = '/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/';
     $imageRegex = '/\\.(jpg|jpeg|png|gif|bmp)$/i';
     $mediaRegex = '/^(\\/)?media\\//';
     $mediaTextRegex = '/\\.(txt|htm|html)$/i';
     // Remote urls and images
     if (preg_match($urlRegex, $attributeValue)) {
         if (preg_match($imageRegex, $attributeValue)) {
             $attributeValue = '<img src="' . $attributeValue . '" border="0"/>';
         } else {
             if (!$popupFeatureContent) {
                 // only if no template is passed by the user
                 $attributeValue = '<a href="' . $attributeValue . '" target="_blank">' . $attributeValue . '</a>';
             }
         }
     }
     // E-mail
     if (preg_match($emailRegex, $attributeValue)) {
         if (!$popupFeatureContent) {
             // only if no template is passed by the user
             $attributeValue = '<a href="mailto:' . $attributeValue . '"</td></tr>';
         }
     }
     // Media = file stored in the repository media folder
     if (preg_match($mediaRegex, $attributeValue)) {
         $sharps = array();
         preg_match('/(.+)#(page=[0-9]+)$/i', $attributeValue, $sharps);
         if (count($sharps) == 3) {
             $pathVal = $sharps[1];
             $sharp = $sharps[2];
         } else {
             $pathVal = $attributeValue;
             $sharp = '';
         }
         $mediaUrl = jUrl::getFull('view~media:getMedia', array('repository' => $repository, 'project' => $project, 'path' => $pathVal), 0, $_SERVER['SERVER_NAME']);
         if ($sharp) {
             $mediaUrl .= '#' . $sharp;
         }
         // Display if it is an image
         if (preg_match($imageRegex, $attributeValue)) {
             if (!$popupFeatureContent) {
                 // only if no template is passed by the user
                 $attributeValue = '<a href="' . $mediaUrl . '" target="_blank"><img src="' . $mediaUrl . '" border="0"/></a>';
             } else {
                 $attributeValue = $mediaUrl;
             }
         } else {
             if (preg_match($mediaTextRegex, $attributeValue)) {
                 $data = '';
                 // Get full path to the file
                 $lrep = lizmap::getRepository($repository);
                 $repositoryPath = realpath($lrep->getPath());
                 $abspath = realpath($repositoryPath . '/' . $attributeValue);
                 $n_repositoryPath = str_replace('\\', '/', $repositoryPath);
                 $n_abspath = str_replace('\\', '/', $abspath);
                 if (preg_match("#^" . $n_repositoryPath . "(/)?media/#", $n_abspath) and file_exists($abspath)) {
                     $data = jFile::read($abspath);
                 }
                 // Replace images src by full path
                 $iUrl = jUrl::get('view~media:getMedia', array('repository' => $repository, 'project' => $project));
                 $data = preg_replace('#src="(.+(jpg|jpeg|gif|png))"?#i', 'src="' . $iUrl . '&path=$1"', $data);
                 $attributeValue = $data;
             } else {
                 if (!$popupFeatureContent) {
                     // only if no template is passed by the user
                     $attributeValue = '<a href="' . $mediaUrl . '" target="_blank">' . $attributeValue . '</a>';
                 } else {
                     $attributeValue = $mediaUrl;
                 }
             }
         }
     } else {
         $attributeValue = preg_replace('#\\n#', '<br>', $attributeValue);
     }
     // Return the modified template or only the resulted attribute value
     if ($popupFeatureContent) {
         // Replace {$mycol} by the processed column value
         $popupFeatureContent = preg_replace('#\\{\\$' . $attributeName . '\\}#i', $attributeValue, $popupFeatureContent);
         return $popupFeatureContent;
     } else {
         // Return the modified attributeValue
         return $attributeValue;
     }
 }
 protected function _prepareTpl()
 {
     $protocol = jApp::coord()->request->getProtocol();
     $this->_tpl->assign('protocol', $protocol);
     $domain = jApp::coord()->request->getDomainName();
     $this->_tpl->assign('domain', $domain);
     $maps = array();
     // Get repository data
     $repository = $this->param('repository');
     $repositories = array();
     if ($repository != null && jAcl2::check('lizmap.repositories.view', $repository)) {
         $repositories[] = $repository;
     } else {
         $repositories = lizmap::getRepositoryList();
     }
     foreach ($repositories as $r) {
         if (jAcl2::check('lizmap.repositories.view', $r)) {
             $lrep = lizmap::getRepository($r);
             $mrep = new lizmapMainViewItem($r, $lrep->getData('label'));
             $lprojects = $lrep->getProjects();
             foreach ($lprojects as $p) {
                 if (!$p->checkAcl()) {
                     continue;
                 }
                 $mrep->childItems[] = new lizmapMainViewItem($p->getData('id'), $p->getData('title'), $p->getData('abstract'), $p->getData('proj'), $p->getData('bbox'), jUrl::getFull('view~map:index', array("repository" => $p->getData('repository'), "project" => $p->getData('id'))), jUrl::getFull('view~media:illustration', array("repository" => $p->getData('repository'), "project" => $p->getData('id'))), 0, $r, 'map');
             }
             $maps[$r] = $mrep;
         }
     }
     $req = jApp::coord()->request;
     $items = jEvent::notify('mainviewGetMaps')->getResponse();
     foreach ($items as $item) {
         if ($item->parentId) {
             if (!isset($maps[$item->parentId])) {
                 $maps[$item->parentId] = new lizmapMainViewItem($item->parentId, '', '');
             }
             $replaced = false;
             foreach ($maps[$item->parentId]->childItems as $k => $i) {
                 if ($i->id == $item->id) {
                     if (!preg_match('/^http/', $item->img)) {
                         $item->img = $req->getServerURI() . $item->img;
                     }
                     if (!preg_match('/^http/', $item->url)) {
                         $item->url = $req->getServerURI() . $item->url;
                     }
                     $maps[$item->parentId]->childItems[$k] = $item;
                     $replaced = true;
                 }
             }
             if (!$replaced) {
                 $maps[$item->parentId]->childItems[] = $item;
             }
         } else {
             if (isset($maps[$item->id])) {
                 $item->img = $maps[$item->id]->img;
                 $maps[$item->id]->copyFrom($item);
             } else {
                 $maps[$item->id] = $item;
             }
         }
     }
     usort($maps, "mainViewItemSort");
     foreach ($maps as $topitem) {
         usort($topitem->childItems, "mainViewItemSort");
     }
     $this->_tpl->assign('mapitems', $maps);
 }
 function testGetFullUrl()
 {
     global $gJConfig, $gJCoord;
     $gJCoord->request->urlScriptPath = '/';
     $gJCoord->request->params = array();
     //$gJCoord->request->type=;
     $gJConfig->urlengine = array('engine' => 'basic_significant', 'enableParser' => true, 'multiview' => false, 'basePath' => '/', 'defaultEntrypoint' => 'index', 'entrypointExtension' => '.php', 'notfoundAct' => 'jelix~error:notfound', 'simple_urlengine_https' => 'jelix_tests~urlsig:url8@classic @xmlrpc', 'significantFile' => 'urls.xml');
     /*
      parameters
         $_SERVER['HTTPS'] ou non
         $_SERVER['SERVER_NAME'] ou $gJConfig->domainName
         given domainName ou pas
         jelix_tests~urlsig:url3 (http) ou jelix_tests~urlsig:url8 (https)
     */
     $_SERVER['SERVER_NAME'] = 'testapp.local';
     $_SERVER['SERVER_PORT'] = '80';
     // ================= HTTP URL
     unset($_SERVER['HTTPS']);
     // without given domain name, without domain name in config, without https
     $gJConfig->domainName = '';
     jUrl::getEngine(true);
     $url = jUrl::getFull('jelix_tests~urlsig:url1', array(), 0, null);
     $this->assertEqual('http://testapp.local/index.php/jelix_tests/urlsig/url1', $url);
     $url = jUrl::getFull('jelix_tests~urlsig:url8', array(), 0, null);
     $this->assertEqual('https://testapp.local/index.php/jelix_tests/urlsig/url8', $url);
     // with given domain name, without domain name in config, without https
     $url = jUrl::getFull('jelix_tests~urlsig:url1', array(), 0, 'football.local');
     $this->assertEqual('http://football.local/index.php/jelix_tests/urlsig/url1', $url);
     $url = jUrl::getFull('jelix_tests~urlsig:url8', array(), 0, 'football.local');
     $this->assertEqual('https://football.local/index.php/jelix_tests/urlsig/url8', $url);
     // without given domain name, with domain name in config, without https
     $gJConfig->domainName = 'configdomain.local';
     jUrl::getEngine(true);
     $url = jUrl::getFull('jelix_tests~urlsig:url1', array(), 0, null);
     $this->assertEqual('http://configdomain.local/index.php/jelix_tests/urlsig/url1', $url);
     $url = jUrl::getFull('jelix_tests~urlsig:url8', array(), 0, null);
     $this->assertEqual('https://configdomain.local/index.php/jelix_tests/urlsig/url8', $url);
     // with given domain name, with domain name in config, without https
     $url = jUrl::getFull('jelix_tests~urlsig:url1', array(), 0, 'football.local');
     $this->assertEqual('http://football.local/index.php/jelix_tests/urlsig/url1', $url);
     $url = jUrl::getFull('jelix_tests~urlsig:url8', array(), 0, 'football.local');
     $this->assertEqual('https://football.local/index.php/jelix_tests/urlsig/url8', $url);
     $_SERVER['HTTPS'] = 'on';
     $_SERVER['SERVER_PORT'] = '443';
     // without given domain name, without domain name in config, with https
     $gJConfig->domainName = '';
     jUrl::getEngine(true);
     $url = jUrl::getFull('jelix_tests~urlsig:url1', array(), 0, null);
     $this->assertEqual('https://testapp.local/index.php/jelix_tests/urlsig/url1', $url);
     $url = jUrl::getFull('jelix_tests~urlsig:url8', array(), 0, null);
     $this->assertEqual('https://testapp.local/index.php/jelix_tests/urlsig/url8', $url);
     // with given domain name, without domain name in config, with https
     $url = jUrl::getFull('jelix_tests~urlsig:url1', array(), 0, 'football.local');
     $this->assertEqual('https://football.local/index.php/jelix_tests/urlsig/url1', $url);
     $url = jUrl::getFull('jelix_tests~urlsig:url8', array(), 0, 'football.local');
     $this->assertEqual('https://football.local/index.php/jelix_tests/urlsig/url8', $url);
     // without given domain name, with domain name in config, with https
     $gJConfig->domainName = 'configdomain.local';
     jUrl::getEngine(true);
     $url = jUrl::getFull('jelix_tests~urlsig:url1', array(), 0, null);
     $this->assertEqual('https://configdomain.local/index.php/jelix_tests/urlsig/url1', $url);
     $url = jUrl::getFull('jelix_tests~urlsig:url8', array(), 0, null);
     $this->assertEqual('https://configdomain.local/index.php/jelix_tests/urlsig/url8', $url);
     // with given domain name, with domain name in config, with https
     $url = jUrl::getFull('jelix_tests~urlsig:url1', array(), 0, 'football.local');
     $this->assertEqual('https://football.local/index.php/jelix_tests/urlsig/url1', $url);
     $url = jUrl::getFull('jelix_tests~urlsig:url8', array(), 0, 'football.local');
     $this->assertEqual('https://football.local/index.php/jelix_tests/urlsig/url8', $url);
 }
 /**
  * Read the qgis files
  */
 protected function readXml($key, $rep)
 {
     $qgs_path = $rep->getPath() . $key . '.qgs';
     if (!file_exists($qgs_path) || !file_exists($qgs_path . '.cfg')) {
         throw new Exception("Files of project {$key} does not exists");
     }
     $config = jFile::read($qgs_path . '.cfg');
     $this->cfg = json_decode($config);
     if ($this->cfg === null) {
         throw new Exception(".qgs.cfg File of project {$key} has invalid content");
     }
     $configOptions = $this->cfg->options;
     $qgs_xml = simplexml_load_file($qgs_path);
     if ($qgs_xml === false) {
         throw new Exception("Qgs File of project {$key} has invalid content");
     }
     $this->xml = $qgs_xml;
     $this->data = array('repository' => $rep->getKey(), 'id' => $key, 'title' => ucfirst($key), 'abstract' => '', 'proj' => $configOptions->projection->ref, 'bbox' => join($configOptions->bbox, ', '));
     # get title from WMS properties
     if (property_exists($qgs_xml->properties, 'WMSServiceTitle')) {
         if (!empty($qgs_xml->properties->WMSServiceTitle)) {
             $this->data['title'] = (string) $qgs_xml->properties->WMSServiceTitle;
         }
     }
     # get abstract from WMS properties
     if (property_exists($qgs_xml->properties, 'WMSServiceAbstract')) {
         $this->data['abstract'] = (string) $qgs_xml->properties->WMSServiceAbstract;
     }
     # get WMS getCapabilities full URL
     $this->data['wmsGetCapabilitiesUrl'] = jUrl::getFull('lizmap~service:index', array('repository' => $rep->getKey(), 'project' => $key, 'SERVICE' => 'WMS', 'VERSION' => '1.3.0', 'REQUEST' => 'GetCapabilities'));
     # get WMTS getCapabilities full URL
     $this->data['wmtsGetCapabilitiesUrl'] = jUrl::getFull('lizmap~service:index', array('repository' => $rep->getKey(), 'project' => $key, 'SERVICE' => 'WMTS', 'VERSION' => '1.0.0', 'REQUEST' => 'GetCapabilities'));
     // get QGIS project version
     $qgisRoot = $qgs_xml->xpath('//qgis');
     $qgisRootZero = $qgisRoot[0];
     $qgisProjectVersion = (string) $qgisRootZero->attributes()->version;
     $qgisProjectVersion = explode('-', $qgisProjectVersion);
     $qgisProjectVersion = $qgisProjectVersion[0];
     $qgisProjectVersion = explode('.', $qgisProjectVersion);
     $a = '';
     foreach ($qgisProjectVersion as $k) {
         if (strlen($k) == 1) {
             $a .= $k . '0';
         } else {
             $a .= $k;
         }
     }
     $qgisProjectVersion = (int) $a;
     $this->qgisProjectVersion = $qgisProjectVersion;
     $shortNames = $qgs_xml->xpath('//maplayer/shortname');
     if ($shortNames && count($shortNames) > 0) {
         foreach ($shortNames as $sname) {
             $sname = (string) $sname;
             $xmlLayer = $qgs_xml->xpath("//maplayer[shortname='{$sname}']");
             $xmlLayer = $xmlLayer[0];
             $name = (string) $xmlLayer->layername;
             if (property_exists($this->cfg->layers, $name)) {
                 $this->cfg->layers->{$name}->shortname = $sname;
             }
         }
     }
     $groupsWithShortName = $qgs_xml->xpath("//layer-tree-group/customproperties/property[@key='wmsShortName']/parent::*/parent::*");
     if ($groupsWithShortName && count($groupsWithShortName) > 0) {
         foreach ($groupsWithShortName as $group) {
             $name = (string) $group['name'];
             $shortNameProperty = $group->xpath("customproperties/property[@key='wmsShortName']");
             if ($shortNameProperty && count($shortNameProperty) > 0) {
                 $shortNameProperty = $shortNameProperty[0];
                 $sname = (string) $shortNameProperty['value'];
                 if (property_exists($this->cfg->layers, $name)) {
                     $this->cfg->layers->{$name}->shortname = $sname;
                 }
             }
         }
     }
     $layersWithShowFeatureCount = $qgs_xml->xpath("//layer-tree-layer/customproperties/property[@key='showFeatureCount']/parent::*/parent::*");
     if ($layersWithShowFeatureCount && count($layersWithShowFeatureCount) > 0) {
         foreach ($layersWithShowFeatureCount as $layer) {
             $name = (string) $layer['name'];
             if (property_exists($this->cfg->layers, $name)) {
                 $this->cfg->layers->{$name}->showFeatureCount = 'True';
             }
         }
     }
     //remove plugin layer
     $pluginLayers = $qgs_xml->xpath('//maplayer[type="plugin"]');
     if ($pluginLayers && count($pluginLayers) > 0) {
         foreach ($pluginLayers as $layer) {
             $name = (string) $layer->layername;
             if (property_exists($this->cfg->layers, $name)) {
                 unset($this->cfg->layers->{$name});
             }
         }
     }
     //unset cache for editionLayers
     if (property_exists($this->cfg, 'editionLayers')) {
         foreach ($this->cfg->editionLayers as $key => $obj) {
             if (property_exists($this->cfg->layers, $key)) {
                 $this->cfg->layers->{$key}->cached = 'False';
                 $this->cfg->layers->{$key}->clientCacheExpiration = 0;
                 if (property_exists($this->cfg->layers->{$key}, 'cacheExpiration')) {
                     unset($this->cfg->layers->{$key}->cacheExpiration);
                 }
             }
         }
     }
     //unset cache for loginFilteredLayers
     if (property_exists($this->cfg, 'loginFilteredLayers')) {
         foreach ($this->cfg->loginFilteredLayers as $key => $obj) {
             if (property_exists($this->cfg->layers, $key)) {
                 $this->cfg->layers->{$key}->cached = 'False';
                 $this->cfg->layers->{$key}->clientCacheExpiration = 0;
                 if (property_exists($this->cfg->layers->{$key}, 'cacheExpiration')) {
                     unset($this->cfg->layers->{$key}->cacheExpiration);
                 }
             }
         }
     }
     //unset displayInLegend for geometryType none or unknown
     foreach ($this->cfg->layers as $key => $obj) {
         if (property_exists($this->cfg->layers->{$key}, 'geometryType') && ($this->cfg->layers->{$key}->geometryType == 'none' || $this->cfg->layers->{$key}->geometryType == 'unknown')) {
             $this->cfg->layers->{$key}->displayInLegend = 'False';
         }
     }
     $this->WMSInformation = $this->readWMSInformation($qgs_xml);
     $this->canvasColor = $this->readCanvasColor($qgs_xml);
     $this->allProj4 = $this->readAllProj4($qgs_xml);
     $this->relations = $this->readRelations($qgs_xml);
     $this->layersOrder = $this->readLayersOrder($qgs_xml);
     $this->printCapabilities = $this->readPrintCapabilities($qgs_xml, $this->cfg);
     $this->locateByLayer = $this->readLocateByLayers($qgs_xml, $this->cfg);
     $this->editionLayers = $this->readEditionLayers($qgs_xml, $this->cfg);
     $this->useLayerIDs = $this->readUseLayerIDs($qgs_xml);
     $this->layers = $this->readLayers($qgs_xml);
 }
示例#13
0
 /**
  * provide a atom feeds for each forum
  */
 function atom()
 {
     $ftitle = jUrl::unescape($this->param('ftitle'), true);
     $id_forum = $this->intParam('id_forum');
     // if the forum is accessible by anonymous then the Atom will be available
     // otherwise NO Atom will be available
     if (!jAcl2::check('hfnu.posts.rss', 'forum' . $id_forum)) {
         jMessage::add(jLocale::get('havefnubb~main.permissions.denied'), 'error');
         $rep = $this->getResponse('html');
         $tpl = new jTpl();
         $rep->body->assign('MAIN', $tpl->fetch('havefnubb~403.html'));
         $rep->setHttpStatus('403', 'Permission denied');
         return $rep;
     }
     if ($id_forum == 0) {
         jLog::log(__METHOD__ . ' line : ' . __LINE__ . ' [this should not be 0] $id_forum', 'DEBUG');
         $rep = $this->getResponse('html');
         $tpl = new jTpl();
         $rep->body->assign('MAIN', $tpl->fetch('havefnubb~404.html'));
         $rep->setHttpStatus('404', 'Not found');
         return $rep;
     }
     $rep = $this->getResponse('atom1.0');
     $gJConfig = jApp::config();
     // entete du flux atom
     $rep->infos->title = $gJConfig->havefnubb['title'];
     $rep->infos->webSiteUrl = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST'];
     $rep->infos->copyright = $gJConfig->havefnubb['title'];
     $rep->infos->description = $gJConfig->havefnubb['description'];
     $rep->infos->updated = date('Y-m-d H:i:s');
     $rep->infos->published = date('Y-m-d H:i:s');
     $rep->infos->selfLink = jUrl::get('havefnubb~posts:atom', array('ftitle' => $ftitle, 'id_forum' => $fid_forum));
     $rep->infos->ttl = 60;
     $dao = jDao::get('havefnubb~forum');
     $forum = $dao->get($id_forum);
     if (jUrl::escape($forum->forum_name, true) != $ftitle) {
         jLog::log(__METHOD__ . ' line : ' . __LINE__ . ' [this should not be different] $forum->forum_name and $ftitle', 'DEBUG');
         $rep = $this->getResponse('html');
         $tpl = new jTpl();
         $rep->body->assign('MAIN', $tpl->fetch('havefnubb~404.html'));
         $rep->setHttpStatus('404', 'Not found');
         return $rep;
     }
     // 1- limit of posts
     $nbPostPerPage = 0;
     $nbPostPerPage = (int) $gJConfig->havefnubb['posts_per_page'];
     // 2- get the posts of the current forum, limited by point 1
     // get all the posts of the current Forum by its Id
     list($page, $nbPosts, $posts) = jClasses::getService('havefnubb~hfnuposts')->getThreads($id_forum, 0, $nbPostPerPage);
     $first = true;
     foreach ($posts as $post) {
         if ($first) {
             // le premier enregistrement permet de connaitre
             // la date du channel
             $rep->infos->updated = date('Y-m-d H:i:s', $post->date_created);
             $rep->infos->published = date('Y-m-d H:i:s', $post->date_created);
             $first = false;
         }
         $url = jUrl::getFull('havefnubb~posts:view', array('id_post' => $post->id_post, 'thread_id' => $post->thread_id, 'ftitle' => $post->forum_name, 'id_forum' => $post->id_forum, 'ptitle' => $post->subject));
         $item = $rep->createItem($post->subject, $url, date('Y-m-d H:i:s', $post->date_created));
         $item->authorName = $post->login;
         $render = new jWiki();
         $item->content = $render->render($post->message);
         $item->contentType = 'html';
         $item->idIsPermalink = true;
         // on ajoute l'item dans le fil atom
         $rep->addItem($item);
     }
     return $rep;
 }
示例#14
0
/**
* @package    jelix
* @subpackage jtpl_plugin
* @author     Mickael Fradin
* @contributor Laurent Jouanneau
* @copyright  2009 Mickael Fradin
* @link       http://www.jelix.org
* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
*/
function jtpl_function_text_jfullurl($tpl, $selector, $params = array(), $domain = false)
{
    echo jUrl::getFull($selector, $params, 0, $domain);
}