本文整理汇总了PHP中Includes\Utils\FileManager::getRelativePath方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::getRelativePath方法的具体用法?PHP FileManager::getRelativePath怎么用?PHP FileManager::getRelativePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Includes\Utils\FileManager
的用法示例。
在下文中一共展示了FileManager::getRelativePath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUpgradeHelperPath
/**
* Return path where the upgrade helper scripts are placed
*
* @return string
*/
protected function getUpgradeHelperPath()
{
list($author, $name) = explode('\\', $this->getActualName());
return \Includes\Utils\FileManager::getRelativePath(\Includes\Utils\ModulesManager::getAbsoluteDir($author, $name), LC_DIR_ROOT) . LC_DS;
}
示例2: getLogoFaviconSubDir
/**
* Defines the subdirectory where images (logo, favicon) will be stored
*
* @return string
*/
protected static function getLogoFaviconSubDir()
{
return \Includes\Utils\FileManager::getRelativePath(LC_DIR_IMAGES, LC_DIR) . LC_DS . 'simplecms' . LC_DS;
}
示例3: filterCoreFiles
/**
* Callback to filter files
*
* @param \Includes\Utils\FileFilter\FilterIterator $iterator Directory iterator
*
* @return boolean
*/
public function filterCoreFiles(\Includes\Utils\FileFilter\FilterIterator $iterator)
{
// Relative path in LC root directory
$path = \Includes\Utils\FileManager::getRelativePath($iterator->getPathname(), LC_DIR_ROOT);
return !preg_match($this->excludePattern, $path) || preg_match($this->includePattern, $path);
}
示例4: uninstallModule
/**
* Uninstall module
*
* @param \XLite\Model\Module $module Module object
* @param array &$messages Messages list
*
* @return boolean
*/
public function uninstallModule(\XLite\Model\Module $module, &$messages)
{
$result = false;
// Get module pack
$pack = new \XLite\Core\Pack\Module($module);
$dirs = $pack->getDirs();
$nonWritableDirs = array();
// Check module directories permissions
foreach ($dirs as $dir) {
if (\Includes\Utils\FileManager::isExists($dir) && !\Includes\Utils\FileManager::isDirWriteable($dir)) {
$nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
}
}
$params = array('name' => sprintf('%s v%s (%s)', $module->getModuleName(), $module->getVersion(), $module->getAuthorName()));
if (empty($nonWritableDirs)) {
$yamlData = array();
$yamlFiles = \Includes\Utils\ModulesManager::getModuleYAMLFiles($module->getAuthor(), $module->getName());
foreach ($yamlFiles as $yamlFile) {
$yamlData[] = \Includes\Utils\FileManager::read($yamlFile);
}
if (!$module->checkModuleMainClass()) {
$classFile = LC_DIR_CLASSES . \Includes\Utils\Converter::getClassFile($module->getMainClass());
if (\Includes\Utils\FileManager::isFileReadable($classFile)) {
require_once $classFile;
}
}
// Call uninstall event method
$r = $module->callModuleMethod('callUninstallEvent', 111);
if (111 == $r) {
\XLite\Logger::getInstance()->log($module->getActualName() . ': Method callUninstallEvent() was not called');
}
// Remove from FS
foreach ($dirs as $dir) {
\Includes\Utils\FileManager::unlinkRecursive($dir);
}
\Includes\Utils\ModulesManager::disableModule($module->getActualName());
\Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
// Remove module from DB
try {
// Refresh module entity as it was changed by disableModule() method above
$module = $this->find($module->getModuleID());
$this->delete($module);
} catch (\Exception $e) {
$messages[] = $e->getMessage();
}
if ($module->getModuleID()) {
$messages[] = \XLite\Core\Translation::getInstance()->translate('A DB error occured while uninstalling the module X', $params);
} else {
if (!empty($yamlData)) {
foreach ($yamlData as $yaml) {
\XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
}
}
$messages[] = \XLite\Core\Translation::getInstance()->translate('The module X has been uninstalled successfully', $params);
$result = true;
}
} else {
$messages[] = \XLite\Core\Translation::getInstance()->translate('Unable to delete module X files: some dirs have no writable permissions: Y', $params + array('dirs' => implode(', ', $nonWritableDirs)));
}
return $result;
}
示例5: loadHashesForInstalledFiles
/**
* Calculate hashes for current version
*
* @return array
*/
protected function loadHashesForInstalledFiles()
{
$result = array();
$module = $this->getModuleInstalled();
if ($module) {
$pack = new \XLite\Core\Pack\Module($module);
foreach ($pack->getDirectoryIterator() as $file) {
if ($file->isFile()) {
$relativePath = \Includes\Utils\FileManager::getRelativePath($file->getPathname(), LC_DIR_ROOT);
if ($relativePath) {
$result[$relativePath] = \Includes\Utils\FileManager::getHash($file->getPathname(), true);
}
}
}
}
return $result ?: $this->getHashes(true);
}
示例6: loadFromLocalFile
/**
* 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);
}
示例7: getImages
/**
* Get images
*
* @return array
*/
protected function getImages()
{
if (!isset($this->images)) {
$this->images = array();
try {
foreach ($this->getImagesIterator()->getIterator() as $file) {
if ($file->isFile()) {
$this->images[] = \Includes\Utils\FileManager::getRelativePath($file->getPathname(), $this->getImagesDir());
}
}
} catch (\Exception $e) {
}
}
return $this->images;
}
示例8: doActionUninstall
/**
* Uninstall module
*
* @return void
*/
protected function doActionUninstall()
{
$module = $this->getModule();
if ($module) {
$pack = new \XLite\Core\Pack\Module($module);
$dirs = $pack->getDirs();
$nonWritableDirs = array();
// Check permissions
foreach ($dirs as $dir) {
if (!\Includes\Utils\FileManager::isDirWriteable($dir)) {
$nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
}
}
$params = array('name' => $module->getActualName());
if (empty($nonWritableDirs)) {
$yaml = \Includes\Utils\FileManager::read(\Includes\Utils\ModulesManager::getModuleYAMLFile($module->getAuthor(), $module->getName()));
// Remove from FS
foreach ($dirs as $dir) {
\Includes\Utils\FileManager::unlinkRecursive($dir);
}
// Disable this and depended modules
\Includes\Utils\ModulesManager::disableModule($module->getActualName());
\Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
// Remove from DB
\XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->delete($module);
if ($module->getModuleID()) {
$message = 'A DB error occured while uninstalling the module "{{name}}"';
$this->showError(__FUNCTION__, $message, $params);
} else {
if (!empty($yaml)) {
\XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
}
$message = 'The module "{{name}}" has been uninstalled successfully';
$this->showInfo(__FUNCTION__, $message, $params);
}
// To restore previous state
\XLite\Core\Marketplace::getInstance()->saveAddonsList(0);
// Flag to rebuild cache
\XLite::setCleanUpCacheFlag(true);
} else {
$message = 'Unable to delete module "{{name}}" files: some dirs have no writable permissions: {{dirs}}';
$this->showError(__FUNCTION__, $message, $params + array('dirs' => implode(', ', $nonWritableDirs)));
}
}
}
示例9: prepareListChildTemplates
/**
* Prepare list childs templates-based
*
* @param array $list List
*
* @return array
*/
protected function prepareListChildTemplates(array $list)
{
\XLite::getInstance()->initModules();
$skins = array();
$hasSubstSkins = false;
foreach (\XLite\Core\Layout::getInstance()->getSkinsAll() as $interface => $path) {
$skins[$interface] = \XLite\Core\Layout::getInstance()->getSkins($interface);
if (!$hasSubstSkins) {
$hasSubstSkins = 1 < count($skins[$interface]);
}
}
if ($hasSubstSkins) {
$patterns = $hash = array();
foreach ($skins as $interface => $data) {
$patterns[$interface] = array();
foreach ($data as $skin) {
$patterns[$interface][] = preg_quote($skin, '/');
}
$patterns[$interface] = '/^(' . implode('|', $patterns[$interface]) . ')' . preg_quote(LC_DS, '/') . '/US';
}
foreach ($list as $index => $item) {
$path = \Includes\Utils\FileManager::getRelativePath($item['path'], LC_DIR_SKINS);
if (preg_match($patterns[$item['zone']], $path, $matches)) {
$hash[$item['zone']][$matches[1]][$item['tpl']][] = $index;
}
}
foreach ($hash as $interface => &$data) {
$data[static::PREPARED_SKIN_NAME] = array();
foreach (array_reverse($skins[$interface]) as $skin) {
if (!empty($data[$skin])) {
foreach ($data[$skin] as $tpl => $indexes) {
$data[static::PREPARED_SKIN_NAME][$tpl] = $indexes;
}
}
}
}
$index = \Includes\Utils\ArrayManager::getArraysArrayFieldValues($hash, static::PREPARED_SKIN_NAME);
unset($hash);
$ids = array();
foreach ($index as $interface => $tpls) {
foreach ($tpls as $tpl => $indexes) {
$ids = array_merge($ids, $indexes);
}
}
unset($index);
$list = \Includes\Utils\ArrayManager::filterByKeys($list, $ids);
}
return $list;
}
示例10: addTags
/**
* Parse template and add tags to the list
*
* @param array $data Tags data
* @param string $path Template file path
*
* @return array
*/
protected function addTags(array $data, $path)
{
$base = \Includes\Utils\FileManager::getRelativePath($path, LC_DIR_SKINS);
$skin = \Includes\Utils\ArrayManager::getIndex(explode(LC_DS, $base), 0, true);
static::$annotatedTemplates[] = array('tpl' => $base, 'zone' => array_search($skin, static::$zones) ?: \XLite\Model\ViewList::INTERFACE_CUSTOMER, 'path' => $path, 'tags' => $data);
}
示例11: addPackHash
/**
* Create list of archive file hashes and add it to the pack
*
* @param \PharData $phar PHAR archive
* @param \Iterator $iterator Directory iterator
*
* @return void
*/
protected static function addPackHash(\PharData $phar, \Iterator $iterator)
{
$data = array();
foreach ($iterator as $filePath => $fileInfo) {
$data[\Includes\Utils\FileManager::getRelativePath($filePath, LC_DIR_ROOT)] = \Includes\Utils\FileManager::getHash($filePath);
}
$phar->addFromString('.hash', json_encode($data));
}
示例12: addTags
/**
* Parse template and add tags to the list
*
* @param array $data Tags data
* @param string $path Template file path
*
* @return array
*/
protected function addTags(array $data, $path)
{
$base = \Includes\Utils\FileManager::getRelativePath($path, LC_DIR_SKINS);
foreach ($data as $tags) {
$skin = \Includes\Utils\ArrayManager::getIndex(explode(LC_DS, $base), 0, true);
$zone = array_search($skin, static::$zones) ?: \XLite\Model\ViewList::INTERFACE_CUSTOMER;
$template = substr($base, strpos($base, LC_DS) + ('common' == $skin ? 1 : 4));
static::$annotatedTemplates[] = array('tpl' => $template, 'zone' => $zone, 'path' => $path) + $tags;
}
}
示例13: prepareListChildTemplates
/**
* Prepare list childs templates-based
*
* @param array $list List
*
* @return array
*/
protected function prepareListChildTemplates(array $list)
{
$result = array();
\XLite::getInstance()->initModules();
$skins = array();
$hasSubstSkins = false;
foreach (\XLite\Core\Layout::getInstance()->getSkinsAll() as $interface => $path) {
$skins[$interface] = \XLite\Core\Layout::getInstance()->getSkins($interface);
if (!$hasSubstSkins) {
$hasSubstSkins = 1 < count($skins[$interface]);
}
}
foreach ($list as $i => $cell) {
foreach ($skins as $interface => $paths) {
foreach ($paths as $path) {
if (0 === strpos($cell['tpl'], $path . LC_DS)) {
$length = strlen($path) + ('common' == $path ? 1 : 4);
$list[$i]['tpl'] = substr($cell['tpl'], $length);
$list[$i]['zone'] = $interface;
}
}
}
if (!isset($list[$i]['zone'])) {
unset($list[$i]);
}
}
if ($hasSubstSkins) {
$patterns = $hash = array();
foreach ($skins as $interface => $data) {
$patterns[$interface] = array();
foreach ($data as $skin) {
$patterns[$interface][] = preg_quote($skin, '/');
}
$patterns[$interface] = '/^(' . implode('|', $patterns[$interface]) . ')' . preg_quote(LC_DS, '/') . '\\w{2}' . preg_quote(LC_DS, '/') . '(.+)$/US';
}
foreach ($list as $index => $item) {
$path = \Includes\Utils\FileManager::getRelativePath($item['path'], LC_DIR_SKINS);
if (preg_match($patterns[$item['zone']], $path, $matches)) {
$hash[$item['zone']][$item['tpl']][$matches[1]] = $index;
$list[$index]['tpl'] = $matches[2];
}
}
foreach ($hash as $interface => $tpls) {
foreach ($tpls as $path => $indexes) {
$idx = null;
$tags = array();
foreach (array_reverse($skins[$interface]) as $skin) {
if (isset($indexes[$skin])) {
$idx = $indexes[$skin];
$tags[] = $list[$indexes[$skin]]['tags'];
}
}
foreach ($this->processTagsQuery($tags) as $tag) {
$tmp = $list[$idx];
unset($tmp['tags'], $tmp['path']);
$result[] = $tmp + $tag;
}
}
}
// Convert template short path to UNIX-style
if (DIRECTORY_SEPARATOR != '/') {
foreach ($result as $i => $v) {
$result[$i]['tpl'] = str_replace(DIRECTORY_SEPARATOR, '/', $v['tpl']);
}
}
} else {
foreach ($list as $cell) {
foreach ($this->processTagsQuery(array($cell['tags'])) as $tag) {
unset($cell['tags'], $cell['path']);
$result[] = $cell + $tag;
}
}
}
return $result;
}