issue 2662 page

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12255 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-11-19 09:56:12 +00:00
parent d456ea02e0
commit 7bb7241447
8 changed files with 1160 additions and 1079 deletions

View file

@ -1,22 +1,23 @@
<?php <?php
/** /**
* @class pageAdminController * @class pageAdminController
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief page of the module admin controller class * @brief page of the module admin controller class
**/ */
class pageAdminController extends page
class pageAdminController extends page { {
/** /**
* @brief Initialization * @brief Initialization
**/ */
function init() { function init()
{
} }
/** /**
* @brief Add a Page * @brief Add a Page
**/ */
function procPageAdminInsert() { function procPageAdminInsert()
{
// Create model/controller object of the module module // Create model/controller object of the module module
$oModuleController = &getController('module'); $oModuleController = &getController('module');
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
@ -30,10 +31,12 @@
if($args->use_mobile != 'Y') $args->use_mobile = ''; if($args->use_mobile != 'Y') $args->use_mobile = '';
// Check if an original module exists by using module_srl // Check if an original module exists by using module_srl
if($args->module_srl) { if($args->module_srl)
{
$columnList = array('module_srl'); $columnList = array('module_srl');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
if($module_info->module_srl != $args->module_srl) { if($module_info->module_srl != $args->module_srl)
{
unset($args->module_srl); unset($args->module_srl);
} }
else else
@ -46,31 +49,38 @@
} }
} }
switch ($args->page_type){ switch ($args->page_type)
case 'WIDGET' : { {
case 'WIDGET' :
{
unset($args->skin); unset($args->skin);
unset($args->mskin); unset($args->mskin);
unset($args->path); unset($args->path);
unset($args->mpath); unset($args->mpath);
break; break;
} }
case 'ARTICLE' : { case 'ARTICLE' :
{
unset($args->page_caching_interval); unset($args->page_caching_interval);
unset($args->path); unset($args->path);
unset($args->mpath); unset($args->mpath);
break; break;
} }
case 'OUTSIDE' : { case 'OUTSIDE' :
{
unset($args->skin); unset($args->skin);
unset($args->mskin); unset($args->mskin);
break; break;
} }
} }
// Insert/update depending on module_srl // Insert/update depending on module_srl
if(!$args->module_srl) { if(!$args->module_srl)
{
$output = $oModuleController->insertModule($args); $output = $oModuleController->insertModule($args);
$msg_code = 'success_registed'; $msg_code = 'success_registed';
} else { }
else
{
$output = $oModuleController->updateModule($args); $output = $oModuleController->updateModule($args);
$msg_code = 'success_updated'; $msg_code = 'success_updated';
} }
@ -87,7 +97,7 @@
/** /**
* @brief Page Modify * @brief Page Modify
**/ */
function procPageAdminUpdate() function procPageAdminUpdate()
{ {
$this->procPageAdminInsert(); $this->procPageAdminInsert();
@ -111,8 +121,9 @@
/** /**
* @brief Save page edits * @brief Save page edits
**/ */
function procPageAdminInsertContent() { function procPageAdminInsertContent()
{
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
$content = Context::get('content'); $content = Context::get('content');
if(!$module_srl) return new Object(-1,'msg_invalid_request'); if(!$module_srl) return new Object(-1,'msg_invalid_request');
@ -121,11 +132,13 @@
// Guhaeom won information page // Guhaeom won information page
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if($type == "mobile") { if($type == "mobile")
{
if(!$mcontent) $mcontent = ''; if(!$mcontent) $mcontent = '';
$module_info->mcontent = $mcontent; $module_info->mcontent = $mcontent;
} }
else { else
{
if(!isset($content)) $content =''; if(!isset($content)) $content ='';
$module_info->content = $content; $module_info->content = $content;
} }
@ -139,7 +152,8 @@
$obj->module_srl = $module_srl; $obj->module_srl = $module_srl;
$obj->list_count = 99999999; $obj->list_count = 99999999;
$output = $oDocumentModel->getDocumentList($obj); $output = $oDocumentModel->getDocumentList($obj);
if(count($output->data)) { if(count($output->data))
{
foreach($output->data as $document) foreach($output->data as $document)
{ {
if($document_srls[$document->document_srl]) continue; if($document_srls[$document->document_srl]) continue;
@ -165,8 +179,9 @@
/** /**
* @brief Delete page * @brief Delete page
**/ */
function procPageAdminDelete() { function procPageAdminDelete()
{
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
// Get an original // Get an original
$oModuleController = &getController('module'); $oModuleController = &getController('module');
@ -183,8 +198,9 @@
/** /**
* @brief Additional pages of basic information * @brief Additional pages of basic information
**/ */
function procPageAdminInsertConfig() { function procPageAdminInsertConfig()
{
// Get the basic information // Get the basic information
$args = Context::getRequestVars(); $args = Context::getRequestVars();
// Insert by creating the module Controller object // Insert by creating the module Controller object
@ -195,8 +211,9 @@
/** /**
* @brief Upload attachments * @brief Upload attachments
**/ */
function procUploadFile() { function procUploadFile()
{
// Basic variables setting // Basic variables setting
$upload_target_srl = Context::get('upload_target_srl'); $upload_target_srl = Context::get('upload_target_srl');
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
@ -210,8 +227,9 @@
/** /**
* @brief Delete the attachment * @brief Delete the attachment
* Delete individual files in the editor using * Delete individual files in the editor using
**/ */
function procDeleteFile() { function procDeleteFile()
{
// Basic variable setting(upload_target_srl and module_srl set) // Basic variable setting(upload_target_srl and module_srl set)
$upload_target_srl = Context::get('upload_target_srl'); $upload_target_srl = Context::get('upload_target_srl');
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
@ -225,8 +243,9 @@
/** /**
* @brief Clear widget cache files of the specified page * @brief Clear widget cache files of the specified page
**/ */
function procPageAdminRemoveWidgetCache() { function procPageAdminRemoveWidgetCache()
{
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
@ -326,7 +345,6 @@
// 성공 메세지 등록 // 성공 메세지 등록
$this->setMessage($msg_code); $this->setMessage($msg_code);
} }
}
/* End of file page.admin.controller.php */
} /* Location: ./modules/page/page.admin.controller.php */
?>

View file

@ -1,31 +1,35 @@
<?php <?php
/** /**
* @class pageAdminView * @class pageAdminView
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief page admin view of the module class * @brief page admin view of the module class
**/ */
class pageAdminView extends page
class pageAdminView extends page { {
var $module_srl = 0; var $module_srl = 0;
var $list_count = 20; var $list_count = 20;
var $page_count = 10; var $page_count = 10;
/** /**
* @brief Initialization * @brief Initialization
**/ */
function init() { function init()
{
// Pre-check if module_srl exists. Set module_info if exists // Pre-check if module_srl exists. Set module_info if exists
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
// Create module model object // Create module model object
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
// module_srl two come over to save the module, putting the information in advance // module_srl two come over to save the module, putting the information in advance
if($module_srl) { if($module_srl)
{
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if(!$module_info) { if(!$module_info)
{
Context::set('module_srl',''); Context::set('module_srl','');
$this->act = 'list'; $this->act = 'list';
} else { }
else
{
ModuleModel::syncModuleToSite($module_info); ModuleModel::syncModuleToSite($module_info);
$this->module_info = $module_info; $this->module_info = $module_info;
Context::set('module_info',$module_info); Context::set('module_info',$module_info);
@ -40,13 +44,13 @@
// Get a template path (page in the administrative template tpl putting together) // Get a template path (page in the administrative template tpl putting together)
$this->setTemplatePath($this->module_path.'tpl'); $this->setTemplatePath($this->module_path.'tpl');
} }
/** /**
* @brief Manage a list of pages showing * @brief Manage a list of pages showing
**/ */
function dispPageAdminContent() { function dispPageAdminContent()
{
$args->sort_index = "module_srl"; $args->sort_index = "module_srl";
$args->page = Context::get('page'); $args->page = Context::get('page');
$args->list_count = 40; $args->list_count = 40;
@ -81,15 +85,17 @@
/** /**
* @brief Information output of the selected page * @brief Information output of the selected page
**/ */
function dispPageAdminInfo() { function dispPageAdminInfo()
{
// Get module_srl by GET parameter // Get module_srl by GET parameter
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
$module_info = Context::get('module_info'); $module_info = Context::get('module_info');
// If you do not value module_srl just showing the index page // If you do not value module_srl just showing the index page
if(!$module_srl) return $this->dispPageAdminContent(); if(!$module_srl) return $this->dispPageAdminContent();
// If the layout is destined to add layout information haejum (layout_title, layout) // If the layout is destined to add layout information haejum (layout_title, layout)
if($module_info->layout_srl) { if($module_info->layout_srl)
{
$oLayoutModel = &getModel('layout'); $oLayoutModel = &getModel('layout');
$layout_info = $oLayoutModel->getLayout($module_info->layout_srl); $layout_info = $oLayoutModel->getLayout($module_info->layout_srl);
$module_info->layout = $layout_info->layout; $module_info->layout = $layout_info->layout;
@ -104,7 +110,8 @@
Context::set('mlayout_list', $mobile_layout_list); Context::set('mlayout_list', $mobile_layout_list);
// Set a template file // Set a template file
if ($this->module_info->page_type == 'ARTICLE'){ if($this->module_info->page_type == 'ARTICLE')
{
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
$skin_list = $oModuleModel->getSkins($this->module_path); $skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list',$skin_list); Context::set('skin_list',$skin_list);
@ -127,8 +134,9 @@
/** /**
* @brief Additional settings page showing * @brief Additional settings page showing
* For additional settings in a service module in order to establish links with other modules peyijiim * For additional settings in a service module in order to establish links with other modules peyijiim
**/ */
function dispPageAdminPageAdditionSetup() { function dispPageAdminPageAdditionSetup()
{
// call by reference content from other modules to come take a year in advance for putting the variable declaration // call by reference content from other modules to come take a year in advance for putting the variable declaration
$content = ''; $content = '';
@ -144,17 +152,20 @@
/** /**
* @brief Add Page Form Output * @brief Add Page Form Output
**/ */
function dispPageAdminInsert() { function dispPageAdminInsert()
{
// Get module_srl by GET parameter // Get module_srl by GET parameter
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
// Get and set module information if module_srl exists // Get and set module information if module_srl exists
if($module_srl) { if($module_srl)
{
$oModuleModel = &getModel('module'); $oModuleModel = &getModel('module');
$columnList = array('module_srl', 'mid', 'module_category_srl', 'browser_title', 'layout_srl', 'use_mobile', 'mlayout_srl'); $columnList = array('module_srl', 'mid', 'module_category_srl', 'browser_title', 'layout_srl', 'use_mobile', 'mlayout_srl');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
if($module_info->module_srl == $module_srl) Context::set('module_info',$module_info); if($module_info->module_srl == $module_srl) Context::set('module_info',$module_info);
else { else
{
unset($module_info); unset($module_info);
unset($module_srl); unset($module_srl);
} }
@ -201,7 +212,7 @@
$oPageMobile->module_info = $this->module_info; $oPageMobile->module_info = $this->module_info;
$page_type_name = strtolower($this->module_info->page_type); $page_type_name = strtolower($this->module_info->page_type);
$method = '_get' . ucfirst($page_type_name) . 'Content'; $method = '_get' . ucfirst($page_type_name) . 'Content';
if (method_exists($oPageMobile, $method)) if(method_exists($oPageMobile, $method))
{ {
$page_content = $oPageMobile->{$method}(); $page_content = $oPageMobile->{$method}();
} }
@ -232,8 +243,9 @@
/** /**
* @brief Edit Page Content * @brief Edit Page Content
**/ */
function dispPageAdminContentModify() { function dispPageAdminContentModify()
{
// Set the module information // Set the module information
Context::set('module_info', $this->module_info); Context::set('module_info', $this->module_info);
@ -247,7 +259,6 @@
} }
} }
function _setWidgetTypeContentModify($isMobile = false) function _setWidgetTypeContentModify($isMobile = false)
{ {
// Setting contents // Setting contents
@ -299,7 +310,7 @@
$target = 'document_srl'; $target = 'document_srl';
} }
if ($this->module_info->{$target}) if($this->module_info->{$target})
{ {
$document_srl = $this->module_info->{$target}; $document_srl = $this->module_info->{$target};
$oDocument->setDocument($document_srl); $oDocument->setDocument($document_srl);
@ -314,8 +325,9 @@
/** /**
* @brief Delete page output * @brief Delete page output
**/ */
function dispPageAdminDelete() { function dispPageAdminDelete()
{
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
if(!$module_srl) return $this->dispContent(); if(!$module_srl) return $this->dispContent();
@ -332,8 +344,9 @@
/** /**
* @brief Rights Listing * @brief Rights Listing
**/ */
function dispPageAdminGrantInfo() { function dispPageAdminGrantInfo()
{
// Common module settings page, call rights // Common module settings page, call rights
$oModuleAdminModel = &getAdminModel('module'); $oModuleAdminModel = &getAdminModel('module');
$grant_content = $oModuleAdminModel->getModuleGrantHTML($this->module_info->module_srl, $this->xml_info->grant); $grant_content = $oModuleAdminModel->getModuleGrantHTML($this->module_info->module_srl, $this->xml_info->grant);
@ -368,5 +381,6 @@
$this->setTemplateFile('skin_info'); $this->setTemplateFile('skin_info');
} }
} }
?> /* End of file page.admin.view.php */
/* Location: ./modules/page/page.admin.view.php */

View file

@ -1,16 +1,16 @@
<?php <?php
/** /**
* @class pageAPI * @class pageAPI
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief View Action page for the module API processing * @brief View Action page for the module API processing
**/ */
class pageAPI extends page
class pageAPI extends page { {
/** /**
* @brief Page information * @brief Page information
**/ */
function dispPageIndex(&$oModule) { function dispPageIndex(&$oModule)
{
$page_content = Context::get('page_content'); $page_content = Context::get('page_content');
$oWidgetController = &getController('widget'); $oWidgetController = &getController('widget');
@ -21,5 +21,6 @@
$oModule->add('page_content',$page_content); $oModule->add('page_content',$page_content);
} }
} }
?> /* End of file page.api.php */
/* Location: ./modules/page/page.api.php */

View file

@ -1,16 +1,16 @@
<?php <?php
/** /**
* @class page * @class page
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief high class of the module page * @brief high class of the module page
**/ */
class page extends ModuleObject
class page extends ModuleObject { {
/** /**
* @brief Implement if additional tasks are necessary when installing * @brief Implement if additional tasks are necessary when installing
**/ */
function moduleInstall() { function moduleInstall()
{
// page generated from the cache directory to use // page generated from the cache directory to use
FileHandler::makeDir('./files/cache/page'); FileHandler::makeDir('./files/cache/page');
@ -19,25 +19,29 @@
/** /**
* @brief a method to check if successfully installed * @brief a method to check if successfully installed
**/ */
function checkUpdate() { function checkUpdate()
{
$output = executeQuery('page.pageTypeOpageCheck'); $output = executeQuery('page.pageTypeOpageCheck');
if ($output->toBool() && $output->data) return true; if($output->toBool() && $output->data) return true;
$output = executeQuery('page.pageTypeNullCheck'); $output = executeQuery('page.pageTypeNullCheck');
if ($output->toBool() && $output->data) return true; if($output->toBool() && $output->data) return true;
return false; return false;
} }
/** /**
* @brief Execute update * @brief Execute update
**/ */
function moduleUpdate() { function moduleUpdate()
{
// opage module instance update // opage module instance update
$output = executeQueryArray('page.pageTypeOpageCheck'); $output = executeQueryArray('page.pageTypeOpageCheck');
if ($output->toBool() && count($output->data) > 0){ if($output->toBool() && count($output->data) > 0)
foreach($output->data as $val){ {
foreach($output->data as $val)
{
$args->module_srl = $val->module_srl; $args->module_srl = $val->module_srl;
$args->name = 'page_type'; $args->name = 'page_type';
$args->value= 'OUTSIDE'; $args->value= 'OUTSIDE';
@ -50,8 +54,10 @@
// old page module instance update // old page module instance update
$output = executeQueryArray('page.pageTypeNullCheck'); $output = executeQueryArray('page.pageTypeNullCheck');
$skin_update_srls = array(); $skin_update_srls = array();
if ($output->toBool() && $output->data){ if($output->toBool() && $output->data)
foreach($output->data as $val){ {
foreach($output->data as $val)
{
$args->module_srl = $val->module_srl; $args->module_srl = $val->module_srl;
$args->name = 'page_type'; $args->name = 'page_type';
$args->value= 'WIDGET'; $args->value= 'WIDGET';
@ -61,7 +67,8 @@
} }
} }
if (count($skin_update_srls)>0){ if(count($skin_update_srls)>0)
{
$skin_args->module_srls = implode(',',$skin_update_srls); $skin_args->module_srls = implode(',',$skin_update_srls);
$skin_args->is_skin_fix = "Y"; $skin_args->is_skin_fix = "Y";
$ouput = executeQuery('page.updateSkinFix', $skin_args); $ouput = executeQuery('page.updateSkinFix', $skin_args);
@ -71,8 +78,10 @@
/** /**
* @brief Re-generate the cache file * @brief Re-generate the cache file
**/ */
function recompileCache() { function recompileCache()
{
} }
} }
?> /* End of file page.class.php */
/* Location: ./modules/page/page.class.php */

View file

@ -1,45 +1,48 @@
<?php <?php
/** /**
* @class documentController * @class documentController
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief controller class of the document module * @brief controller class of the document module
**/ */
class pageController extends page
class pageController extends page { {
var $target_path = ''; var $target_path = '';
/** /**
* @brief Initialization * @brief Initialization
**/ */
function init() { } function init() { }
/** /**
* @brief Extract a title * @brief Extract a title
**/ */
function getTitle($content) { function getTitle($content)
{
preg_match('!<title([^>]*)>(.*?)<\/title>!is', $content, $buff); preg_match('!<title([^>]*)>(.*?)<\/title>!is', $content, $buff);
return trim($buff[2]); return trim($buff[2]);
} }
/** /**
* @brief Extract header script * @brief Extract header script
**/ */
function getHeadScript($content) { function getHeadScript($content)
{
// remove the title tag // remove the title tag
$content = preg_replace('!<title([^>]*)>(.*?)<\/title>!is','', $content); $content = preg_replace('!<title([^>]*)>(.*?)<\/title>!is','', $content);
// Remove meta tags // Remove meta tags
$content = preg_replace('!<(\/){0,1}meta([^>]*)>!is','', $content); $content = preg_replace('!<(\/){0,1}meta([^>]*)>!is','', $content);
// Extract information such as <link, <style, <script and so on // Extract information such as <link, <style, <script and so on
preg_match_all('!<link([^>]*)>!is', $content, $link_buff); preg_match_all('!<link([^>]*)>!is', $content, $link_buff);
for($i=0;$i<count($link_buff[0]);$i++) { for($i=0;$i<count($link_buff[0]);$i++)
{
$tmp_str = trim($link_buff[0][$i]); $tmp_str = trim($link_buff[0][$i]);
if(!$tmp_str) continue; if(!$tmp_str) continue;
$header_script .= $tmp_str."\n"; $header_script .= $tmp_str."\n";
} }
preg_match_all('!<(style|script)(.*?)<\/(style|script)>!is', $content, $script_buff); preg_match_all('!<(style|script)(.*?)<\/(style|script)>!is', $content, $script_buff);
for($i=0;$i<count($script_buff[0]);$i++) { for($i=0;$i<count($script_buff[0]);$i++)
{
$tmp_str = trim($script_buff[0][$i]); $tmp_str = trim($script_buff[0][$i]);
if(!$tmp_str) continue; if(!$tmp_str) continue;
$header_script .= $tmp_str."\n"; $header_script .= $tmp_str."\n";
@ -50,8 +53,9 @@
/** /**
* @brief Extract the contents of the body * @brief Extract the contents of the body
**/ */
function getBodyScript($content) { function getBodyScript($content)
{
// Extract content // Extract content
preg_match('!<body([^>]*)>(.*?)<\/body>!is', $content, $body_buff); preg_match('!<body([^>]*)>(.*?)<\/body>!is', $content, $body_buff);
$body_script = $body_buff[2]; $body_script = $body_buff[2];
@ -63,8 +67,9 @@
/** /**
* @brief Change the value of src, href in the content * @brief Change the value of src, href in the content
**/ */
function replaceSrc($content, $path) { function replaceSrc($content, $path)
{
$url_info = parse_url($path); $url_info = parse_url($path);
$host = sprintf("%s://%s%s",$url_info['scheme'],$url_info['host'],$url_info['port']?':'.$url_info['port']:''); $host = sprintf("%s://%s%s",$url_info['scheme'],$url_info['host'],$url_info['port']?':'.$url_info['port']:'');
$this->host = $host.'/'; $this->host = $host.'/';
@ -72,7 +77,8 @@
if(substr($path,-1)=='/') $path = substr($path,-1); if(substr($path,-1)=='/') $path = substr($path,-1);
$t = explode('/',$path); $t = explode('/',$path);
$_t = array(); $_t = array();
for($i=0,$c=count($t)-1;$i<$c;$i++) { for($i=0,$c=count($t)-1;$i<$c;$i++)
{
$v = trim($t[$i]); $v = trim($t[$i]);
if(!$v) continue; if(!$v) continue;
$_t[] = $v; $_t[] = $v;
@ -85,18 +91,24 @@
return $content; return $content;
} }
function _replacePath($matches) { function _replacePath($matches)
{
$val = trim($matches[3]); $val = trim($matches[3]);
if(preg_match('/^(http|https|ftp|telnet|mms|mailto)/i',$val)) return $matches[0]; if(preg_match('/^(http|https|ftp|telnet|mms|mailto)/i',$val)) return $matches[0];
if(substr($val,0,2)=='./') { if(substr($val,0,2)=='./')
{
$path = $this->path.substr($val,2); $path = $this->path.substr($val,2);
} elseif(substr($val,0,1)=='/') { }
elseif(substr($val,0,1)=='/')
{
$path = $this->host.substr($val,1); $path = $this->host.substr($val,1);
} else { }
else
{
$path = $this->path.$val; $path = $this->path.$val;
} }
return sprintf("%s%s%s%s", $matches[1], $matches[2], $path, $matches[4]); return sprintf("%s%s%s%s", $matches[1], $matches[2], $path, $matches[4]);
} }
}
} /* End of file page.controller.php */
?> /* Location: ./modules/page/page.controller.php */

View file

@ -1,20 +1,23 @@
<?php <?php
require_once(_XE_PATH_.'modules/page/page.view.php'); require_once(_XE_PATH_.'modules/page/page.view.php');
class pageMobile extends pageView { class pageMobile extends pageView
function init() { {
function init()
{
// Get a template path (page in the administrative template tpl putting together) // Get a template path (page in the administrative template tpl putting together)
$this->setTemplatePath($this->module_path.'tpl'); $this->setTemplatePath($this->module_path.'tpl');
switch($this->module_info->page_type) switch($this->module_info->page_type)
{ {
case 'WIDGET' : { case 'WIDGET' :
{
$this->cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus()); $this->cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus());
$this->interval = (int)($this->module_info->page_caching_interval); $this->interval = (int)($this->module_info->page_caching_interval);
break; break;
} }
case 'OUTSIDE' : { case 'OUTSIDE' :
{
$this->cache_file = sprintf("./files/cache/opage/%d.%s.m.cache.php", $this->module_info->module_srl, Context::getSslStatus()); $this->cache_file = sprintf("./files/cache/opage/%d.%s.m.cache.php", $this->module_info->module_srl, Context::getSslStatus());
$this->interval = (int)($this->module_info->page_caching_interval); $this->interval = (int)($this->module_info->page_caching_interval);
$this->path = $this->module_info->mpath; $this->path = $this->module_info->mpath;
@ -23,7 +26,8 @@ class pageMobile extends pageView {
} }
} }
function dispPageIndex() { function dispPageIndex()
{
// Variables used in the template Context:: set() // Variables used in the template Context:: set()
if($this->module_srl) Context::set('module_srl',$this->module_srl); if($this->module_srl) Context::set('module_srl',$this->module_srl);
@ -96,7 +100,7 @@ class pageMobile extends pageView {
$oDocumentModel = &getModel('document'); $oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument(0, true); $oDocument = $oDocumentModel->getDocument(0, true);
if ($this->module_info->mdocument_srl) if($this->module_info->mdocument_srl)
{ {
$document_srl = $this->module_info->mdocument_srl; $document_srl = $this->module_info->mdocument_srl;
$oDocument->setDocument($document_srl); $oDocument->setDocument($document_srl);
@ -104,7 +108,7 @@ class pageMobile extends pageView {
} }
Context::set('oDocument', $oDocument); Context::set('oDocument', $oDocument);
if ($this->module_info->mskin) if($this->module_info->mskin)
{ {
$templatePath = (sprintf($this->module_path.'m.skins/%s', $this->module_info->skin)); $templatePath = (sprintf($this->module_path.'m.skins/%s', $this->module_info->skin));
} }
@ -118,9 +122,11 @@ class pageMobile extends pageView {
return $page_content; return $page_content;
} }
function _getOutsideContent(){ function _getOutsideContent()
{
// check if it is http or internal file // check if it is http or internal file
if($this->path) { if($this->path)
{
if(preg_match("/^([a-z]+):\/\//i",$this->path)) $content = $this->getHtmlPage($this->path, $this->interval, $this->cache_file); if(preg_match("/^([a-z]+):\/\//i",$this->path)) $content = $this->getHtmlPage($this->path, $this->interval, $this->cache_file);
else $content = $this->executeFile($this->path, $this->interval, $this->cache_file); else $content = $this->executeFile($this->path, $this->interval, $this->cache_file);
} }
@ -128,5 +134,5 @@ class pageMobile extends pageView {
return $content; return $content;
} }
} }
/* End of file page.mobile.php */
?> /* Location: ./modules/page/page.mobile.php */

View file

@ -1,12 +1,11 @@
<?php <?php
/** /**
* @class pageView * @class pageView
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief page view class of the module * @brief page view class of the module
**/ */
class pageView extends page
class pageView extends page { {
var $module_srl = 0; var $module_srl = 0;
var $list_count = 20; var $list_count = 20;
var $page_count = 10; var $page_count = 10;
@ -16,19 +15,22 @@
/** /**
* @brief Initialization * @brief Initialization
**/ */
function init() { function init()
{
// Get a template path (page in the administrative template tpl putting together) // Get a template path (page in the administrative template tpl putting together)
$this->setTemplatePath($this->module_path.'tpl'); $this->setTemplatePath($this->module_path.'tpl');
switch($this->module_info->page_type) switch($this->module_info->page_type)
{ {
case 'WIDGET' : { case 'WIDGET' :
{
$this->cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus()); $this->cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType(), Context::getSslStatus());
$this->interval = (int)($this->module_info->page_caching_interval); $this->interval = (int)($this->module_info->page_caching_interval);
break; break;
} }
case 'OUTSIDE' : { case 'OUTSIDE' :
{
$this->cache_file = sprintf("./files/cache/opage/%d.%s.cache.php", $this->module_info->module_srl, Context::getSslStatus()); $this->cache_file = sprintf("./files/cache/opage/%d.%s.cache.php", $this->module_info->module_srl, Context::getSslStatus());
$this->interval = (int)($this->module_info->page_caching_interval); $this->interval = (int)($this->module_info->page_caching_interval);
$this->path = $this->module_info->path; $this->path = $this->module_info->path;
@ -39,14 +41,15 @@
/** /**
* @brief General request output * @brief General request output
**/ */
function dispPageIndex() { function dispPageIndex()
{
// Variables used in the template Context:: set() // Variables used in the template Context:: set()
if($this->module_srl) Context::set('module_srl',$this->module_srl); if($this->module_srl) Context::set('module_srl',$this->module_srl);
$page_type_name = strtolower($this->module_info->page_type); $page_type_name = strtolower($this->module_info->page_type);
$method = '_get' . ucfirst($page_type_name) . 'Content'; $method = '_get' . ucfirst($page_type_name) . 'Content';
if (method_exists($this, $method)) $page_content = $this->{$method}(); if(method_exists($this, $method)) $page_content = $this->{$method}();
else return new Object(-1, sprintf('%s method is not exists', $method)); else return new Object(-1, sprintf('%s method is not exists', $method));
Context::set('module_info', $this->module_info); Context::set('module_info', $this->module_info);
@ -55,33 +58,42 @@
$this->setTemplateFile('content'); $this->setTemplateFile('content');
} }
function _getWidgetContent(){ function _getWidgetContent()
if($this->interval>0) { {
if($this->interval>0)
{
if(!file_exists($this->cache_file)) $mtime = 0; if(!file_exists($this->cache_file)) $mtime = 0;
else $mtime = filemtime($this->cache_file); else $mtime = filemtime($this->cache_file);
if($mtime + $this->interval*60 > time()) { if($mtime + $this->interval*60 > time())
{
$page_content = FileHandler::readFile($this->cache_file); $page_content = FileHandler::readFile($this->cache_file);
$page_content = preg_replace('@<\!--#Meta:@', '<!--Meta:', $page_content); $page_content = preg_replace('@<\!--#Meta:@', '<!--Meta:', $page_content);
} else { }
else
{
$oWidgetController = &getController('widget'); $oWidgetController = &getController('widget');
$page_content = $oWidgetController->transWidgetCode($this->module_info->content); $page_content = $oWidgetController->transWidgetCode($this->module_info->content);
FileHandler::writeFile($this->cache_file, $page_content); FileHandler::writeFile($this->cache_file, $page_content);
} }
} else { }
else
{
if(file_exists($this->cache_file)) FileHandler::removeFile($this->cache_file); if(file_exists($this->cache_file)) FileHandler::removeFile($this->cache_file);
$page_content = $this->module_info->content; $page_content = $this->module_info->content;
} }
return $page_content; return $page_content;
} }
function _getArticleContent(){ function _getArticleContent()
{
$oTemplate = &TemplateHandler::getInstance(); $oTemplate = &TemplateHandler::getInstance();
$oDocumentModel = &getModel('document'); $oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument(0, true); $oDocument = $oDocumentModel->getDocument(0, true);
if ($this->module_info->document_srl){ if($this->module_info->document_srl)
{
$document_srl = $this->module_info->document_srl; $document_srl = $this->module_info->document_srl;
$oDocument->setDocument($document_srl); $oDocument->setDocument($document_srl);
Context::set('document_srl', $document_srl); Context::set('document_srl', $document_srl);
@ -102,9 +114,11 @@
return $page_content; return $page_content;
} }
function _getOutsideContent(){ function _getOutsideContent()
{
// check if it is http or internal file // check if it is http or internal file
if($this->path) { if($this->path)
{
if(preg_match("/^([a-z]+):\/\//i",$this->path)) $content = $this->getHtmlPage($this->path, $this->interval, $this->cache_file); if(preg_match("/^([a-z]+):\/\//i",$this->path)) $content = $this->getHtmlPage($this->path, $this->interval, $this->cache_file);
else $content = $this->executeFile($this->path, $this->interval, $this->cache_file); else $content = $this->executeFile($this->path, $this->interval, $this->cache_file);
} }
@ -114,18 +128,18 @@
/** /**
* @brief Save the file and return if a file is requested by http * @brief Save the file and return if a file is requested by http
**/ */
function getHtmlPage($path, $caching_interval, $cache_file) { function getHtmlPage($path, $caching_interval, $cache_file)
{
// Verify cache // Verify cache
if($caching_interval > 0 && file_exists($cache_file) && filemtime($cache_file) + $caching_interval*60 > time()) { if($caching_interval > 0 && file_exists($cache_file) && filemtime($cache_file) + $caching_interval*60 > time())
{
$content = FileHandler::readFile($cache_file); $content = FileHandler::readFile($cache_file);
}
} else { else
{
FileHandler::getRemoteFile($path, $cache_file); FileHandler::getRemoteFile($path, $cache_file);
$content = FileHandler::readFile($cache_file); $content = FileHandler::readFile($cache_file);
} }
// Create opage controller // Create opage controller
$oPageController = &getController('page'); $oPageController = &getController('page');
@ -150,8 +164,9 @@
/** /**
* @brief Create a cache file in order to include if it is an internal file * @brief Create a cache file in order to include if it is an internal file
**/ */
function executeFile($path, $caching_interval, $cache_file) { function executeFile($path, $caching_interval, $cache_file)
{
// Cancel if the file doesn't exist // Cancel if the file doesn't exist
if(!file_exists($path)) return; if(!file_exists($path)) return;
// Get a path and filename // Get a path and filename
@ -159,7 +174,8 @@
$filename = $tmp_path[count($tmp_path)-1]; $filename = $tmp_path[count($tmp_path)-1];
$filepath = preg_replace('/'.$filename."$/i","",$cache_file); $filepath = preg_replace('/'.$filename."$/i","",$cache_file);
// Verify cache // Verify cache
if($caching_interval <1 || !file_exists($cache_file) || filemtime($cache_file) + $caching_interval*60 <= time() || filemtime($cache_file)<filemtime($path) ) { if($caching_interval <1 || !file_exists($cache_file) || filemtime($cache_file) + $caching_interval*60 <= time() || filemtime($cache_file)<filemtime($path))
{
if(file_exists($cache_file)) FileHandler::removeFile($cache_file); if(file_exists($cache_file)) FileHandler::removeFile($cache_file);
// Read a target file and get content // Read a target file and get content
ob_start(); ob_start();
@ -190,14 +206,18 @@
return $content; return $content;
} }
function _replacePath($matches) { function _replacePath($matches)
{
$val = trim($matches[3]); $val = trim($matches[3]);
// Pass if the path is external or starts with /, #, { characters // Pass if the path is external or starts with /, #, { characters
// /=absolute path, #=hash in a page, {=Template syntax // /=absolute path, #=hash in a page, {=Template syntax
if(strpos($val, '.') === FALSE || preg_match('@^((?:http|https|ftp|telnet|mms)://|(?:mailto|javascript):|[/#{])@i',$val)) { if(strpos($val, '.') === FALSE || preg_match('@^((?:http|https|ftp|telnet|mms)://|(?:mailto|javascript):|[/#{])@i',$val))
{
return $matches[0]; return $matches[0];
// In case of .. , get a path // In case of .. , get a path
} elseif(preg_match('/^\.\./i',$val)) { }
else if(preg_match('/^\.\./i',$val))
{
$p = Context::pathToUrl($this->path); $p = Context::pathToUrl($this->path);
return sprintf("%s%s%s%s",$matches[1],$matches[2],$p.$val,$matches[4]); return sprintf("%s%s%s%s",$matches[1],$matches[2],$p.$val,$matches[4]);
} }
@ -208,5 +228,6 @@
return $path; return $path;
} }
} }
?> /* End of file page.view.php */
/* Location: ./modules/page/page.view.php */

View file

@ -1,18 +1,18 @@
<?php <?php
/** /**
* @class pageWap * @class pageWap
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief wap class page of the module * @brief wap class page of the module
**/ */
class pageWap extends page
class pageWap extends page { {
/** /**
* @brief wap procedure method * @brief wap procedure method
* *
* Page module does not include the following items on the full content control and output from the mobile class * Page module does not include the following items on the full content control and output from the mobile class
**/ */
function procWAP(&$oMobile) { function procWAP(&$oMobile)
{
// Check permissions // Check permissions
if(!$this->grant->access) return $oMobile->setContent(Context::getLang('msg_not_permitted')); if(!$this->grant->access) return $oMobile->setContent(Context::getLang('msg_not_permitted'));
// The contents of the widget chuchulham // The contents of the widget chuchulham
@ -20,6 +20,6 @@
$content = $oWidgetController->transWidgetCode($this->module_info->content); $content = $oWidgetController->transWidgetCode($this->module_info->content);
$oMobile->setContent($content); $oMobile->setContent($content);
} }
}
} /* End of file page.wap.php */
?> /* Location: ./modules/page/page.wap.php */