Adds comments for phpDoc

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10753 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2012-05-30 07:34:19 +00:00
parent 86296c899e
commit 455091f7e8
6 changed files with 609 additions and 29 deletions

View file

@ -1,29 +1,47 @@
<?php
/**
* @class autoinstallAdminController
* @author NHN (developers@xpressengine.com)
* @brief autoinstall module admin controller class
**/
require_once(_XE_PATH_.'modules/autoinstall/autoinstall.lib.php');
/**
* autoinstall module admin controller class
*
* @author NHN (developers@xpressengine.com)
**/
class autoinstallAdminController extends autoinstall {
/**
* @brief Initialization
* Initialization
**/
function init() {
}
/**
* Check file checksum is equal
*
* @param string $file local file path
* @param string $checksum Recieved checksum from server
* @return bool Returns true on equal local checksum and recieved checksum, otherwise false.
*/
function checkFileCheckSum($file, $checksum){
$local_checksum = md5_file(FileHandler::getRealPath($file));
return ($local_checksum === $checksum);
}
/**
* Clean download file
*
* @param object $obj
* @return void
*/
function _cleanDownloaded($obj){
FileHandler::removeDir($obj->download_path);
}
/**
* Update easy install information
*
* @return Object
*/
function procAutoinstallAdminUpdateinfo()
{
$this->_updateinfo();
@ -31,6 +49,11 @@
$this->setRedirectUrl(Context::get('error_return_url'));
}
/**
* Update easy install information
*
* @return void
*/
function _updateinfo(){
$oModel = &getModel('autoinstall');
$item = $oModel->getLatestPackage();
@ -49,6 +72,11 @@
$this->checkInstalled();
}
/**
* Update installed package information
*
* @return void
*/
function checkInstalled()
{
executeQuery("autoinstall.deleteInstalledPackage");
@ -122,6 +150,11 @@
}
}
/**
* Install package
*
* @return Object
*/
function procAutoinstallAdminPackageinstall()
{
@set_time_limit(0);
@ -175,6 +208,12 @@
}
}
/**
* Update package informations using recieved data from server
*
* @param object $xmlDoc Recieved data
* @return void
*/
function updatePackages(&$xmlDoc)
{
$oModel =& getModel('autoinstall');
@ -207,6 +246,12 @@
}
}
/**
* Update category using recived data from server.
*
* @param object $xmlDoc Recived data
* @return void
*/
function updateCategory(&$xmlDoc)
{
executeQuery("autoinstall.deleteCategory");
@ -227,6 +272,11 @@
}
}
/**
* Uninstall package
*
* @return Object
*/
function procAutoinstallAdminUninstallPackage()
{
$package_srl = Context::get('package_srl');

View file

@ -1,16 +1,27 @@
<?php
/**
* @class autoinstallAdminView
* Admin view class in the autoinstall module
* @author NHN (developers@xpressengine.com)
* @brief admin view class in the autoinstall module
**/
class autoinstallAdminView extends autoinstall {
/**
* Category list
* @var array
*/
var $categories;
/**
* Is set a ftp information
* @var bool
*/
var $ftp_set = false;
/**
* initialize
*
* @return void
*/
function init() {
$template_path = sprintf("%stpl/",$this->module_path);
Context::set('original_site', _XE_LOCATION_SITE_);
@ -28,6 +39,45 @@
Context::set('iCount', $oModel->getInstalledPackageCount());
}
/**
* Rearrange one item
*
* <pre>
* $item:
* stdClass Object
* (
* [category_srl] => stdClass Object
* (
* [body] => xxx
* )
* [package_srl] => stdClass Object
* (
* [body] => xxx
* )
* ...
* [depfrom] => stdClass Object
* (
* [body] => xxx
* )
* )
*
* $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');
*
* returns:
* stdClass Object
* (
* [category_srl] => xxx
* [package_srl] => xxx
* ...
* [depfrom] => xxx
* )
* </pre>
*
* @param object $item
* @param object $targets
* @return object
*/
function rearrange(&$item, &$targets)
{
$ret = null;
@ -38,6 +88,76 @@
return $ret;
}
/**
* Rearrage all item
*
* <pre>
* $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
* (
* ...
* )
* ...
* )
*
* $packages:
* Array
* (
* [<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
* ...
* )
* )
* ...
* )
* </pre>
*
* @param object $items Recived data from server
* @param object $packages Local data
* @return object
*/
function rearranges($items, $packages = null)
{
if(!is_array($items)) $items = array($items);
@ -113,6 +233,11 @@
return $item_list;
}
/**
* Display installed packages
*
* @return Object
*/
function dispAutoinstallAdminInstalledPackages()
{
$page = Context::get('page');
@ -146,6 +271,11 @@
$security->encodeHTML('item_list..');
}
/**
* Display install package
*
* @return Object
*/
function dispAutoinstallAdminInstall() {
$package_srl = Context::get('package_srl');
if(!$package_srl) return $this->dispAutoinstallAdminIndex();
@ -219,6 +349,11 @@
$security->encodeHTML('package.' , 'package.depends..');
}
/**
* Display package list
*
* @return Object
*/
function dispAutoinstallAdminIndex() {
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('autoinstall');
@ -254,7 +389,7 @@
return;
}
}
unset($_SESSION['__XE_EASYiNSTALL_REDIRECT__']);
unset($_SESSION['__XE_EASYINSTALL_REDIRECT__']);
$page = Context::get('page');
if(!$page) $page = 1;
@ -299,6 +434,11 @@
}
/**
* Display category
*
* @return void
*/
function dispCategory()
{
$oModel = &getModel('autoinstall');
@ -306,6 +446,11 @@
Context::set('categories', $this->categories);
}
/**
* Display uninstall package
*
* @return Object
*/
function dispAutoinstallAdminUninstall()
{
$package_srl = Context::get('package_srl');

View file

@ -1,11 +1,15 @@
<?php
/**
* @class autoinstall
* @author NHN (developers@xpressengine.com)
* @brief high class of the autoinstall module
**/
/**
* XML Generater
* @author NHN (developers@xpressengine.com)
*/
class XmlGenerater {
/**
* Generate XML using given data
*
* @param array $params The data
* @return string Returns xml string
*/
function generate(&$params)
{
$xmlDoc = '<?xml version="1.0" encoding="utf-8" ?><methodCall><params>';
@ -19,6 +23,12 @@
return $xmlDoc;
}
/**
* Request data to server and returns result
*
* @param array $params Request data
* @return object
*/
function getXmlDoc(&$params)
{
$body = XmlGenerater::generate($params);
@ -30,9 +40,21 @@
}
}
/**
* High class of the autoinstall module
* @author NHN (developers@xpressengine.com)
**/
class autoinstall extends ModuleObject {
/**
* Temporary directory path
*/
var $tmp_dir = './files/cache/autoinstall/';
/**
* Constructor
*
* @return void
*/
function autoinstall()
{
$oModuleModel = &getModel('module');
@ -44,7 +66,9 @@
}
/**
* @brief for additional tasks required when installing
* For additional tasks required when installing
*
* @return Object
**/
function moduleInstall() {
$oModuleController = &getController('module');
@ -54,7 +78,9 @@
}
/**
* @brief method to check if installation is succeeded
* Method to check if installation is succeeded
*
* @return bool
**/
function checkUpdate() {
$oDB =& DB::getInstance();
@ -82,7 +108,9 @@
}
/**
* @brief Execute update
* Execute update
*
* @return Object
**/
function moduleUpdate() {
$oDB =& DB::getInstance();
@ -118,7 +146,8 @@
}
/**
* @brief Re-generate the cache file
* Re-generate the cache file
* @return Object
**/
function recompileCache() {
}

View file

@ -1,21 +1,75 @@
<?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;
/**
* Server's base url
* @var string
*/
var $base_url;
/**
* Temporary directory
* @var string
*/
var $temp_dir = './files/cache/autoinstall/';
/**
* Install path
* @var string
*/
var $target_path;
/**
* Downloaded file path
* @var string
*/
var $download_file;
/**
* ???
* @var string
*/
var $url;
/**
* Download path
* @var string
*/
var $download_path;
/**
* FTP password
* @var string
*/
var $ftp_password;
/**
* Set server's base url
*
* @param string $url The url to set
* @return void
*/
function setServerUrl($url)
{
$this->base_url = $url;
}
/**
* Uninstall
*
* @return Object
*/
function uninstall()
{
$oModel =& getModel('autoinstall');
@ -33,11 +87,22 @@
return $output;
}
/**
* Set a FTP password
*
* @param string $ftp_password The password to set.
* @return void
*/
function setPassword($ftp_password)
{
$this->ftp_password = $ftp_password;
}
/**
* Download file from server
*
* @return void
*/
function _download()
{
if($this->package->path == ".")
@ -64,6 +129,13 @@
FileHandler::writeFile($this->download_file, $buff);
}
/**
* Uninstall module.
*
* Call module's moduleUninstall() and drop all tables related module
*
* @return Object
*/
function uninstallModule()
{
$path_array = explode("/", $this->package->path);
@ -87,6 +159,13 @@
return new Object();
}
/**
* Install module
*
* Call module's moduleInstall(), moduleUpdate() and create tables.
*
* @return void
*/
function installModule()
{
$path = $this->package->path;
@ -116,6 +195,13 @@
}
}
/**
* Install module.
*
* Download file and install module
*
* @return Object
*/
function install()
{
$this->_download();
@ -132,6 +218,11 @@
return new Object();
}
/**
* Untar a downloaded tar ball
*
* @return array Returns file list
*/
function _unPack(){
require_once(_XE_PATH_.'libs/tar.class.php');
@ -150,6 +241,12 @@
return $file_list;
}
/**
* Remove directory
*
* @param string $path Path to remove
* @return Object
*/
function _removeDir($path) {
$real_path = FileHandler::getRealPath($path);
$oDir = dir($path);
@ -179,17 +276,46 @@
}
/**
* Module installer for SFTP
* @author NHN (developers@xpressengine.com)
*/
class SFTPModuleInstaller extends ModuleInstaller {
/**
* FTP information
* @var object
*/
var $ftp_info = null;
/**
* SFTP connection
* @var resource
*/
var $connection = null;
/**
* SFTP resource
* @var resource
*/
var $sftp = null;
/**
* Constructor
*
* @param object $package Package information
* @return void
*/
function SFTPModuleInstaller(&$package)
{
$this->package =& $package;
$this->ftp_info = Context::getFTPInfo();
}
/**
* Connect to SFTP
*
* @return Object
*/
function _connect() {
if(!function_exists('ssh2_connect'))
{
@ -216,9 +342,20 @@
return new Object();
}
/**
* Close
*
* @return void
*/
function _close() {
}
/**
* Remove file
*
* @param string $path Path to remove
* @return Object
*/
function _removeFile($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
@ -231,6 +368,12 @@
return new Object();
}
/**
* Remove Directory
*
* @param string $path Path to remove
* @return Object
*/
function _removeDir_real($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
@ -243,6 +386,12 @@
return new Object();
}
/**
* Copy directory
*
* @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');
@ -270,17 +419,40 @@
}
}
/**
* Module installer for PHP FTP
* @author NHN (developers@xpressengine.com)
*/
class PHPFTPModuleInstaller extends ModuleInstaller {
/**
* FTP information
* @var object
*/
var $ftp_info = null;
/**
* FTP connection
* @var resource
*/
var $connection = null;
/**
* Constructor
*
* @param object $package Package information
* @var void
*/
function PHPFTPModuleInstaller(&$package)
{
$this->package =& $package;
$this->ftp_info = Context::getFTPInfo();
}
/**
* Connect to FTP
*
* @return Object
*/
function _connect()
{
if($this->ftp_info->ftp_host)
@ -313,6 +485,12 @@
return new Object();
}
/**
* Remove file
*
* @param string $path Path to remove
* @return Object
*/
function _removeFile($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
@ -325,6 +503,12 @@
return new Object();
}
/**
* Remove directory
*
* @param string $path Path to remove
* @return Object
*/
function _removeDir_real($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
@ -338,10 +522,21 @@
}
/**
* Close
*
* @return void
*/
function _close() {
ftp_close($this->connection);
}
/**
* Copy directory
*
* @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');
@ -402,16 +597,39 @@
}
}
/**
* Module installer for FTP
* @author NHN (developers@xpressengine.com)
*/
class FTPModuleInstaller extends ModuleInstaller {
/**
* FTP instance
* @var FTP
*/
var $oFtp = null;
/**
* FTP information
* @var object
*/
var $ftp_info = null;
/**
* Constructor
*
* @param object $package Package information
*/
function FTPModuleInstaller(&$package)
{
$this->package =& $package;
$this->ftp_info = Context::getFTPInfo();
}
/**
* Connect to FTP
*
* @return Object
*/
function _connect() {
if($this->ftp_info->ftp_host)
{
@ -435,6 +653,12 @@
return new Object();
}
/**
* Remove file
*
* @param string $path Path to remove
* @return Object
*/
function _removeFile($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
@ -447,6 +671,11 @@
return new Object();
}
/**
* Remove directory
* @param string $path Path to remove
* @return Object
*/
function _removeDir_real($path)
{
if(substr($path, 0, 2) == "./") $path = substr($path, 2);
@ -459,10 +688,21 @@
return new Object();
}
/**
* Close
*
* @return void
*/
function _close() {
$this->oFtp->ftp_quit();
}
/**
* Copy directory
*
* @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');

View file

@ -1,12 +1,16 @@
<?php
/**
* @class autoinstallModel
* Model class of the autoinstall module
* @author NHN (developers@xpressengine.com)
* @brief Model class of the autoinstall module
**/
class autoinstallModel extends autoinstall {
/**
* Get category information
*
* @param int $category_srl The sequence of category to get information
* @return object
*/
function getCategory($category_srl)
{
$args->category_srl = $category_srl;
@ -15,6 +19,11 @@
return array_shift($output->data);
}
/**
* Get packages information
*
* @return array
*/
function getPackages()
{
$output = executeQueryArray("autoinstall.getPackages");
@ -22,6 +31,12 @@
return $output->data;
}
/**
* Get installed packages information
*
* @param int $package_srl The sequence of package to get information
* @return object
*/
function getInstalledPackage($package_srl)
{
$args->package_srl = $package_srl;
@ -30,6 +45,12 @@
return array_shift($output->data);
}
/**
* Get one package information
*
* @param int $package_srl The sequence of package to get information
* @return object
*/
function getPackage($package_srl)
{
$args->package_srl = $package_srl;
@ -38,6 +59,11 @@
return array_shift($output->data);
}
/**
* Get category list
*
* @return array
*/
function getCategoryList()
{
$output = executeQueryArray("autoinstall.getCategories");
@ -70,6 +96,12 @@
return $resultList;
}
/**
* Get pcakge count in category
*
* @param int $category_srl The sequence of category to get count
* @return int
*/
function getPackageCount($category_srl)
{
$args->category_srl = $category_srl;
@ -78,6 +110,11 @@
return $output->data->count;
}
/**
* Get installed package count
*
* @return int
*/
function getInstalledPackageCount()
{
$output = executeQuery("autoinstall.getInstalledPackageCount", $args);
@ -85,6 +122,15 @@
return $output->data->count;
}
/**
* Set depth, children list and package count of category
*
* @param object $item Category information
* @param int $depth Depth of category
* @param array $list Category list
* @param array $resultList Final result list
* @return string $siblingList Comma seperated list
*/
function setDepth(&$item, $depth, &$list, &$resultList)
{
$resultList[$item->category_srl] =& $item;
@ -102,12 +148,23 @@
return $siblingList;
}
/**
* Get lastest package information
*
* @return object Returns lastest package information. If no result returns null.
*/
function getLatestPackage() {
$output = executeQueryArray("autoinstall.getLatestPackage");
if(!$output->data) return null;
return array_shift($output->data);
}
/**
* Get installed package informations
*
* @param array $package_list Package sequence list to get information
* @return array Returns array contains pacakge information. If no result returns empty array.
*/
function getInstalledPackages($package_list) {
$args->package_list = $package_list;
$output = executeQueryArray("autoinstall.getInstalledPackages", $args);
@ -120,6 +177,12 @@
return $result;
}
/**
* Get installed package list
*
* @param int $page
* @return Object
*/
function getInstalledPackageList($page)
{
$args->page = $page;
@ -138,6 +201,12 @@
return $output;
}
/**
* Get type using path
*
* @param string $path Path to get type
* @return string
*/
function getTypeFromPath($path)
{
if(!$path) return null;
@ -148,6 +217,12 @@
return $type;
}
/**
* Get config file path by type
*
* @param string $type Type to get config file path
* @return string
*/
function getConfigFilePath($type)
{
$config_file = null;
@ -176,6 +251,12 @@
return $config_file;
}
/**
* Returns target is removable
*
* @param string $path Path
* @return bool
*/
function checkRemovable($path)
{
$path_array = explode("/", $path);
@ -186,6 +267,12 @@
else return false;
}
/**
* Get sequence of package by path
*
* @param string $path Path to get sequence
* @return int
*/
function getPackageSrlByPath($path)
{
if (!$path) return;
@ -203,6 +290,12 @@
return $GLOBLAS['XE_AUTOINSTALL_PACKAGE_SRL_BY_PATH'][$path];
}
/**
* Get remove url by package srl
*
* @param int $packageSrl Sequence of pakcage to get url
* @return string
*/
function getRemoveUrlByPackageSrl($packageSrl)
{
$ftp_info = Context::getFTPInfo();
@ -213,6 +306,12 @@
return getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminUninstall', 'package_srl', $packageSrl);
}
/**
* Get remove url by path
*
* @param string $path Path to get url
* @return string
*/
function getRemoveUrlByPath($path)
{
if (!$path) return;
@ -226,6 +325,12 @@
return getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminUninstall', 'package_srl', $packageSrl);
}
/**
* Get update url by package srl
*
* @param int $packageSrl Sequence to get url
* @return string
*/
function getUpdateUrlByPackageSrl($packageSrl)
{
if (!$packageSrl) return;
@ -233,6 +338,12 @@
return getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAutoinstallAdminInstall', 'package_srl', $packageSrl);
}
/**
* Get update url by path
*
* @param string $path Path to get url
* @return string
*/
function getUpdateUrlByPath($path)
{
if (!$path) return;

View file

@ -1,19 +1,24 @@
<?php
/**
* @class autoinstallView
* View class of the autoinstall module
* @author NHN (developers@xpressengine.com)
* @brief View class of the autoinstall module
**/
class autoinstallView extends autoinstall {
/**
* @brief Initialization
* Initialization
*
* @return void
**/
function init() {
}
/**
* Test
*
* @return Object
*/
function dispAutoinstallTest(){
$file = "modules.test.tar";
$checksum = '549989037bd8401d39b83ca2393d8131';