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


PHP FileUtil::addTrailingSlash方法代码示例

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


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

示例1: uninstall

	/**
	 * @see	wcf\system\package\plugin\IPackageInstallationPlugin::uninstall()
	 */
	public function uninstall() {
		// create ACP-templates list
		$templates = array();
		
		// get ACP-templates from log
		$sql = "SELECT	*
			FROM	wcf".WCF_N."_acp_template
			WHERE	packageID = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		$statement->execute(array($this->installation->getPackageID()));
		while ($row = $statement->fetchArray()) {
			// store acp template with suffix (_$packageID)
			$templates[] = 'acp/templates/'.$row['templateName'].'.tpl';
		}
		
		if (!empty($templates)) {
			// delete template files
			$packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$this->installation->getPackage()->packageDir));
			$deleteEmptyDirectories = $this->installation->getPackage()->isApplication;
			$this->installation->deleteFiles($packageDir, $templates, false, $deleteEmptyDirectories);
			
			// delete log entries
			parent::uninstall();
		}
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:28,代码来源:ACPTemplatePackageInstallationPlugin.class.php

示例2: getData

 /**
  * @see	\wcf\system\option\IOptionType::getData()
  */
 public function getData(Option $option, $newValue)
 {
     $this->createUploadHandler($option);
     if ($this->uploadHandlers[$option->optionName] === null) {
         return '';
     }
     $files = $this->uploadHandlers[$option->optionName]->getFiles();
     $file = reset($files);
     // check if file has been uploaded
     if (!$file->getFilename()) {
         // if checkbox is checked, remove file
         if ($newValue) {
             @unlink($option->optionValue);
             return '';
         }
         // use old value
         return $option->optionValue;
     } else {
         if ($option->optionValue) {
             // delete old file first
             @unlink($option->optionValue);
         }
     }
     // determine location the file will be stored at
     $package = PackageCache::getInstance()->getPackage($option->packageID);
     $fileLocation = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $package->packageDir)) . $option->filelocation . '.' . $file->getFileExtension();
     // save file
     move_uploaded_file($file->getLocation(), $fileLocation);
     // return file location as the value to store in the database
     return $fileLocation;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:34,代码来源:FileOptionType.class.php

示例3: __construct

 /**
  * Creates a new Installer object.
  * 
  * @param	string				$targetDir
  * @param	string				$source
  * @param	\wcf\system\setup\IFileHandler	$fileHandler
  * @param	string				$folder
  */
 public function __construct($targetDir, $source, $fileHandler = null, $folder = '')
 {
     $this->targetDir = FileUtil::addTrailingSlash($targetDir);
     $this->source = $source;
     $this->folder = $folder;
     $this->fileHandler = $fileHandler;
     $this->install();
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:16,代码来源:Installer.class.php

示例4: rebuild

	/**
	 * Assigns a list of applications to a group and computes cookie domain and path.
	 */
	public function rebuild() {
		if (empty($this->objects)) {
			$this->readObjects();
		}
		
		$sql = "UPDATE	wcf".WCF_N."_application
			SET	cookieDomain = ?,
				cookiePath = ?
			WHERE	packageID = ?";
		$statement = WCF::getDB()->prepareStatement($sql);
		
		// calculate cookie path
		$domains = array();
		foreach ($this->objects as $application) {
			if (!isset($domains[$application->domainName])) {
				$domains[$application->domainName] = array();
			}
			
			$domains[$application->domainName][$application->packageID] = explode('/', FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($application->domainPath)));
		}
		
		WCF::getDB()->beginTransaction();
		foreach ($domains as $domainName => $data) {
			$path = null;
			foreach ($data as $domainPath) {
				if ($path === null) {
					$path = $domainPath;
				}
				else {
					foreach ($path as $i => $part) {
						if (!isset($domainPath[$i]) || $domainPath[$i] != $part) {
							// remove all following elements including current one
							foreach ($path as $j => $innerPart) {
								if ($j >= $i) {
									unset($path[$j]);
								}
							}
							
							// skip to next domain
							continue 2;
						}
					}
				}
			}
			
			$path = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash(implode('/', $path)));
			
			foreach (array_keys($data) as $packageID) {
				$statement->execute(array(
					$domainName,
					$path,
					$packageID
				));
			}
		}
		WCF::getDB()->commitTransaction();
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:60,代码来源:ApplicationAction.class.php

