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


PHP UTIL_File::findFiles方法代码示例

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


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

示例1: updateThemeInfo

 /**
  * Update theme info in the [OW_DB_PREFIX]_base_theme table according to the theme.xml file and force theme rebuilding if necessary
  * @param $name
  * @param bool $processTheme
  */
 public function updateThemeInfo($name, $processTheme = false)
 {
     $path = OW_DIR_THEME . $name;
     $xmlFiles = UTIL_File::findFiles($path, array('xml'), 1);
     $themeXml = $xmlFiles[0];
     if (basename($themeXml) === self::MANIFEST_FILE) {
         $xml = simplexml_load_file($themeXml);
         $title = (string) $xml->name;
         $build = (int) $xml->build;
         $developerKey = (string) $xml->developerKey;
         $sidebarPosition = (string) $xml->sidebarPosition;
         if (!in_array(trim($sidebarPosition), array('left', 'right', 'none'))) {
             $sidebarPosition = 'none';
         }
         $xmlArray = (array) $xml;
         unset($xmlArray['masterPages']);
         $description = json_encode($xmlArray);
         if (!trim($title)) {
             $title = $name;
         }
         $theme = $this->findThemeByName($name);
         if (empty($theme)) {
             return;
         }
         $theme->setName($name);
         $theme->setTitle($title);
         $theme->setDescription($description);
         $theme->setSidebarPosition($sidebarPosition);
         $theme->setDeveloperKey($developerKey);
         $this->themeDao->save($theme);
         if ($processTheme) {
             $this->processTheme($theme->getId());
         }
     }
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:40,代码来源:theme_service.php

示例2: getPluginsXmlInfo

 /**
  * Returns all plugins XML info.
  */
 public function getPluginsXmlInfo()
 {
     $resultArray = array();
     $xmlFiles = UTIL_File::findFiles(OW_DIR_PLUGIN, array('xml'), 1);
     foreach ($xmlFiles as $pluginXml) {
         if (basename($pluginXml) === 'plugin.xml') {
             $pluginInfo = $this->readPluginXmlInfo($pluginXml);
             if ($pluginInfo !== null) {
                 $resultArray[$pluginInfo['key']] = $pluginInfo;
             }
         }
     }
     return $resultArray;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:17,代码来源:plugin_service.php

示例3: 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

示例4: update

 public function update(array $params)
 {
     $themeDto = $this->getThemeDtoByKeyInParamsArray($params);
     $language = OW::getLanguage();
     $router = OW::getRouter();
     if (!empty($_GET["mode"])) {
         switch (trim($_GET["mode"])) {
             case "theme_up_to_date":
                 $this->feedback->warning($language->text("admin", "manage_themes_up_to_date_message"));
                 break;
             case "theme_update_success":
                 $this->feedback->info($language->text("admin", "manage_themes_update_success_message"));
                 break;
             default:
                 $this->feedback->error($language->text("admin", "manage_themes_update_process_error"));
                 break;
         }
         $this->redirect($router->urlForRoute("admin_themes_choose"));
     }
     $remoteThemeInfo = (array) $this->storageService->getItemInfoForUpdate($themeDto->getKey(), $themeDto->getDeveloperKey(), $themeDto->getBuild());
     if (empty($remoteThemeInfo) || !empty($remoteThemeInfo["error"])) {
         $this->feedback->error($language->text("admin", "manage_themes_update_process_error"));
         $this->redirect($router->urlForRoute("admin_themes_choose"));
     }
     if (!(bool) $remoteThemeInfo["freeware"] && ($themeDto->getLicenseKey() == null || !$this->storageService->checkLicenseKey($themeDto->getKey(), $themeDto->getDeveloperKey(), $themeDto->getLicenseKey()))) {
         $this->feedback->error($language->text("admin", "manage_plugins_update_invalid_key_error"));
         $this->redirect($router->urlForRoute("admin_themes_choose"));
     }
     $ftp = $this->getFtpConnection();
     try {
         $archivePath = $this->storageService->downloadItem($themeDto->getKey(), $themeDto->getDeveloperKey(), $themeDto->getLicenseKey());
     } catch (Exception $e) {
         $this->feedback->error($e->getMessage());
         $this->redirect($router->urlForRoute("admin_themes_choose"));
     }
     if (!file_exists($archivePath)) {
         $this->feedback->error($language->text("admin", "theme_update_download_error"));
         $this->redirect($router->urlForRoute("admin_themes_choose"));
     }
     $zip = new ZipArchive();
     $pluginfilesDir = OW::getPluginManager()->getPlugin("base")->getPluginFilesDir();
     $tempDirPath = $pluginfilesDir . UTIL_HtmlTag::generateAutoId("theme_update") . DS;
     if ($zip->open($archivePath) === true) {
         $zip->extractTo($tempDirPath);
         $zip->close();
     } else {
         $this->feedback->error($language->text("admin", "theme_update_download_error"));
         $this->redirect($router->urlForRoute("admin_themes_choose"));
     }
     $result = UTIL_File::findFiles($tempDirPath, array("xml"));
     $localThemeRootPath = null;
     foreach ($result as $item) {
         if (basename($item) == BOL_ThemeService::THEME_XML) {
             $localThemeRootPath = dirname($item) . DS;
         }
     }
     if ($localThemeRootPath == null) {
         $this->feedback->error($language->text("admin", "manage_theme_update_extract_error"));
         $this->redirect($router->urlForRoute("admin_themes_choose"));
     }
     $remoteDir = OW_DIR_THEME . $themeDto->getKey();
     if (!file_exists($remoteDir)) {
         $this->feedback->error($language->text("admin", "manage_theme_update_theme_not_found"));
         $this->redirect($router->urlForRoute("admin_themes_choose"));
     }
     $ftp->uploadDir($localThemeRootPath, $remoteDir);
     UTIL_File::removeDir($localThemeRootPath);
     $params = array("theme" => $themeDto->getKey(), "back-uri" => urlencode(OW::getRequest()->getRequestUri()));
     $this->redirect(OW::getRequest()->buildUrlQueryString($this->storageService->getUpdaterUrl(), $params));
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:70,代码来源:themes.php

示例5: update

 /**
  * Executes plugin update
  * 
  * @param array $params
  */
 public function update(array $params)
 {
     $pluginDto = $this->getPluginDtoByKeyInParamsArray($params);
     $language = OW::getLanguage();
     $feedback = OW::getFeedback();
     $redirectUrl = OW::getRouter()->urlForRoute("admin_plugins_installed");
     //TODO remove hardcoded constants
     // process data returned by update script
     if (!empty($_GET["mode"])) {
         switch (trim($_GET["mode"])) {
             case "plugin_up_to_date":
                 $feedback->warning($language->text("admin", "manage_plugins_up_to_date_message"));
                 break;
             case "plugin_update_success":
                 OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_AFTER_PLUGIN_UPDATE, array('pluginKey' => $pluginDto->getKey())));
                 $feedback->info($language->text("admin", "manage_plugins_update_success_message"));
                 break;
             default:
                 $feedback->error($language->text("admin", "manage_plugins_update_process_error"));
                 break;
         }
         $this->redirect($redirectUrl);
     }
     $remotePluginInfo = (array) $this->storageService->getItemInfoForUpdate($pluginDto->getKey(), $pluginDto->getDeveloperKey(), $pluginDto->getBuild());
     if (empty($remotePluginInfo) || !empty($remotePluginInfo["error"])) {
         $feedback->error($language->text("admin", "manage_plugins_update_process_error"));
         $this->redirect($redirectUrl);
     }
     if (!(bool) $remotePluginInfo["freeware"] && ($pluginDto->getLicenseKey() == null || !$this->storageService->checkLicenseKey($pluginDto->getKey(), $pluginDto->getDeveloperKey(), $pluginDto->getLicenseKey()))) {
         $feedback->error($language->text("admin", "manage_plugins_update_invalid_key_error"));
         $this->redirect($redirectUrl);
     }
     $ftp = $this->getFtpConnection();
     try {
         $archivePath = $this->storageService->downloadItem($pluginDto->getKey(), $pluginDto->getDeveloperKey(), $pluginDto->getLicenseKey());
     } catch (Exception $e) {
         $feedback->error($e->getMessage());
         $this->redirect($redirectUrl);
     }
     if (!file_exists($archivePath)) {
         $feedback->error(OW::getLanguage()->text("admin", "plugin_update_download_error"));
         $this->redirect($redirectUrl);
     }
     $zip = new ZipArchive();
     $tempDirPath = OW::getPluginManager()->getPlugin("base")->getPluginFilesDir() . "plugin_update" . UTIL_String::getRandomString(5, UTIL_String::RND_STR_ALPHA_NUMERIC) . DS;
     mkdir($tempDirPath);
     if ($zip->open($archivePath) === true) {
         $zip->extractTo($tempDirPath);
         $zip->close();
     } else {
         $feedback->error(OW::getLanguage()->text("admin", "plugin_update_download_error"));
         $this->redirect($redirectUrl);
     }
     // locate plugin.xml file to find plugin source root dir
     $result = UTIL_File::findFiles($tempDirPath, array("xml"));
     $localPluginRootPath = null;
     foreach ($result as $item) {
         if (basename($item) == BOL_PluginService::PLUGIN_INFO_XML) {
             $localPluginRootPath = dirname($item) . DS;
         }
     }
     if ($localPluginRootPath == null) {
         $feedback->error($language->text("admin", "manage_plugin_add_extract_error"));
         $this->redirect($redirectUrl);
     }
     try {
         $plugin = OW::getPluginManager()->getPlugin($pluginDto->getKey());
     } catch (InvalidArgumentException $ex) {
         $feedback->error($language->text("admin", "manage_plugin_update_plugin_not_active_error"));
         $this->redirect($redirectUrl);
     }
     $remoteDirPath = $plugin->getRootDir();
     $ftp->uploadDir($localPluginRootPath, $remoteDirPath);
     UTIL_File::removeDir($localPluginRootPath);
     $this->pluginService->addPluginDirs($pluginDto);
     $params = array("plugin" => $pluginDto->getKey(), "back-uri" => urlencode(OW::getRequest()->getRequestUri()));
     $this->redirect(OW::getRequest()->buildUrlQueryString($this->storageService->getUpdaterUrl(), $params));
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:83,代码来源:plugins.php

示例6: installSystemPlugins

 /**
  * Installs plugins.
  * Installs all available system plugins
  */
 public function installSystemPlugins()
 {
     $files = UTIL_File::findFiles(OW_DIR_SYSTEM_PLUGIN, array("xml"), 1);
     $pluginData = array();
     $tempPluginData = array();
     // first element should be BASE plugin
     foreach ($files as $file) {
         $tempArr = $this->readPluginXmlInfo($file);
         $pathArr = explode(DS, dirname($file));
         $tempArr["dir_name"] = array_pop($pathArr);
         if ($tempArr["key"] == "base") {
             $pluginData[$tempArr["key"]] = $tempArr;
         } else {
             $tempPluginData[$tempArr["key"]] = $tempArr;
         }
     }
     foreach ($tempPluginData as $key => $val) {
         $pluginData[$key] = $val;
     }
     if (!array_key_exists("base", $pluginData)) {
         throw new LogicException("Base plugin is not found in `{$basePluginRootDir}`!");
     }
     // install plugins list
     foreach ($pluginData as $pluginInfo) {
         $pluginDto = new BOL_Plugin();
         $pluginDto->setTitle(!empty($pluginInfo["title"]) ? trim($pluginInfo["title"]) : "No Title");
         $pluginDto->setDescription(!empty($pluginInfo["description"]) ? trim($pluginInfo["description"]) : "No Description");
         $pluginDto->setKey(trim($pluginInfo["key"]));
         $pluginDto->setModule($pluginInfo["dir_name"]);
         $pluginDto->setIsActive(true);
         $pluginDto->setIsSystem(true);
         $pluginDto->setBuild((int) $pluginInfo["build"]);
         if (!empty($pluginInfo["developerKey"])) {
             $pluginDto->setDeveloperKey(trim($pluginInfo["developerKey"]));
         }
         $this->pluginListCache[$pluginDto->getKey()] = $pluginDto;
         $plugin = new OW_Plugin($pluginDto);
         $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_INSTALL);
         $this->pluginDao->save($pluginDto);
         $this->updatePluginListCache();
         $this->addPluginDirs($pluginDto);
     }
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:47,代码来源:plugin_service.php


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