Replace some usages of getModel(), getController(), etc. with getInstance()

This commit is contained in:
Kijin Sung 2020-05-18 21:45:44 +09:00
parent 6f9bfb0bac
commit 052930a6d4
4 changed files with 31 additions and 31 deletions

View file

@ -266,7 +266,7 @@ class Context
define('RX_BASEURL', parse_url($default_url, PHP_URL_PATH)); define('RX_BASEURL', parse_url($default_url, PHP_URL_PATH));
} }
} }
$oModuleModel = getModel('module'); $oModuleModel = ModuleModel::getInstance();
$site_module_info = $oModuleModel->getDefaultMid() ?: new stdClass; $site_module_info = $oModuleModel->getDefaultMid() ?: new stdClass;
self::set('site_module_info', $site_module_info); self::set('site_module_info', $site_module_info);
self::set('_default_timezone', ($site_module_info->settings && $site_module_info->settings->timezone) ? $site_module_info->settings->timezone : null); self::set('_default_timezone', ($site_module_info->settings && $site_module_info->settings->timezone) ? $site_module_info->settings->timezone : null);
@ -358,8 +358,8 @@ class Context
// set session handler // set session handler
if(self::isInstalled() && config('session.use_db')) if(self::isInstalled() && config('session.use_db'))
{ {
$oSessionModel = getModel('session'); $oSessionModel = SessionModel::getInstance();
$oSessionController = getController('session'); $oSessionController = SessionController::getInstance();
ini_set('session.serialize_handler', 'php'); ini_set('session.serialize_handler', 'php');
session_set_save_handler( session_set_save_handler(
array(&$oSessionController, 'open'), array(&$oSessionController, 'close'), array(&$oSessionModel, 'read'), array(&$oSessionController, 'write'), array(&$oSessionController, 'destroy'), array(&$oSessionController, 'gc') array(&$oSessionController, 'open'), array(&$oSessionController, 'close'), array(&$oSessionModel, 'read'), array(&$oSessionController, 'write'), array(&$oSessionController, 'destroy'), array(&$oSessionController, 'gc')
@ -380,12 +380,11 @@ class Context
// set authentication information in Context and session // set authentication information in Context and session
if (self::isInstalled()) if (self::isInstalled())
{ {
$oModuleModel = getModel('module');
$oModuleModel->loadModuleExtends(); $oModuleModel->loadModuleExtends();
if (Rhymix\Framework\Session::getMemberSrl()) if (Rhymix\Framework\Session::getMemberSrl())
{ {
getController('member')->setSessionInfo(); MemberController::getInstance()->setSessionInfo();
} }
else else
{ {
@ -803,7 +802,7 @@ class Context
{ {
return ''; return '';
} }
getController('module')->replaceDefinedLangCode(self::$_instance->browser_title); ModuleController::getInstance()->replaceDefinedLangCode(self::$_instance->browser_title);
return htmlspecialchars(self::$_instance->browser_title, ENT_QUOTES, 'UTF-8', FALSE); return htmlspecialchars(self::$_instance->browser_title, ENT_QUOTES, 'UTF-8', FALSE);
} }
@ -818,7 +817,7 @@ class Context
if ($domain_info && $domain_info->settings && $domain_info->settings->title) if ($domain_info && $domain_info->settings && $domain_info->settings->title)
{ {
$title = trim($domain_info->settings->title); $title = trim($domain_info->settings->title);
getController('module')->replaceDefinedLangCode($title); ModuleController::getInstance()->replaceDefinedLangCode($title);
return $title; return $title;
} }
else else
@ -838,7 +837,7 @@ class Context
if ($domain_info && $domain_info->settings && $domain_info->settings->subtitle) if ($domain_info && $domain_info->settings && $domain_info->settings->subtitle)
{ {
$subtitle = trim($domain_info->settings->subtitle); $subtitle = trim($domain_info->settings->subtitle);
getController('module')->replaceDefinedLangCode($subtitle); ModuleController::getInstance()->replaceDefinedLangCode($subtitle);
return $subtitle; return $subtitle;
} }
else else
@ -1863,7 +1862,7 @@ class Context
{ {
if (!isset($domain_infos[$domain])) if (!isset($domain_infos[$domain]))
{ {
$domain_infos[$domain] = getModel('module')->getSiteInfoByDomain($domain); $domain_infos[$domain] = ModuleModel::getInstance()->getSiteInfoByDomain($domain);
} }
$site_module_info = $domain_infos[$domain] ?: $site_module_info; $site_module_info = $domain_infos[$domain] ?: $site_module_info;
} }
@ -2744,7 +2743,7 @@ class Context
*/ */
public static function addMetaTag($name, $content, $is_http_equiv = false) public static function addMetaTag($name, $content, $is_http_equiv = false)
{ {
getController('module')->replaceDefinedLangCode($content); ModuleController::getInstance()->replaceDefinedLangCode($content);
self::$_instance->meta_tags[$name] = array('is_http_equiv' => (bool)$is_http_equiv, 'content' => $content); self::$_instance->meta_tags[$name] = array('is_http_equiv' => (bool)$is_http_equiv, 'content' => $content);
} }

View file

@ -82,7 +82,7 @@ class DisplayHandler extends Handler
// execute add-on // execute add-on
$called_position = 'before_display_content'; $called_position = 'before_display_content';
$oAddonController = getController('addon'); $oAddonController = AddonController::getInstance();
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
if(file_exists($addon_file)) include($addon_file); if(file_exists($addon_file)) include($addon_file);
if($output === false || $output === null || $output instanceof BaseObject) if($output === false || $output === null || $output instanceof BaseObject)

View file

@ -135,7 +135,7 @@ class ModuleHandler extends Handler
// execute addon (before module initialization) // execute addon (before module initialization)
$called_position = 'before_module_init'; $called_position = 'before_module_init';
$oAddonController = getController('addon'); $oAddonController = AddonController::getInstance();
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? 'mobile' : 'pc'); $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? 'mobile' : 'pc');
if(file_exists($addon_file)) include($addon_file); if(file_exists($addon_file)) include($addon_file);
} }
@ -146,13 +146,13 @@ class ModuleHandler extends Handler
* */ * */
public function init() public function init()
{ {
$oModuleModel = getModel('module'); $oModuleModel = ModuleModel::getInstance();
$site_module_info = Context::get('site_module_info'); $site_module_info = Context::get('site_module_info');
// Check unregistered domain action. // Check unregistered domain action.
if (!$site_module_info || !isset($site_module_info->domain_srl) || $site_module_info->is_default_replaced) if (!$site_module_info || !isset($site_module_info->domain_srl) || $site_module_info->is_default_replaced)
{ {
$site_module_info = getModel('module')->getDefaultDomainInfo(); $site_module_info = $oModuleModel->getDefaultDomainInfo();
if ($site_module_info) if ($site_module_info)
{ {
$domain_action = config('url.unregistered_domain_action') ?: 'redirect_301'; $domain_action = config('url.unregistered_domain_action') ?: 'redirect_301';
@ -208,7 +208,7 @@ class ModuleHandler extends Handler
// Convert document alias (entry) to document_srl // Convert document alias (entry) to document_srl
if(!$this->document_srl && $this->mid && $this->entry) if(!$this->document_srl && $this->mid && $this->entry)
{ {
$oDocumentModel = getModel('document'); $oDocumentModel = DocumentModel::getInstance();
$this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry); $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry);
if($this->document_srl) if($this->document_srl)
{ {
@ -248,7 +248,7 @@ class ModuleHandler extends Handler
// Block access to secret or temporary documents. // Block access to secret or temporary documents.
if(Context::getRequestMethod() == 'GET') if(Context::getRequestMethod() == 'GET')
{ {
$oDocumentModel = getModel('document'); $oDocumentModel = DocumentModel::getInstance();
$oDocument = $oDocumentModel->getDocument($this->document_srl); $oDocument = $oDocumentModel->getDocument($this->document_srl);
if($oDocument->isExists() && !$oDocument->isAccessible()) if($oDocument->isExists() && !$oDocument->isAccessible())
{ {
@ -304,7 +304,7 @@ class ModuleHandler extends Handler
$seo_title = config('seo.subpage_title') ?: '$SITE_TITLE - $SUBPAGE_TITLE'; $seo_title = config('seo.subpage_title') ?: '$SITE_TITLE - $SUBPAGE_TITLE';
} }
getController('module')->replaceDefinedLangCode($seo_title); ModuleController::getInstance()->replaceDefinedLangCode($seo_title);
Context::setBrowserTitle($seo_title, array( Context::setBrowserTitle($seo_title, array(
'site_title' => Context::getSiteTitle(), 'site_title' => Context::getSiteTitle(),
'site_subtitle' => Context::getSiteSubtitle(), 'site_subtitle' => Context::getSiteSubtitle(),
@ -415,7 +415,7 @@ class ModuleHandler extends Handler
* */ * */
public function procModule() public function procModule()
{ {
$oModuleModel = getModel('module'); $oModuleModel = ModuleModel::getInstance();
$display_mode = Mobile::isFromMobilePhone() ? 'mobile' : 'view'; $display_mode = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
// If error occurred while preparation, return a message instance // If error occurred while preparation, return a message instance
@ -1061,14 +1061,14 @@ class ModuleHandler extends Handler
// if layout_srl is rollback by module, set default layout // if layout_srl is rollback by module, set default layout
if($layout_srl == -1) if($layout_srl == -1)
{ {
$oLayoutAdminModel = getAdminModel('layout'); $oLayoutAdminModel = LayoutAdminModel::getInstance();
$layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl); $layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl);
} }
if($layout_srl && !$oModule->getLayoutFile()) if($layout_srl && !$oModule->getLayoutFile())
{ {
// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file // If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
$oLayoutModel = getModel('layout'); $oLayoutModel = LayoutModel::getInstance();
$layout_info = $oLayoutModel->getLayout($layout_srl); $layout_info = $oLayoutModel->getLayout($layout_srl);
if($layout_info) if($layout_info)
{ {
@ -1234,7 +1234,7 @@ class ModuleHandler extends Handler
return new BaseObject(); return new BaseObject();
} }
$oModuleModel = getModel('module'); $oModuleModel = ModuleModel::getInstance();
$triggers = $oModuleModel->getTriggers($trigger_name, $called_position); $triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
if(!$triggers) if(!$triggers)
{ {

View file

@ -201,7 +201,7 @@ class ModuleObject extends BaseObject
$this->origin_module_info = $module_info; $this->origin_module_info = $module_info;
$this->xml_info = $xml_info; $this->xml_info = $xml_info;
$this->skin_vars = $module_info->skin_vars; $this->skin_vars = $module_info->skin_vars;
$this->module_config = getModel('module')->getModuleConfig($this->module, $module_info->site_srl); $this->module_config = ModuleModel::getInstance()->getModuleConfig($this->module, $module_info->site_srl);
// Set privileges(granted) information // Set privileges(granted) information
if($this->setPrivileges() !== true) if($this->setPrivileges() !== true)
@ -277,7 +277,7 @@ class ModuleObject extends BaseObject
foreach($check_module_srl as $target_srl) foreach($check_module_srl as $target_srl)
{ {
// Get privileges(granted) information of current user for target module // Get privileges(granted) information of current user for target module
if(($grant = getModel('module')->getPrivilegesBySrl($target_srl, $permission_check->type)) === false) if(($grant = ModuleModel::getInstance()->getPrivilegesBySrl($target_srl, $permission_check->type)) === false)
{ {
return false; return false;
} }
@ -296,7 +296,7 @@ class ModuleObject extends BaseObject
if(!isset($grant)) if(!isset($grant))
{ {
// Get privileges(granted) information of current user for current module // Get privileges(granted) information of current user for current module
$grant = getModel('module')->getGrant($this->module_info, Context::get('logged_info'), $this->xml_info); $grant = ModuleModel::getInstance()->getGrant($this->module_info, Context::get('logged_info'), $this->xml_info);
// Check permission // Check permission
if($this->checkPermission($grant) !== true) if($this->checkPermission($grant) !== true)
@ -335,9 +335,10 @@ class ModuleObject extends BaseObject
} }
// Get privileges(granted) information of the member for current module // Get privileges(granted) information of the member for current module
$oModuleModel = ModuleModel::getInstance();
if(!$grant) if(!$grant)
{ {
$grant = getModel('module')->getGrant($this->module_info, $member_info, $this->xml_info); $grant = $oModuleModel->getGrant($this->module_info, $member_info, $this->xml_info);
} }
// If an administrator, Pass // If an administrator, Pass
@ -380,17 +381,17 @@ class ModuleObject extends BaseObject
if(Context::get('is_logged') && isset($type[2])) if(Context::get('is_logged') && isset($type[2]))
{ {
// Manager privilege of the member is found by search all modules, Pass // Manager privilege of the member is found by search all modules, Pass
if($type[2] == 'all' && getModel('module')->findManagerPrivilege($member_info) !== false) if($type[2] == 'all' && $oModuleModel->findManagerPrivilege($member_info) !== false)
{ {
return true; return true;
} }
// Manager privilege of the member is found by search same module as this module, Pass // Manager privilege of the member is found by search same module as this module, Pass
else if($type[2] == 'same' && getModel('module')->findManagerPrivilege($member_info, $this->module) !== false) elseif($type[2] == 'same' && $oModuleModel->findManagerPrivilege($member_info, $this->module) !== false)
{ {
return true; return true;
} }
// Manager privilege of the member is found by search same module as the module, Pass // Manager privilege of the member is found by search same module as the module, Pass
else if(getModel('module')->findManagerPrivilege($member_info, $type[2]) !== false) elseif($oModuleModel->findManagerPrivilege($member_info, $type[2]) !== false)
{ {
return true; return true;
} }
@ -629,7 +630,7 @@ class ModuleObject extends BaseObject
// execute an addon(call called_position as before_module_proc) // execute an addon(call called_position as before_module_proc)
$called_position = 'before_module_proc'; $called_position = 'before_module_proc';
$oAddonController = getController('addon'); $oAddonController = AddonController::getInstance();
$addon_file = $oAddonController->getCacheFilePath($is_mobile ? "mobile" : "pc"); $addon_file = $oAddonController->getCacheFilePath($is_mobile ? "mobile" : "pc");
if(FileHandler::exists($addon_file)) include($addon_file); if(FileHandler::exists($addon_file)) include($addon_file);
@ -649,7 +650,7 @@ class ModuleObject extends BaseObject
// Set module skin // Set module skin
if(isset($this->module_info->skin) && $this->module_info->module === $this->module && strpos($this->act, 'Admin') === false) if(isset($this->module_info->skin) && $this->module_info->module === $this->module && strpos($this->act, 'Admin') === false)
{ {
$oModuleModel = getModel('module'); $oModuleModel = ModuleModel::getInstance();
$skin_type = $is_mobile ? 'M' : 'P'; $skin_type = $is_mobile ? 'M' : 'P';
$skin_key = $is_mobile ? 'mskin' : 'skin'; $skin_key = $is_mobile ? 'mskin' : 'skin';
$skin_dir = $is_mobile ? 'm.skins' : 'skins'; $skin_dir = $is_mobile ? 'm.skins' : 'skins';
@ -733,7 +734,7 @@ class ModuleObject extends BaseObject
// execute an addon(call called_position as after_module_proc) // execute an addon(call called_position as after_module_proc)
$called_position = 'after_module_proc'; $called_position = 'after_module_proc';
$oAddonController = getController('addon'); $oAddonController = AddonController::getInstance();
$addon_file = $oAddonController->getCacheFilePath($is_mobile ? "mobile" : "pc"); $addon_file = $oAddonController->getCacheFilePath($is_mobile ? "mobile" : "pc");
if(FileHandler::exists($addon_file)) include($addon_file); if(FileHandler::exists($addon_file)) include($addon_file);