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


PHP Folder::getRelativePath方法代码示例

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


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

示例1: __construct

 public function __construct($path, $name = '')
 {
     $gantry = \Gantry\Framework\Gantry::instance();
     $relpath = Folder::getRelativePath($path);
     // Initialize admin streams.
     /** @var Platform $patform */
     $patform = $gantry['platform'];
     $nucleus = $patform->getEnginePaths('nucleus')[''];
     $patform->set('streams.gantry-admin.prefixes', ['' => ['gantry-theme://admin', $relpath, $relpath . '/common', 'gantry-engine://admin'], 'assets/' => array_merge([$relpath, $relpath . '/common'], $nucleus, ['gantry-assets://'])]);
     $gantry['particles'] = function ($c) {
         return new Particles($c);
     };
     $gantry['styles'] = function ($c) {
         return new Styles($c);
     };
     $gantry['defaults'] = function ($c) {
         /** @var UniformResourceLocator $locator */
         $locator = $c['locator'];
         $cache = $locator->findResource('gantry-cache://theme/compiled/config', true, true);
         $paths = $locator->findResources('gantry-config://default');
         $files = (new ConfigFileFinder())->locateFiles($paths);
         $config = new CompiledConfig($cache, $files, function () use($c) {
             return $c['blueprints'];
         });
         return $config->load(true);
     };
     parent::__construct($path, $name);
     $this->boot();
 }
开发者ID:naka211,项目名称:myloyal,代码行数:29,代码来源:Theme.php

示例2: init

 /**
  * @see AbstractTheme::init()
  */
 protected function init()
 {
     $gantry = static::gantry();
     // Add particles, styles and defaults into DI.
     $gantry['particles'] = function ($c) {
         return new Particles($c);
     };
     $gantry['styles'] = function ($c) {
         return new Styles($c);
     };
     $gantry['defaults'] = function ($c) {
         /** @var UniformResourceLocator $locator */
         $locator = $c['locator'];
         $cache = $locator->findResource('gantry-cache://theme/compiled/config', true, true);
         $paths = $locator->findResources('gantry-config://default');
         $files = (new ConfigFileFinder())->locateFiles($paths);
         $config = new CompiledConfig($cache, $files, function () use($c) {
             return $c['blueprints'];
         });
         return $config->load(true);
     };
     // Initialize admin streams.
     /** @var Platform $patform */
     $patform = $gantry['platform'];
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $nucleus = $patform->getEnginePaths('nucleus')[''];
     $relpath = Folder::getRelativePath($this->path);
     $patform->set('streams.gantry-admin.prefixes', ['' => ['gantry-theme://admin', $relpath, $relpath . '/common', 'gantry-engine://admin'], 'assets/' => array_merge([$relpath, $relpath . '/common'], $nucleus, ['gantry-assets://'])]);
     // Add admin paths.
     foreach ($patform->get('streams.gantry-admin.prefixes') as $prefix => $paths) {
         $locator->addPath('gantry-admin', $prefix, $paths);
     }
 }
开发者ID:rastabrane,项目名称:gantry5,代码行数:37,代码来源:Theme.php

示例3: boot

 protected function boot()
 {
     $gantry = \Gantry\Framework\Gantry::instance();
     $relpath = Folder::getRelativePath($this->path);
     /** @var Streams $streams */
     $streams = $gantry['streams'];
     $streams->add(['gantry-admin' => ['prefixes' => ['' => ['gantry-theme://admin', $relpath, $relpath . '/common'], 'assets/' => ['gantry-theme://admin', $relpath, $relpath . '/common']]]]);
     $streams->register();
 }
开发者ID:Acidburn0zzz,项目名称:gantry5,代码行数:9,代码来源:Theme.php

示例4: __construct

 public function __construct($path, $name = '')
 {
     $gantry = \Gantry\Framework\Gantry::instance();
     $relpath = Folder::getRelativePath($path);
     // Initialize admin streams.
     $gantry['platform']->set('streams.gantry-admin.prefixes', ['' => [$relpath, $relpath . '/common'], 'assets/' => [$relpath, $relpath . '/common']]);
     parent::__construct($path, $name);
     // FIXME:
     $this->url = '/templates/' . $this->name;
     $this->boot();
 }
开发者ID:nmsde,项目名称:gantry5,代码行数:11,代码来源:Theme.php

