当前位置: 首页>>代码示例>>PHP>>正文


PHP jFile::read方法代码示例

本文整理汇总了PHP中jFile::read方法的典型用法代码示例。如果您正苦于以下问题:PHP jFile::read方法的具体用法?PHP jFile::read怎么用?PHP jFile::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jFile的用法示例。


在下文中一共展示了jFile::read方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * 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;
     }
 }
开发者ID:vincent-petale,项目名称:lizmap-web-client,代码行数:75,代码来源:lizmapProject.class.php

示例2: getCssFile

 /**
  * Get a CSS file stored in the repository in a "media/themes" folder.
  * Url to images are replaced by getMedia URL
  *
  * @param string $repository Repository of the project.
  * @param string $project Project key.
  * @param string $path Path to the CSS file relative to the project file.
  * @return binary object The transformed CSS file.
  */
 function getCssFile()
 {
     // Get repository data
     $repository = $this->param('repository');
     $lrep = lizmap::getRepository($repository);
     if (!jAcl2::check('lizmap.repositories.view', $lrep->getKey())) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'view~default:error';
         jMessage::add(jLocale::get('view~default.repository.access.denied'), 'error');
         return $rep;
     }
     // Get the project
     $project = $this->param('project');
     // Get the file
     $path = $this->param('path');
     $repositoryPath = realpath($lrep->getPath());
     $abspath = realpath($repositoryPath . '/' . $path);
     $n_repositoryPath = str_replace('\\', '/', $repositoryPath);
     $n_abspath = str_replace('\\', '/', $abspath);
     $ok = True;
     // Only allow files within the repository for safety reasons
     // and in the media/themes/ folder
     if (!preg_match("#^" . $n_repositoryPath . "(/)?media/themes/#", $n_abspath)) {
         $ok = False;
     }
     // Check if file exists
     if ($ok and !file_exists($abspath)) {
         $ok = False;
     }
     // Check if file is CSS
     $path_parts = pathinfo($abspath);
     if (strtolower($path_parts['extension']) != 'css') {
         $ok = False;
     }
     // Redirect if errors
     if (!$ok) {
         $content = "No CSS file in the specified path";
         $rep = $this->getResponse('text');
         $rep->content = $content;
         return $rep;
     }
     // Prepare the file to return
     $rep = $this->getResponse('binary');
     $rep->doDownload = false;
     $rep->fileName = $abspath;
     // Get the name of the file
     $name = $path_parts['basename'] . '.' . $path_parts['extension'];
     $rep->outputFileName = $name;
     // Mime type
     $rep->mimeType = 'text/css';
     // Read content from file
     $content = jFile::read($abspath);
     // Replace relative images URL with getMedia URL
     $newPath = preg_replace("#" . $path_parts['basename'] . "\$#", '', $path);
     $baseUrl = jUrl::get('view~media:getMedia', array('repository' => $lrep->getKey(), 'project' => $project, 'path' => $newPath));
     $pattern = 'url\\((.+)\\)';
     $replacement = 'url(' . $baseUrl . '/\\1)';
     $content = preg_replace("#{$pattern}#", $replacement, $content);
     $content = str_replace('"', '', $content);
     $rep->content = $content;
     $rep->setExpires('+60 seconds');
     return $rep;
 }
开发者ID:CREASIG,项目名称:lizmap-web-client,代码行数:72,代码来源:media.classic.php

示例3:

<?php

// check version from 2 files :
// from the defaultconfig.ini.php file
//     and
// from the VERSION file and compare them
$currentVersion = jIniFile::read(jApp::configPath() . 'defaultconfig.ini.php');
$newVersion = jFile::read(jApp::appPath() . 'VERSION');
if (trim($currentVersion['havefnubb']['version']) == trim($newVersion)) {
    $alreadyInstalled = true;
} else {
    $alreadyInstalled = false;
}
// check if the application is already installed
$appInstalled = file_exists(jApp::configPath() . 'installer.ini.php');
开发者ID:havefnubb,项目名称:havefnubb,代码行数:15,代码来源:version.php

示例4: getHtmlFeatureAttribute

 /**
  * 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
//.........这里部分代码省略.........
开发者ID:CREASIG,项目名称:lizmap-web-client,代码行数:101,代码来源:popup.class.php

示例5: extensionsFiles

 protected function extensionsFiles()
 {
     $config = array();
     $dir = "modules/";
     $tpl = new jTpl();
     //
     $iter = new DirectoryIterator($dir);
     foreach ($iter as $file) {
         if (!$file->isDot()) {
             if ($file->isDir() && file_exists($dir . $file->getFilename() . '/urls.json')) {
                 //get the module xml file
                 $doc = jFile::read($dir . $file->getFilename() . '/urls.json');
                 $urls = json_decode($doc);
                 foreach ($urls->jsfiles->head as $row) {
                     $config['head'][] = jUrl::get('jelix~www:getfile', array('targetmodule' => $file->getFilename(), 'file' => $row));
                 }
                 foreach ($urls->jsfiles->bottom as $row) {
                     $config['bottom'][] = jUrl::get('jelix~www:getfile', array('targetmodule' => $file->getFilename(), 'file' => $row));
                 }
             }
         }
     }
     return $config;
 }
开发者ID:aurellemeless,项目名称:favoris,代码行数:24,代码来源:default.classic.php

示例6: readXml

 /**
  * 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) {
//.........这里部分代码省略.........
开发者ID:laurentj,项目名称:lizmap-web-client,代码行数:101,代码来源:lizmapProject.class.php


注:本文中的jFile::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。