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


PHP UTIL_File::stripExtension方法代码示例

本文整理汇总了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);
     }
//.........这里部分代码省略.........
开发者ID:hardikamutech,项目名称:loov,代码行数:101,代码来源:theme_service.php

示例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);
         }
//.........这里部分代码省略.........
开发者ID:ZyXelP,项目名称:oxwall,代码行数:101,代码来源:theme_service.php


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