本文整理汇总了PHP中ModuleHandler::getModuleInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleHandler::getModuleInstance方法的具体用法?PHP ModuleHandler::getModuleInstance怎么用?PHP ModuleHandler::getModuleInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleHandler
的用法示例。
在下文中一共展示了ModuleHandler::getModuleInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispBoardMessage
function dispBoardMessage($msg_code)
{
$msg = Context::getLang($msg_code);
$oMessageObject =& ModuleHandler::getModuleInstance('message', 'mobile');
$oMessageObject->setError(-1);
$oMessageObject->setMessage($msg);
$oMessageObject->dispMessage();
$this->setTemplatePath($oMessageObject->getTemplatePath());
$this->setTemplateFile($oMessageObject->getTemplateFile());
}
示例2: IS
/**
* Search Result
*
* @return Object
*/
function IS()
{
$oFile = getClass('file');
$oModuleModel = getModel('module');
$logged_info = Context::get('logged_info');
// Check permissions
if (!$this->grant->access) {
return new Object(-1, 'msg_not_permitted');
}
$config = $oModuleModel->getModuleConfig('integration_search');
if (!$config) {
$config = new stdClass();
}
if (!$config->skin) {
$config->skin = 'default';
$template_path = sprintf('%sskins/%s', $this->module_path, $config->skin);
} else {
//check theme
$config_parse = explode('|@|', $config->skin);
if (count($config_parse) > 1) {
$template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]);
} else {
$template_path = sprintf('%sskins/%s', $this->module_path, $config->skin);
}
}
// Template path
$this->setTemplatePath($template_path);
$skin_vars = $config->skin_vars ? unserialize($config->skin_vars) : new stdClass();
Context::set('module_info', $skin_vars);
$target = $config->target;
if (!$target) {
$target = 'include';
}
if (empty($config->target_module_srl)) {
$module_srl_list = array();
} else {
$module_srl_list = explode(',', $config->target_module_srl);
}
// https://github.com/xpressengine/xe-core/issues/1522
// 검색 대상을 지정하지 않았을 때 검색 제한
if ($target === 'include' && !count($module_srl_list)) {
$oMessageObject = ModuleHandler::getModuleInstance('message');
$oMessageObject->setError(-1);
$oMessageObject->setMessage('msg_not_enabled');
$oMessageObject->dispMessage();
$this->setTemplatePath($oMessageObject->getTemplatePath());
$this->setTemplateFile($oMessageObject->getTemplateFile());
return;
}
// Set a variable for search keyword
$is_keyword = Context::get('is_keyword');
// Set page variables
$page = (int) Context::get('page');
if (!$page) {
$page = 1;
}
// Search by search tab
$where = Context::get('where');
// Create integration search model object
if ($is_keyword) {
$oIS = getModel('integration_search');
switch ($where) {
case 'document':
$search_target = Context::get('search_target');
if (!in_array($search_target, array('title', 'content', 'title_content', 'tag'))) {
$search_target = 'title';
}
Context::set('search_target', $search_target);
$output = $oIS->getDocuments($target, $module_srl_list, $search_target, $is_keyword, $page, 10);
Context::set('output', $output);
$this->setTemplateFile("document", $page);
break;
case 'comment':
$output = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 10);
Context::set('output', $output);
$this->setTemplateFile("comment", $page);
break;
case 'trackback':
$search_target = Context::get('search_target');
if (!in_array($search_target, array('title', 'url', 'blog_name', 'excerpt'))) {
$search_target = 'title';
}
Context::set('search_target', $search_target);
$output = $oIS->getTrackbacks($target, $module_srl_list, $search_target, $is_keyword, $page, 10);
Context::set('output', $output);
$this->setTemplateFile("trackback", $page);
break;
case 'multimedia':
$output = $oIS->getImages($target, $module_srl_list, $is_keyword, $page, 20);
Context::set('output', $output);
$this->setTemplateFile("multimedia", $page);
break;
case 'file':
$output = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 20);
Context::set('output', $output);
//.........这里部分代码省略.........
示例3: stop
/**
* set the stop_proc and approprate message for msg_code
* @param string $msg_code an error code
* @return ModuleObject $this
* */
function stop($msg_code)
{
// flag setting to stop the proc processing
$this->stop_proc = TRUE;
// Error handling
$this->setError(-1);
$this->setMessage($msg_code);
// Error message display by message module
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($msg_code);
$oMessageObject->dispMessage();
$this->setTemplatePath($oMessageObject->getTemplatePath());
$this->setTemplateFile($oMessageObject->getTemplateFile());
return $this;
}
示例4: getModule
/**
* Define a function to use {@see ModuleHandler::getModuleObject()} ($module_name, $type)
*
* @param string $module_name The module name to get a instance
* @param string $type disp, proc, controller, class
* @param string $kind admin, null
* @return mixed Module instance
*/
function getModule($module_name, $type = 'view', $kind = '')
{
return ModuleHandler::getModuleInstance($module_name, $type, $kind);
}
示例5: displayContent
/**
* display contents from executed module
* @param ModuleObject $oModule module instance
* @return void
**/
function displayContent($oModule = NULL)
{
// If the module is not set or not an object, set error
if (!$oModule || !is_object($oModule)) {
$this->error = 'msg_module_is_not_exists';
$this->httpStatusCode = '404';
}
// If connection to DB has a problem even though it's not install module, set error
if ($this->module != 'install' && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == false) {
$this->error = 'msg_dbconnect_failed';
}
// Call trigger after moduleHandler proc
$output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
if (!$output->toBool()) {
$this->error = $output->getMessage();
}
// Use message view object, if HTML call
$methodList = array('XMLRPC' => 1, 'JSON' => 1);
if (!isset($methodList[Context::getRequestMethod()])) {
if ($_SESSION['XE_VALIDATOR_RETURN_URL']) {
$display_handler = new DisplayHandler();
$display_handler->_debugOutput();
header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
return;
}
// If error occurred, handle it
if ($this->error) {
// display content with message module instance
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject =& ModuleHandler::getModuleInstance('message', $type);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
if ($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200') {
$this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode());
$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) {
$oModule->setTemplatePath($oMessageObject->getTemplatePath());
$oModule->setTemplateFile($oMessageObject->getTemplateFile());
// Otherwise, set message instance as the target module
} else {
$oModule = $oMessageObject;
}
$this->_clearErrorSession();
}
// Check if layout_srl exists for the module
if (Mobile::isFromMobilePhone()) {
$layout_srl = $oModule->module_info->mlayout_srl;
} else {
$layout_srl = $oModule->module_info->layout_srl;
}
if ($layout_srl && !$oModule->getLayoutFile()) {
// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
$oLayoutModel =& getModel('layout');
$layout_info = $oLayoutModel->getLayout($layout_srl);
if ($layout_info) {
// Input extra_vars into $layout_info
if ($layout_info->extra_var_count) {
foreach ($layout_info->extra_var as $var_id => $val) {
if ($val->type == 'image') {
if (preg_match('/^\\.\\/files\\/attach\\/images\\/(.+)/i', $val->value)) {
$val->value = Context::getRequestUri() . substr($val->value, 2);
}
}
$layout_info->{$var_id} = $val->value;
}
}
// Set menus into context
if ($layout_info->menu_count) {
foreach ($layout_info->menu as $menu_id => $menu) {
if (file_exists($menu->php_file)) {
@(include $menu->php_file);
}
Context::set($menu_id, $menu);
}
}
// Set layout information into context
Context::set('layout_info', $layout_info);
$oModule->setLayoutPath($layout_info->path);
$oModule->setLayoutFile('layout');
// If layout was modified, use the modified version
$edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
if (file_exists($edited_layout)) {
$oModule->setEditedLayoutFile($edited_layout);
}
}
}
}
// Display contents
$oDisplayHandler = new DisplayHandler();
$oDisplayHandler->printContent($oModule);
}
示例6: displayContent
/**
* display contents from executed module
* @param ModuleObject $oModule module instance
* @return void
* */
function displayContent($oModule = NULL)
{
// If the module is not set or not an object, set error
if (!$oModule || !is_object($oModule)) {
$this->error = 'msg_module_is_not_exists';
$this->httpStatusCode = '404';
}
// If connection to DB has a problem even though it's not install module, set error
if ($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE) {
$this->error = 'msg_dbconnect_failed';
}
// Call trigger after moduleHandler proc
$output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
if (!$output->toBool()) {
$this->error = $output->getMessage();
}
// Use message view object, if HTML call
$methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
if (!isset($methodList[Context::getRequestMethod()])) {
if ($_SESSION['XE_VALIDATOR_RETURN_URL']) {
$display_handler = new DisplayHandler();
$display_handler->_debugOutput();
header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
return;
}
// If error occurred, handle it
if ($this->error) {
// display content with message module instance
$type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
$oMessageObject = ModuleHandler::getModuleInstance('message', $type);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
if ($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200') {
$this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode());
$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) {
$oModule->setTemplatePath($oMessageObject->getTemplatePath());
$oModule->setTemplateFile($oMessageObject->getTemplateFile());
// Otherwise, set message instance as the target module
} else {
$oModule = $oMessageObject;
}
$this->_clearErrorSession();
}
// Check if layout_srl exists for the module
if (Mobile::isFromMobilePhone()) {
$layout_srl = $oModule->module_info->mlayout_srl;
} else {
$layout_srl = $oModule->module_info->layout_srl;
}
// if layout_srl is rollback by module, set default layout
if ($layout_srl == -1) {
$viewType = Mobile::isFromMobilePhone() ? 'M' : 'P';
$oLayoutAdminModel = getAdminModel('layout');
$layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl);
}
if ($layout_srl && !$oModule->getLayoutFile()) {
// If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
$oLayoutModel = getModel('layout');
$layout_info = $oLayoutModel->getLayout($layout_srl);
if ($layout_info) {
// Input extra_vars into $layout_info
if ($layout_info->extra_var_count) {
foreach ($layout_info->extra_var as $var_id => $val) {
if ($val->type == 'image') {
if (strncmp('./files/attach/images/', $val->value, 22) === 0) {
$val->value = Context::getRequestUri() . substr($val->value, 2);
}
}
$layout_info->{$var_id} = $val->value;
}
}
// Set menus into context
if ($layout_info->menu_count) {
foreach ($layout_info->menu as $menu_id => $menu) {
// set default menu set(included home menu)
if (!$menu->menu_srl || $menu->menu_srl == -1) {
$oMenuAdminController = getAdminController('menu');
$homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();
if (FileHandler::exists($homeMenuCacheFile)) {
include $homeMenuCacheFile;
}
if (!$menu->menu_srl) {
$menu->xml_file = str_replace('.xml.php', $homeMenuSrl . '.xml.php', $menu->xml_file);
$menu->php_file = str_replace('.php', $homeMenuSrl . '.php', $menu->php_file);
$layout_info->menu->{$menu_id}->menu_srl = $homeMenuSrl;
} else {
$menu->xml_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->xml_file);
$menu->php_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->php_file);
}
}
$php_file = FileHandler::exists($menu->php_file);
//.........这里部分代码省略.........
示例7: procModule
/**
* get a module instance and execute an action
* @return ModuleObject executed module instance
* */
public function procModule()
{
$oModuleModel = getModel('module');
$display_mode = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
// If error occurred while preparation, return a message instance
if ($this->error) {
self::_setInputErrorToContext();
$oMessageObject = self::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
if ($this->httpStatusCode) {
$oMessageObject->setHttpStatusCode($this->httpStatusCode);
}
return $oMessageObject;
}
// Get action information with conf/module.xml
$xml_info = $oModuleModel->getModuleActionXml($this->module);
// If not installed yet, modify act
if ($this->module == "install") {
if (!$this->act || !$xml_info->action->{$this->act}) {
$this->act = $xml_info->default_index_act;
}
}
// if act exists, find type of the action, if not use default index act
if (!$this->act) {
$this->act = $xml_info->default_index_act;
}
// still no act means error
if (!$this->act) {
$this->error = 'msg_module_is_not_exists';
$this->httpStatusCode = '404';
self::_setInputErrorToContext();
$oMessageObject = self::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
if ($this->httpStatusCode) {
$oMessageObject->setHttpStatusCode($this->httpStatusCode);
}
return $oMessageObject;
}
// get type, kind
$type = $xml_info->action->{$this->act}->type;
$ruleset = $xml_info->action->{$this->act}->ruleset;
$kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : '';
if (!$kind && $this->module == 'admin') {
$kind = 'admin';
}
// check REQUEST_METHOD in controller
if ($type == 'controller') {
$allowedMethod = $xml_info->action->{$this->act}->method;
if (!$allowedMethod) {
$allowedMethodList[0] = 'POST';
} else {
$allowedMethodList = explode('|', strtoupper($allowedMethod));
}
if (!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList)) {
$this->error = "msg_invalid_request";
$oMessageObject = self::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
return $oMessageObject;
}
}
// check CSRF for POST actions
if (Context::getRequestMethod() === 'POST' && Context::isInstalled()) {
if ($xml_info->action->{$this->act} && $xml_info->action->{$this->act}->check_csrf !== 'false' && !checkCSRF()) {
$this->_setInputErrorToContext();
$this->error = 'msg_invalid_request';
$oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
return $oMessageObject;
}
}
if ($this->module_info->use_mobile != "Y") {
Mobile::setMobile(FALSE);
}
$logged_info = Context::get('logged_info');
// Admin ip
if ($kind == 'admin' && $_SESSION['denied_admin'] == 'Y') {
self::_setInputErrorToContext();
$this->error = "msg_not_permitted_act";
$oMessageObject = self::getModuleInstance('message', $display_mode);
$oMessageObject->setError(-1);
$oMessageObject->setMessage($this->error);
$oMessageObject->dispMessage();
return $oMessageObject;
}
// if(type == view, and case for using mobilephone)
if ($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled()) {
$orig_type = "view";
$type = "mobile";
//.........这里部分代码省略.........