本文整理汇总了PHP中UTIL_File::stripExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_File::stripExtension方法的具体用法?PHP UTIL_File::stripExtension怎么用?PHP UTIL_File::stripExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTIL_File
的用法示例。
在下文中一共展示了UTIL_File::stripExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processTheme
/**
* Updates/adds whole theme content, generating static files and inserting theme content in DB.
*
* @param integer $id
*/
public function processTheme($id)
{
$theme = $this->getThemeById($id);
$themeName = $theme->getName();
if (!file_exists($this->getRootDir($themeName))) {
throw new LogicException("Can't find theme dir for `" . $themeName . "`!");
}
$themeStaticDir = $this->getStaticDir($themeName);
$themeRootDir = $this->getRootDir($themeName);
$mobileRootDir = $this->getRootDir($themeName, true);
// deleting DB entries and files
$this->unlinkTheme($theme->getId());
mkdir($themeStaticDir);
// copy all static files
UTIL_File::copyDir($themeRootDir, $this->getStaticDir($themeName));
$files = UTIL_File::findFiles($themeStaticDir, array('psd', 'html'));
foreach ($files as $file) {
unlink($file);
}
$themeControls = array();
// copy main css file
if (file_exists($themeRootDir . self::CSS_FILE_NAME)) {
$controlsContent = file_get_contents($themeRootDir . self::CSS_FILE_NAME);
$themeControls = $this->getThemeControls($controlsContent);
$mobileControls = array();
if (file_exists($mobileRootDir . self::CSS_FILE_NAME)) {
$controlsContent .= PHP_EOL . file_get_contents($mobileRootDir . self::CSS_FILE_NAME);
$mobileControls = $this->getThemeControls(file_get_contents($mobileRootDir . self::CSS_FILE_NAME));
foreach ($mobileControls as $key => $val) {
$mobileControls[$key]['mobile'] = true;
}
}
$themeControls = array_merge($mobileControls, $themeControls);
// adding theme controls in DB
if (!empty($themeControls)) {
foreach ($themeControls as $value) {
$themeControl = new BOL_ThemeControl();
$themeControl->setAttribute($value['attrName']);
$themeControl->setKey($value['key']);
$themeControl->setSection($value['section']);
$themeControl->setSelector($value['selector']);
$themeControl->setThemeId($theme->getId());
$themeControl->setDefaultValue($value['defaultValue']);
$themeControl->setType($value['type']);
$themeControl->setLabel($value['label']);
if (isset($value['description'])) {
$themeControl->setDescription(trim($value['description']));
}
$themeControl->setMobile(!empty($value['mobile']));
$this->themeControlDao->save($themeControl);
}
}
}
// decorators
if (file_exists($this->getDecoratorsDir($themeName))) {
$files = UTIL_File::findFiles($this->getDecoratorsDir($themeName), array('html'), 0);
foreach ($files as $value) {
$decoratorEntry = new BOL_ThemeContent();
$decoratorEntry->setThemeId($theme->getId());
$decoratorEntry->setType(BOL_ThemeContentDao::VALUE_TYPE_ENUM_DECORATOR);
$decoratorEntry->setValue(UTIL_File::stripExtension(basename($value)));
$this->themeContentDao->save($decoratorEntry);
}
}
// master pages
if (file_exists($this->getMasterPagesDir($themeName))) {
$files = UTIL_File::findFiles($this->getMasterPagesDir($themeName), array('html'), 0);
foreach ($files as $value) {
$masterPageEntry = new BOL_ThemeContent();
$masterPageEntry->setThemeId($theme->getId());
$masterPageEntry->setType(BOL_ThemeContentDao::VALUE_TYPE_ENUM_MASTER_PAGE);
$masterPageEntry->setValue(UTIL_File::stripExtension(basename($value)));
$this->themeContentDao->save($masterPageEntry);
}
}
if (file_exists($this->getMasterPagesDir($themeName, true))) {
$files = UTIL_File::findFiles($this->getMasterPagesDir($themeName, true), array('html'), 0);
foreach ($files as $value) {
$masterPageEntry = new BOL_ThemeContent();
$masterPageEntry->setThemeId($theme->getId());
$masterPageEntry->setType(BOL_ThemeContentDao::VALUE_TYPE_ENUM_MOBILE_MASTER_PAGE);
$masterPageEntry->setValue(UTIL_File::stripExtension(basename($value)));
$this->themeContentDao->save($masterPageEntry);
}
}
// xml master page assignes
$xml = simplexml_load_file($this->getRootDir($themeName) . self::MANIFEST_FILE);
$masterPages = (array) $xml->masterPages;
foreach ($masterPages as $key => $value) {
$masterPageLinkEntry = new BOL_ThemeMasterPage();
$masterPageLinkEntry->setThemeId($theme->getId());
$masterPageLinkEntry->setDocumentKey(trim($key));
$masterPageLinkEntry->setMasterPage(trim($value));
$this->themeMasterPageDao->save($masterPageLinkEntry);
}
//.........这里部分代码省略.........
示例2: processTheme
/**
* Updates/adds whole theme content, generating static files and inserting theme content in DB.
*
* @param int $id
*/
public function processTheme($id)
{
$theme = $this->getThemeById($id);
if (empty($theme)) {
throw new InvalidArgumentException("Can't process theme with id `" . $id . "`, not found!");
}
$themeName = $theme->getKey();
if (!file_exists($this->getRootDir($themeName))) {
throw new LogicException("Can't find theme dir for `" . $themeName . "`!");
}
$themeStaticDir = $this->getStaticDir($themeName);
$themeRootDir = $this->getRootDir($themeName);
$mobileRootDir = $this->getRootDir($themeName, true);
// deleting DB entries and files
$this->unlinkTheme($theme->getId());
mkdir($themeStaticDir);
// copy all static files
UTIL_File::copyDir($themeRootDir, $this->getStaticDir($themeName), function ($itemPath) {
if (substr($itemPath, 0, 1) == ".") {
return false;
}
if (is_dir($itemPath)) {
return true;
}
$fileExtension = strtolower(UTIL_File::getExtension(basename($itemPath)));
if (in_array($fileExtension, array("psd", "html"))) {
return false;
}
return true;
});
$themeControls = array();
// copy main css file
if (file_exists($themeRootDir . self::CSS_FILE_NAME)) {
$controlsContent = file_get_contents($themeRootDir . self::CSS_FILE_NAME);
$themeControls = $this->getThemeControls($controlsContent);
$mobileControls = array();
if (file_exists($mobileRootDir . self::CSS_FILE_NAME)) {
$controlsContent .= PHP_EOL . file_get_contents($mobileRootDir . self::CSS_FILE_NAME);
$mobileControls = $this->getThemeControls(file_get_contents($mobileRootDir . self::CSS_FILE_NAME));
foreach ($mobileControls as $key => $val) {
$mobileControls[$key]["mobile"] = true;
}
}
$themeControls = array_merge($mobileControls, $themeControls);
// adding theme controls in DB
if (!empty($themeControls)) {
foreach ($themeControls as $value) {
$themeControl = new BOL_ThemeControl();
$themeControl->setAttribute($value["attrName"]);
$themeControl->setKey($value["key"]);
$themeControl->setSection($value["section"]);
$themeControl->setSelector($value["selector"]);
$themeControl->setThemeId($theme->getId());
$themeControl->setDefaultValue($value["defaultValue"]);
$themeControl->setType($value["type"]);
$themeControl->setLabel($value["label"]);
if (isset($value["description"])) {
$themeControl->setDescription(trim($value["description"]));
}
$themeControl->setMobile(!empty($value["mobile"]));
$this->themeControlDao->save($themeControl);
}
}
}
// decorators
if (file_exists($this->getDecoratorsDir($themeName))) {
$files = UTIL_File::findFiles($this->getDecoratorsDir($themeName), array("html"), 0);
foreach ($files as $value) {
$decoratorEntry = new BOL_ThemeContent();
$decoratorEntry->setThemeId($theme->getId());
$decoratorEntry->setType(BOL_ThemeContentDao::VALUE_TYPE_ENUM_DECORATOR);
$decoratorEntry->setValue(UTIL_File::stripExtension(basename($value)));
$this->themeContentDao->save($decoratorEntry);
}
}
// master pages
if (file_exists($this->getMasterPagesDir($themeName))) {
$files = UTIL_File::findFiles($this->getMasterPagesDir($themeName), array("html"), 0);
foreach ($files as $value) {
$masterPageEntry = new BOL_ThemeContent();
$masterPageEntry->setThemeId($theme->getId());
$masterPageEntry->setType(BOL_ThemeContentDao::VALUE_TYPE_ENUM_MASTER_PAGE);
$masterPageEntry->setValue(UTIL_File::stripExtension(basename($value)));
$this->themeContentDao->save($masterPageEntry);
}
}
if (file_exists($this->getMasterPagesDir($themeName, true))) {
$files = UTIL_File::findFiles($this->getMasterPagesDir($themeName, true), array("html"), 0);
foreach ($files as $value) {
$masterPageEntry = new BOL_ThemeContent();
$masterPageEntry->setThemeId($theme->getId());
$masterPageEntry->setType(BOL_ThemeContentDao::VALUE_TYPE_ENUM_MOBILE_MASTER_PAGE);
$masterPageEntry->setValue(UTIL_File::stripExtension(basename($value)));
$this->themeContentDao->save($masterPageEntry);
}
//.........这里部分代码省略.........