mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Clean up constructors and other method signatures
This commit is contained in:
parent
2cbfd4500c
commit
564563f56c
8 changed files with 175 additions and 124 deletions
|
|
@ -5,28 +5,38 @@
|
|||
* @class ModuleObject
|
||||
* @author NAVER (developers@xpressengine.com)
|
||||
* base class of ModuleHandler
|
||||
* */
|
||||
*/
|
||||
class ModuleObject extends BaseObject
|
||||
{
|
||||
// Variables about the current module
|
||||
public $module;
|
||||
public $module_info;
|
||||
public $origin_module_info;
|
||||
public $module_config;
|
||||
public $module_path;
|
||||
public $xml_info;
|
||||
|
||||
var $mid = NULL; ///< string to represent run-time instance of Module (XE Module)
|
||||
var $module = NULL; ///< Class name of Xe Module that is identified by mid
|
||||
var $module_srl = NULL; ///< integer value to represent a run-time instance of Module (XE Module)
|
||||
var $module_info = NULL; ///< an object containing the module information
|
||||
var $origin_module_info = NULL;
|
||||
var $xml_info = NULL; ///< an object containing the module description extracted from XML file
|
||||
var $module_path = NULL; ///< a path to directory where module source code resides
|
||||
var $act = NULL; ///< a string value to contain the action name
|
||||
var $template_path = NULL; ///< a path of directory where template files reside
|
||||
var $template_file = NULL; ///< name of template file
|
||||
var $layout_path = ''; ///< a path of directory where layout files reside
|
||||
var $layout_file = ''; ///< name of layout file
|
||||
var $edited_layout_file = ''; ///< name of temporary layout files that is modified in an admin mode
|
||||
var $stop_proc = FALSE; ///< a flag to indicating whether to stop the execution of code.
|
||||
var $module_config = NULL;
|
||||
var $ajaxRequestMethod = array('XMLRPC', 'JSON');
|
||||
var $gzhandler_enable = TRUE;
|
||||
var $user = FALSE;
|
||||
// Variables about the current module instance and the current request
|
||||
public $module_srl;
|
||||
public $mid;
|
||||
public $act;
|
||||
|
||||
// Variables about the layout and/or template
|
||||
public $template_path;
|
||||
public $template_file;
|
||||
public $layout_path;
|
||||
public $layout_file;
|
||||
public $edited_layout_file;
|
||||
|
||||
// Variables to control processing
|
||||
public $stop_proc = false;
|
||||
|
||||
// Variables for convenience
|
||||
public $user;
|
||||
|
||||
// Other variables for compatibility
|
||||
public $ajaxRequestMethod = array('XMLRPC', 'JSON');
|
||||
public $gzhandler_enable = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -35,7 +45,7 @@ class ModuleObject extends BaseObject
|
|||
* @param string $message Error message
|
||||
* @return void
|
||||
*/
|
||||
function __construct($error = 0, $message = 'success')
|
||||
public function __construct($error = 0, $message = 'success')
|
||||
{
|
||||
$this->user = Context::get('logged_info') ?: new Rhymix\Framework\Helpers\SessionHelper;
|
||||
if(!($this->user instanceof Rhymix\Framework\Helpers\SessionHelper))
|
||||
|
|
@ -47,35 +57,39 @@ class ModuleObject extends BaseObject
|
|||
|
||||
/**
|
||||
* setter to set the name of module
|
||||
*
|
||||
* @param string $module name of module
|
||||
* @return void
|
||||
* */
|
||||
function setModule($module)
|
||||
* @return $this
|
||||
*/
|
||||
public function setModule($module)
|
||||
{
|
||||
$this->module = $module;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter to set the name of module path
|
||||
*
|
||||
* @param string $path the directory path to a module directory
|
||||
* @return void
|
||||
* */
|
||||
function setModulePath($path)
|
||||
* @return $this
|
||||
*/
|
||||
public function setModulePath($path)
|
||||
{
|
||||
if(substr_compare($path, '/', -1) !== 0)
|
||||
{
|
||||
$path.='/';
|
||||
}
|
||||
$this->module_path = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter to set an url for redirection
|
||||
*
|
||||
* @param string $url url for redirection
|
||||
* @remark redirect_url is used only for ajax requests
|
||||
* @return void
|
||||
* */
|
||||
function setRedirectUrl($url = './', $output = NULL)
|
||||
* @return $this
|
||||
*/
|
||||
public function setRedirectUrl($url = './', $output = NULL)
|
||||
{
|
||||
$this->add('redirect_url', $url);
|
||||
|
||||
|
|
@ -83,13 +97,18 @@ class ModuleObject extends BaseObject
|
|||
{
|
||||
return $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get url for redirection
|
||||
* @return string redirect_url
|
||||
* */
|
||||
function getRedirectUrl()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRedirectUrl()
|
||||
{
|
||||
return $this->get('redirect_url');
|
||||
}
|
||||
|
|
@ -98,31 +117,36 @@ class ModuleObject extends BaseObject
|
|||
* Set the template path for refresh.html
|
||||
* refresh.html is executed as a result of method execution
|
||||
* Tpl as the common run of the refresh.html ..
|
||||
* @return void
|
||||
* */
|
||||
function setRefreshPage()
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRefreshPage()
|
||||
{
|
||||
$this->setTemplatePath('./common/tpl');
|
||||
$this->setTemplateFile('refresh');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the action name
|
||||
*
|
||||
* @param string $act
|
||||
* @return void
|
||||
* */
|
||||
function setAct($act)
|
||||
* @return $this
|
||||
*/
|
||||
public function setAct($act)
|
||||
{
|
||||
$this->act = $act;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set module information
|
||||
*
|
||||
* @param object $module_info object containing module information
|
||||
* @param object $xml_info object containing module description
|
||||
* @return void
|
||||
* */
|
||||
function setModuleInfo($module_info, $xml_info)
|
||||
* @return $this
|
||||
*/
|
||||
public function setModuleInfo($module_info, $xml_info)
|
||||
{
|
||||
// Set default variables
|
||||
$this->mid = $module_info->mid;
|
||||
|
|
@ -167,13 +191,16 @@ class ModuleObject extends BaseObject
|
|||
$this->stop($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set privileges(granted) information of current user and check permission of current module
|
||||
* @return boolean success : true, fail : false
|
||||
* */
|
||||
function setPrivileges()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setPrivileges()
|
||||
{
|
||||
if(Context::get('logged_info')->is_admin !== 'Y')
|
||||
{
|
||||
|
|
@ -248,11 +275,12 @@ class ModuleObject extends BaseObject
|
|||
|
||||
/**
|
||||
* Check permission
|
||||
*
|
||||
* @param object $grant privileges(granted) information of user
|
||||
* @param object $member_info member information
|
||||
* @return boolean success : true, fail : false
|
||||
* */
|
||||
function checkPermission($grant = null, $member_info = null)
|
||||
* @return bool
|
||||
*/
|
||||
public function checkPermission($grant = null, $member_info = null)
|
||||
{
|
||||
// Get logged-in member information
|
||||
if(!$member_info)
|
||||
|
|
@ -348,11 +376,12 @@ class ModuleObject extends BaseObject
|
|||
}
|
||||
|
||||
/**
|
||||
* set the stop_proc and approprate message for msg_code
|
||||
* Stop processing this module instance.
|
||||
*
|
||||
* @param string $msg_code an error code
|
||||
* @return ModuleObject $this
|
||||
* */
|
||||
function stop($msg_code)
|
||||
*/
|
||||
public function stop($msg_code)
|
||||
{
|
||||
if($this->stop_proc !== true)
|
||||
{
|
||||
|
|
@ -385,35 +414,39 @@ class ModuleObject extends BaseObject
|
|||
|
||||
/**
|
||||
* set the file name of the template file
|
||||
*
|
||||
* @param string name of file
|
||||
* @return void
|
||||
* */
|
||||
function setTemplateFile($filename)
|
||||
* @return $this
|
||||
*/
|
||||
public function setTemplateFile($filename)
|
||||
{
|
||||
if(isset($filename) && substr_compare($filename, '.html', -5) !== 0)
|
||||
{
|
||||
$filename .= '.html';
|
||||
}
|
||||
$this->template_file = $filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve the directory path of the template directory
|
||||
*
|
||||
* @return string
|
||||
* */
|
||||
function getTemplateFile()
|
||||
*/
|
||||
public function getTemplateFile()
|
||||
{
|
||||
return $this->template_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the directory path of the template directory
|
||||
*
|
||||
* @param string path of template directory.
|
||||
* @return void
|
||||
* */
|
||||
function setTemplatePath($path)
|
||||
* @return $this
|
||||
*/
|
||||
public function setTemplatePath($path)
|
||||
{
|
||||
if(!$path) return;
|
||||
if(!$path) return $this;
|
||||
|
||||
if((strlen($path) >= 1 && substr_compare($path, '/', 0, 1) !== 0) && (strlen($path) >= 2 && substr_compare($path, './', 0, 2) !== 0))
|
||||
{
|
||||
|
|
@ -425,70 +458,80 @@ class ModuleObject extends BaseObject
|
|||
$path .= '/';
|
||||
}
|
||||
$this->template_path = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve the directory path of the template directory
|
||||
*
|
||||
* @return string
|
||||
* */
|
||||
function getTemplatePath()
|
||||
*/
|
||||
public function getTemplatePath()
|
||||
{
|
||||
return $this->template_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the file name of the temporarily modified by admin
|
||||
*
|
||||
* @param string name of file
|
||||
* @return void
|
||||
* */
|
||||
function setEditedLayoutFile($filename)
|
||||
* @return $this
|
||||
*/
|
||||
public function setEditedLayoutFile($filename)
|
||||
{
|
||||
if(!$filename) return;
|
||||
if(!$filename) return $this;
|
||||
|
||||
if(substr_compare($filename, '.html', -5) !== 0)
|
||||
{
|
||||
$filename .= '.html';
|
||||
}
|
||||
$this->edited_layout_file = $filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* retreived the file name of edited_layout_file
|
||||
*
|
||||
* @return string
|
||||
* */
|
||||
function getEditedLayoutFile()
|
||||
*/
|
||||
public function getEditedLayoutFile()
|
||||
{
|
||||
return $this->edited_layout_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the file name of the layout file
|
||||
*
|
||||
* @param string name of file
|
||||
* @return void
|
||||
* */
|
||||
function setLayoutFile($filename)
|
||||
* @return $this
|
||||
*/
|
||||
public function setLayoutFile($filename)
|
||||
{
|
||||
if($filename && substr_compare($filename, '.html', -5) !== 0)
|
||||
{
|
||||
$filename .= '.html';
|
||||
}
|
||||
$this->layout_file = $filename;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the file name of the layout file
|
||||
*
|
||||
* @return string
|
||||
* */
|
||||
function getLayoutFile()
|
||||
*/
|
||||
public function getLayoutFile()
|
||||
{
|
||||
return $this->layout_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the directory path of the layout directory
|
||||
*
|
||||
* @param string path of layout directory.
|
||||
* */
|
||||
function setLayoutPath($path)
|
||||
* @return $this
|
||||
*/
|
||||
public function setLayoutPath($path)
|
||||
{
|
||||
if(!$path) return;
|
||||
|
||||
|
|
@ -501,22 +544,24 @@ class ModuleObject extends BaseObject
|
|||
$path .= '/';
|
||||
}
|
||||
$this->layout_path = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the directory path of the layout directory
|
||||
*
|
||||
* @return string
|
||||
* */
|
||||
function getLayoutPath($layout_name = "", $layout_type = "P")
|
||||
*/
|
||||
public function getLayoutPath($layout_name = "", $layout_type = "P")
|
||||
{
|
||||
return $this->layout_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* excute the member method specified by $act variable
|
||||
* @return boolean true : success false : fail
|
||||
* */
|
||||
function proc()
|
||||
* @return bool
|
||||
*/
|
||||
public function proc()
|
||||
{
|
||||
// pass if stop_proc is true
|
||||
if($this->stop_proc)
|
||||
|
|
|
|||
|
|
@ -8,30 +8,29 @@
|
|||
*/
|
||||
class BaseObject
|
||||
{
|
||||
|
||||
/**
|
||||
* Error code. If `0`, it is not an error.
|
||||
* @var int
|
||||
*/
|
||||
var $error = 0;
|
||||
public $error = 0;
|
||||
|
||||
/**
|
||||
* Error message. If `success`, it is not an error.
|
||||
* @var string
|
||||
*/
|
||||
var $message = 'success';
|
||||
public $message = 'success';
|
||||
|
||||
/**
|
||||
* An additional variable
|
||||
* @var array
|
||||
*/
|
||||
var $variables = array();
|
||||
public $variables = array();
|
||||
|
||||
/**
|
||||
* http status code.
|
||||
* @var int
|
||||
*/
|
||||
var $httpStatusCode = 200;
|
||||
public $httpStatusCode = 200;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -40,7 +39,7 @@ class BaseObject
|
|||
* @param string $message Error message
|
||||
* @return void
|
||||
*/
|
||||
function __construct($error = 0, $message = 'success')
|
||||
public function __construct($error = 0, $message = 'success')
|
||||
{
|
||||
$this->setError($error);
|
||||
$this->setMessage($message);
|
||||
|
|
@ -81,7 +80,7 @@ class BaseObject
|
|||
* @param int|strong $error error code or message
|
||||
* @return $this
|
||||
*/
|
||||
function setError($error = 0)
|
||||
public function setError($error = 0)
|
||||
{
|
||||
// If the first argument is an integer, treat it as an error code. Otherwise, treat it as an error message.
|
||||
$args = func_get_args();
|
||||
|
|
@ -113,7 +112,7 @@ class BaseObject
|
|||
*
|
||||
* @return int Returns an error code
|
||||
*/
|
||||
function getError()
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
|
@ -124,9 +123,9 @@ class BaseObject
|
|||
* @param int $code HTTP status code. Default value is `200` that means successful
|
||||
* @return $this
|
||||
*/
|
||||
function setHttpStatusCode($code = 200)
|
||||
public function setHttpStatusCode($code = 200)
|
||||
{
|
||||
$this->httpStatusCode = (int) $code;
|
||||
$this->httpStatusCode = (int)$code;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +134,7 @@ class BaseObject
|
|||
*
|
||||
* @return int Returns HTTP status code
|
||||
*/
|
||||
function getHttpStatusCode()
|
||||
public function getHttpStatusCode()
|
||||
{
|
||||
return $this->httpStatusCode;
|
||||
}
|
||||
|
|
@ -147,7 +146,7 @@ class BaseObject
|
|||
* @param string $type type of message (error, info, update)
|
||||
* @return $this
|
||||
*/
|
||||
function setMessage($message = 'success', $type = null)
|
||||
public function setMessage($message = 'success', $type = null)
|
||||
{
|
||||
$this->message = lang($message);
|
||||
if($type !== null)
|
||||
|
|
@ -162,7 +161,7 @@ class BaseObject
|
|||
*
|
||||
* @return string Returns message
|
||||
*/
|
||||
function getMessage()
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
|
@ -172,9 +171,9 @@ class BaseObject
|
|||
* @param string $type type of message (error, info, update)
|
||||
* @return $this
|
||||
* */
|
||||
function setMessageType($type)
|
||||
public function setMessageType($type)
|
||||
{
|
||||
$this->add('message_type', $type);
|
||||
$this->variables['message_type'] = strval($type);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +181,7 @@ class BaseObject
|
|||
* get type of message
|
||||
* @return string $type
|
||||
* */
|
||||
function getMessageType()
|
||||
public function getMessageType()
|
||||
{
|
||||
$type = $this->get('message_type');
|
||||
$typeList = array('error' => 1, 'info' => 1, 'update' => 1);
|
||||
|
|
@ -200,19 +199,28 @@ class BaseObject
|
|||
* @param mixed $val A value for the variable
|
||||
* @return $this
|
||||
*/
|
||||
function add($key, $val)
|
||||
public function set($key, $val)
|
||||
{
|
||||
$this->variables[$key] = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set multiple key/value pairs as an additional variables
|
||||
* Alias to set().
|
||||
*/
|
||||
public function add($key, $val)
|
||||
{
|
||||
$this->variables[$key] = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set multiple key/value pairs as additional variables
|
||||
*
|
||||
* @param object|array $vars Either object or array containg key/value pairs to be added
|
||||
* @return $this
|
||||
*/
|
||||
function adds($vars)
|
||||
public function sets($vars)
|
||||
{
|
||||
if(is_object($vars))
|
||||
{
|
||||
|
|
@ -228,13 +236,21 @@ class BaseObject
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias to sets().
|
||||
*/
|
||||
public function adds($vars)
|
||||
{
|
||||
return $this->sets($vars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve a corresponding value to a given key
|
||||
*
|
||||
* @param string $key
|
||||
* @return string Returns value to a given key
|
||||
*/
|
||||
function get($key)
|
||||
public function get($key)
|
||||
{
|
||||
return $this->variables[$key];
|
||||
}
|
||||
|
|
@ -244,7 +260,7 @@ class BaseObject
|
|||
*
|
||||
* @return object Returns an object containing key/value pairs
|
||||
*/
|
||||
function gets()
|
||||
public function gets()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$output = new stdClass();
|
||||
|
|
@ -260,7 +276,7 @@ class BaseObject
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
function getVariables()
|
||||
public function getVariables()
|
||||
{
|
||||
return $this->variables;
|
||||
}
|
||||
|
|
@ -270,14 +286,9 @@ class BaseObject
|
|||
*
|
||||
* @return object
|
||||
*/
|
||||
function getObjectVars()
|
||||
public function getObjectVars()
|
||||
{
|
||||
$output = new stdClass();
|
||||
foreach($this->variables as $key => $val)
|
||||
{
|
||||
$output->{$key} = $val;
|
||||
}
|
||||
return $output;
|
||||
return get_object_vars($this->variables);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -285,7 +296,7 @@ class BaseObject
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function unset($key)
|
||||
public function unset($key)
|
||||
{
|
||||
unset($this->variables[$key]);
|
||||
}
|
||||
|
|
@ -295,7 +306,7 @@ class BaseObject
|
|||
*
|
||||
* @return bool Retruns true : error isn't 0 or false : otherwise.
|
||||
*/
|
||||
function toBool()
|
||||
public function toBool()
|
||||
{
|
||||
// TODO This method is misleading in that it returns true if error is 0, which should be true in boolean representation.
|
||||
return ($this->error == 0);
|
||||
|
|
@ -306,7 +317,7 @@ class BaseObject
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
function toBoolean()
|
||||
public function toBoolean()
|
||||
{
|
||||
return $this->toBool();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class adminAdminView extends admin
|
|||
function __construct()
|
||||
{
|
||||
Context::set('xe_default_url', Context::getDefaultUrl());
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -69,15 +69,6 @@ class autoinstall extends ModuleObject
|
|||
*/
|
||||
var $tmp_dir = './files/cache/autoinstall/';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* For additional tasks required when installing
|
||||
*
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ class board extends ModuleObject
|
|||
{
|
||||
Context::addSSLAction('dispTempSavedList');
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,15 +22,14 @@ class member extends ModuleObject {
|
|||
{
|
||||
if(!Context::isInstalled()) return;
|
||||
|
||||
$oModuleModel = getModel('module');
|
||||
$member_config = $oModuleModel->getModuleConfig('member');
|
||||
|
||||
// Set to use SSL upon actions related member join/information/password and so on. 2013.02.15
|
||||
if(!Context::isExistsSSLAction('dispMemberModifyPassword') && Context::getSslStatus() == 'optional')
|
||||
{
|
||||
$ssl_actions = array('dispMemberModifyPassword', 'dispMemberSignUpForm', 'dispMemberModifyInfo', 'dispMemberModifyEmailAddress', 'dispMemberResendAuthMail', 'dispMemberLoginForm', 'dispMemberFindAccount', 'dispMemberLeave', 'procMemberLogin', 'procMemberModifyPassword', 'procMemberInsert', 'procMemberModifyInfo', 'procMemberFindAccount', 'procMemberModifyEmailAddress', 'procMemberResendAuthMail', 'procMemberLeave'/*, 'getMemberMenu'*/, 'procMemberFindAccountByQuestion');
|
||||
Context::addSSLActions($ssl_actions);
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ class menuAdminController extends menu
|
|||
|
||||
function __construct() {
|
||||
$this->homeMenuCacheFile = _XE_PATH_ . $this->homeMenuCacheFile;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class session extends ModuleObject
|
|||
function __construct()
|
||||
{
|
||||
if(Context::isInstalled()) $this->session_started= true;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue