Remove trailing whitespace in legacy class files

This commit is contained in:
Kijin Sung 2023-01-17 21:07:55 +09:00
parent 8a6039b829
commit c881e73c1d
29 changed files with 481 additions and 483 deletions

View file

@ -120,7 +120,7 @@ class ModuleHandler extends Handler
public function init()
{
$site_module_info = Context::get('site_module_info');
// Check unregistered domain action.
if (!$site_module_info || !isset($site_module_info->domain_srl) || ($site_module_info->is_default_replaced ?? false))
{
@ -133,17 +133,17 @@ class ModuleHandler extends Handler
case 'redirect_301':
header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 301);
return false;
case 'redirect_302':
header('Location: ' . Context::getDefaultUrl($site_module_info) . RX_REQUEST_URL, true, 302);
return false;
case 'block':
$this->error = 'The site does not exist';
$this->error_detail = 'ERR_DOMAIN_NOT_FOUND';
$this->httpStatusCode = 404;
return true;
case 'display':
// pass
}
@ -160,7 +160,7 @@ class ModuleHandler extends Handler
Context::set($key, null);
}
}
// If the Router returned an error earlier, show an error here.
if($this->route && $this->route->status > 200)
{
@ -169,7 +169,7 @@ class ModuleHandler extends Handler
$this->httpStatusCode = 404;
return true;
}
// Convert document alias (entry) to document_srl
if(!$this->document_srl && $this->mid && $this->entry)
{
@ -193,7 +193,7 @@ class ModuleHandler extends Handler
{
$module_info = null;
}
// Get module info from mid.
if(!$module_info && $this->mid)
{
@ -219,7 +219,7 @@ class ModuleHandler extends Handler
header('location: ' . getNotEncodedSiteUrl($site_module_info->domain), true, 301);
return false;
}
// If module info was set, retrieve variables from the module information
if($module_info)
{
@ -228,7 +228,7 @@ class ModuleHandler extends Handler
$this->mid = $module_info->mid;
$this->module_info = $module_info;
$this->_setModuleSEOInfo($module_info, $site_module_info);
// Check if the current request is from a mobile device.
$this->is_mobile = Mobile::isFromMobilePhone();
$viewType = $this->is_mobile ? 'M' : 'P';
@ -257,7 +257,7 @@ class ModuleHandler extends Handler
// Reset layout_srl in module_info.
$module_info->{$targetSrl} = $layoutSrl;
// Add layout header script.
$part_config = ModuleModel::getModulePartConfig('layout', $layoutSrl);
Context::addHtmlHeader($part_config->header_script);
@ -270,7 +270,7 @@ class ModuleHandler extends Handler
}
$this->_setModuleColorScheme($site_module_info);
// Always overwrite site_srl (deprecated)
$this->module_info->site_srl = $site_module_info->site_srl;
@ -288,7 +288,7 @@ class ModuleHandler extends Handler
{
Context::set('mid', $this->mid, TRUE);
}
// Call a trigger after moduleHandler init
$output = self::triggerCall('moduleHandler.init', 'after', $this->module_info);
if(!$output->toBool())
@ -376,7 +376,7 @@ class ModuleHandler extends Handler
return self::_createErrorMessage(-1, 'msg_security_violation', 403, 'ERR_CSRF_CHECK_FAILED');
}
}
// check if the current action allows standalone access (without mid)
if(isset($xml_info->action->{$this->act}))
{
@ -467,7 +467,7 @@ class ModuleHandler extends Handler
{
return self::_createErrorMessage(-1, 'msg_invalid_request', 403, 'ERR_NOT_FORWARDABLE');
}
// 1. Look for the module with action name
if(preg_match('/^[a-z]+([A-Z][a-z0-9\_]+).*$/', $this->act, $matches))
{
@ -497,12 +497,12 @@ class ModuleHandler extends Handler
$forward->act = $this->act;
}
}
if(empty($forward->module))
{
$forward = ModuleModel::getActionForward($this->act);
}
if(!empty($forward->module))
{
$kind = (stripos($forward->act, 'admin') !== false || stripos($forward->class_name, 'admin') !== false) ? 'admin' : '';
@ -514,9 +514,9 @@ class ModuleHandler extends Handler
{
Context::addMetaTag('robots', 'noindex');
}
$xml_info = ModuleModel::getModuleActionXml($forward->module);
// Protect admin action
if(($this->module == 'admin' || $kind == 'admin') && !ModuleModel::getGrant($forward, $logged_info)->root)
{
@ -525,7 +525,7 @@ class ModuleHandler extends Handler
return self::_createErrorMessage(-1, 'admin.msg_is_not_administrator');
}
}
// SECISSUE also check REQUEST_METHOD for forwarded actions
$allowedMethodList = explode('|', $xml_info->action->{$this->act}->method);
if(!in_array($_SERVER['REQUEST_METHOD'], $allowedMethodList))
@ -541,7 +541,7 @@ class ModuleHandler extends Handler
return self::_createErrorMessage(-1, 'msg_security_violation', 403, 'ERR_CSRF_CHECK_FAILED');
}
}
if($forward->class_name)
{
$class_fullname = sprintf('Rhymix\\Modules\\%s\\%s', $forward->module, $forward->class_name);
@ -572,12 +572,12 @@ class ModuleHandler extends Handler
{
$oModule = self::getModuleInstance($forward->module, $type, $kind);
}
if(!is_object($oModule))
{
return self::_createErrorMessage(-1, 'msg_module_class_not_found', 404);
}
// Admin page layout
if($this->module == 'admin' && $type == 'view' && $this->act != 'dispLayoutAdminLayoutModify')
{
@ -598,7 +598,7 @@ class ModuleHandler extends Handler
return $oModule;
}
}
// ruleset check...
if(!empty($ruleset))
{
@ -668,11 +668,11 @@ class ModuleHandler extends Handler
$domain_info = Context::get('site_module_info');
if ($domain_info && $domain_info->settings && $domain_info->settings->html_header)
{
Context::addHtmlHeader($domain_info->settings->html_header);
Context::addHtmlHeader($domain_info->settings->html_header);
}
if ($domain_info && $domain_info->settings && $domain_info->settings->html_footer)
{
Context::addHtmlFooter($domain_info->settings->html_footer);
Context::addHtmlFooter($domain_info->settings->html_footer);
}
if ($domain_info && $domain_info->settings && $domain_info->settings->title)
{
@ -737,7 +737,7 @@ class ModuleHandler extends Handler
/**
* Check the value of $document_srl. This method is called during init().
*
*
* @return object|false
*/
protected function _checkDocumentSrl()
@ -773,14 +773,14 @@ class ModuleHandler extends Handler
Context::set('mid', $this->mid);
}
}
// Remove module info if a different module has already been selected for the current request.
if($this->module && $module_info->module !== $this->module)
{
$module_info = null;
}
}
// Block access to secret or temporary documents.
if(Context::getRequestMethod() === 'GET')
{
@ -794,14 +794,14 @@ class ModuleHandler extends Handler
$this->httpStatusCode = 403;
}
}
// Return the module info for further processing.
return $module_info;
}
/**
* Set color scheme.
*
*
* @param object $site_module_info
*/
protected function _setModuleColorScheme($site_module_info)
@ -820,10 +820,10 @@ class ModuleHandler extends Handler
Context::addBodyClass('color_scheme_' . $color_scheme);
}
}
/**
* Set SEO information to Context.
*
*
* @param object $module_info
* @param object $site_module_info
*/
@ -845,7 +845,7 @@ class ModuleHandler extends Handler
'subpage_title' => $module_info->browser_title,
'page' => Context::get('page') ?: 1,
));
// Set meta keywords.
$module_config = ModuleModel::getModuleConfig('module');
if (!empty($module_info->meta_keywords))
@ -860,7 +860,7 @@ class ModuleHandler extends Handler
{
Context::addMetaTag('keywords', $module_config->meta_keywords);
}
// Set meta description.
if (!empty($module_info->meta_description))
{
@ -875,10 +875,10 @@ class ModuleHandler extends Handler
Context::addMetaTag('description', $module_config->meta_description);
}
}
/**
* Save input values to session so that they can be recovered after returning to the previous form.
*
*
* @return void
*/
protected static function _setInputValueToSession()
@ -893,7 +893,7 @@ class ModuleHandler extends Handler
/**
* Get previous error information and restore it to Context so that it is available to templates.
*
*
* @return void
*/
protected static function _setInputErrorToContext()
@ -905,7 +905,7 @@ class ModuleHandler extends Handler
'XE_VALIDATOR_ERROR',
'XE_VALIDATOR_RETURN_URL',
];
foreach ($keys as $key)
{
if (!Context::get($key))
@ -913,7 +913,7 @@ class ModuleHandler extends Handler
Context::set($key, empty($_SESSION[$key]) ? null : $_SESSION[$key]);
}
}
if (!empty($_SESSION['INPUT_ERROR']))
{
Context::set('INPUT_ERROR', $_SESSION['INPUT_ERROR']);
@ -947,7 +947,7 @@ class ModuleHandler extends Handler
$caller = array_shift($backtrace);
$location = $caller['file'] . ':' . $caller['line'];
}
self::_setInputErrorToContext();
$oMessageObject = MessageView::getInstance();
$oMessageObject->setError($error);
@ -966,7 +966,7 @@ class ModuleHandler extends Handler
{
// Set the display mode for the current device type.
$this->is_mobile = Mobile::isFromMobilePhone();
// If the module is not set or not an object, set error
if(!$oModule || !is_object($oModule))
{
@ -1006,12 +1006,12 @@ class ModuleHandler extends Handler
$data['message'] = lang($oModule->message);
}
$data = array_merge($data, $oModule->getVariables());
ob_end_clean();
echo sprintf('<html><head></head><body><script>parent.XE.handleIframeResponse(%s, %s);</script></body></html>', json_encode(strval($_POST['_rx_ajax_form'])), json_encode($data));
return;
}
// Handle redirects.
if($oModule->getRedirectUrl())
{
@ -1038,7 +1038,7 @@ class ModuleHandler extends Handler
return;
}
}
// If error occurred, handle it
if($this->error)
{
@ -1050,7 +1050,7 @@ class ModuleHandler extends Handler
{
$oMessageObject->setTemplateFile('http_status_code');
}
// If module was called normally, change the templates of the module into ones of the message view module
if($oModule)
{
@ -1063,7 +1063,7 @@ class ModuleHandler extends Handler
{
$oModule = $oMessageObject;
}
self::_clearErrorSession();
}
@ -1118,7 +1118,7 @@ class ModuleHandler extends Handler
{
$oMenuAdminController = getAdminController('menu');
$homeMenuCacheFile = null;
foreach($layout_info->menu as $menu_id => $menu)
{ // No menu selected
if($menu->menu_srl == 0)
@ -1139,12 +1139,12 @@ class ModuleHandler extends Handler
{
include($homeMenuCacheFile);
}
$menu->xml_file = './files/cache/menu/' . $homeMenuSrl . '.xml.php';
$menu->php_file = './files/cache/menu/' . $homeMenuSrl . '.php';
$menu->menu_srl = $homeMenuSrl;
}
$php_file = FileHandler::exists($menu->php_file);
if(!$php_file)
{
@ -1156,7 +1156,7 @@ class ModuleHandler extends Handler
include($php_file);
}
}
Context::set($menu_id, $menu);
}
}
@ -1190,16 +1190,16 @@ class ModuleHandler extends Handler
}
}
}
// Set http status code
if($this->httpStatusCode && $oModule->getHttpStatusCode() === 200)
{
$oModule->setHttpStatusCode($this->httpStatusCode);
}
// Set http status message
self::_setHttpStatusMessage($oModule->getHttpStatusCode());
// Display contents
$oDisplayHandler = new DisplayHandler();
$oDisplayHandler->printContent($oModule);
@ -1264,7 +1264,7 @@ class ModuleHandler extends Handler
{
$triggers = array();
}
foreach($triggers as $item)
{
$module = $item->module;
@ -1289,13 +1289,13 @@ class ModuleHandler extends Handler
{
continue;
}
// do not call if module is blacklisted
if (Context::isBlacklistedPlugin($oModule->module))
{
continue;
}
try
{
$before_each_trigger_time = microtime(true);
@ -1310,7 +1310,7 @@ class ModuleHandler extends Handler
if ($trigger_name !== 'common.flushDebugInfo')
{
$trigger_target = $module . ($type === 'class' ? '' : $type) . '.' . $called_method;
if (Rhymix\Framework\Debug::isEnabledForCurrentUser())
{
Rhymix\Framework\Debug::addTrigger(array(
@ -1364,7 +1364,7 @@ class ModuleHandler extends Handler
{
$trigger_target = 'closure';
}
if (Rhymix\Framework\Debug::isEnabledForCurrentUser())
{
Rhymix\Framework\Debug::addTrigger(array(

View file

@ -52,7 +52,7 @@ class ModuleObject extends BaseObject
/**
* Singleton
*
*
* @param string $module_hint (optional)
* @return static
*/
@ -97,7 +97,7 @@ class ModuleObject extends BaseObject
/**
* setter to set the name of module
*
*
* @param string $module name of module
* @return $this
*/
@ -109,7 +109,7 @@ class ModuleObject extends BaseObject
/**
* setter to set the name of module path
*
*
* @param string $path the directory path to a module directory
* @return $this
*/
@ -125,7 +125,7 @@ class ModuleObject extends BaseObject
/**
* setter to set an url for redirection
*
*
* @param string $url url for redirection
* @return $this
*/
@ -145,7 +145,7 @@ class ModuleObject extends BaseObject
/**
* get url for redirection
*
*
* @return string
*/
public function getRedirectUrl()
@ -157,7 +157,7 @@ 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 ..
*
*
* @deprecated
* @return $this
*/
@ -170,7 +170,7 @@ class ModuleObject extends BaseObject
/**
* Set the action name
*
*
* @param string $act
* @return $this
*/
@ -179,10 +179,10 @@ class ModuleObject extends BaseObject
$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 $this
@ -197,14 +197,14 @@ class ModuleObject extends BaseObject
$this->xml_info = $xml_info;
$this->skin_vars = $module_info->skin_vars ?? null;
$this->module_config = ModuleModel::getInstance()->getModuleConfig($this->module, $module_info->site_srl);
// Set privileges(granted) information
if($this->setPrivileges() !== true)
{
$this->stop('msg_not_permitted');
return;
}
// Set admin layout
if(preg_match('/^disp[A-Z][a-z0-9\_]+Admin/', $this->act))
{
@ -219,7 +219,7 @@ class ModuleObject extends BaseObject
$oTemplate->compile('modules/admin/tpl', '_admin_common.html');
}
}
// Execute init
if(method_exists($this, 'init'))
{
@ -235,10 +235,10 @@ class ModuleObject extends BaseObject
return $this;
}
/**
* Set privileges(granted) information of current user and check permission of current module
*
*
* @return bool
*/
public function setPrivileges()
@ -253,7 +253,7 @@ class ModuleObject extends BaseObject
{
return false;
}
// If value is not array
if(!is_array($check_module_srl))
{
@ -267,7 +267,7 @@ class ModuleObject extends BaseObject
$check_module_srl = array($check_module_srl);
}
}
// Check permission by privileges(granted) information for target module
foreach($check_module_srl as $target_srl)
{
@ -276,7 +276,7 @@ class ModuleObject extends BaseObject
{
return false;
}
// Check permission
if(!$this->checkPermission($grant, $this->user))
{
@ -286,13 +286,13 @@ class ModuleObject extends BaseObject
}
}
}
// If no privileges(granted) information, check permission by privileges(granted) information for current module
if(!isset($grant))
{
// Get privileges(granted) information of current user for current module
$grant = ModuleModel::getInstance()->getGrant($this->module_info, $this->user, $this->xml_info);
// Check permission
if(!$this->checkPermission($grant, $this->user))
{
@ -300,23 +300,23 @@ class ModuleObject extends BaseObject
return false;
}
}
// If member action, grant access for log-in, sign-up, member pages
if(preg_match('/^(disp|proc)(Member|Communication)[A-Z][a-zA-Z]+$/', $this->act))
{
$grant->access = true;
}
// Set privileges(granted) variables
$this->grant = $grant;
Context::set('grant', $grant);
return true;
}
/**
* Check permission
*
*
* @param object $grant privileges(granted) information of user
* @param object $member_info member information
* @return bool
@ -328,28 +328,28 @@ class ModuleObject extends BaseObject
{
$member_info = $this->user;
}
// Get privileges(granted) information of the member for current module
if(!$grant)
{
$grant = ModuleModel::getGrant($this->module_info, $member_info, $this->xml_info);
}
// If an administrator, Pass
if($grant->root)
{
return true;
}
// Get permission types(guest, member, manager, root) of the currently requested action
$permission = $this->xml_info->action->{$this->act}->permission->target ?: ($this->xml_info->permission->{$this->act} ?? null);
// If admin action, set default permission
if(empty($permission) && stripos($this->act, 'admin') !== false)
{
$permission = 'root';
}
// If permission is not or 'guest', Pass
if(empty($permission) || $permission == 'guest')
{
@ -370,7 +370,7 @@ class ModuleObject extends BaseObject
{
return true;
}
// If permission is '*-managers', search modules to find manager privilege of the member
if(Context::get('is_logged') && isset($type[2]))
{
@ -401,7 +401,7 @@ class ModuleObject extends BaseObject
else if($grant_names = explode(',', $permission))
{
$privilege_list = array_keys((array) $this->xml_info->grant);
foreach($grant_names as $name)
{
if(!in_array($name, $privilege_list) || !$grant->$name)
@ -409,16 +409,16 @@ class ModuleObject extends BaseObject
return false;
}
}
return true;
}
return false;
}
/**
* Stop processing this module instance.
*
*
* @param string $msg_code an error code
* @return ModuleObject $this
*/
@ -428,33 +428,33 @@ class ModuleObject extends BaseObject
{
// flag setting to stop the proc processing
$this->stop_proc = true;
// Error handling
$this->setError(-1);
$this->setMessage($msg_code);
// Get backtrace
$backtrace = debug_backtrace(false);
$caller = array_shift($backtrace);
$location = $caller['file'] . ':' . $caller['line'];
// Error message display by message module
$oMessageObject = MessageView::getInstance();
$oMessageObject->setError(-1);
$oMessageObject->setMessage($msg_code);
$oMessageObject->dispMessage('', $location);
$this->setTemplatePath($oMessageObject->getTemplatePath());
$this->setTemplateFile($oMessageObject->getTemplateFile());
$this->setHttpStatusCode($oMessageObject->getHttpStatusCode());
}
return $this;
}
/**
* set the file name of the template file
*
*
* @param string name of file
* @return $this
*/
@ -470,7 +470,7 @@ class ModuleObject extends BaseObject
/**
* retrieve the directory path of the template directory
*
*
* @return string
*/
public function getTemplateFile()
@ -480,7 +480,7 @@ class ModuleObject extends BaseObject
/**
* set the directory path of the template directory
*
*
* @param string path of template directory.
* @return $this
*/
@ -501,7 +501,7 @@ class ModuleObject extends BaseObject
/**
* retrieve the directory path of the template directory
*
*
* @return string
*/
public function getTemplatePath()
@ -511,7 +511,7 @@ class ModuleObject extends BaseObject
/**
* set the file name of the temporarily modified by admin
*
*
* @param string name of file
* @return $this
*/
@ -529,7 +529,7 @@ class ModuleObject extends BaseObject
/**
* retreived the file name of edited_layout_file
*
*
* @return string
*/
public function getEditedLayoutFile()
@ -539,7 +539,7 @@ class ModuleObject extends BaseObject
/**
* set the file name of the layout file
*
*
* @param string name of file
* @return $this
*/
@ -555,7 +555,7 @@ class ModuleObject extends BaseObject
/**
* get the file name of the layout file
*
*
* @return string
*/
public function getLayoutFile()
@ -565,7 +565,7 @@ class ModuleObject extends BaseObject
/**
* set the directory path of the layout directory
*
*
* @param string path of layout directory.
* @return $this
*/
@ -586,7 +586,7 @@ class ModuleObject extends BaseObject
/**
* set the directory path of the layout directory
*
*
* @return string
*/
public function getLayoutPath($layout_name = "", $layout_type = "P")
@ -605,7 +605,7 @@ class ModuleObject extends BaseObject
{
return FALSE;
}
// Check mobile status
$is_mobile = Mobile::isFromMobilePhone();
@ -623,7 +623,7 @@ class ModuleObject extends BaseObject
$oAddonController = AddonController::getInstance();
$addon_file = $oAddonController->getCacheFilePath($is_mobile ? "mobile" : "pc");
if(FileHandler::exists($addon_file)) include($addon_file);
// Check mobile status again, in case a trigger changed it
$is_mobile = Mobile::isFromMobilePhone();
@ -636,7 +636,7 @@ class ModuleObject extends BaseObject
$this->stop("msg_not_permitted_act");
return FALSE;
}
// Set module skin
if(isset($this->module_info->skin) && $this->module_info->module === $this->module && strpos($this->act, 'Admin') === false)
{
@ -645,7 +645,7 @@ class ModuleObject extends BaseObject
$skin_dir = $is_mobile ? 'm.skins' : 'skins';
$module_skin = $this->module_info->{$skin_key} ?: '/USE_DEFAULT/';
$use_default_skin = $this->module_info->{'is_' . $skin_key . '_fix'} === 'N';
// Set default skin
if(!$this->getTemplatePath() || $use_default_skin)
{
@ -669,12 +669,12 @@ class ModuleObject extends BaseObject
}
$this->setTemplatePath(sprintf('%s%s/%s', $this->module_path, $skin_dir, $module_skin));
}
// Set skin variable
ModuleModel::syncSkinInfoToModuleInfo($this->module_info);
Context::set('module_info', $this->module_info);
}
// Run
try
{
@ -756,10 +756,10 @@ class ModuleObject extends BaseObject
}
return TRUE;
}
/**
* Copy the response of another ModuleObject into this instance.
*
*
* @param self $instance
* @return void
*/
@ -769,14 +769,14 @@ class ModuleObject extends BaseObject
$this->error = $instance->getError();
$this->message = $instance->getMessage();
$this->httpStatusCode = $instance->getHttpStatusCode();
// Copy template settings.
$this->setTemplatePath($instance->getTemplatePath());
$this->setTemplateFile($instance->getTemplateFile());
$this->setLayoutPath($instance->getLayoutPath());
$this->setLayoutFile($instance->getLayoutFile());
$this->setEditedLayoutFile($instance->getEditedLayoutFile());
// Copy all other variables: redirect URL, message type, etc.
foreach ($instance->getVariables() as $key => $val)
{