/** * @param string $fullPath * @param string $relPath * @return string */ public function compile($fullPath, $relPath) { $this->_initCompiler(); $fullPath = FS::real($fullPath); $result = $this->_compile($fullPath, $relPath); return $result; }
/** * @return string */ protected function _getResultFile() { // Normalize relative path $relPath = Slug::filter($this->_hash, '_'); $relPath = Str::low($relPath); // Gett full clean path $fullPath = FS::real($this->_options->get('cache_path')) . '/' . $relPath . '.css'; $fullPath = FS::clean($fullPath); return $fullPath; }
/** * @param array $options * @return Data * @throws Exception * @SuppressWarnings(PHPMD.Superglobals) */ protected function _prepareOptions(array $options) { // Default data for current system $this->_default['root_url'] = Url::root(); $this->_default['root_path'] = Sys::getDocRoot(); $options = array_merge($this->_default, $options); // Check cache directory $cachePath = FS::clean($options['cache_path']); if (!$cachePath) { throw new Exception('Option "cache_path" is empty!'); } if (!FS::isDir($cachePath)) { mkdir($cachePath, 0755, true); } $options['cache_path'] = FS::real($cachePath); $options['root_url'] = rtrim($options['root_url'], '/'); $options['root_path'] = FS::real($options['root_path']); $options['driver'] = ucfirst(strtolower(trim($options['driver']))); // Check mixin paths $lessFile = (array) $options['autoload']; foreach ($lessFile as $key => $mixin) { $lessFile[$key] = FS::real($mixin); } $options['autoload'] = array_filter($lessFile); // Check imported paths $importPaths = []; foreach ((array) $options['import_paths'] as $path => $uri) { if ($cleanPath = FS::real($path)) { $importPaths[$cleanPath] = $uri; } } $importPaths[$options['root_path']] = $options['root_url']; // Forced add root path in the end of list! $options['import_paths'] = array_filter($importPaths); return new Data($options); }
/** * Load current config */ protected function _initCurrentConfig() { $this->_config = new PHPArray(); $isProfile = $this->_in->hasOption('profile'); $configName = str_replace(':', '-', strtolower($this->_in->getFirstArgument())); $configName = $isProfile ? $configName . '-' . $this->_getOpt('profile') : $configName; $configPath = JBZOO_CLI_ROOT . '/configs/' . $configName . '.php'; if ($path = FS::real($configPath)) { $this->_config = new PHPArray($path); } elseif ($isProfile) { throw new Exception('Config file "' . $configPath . '" not found'); } }
<?php /** * JBZoo CCK Cli * * This file is part of the JBZoo CCK package. * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @package CCK Cli * @license MIT * @copyright Copyright (C) JBZoo.com, All rights reserved. * @link https://github.com/JBZoo/CCK-Cli * @author Denis Smetannikov <*****@*****.**> */ use JBZoo\Utils\FS; // Define important constatns define('JBZOO_CLI', true); // simple security define('JBZOO_CLI_ROOT', FS::real(__DIR__ . '/../')); !defined('DIRECTORY_SEPERATOR') && define('DIRECTORY_SEPERATOR', '/'); // Try to find Joomla root path $jrootPath = FS::real(__DIR__ . '/../../../'); $jconfigPath = FS::real($jrootPath . '/configuration.php'); $path = $jconfigPath ? $jrootPath : getenv('JOOMLA_DEV_PATH'); // placeholder for developer if (!$path) { throw new Exception('Joomla Root Path is not found!'); } define('JBZOO_CLI_JOOMLA_ROOT', FS::real($path));
/** * @param string $file * @param string $name * @return bool */ public function addAttachment($file, $name = null) { if ($file = FS::real($file)) { if (!$name) { $name = FS::base($file); } $this->_atachments[$file] = $name; return true; } return false; }
<?php /** * JBZoo CrossCMS * * This file is part of the JBZoo CCK package. * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @package CrossCMS * @license MIT * @copyright Copyright (C) JBZoo.com, All rights reserved. * @link https://github.com/JBZoo/CrossCMS * @author Denis Smetannikov <*****@*****.**> */ use JBZoo\Utils\FS; require_once realpath('./vendor/autoload.php'); $configPath = FS::real('./resources/joomla/configuration.php'); if ($configPath) { $config = FS::openFile($configPath); $config = preg_replace('#\'smtp\'#ius', "'mail'", $config); $config = preg_replace('#\'default\'#ius', "'development'", $config); file_put_contents($configPath, $config); } else { throw new \Exception('Joomla configuration file not found!'); }
public function testReal() { isSame(__FILE__, FS::real(__FILE__)); }