示例5: attachData

 protected function attachData(&$node, $iteration)
 {
     foreach (['getFilename', 'getExtension', 'getPerms', 'getMTime', 'getBasename', 'getPathname', 'getSize', 'getType', 'isReadable', 'isWritable', 'isDir', 'isFile'] as $method) {
         $keyMethod = strtolower(preg_replace("/^(is|get)/", '', $method));
         $node->{$keyMethod} = $iteration->{$method}();
         if ($method == 'getPathname') {
             $node->{$keyMethod} = $this->isStream ? $iteration->getUrl() : Folder::getRelativePath($node->{$keyMethod});
         } else {
             if ($method == 'getExtension') {
                 $node->isImage = in_array($node->{$keyMethod}, ['jpg', 'jpeg', 'png', 'gif', 'ico', 'svg', 'bmp']);
             }
         }
     }
 }
开发者ID:naka211,项目名称:myloyal,代码行数:14,代码来源:Filepicker.php

示例6: getThemesPaths

 public function getThemesPaths()
 {
     return ['' => Folder::getRelativePath(get_theme_root())];
 }
开发者ID:juanmanunez,项目名称:gantry5,代码行数:4,代码来源:Platform.php

示例7: setBasePath

 public function setBasePath($basePath)
 {
     $this->basePath = '/' . Folder::getRelativePath($basePath);
 }
开发者ID:sam-suresh,项目名称:gantry5,代码行数:4,代码来源:Compiler.php

示例8: dirname

<?php

use Gantry\Component\Filesystem\Folder;
define('PRIME_ROOT', dirname($_SERVER['SCRIPT_FILENAME']));
define('PRIME_URI', dirname($_SERVER['SCRIPT_NAME']));
date_default_timezone_set('UTC');
// Bootstrap Gantry framework or fail gracefully (inside included file).
$gantry = (include_once PRIME_ROOT . '/includes/gantry.php');
// Get current theme and path.
$path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : Folder::getRelativePath($_SERVER['REQUEST_URI'], PRIME_URI);
$path = explode('?', $path, 2);
$path = reset($path);
$extension = strrchr(basename($path), '.');
if ($extension) {
    $path = substr($path, 0, -strlen($extension));
}
$theme = strpos($path, 'admin') !== 0 ? Folder::shift($path) : null;
define('THEME', $theme);
define('PAGE_PATH', $path ?: ($theme ? 'home' : ''));
define('PAGE_EXTENSION', trim($extension, '.') ?: 'html');
// Bootstrap selected theme.
$include = PRIME_ROOT . "/themes/{$theme}/includes/gantry.php";
if (is_file($include)) {
    include $include;
}
// Enter to administration if we are in /ROOT/theme/admin. Also display installed themes if no theme has been selected.
if (!isset($gantry['theme']) || strpos($path, 'admin') === 0) {
    require_once PRIME_ROOT . '/admin/admin.php';
    exit;
}
// Boot the service.
开发者ID:Tanver186,项目名称:gantry5,代码行数:31,代码来源:index.php

示例9: detectAll

 /**
  * Detects all plugins with a configuration file and returns them with last modification time.
  *
  * @param  string $folder   Location to look up from.
  * @param  string $pattern  Pattern to match the file. Pattern will also be removed from the key.
  * @param  int    $levels   Maximum number of recursive directories.
  * @return array
  * @internal
  */
 protected function detectAll($folder, $pattern, $levels)
 {
     $path = trim(Folder::getRelativePath($folder), '/');
     if (is_dir($folder)) {
         // Find all system and user configuration files.
         $options = ['levels' => $levels, 'compare' => 'Filename', 'pattern' => $pattern, 'filters' => ['pre-key' => $this->base, 'key' => $pattern, 'value' => function (\RecursiveDirectoryIterator $file) use($path) {
             return ["{$path}/{$file->getSubPathname()}" => $file->getMTime()];
         }], 'key' => 'SubPathname'];
         $list = Folder::all($folder, $options);
         ksort($list);
     } else {
         $list = [];
     }
     return $list;
 }
开发者ID:ericssonm,项目名称:JusCuzCustoms,代码行数:24,代码来源:ConfigFileFinder.php

示例10: getCachePath

 /**
  * @return string
  */
 public function getCachePath()
 {
     return Folder::getRelativePath(\Mage::getBaseDir('cache')) . '/gantry5';
 }
开发者ID:Acidburn0zzz,项目名称:gantry5,代码行数:7,代码来源:Platform.php

