*/ /** * @class pageView * @author NAVER (developers@xpressengine.com) * @brief page view class of the module */ class PageView extends Page { public $module_srl = 0; public $list_count = 20; public $page_count = 10; public $cache_file = null; public $interval = 0; public $path = ''; public $proc_php = false; public $proc_tpl = false; /** * @brief Initialization */ function init() { if ($this->module_info->page_type === 'WIDGET') { $this->interval = (int)($this->module_info->page_caching_interval ?? 0); $this->cache_file = vsprintf('%sfiles/cache/page/%d.%s.%s.%s.cache.php', [ \RX_BASEDIR, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus(), $this instanceof pageMobile ? 'm' : 'pc', ]); } if ($this->module_info->page_type === 'OUTSIDE') { $this->interval = (int)($this->module_info->page_caching_interval ?? 0); if ($this instanceof pageMobile) { $this->path = ($this->module_info->mpath ?? '') ?: ($this->module_info->path ?? ''); } else { $this->path = ($this->module_info->path ?? ''); } $this->proc_php = (isset($this->module_info->opage_proc_php) && $this->module_info->opage_proc_php === 'N') ? false : true; $this->proc_tpl = (isset($this->module_info->opage_proc_tpl) && $this->module_info->opage_proc_tpl === 'Y') ? true : false; $this->cache_file = vsprintf('%sfiles/cache/opage/%d.%s.%s.%s.%s.cache.php', [ \RX_BASEDIR, $this->module_info->module_srl, Context::getSslStatus(), $this->proc_php ? 'php' : 'nophp', $this->proc_tpl ? 'tpl' : 'notpl', $this instanceof pageMobile ? 'm' : 'pc', ]); } } /** * @brief General request output */ function dispPageIndex() { // Variables used in the template Context:: set() if ($this->module_srl) { Context::set('module_srl', $this->module_srl); } // Get page content according to page type. $page_type_name = strtolower($this->module_info->page_type); if (!in_array($page_type_name, ['widget', 'article', 'outside'])) { $page_type_name = 'widget'; } // Check document_srl. $request_vars = Context::getRequestVars(); if (!empty($request_vars->document_srl)) { $oDocument = DocumentModel::getDocument($request_vars->document_srl); if (!$oDocument->isExists()) { return $this->dispPageNotFound(404, 'msg_not_founded'); } elseif (!$oDocument->isAccessible()) { return $this->dispPageNotFound(403, 'msg_not_permitted'); } elseif (in_array($page_type_name, ['article'])) { return $this->setRedirectUrl(getNotEncodedUrl(['mid' => $this->mid])); } } // Get page content. $method = '_get' . ucfirst($page_type_name) . 'Content'; $page_content = $this->{$method}(); Context::set('module_info', $this->module_info); Context::set('page_content', $page_content); $this->setTemplatePath($this->module_path . 'tpl'); $this->setTemplateFile($this instanceof pageMobile ? 'mobile' : 'content'); } /** * 404 error handler */ public function dispPageNotFound($code = '404', $message = 'msg_not_founded') { $oMessageObject = $this instanceof PageMobile ? MessageMobile::getInstance() : MessageView::getInstance(); $oMessageObject->setMessage($message); $oMessageObject->dispMessage(); $this->setTemplatePath($oMessageObject->getTemplatePath()); $this->setTemplateFile($oMessageObject->getTemplateFile()); $this->setHttpStatusCode($code); } function _getWidgetContent() { if ($this instanceof pageMobile) { $page_content = $this->module_info->mcontent ?: $this->module_info->content; } else { $page_content = $this->module_info->content; } if ($this->interval > 0) { if (!file_exists($this->cache_file) || !filesize($this->cache_file)) { $mtime = 0; } else { $mtime = filemtime($this->cache_file); } if($mtime && $mtime + ($this->interval * 60) > \RX_TIME) { $page_content = FileHandler::readFile($this->cache_file); $page_content = str_replace('