/** * 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); }
/** * @ 실행된 모듈의 컨텐츠를 출력 **/ function displayContent($oModule = NULL) { // 설정된 모듈이 정상이지 않을 경우 message 모듈 객체 생성 if (!$oModule || !is_object($oModule)) { $this->error = 'msg_module_is_not_exists'; } // install 모듈이 아닐 때 DB 접속에 문제가 있으면 오류 if ($this->module != 'install' && $GLOBALS['__DB__'][Context::getDBType()]->is_connected == false) { $this->error = 'msg_dbconnect_failed'; } // 모듈 동작을 마친 후 trigger call $output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule); if (!$output->toBool()) { $this->error = $output->getMessage(); } // HTML call 이면 message view 객체 이용하도록 if (!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON'))) { // 에러가 발생하였을시 처리 if ($this->error) { // message 모듈 객체를 생성해서 컨텐츠 생성 $oMessageView =& getView('message'); $oMessageView->setError(-1); $oMessageView->setMessage($this->error); $oMessageView->dispMessage(); // 정상적으로 호출된 객체가 있을 경우 해당 객체의 template를 변경 if ($oModule) { $oModule->setTemplatePath($oMessageView->getTemplatePath()); $oModule->setTemplateFile($oMessageView->getTemplateFile()); // 그렇지 않으면 message 객체를 호출된 객체로 지정 } else { $oModule = $oMessageView; } } // 해당 모듈에 layout_srl이 있는지 확인 if ($oModule->module_info->layout_srl && !$oModule->getLayoutFile()) { // layout_srl이 있으면 해당 레이아웃 정보를 가져와 layout_path/ layout_file 위치 변경 $oLayoutModel =& getModel('layout'); $layout_info = $oLayoutModel->getLayout($oModule->module_info->layout_srl); if ($layout_info) { // 레이아웃 정보중 extra_vars의 이름과 값을 $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; } } // 레이아웃 정보중 menu를 Context::set 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); } } // 레이아웃 정보를 Context::set Context::set('layout_info', $layout_info); $oModule->setLayoutPath($layout_info->path); $oModule->setLayoutFile('layout'); // 레이아웃이 수정되었을 경우 수정본을 지정 $edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl); if (file_exists($edited_layout)) { $oModule->setEditedLayoutFile($edited_layout); } } } } // 컨텐츠 출력 $oDisplayHandler = new DisplayHandler(); $oDisplayHandler->printContent($oModule); }
/** * 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); if ($php_file) { include $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); } } } $isLayoutDrop = Context::get('isLayoutDrop'); if ($isLayoutDrop) { $kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : ''; if ($kind == 'admin') { $oModule->setLayoutFile('popup_layout'); } else { $oModule->setLayoutPath('common/tpl'); $oModule->setLayoutFile('default_layout'); } } } // Display contents $oDisplayHandler = new DisplayHandler(); $oDisplayHandler->printContent($oModule); }