本文整理汇总了PHP中Cx\Lib\FileSystem\FileSystem::path_relative_to_root方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::path_relative_to_root方法的具体用法?PHP FileSystem::path_relative_to_root怎么用?PHP FileSystem::path_relative_to_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cx\Lib\FileSystem\FileSystem
的用法示例。
在下文中一共展示了FileSystem::path_relative_to_root方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _overviewMedia
/**
* Overview Media Data
*
* @global array $_ARRAYLANG
* @return string parsed content
*/
function _overviewMedia()
{
global $_ARRAYLANG, $_CORELANG;
$searchTerm = $this->isSearchActivated() && !empty($_GET['term']) ? \FWValidator::getCleanFileName(contrexx_input2raw($_GET['term'])) : '';
switch ($this->getAct) {
case 'download':
$this->_downloadMedia();
break;
case 'newDir':
$this->_createDirectory($_POST['media_directory_name']);
break;
case 'upload':
$this->_uploadFiles();
break;
case 'rename':
$this->_renameFiles();
break;
case 'delete':
$this->_deleteFiles();
break;
default:
}
// tree navigation
$tmp = $this->arrWebPaths[$this->archive];
if (substr($this->webPath, 0, strlen($tmp)) == $tmp) {
$this->_objTpl->setVariable(array('MEDIA_TREE_NAV_MAIN' => "Home /", 'MEDIA_TREE_NAV_MAIN_HREF' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&path=' . rawurlencode($this->arrWebPaths[$this->archive])));
if (strlen($this->webPath) != strlen($tmp)) {
$tmpPath = substr($this->webPath, -(strlen($this->webPath) - strlen($tmp)));
$tmpPath = explode('/', $tmpPath);
$tmpLink = '';
foreach ($tmpPath as $path) {
if (!empty($path)) {
$tmpLink .= $path . '/';
$this->_objTpl->setVariable(array('MEDIA_TREE_NAV_DIR' => $path, 'MEDIA_TREE_NAV_DIR_HREF' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&path=' . rawurlencode($this->arrWebPaths[$this->archive] . $tmpLink)));
$this->_objTpl->parse('mediaTreeNavigation');
}
}
}
}
if (!empty($_GET['highlightFiles'])) {
$this->highlightName = array_merge($this->highlightName, array_map('basename', json_decode(contrexx_stripslashes(urldecode($_GET['highlightFiles'])))));
}
// media directory tree
$dirTree = array();
$this->getDirectoryTree($this->path, $searchTerm, $dirTree, !empty($searchTerm));
$dirTree = $this->_sortDirTree($dirTree);
$deleteUrl = clone \Cx\Core\Core\Controller\Cx::instanciate()->getRequest()->getUrl();
$deleteUrl->setParam('act', null);
$previewUrl = clone $deleteUrl;
$renameUrl = clone $deleteUrl;
$redirect = urlencode(base64_encode($deleteUrl->toString(false)));
$renameUrl->setParam('redirect', $redirect);
$deleteUrl->setParam('redirect', $redirect);
$renameUrl->setParam('act', 'rename');
$deleteUrl->setParam('act', 'delete');
$i = 0;
foreach (array_keys($dirTree) as $key) {
if (!is_array($dirTree[$key]['icon'])) {
continue;
}
$mediaCount = count($dirTree[$key]['icon']);
for ($x = 0; $x < $mediaCount; $x++) {
$fileName = $dirTree[$key]['name'][$x];
if (MediaLibrary::isIllegalFileName($fileName)) {
continue;
}
$class = $i % 2 ? 'row2' : 'row1';
// highlight
if (in_array($fileName, $this->highlightName)) {
$class .= '" style="background-color: ' . $this->highlightColor . ';';
}
if (!$this->manageAccessGranted()) {
//if the user is not allowed to delete or rename files -- hide those blocks
if ($this->_objTpl->blockExists('manage_access_option')) {
$this->_objTpl->hideBlock('manage_access_option');
}
}
$this->_objTpl->setVariable(array('MEDIA_DIR_TREE_ROW' => $class, 'MEDIA_FILE_ICON' => $dirTree[$key]['icon'][$x], 'MEDIA_FILE_NAME' => $fileName, 'MEDIA_FILE_SIZE' => $this->_formatSize($dirTree[$key]['size'][$x]), 'MEDIA_FILE_TYPE' => $this->_formatType($dirTree[$key]['type'][$x]), 'MEDIA_FILE_DATE' => $this->_formatDate($dirTree[$key]['date'][$x]), 'MEDIA_RENAME_TITLE' => $_ARRAYLANG['TXT_MEDIA_RENAME'], 'MEDIA_DELETE_TITLE' => $_ARRAYLANG['TXT_MEDIA_DELETE']));
$image = false;
$imagePreview = '';
$mediaPath = $this->path;
$mediaWebPath = $this->webPath;
if (!empty($searchTerm)) {
$mediaPath = $dirTree[$key]['path'][$x] . '/';
$mediaWebPath = $mediaPath;
\Cx\Lib\FileSystem\FileSystem::path_relative_to_root($mediaWebPath);
$mediaWebPath = '/' . $mediaWebPath;
// Filesysystem removes the beginning slash(/)
}
$file = rawurlencode($fileName);
if ($key == 'dir') {
$path = rawurlencode($mediaWebPath . $fileName . '/');
$previewUrl->setParam('act', null);
$previewUrl->setParam('file', null);
//.........这里部分代码省略.........
示例2: _overviewMedia
//.........这里部分代码省略.........
$editUrl->setParam('act', 'edit');
foreach (array_keys($dirTree) as $key) {
if (!is_array($dirTree[$key]['icon'])) {
continue;
}
$mediaCount = count($dirTree[$key]['icon']);
for ($x = 0; $x < $mediaCount; $x++) {
$fileName = $dirTree[$key]['name'][$x];
if (MediaLibrary::isIllegalFileName($fileName)) {
continue;
}
// colors
$class = $i % 2 ? 'row2' : 'row1';
if (in_array($fileName, $this->highlightName)) {
// highlight
$class .= '" style="background-color: ' . $this->highlightColor . ';';
}
if (isset($_SESSION['mediaCutFile']) && !empty($_SESSION['mediaCutFile']) && $this->webPath == $_SESSION['mediaCutFile'][1] && in_array($fileName, $_SESSION['mediaCutFile'][2])) {
// cut
$class .= '" style="background-color: ' . $this->highlightCCColor . ';';
}
if (isset($_SESSION['mediaCopyFile']) && !empty($_SESSION['mediaCopyFile']) && $this->webPath == $_SESSION['mediaCopyFile'][1] && in_array($fileName, $_SESSION['mediaCopyFile'][2])) {
// copy
$class .= '" style="background-color: ' . $this->highlightCCColor . ';';
}
$this->_objTpl->setVariable(array('MEDIA_DIR_TREE_ROW' => $class, 'MEDIA_FILE_ICON' => $dirTree[$key]['icon'][$x], 'MEDIA_FILE_NAME' => $fileName, 'MEDIA_FILE_SIZE' => $this->_formatSize($dirTree[$key]['size'][$x]), 'MEDIA_FILE_TYPE' => $this->_formatType($dirTree[$key]['type'][$x]), 'MEDIA_FILE_DATE' => $this->_formatDate($dirTree[$key]['date'][$x]), 'MEDIA_FILE_PERM' => $this->_formatPerm($dirTree[$key]['perm'][$x], $key)));
$image = false;
$imagePreview = '';
$mediaPath = $this->path;
$mediaWebPath = $this->webPath;
if (!empty($searchTerm)) {
$mediaPath = $dirTree[$key]['path'][$x] . '/';
$mediaWebPath = $mediaPath;
\Cx\Lib\FileSystem\FileSystem::path_relative_to_root($mediaWebPath);
$mediaWebPath = '/' . $mediaWebPath;
// Filesystem removes the beginning slash(/)
}
$file = rawurlencode($fileName);
if ($key == 'dir') {
$path = rawurlencode($mediaWebPath . $fileName . '/');
$previewUrl->setParam('act', null);
$previewUrl->setParam('file', null);
} elseif ($key == 'file') {
$path = rawurlencode($mediaWebPath);
$filePath = $mediaPath . $fileName;
if ($this->_isImage($filePath)) {
$image = true;
$imagePreview = 'javascript:expandcontent(\'preview_' . $fileName . '\');';
} else {
$previewUrl->setParam('act', 'download');
$previewUrl->setParam('file', $file);
}
}
$deleteUrl->setParam('path', rawurlencode($mediaWebPath));
$deleteUrl->setParam('file', $file);
$renameUrl->setParam('path', rawurlencode($mediaWebPath));
$renameUrl->setParam('file', $file);
$editUrl->setParam('path', rawurlencode($mediaWebPath));
$editUrl->setParam('file', $file);
if (!$image) {
$previewUrl->setParam('path', $path);
}
// show thumbnail
if ($image) {
// make thumbnail if it doesn't exist
$tmpSize = @getimagesize($mediaPath . $fileName);