issue 2119. supporting php 5.4. autoinstall module.

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12714 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2013-02-06 09:47:19 +00:00
parent 0841f7be53
commit 6be23a3ac2
7 changed files with 610 additions and 324 deletions

View file

@ -1,5 +1,7 @@
<?php
require_once(_XE_PATH_.'modules/autoinstall/autoinstall.lib.php');
require_once(_XE_PATH_ . 'modules/autoinstall/autoinstall.lib.php');
/**
* autoinstall module admin controller class
*
@ -7,11 +9,13 @@ require_once(_XE_PATH_.'modules/autoinstall/autoinstall.lib.php');
*/
class autoinstallAdminController extends autoinstall
{
/**
* Initialization
*/
function init()
{
}
/**
@ -57,7 +61,7 @@ class autoinstallAdminController extends autoinstall
*/
function _updateinfo()
{
$oModel = &getModel('autoinstall');
$oModel = getModel('autoinstall');
$item = $oModel->getLatestPackage();
if($item)
{
@ -73,7 +77,7 @@ class autoinstallAdminController extends autoinstall
$this->updatePackages($xmlDoc);
$this->checkInstalled();
$oAdminController = &getAdminController('admin');
$oAdminController = getAdminController('admin');
$output = $oAdminController->cleanFavorite();
}
@ -85,7 +89,7 @@ class autoinstallAdminController extends autoinstall
function checkInstalled()
{
executeQuery("autoinstall.deleteInstalledPackage");
$oModel =& getModel('autoinstall');
$oModel = getModel('autoinstall');
$packages = $oModel->getPackages();
foreach($packages as $package)
{
@ -102,7 +106,7 @@ class autoinstallAdminController extends autoinstall
}
else
{
$config_file = null;
$config_file = NULL;
switch($type)
{
case "m.layout":
@ -132,10 +136,20 @@ class autoinstallAdminController extends autoinstall
$type = "theme";
break;
}
if(!$config_file) continue;
if(!$config_file)
{
continue;
}
$xml = new XmlParser();
$xmlDoc = $xml->loadXmlFile($real_path.$config_file);
if(!$xmlDoc) continue;
$xmlDoc = $xml->loadXmlFile($real_path . $config_file);
if(!$xmlDoc)
{
continue;
}
$version = $xmlDoc->{$type}->version->body;
}
@ -145,11 +159,11 @@ class autoinstallAdminController extends autoinstall
$args->current_version = $version;
if(version_compare($args->version, $args->current_version, ">"))
{
$args->need_update="Y";
$args->need_update = "Y";
}
else
{
$args->need_update="N";
$args->need_update = "N";
}
$output = executeQuery("autoinstall.insertInstalledPackage", $args);
@ -165,9 +179,9 @@ class autoinstallAdminController extends autoinstall
{
@set_time_limit(0);
$package_srls = Context::get('package_srl');
$oModel =& getModel('autoinstall');
$oModel = getModel('autoinstall');
$packages = explode(',', $package_srls);
$ftp_info = Context::getFTPInfo();
$ftp_info = Context::getFTPInfo();
if(!$_SESSION['ftp_password'])
{
$ftp_password = Context::get('ftp_password');
@ -197,7 +211,10 @@ class autoinstallAdminController extends autoinstall
$oModuleInstaller->setServerUrl(_XE_DOWNLOAD_SERVER_);
$oModuleInstaller->setPassword($ftp_password);
$output = $oModuleInstaller->install();
if(!$output->toBool()) return $output;
if(!$output->toBool())
{
return $output;
}
}
$this->_updateinfo();
@ -222,8 +239,11 @@ class autoinstallAdminController extends autoinstall
*/
function updatePackages(&$xmlDoc)
{
$oModel =& getModel('autoinstall');
if(!$xmlDoc->response->packages->item) return;
$oModel = getModel('autoinstall');
if(!$xmlDoc->response->packages->item)
{
return;
}
if(!is_array($xmlDoc->response->packages->item))
{
$xmlDoc->response->packages->item = array($xmlDoc->response->packages->item);
@ -231,7 +251,7 @@ class autoinstallAdminController extends autoinstall
$targets = array('package_srl', 'updatedate', 'latest_item_srl', 'path', 'version', 'category_srl', 'have_instance');
foreach($xmlDoc->response->packages->item as $item)
{
$args = null;
$args = new stdClass();
foreach($targets as $target)
{
$args->{$target} = $item->{$target}->body;
@ -261,7 +281,7 @@ class autoinstallAdminController extends autoinstall
function updateCategory(&$xmlDoc)
{
executeQuery("autoinstall.deleteCategory");
$oModel =& getModel('autoinstall');
$oModel = getModel('autoinstall');
if(!is_array($xmlDoc->response->categorylist->item))
{
$xmlDoc->response->categorylist->item = array($xmlDoc->response->categorylist->item);
@ -306,7 +326,7 @@ class autoinstallAdminController extends autoinstall
*/
function uninstallPackageByPackageSrl($package_srl)
{
$oModel =& getModel('autoinstall');
$oModel = getModel('autoinstall');
$package = $oModel->getPackage($package_srl);
$this->_uninstallPackage($package);
@ -335,7 +355,7 @@ class autoinstallAdminController extends autoinstall
{
$ftp_password = $_SESSION['ftp_password'];
}
$ftp_info = Context::getFTPInfo();
$ftp_info = Context::getFTPInfo();
$isSftpSupported = function_exists(ssh2_sftp);
if($ftp_info->sftp && $ftp_info->sftp == 'Y' && $isSftpSupported)
@ -355,12 +375,16 @@ class autoinstallAdminController extends autoinstall
$oModuleInstaller->setPassword($ftp_password);
$output = $oModuleInstaller->uninstall();
if(!$output->toBool()) return $output;
if(!$output->toBool())
{
return $output;
}
$this->_updateinfo();
$this->setMessage('success_deleted', 'update');
}
}
/* End of file autoinstall.admin.controller.php */
/* Location: ./modules/autoinstall/autoinstall.admin.controller.php */

View file

@ -1,4 +1,5 @@
<?php
/**
* Model class of the autoinstall module
* @author NHN (developers@xpressengine.com)
@ -28,7 +29,7 @@ class autoinstallAdminModel extends autoinstall
$order_type = 'desc';
}
$page = (int)$page;
$page = (int) $page;
if($page < 1)
{
$page = 1;
@ -164,14 +165,14 @@ class autoinstallAdminModel extends autoinstall
{
$is_authed = 0;
$ftp_info = Context::getFTPInfo();
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_root_path)
{
$is_authed = -1;
}
else
{
$is_authed = (int)isset($_SESSION['ftp_password']);
$is_authed = (int) isset($_SESSION['ftp_password']);
}
$this->add('is_authed', $is_authed);
@ -184,14 +185,17 @@ class autoinstallAdminModel extends autoinstall
{
$oModel = getModel('autoinstall');
$output = executeQueryArray('autoinstall.getNeedUpdate');
if(!is_array($output->data)) return NULL;
if(!is_array($output->data))
{
return NULL;
}
$result = array();
$xml = new XmlParser();
foreach($output->data as $package)
{
$packageSrl = $package->package_srl;
$packageInfo = new stdClass();
$packageInfo->currentVersion = $package->current_version;
$packageInfo->version = $package->version;
@ -210,9 +214,18 @@ class autoinstallAdminModel extends autoinstall
if($xmlDoc)
{
$type = $packageInfo->type;
if($type == "drcomponent") $type = "component";
if($type == "style" || $type == "m.skin") $type = "skin";
if($type == "m.layout") $type = "layout";
if($type == "drcomponent")
{
$type = "component";
}
if($type == "style" || $type == "m.skin")
{
$type = "skin";
}
if($type == "m.layout")
{
$type = "layout";
}
$title = $xmlDoc->{$type}->title->body;
}
else

View file

@ -1,10 +1,12 @@
<?php
/**
* Admin view class in the autoinstall module
* @author NHN (developers@xpressengine.com)
*/
class autoinstallAdminView extends autoinstall
{
/**
* Category list
* @var array
@ -15,7 +17,7 @@ class autoinstallAdminView extends autoinstall
* Is set a ftp information
* @var bool
*/
var $ftp_set = false;
var $ftp_set = FALSE;
/**
* initialize
@ -24,18 +26,24 @@ class autoinstallAdminView extends autoinstall
*/
function init()
{
$template_path = sprintf("%stpl/",$this->module_path);
$template_path = sprintf("%stpl/", $this->module_path);
Context::set('original_site', _XE_LOCATION_SITE_);
Context::set('uri', _XE_DOWNLOAD_SERVER_);
$this->setTemplatePath($template_path);
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_root_path) Context::set('show_ftp_note', true);
else $this->ftp_set = true;
$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');
Context::set('tCount', $oModel->getPackageCount(null));
$oModel = getModel('autoinstall');
Context::set('tCount', $oModel->getPackageCount(NULL));
Context::set('iCount', $oModel->getInstalledPackageCount());
}
@ -46,19 +54,19 @@ class autoinstallAdminView extends autoinstall
* $item:
* stdClass Object
* (
* [category_srl] => stdClass Object
* (
* [body] => xxx
* )
* [package_srl] => stdClass Object
* (
* [body] => xxx
* )
* ...
* [depfrom] => stdClass Object
* (
* [body] => xxx
* )
* [category_srl] => stdClass Object
* (
* [body] => xxx
* )
* [package_srl] => stdClass Object
* (
* [body] => xxx
* )
* ...
* [depfrom] => stdClass Object
* (
* [body] => xxx
* )
* )
*
* $targets:
@ -67,10 +75,10 @@ class autoinstallAdminView extends autoinstall
* returns:
* stdClass Object
* (
* [category_srl] => xxx
* [package_srl] => xxx
* ...
* [depfrom] => xxx
* [category_srl] => xxx
* [package_srl] => xxx
* ...
* [depfrom] => xxx
* )
* </pre>
*
@ -95,62 +103,62 @@ class autoinstallAdminView extends autoinstall
* $items:
* Array
* (
* [0] => stdClass Object
* (
* [category_srl] => stdClass Object
* (
* [body] => xxx
* )
* [package_srl] => stdClass Object
* (
* [body] => xxx
* )
* ...
* [depfrom] => stdClass Object
* (
* [body] => xxx
* )
* )
* [1] => stdClass Object
* (
* ...
* )
* ...
* [0] => stdClass Object
* (
* [category_srl] => stdClass Object
* (
* [body] => xxx
* )
* [package_srl] => stdClass Object
* (
* [body] => xxx
* )
* ...
* [depfrom] => stdClass Object
* (
* [body] => xxx
* )
* )
* [1] => stdClass Object
* (
* ...
* )
* ...
* )
*
* $packages:
* Array
* (
* [<i>package_srl</i>] => stdClass Object
* (
* [current_version] => xxx
* [need_update] => xxx
* [path] => xxx
* ...
* )
* ...
* [<i>package_srl</i>] => stdClass Object
* (
* [current_version] => xxx
* [need_update] => xxx
* [path] => xxx
* ...
* )
* ...
* )
*
* return:
* Array
* (
* [<i>package_srl</i>] => stdClass Object
* (
* [category_srl] => xxx
* [package_srl] => xxx
* ...
* [category] => xxx
* [current_version] => xxx
* [type] => xxx
* [need_update] => xxx
* [avail_remove] => xxx
* [deps] => Array
* (
* [0] => xxx
* ...
* )
* )
* ...
* [<i>package_srl</i>] => stdClass Object
* (
* [category_srl] => xxx
* [package_srl] => xxx
* ...
* [category] => xxx
* [current_version] => xxx
* [type] => xxx
* [need_update] => xxx
* [avail_remove] => xxx
* [deps] => Array
* (
* [0] => xxx
* ...
* )
* )
* ...
* )
* </pre>
*
@ -160,18 +168,29 @@ class autoinstallAdminView extends autoinstall
*/
function rearranges($items, $packages = null)
{
if(!is_array($items)) $items = array($items);
if(!is_array($items))
{
$items = array($items);
}
$item_list = array();
$targets = array('category_srl', 'package_srl', 'item_screenshot_url', 'package_voted', 'package_voter', 'package_description', 'package_downloaded', 'item_regdate', 'title', 'item_version', 'package_star', 'depfrom');
$targetpackages = array();
foreach($items as $item)
{
$targetpackages[$item->package_srl->body] = 0;
}
$oModel = &getModel('autoinstall');
$oModel = getModel('autoinstall');
if($package == null)
{
$packages = $oModel->getInstalledPackages(array_keys($targetpackages));
}
$depto = array();
foreach($items as $item)
{
$v = $this->rearrange($item, $targets);
@ -184,20 +203,28 @@ class autoinstallAdminView extends autoinstall
$v->current_version = $packages[$v->package_srl]->current_version;
$v->need_update = $packages[$v->package_srl]->need_update;
$v->type = $oModel->getTypeFromPath($packages[$v->package_srl]->path);
if($this->ftp_set && $v->depfrom)
{
$depfrom = explode("," , $v->depfrom);
$depfrom = explode(",", $v->depfrom);
foreach($depfrom as $package_srl)
{
$depto[$package_srl][] = $v->package_srl;
}
}
if($v->type == "core") $v->avail_remove = false;
if($v->type == "core")
{
$v->avail_remove = FALSE;
}
else if($v->type == "module")
{
$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;
}
@ -205,27 +232,48 @@ class autoinstallAdminView extends autoinstall
if(count($depto) > 0)
{
$installed = $oModel->getInstalledPackages(implode(",", array_keys($depto)));
foreach($installed as $key=>$val)
foreach($installed as $key => $val)
{
$path = $val->path;
$type = $oModel->getTypeFromPath($path);
if(!$type || $type == "core") continue;
if(!$type || $type == "core")
{
continue;
}
$config_file = $oModel->getConfigFilePath($type);
if(!$config_file) continue;
if(!$config_file)
{
continue;
}
$xml = new XmlParser();
$xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($path).$config_file);
if(!$xmlDoc) continue;
if($type == "drcomponent") $type = "component";
if($type == "style" || $type == "m.skin") $type = "skin";
if($type == "m.layout") $type = "layout";
$xmlDoc = $xml->loadXmlFile(FileHandler::getRealPath($path) . $config_file);
if(!$xmlDoc)
{
continue;
}
if($type == "drcomponent")
{
$type = "component";
}
if($type == "style" || $type == "m.skin")
{
$type = "skin";
}
if($type == "m.layout")
{
$type = "layout";
}
$title = $xmlDoc->{$type}->title->body;
$installed[$key]->title = $title;
}
Context::set('installed', $installed);
foreach($installed as $key=>$val)
foreach($installed as $key => $val)
{
foreach($depto[$key] as $package_srl)
{
@ -246,9 +294,13 @@ class autoinstallAdminView extends autoinstall
function dispAutoinstallAdminInstalledPackages()
{
$page = Context::get('page');
if(!$page) $page = 1;
if(!$page)
{
$page = 1;
}
Context::set('page', $page);
$oModel = &getModel('autoinstall');
$oModel = getModel('autoinstall');
$output = $oModel->getInstalledPackageList($page);
$package_list = $output->data;
@ -297,17 +349,20 @@ class autoinstallAdminView extends autoinstall
function dispAutoinstallAdminInstall()
{
$package_srl = Context::get('package_srl');
if(!$package_srl) return $this->dispAutoinstallAdminIndex();
if(!$package_srl)
{
return $this->dispAutoinstallAdminIndex();
}
$params["act"] = "getResourceapiInstallInfo";
$params["package_srl"] = $package_srl;
$xmlDoc = XmlGenerater::getXmlDoc($params);
$oModel = &getModel('autoinstall');
$oModel = getModel('autoinstall');
$targetpackages = array();
if($xmlDoc)
{
$xmlPackage =& $xmlDoc->response->package;
$xmlPackage = & $xmlDoc->response->package;
$package = new stdClass();
$package->package_srl = $xmlPackage->package_srl->body;
$package->title = $xmlPackage->title->body;
@ -316,7 +371,11 @@ class autoinstallAdminView extends autoinstall
$package->path = $xmlPackage->path->body;
if($xmlPackage->depends)
{
if(!is_array($xmlPackage->depends->item)) $xmlPackage->depends->item = array($xmlPackage->depends->item);
if(!is_array($xmlPackage->depends->item))
{
$xmlPackage->depends->item = array($xmlPackage->depends->item);
}
$package->depends = array();
foreach($xmlPackage->depends->item as $item)
{
@ -328,23 +387,24 @@ class autoinstallAdminView extends autoinstall
$package->depends[] = $dep_item;
$targetpackages[$dep_item->package_srl] = 1;
}
$packages = $oModel->getInstalledPackages(array_keys($targetpackages));
$package->deplist = "";
foreach($package->depends as $key => $dep)
{
if(!$packages[$dep->package_srl])
{
$package->depends[$key]->installed = false;
$package->package_srl .= ",". $dep->package_srl;
$package->depends[$key]->installed = FALSE;
$package->package_srl .= "," . $dep->package_srl;
}
else
{
$package->depends[$key]->installed = true;
$package->depends[$key]->installed = TRUE;
$package->depends[$key]->cur_version = $packages[$dep->package_srl]->current_version;
if(version_compare($dep->version, $packages[$dep->package_srl]->current_version, ">"))
{
$package->depends[$key]->need_update = true;
$package->package_srl .= ",". $dep->package_srl;
$package->depends[$key]->need_update = TRUE;
$package->package_srl .= "," . $dep->package_srl;
if($dep->path === '.')
{
@ -353,15 +413,16 @@ class autoinstallAdminView extends autoinstall
}
else
{
$package->need_update = false;
$package->need_update = FALSE;
}
}
}
}
$installedPackage = $oModel->getInstalledPackage($package_srl);
if($installedPackage)
{
$package->installed = true;
$package->installed = TRUE;
$package->cur_version = $installedPackage->current_version;
$package->need_update = version_compare($package->version, $installedPackage->current_version, ">");
}
@ -372,14 +433,16 @@ class autoinstallAdminView extends autoinstall
Context::set('contain_core', TRUE);
}
}
if(!$_SESSION['ftp_password'])
{
Context::set('need_password', true);
Context::set('need_password', TRUE);
}
$this->setTemplateFile('install');
$security = new Security();
$security->encodeHTML('package.' , 'package.depends..');
$security->encodeHTML('package.', 'package.depends..');
}
/**
@ -389,10 +452,13 @@ class autoinstallAdminView extends autoinstall
*/
function dispAutoinstallAdminIndex()
{
$oModuleModel = &getModel('module');
$oModuleModel = getModel('module');
$config = $oModuleModel->getModuleConfig('autoinstall');
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_root_path) Context::set('show_ftp_note', true);
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_root_path)
{
Context::set('show_ftp_note', TRUE);
}
$this->setTemplateFile('index');
@ -404,45 +470,60 @@ class autoinstallAdminView extends autoinstall
$lUpdateDoc = $xml_lUpdate->parse($buff);
$updateDate = $lUpdateDoc->response->updatedate->body;
if (!$updateDate)
if(!$updateDate)
{
return $this->stop('msg_connection_fail');
}
$oModel = &getModel('autoinstall');
$oModel = getModel('autoinstall');
$item = $oModel->getLatestPackage();
if(!$item || $item->updatedate < $updateDate || count($this->categories) < 1)
{
$oController = &getAdminController('autoinstall');
$oController = getAdminController('autoinstall');
$oController->_updateinfo();
if (!$_SESSION['__XE_EASYINSTALL_REDIRECT__'])
if(!$_SESSION['__XE_EASYINSTALL_REDIRECT__'])
{
header('location: ' . getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminIndex'));
$_SESSION['__XE_EASYINSTALL_REDIRECT__'] = true;
$_SESSION['__XE_EASYINSTALL_REDIRECT__'] = TRUE;
return;
}
}
unset($_SESSION['__XE_EASYINSTALL_REDIRECT__']);
$page = Context::get('page');
if(!$page) $page = 1;
if(!$page)
{
$page = 1;
}
Context::set('page', $page);
$order_type = Context::get('order_type');
if(!in_array($order_type, array('asc', 'desc'))) $order_type = 'desc';
if(!in_array($order_type, array('asc', 'desc')))
{
$order_type = 'desc';
}
Context::set('order_type', $order_type);
$order_target = Context::get('order_target');
if(!in_array($order_target, array('newest', 'download', 'popular'))) $order_target = 'newest';
if(!in_array($order_target, array('newest', 'download', 'popular')))
{
$order_target = 'newest';
}
Context::set('order_target', $order_target);
$search_keyword = Context::get('search_keyword');
$childrenList = Context::get('childrenList');
$category_srl = Context::get('category_srl');
if($childrenList) $params["category_srl"] = $childrenList;
else if($category_srl) $params["category_srl"] = $category_srl;
if($childrenList)
{
$params["category_srl"] = $childrenList;
}
else if($category_srl)
{
$params["category_srl"] = $category_srl;
}
$params["act"] = "getResourceapiPackagelist";
$params["order_target"] = $order_target;
@ -464,7 +545,7 @@ class autoinstallAdminView extends autoinstall
}
$security = new Security();
$security->encodeHTML('package.' , 'package.depends..');
$security->encodeHTML('package.', 'package.depends..');
}
/**
@ -474,8 +555,8 @@ class autoinstallAdminView extends autoinstall
*/
function dispCategory()
{
$oModel = &getModel('autoinstall');
$this->categories = &$oModel->getCategoryList();
$oModel = getModel('autoinstall');
$this->categories = $oModel->getCategoryList();
Context::set('categories', $this->categories);
}
@ -487,21 +568,37 @@ class autoinstallAdminView extends autoinstall
function dispAutoinstallAdminUninstall()
{
$package_srl = Context::get('package_srl');
if(!$package_srl) return $this->dispAutoinstallAdminIndex();
$oModel =& getModel('autoinstall');
if(!$package_srl)
{
return $this->dispAutoinstallAdminIndex();
}
$oModel = getModel('autoinstall');
$installedPackage = $oModel->getInstalledPackage($package_srl);
if(!$installedPackage) return $this->dispAutoinstallAdminInstalledPackages();
if(!$installedPackage)
{
return $this->dispAutoinstallAdminInstalledPackages();
}
if(!$_SESSION['ftp_password'])
{
Context::set('need_password', true);
Context::set('need_password', TRUE);
}
$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");
}
$params["act"] = "getResourceapiPackages";
$params["package_srls"] = $package_srl;
@ -518,7 +615,7 @@ class autoinstallAdminView extends autoinstall
$installedPackage->deps = $item_list[$package_srl]->deps;
Context::set('package', $installedPackage);
$this->setTemplateFile('uninstall');
Context::addJsFilter($this->module_path.'tpl/filter', 'uninstall_package.xml');
Context::addJsFilter($this->module_path . 'tpl/filter', 'uninstall_package.xml');
$security = new Security();
$security->encodeHTML('package.');
@ -530,6 +627,7 @@ class autoinstallAdminView extends autoinstall
return $this->stop('msg_connection_fail');
}
}
}
/* End of file autoinstall.admin.view.php */
/* Location: ./modules/autoinstall/autoinstall.admin.view.php */

View file

@ -1,10 +1,12 @@
<?php
/**
* XML Generater
* @author NHN (developers@xpressengine.com)
*/
class XmlGenerater
{
/**
* Generate XML using given data
*
@ -14,7 +16,11 @@ class XmlGenerater
function generate(&$params)
{
$xmlDoc = '<?xml version="1.0" encoding="utf-8" ?><methodCall><params>';
if(!is_array($params)) return null;
if(!is_array($params))
{
return NULL;
}
$params["module"] = "resourceapi";
foreach($params as $key => $val)
{
@ -34,11 +40,16 @@ class XmlGenerater
{
$body = XmlGenerater::generate($params);
$buff = FileHandler::getRemoteResource(_XE_DOWNLOAD_SERVER_, $body, 3, "POST", "application/xml");
if(!$buff) return;
if(!$buff)
{
return;
}
$xml = new XmlParser();
$xmlDoc = $xml->parse($buff);
return $xmlDoc;
}
}
/**
@ -47,6 +58,7 @@ class XmlGenerater
*/
class autoinstall extends ModuleObject
{
/**
* Temporary directory path
*/
@ -59,9 +71,9 @@ class autoinstall extends ModuleObject
*/
function autoinstall()
{
$oModuleModel = &getModel('module');
$oModuleModel = getModel('module');
$config = $oModuleModel->getModuleConfig('autoinstall');
if ($config->downloadServer != _XE_DOWNLOAD_SERVER_)
if($config->downloadServer != _XE_DOWNLOAD_SERVER_)
{
$this->stop('msg_not_match_server');
}
@ -74,7 +86,7 @@ class autoinstall extends ModuleObject
*/
function moduleInstall()
{
$oModuleController = &getController('module');
$oModuleController = getController('module');
$config->downloadServer = _XE_DOWNLOAD_SERVER_;
$oModuleController->insertModuleConfig('autoinstall', $config);
@ -87,26 +99,32 @@ class autoinstall extends ModuleObject
*/
function checkUpdate()
{
$oDB =& DB::getInstance();
$oModuleModel = &getModel('module');
$oDB = DB::getInstance();
$oModuleModel = getModel('module');
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_installed_packages.xml"))
&& $oDB->isTableExists("autoinstall_installed_packages"))
{
return true;
return TRUE;
}
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_remote_categories.xml"))
&& $oDB->isTableExists("autoinstall_remote_categories"))
{
return true;
return TRUE;
}
// 2011.08.08 add column 'list_order' in ai_remote_categories
if(!$oDB->isColumnExists('ai_remote_categories', 'list_order')) return true;
if(!$oDB->isColumnExists('ai_remote_categories', 'list_order'))
{
return TRUE;
}
// 2011.08.08 set _XE_DOWNLOAD_SERVER_ at module config
$config = $oModuleModel->getModuleConfig('autoinstall');
if(!isset($config->downloadServer)) return true;
if(!isset($config->downloadServer))
{
return TRUE;
}
// 2012.11.12 add column 'have_instance' in autoinstall_packages
if(!$oDB->isColumnExists('autoinstall_packages', 'have_instance'))
@ -114,7 +132,7 @@ class autoinstall extends ModuleObject
return TRUE;
}
return false;
return FALSE;
}
/**
@ -124,9 +142,9 @@ class autoinstall extends ModuleObject
*/
function moduleUpdate()
{
$oDB =& DB::getInstance();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
$oDB = DB::getInstance();
$oModuleModel = getModel('module');
$oModuleController = getController('module');
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_installed_packages.xml"))
&& $oDB->isTableExists("autoinstall_installed_packages"))
@ -142,7 +160,7 @@ class autoinstall extends ModuleObject
// 2011.08.08 add column 'list_order' in 'ai_remote_categories
if(!$oDB->isColumnExists('ai_remote_categories', 'list_order'))
{
$oDB->addColumn('ai_remote_categories', 'list_order', 'number', 11, null, true);
$oDB->addColumn('ai_remote_categories', 'list_order', 'number', 11, NULL, TRUE);
$oDB->addIndex('ai_remote_categories', 'idx_list_order', array('list_order'));
}
@ -169,7 +187,9 @@ class autoinstall extends ModuleObject
*/
function recompileCache()
{
}
}
/* End of file autoinstall.class.php */
/* Location: ./modules/autoinstall/autoinstall.class.php */

View file

@ -1,16 +1,19 @@
<?php
require_once(_XE_PATH_.'libs/ftp.class.php');
require_once(_XE_PATH_ . 'libs/ftp.class.php');
/**
* Module installer
* @author NHN (developers@xpressengine.com)
*/
class ModuleInstaller
{
/**
* Package information
* @var object
*/
var $package = null;
var $package = NULL;
/**
* Server's base url
@ -72,16 +75,22 @@ class ModuleInstaller
*/
function uninstall()
{
$oModel =& getModel('autoinstall');
$oModel = getModel('autoinstall');
$type = $oModel->getTypeFromPath($this->package->path);
if($type == "module")
{
$output = $this->uninstallModule();
if(!$output->toBool()) return $output;
if(!$output->toBool())
{
return $output;
}
}
$output = $this->_connect();
if(!$output->toBool()) return $output;
if(!$output->toBool())
{
return $output;
}
$output = $this->_removeDir($this->package->path);
$this->_close();
@ -108,17 +117,17 @@ class ModuleInstaller
{
if($this->package->path == ".")
{
$this->download_file = $this->temp_dir."xe.tar";
$this->download_file = $this->temp_dir . "xe.tar";
$this->target_path = "";
$this->download_path = $this->temp_dir;
}
else
{
$subpath = substr($this->package->path,2);
$this->download_file = $this->temp_dir.$subpath.".tar";
$subpath = substr($this->package->path, 2);
$this->download_file = $this->temp_dir . $subpath . ".tar";
$subpatharr = explode("/", $subpath);
array_pop($subpatharr);
$this->download_path = $this->temp_dir.implode("/", $subpatharr);
$this->download_path = $this->temp_dir . implode("/", $subpatharr);
$this->target_path = implode("/", $subpatharr);
}
@ -126,7 +135,7 @@ class ModuleInstaller
$postdata["path"] = $this->package->path;
$postdata["module"] = "resourceapi";
$postdata["act"] = "procResourceapiDownload";
$buff = FileHandler::getRemoteResource($this->base_url, null, 3, "POST", "application/x-www-form-urlencoded", array(), array(), $postdata);
$buff = FileHandler::getRemoteResource($this->base_url, NULL, 3, "POST", "application/x-www-form-urlencoded", array(), array(), $postdata);
FileHandler::writeFile($this->download_file, $buff);
}
@ -141,16 +150,25 @@ class ModuleInstaller
{
$path_array = explode("/", $this->package->path);
$target_name = array_pop($path_array);
$oModule =& getModule($target_name, "class");
if(!$oModule) return new Object(-1, 'msg_invalid_request');
if(!method_exists($oModule, "moduleUninstall")) return new Object(-1, 'msg_invalid_request');
$oModule = getModule($target_name, "class");
if(!$oModule)
{
return new Object(-1, 'msg_invalid_request');
}
if(!method_exists($oModule, "moduleUninstall"))
{
return new Object(-1, 'msg_invalid_request');
}
$output = $oModule->moduleUninstall();
if(is_subclass_of($output, 'Object') && !$output->toBool()) return $output;
if(is_subclass_of($output, 'Object') && !$output->toBool())
{
return $output;
}
$schema_dir = sprintf('%s/schemas/', $this->package->path);
$schema_files = FileHandler::readDir($schema_dir);
$oDB =& DB::getInstance();
$oDB = DB::getInstance();
if(is_array($schema_files))
{
foreach($schema_files as $file)
@ -182,8 +200,8 @@ class ModuleInstaller
if($type == "module")
{
$oModuleModel = &getModel('module');
$oInstallController = &getController('install');
$oModuleModel = getModel('module');
$oInstallController = getController('install');
$module_path = ModuleHandler::getModulePath($target_name);
if($oModuleModel->checkNeedInstall($target_name))
{
@ -191,7 +209,7 @@ class ModuleInstaller
}
if($oModuleModel->checkNeedUpdate($target_name))
{
$oModule = &getModule($target_name, 'class');
$oModule = getModule($target_name, 'class');
if(method_exists($oModule, 'moduleUpdate'))
{
$oModule->moduleUpdate();
@ -230,7 +248,7 @@ class ModuleInstaller
*/
function _unPack()
{
require_once(_XE_PATH_.'libs/tar.class.php');
require_once(_XE_PATH_ . 'libs/tar.class.php');
$oTar = new tar();
$oTar->openTAR($this->download_file);
@ -241,7 +259,7 @@ class ModuleInstaller
{
foreach($_files as $key => $info)
{
FileHandler::writeFile($this->download_path."/".$info['name'], $info['file']);
FileHandler::writeFile($this->download_path . "/" . $info['name'], $info['file']);
$file_list[] = $info['name'];
}
}
@ -261,27 +279,37 @@ class ModuleInstaller
$files = array();
while($file = $oDir->read())
{
if($file == "." || $file == "..") continue;
if($file == "." || $file == "..")
{
continue;
}
$files[] = $file;
}
foreach($files as $file)
{
$file_path = $path."/".$file;
$file_path = $path . "/" . $file;
if(is_dir(FileHandler::getRealPath($file_path)))
{
$output = $this->_removeDir($file_path);
if(!$output->toBool()) return $output;
if(!$output->toBool())
{
return $output;
}
}
else
{
$output = $this->_removeFile($file_path);
if(!$output->toBool()) return $output;
if(!$output->toBool())
{
return $output;
}
}
}
$output = $this->_removeDir_real($path);
return $output;
}
}
/**
@ -290,23 +318,24 @@ class ModuleInstaller
*/
class SFTPModuleInstaller extends ModuleInstaller
{
/**
* FTP information
* @var object
*/
var $ftp_info = null;
var $ftp_info = NULL;
/**
* SFTP connection
* @var resource
*/
var $connection = null;
var $connection = NULL;
/**
* SFTP resource
* @var resource
*/
var $sftp = null;
var $sftp = NULL;
/**
* Constructor
@ -316,7 +345,7 @@ class SFTPModuleInstaller extends ModuleInstaller
*/
function SFTPModuleInstaller(&$package)
{
$this->package =& $package;
$this->package = &$package;
$this->ftp_info = Context::getFTPInfo();
}
@ -332,7 +361,10 @@ class SFTPModuleInstaller extends ModuleInstaller
return new Object(-1, 'msg_sftp_not_supported');
}
if(!$this->ftp_info->ftp_user || !$this->ftp_info->sftp || $this->ftp_info->sftp != 'Y') return new Object(-1,'msg_ftp_invalid_auth_info');
if(!$this->ftp_info->ftp_user || !$this->ftp_info->sftp || $this->ftp_info->sftp != 'Y')
{
return new Object(-1, 'msg_ftp_invalid_auth_info');
}
if($this->ftp_info->ftp_host)
{
@ -345,7 +377,7 @@ class SFTPModuleInstaller extends ModuleInstaller
$this->connection = ssh2_connect($ftp_host, $this->ftp_info->ftp_port);
if(!ssh2_auth_password($this->connection, $this->ftp_info->ftp_user, $this->ftp_password))
{
return new Object(-1,'msg_ftp_invalid_auth_info');
return new Object(-1, 'msg_ftp_invalid_auth_info');
}
$_SESSION['ftp_password'] = $this->ftp_password;
$this->sftp = ssh2_sftp($this->connection);
@ -359,6 +391,7 @@ class SFTPModuleInstaller extends ModuleInstaller
*/
function _close()
{
}
/**
@ -369,8 +402,11 @@ class SFTPModuleInstaller extends ModuleInstaller
*/
function _removeFile($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
$target_path = $this->ftp_info->ftp_root_path.$path;
if(substr($path, 0, 2) == "./")
{
$path = substr($path, 2);
}
$target_path = $this->ftp_info->ftp_root_path . $path;
if(!@ssh2_sftp_unlink($this->sftp, $target_path))
{
@ -387,8 +423,11 @@ class SFTPModuleInstaller extends ModuleInstaller
*/
function _removeDir_real($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
$target_path = $this->ftp_info->ftp_root_path.$path;
if(substr($path, 0, 2) == "./")
{
$path = substr($path, 2);
}
$target_path = $this->ftp_info->ftp_root_path . $path;
if(!@ssh2_sftp_rmdir($this->sftp, $target_path))
{
@ -403,12 +442,19 @@ class SFTPModuleInstaller extends ModuleInstaller
* @param array $file_list File list to copy
* @return Object
*/
function _copyDir(&$file_list){
if(!$this->ftp_password) return new Object(-1,'msg_ftp_password_input');
function _copyDir(&$file_list)
{
if(!$this->ftp_password)
{
return new Object(-1, 'msg_ftp_password_input');
}
$output = $this->_connect();
if(!$output->toBool()) return $output;
$target_dir = $this->ftp_info->ftp_root_path.$this->target_path;
if(!$output->toBool())
{
return $output;
}
$target_dir = $this->ftp_info->ftp_root_path . $this->target_path;
if(is_array($file_list))
{
@ -417,21 +463,22 @@ class SFTPModuleInstaller extends ModuleInstaller
$org_file = $file;
if($this->package->path == ".")
{
$file = substr($file,3);
$file = substr($file, 3);
}
$path = FileHandler::getRealPath("./".$this->target_path."/".$file);
$pathname = dirname($target_dir."/".$file);
$path = FileHandler::getRealPath("./" . $this->target_path . "/" . $file);
$pathname = dirname($target_dir . "/" . $file);
if(!file_exists(FileHandler::getRealPath($real_path)))
{
ssh2_sftp_mkdir($this->sftp, $pathname, 0755, true);
ssh2_sftp_mkdir($this->sftp, $pathname, 0755, TRUE);
}
ssh2_scp_send($this->connection, FileHandler::getRealPath($this->download_path."/".$org_file), $target_dir."/".$file);
ssh2_scp_send($this->connection, FileHandler::getRealPath($this->download_path . "/" . $org_file), $target_dir . "/" . $file);
}
}
return new Object();
}
}
/**
@ -440,17 +487,18 @@ class SFTPModuleInstaller extends ModuleInstaller
*/
class PHPFTPModuleInstaller extends ModuleInstaller
{
/**
* FTP information
* @var object
*/
var $ftp_info = null;
var $ftp_info = NULL;
/**
* FTP connection
* @var resource
*/
var $connection = null;
var $connection = NULL;
/**
* Constructor
@ -460,7 +508,7 @@ class PHPFTPModuleInstaller extends ModuleInstaller
*/
function PHPFTPModuleInstaller(&$package)
{
$this->package =& $package;
$this->package = &$package;
$this->ftp_info = Context::getFTPInfo();
}
@ -490,13 +538,13 @@ class PHPFTPModuleInstaller extends ModuleInstaller
if(!$login_result)
{
$this->_close();
return new Object(-1,'msg_ftp_invalid_auth_info');
return new Object(-1, 'msg_ftp_invalid_auth_info');
}
$_SESSION['ftp_password'] = $this->ftp_password;
if($this->ftp_info->ftp_pasv != "N")
{
ftp_pasv($this->connection, true);
ftp_pasv($this->connection, TRUE);
}
return new Object();
}
@ -509,12 +557,15 @@ class PHPFTPModuleInstaller extends ModuleInstaller
*/
function _removeFile($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
$target_path = $this->ftp_info->ftp_root_path.$path;
if(substr($path, 0, 2) == "./")
{
$path = substr($path, 2);
}
$target_path = $this->ftp_info->ftp_root_path . $path;
if(!@ftp_delete($this->connection, $target_path))
{
return new Object(-1, "failed to delete file ".$path);
return new Object(-1, "failed to delete file " . $path);
}
return new Object();
}
@ -527,12 +578,15 @@ class PHPFTPModuleInstaller extends ModuleInstaller
*/
function _removeDir_real($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
$target_path = $this->ftp_info->ftp_root_path.$path;
if(substr($path, 0, 2) == "./")
{
$path = substr($path, 2);
}
$target_path = $this->ftp_info->ftp_root_path . $path;
if(!@ftp_rmdir($this->connection, $target_path))
{
return new Object(-1, "failed to delete directory ".$path);
return new Object(-1, "failed to delete directory " . $path);
}
return new Object();
}
@ -555,39 +609,54 @@ class PHPFTPModuleInstaller extends ModuleInstaller
*/
function _copyDir(&$file_list)
{
if(!$this->ftp_password) return new Object(-1,'msg_ftp_password_input');
if(!$this->ftp_password)
{
return new Object(-1, 'msg_ftp_password_input');
}
$output = $this->_connect();
if(!$output->toBool()) return $output;
if(!$output->toBool())
{
return $output;
}
if(!$this->target_path) $this->target_path = '.';
if(!$this->target_path)
{
$this->target_path = '.';
}
if(substr($this->download_path, -1) == '/')
{
$this->download_path = substr($this->download_path, 0, -1);
}
$target_dir = $this->ftp_info->ftp_root_path.$this->target_path;
$target_dir = $this->ftp_info->ftp_root_path . $this->target_path;
if(is_array($file_list))
{
foreach($file_list as $k => $file)
{
if(!$file) continue;
if(!$file)
{
continue;
}
$org_file = $file;
if($this->package->path == ".")
{
$file = substr($file,3);
$file = substr($file, 3);
}
$path = FileHandler::getRealPath("./".$this->target_path."/".$file);
$path_list = explode('/', dirname($this->target_path."/".$file));
$path = FileHandler::getRealPath("./" . $this->target_path . "/" . $file);
$path_list = explode('/', dirname($this->target_path . "/" . $file));
$real_path = "./";
$ftp_path = $this->ftp_info->ftp_root_path;
for($i=0;$i<count($path_list);$i++)
for($i = 0; $i < count($path_list); $i++)
{
if($path_list=="") continue;
$real_path .= $path_list[$i]."/";
$ftp_path .= $path_list[$i]."/";
if($path_list == "")
{
continue;
}
$real_path .= $path_list[$i] . "/";
$ftp_path .= $path_list[$i] . "/";
if(!file_exists(FileHandler::getRealPath($real_path)))
{
if(!@ftp_mkdir($this->connection, $ftp_path))
@ -606,7 +675,7 @@ class PHPFTPModuleInstaller extends ModuleInstaller
}
else
{
if(!ftp_site($this->connection, "CHMOD 755 ".$ftp_path))
if(!ftp_site($this->connection, "CHMOD 755 " . $ftp_path))
{
return new Object(-1, "msg_permission_adjust_failed");
}
@ -614,7 +683,7 @@ class PHPFTPModuleInstaller extends ModuleInstaller
}
}
}
if(!ftp_put($this->connection, $target_dir .'/'. $file, FileHandler::getRealPath($this->download_path."/".$org_file), FTP_BINARY))
if(!ftp_put($this->connection, $target_dir . '/' . $file, FileHandler::getRealPath($this->download_path . "/" . $org_file), FTP_BINARY))
{
return new Object(-1, "msg_ftp_upload_failed");
}
@ -623,6 +692,7 @@ class PHPFTPModuleInstaller extends ModuleInstaller
$this->_close();
return new Object();
}
}
/**
@ -631,17 +701,18 @@ class PHPFTPModuleInstaller extends ModuleInstaller
*/
class FTPModuleInstaller extends ModuleInstaller
{
/**
* FTP instance
* @var FTP
*/
var $oFtp = null;
var $oFtp = NULL;
/**
* FTP information
* @var object
*/
var $ftp_info = null;
var $ftp_info = NULL;
/**
* Constructor
@ -650,8 +721,8 @@ class FTPModuleInstaller extends ModuleInstaller
*/
function FTPModuleInstaller(&$package)
{
$this->package =& $package;
$this->ftp_info = Context::getFTPInfo();
$this->package = &$package;
$this->ftp_info = Context::getFTPInfo();
}
/**
@ -675,9 +746,10 @@ class FTPModuleInstaller extends ModuleInstaller
{
return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_host));
}
if(!$this->oFtp->ftp_login($this->ftp_info->ftp_user, $this->ftp_password)) {
if(!$this->oFtp->ftp_login($this->ftp_info->ftp_user, $this->ftp_password))
{
$this->_close();
return new Object(-1,'msg_ftp_invalid_auth_info');
return new Object(-1, 'msg_ftp_invalid_auth_info');
}
$_SESSION['ftp_password'] = $this->ftp_password;
return new Object();
@ -691,8 +763,11 @@ class FTPModuleInstaller extends ModuleInstaller
*/
function _removeFile($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
$target_path = $this->ftp_info->ftp_root_path.$path;
if(substr($path, 0, 2) == "./")
{
$path = substr($path, 2);
}
$target_path = $this->ftp_info->ftp_root_path . $path;
if(!$this->oFtp->ftp_delete($target_path))
{
@ -708,8 +783,11 @@ class FTPModuleInstaller extends ModuleInstaller
*/
function _removeDir_real($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
$target_path = $this->ftp_info->ftp_root_path.$path;
if(substr($path, 0, 2) == "./")
{
$path = substr($path, 2);
}
$target_path = $this->ftp_info->ftp_root_path . $path;
if(!$this->oFtp->ftp_rmdir($target_path))
{
@ -736,13 +814,19 @@ class FTPModuleInstaller extends ModuleInstaller
*/
function _copyDir(&$file_list)
{
if(!$this->ftp_password) return new Object(-1,'msg_ftp_password_input');
if(!$this->ftp_password)
{
return new Object(-1, 'msg_ftp_password_input');
}
$output = $this->_connect();
if(!$output->toBool()) return $output;
if(!$output->toBool())
{
return $output;
}
$oFtp =& $this->oFtp;
$target_dir = $this->ftp_info->ftp_root_path.$this->target_path;
$oFtp = &$this->oFtp;
$target_dir = $this->ftp_info->ftp_root_path . $this->target_path;
if(is_array($file_list))
{
@ -751,26 +835,29 @@ class FTPModuleInstaller extends ModuleInstaller
$org_file = $file;
if($this->package->path == ".")
{
$file = substr($file,3);
$file = substr($file, 3);
}
$path = FileHandler::getRealPath("./".$this->target_path."/".$file);
$path_list = explode('/', dirname($this->target_path."/".$file));
$path = FileHandler::getRealPath("./" . $this->target_path . "/" . $file);
$path_list = explode('/', dirname($this->target_path . "/" . $file));
$real_path = "./";
$ftp_path = $this->ftp_info->ftp_root_path;
for($i=0;$i<count($path_list);$i++)
for($i = 0; $i < count($path_list); $i++)
{
if($path_list=="") continue;
$real_path .= $path_list[$i]."/";
$ftp_path .= $path_list[$i]."/";
if($path_list == "")
{
continue;
}
$real_path .= $path_list[$i] . "/";
$ftp_path .= $path_list[$i] . "/";
if(!file_exists(FileHandler::getRealPath($real_path)))
{
$oFtp->ftp_mkdir($ftp_path);
$oFtp->ftp_site("CHMOD 755 ".$ftp_path);
$oFtp->ftp_site("CHMOD 755 " . $ftp_path);
}
}
$oFtp->ftp_put($target_dir .'/'. $file, FileHandler::getRealPath($this->download_path."/".$org_file));
$oFtp->ftp_put($target_dir . '/' . $file, FileHandler::getRealPath($this->download_path . "/" . $org_file));
}
}
@ -778,7 +865,7 @@ class FTPModuleInstaller extends ModuleInstaller
return new Object();
}
}
}
/* End of file autoinstall.lib.php */
/* Location: ./modules/autoinstall/autoinstall.lib.php */

View file

@ -1,10 +1,12 @@
<?php
/**
* Model class of the autoinstall module
* @author NHN (developers@xpressengine.com)
*/
class autoinstallModel extends autoinstall
{
/**
* Get category information
*
@ -13,9 +15,13 @@ class autoinstallModel extends autoinstall
*/
function getCategory($category_srl)
{
$args = new stdClass();
$args->category_srl = $category_srl;
$output = executeQueryArray("autoinstall.getCategory", $args);
if(!$output->data) return null;
if(!$output->data)
{
return null;
}
return array_shift($output->data);
}
@ -27,7 +33,10 @@ class autoinstallModel extends autoinstall
function getPackages()
{
$output = executeQueryArray("autoinstall.getPackages");
if(!$output->data) return array();
if(!$output->data)
{
return array();
}
return $output->data;
}
@ -42,7 +51,10 @@ class autoinstallModel extends autoinstall
$args = new stdClass();
$args->package_srl = $package_srl;
$output = executeQueryArray("autoinstall.getInstalledPackage", $args);
if(!$output->data) return null;
if(!$output->data)
{
return null;
}
return array_shift($output->data);
}
@ -57,7 +69,10 @@ class autoinstallModel extends autoinstall
$args = new stdClass();
$args->package_srl = $package_srl;
$output = executeQueryArray("autoinstall.getPackage", $args);
if(!$output->data) return null;
if(!$output->data)
{
return null;
}
return array_shift($output->data);
}
@ -69,7 +84,10 @@ class autoinstallModel extends autoinstall
function getCategoryList()
{
$output = executeQueryArray("autoinstall.getCategories");
if(!$output->toBool() || !$output->data) return array();
if(!$output->toBool() || !$output->data)
{
return array();
}
$categoryList = array();
foreach($output->data as $category)
@ -83,7 +101,7 @@ class autoinstallModel extends autoinstall
{
if($category->parent_srl)
{
$categoryList[$category->parent_srl]->children[] =& $categoryList[$key];
$categoryList[$category->parent_srl]->children[] = & $categoryList[$key];
}
else
{
@ -109,7 +127,10 @@ class autoinstallModel extends autoinstall
$args = new stdClass();
$args->category_srl = $category_srl;
$output = executeQuery("autoinstall.getPackageCount", $args);
if(!$output->data) return 0;
if(!$output->data)
{
return 0;
}
return $output->data->count;
}
@ -120,8 +141,11 @@ class autoinstallModel extends autoinstall
*/
function getInstalledPackageCount()
{
$output = executeQuery("autoinstall.getInstalledPackageCount", $args);
if(!$output->data) return 0;
$output = executeQuery("autoinstall.getInstalledPackageCount");
if(!$output->data)
{
return 0;
}
return $output->data->count;
}
@ -136,12 +160,12 @@ class autoinstallModel extends autoinstall
*/
function setDepth(&$item, $depth, &$list, &$resultList)
{
$resultList[$item->category_srl] =& $item;
$resultList[$item->category_srl] = &$item;
$item->depth = $depth;
$siblingList = $item->category_srl;
foreach($item->children as $child)
{
$siblingList .= ",".$this->setDepth($list[$child->category_srl], $depth+1, $list, $resultList);
$siblingList .= "," . $this->setDepth($list[$child->category_srl], $depth + 1, $list, $resultList);
}
if(count($item->children) < 1)
{
@ -159,7 +183,10 @@ class autoinstallModel extends autoinstall
function getLatestPackage()
{
$output = executeQueryArray("autoinstall.getLatestPackage");
if(!$output->data) return null;
if(!$output->data)
{
return null;
}
return array_shift($output->data);
}
@ -175,7 +202,10 @@ class autoinstallModel extends autoinstall
$args->package_list = $package_list;
$output = executeQueryArray("autoinstall.getInstalledPackages", $args);
$result = array();
if(!$output->data) return $result;
if(!$output->data)
{
return $result;
}
foreach($output->data as $value)
{
$result[$value->package_srl] = $value;
@ -216,8 +246,16 @@ class autoinstallModel extends autoinstall
*/
function getTypeFromPath($path)
{
if(!$path) return null;
if($path == ".") return "core";
if(!$path)
{
return NULL;
}
if($path == ".")
{
return "core";
}
$path_array = explode("/", $path);
$target_name = array_pop($path_array);
if(!$target_name)
@ -236,7 +274,7 @@ class autoinstallModel extends autoinstall
*/
function getConfigFilePath($type)
{
$config_file = null;
$config_file = NULL;
switch($type)
{
case "m.layout":
@ -272,10 +310,19 @@ class autoinstallModel extends autoinstall
{
$path_array = explode("/", $path);
$target_name = array_pop($path_array);
$oModule =& getModule($target_name, "class");
if(!$oModule) return false;
if(method_exists($oModule, "moduleUninstall")) return true;
else return false;
$oModule = getModule($target_name, "class");
if(!$oModule)
{
return FALSE;
}
if(method_exists($oModule, "moduleUninstall"))
{
return TRUE;
}
else
{
return FALSE;
}
}
/**
@ -286,9 +333,15 @@ class autoinstallModel extends autoinstall
*/
function getPackageSrlByPath($path)
{
if(!$path) return;
if(!$path)
{
return;
}
if(substr($path,-1) == '/') $path = substr($path, 0, strlen($path)-1);
if(substr($path, -1) == '/')
{
$path = substr($path, 0, strlen($path) - 1);
}
if(!$GLOBLAS['XE_AUTOINSTALL_PACKAGE_SRL_BY_PATH'][$path])
{
@ -310,10 +363,16 @@ class autoinstallModel extends autoinstall
*/
function getRemoveUrlByPackageSrl($packageSrl)
{
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_root_path) return;
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_root_path)
{
return;
}
if(!$packageSrl) return;
if(!$packageSrl)
{
return;
}
return getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminUninstall', 'package_srl', $packageSrl);
}
@ -326,13 +385,22 @@ class autoinstallModel extends autoinstall
*/
function getRemoveUrlByPath($path)
{
if(!$path) return;
if(!$path)
{
return;
}
$ftp_info = Context::getFTPInfo();
if (!$ftp_info->ftp_root_path) return;
$ftp_info = Context::getFTPInfo();
if(!$ftp_info->ftp_root_path)
{
return;
}
$packageSrl = $this->getPackageSrlByPath($path);
if(!$packageSrl) return;
if(!$packageSrl)
{
return;
}
return getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminUninstall', 'package_srl', $packageSrl);
}
@ -345,7 +413,10 @@ class autoinstallModel extends autoinstall
*/
function getUpdateUrlByPackageSrl($packageSrl)
{
if(!$packageSrl) return;
if(!$packageSrl)
{
return;
}
return getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminInstall', 'package_srl', $packageSrl);
}
@ -358,15 +429,20 @@ class autoinstallModel extends autoinstall
*/
function getUpdateUrlByPath($path)
{
if(!$path) return;
if(!$path)
{
return;
}
$packageSrl = $this->getPackageSrlByPath($path);
if (!$packageSrl) return;
if(!$packageSrl)
{
return;
}
return getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminInstall', 'package_srl', $packageSrl);
}
function getHaveInstance($columnList = array())
{
$output = executeQueryArray('autoinstall.getHaveInstance', NULL, $columnList);
@ -377,6 +453,7 @@ class autoinstallModel extends autoinstall
return $output->data;
}
}
/* End of file autoinstall.model.php */
/* Location: ./modules/autoinstall/autoinstall.model.php */

View file

@ -1,33 +0,0 @@
<?php
/**
* View class of the autoinstall module
* @author NHN (developers@xpressengine.com)
*/
class autoinstallView extends autoinstall
{
/**
* Initialization
*
* @return void
*/
function init()
{
}
/**
* Test
*
* @return Object
*/
function dispAutoinstallTest()
{
$file = "modules.test.tar";
$checksum = '549989037bd8401d39b83ca2393d8131';
$file = "modules.test.skins.test.tar";
$oAutoinstallAdminController = &getAdminController('autoinstall');
$output = $oAutoinstallAdminController->install($file, $checksum);
return $output;
}
}
/* End of file autoinstall.view.php */
/* Location: ./modules/autoinstall/autoinstall.view.php */