本文整理汇总了PHP中FWValidator::getCleanFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP FWValidator::getCleanFileName方法的具体用法?PHP FWValidator::getCleanFileName怎么用?PHP FWValidator::getCleanFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWValidator
的用法示例。
在下文中一共展示了FWValidator::getCleanFileName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _overviewMedia
/**
* Overview Media Data
*
* @global array $_ARRAYLANG
* @global array $_CONFIG
* @global array $_CORELANG
* @return string parsed content
*/
function _overviewMedia()
{
global $_ARRAYLANG, $_CONFIG, $_CORELANG, $objDatabase;
\JS::activate('shadowbox');
$this->_objTpl->loadTemplateFile('module_media.html', true, true);
switch ($this->archive) {
case 'themes':
$this->pageTitle = $_ARRAYLANG['TXT_MEDIA_LAYOUT'];
break;
case 'content':
$this->pageTitle = $_ARRAYLANG['TXT_IMAGE_ADMINISTRATION'];
break;
case 'Contact':
$this->pageTitle = $_ARRAYLANG['TXT_FILE_UPLOADS'];
break;
case 'attach':
case 'Access':
case 'Blog':
case 'Calendar':
case 'Downloads':
case 'Gallery':
case 'MediaDir':
case 'Podcast':
case 'Shop':
$archives = array('attach' => 'TXT_FILE_UPLOADS', 'Shop' => 'TXT_IMAGE_SHOP', 'Gallery' => 'TXT_GALLERY_TITLE', 'Access' => 'TXT_USER_ADMINISTRATION', 'MediaDir' => 'TXT_MEDIADIR_MODULE', 'Downloads' => 'TXT_DOWNLOADS', 'Calendar' => 'TXT_CALENDAR', 'Podcast' => 'TXT_PODCAST', 'Blog' => 'TXT_BLOG_MODULE');
$moduleMatchTable = array('attach' => 'core');
$subnavigation = '
<div id="subnavbar_level2">
<ul>';
$license = \Cx\Core_Modules\License\License::getCached($_CONFIG, $objDatabase);
$license->check();
foreach ($archives as $archive => $txtKey) {
$moduleName = $archive;
if (isset($moduleMatchTable[$archive])) {
$moduleName = $moduleMatchTable[$archive];
}
if (!$license->isInLegalComponents($moduleName)) {
\DBG::msg('Module "' . $archive . '" is deactivated');
continue;
}
$subnavigation .= '
<li><a href="index.php?cmd=Media&archive=' . $archive . '" class="' . ($this->archive == $archive ? 'active' : '') . '">' . $_ARRAYLANG[$txtKey] . '</a></li>';
}
$subnavigation .= '
</ul>
</div>';
$this->_objTpl->setVariable('CONTENT_SUBNAVIGATION', $subnavigation);
default:
$this->pageTitle = $_ARRAYLANG['TXT_MEDIA_OVERVIEW'];
if ($this->archive == "FileSharing") {
\Cx\Modules\FileSharing\Controller\FileSharingLib::cleanUp();
}
break;
}
$searchTerm = !empty($_GET['term']) ? \FWValidator::getCleanFileName(contrexx_input2raw($_GET['term'])) : '';
// cut, copy and paste session
if (isset($_SESSION['mediaCutFile'])) {
$tmpArray = array();
foreach ($_SESSION['mediaCutFile'][2] as $tmp) {
if (file_exists($_SESSION['mediaCutFile'][0] . $tmp)) {
$tmpArray[] = $tmp;
}
}
if (count($tmpArray) > 0) {
$_SESSION['mediaCutFile'][0] = $_SESSION['mediaCutFile'][0];
$_SESSION['mediaCutFile'][1] = $_SESSION['mediaCutFile'][1];
$_SESSION['mediaCutFile'][2] = $tmpArray;
} else {
unset($_SESSION['mediaCutFile']);
}
}
if (isset($_SESSION['mediaCopyFile'])) {
$tmpArray = array();
foreach ($_SESSION['mediaCopyFile'][2] as $tmp) {
if (file_exists($_SESSION['mediaCopyFile'][0] . $tmp)) {
$tmpArray[] = $tmp;
}
}
if (count($tmpArray) > 0) {
$_SESSION['mediaCopyFile'][0] = $_SESSION['mediaCopyFile'][0];
$_SESSION['mediaCopyFile'][1] = $_SESSION['mediaCopyFile'][1];
$_SESSION['mediaCopyFile'][2] = $tmpArray;
} else {
unset($_SESSION['mediaCopyFile']);
}
}
// tree navigation
$tmp = $this->arrWebPaths[$this->archive];
if (substr($this->webPath, 0, strlen($tmp)) == $tmp) {
$this->_objTpl->setVariable(array('MEDIA_TREE_NAV_MAIN' => 'http://' . $_SERVER['HTTP_HOST'] . $this->arrWebPaths[$this->archive], 'MEDIA_TREE_NAV_MAIN_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->arrWebPaths[$this->archive]));
if (strlen($this->webPath) != strlen($tmp)) {
$tmpPath = substr($this->webPath, -(strlen($this->webPath) - strlen($tmp)));
//.........这里部分代码省略.........
示例2: _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);
//.........这里部分代码省略.........
示例3: replaceCharacters
public static function replaceCharacters($string)
{
// cloudrexx file name policies
$string = \FWValidator::getCleanFileName($string);
// media library special changes; code depends on those
// replace $change with ''
$change = array('+');
// replace $signs1 with $signs
$signs1 = array(' ', 'ä', 'ö', 'ü', 'ç');
$signs2 = array('_', 'ae', 'oe', 'ue', 'c');
foreach ($change as $str) {
$string = str_replace($str, '_', $string);
}
for ($x = 0; $x < count($signs1); $x++) {
$string = str_replace($signs1[$x], $signs2[$x], $string);
}
$string = str_replace('__', '_', $string);
if (strlen($string) > self::MAX_FILENAME_LENGTH) {
$info = pathinfo($string);
$stringExt = $info['extension'];
$stringName = substr($string, 0, strlen($string) - (strlen($stringExt) + self::DOT_LENGTH));
$stringName = substr($stringName, 0, self::MAX_FILENAME_LENGTH - (strlen($stringExt) + self::DOT_LENGTH));
$string = $stringName . '.' . $stringExt;
}
return $string;
}