From 5f7be4a7f1843ac6c32ec17e6418380a5fe0b741 Mon Sep 17 00:00:00 2001 From: flyskyko Date: Tue, 26 Jul 2011 07:04:49 +0000 Subject: [PATCH] add getRemoveUrlByPath(), checking dependency when dispAutoinstallAdminUninstall git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8642 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- .../autoinstall.admin.controller.php | 12 ++-- .../autoinstall/autoinstall.admin.view.php | 71 ++++++++++++------- modules/autoinstall/autoinstall.model.php | 30 +++++++- modules/autoinstall/lang/en.lang.php | 2 + modules/autoinstall/lang/jp.lang.php | 4 +- modules/autoinstall/lang/ko.lang.php | 2 + modules/autoinstall/lang/ru.lang.php | 2 + modules/autoinstall/lang/tr.lang.php | 2 + modules/autoinstall/lang/vi.lang.php | 2 + modules/autoinstall/lang/zh-CN.lang.php | 2 + modules/autoinstall/lang/zh-TW.lang.php | 2 + .../queries/getPackageSrlByPath.xml | 11 +++ modules/autoinstall/tpl/install.html | 2 +- modules/autoinstall/tpl/list.html | 26 +++---- modules/autoinstall/tpl/uninstall.html | 53 ++++++++------ 15 files changed, 153 insertions(+), 70 deletions(-) create mode 100644 modules/autoinstall/queries/getPackageSrlByPath.xml diff --git a/modules/autoinstall/autoinstall.admin.controller.php b/modules/autoinstall/autoinstall.admin.controller.php index 3efb7d275..7f677465c 100644 --- a/modules/autoinstall/autoinstall.admin.controller.php +++ b/modules/autoinstall/autoinstall.admin.controller.php @@ -30,7 +30,7 @@ $this->setMessage("success_updated", 'update'); $this->setRedirectUrl(Context::get('error_return_url')); } - + function _updateinfo(){ $oModel = &getModel('autoinstall'); $item = $oModel->getLatestPackage(); @@ -64,7 +64,7 @@ $type = $oModel->getTypeFromPath($package->path); if($type == "core") { - $version = __ZBXE_VERSION__; + $version = __ZBXE_VERSION__; } else { @@ -85,7 +85,7 @@ case "style": case "m.skin": $type = "skin"; - case "skin": + case "skin": case "widgetstyle": $config_file = "/skin.xml"; break; @@ -155,9 +155,9 @@ $output = $oModuleInstaller->install(); if(!$output->toBool()) return $output; } - + $this->_updateinfo(); - + $this->setMessage('success_installed', 'update'); $this->setRedirectUrl(preg_replace('/act=[^&]*/', 'act=dispAutoinstallAdminIndex', Context::get('error_return_url'))); } @@ -249,7 +249,7 @@ if(!$output->toBool()) return $output; $this->_updateinfo(); - + $this->setMessage('success_deleted', 'update'); $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminInstalledPackages')); } diff --git a/modules/autoinstall/autoinstall.admin.view.php b/modules/autoinstall/autoinstall.admin.view.php index 43bbc7bec..a250133f4 100644 --- a/modules/autoinstall/autoinstall.admin.view.php +++ b/modules/autoinstall/autoinstall.admin.view.php @@ -2,7 +2,7 @@ /** * @class autoinstallAdminView * @author NHN (developers@xpressengine.com) - * @brief admin view class in the autoinstall module + * @brief admin view class in the autoinstall module **/ @@ -20,7 +20,7 @@ $ftp_info = Context::getFTPInfo(); if(!$ftp_info->ftp_root_path) Context::set('show_ftp_note', true); else $this->ftp_set = true; - + $this->dispCategory(); $oModel = &getModel('autoinstall'); @@ -70,9 +70,9 @@ } if($v->type == "core") $v->avail_remove = false; else if($v->type == "module") { - $v->avail_remove = $oModel->checkRemovable($packages[$v->package_srl]->path); + $v->avail_remove = $oModel->checkRemovable($packages[$v->package_srl]->path); } - else $v->avail_remove = true; + else $v->avail_remove = true; } $item_list[$v->package_srl] = $v; } @@ -98,6 +98,7 @@ $installed[$key]->title = $title; } Context::set('installed', $installed); + foreach($installed as $key=>$val) { foreach($depto[$key] as $package_srl) @@ -114,14 +115,14 @@ function dispAutoinstallAdminInstalledPackages() { $page = Context::get('page'); - if(!$page) $page = 1; + if(!$page) $page = 1; Context::set('page', $page); $oModel = &getModel('autoinstall'); $output = $oModel->getInstalledPackageList($page); $package_list = $output->data; $params["act"] = "getResourceapiPackages"; - $params["package_srls"] = implode(",", array_keys($package_list)); + $params["package_srls"] = implode(",", array_keys($package_list)); $body = XmlGenerater::generate($params); $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml"); $xml_lUpdate = new XmlParser(); @@ -134,11 +135,11 @@ { $res[] = $item_list[$package_srl]; } - Context::set('item_list', $res); + Context::set('item_list', $res); } Context::set('page_navigation', $output->page_navigation); - $this->setTemplateFile('index'); + $this->setTemplateFile('index'); } function dispAutoinstallAdminInstall() { @@ -237,7 +238,7 @@ } $page = Context::get('page'); - if(!$page) $page = 1; + if(!$page) $page = 1; Context::set('page', $page); $order_type = Context::get('order_type'); @@ -263,13 +264,13 @@ { $params["search_keyword"] = $search_keyword; } - $xmlDoc = XmlGenerater::getXmlDoc($params); + $xmlDoc = XmlGenerater::getXmlDoc($params); if($xmlDoc && $xmlDoc->response->packagelist->item) { $item_list = $this->rearranges($xmlDoc->response->packagelist->item); - Context::set('item_list', $item_list); + Context::set('item_list', $item_list); $array = array('total_count', 'total_page', 'cur_page', 'page_count', 'first_page', 'last_page'); - $page_nav = $this->rearrange($xmlDoc->response->page_navigation, $array); + $page_nav = $this->rearrange($xmlDoc->response->page_navigation, $array); $page_navigation = new PageHandler($page_nav->total_count, $page_nav->total_page, $page_nav->cur_page, $page_nav->page_count); Context::set('page_navigation', $page_navigation); } @@ -298,22 +299,42 @@ $installedPackage = $oModel->getPackage($package_srl); $path = $installedPackage->path; $type = $oModel->getTypeFromPath($path); - if(!$type || $type == "core") return $this->stop("msg_invalid_request"); + if(!$type || $type == "core") return $this->stop("msg_invalid_request"); $config_file = $oModel->getConfigFilePath($type); - if(!$config_file) return $this->stop("msg_invalid_request"); + if(!$config_file) return $this->stop("msg_invalid_request"); - $xml = new XmlParser(); - $xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($path).$config_file); - if(!$xmlDoc) return $this->stop("msg_invalid_request"); - if($type == "drcomponent") $type = "component"; - if($type == "style") $type = "skin"; - $title = $xmlDoc->{$type}->title->body; - $installedPackage->title = $title; - $installedPackage->type = $type; - Context::set('package', $installedPackage); + // $xml = new XmlParser(); + // $xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($path).$config_file); + // if(!$xmlDoc) return $this->stop("msg_invalid_request"); + // if($type == "drcomponent") $type = "component"; + // if($type == "style") $type = "skin"; + // $title = $xmlDoc->{$type}->title->body; + // $installedPackage->title = $title; + // $installedPackage->type = $type; + // Context::set('package', $installedPackage); - $this->setTemplateFile('uninstall'); - Context::addJsFilter($this->module_path.'tpl/filter', 'uninstall_package.xml'); + $params["act"] = "getResourceapiPackages"; + $params["package_srls"] = $package_srl; + $body = XmlGenerater::generate($params); + $buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml"); + $xml_lUpdate = new XmlParser(); + $xmlDoc = $xml_lUpdate->parse($buff); + if($xmlDoc && $xmlDoc->response->packagelist->item) + { + $item_list = $this->rearranges($xmlDoc->response->packagelist->item); + $installedPackage->title = $item_list[$package_srl]->title; + $installedPackage->type = $item_list[$package_srl]->category; + $installedPackage->avail_remove = $item_list[$package_srl]->avail_remove; + $installedPackage->deps = $item_list[$package_srl]->deps; + Context::set('package', $installedPackage); + + $this->setTemplateFile('uninstall'); + Context::addJsFilter($this->module_path.'tpl/filter', 'uninstall_package.xml'); + } + else + { + return $this->stop('Connection failed'); + } } } ?> diff --git a/modules/autoinstall/autoinstall.model.php b/modules/autoinstall/autoinstall.model.php index 726d3497b..5166b89ab 100644 --- a/modules/autoinstall/autoinstall.model.php +++ b/modules/autoinstall/autoinstall.model.php @@ -94,7 +94,7 @@ { $siblingList .= ",".$this->setDepth($list[$child->category_srl], $depth+1, $list, $resultList); } - if(count($item->children) < 1) + if(count($item->children) < 1) { $item->nPackages = $this->getPackageCount($item->category_srl); } @@ -123,6 +123,8 @@ function getInstalledPackageList($page) { $args->page = $page; + $args->list_count = 10; + $args->page_count = 5; $output = executeQueryArray("autoinstall.getInstalledPackageList", $args); $res = array(); foreach($output->data as $val) @@ -159,7 +161,7 @@ $config_file = "/info.xml"; break; case "m.skin": - case "skin": + case "skin": case "widgetstyle": case "style": $config_file = "/skin.xml"; @@ -176,10 +178,32 @@ $path_array = explode("/", $path); $target_name = array_pop($path_array); $oModule =& getModule($target_name, "class"); - if(!$oModule) return false; + if(!$oModule) return false; if(method_exists($oModule, "moduleUninstall")) return true; else return false; } + function getPackageSrlByPath($path) + { + if (!$path) return; + + if(substr($path,-1) == '/') $path = substr($path, 0, strlen($path)-1); + + $args->path = $path; + $output = executeQuery('autoinstall.getPackageSrlByPath', $args); + + return $output->data->package_srl; + } + + function getRemoveUrlByPath($path) + { + if (!$path) return; + + $packageSrl = $this->getPackageSrlByPath($path); + if (!$packageSrl) return; + + return getUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminUninstall', 'package_srl', $packageSrl); + } + } ?> diff --git a/modules/autoinstall/lang/en.lang.php b/modules/autoinstall/lang/en.lang.php index 1e83417d2..515b82f23 100644 --- a/modules/autoinstall/lang/en.lang.php +++ b/modules/autoinstall/lang/en.lang.php @@ -33,4 +33,6 @@ $lang->name = 'Name'; $lang->about_depending_programs = 'To use this package must be installed the fllowing program.'; $lang->ftp_password = 'FTP password'; + $lang->msg_dependency_package = 'Can not remove this package because there exists another package dependent on this.'; + $lang->dependant_list = "Dependant package list of the current package"; ?> diff --git a/modules/autoinstall/lang/jp.lang.php b/modules/autoinstall/lang/jp.lang.php index 97d9f020e..f639862b3 100644 --- a/modules/autoinstall/lang/jp.lang.php +++ b/modules/autoinstall/lang/jp.lang.php @@ -1,7 +1,7 @@ autoinstall = 'イージーインストール'; @@ -32,4 +32,6 @@ $lang->name = 'Name'; $lang->about_depending_programs = 'To use this package must be installed the fllowing program.'; $lang->ftp_password = 'FTP password'; + $lang->msg_dependency_package = 'Can not remove this package because there exists another package dependent on this.'; + $lang->dependant_list = "このパッケージに依存するパッケージのリスト"; ?> diff --git a/modules/autoinstall/lang/ko.lang.php b/modules/autoinstall/lang/ko.lang.php index 18ada5afa..1e202e417 100644 --- a/modules/autoinstall/lang/ko.lang.php +++ b/modules/autoinstall/lang/ko.lang.php @@ -32,4 +32,6 @@ $lang->name = '이름'; $lang->about_depending_programs = '이 패키지 사용을 위해서는 아래 프로그램이 설치되어 있어야 합니다.'; $lang->ftp_password = 'FTP 비밀번호'; + $lang->msg_dependency_package = '이 패키지를 의존하고 있는 다른 패키지가 있기 때문에 삭제할 수 없습니다.'; + $lang->dependant_list = "이 패키지에 의존하는 패키지 목록"; ?> diff --git a/modules/autoinstall/lang/ru.lang.php b/modules/autoinstall/lang/ru.lang.php index 0bf3823cd..ba848721b 100644 --- a/modules/autoinstall/lang/ru.lang.php +++ b/modules/autoinstall/lang/ru.lang.php @@ -32,4 +32,6 @@ $lang->name = 'Name'; $lang->about_depending_programs = 'To use this package must be installed the fllowing program.'; $lang->ftp_password = 'FTP password'; + $lang->msg_dependency_package = 'Can not remove this package because there exists another package dependent on this.'; + $lang->dependant_list = "Dependant package list of the current package"; ?> diff --git a/modules/autoinstall/lang/tr.lang.php b/modules/autoinstall/lang/tr.lang.php index af7938e85..37e222e4b 100644 --- a/modules/autoinstall/lang/tr.lang.php +++ b/modules/autoinstall/lang/tr.lang.php @@ -32,4 +32,6 @@ $lang->name = 'Name'; $lang->about_depending_programs = 'To use this package must be installed the fllowing program.'; $lang->ftp_password = 'FTP password'; + $lang->msg_dependency_package = 'Can not remove this package because there exists another package dependent on this.'; + $lang->dependant_list = "Mevcut pakete bağlı paket listesi"; ?> diff --git a/modules/autoinstall/lang/vi.lang.php b/modules/autoinstall/lang/vi.lang.php index d02aa8395..a26b993b0 100644 --- a/modules/autoinstall/lang/vi.lang.php +++ b/modules/autoinstall/lang/vi.lang.php @@ -32,4 +32,6 @@ $lang->name = 'Name'; $lang->about_depending_programs = 'To use this package must be installed the fllowing program.'; $lang->ftp_password = 'FTP password'; + $lang->msg_dependency_package = 'Can not remove this package because there exists another package dependent on this.'; + $lang->dependant_list = "Gói cài đặt này phụ thuộc vào các gói khác trong danh sách"; ?> diff --git a/modules/autoinstall/lang/zh-CN.lang.php b/modules/autoinstall/lang/zh-CN.lang.php index 83ac499b3..ce21fdbad 100644 --- a/modules/autoinstall/lang/zh-CN.lang.php +++ b/modules/autoinstall/lang/zh-CN.lang.php @@ -32,4 +32,6 @@ $lang->name = 'Name'; $lang->about_depending_programs = 'To use this package must be installed the fllowing program.'; $lang->ftp_password = 'FTP password'; + $lang->msg_dependency_package = 'Can not remove this package because there exists another package dependent on this.'; + $lang->dependant_list = "联动数据包列表"; ?> diff --git a/modules/autoinstall/lang/zh-TW.lang.php b/modules/autoinstall/lang/zh-TW.lang.php index ab92bb86a..04eba9f31 100644 --- a/modules/autoinstall/lang/zh-TW.lang.php +++ b/modules/autoinstall/lang/zh-TW.lang.php @@ -33,4 +33,6 @@ $lang->name = 'Name'; $lang->about_depending_programs = 'To use this package must be installed the fllowing program.'; $lang->ftp_password = 'FTP password'; + $lang->msg_dependency_package = 'Can not remove this package because there exists another package dependent on this.'; + $lang->dependant_list = "與此程式相關程式列表"; ?> diff --git a/modules/autoinstall/queries/getPackageSrlByPath.xml b/modules/autoinstall/queries/getPackageSrlByPath.xml new file mode 100644 index 000000000..fef67cbdc --- /dev/null +++ b/modules/autoinstall/queries/getPackageSrlByPath.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/modules/autoinstall/tpl/install.html b/modules/autoinstall/tpl/install.html index d93a135a3..9cf0f4bba 100644 --- a/modules/autoinstall/tpl/install.html +++ b/modules/autoinstall/tpl/install.html @@ -1,5 +1,5 @@ -{@debugPrint($package)} +

