/** * @brief display the board conent view **/ function dispBoardContentView() { // get the variable value $document_srl = Context::get('document_srl'); $page = Context::get('page'); // generate document model object $oDocumentModel = getModel('document'); /** * if the document exists, then get the document information **/ if ($document_srl) { $oDocument = $oDocumentModel->getDocument($document_srl, false, true); // if the document is existed if ($oDocument->isExists()) { // if the module srl is not consistent if ($oDocument->get('module_srl') != $this->module_info->module_srl) { return $this->stop('msg_invalid_request'); } // check the manage grant if ($this->grant->manager) { $oDocument->setGrant(); } // if the consultation function is enabled, and the document is not a notice if ($this->consultation && !$oDocument->isNotice()) { $logged_info = Context::get('logged_info'); if ($oDocument->get('member_srl') != $logged_info->member_srl) { $oDocument = $oDocumentModel->getDocument(0); } } // if the document is TEMP saved, check Grant if ($oDocument->getStatus() == 'TEMP') { if (!$oDocument->isGranted()) { $oDocument = $oDocumentModel->getDocument(0); } } } else { // if the document is not existed, then alert a warning message Context::set('document_srl', '', true); $this->alertMessage('msg_not_founded'); } /** * if the document is not existed, get an empty document **/ } else { $oDocument = $oDocumentModel->getDocument(0); } /** *check the document view grant **/ if ($oDocument->isExists()) { if (!$this->grant->view && !$oDocument->isGranted()) { $oDocument = $oDocumentModel->getDocument(0); Context::set('document_srl', '', true); $this->alertMessage('msg_not_permitted'); } else { // add the document title to the browser Context::setCanonicalURL($oDocument->getPermanentUrl()); $seo_title = config('seo.document_title') ?: '$SITE_TITLE - $DOCUMENT_TITLE'; getController('module')->replaceDefinedLangCode($seo_title); Context::setBrowserTitle($seo_title, array('site_title' => Context::getSiteTitle(), 'site_subtitle' => Context::getSiteSubtitle(), 'subpage_title' => $this->module_info->browser_title, 'document_title' => $oDocument->getTitleText(), 'page' => Context::get('page') ?: 1)); // update the document view count (if the document is not secret) if (!$oDocument->isSecret() || $oDocument->isGranted()) { $oDocument->updateReadedCount(); } // disappear the document if it is secret if ($oDocument->isSecret() && !$oDocument->isGranted()) { $oDocument->add('content', lang('thisissecret')); } } } Context::set('update_view', $this->grant->update_view); // setup the document oject on context $oDocument->add('module_srl', $this->module_srl); Context::set('oDocument', $oDocument); /** * add javascript filters **/ Context::addJsFilter($this->module_path . 'tpl/filter', 'insert_comment.xml'); // return new Object(); }
/** * Initialization. It finds the target module based on module, mid, document_srl, and prepares to execute an action * @return boolean true: OK, false: redirected * */ public function init() { $oModuleModel = getModel('module'); $site_module_info = Context::get('site_module_info'); // if success_return_url and error_return_url is incorrect $urls = array(Context::get('success_return_url'), Context::get('error_return_url')); foreach ($urls as $url) { if (empty($url)) { continue; } if ($host = parse_url($url, PHP_URL_HOST)) { $defaultHost = parse_url(Context::getDefaultUrl(), PHP_URL_HOST); if ($host !== $defaultHost) { $siteModuleHost = $site_module_info->domain; if (strpos($siteModuleHost, '/') !== false) { $siteModuleHost = parse_url($siteModuleHost, PHP_URL_HOST); } if ($host !== $siteModuleHost) { Context::set('success_return_url', null); Context::set('error_return_url', null); } } } } if (!$this->document_srl && $this->mid && $this->entry) { $oDocumentModel = getModel('document'); $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry); if ($this->document_srl) { Context::set('document_srl', $this->document_srl); } } // Get module's information based on document_srl, if it's specified if ($this->document_srl) { $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl); // If the document does not exist, remove document_srl if (!$module_info) { if (Context::getRequestMethod() == 'GET') { $this->error = 'The document does not exist'; $this->httpStatusCode = '404'; return true; } else { unset($this->document_srl); } } else { // If it exists, compare mid based on the module information // if mids are not matching, set it as the document's mid if (!$this->mid || $this->mid != $module_info->mid) { if (Context::getRequestMethod() == 'GET') { Context::setCacheControl(0); header('location: ' . getNotEncodedSiteUrl($site_module_info->domain, 'mid', $module_info->mid, 'document_srl', $this->document_srl), true, 301); return false; } else { $this->mid = $module_info->mid; Context::set('mid', $this->mid); } } // if requested module is different from one of the document, remove the module information retrieved based on the document number if ($this->module && $module_info->module != $this->module) { unset($module_info); } // if the secret document permission does not have, specify HTTP 403 if (Context::getRequestMethod() == 'GET') { $oDocumentModel = getModel('document'); $oDocument = $oDocumentModel->getDocument($this->document_srl); if ($oDocument->isSecret() || $oDocument->get('status') === $oDocumentModel->getConfigStatus('temp')) { if (!$oDocument->isGranted() && !$oDocument->isAccessible()) { $this->httpStatusCode = '403'; } } } } } // If module_info is not set yet, and there exists mid information, get module information based on the mid if (!$module_info && $this->mid) { $module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl); //if($this->module && $module_info->module != $this->module) unset($module_info); } // redirect, if module_site_srl and site_srl are different if (!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0) { Context::setCacheControl(0); $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl); header('location: ' . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid), true, 301); return false; } // If module_info is not set still, and $module does not exist, find the default module if (!$module_info && !$this->module && !$this->mid) { $module_info = $site_module_info; } if (!$module_info && !$this->module && $site_module_info->module_site_srl) { $module_info = $site_module_info; } // redirect, if site_srl of module_info is different from one of site's module_info if ($module_info && $module_info->site_srl != $site_module_info->site_srl && !Rhymix\Framework\UA::isRobot()) { // If the module is of virtual site if ($module_info->site_srl) { $site_info = $oModuleModel->getSiteInfo($module_info->site_srl); $redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); // If it's called from a virtual site, though it's not a module of the virtual site } else { $redirect_url = getNotEncodedSiteUrl(Context::getDefaultUrl(), 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry')); } Context::setCacheControl(0); header("Location: {$redirect_url}", true, 301); return false; } // redirect, if site start module if (Context::getRequestMethod() === 'GET' && isset($_GET['mid']) && $_GET['mid'] === $site_module_info->mid && count($_GET) === 1) { Context::setCacheControl(0); 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) { $this->module = $module_info->module; $this->mid = $module_info->mid; $this->module_info = $module_info; if ($module_info->mid == $site_module_info->mid) { $seo_title = config('seo.main_title') ?: '$SITE_TITLE - $SITE_SUBTITLE'; } else { $seo_title = config('seo.subpage_title') ?: '$SITE_TITLE - $SUBPAGE_TITLE'; } getController('module')->replaceDefinedLangCode($seo_title); Context::setBrowserTitle($seo_title, array('site_title' => Context::getSiteTitle(), 'site_subtitle' => Context::getSiteSubtitle(), 'subpage_title' => $module_info->browser_title, 'page' => Context::get('page') ?: 1)); $module_config = $oModuleModel->getModuleConfig('module'); if ($module_info->meta_keywords) { Context::addMetaTag('keywords', $module_info->meta_keywords); } elseif ($module_config->meta_keywords) { Context::addMetaTag('keywords', $module_config->meta_keywords); } if ($module_info->meta_description) { Context::addMetaTag('description', $module_info->meta_description); } elseif ($module_config->meta_description) { Context::addMetaTag('description', $module_config->meta_description); } $viewType = Mobile::isFromMobilePhone() ? 'M' : 'P'; $targetSrl = Mobile::isFromMobilePhone() ? 'mlayout_srl' : 'layout_srl'; // use the site default layout. if ($module_info->{$targetSrl} == -1) { $oLayoutAdminModel = getAdminModel('layout'); $layoutSrl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $module_info->site_srl); } else { $layoutSrl = $module_info->{$targetSrl}; } // reset a layout_srl in module_info. $module_info->{$targetSrl} = $layoutSrl; $part_config = $oModuleModel->getModulePartConfig('layout', $layoutSrl); Context::addHtmlHeader($part_config->header_script); } // Set module and mid into module_info if (!isset($this->module_info)) { $this->module_info = new stdClass(); } $this->module_info->module = $this->module; $this->module_info->mid = $this->mid; // Set site_srl add 2011 08 09 $this->module_info->site_srl = $site_module_info->site_srl; // Still no module? it's an error if (!$this->module) { $this->error = 'msg_module_is_not_exists'; $this->httpStatusCode = '404'; return true; } // If mid exists, set mid into context if ($this->mid) { Context::set('mid', $this->mid, TRUE); } // Call a trigger after moduleHandler init $output = self::triggerCall('moduleHandler.init', 'after', $this->module_info); if (!$output->toBool()) { $this->error = $output->getMessage(); return true; } // Set current module info into context Context::set('current_module_info', $this->module_info); return true; }