mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
Merge duplicate code paths in PageView and PageMobile classes
보안 체크가 한 곳에서 이루어지도록 중복되는 메소드 제거
This commit is contained in:
parent
9170d9444c
commit
d4a1be1ef0
2 changed files with 27 additions and 77 deletions
|
|
@ -3,74 +3,6 @@
|
|||
|
||||
class pageMobile extends pageView
|
||||
{
|
||||
function dispPageIndex()
|
||||
{
|
||||
// Variables used in the template Context:: set()
|
||||
if($this->module_srl) Context::set('module_srl',$this->module_srl);
|
||||
|
||||
$page_type_name = strtolower($this->module_info->page_type);
|
||||
$method = '_get' . ucfirst($page_type_name) . 'Content';
|
||||
if (method_exists($this, $method))
|
||||
{
|
||||
$page_content = $this->{$method}();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Rhymix\Framework\Exception(sprintf('%s method is not exists', $method));
|
||||
}
|
||||
|
||||
Context::set('module_info', $this->module_info);
|
||||
Context::set('page_content', $page_content);
|
||||
|
||||
$this->setTemplatePath($this->module_path . 'tpl');
|
||||
$this->setTemplateFile('mobile');
|
||||
}
|
||||
|
||||
function _getWidgetContent()
|
||||
{
|
||||
// Arrange a widget ryeolro
|
||||
if($this->module_info->mcontent)
|
||||
{
|
||||
if($this->interval>0)
|
||||
{
|
||||
if(!file_exists($this->cache_file) || filesize($this->cache_file) < 1)
|
||||
{
|
||||
$mtime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mtime = filemtime($this->cache_file);
|
||||
}
|
||||
|
||||
if($mtime + $this->interval*60 > $_SERVER['REQUEST_TIME'])
|
||||
{
|
||||
$page_content = FileHandler::readFile($this->cache_file);
|
||||
$page_content = str_replace('<!--#Meta:', '<!--Meta:', $page_content);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oWidgetController = getController('widget');
|
||||
$page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
|
||||
FileHandler::writeFile($this->cache_file, $page_content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(file_exists($this->cache_file))
|
||||
{
|
||||
FileHandler::removeFile($this->cache_file);
|
||||
}
|
||||
$page_content = $this->module_info->mcontent;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$page_content = $this->module_info->content;
|
||||
}
|
||||
|
||||
return $page_content;
|
||||
}
|
||||
|
||||
function _getArticleContent()
|
||||
{
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
|
|
|
|||
|
|
@ -79,33 +79,51 @@ class pageView extends page
|
|||
Context::set('page_content', $page_content);
|
||||
|
||||
$this->setTemplatePath($this->module_path . 'tpl');
|
||||
$this->setTemplateFile('content');
|
||||
$this->setTemplateFile($this instanceof pageMobile ? 'mobile' : 'content');
|
||||
}
|
||||
|
||||
function _getWidgetContent()
|
||||
{
|
||||
if($this->interval>0)
|
||||
if ($this instanceof pageMobile)
|
||||
{
|
||||
if(!file_exists($this->cache_file)) $mtime = 0;
|
||||
else $mtime = filemtime($this->cache_file);
|
||||
$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 + $this->interval*60 > $_SERVER['REQUEST_TIME'])
|
||||
if($mtime && $mtime + ($this->interval * 60) > \RX_TIME)
|
||||
{
|
||||
$page_content = FileHandler::readFile($this->cache_file);
|
||||
$page_content = str_replace('<!--#Meta:', '<!--Meta:', $page_content);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oWidgetController = getController('widget');
|
||||
$page_content = $oWidgetController->transWidgetCode($this->module_info->content);
|
||||
$oWidgetController = WidgetController::getInstance();
|
||||
$page_content = $oWidgetController->transWidgetCode($page_content);
|
||||
FileHandler::writeFile($this->cache_file, $page_content);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(file_exists($this->cache_file)) FileHandler::removeFile($this->cache_file);
|
||||
$page_content = $this->module_info->content;
|
||||
if (file_exists($this->cache_file))
|
||||
{
|
||||
FileHandler::removeFile($this->cache_file);
|
||||
}
|
||||
}
|
||||
|
||||
return $page_content;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue