/** * Get browscap client * * @return \phpbrowscap\Browscap */ protected function getBrowscapClient() { require_once LC_DIR_LIB . 'Browscap.php'; $cacheDir = LC_DIR_DATA . 'browscap'; if (!file_exists($cacheDir)) { \Includes\Utils\FileManager::mkdirRecursive($cacheDir); \Includes\Utils\FileManager::copy($this->getBrowsCapPath(), $cacheDir . LC_DS . 'browscap.ini'); } return new \phpbrowscap\Browscap($cacheDir); }
/** * Load from local file * * @param string $path Absolute path * @param string $basename File name OPTIONAL * * @return boolean */ public function loadFromLocalFile($path, $basename = null) { $result = true; $basename = $basename ?: basename($path); if (\Includes\Utils\FileManager::isExists($path)) { foreach ($this->getAllowedFileSystemRoots() as $root) { if (\Includes\Utils\FileManager::getRelativePath($path, $root)) { $local = true; break; } } if (empty($local)) { $newPath = \Includes\Utils\FileManager::getUniquePath($this->getStoreFileSystemRoot(), $basename); if (\Includes\Utils\FileManager::copy($path, $newPath)) { $path = $newPath; $this->setStorageType(static::STORAGE_RELATIVE); } else { \XLite\Logger::getInstance()->log('\'' . $path . '\' file could not be copied to a new location \'' . $newPath . '\'.', LOG_ERR); $result = false; } } else { $this->setStorageType(static::STORAGE_ABSOLUTE); } } else { $result = false; } if ($result && $basename) { $this->setFileName($basename); } return $result && $this->savePath($path); }
/** * Move/copy class file * * @param string $class New class name * * @return void */ protected function moveClassFile($class) { if (!$this->isRoot() && !$this->isRoot($class)) { if ($this->getClass()) { \Includes\Utils\FileManager::move($this->getFile(), $this->getFile($class)); } else { \Includes\Utils\FileManager::copy($this->getFile($class, LC_DIR_CLASSES), $this->getFile($class)); } } }