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


PHP CRM_Utils_File::relativize方法代码示例

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


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

示例1: getCiviSourceStorage

 /**
  * Determine the location of the CiviCRM source tree.
  *
  * @return array
  *   - url: string. ex: "http://example.com/sites/all/modules/civicrm"
  *   - path: string. ex: "/var/www/sites/all/modules/civicrm"
  */
 public function getCiviSourceStorage()
 {
     global $civicrm_root;
     // Don't use $config->userFrameworkBaseURL; it has garbage on it.
     // More generally, we shouldn't be using $config here.
     if (!defined('CIVICRM_UF_BASEURL')) {
         throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
     }
     $cmsPath = $this->cmsRootPath();
     // $config  = CRM_Core_Config::singleton();
     // overkill? // $cmsUrl = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
     $cmsUrl = CIVICRM_UF_BASEURL;
     if (CRM_Utils_System::isSSL()) {
         $cmsUrl = str_replace('http://', 'https://', $cmsUrl);
     }
     $civiRelPath = CRM_Utils_File::relativize($civicrm_root, $cmsPath);
     $civiUrl = rtrim($cmsUrl, '/') . '/' . ltrim($civiRelPath, ' /');
     return array('url' => CRM_Utils_File::addTrailingSlash($civiUrl, '/'), 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root));
 }
开发者ID:sarehag,项目名称:civicrm-core,代码行数:26,代码来源:WordPress.php

示例2: glob

 /**
  * Evaluate a glob pattern in the context of a particular extension.
  *
  * @param string $ext
  *   Extension name; use 'civicrm' for core.
  * @param string|array $patterns
  *   Glob pattern; e.g. "*.html".
  * @param null|int $flags
  *   See glob().
  * @return array
  *   List of matching files, relative to the extension base dir.
  * @see glob()
  */
 public function glob($ext, $patterns, $flags = NULL)
 {
     $path = $this->getPath($ext);
     $patterns = (array) $patterns;
     $files = array();
     foreach ($patterns as $pattern) {
         if (CRM_Utils_File::isAbsolute($pattern)) {
             // Absolute path.
             $files = array_merge($files, (array) glob($pattern, $flags));
         } else {
             // Relative path.
             $files = array_merge($files, (array) glob("{$path}/{$pattern}", $flags));
         }
     }
     sort($files);
     // Deterministic order.
     $files = array_unique($files);
     return array_map(function ($file) use($path) {
         return CRM_Utils_File::relativize($file, "{$path}/");
     }, $files);
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:34,代码来源:Resources.php

示例3: getRelPaths

 /**
  * Scan $basedir for a list of extension-keys
  *
  * @return array
  *   ($key => $relPath)
  */
 protected function getRelPaths()
 {
     if (!is_array($this->relPaths)) {
         if ($this->cache) {
             $this->relPaths = $this->cache->get($this->cacheKey);
         }
         if (!is_array($this->relPaths)) {
             $this->relPaths = array();
             $infoPaths = CRM_Utils_File::findFiles($this->baseDir, 'info.xml');
             foreach ($infoPaths as $infoPath) {
                 $relPath = CRM_Utils_File::relativize(dirname($infoPath), $this->baseDir);
                 try {
                     $info = CRM_Extension_Info::loadFromFile($infoPath);
                 } catch (CRM_Extension_Exception_ParseException $e) {
                     CRM_Core_Session::setStatus(ts('Parse error in extension: %1', array(1 => $e->getMessage())), '', 'error');
                     CRM_Core_Error::debug_log_message("Parse error in extension: " . $e->getMessage());
                     continue;
                 }
                 $this->relPaths[$info->key] = $relPath;
             }
             if ($this->cache) {
                 $this->cache->set($this->cacheKey, $this->relPaths);
             }
         }
     }
     return $this->relPaths;
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:33,代码来源:Basic.php

示例4: findFiles

 /**
  * Search directory tree for files which match a glob pattern.
  *
  * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
  *
  * @param string $dir
  *   base dir.
  * @param string $pattern
  *   glob pattern, eg "*.txt".
  * @param bool $relative
  *   TRUE if paths should be made relative to $dir
  * @return array(string)
  */
 public static function findFiles($dir, $pattern, $relative = FALSE)
 {
     if (!is_dir($dir)) {
         return array();
     }
     $dir = rtrim($dir, '/');
     $todos = array($dir);
     $result = array();
     while (!empty($todos)) {
         $subdir = array_shift($todos);
         $matches = glob("{$subdir}/{$pattern}");
         if (is_array($matches)) {
             foreach ($matches as $match) {
                 if (!is_dir($match)) {
                     $result[] = $relative ? CRM_Utils_File::relativize($match, "{$dir}/") : $match;
                 }
             }
         }
         if ($dh = opendir($subdir)) {
             while (FALSE !== ($entry = readdir($dh))) {
                 $path = $subdir . DIRECTORY_SEPARATOR . $entry;
                 if ($entry[0] == '.') {
                     // ignore
                 } elseif (is_dir($path)) {
                     $todos[] = $path;
                 }
             }
             closedir($dh);
         }
     }
     return $result;
 }
开发者ID:routinet,项目名称:civicrm-core,代码行数:45,代码来源:File.php


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