示例11: index

 public function index()
 {
     /** @var UniformResourceLocator $locator */
     $locator = $this->container['locator'];
     $base = $locator->base;
     $bookmarks = [];
     $drives = [DS];
     $subfolder = false;
     $filter = false;
     if (isset($_POST)) {
         $drives = isset($_POST['root']) ? $_POST['root'] != 'false' ? $_POST['root'] : [DS] : [DS];
         $subfolder = isset($_POST['subfolder']) ? true : false;
         $filter = isset($_POST['filter']) ? $_POST['filter'] != 'false' ? $_POST['filter'] : false : false;
     }
     if (!is_array($drives)) {
         $drives = [$drives];
     }
     foreach ($drives as $drive) {
         // cleanup of the path so it's chrooted.
         $drive = str_replace('..', '', $drive);
         $stream = explode('://', $drive);
         $scheme = $stream[0];
         $isStream = $locator->schemeExists($scheme);
         $path = rtrim($base, DS) . DS . ltrim($scheme, DS);
         // It's a stream but the scheme doesn't exist. we skip it.
         if (!$isStream && (count($stream) == 2 || !file_exists($path))) {
             continue;
         }
         if ($isStream && !count($resources = $locator->findResources($drive, false))) {
             continue;
         }
         $key = $isStream ? $drive : preg_replace('#' . DS . '{2,}+#', DS, $drive);
         if (!array_key_exists($key, $bookmarks)) {
             $bookmarks[$key] = $isStream ? $resources : [rtrim(Folder::getRelativePath($path), DS) . DS];
         }
     }
     if (!count($bookmarks)) {
         throw new \RuntimeException((count($drives) > 1 ? 'directories' : 'directory') . ' "' . implode('", "', $drives) . '" not found', 404);
     }
     $files = new \ArrayObject();
     $folders = [];
     $active = [];
     $index = 0;
     // iterating the folder and collecting subfolders and files
     foreach ($bookmarks as $key => $bookmark) {
         $folders[$key] = [];
         if (!$index) {
             $active[] = $key;
         }
         foreach ($bookmark as $folder) {
             $folders[$key][$folder] = new \ArrayObject();
             if (!$index) {
                 $active[] = $folder;
             }
             /** @var \SplFileInfo $info */
             foreach (new \DirectoryIterator($base . DS . ltrim($folder, DS)) as $info) {
                 // no dot files nor files beginning with dot
                 if ($info->isDot() || substr($info->getFilename(), 0, 1) == '.') {
                     continue;
                 }
                 $file = new \stdClass();
                 foreach (['getFilename', 'getExtension', 'getPerms', 'getMTime', 'getBasename', 'getPathname', 'getSize', 'getType', 'isReadable', 'isWritable', 'isDir', 'isFile'] as $method) {
                     $keyMethod = strtolower(preg_replace("/^(is|get)/", '', $method));
                     $file->{$keyMethod} = $info->{$method}();
                     if ($method == 'getPathname') {
                         $file->{$keyMethod} = Folder::getRelativePath($file->{$keyMethod});
                     } else {
                         if ($method == 'getExtension') {
                             $file->isImage = in_array($file->{$keyMethod}, ['jpg', 'jpeg', 'png', 'gif', 'ico', 'svg', 'bmp']);
                         }
                     }
                 }
                 if ($file->dir) {
                     $folders[$key][$folder]->append($file);
                 } else {
                     if ($filter && !preg_match("/" . $filter . "/i", $file->filename)) {
                         continue;
                     }
                     if (!$index) {
                         $files->append($file);
                     }
                 }
             }
             $index++;
         }
     }
     $response = [];
     if (!$subfolder) {
         $response['html'] = $this->container['admin.theme']->render('@gantry-admin/ajax/filepicker.html.twig', ['active' => $active, 'base' => $base, 'bookmarks' => $bookmarks, 'folders' => $folders, 'files' => $files]);
     } else {
         $response['subfolder'] = !$folders[$key][$folder]->count() ? false : $this->container['admin.theme']->render('@gantry-admin/ajax/filepicker/subfolders.html.twig', ['folder' => $folders[$key][$folder]]);
         $response['files'] = !$files->count() ? false : $this->container['admin.theme']->render('@gantry-admin/ajax/filepicker/files.html.twig', ['files' => $files]);
     }
     return new JsonResponse($response);
 }
开发者ID:Ettore495,项目名称:Ettore-Work,代码行数:95,代码来源:Filepicker.php


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