コード例 #1
0
 /**
  * Delete custom module
  *
  * @param string $moduleName
  * @param array $formData
  *      string login required
  *      string password required
  * @param string $host
  * @param array $moduleInstallConfig
  *      string compatable
  *      string version 
  *      string vendor 
  *      string vendor_email 
  *      string description optional
  *      array module_depends optional
  *          string module
  *          string vendor
  *          string vendor_email
  *      array clear_caches optional
  *      array resources optional
  *          string dir_name
  *          boolean is_public optional
  *      string install_sql optional
  *      string uninstall_sql optional
  *      array system_requirements optional
  *          array php_extensions optional
  *          array php_settings optional
  *          array php_enabled_functions optional
  *          array php_version optional
  *      string install_sql optional
  *      string install_intro optional
  *      string uninstall_sql optional
  *      string uninstall_intro optional
  *      string layout_path optional
  * @return boolean|string
  */
 public function deleteCustomModule($moduleName, array $formData, $host, array $moduleInstallConfig)
 {
     try {
         $globalModulePath = ApplicationService::getModulePath(false) . '/' . $moduleName;
         $ftp = new ApplicationFtpUtility($host, $formData['login'], $formData['password']);
         $ftp->removeDirectory($globalModulePath);
         if (!empty($moduleInstallConfig['layout_path'])) {
             $globalModuleLayoutPath = basename(APPLICATION_PUBLIC) . '/' . ApplicationService::getBaseLayoutPath(false) . '/' . $moduleInstallConfig['layout_path'];
             $ftp->removeDirectory($globalModuleLayoutPath);
         }
     } catch (Exception $e) {
         ApplicationErrorLogger::log($e);
         return $e->getMessage();
     }
     ApplicationEvent::fireDeleteCustomModuleEvent($moduleName);
     return true;
 }
コード例 #2
0
 /**
  * Delete custom layout
  *
  * @param string $layoutName
  * @param array $formData
  *      string login required
  *      string password required
  * @param string $host
  * @return boolean|string
  */
 public function deleteCustomLayout($layoutName, array $formData, $host)
 {
     try {
         // delete a layout dir
         $globalLayoutPath = basename(APPLICATION_PUBLIC) . '/' . ApplicationService::getLayoutPath(false) . '/' . $layoutName;
         $ftp = new ApplicationFtpUtility($host, $formData['login'], $formData['password']);
         $ftp->removeDirectory($globalLayoutPath);
         // delete modules templates
         $globalModulePath = ApplicationService::getModulePath(false);
         $localModulePath = APPLICATION_ROOT . '/' . $globalModulePath;
         $directoryIterator = new DirectoryIterator($localModulePath);
         foreach ($directoryIterator as $module) {
             if ($module->isDot() || !$module->isDir()) {
                 continue;
             }
             $moduleTemplateDir = $localModulePath . '/' . $module->getFileName() . '/' . ApplicationService::getModuleViewDir() . '/' . $layoutName;
             if (file_exists($moduleTemplateDir)) {
                 $ftp->removeDirectory($globalModulePath . '/' . $module->getFileName() . '/' . ApplicationService::getModuleViewDir() . '/' . $layoutName);
             }
         }
     } catch (Exception $e) {
         ApplicationErrorLogger::log($e);
         return $e->getMessage();
     }
     LayoutEvent::fireDeleteCustomLayoutEvent($layoutName);
     return true;
 }