*/ /** * @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'; } $method = '_get' . ucfirst($page_type_name) . 'Content'; $page_content = $this->{$method}(); Context::set('module_info', $this->module_info); Context::set('page_content', $page_content); // if the page type is the widget or outside, there might be usable GET entities. $request_vars = Context::getRequestVars(); if (isset($request_vars->document_srl) && intval($request_vars->document_srl) > 0 && $page_type_name == 'article') { $returnUrl = getUrl(['mid' => Context::get('mid')]); $this->setRedirectUrl($returnUrl); } else { $this->setTemplatePath($this->module_path . 'tpl'); $this->setTemplateFile($this instanceof pageMobile ? 'mobile' : 'content'); } } 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('' . PHP_EOL; $content = sprintf($sign, 'start') . $content . sprintf($sign, 'end'); } } // Parse as PHP if enabled. elseif ($this->proc_php) { ob_start(); call_user_func(function() use($real_target_file) { include $real_target_file; }); $content = ob_get_clean(); } // Otherwise, get the raw content of the file. else { $content = file_get_contents($real_target_file); } // Convert relative paths to absolute paths. $this->path = str_replace('\\', '/', dirname($real_target_file)) . '/'; $content = preg_replace_callback('/\b(target=|src=|href=|url\()("|\')?([^"\'\)]+)("|\'\))?/is', array($this, '_replacePath'), $content); $content = preg_replace_callback('/(