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
This commit is contained in:
flyskyko 2011-07-26 07:04:49 +00:00
parent 9acd474c52
commit 5f7be4a7f1
15 changed files with 153 additions and 70 deletions

View file

@ -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'));
}

View file

@ -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');
}
}
}
?>

View file

@ -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);
}
}
?>

View file

@ -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";
?>

View file

@ -1,7 +1,7 @@
<?php
/**
* @file modules/autoinstall/lang/jp.lang.php
* @author NHN (developers@xpressengine.com) 翻訳:ミニミ
* @author NHN (developers@xpressengine.com) 翻訳:ミニミ
* @brief Autoinstall(autoinstall) 日本語基本言語パッケージ
**/
$lang->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 = "このパッケージに依存するパッケージのリスト";
?>

View file

@ -32,4 +32,6 @@
$lang->name = '이름';
$lang->about_depending_programs = '이 패키지 사용을 위해서는 아래 프로그램이 설치되어 있어야 합니다.';
$lang->ftp_password = 'FTP 비밀번호';
$lang->msg_dependency_package = '이 패키지를 의존하고 있는 다른 패키지가 있기 때문에 삭제할 수 없습니다.';
$lang->dependant_list = "이 패키지에 의존하는 패키지 목록";
?>

View file

@ -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";
?>

View file

@ -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";
?>

View file

@ -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";
?>

View file

@ -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 = "联动数据包列表";
?>

View file

@ -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 = "與此程式相關程式列表";
?>

View file

@ -0,0 +1,11 @@
<query id="getPackageSqlByPath" action="select">
<tables>
<table name="autoinstall_packages" />
</tables>
<columns>
<column name="package_srl" />
</columns>
<conditions>
<condition operation="equal" column="path" var="path" notnull="notnull" />
</conditions>
</query>

View file

@ -1,5 +1,5 @@
<include target="header.html" />
{@debugPrint($package)}
<h2 class="h2">{$package->title} ver. {$package->version}</h2>
<p cond="$package->installed">{$lang->current_version}: {$package->cur_version} <block cond="$package->need_update">({$lang->require_update})</block></p>
<p cond="!$package->installed">{$lang->require_installation}</p>

View file

