当前位置: 首页>>代码示例>>PHP>>正文


PHP dmOs::sanitizeDirName方法代码示例

本文整理汇总了PHP中dmOs::sanitizeDirName方法的典型用法代码示例。如果您正苦于以下问题:PHP dmOs::sanitizeDirName方法的具体用法?PHP dmOs::sanitizeDirName怎么用?PHP dmOs::sanitizeDirName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dmOs的用法示例。


在下文中一共展示了dmOs::sanitizeDirName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doClean

 /**
  * @see sfValidatorUrl
  */
 protected function doClean($value)
 {
     $value = parent::doClean($value);
     if ($value !== dmOs::sanitizeDirName($value)) {
         throw new sfValidatorError($this, 'invalid', array('value' => $value));
     }
     return $value;
 }
开发者ID:theolymp,项目名称:diem,代码行数:11,代码来源:dmValidatorDirectoryName.php

示例2: rename

 /**
  * Change folder name
  *
  * @param string $name
  */
 public function rename($name)
 {
     if ($name === $this->name) {
         return $this;
     }
     if ($this->getNode()->isRoot()) {
         throw new dmException('The root folder cannot be renamed');
     }
     if (!$this->isWritable()) {
         throw new dmException(sprintf('The folder %s is not writable.', dmProject::unRootify($this->fullPath)));
     }
     if (dmOs::sanitizeDirName($name) !== $name) {
         throw new dmException(sprintf('The target folder: "%s" contains incorrect characters.', $name));
     }
     if ($this->getNode()->getParent()->hasSubFolder($name)) {
         throw new dmException(sprintf('The parent folder already contains a folder named "%s".', $name));
     }
     $oldName = $this->getName();
     $oldRelPath = $this->get('rel_path');
     $newRelPath = $this->getNode()->getParent()->get('rel_path') . '/' . $name;
     $fs = $this->getService('filesystem');
     $oldFullPath = $this->getFullPath();
     $newFullPath = dmOs::join($this->getNode()->getParent()->getFullPath(), $name);
     if (!rename($oldFullPath, $newFullPath)) {
         throw new dmException('Can not move %s to %s', dmProject::unRootify($oldFullPath), dmProject::unRootify($newFullPath));
     }
     $this->set('rel_path', $newRelPath);
     $this->clearCache()->save();
     //update descendants
     if ($descendants = $this->getNode()->getDescendants()) {
         foreach ($descendants as $folder) {
             $folder->set('rel_path', dmString::str_replace_once($oldRelPath, $newRelPath, $folder->get('rel_path')));
             $folder->save();
         }
     }
     return $this;
 }
开发者ID:jdart,项目名称:diem,代码行数:42,代码来源:PluginDmMediaFolder.class.php

示例3: sanitizeDir

 /**
  * Sanitize dirs name (move dirs)
  */
 protected function sanitizeDir($dir)
 {
     if (basename($dir) != dmOs::sanitizeDirName(basename($dir))) {
         $renamedDir = dmOs::join(dirname($dir), dmOs::sanitizeDirName(basename($dir)));
         while (is_dir($renamedDir)) {
             $renamedDir = dmOs::randomizeDirName($renamedDir);
         }
         rename($dir, $renamedDir);
         $dir = $renamedDir;
     }
     return $dir;
 }
开发者ID:theolymp,项目名称:diem,代码行数:15,代码来源:dmMediaSynchronizer.php

示例4: dirname

<?php

require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot();
$t = new lime_test(5);
$t->is(dmOs::join("home"), "/home", 'dmOs::join /home');
$t->is(dmOs::join(sfConfig::get("sf_root_dir"), "/cache/"), sfConfig::get("sf_root_dir") . "/cache", 'dmOs::join sfConfig::get("sf_root_dir"), "/cache/"');
$t->is(dmOs::join("home", "user/dir", "file.ext"), "/home/user/dir/file.ext", 'dmOs::join "home", "user/dir", "file.ext"');
$t->is(dmOs::join("//home///user//dir/file.ext///"), "/home/user/dir/file.ext", 'dmOs::join "//home///user//dir/file.ext///"');
$t->is(dmOs::sanitizeDirName('A strange DIR name é & / \\ ( $'), $expected = 'A-strange-DIR-name-e', 'dmOs::sanitizeDirName() : ' . $expected);
开发者ID:theolymp,项目名称:diem,代码行数:11,代码来源:dmOsTest.php


注:本文中的dmOs::sanitizeDirName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。