示例5: extractAll

 /**
  * Extracts all files to the given destination.
  * The directory-structure inside the .zip is preserved.
  * 
  * @param	string	$destination	where to extract
  */
 public function extractAll($destination)
 {
     $destination = FileUtil::addTrailingSlash($destination);
     $this->seek(0);
     while ($this->isFile()) {
         $offset = $this->tell();
         $file = $this->readFile();
         $filename = $file['header']['filename'];
         $this->extract($offset, $destination . $filename);
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:17,代码来源:Zip.class.php

示例6: clear

 /**
  * @see	wcf\system\cache\source\ICacheSource::clear()
  */
 public function clear($directory, $filepattern)
 {
     $pattern = preg_quote(FileUtil::addTrailingSlash($directory), '%') . str_replace('*', '.*', str_replace('.', '\\.', $filepattern));
     $apcinfo = apc_cache_info('user');
     $cacheList = $apcinfo['cache_list'];
     foreach ($cacheList as $cache) {
         if (preg_match('%^' . $pattern . '$%i', $cache['info'])) {
             apc_delete($cache['info']);
         }
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:14,代码来源:ApcCacheSource.class.php

示例7: rebuild

 /**
  * Assigns a list of applications to a group and computes cookie domain and path.
  */
 public function rebuild()
 {
     if (empty($this->objects)) {
         $this->readObjects();
     }
     $sql = "UPDATE\twcf" . WCF_N . "_application\n\t\t\tSET\tcookieDomain = ?,\n\t\t\t\tcookiePath = ?\n\t\t\tWHERE\tpackageID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     // calculate cookie path
     $domains = array();
     $regex = new Regex(':[0-9]+');
     foreach ($this->objects as $application) {
         $domainName = $application->domainName;
         if (StringUtil::endsWith($regex->replace($domainName, ''), $application->cookieDomain)) {
             $domainName = $application->cookieDomain;
         }
         if (!isset($domains[$domainName])) {
             $domains[$domainName] = array();
         }
         $domains[$domainName][$application->packageID] = explode('/', FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($application->domainPath)));
     }
     WCF::getDB()->beginTransaction();
     foreach ($domains as $domainName => $data) {
         $path = null;
         foreach ($data as $domainPath) {
             if ($path === null) {
                 $path = $domainPath;
             } else {
                 foreach ($path as $i => $part) {
                     if (!isset($domainPath[$i]) || $domainPath[$i] != $part) {
                         // remove all following elements including current one
                         foreach ($path as $j => $innerPart) {
                             if ($j >= $i) {
                                 unset($path[$j]);
                             }
                         }
                         // skip to next domain
                         continue 2;
                     }
                 }
             }
         }
         $path = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash(implode('/', $path)));
         foreach (array_keys($data) as $packageID) {
             $statement->execute(array($domainName, $path, $packageID));
         }
     }
     WCF::getDB()->commitTransaction();
     // rebuild templates
     LanguageFactory::getInstance()->deleteLanguageCache();
     // reset application cache
     ApplicationCacheBuilder::getInstance()->reset();
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:55,代码来源:ApplicationAction.class.php

示例8: sendMail

 /**
  * Writes the given e-mail in a log file.
  * 
  * @param	Mail	$mail
  */
 public function sendMail(Mail $mail)
 {
     if ($this->log === null) {
         $logFilePath = '';
         if (MAIL_DEBUG_LOGFILE_PATH) {
             $logFilePath = FileUtil::addTrailingSlash(MAIL_DEBUG_LOGFILE_PATH);
         } else {
             $logFilePath = WCF_DIR . 'log/';
         }
         $this->log = new File($logFilePath . 'mail.log', 'ab');
     }
     $this->log->write($this->printMail($mail));
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:18,代码来源:DebugMailSender.class.php

示例9: readFormParameters

 /**
  * @see	\wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['templateGroupName'])) {
         $this->templateGroupName = StringUtil::trim($_POST['templateGroupName']);
     }
     if (!empty($_POST['templateGroupFolderName'])) {
         $this->templateGroupFolderName = StringUtil::trim($_POST['templateGroupFolderName']);
         if ($this->templateGroupFolderName) {
             $this->templateGroupFolderName = FileUtil::addTrailingSlash($this->templateGroupFolderName);
         }
     }
     if (isset($_POST['parentTemplateGroupID'])) {
         $this->parentTemplateGroupID = intval($_POST['parentTemplateGroupID']);
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:19,代码来源:TemplateGroupAddForm.class.php

示例10: addDir

 /**
  * Adds a folder to the Zip archive.
  * 
  * @param	string		$name		dirname
  */
 public function addDir($name, $date = TIME_NOW)
 {
     // replace backward slashes with forward slashes in the dirname
     $name = str_replace("\\", "/", $name);
     $name = FileUtil::addTrailingSlash($name);
     // construct the general header information for the directory
     $header = "PK";
     $header .= "\n";
     $header .= "";
     $header .= "";
     // construct the directory header specific information
     $header .= pack("V", 0);
     $header .= pack("V", 0);
     $header .= pack("V", 0);
     $header .= pack("v", strlen($name));
     $header .= pack("v", 0);
     $header .= $name;
     $header .= pack("V", 0);
     $header .= pack("V", 0);
     $header .= pack("V", 0);
     // store the complete header information into the $headers array
     $this->headers[] = $header;
     // calculate the new offset that will be used the next time a segment is added
     $newOffset = strlen(implode('', $this->headers));
     // construct the general header for the central index record
     $record = "PK";
     $record .= "\n";
     $record .= "";
     //$record .= "\x00\x00\x00\x00";
     $record .= $this->getDosDatetime($date);
     $record .= pack("V", 0);
     $record .= pack("V", 0);
     $record .= pack("V", 0);
     $record .= pack("v", strlen($name));
     $record .= pack("v", 0);
     $record .= pack("v", 0);
     $record .= pack("v", 0);
     $record .= pack("v", 0);
     //$ext = "\x00\x00\x10\x00";
     //$ext = "\xff\xff\xff\xff";
     $record .= pack("V", 16);
     $record .= pack("V", $this->lastOffset);
     $record .= $name;
     // save the central index record in the array $data
     $this->data[] = $record;
     $this->lastOffset = $newOffset;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:52,代码来源:ZipWriter.class.php

示例11: getDirectory

 /**
  * Returns the directory of the application with the given abbrevation.
  * 
  * @param	string		$abbreviation
  * @return	string
  */
 public static function getDirectory($abbreviation)
 {
     if (static::$directories === null) {
         static::$directories = array();
         // read application directories
         $packageList = new PackageList();
         $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1));
         $packageList->readObjects();
         foreach ($packageList as $package) {
             $abbr = Package::getAbbreviation($package->package);
             static::$directories[$abbr] = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $package->packageDir));
         }
     }
     if (!isset(static::$directories[$abbreviation])) {
         throw new SystemException("Unknown application '" . $abbreviation . "'");
     }
     return static::$directories[$abbreviation];
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:24,代码来源:Application.class.php

示例12: uninstall

 /**
  * Uninstalls the files of this package.
  */
 public function uninstall()
 {
     // get absolute package dir
     $packageDir = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(realpath(WCF_DIR . $this->installation->getPackage()->packageDir)));
     // create file list
     $files = array();
     // get files from log
     $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_package_installation_file_log\n\t\t\tWHERE \tpackageID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->installation->getPackageID()));
     while ($row = $statement->fetchArray()) {
         $files[] = $row['filename'];
     }
     if (count($files) > 0) {
         // delete files
         $this->installation->deleteFiles($packageDir, $files);
         // delete log entries
         parent::uninstall();
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:23,代码来源:FilePackageInstallationPlugin.class.php

示例13: uninstall

 /**
  * Uninstalls the templates of this package.
  */
 public function uninstall()
 {
     // create templates list
     $templates = array();
     // get templates from log
     $sql = "SELECT\ttemplateName\n\t\t\tFROM\twcf" . WCF_N . "_template\n\t\t\tWHERE \tpackageID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($this->installation->getPackageID()));
     while ($row = $statement->fetchArray()) {
         $templates[] = 'templates/' . $row['templateName'] . '.tpl';
     }
     if (count($templates) > 0) {
         // delete template files
         $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $this->installation->getPackage()->packageDir));
         $deleteEmptyDirectories = $this->installation->getPackage()->isApplication;
         $this->installation->deleteFiles($packageDir, $templates, false, $deleteEmptyDirectories);
         // delete log entries
         parent::uninstall();
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:23,代码来源:TemplatePackageInstallationPlugin.class.php

示例14: compile

 /**
  * Compiles LESS stylesheets.
  * 
  * @param	\wcf\data\style\Style	$style
  */
 public function compile(Style $style)
 {
     // read stylesheets by dependency order
     $conditions = new PreparedStatementConditionBuilder();
     $conditions->add("filename REGEXP ?", array('style/([a-zA-Z0-9\\_\\-\\.]+)\\.less'));
     $sql = "SELECT\t\tfilename, application\n\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_file_log\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\tpackageID";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute($conditions->getParameters());
     $files = array();
     while ($row = $statement->fetchArray()) {
         $files[] = Application::getDirectory($row['application']) . $row['filename'];
     }
     // get style variables
     $variables = $style->getVariables();
     $individualLess = '';
     if (isset($variables['individualLess'])) {
         $individualLess = $variables['individualLess'];
         unset($variables['individualLess']);
     }
     // add style image path
     $imagePath = '../images/';
     if ($style->imagePath) {
         $imagePath = FileUtil::getRelativePath(WCF_DIR . 'style/', WCF_DIR . $style->imagePath);
         $imagePath = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator($imagePath));
     }
     $variables['style_image_path'] = "'{$imagePath}'";
     // apply overrides
     if (isset($variables['overrideLess'])) {
         $lines = explode("\n", StringUtil::unifyNewlines($variables['overrideLess']));
         foreach ($lines as $line) {
             if (preg_match('~^@([a-zA-Z]+): ?([@a-zA-Z0-9 ,\\.\\(\\)\\%\\#-]+);$~', $line, $matches)) {
                 $variables[$matches[1]] = $matches[2];
             }
         }
         unset($variables['overrideLess']);
     }
     $this->compileStylesheet(WCF_DIR . 'style/style-' . $style->styleID, $files, $variables, $individualLess, new Callback(function ($content) use($style) {
         return "/* stylesheet for '" . $style->styleName . "', generated on " . gmdate('r') . " -- DO NOT EDIT */\n\n" . $content;
     }));
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:45,代码来源:StyleCompiler.class.php

示例15: resetCache

 /**
  * @see wcf\data\IEditableCachedObject::resetCache()
  */
 public static function resetCache()
 {
     // reset cache
     CacheHandler::getInstance()->clear(WCF_DIR . 'cache', 'cache.option-*.php');
     // reset options.inc.php files
     $sql = "SELECT\tpackage, packageID, packageDir\n\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\tWHERE\tisApplication = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(1));
     while ($row = $statement->fetchArray()) {
         if ($row['package'] == 'com.woltlab.wcf') {
             $packageDir = WCF_DIR;
         } else {
             $packageDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
         }
         $filename = FileUtil::addTrailingSlash($packageDir) . self::FILENAME;
         if (file_exists($filename)) {
             if (!@touch($filename, 1)) {
                 if (!@unlink($filename)) {
                     self::rebuildFile($filename, $row['packageID']);
                 }
             }
         }
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:27,代码来源:OptionEditor.class.php


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