本文整理汇总了PHP中FileUtil::getFilebase方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::getFilebase方法的具体用法?PHP FileUtil::getFilebase怎么用?PHP FileUtil::getFilebase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::getFilebase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _get_auto_filename
/**
* Get a concrete filename for automagically created content.
*
* Generates a filename path like: Theme / auto_id [/ source_dir / filename-l{lang}.ext]
* the final part gets generated only if $auto_source is specified.
*
* @param string $path The base path.
* @param string $auto_source The file name (optional).
* @param string $auto_id The ID (optional).
*
* @return string The concrete path and file name to the content.
*/
public function _get_auto_filename($path, $auto_source = null, $auto_id = null, $themedir = null)
{
// enables a flags to detect when is treating compiled templates
$tocompile = $path == $this->compile_dir ? true : false;
// format auto_source for os to make sure that id does not contain 'ugly' characters
$auto_source = DataUtil::formatForOS($auto_source);
// add the Theme name as first folder
if (empty($themedir)) {
$path .= '/' . $this->directory;
} else {
$path .= '/' . $themedir;
}
// the last folder is the cache_id if set
$path .= !empty($auto_id) ? '/' . $auto_id : '';
// takes in account the source subdirectory
$path .= strpos($auto_source, '/') !== false ? '/' . dirname($auto_source) : '';
// make sure the path exists to write the compiled/cached template there
if (!file_exists($path)) {
mkdir($path, $this->serviceManager['system.chmod_dir'], true);
}
// if there's a explicit source, it
if ($auto_source) {
$path .= '/';
$extension = FileUtil::getExtension($auto_source);
// isolates the filename on the source path passed
$path .= FileUtil::getFilebase($auto_source);
// if we are compiling we do not include cache variables
if (!$tocompile) {
// add the variable stuff only if $auto_source is present
// to allow a easy flush cache for all the languages (if needed)
$path .= '-l';
if (System::getVar('multilingual') == 1) {
$path .= $this->language;
}
// end with a suffix convention of filename--Themename-lang.ext
$path .= $extension ? ".{$extension}" : '';
}
}
return $path;
}
示例2: rmtpl
/**
* Internal function to delete cache of templates.
*
* @param string $tplpath Relative template path.
* @param string $template Template partial filename.
* @param integer $expire Expire limit of the cached templates.
*
* @return boolean True on success, false otherwise
*/
protected function rmtpl($tplpath, $template, $expire = null)
{
if (!$template || !is_dir($tplpath) || !is_readable($tplpath)) {
return false;
}
$filebase = FileUtil::getFilebase($template);
$dh = opendir($tplpath);
while (($entry = readdir($dh)) !== false) {
if ($entry != '.' && $entry != '..') {
$path = $tplpath . DIRECTORY_SEPARATOR . $entry;
if (is_dir($path)) {
// search recusively
$this->rmtpl($path, $template, $expire);
} elseif (strpos($entry, $filebase) === 0) {
// delete the files that matches the template base filename
$this->_unlink($path, $expire);
}
}
}
closedir($dh);
return true;
}