@ -20,7 +20,7 @@
<!--@else-->
{@$_popular_order_type = 'desc'}
<!--@end-->
Sort by
<a href="{getUrl('order_target','newest','order_type',$_newest_order_type)}">{$lang->order_newest}</a> <!--@if($order_target == 'newest')--><!--@if($_newest_order_type == 'asc')--><!--@else--><!--@end--><!--@end--> |
<a href="{getUrl('order_target','download','order_type',$_download_order_type)}">{$lang->order_download}</a> <!--@if($order_target == 'download')--><!--@if($_download_order_type == 'asc')--><!--@else--><!--@end--><!--@end--> |
@ -39,6 +39,7 @@
</thead>
<tbody>
<tr loop="$item_list => $key, $item">
{@ $target_url = $original_site."?mid=download&package_srl=".$item->package_srl; }
<td>{$item->category}</td>
<td class="title"><img src="{str_replace('./', $uri, $item->item_screenshot_url)}" alt="" width="100" height="100" /></td>
<td class="title">
@ -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)}
</p>
<p cond="$item->deps">{$lang->dependant_list}:</p>
<ul cond="$item->deps">
<li loop="$item->deps => $package_srl">{$installed[$package_srl]->title}</li>
</ul>
</td>
<td>{htmlspecialchars($item->item_version)}</td>
<td>{htmlspecialchars($item->current_version)}</td>
@ -72,16 +77,11 @@
<input cond="$category_srl" type="hidden" name="category_srl" value="{$category_srl}" />
<input cond="$childrenList" type="hidden" name="childrenList" value="{$childrenList}" />
<input cond="$search_keyword" type="hidden" name="search_keyword" value="{$search_keyword}" />
<a href="{getUrl('page', '')}" class="direction">&laquo; FIRST</a>
<block cond="$page_navigation->first_page + $page_navigation->page_count > $page_navigation->last_page && $page_navigation->page_count != $page_navigation->total_page">
<a href="{getUrl('page', '')}">1</a>
<a href="#goTo" class="tgSimple">...</a>
<span id="goTo" class="tgContent">
<input name="page" title="Go to Page" />
<button type="submit">Go</button>
</span>
<a href="{getUrl('page', $page_navigation->last_page)}">{$page_navigation->last_page}</a>
<a href="#goTo" class="tgSimple" title="{$lang->cmd_go_to_page}">...</a>
</block>
<!--@while($page_no = $page_navigation->getNextPage())-->
{@$last_page = $page_no}
@ -89,14 +89,14 @@
<a cond="$page_no != $page" href="{getUrl('page', $page_no)}">{$page_no}</a>
<!--@end-->
<block cond="$last_page != $page_navigation->last_page">
<a href="#goTo" class="tgSimple">...</a>
<span id="goTo" class="tgContent">
<input name="page" title="Go to Page" />
<button type="submit">Go</button>
</span>
<a href="#goTo" class="tgSimple" title="{$lang->cmd_go_to_page}">...</a>
<a href="{getUrl('page', $page_navigation->last_page)}">{$page_navigation->last_page}</a>
</block>
<a href="{getUrl('page', $page_navigation->last_page)}" class="direction">LAST &raquo;</a>
<span id="goTo" class="tgContent">
<input name="page" title="{$lang->cmd_go_to_page}" />
<button type="submit">Go</button>
</span>
</form>
<form cond="$act == 'dispAutoinstallAdminIndex'" action="./">
<input type="hidden" name="error_return_url" value="" />

View file

@ -3,25 +3,36 @@
<h2 class="h2">{$package->title}</h2>
<p>{$package->type} ({$package->path})</p>
<div class="message info">
<p>{$lang->description_uninstall}</p>
</div>
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>
<form action="" class="form" method="post">
<input type="hidden" name="module" value="autoinstall" />
<input type="hidden" name="act" value="procAutoinstallAdminUninstallPackage" />
<input type="hidden" name="package_srl" value="{$package_srl}" />
<input cond="!$need_password" type="hidden" name="ftp_password" value="dummy" />
<block cond="$need_password">
<p class="q"><label for="ftp_password">FTP {$lang->password}</label></p>
<p class="a"><input type="password" name="ftp_password" id="ftp_password" value="" /> <span class="desc">{$lang->about_ftp_password}</span></p>
</block>
<div class="btnArea">
<span class="btn medium"><input type="submit" value="{$lang->cmd_delete}" /></span>
<block cond="$package->avail_remove">
<div class="message info">
<p>{$lang->description_uninstall}</p>
</div>
</form>
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>
<form action="" class="form" method="post">
<input type="hidden" name="module" value="autoinstall" />
<input type="hidden" name="act" value="procAutoinstallAdminUninstallPackage" />
<input type="hidden" name="package_srl" value="{$package_srl}" />
<input cond="!$need_password" type="hidden" name="ftp_password" value="dummy" />
<block cond="$need_password">
<p class="q"><label for="ftp_password">FTP {$lang->password}</label></p>
<p class="a"><input type="password" name="ftp_password" id="ftp_password" value="" /> <span class="desc">{$lang->about_ftp_password}</span></p>
</block>
<div class="btnArea">
<span class="btn medium"><input type="submit" value="{$lang->cmd_delete}" /></span>
</div>
</form>
</block>
<block cond="!$package->avail_remove">
<div class="message error">
<p>{$lang->msg_dependency_package}</p>
</div>
<p cond="$package->deps">{$lang->dependant_list}:</p>
<ul cond="$package->deps">
<li loop="$package->deps => $dep_package_srl">{$installed[$dep_package_srl]->title}</li>
</ul>
</block>