{$package->title} ver. {$package->version}

{$lang->current_version}: {$package->cur_version} ({$lang->require_update})

{$lang->require_installation}

diff --git a/modules/autoinstall/tpl/list.html b/modules/autoinstall/tpl/list.html index d7e4d0d26..b31b6f641 100644 --- a/modules/autoinstall/tpl/list.html +++ b/modules/autoinstall/tpl/list.html @@ -20,7 +20,7 @@ {@$_popular_order_type = 'desc'} - + Sort by {$lang->order_newest} | {$lang->order_download} | @@ -39,6 +39,7 @@
+ {@ $target_url = $original_site."?mid=download&package_srl=".$item->package_srl; } @@ -72,16 +77,11 @@ - + « FIRST 1 - ... - - - - - {$page_navigation->last_page} + ... {@$last_page = $page_no} @@ -89,14 +89,14 @@ {$page_no} - ... - - - - + ... {$page_navigation->last_page} LAST » + + + + diff --git a/modules/autoinstall/tpl/uninstall.html b/modules/autoinstall/tpl/uninstall.html index 64ad41fd6..e4f8ab038 100644 --- a/modules/autoinstall/tpl/uninstall.html +++ b/modules/autoinstall/tpl/uninstall.html @@ -3,25 +3,36 @@

{$package->title}

{$package->type} ({$package->path})

-
-

{$lang->description_uninstall}

-
- -
-

{$XE_VALIDATOR_MESSAGE}

-
- - - - - - - -

-

{$lang->about_ftp_password}

-
- -
- + +
+

{$lang->description_uninstall}

- \ No newline at end of file + +
+

{$XE_VALIDATOR_MESSAGE}

+
+
+ + + + + + +

+

{$lang->about_ftp_password}

+
+ +
+ +
+ +
+ +
+

{$lang->msg_dependency_package}

+
+

{$lang->dependant_list}:

+
    +
  • {$installed[$dep_package_srl]->title}
  • +
+
\ No newline at end of file
{$item->category} @@ -50,6 +51,10 @@ {$lang->package_update} {zdate($item->item_regdate, "Y-m-d H:i")} | {$lang->package_downloaded_count} : {number_format($item->package_downloaded)}

+

{$lang->dependant_list}:

+
    +
  • {$installed[$package_srl]->title}
  • +
{htmlspecialchars($item->item_version)} {htmlspecialchars($item->current_version)}