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,332 +1,350 @@
<?php
/**
* @class pageAdminController
* @author NHN (developers@xpressengine.com)
* @brief page of the module admin controller class
**/
/**
* @class pageAdminController
* @author NHN (developers@xpressengine.com)
* @brief page of the module admin controller class
*/
class pageAdminController extends page
{
/**
* @brief Initialization
*/
function init()
{
}
class pageAdminController extends page {
/**
* @brief Add a Page
*/
function procPageAdminInsert()
{
// Create model/controller object of the module module
$oModuleController = &getController('module');
$oModuleModel = &getModel('module');
// Set board module
$args = Context::getRequestVars();
$args->module = 'page';
$args->mid = $args->page_name; //because if mid is empty in context, set start page mid
$args->path = (!$args->path) ? '' : $args->path;
$args->mpath = (!$args->mpath) ? '' : $args->mpath;
unset($args->page_name);
/**
* @brief Initialization
**/
function init() {
}
/**
* @brief Add a Page
**/
function procPageAdminInsert() {
// Create model/controller object of the module module
$oModuleController = &getController('module');
$oModuleModel = &getModel('module');
// Set board module
$args = Context::getRequestVars();
$args->module = 'page';
$args->mid = $args->page_name; //because if mid is empty in context, set start page mid
$args->path = (!$args->path) ? '' : $args->path;
$args->mpath = (!$args->mpath) ? '' : $args->mpath;
unset($args->page_name);
if($args->use_mobile != 'Y') $args->use_mobile = '';
// Check if an original module exists by using module_srl
if($args->module_srl) {
$columnList = array('module_srl');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
if($module_info->module_srl != $args->module_srl) {
unset($args->module_srl);
}
else
{
foreach($args as $key=>$val)
{
$module_info->{$key} = $val;
}
$args = $module_info;
}
}
switch ($args->page_type){
case 'WIDGET' : {
unset($args->skin);
unset($args->mskin);
unset($args->path);
unset($args->mpath);
break;
}
case 'ARTICLE' : {
unset($args->page_caching_interval);
unset($args->path);
unset($args->mpath);
break;
}
case 'OUTSIDE' : {
unset($args->skin);
unset($args->mskin);
break;
}
}
// Insert/update depending on module_srl
if(!$args->module_srl) {
$output = $oModuleController->insertModule($args);
$msg_code = 'success_registed';
} else {
$output = $oModuleController->updateModule($args);
$msg_code = 'success_updated';
}
if(!$output->toBool()) return $output;
$this->add("page", Context::get('page'));
$this->add('module_srl',$output->get('module_srl'));
$this->setMessage($msg_code);
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'module_srl', $output->get('module_srl'), 'act', 'dispPageAdminInfo');
$this->setRedirectUrl($returnUrl);
}
/**
* @brief Page Modify
**/
function procPageAdminUpdate()
if($args->use_mobile != 'Y') $args->use_mobile = '';
// Check if an original module exists by using module_srl
if($args->module_srl)
{
$this->procPageAdminInsert();
}
function putDocumentsInPageToArray($target, &$array)
{
if(!$target) return;
preg_match_all('!<img hasContent="true" ([^>]+)!is', $target, $matches);
$pattern = '!document_srl="(\d+)"!';
foreach($matches[1] as $match)
$columnList = array('module_srl');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
if($module_info->module_srl != $args->module_srl)
{
$match2 = null;
preg_match($pattern, $match, $match2);
if(count($match2))
unset($args->module_srl);
}
else
{
foreach($args as $key=>$val)
{
$array[(int)$match2[1]] = 1;
$module_info->{$key} = $val;
}
$args = $module_info;
}
}
/**
* @brief Save page edits
**/
function procPageAdminInsertContent() {
$module_srl = Context::get('module_srl');
$content = Context::get('content');
if(!$module_srl) return new Object(-1,'msg_invalid_request');
$mcontent = Context::get('mcontent');
$type = Context::get('type');
// Guhaeom won information page
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if($type == "mobile") {
if(!$mcontent) $mcontent = '';
$module_info->mcontent = $mcontent;
}
else {
if(!isset($content)) $content ='';
$module_info->content = $content;
}
$document_srls = array();
$this->putDocumentsInPageToArray($module_info->content, $document_srls);
$this->putDocumentsInPageToArray($module_info->mcontent, $document_srls);
$oDocumentModel = &getModel('document');
$oDocumentController = &getController('document');
$obj->module_srl = $module_srl;
$obj->list_count = 99999999;
$output = $oDocumentModel->getDocumentList($obj);
if(count($output->data)) {
foreach($output->data as $document)
{
if($document_srls[$document->document_srl]) continue;
$oDocumentController->deleteDocument($document->document_srl, true);
}
}
// Creates an object of the controller module module
$oModuleController = &getController('module');
// Save
$output = $oModuleController->updateModule($module_info);
if(!$output->toBool()) return $output;
// On the page, change the validity status of the attached file
$oFileController = &getController('file');
$oFileController->setFilesValid($module_info->module_srl);
// Create cache file
//$this->procPageAdminRemoveWidgetCache();
$this->add("module_srl", $module_info->module_srl);
$this->add("page", Context::get('page'));
$this->add("mid", $module_info->mid);
$this->setMessage($msg_code);
}
/**
* @brief Delete page
**/
function procPageAdminDelete() {
$module_srl = Context::get('module_srl');
// Get an original
$oModuleController = &getController('module');
$output = $oModuleController->deleteModule($module_srl);
if(!$output->toBool()) return $output;
$this->add('module','page');
$this->add('page',Context::get('page'));
$this->setMessage('success_deleted');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'module_srl', $output->get('module_srl'), 'act', 'dispPageAdminInfo');
$this->setRedirectUrl($returnUrl);
}
/**
* @brief Additional pages of basic information
**/
function procPageAdminInsertConfig() {
// Get the basic information
$args = Context::getRequestVars();
// Insert by creating the module Controller object
$oModuleController = &getController('module');
$output = $oModuleController->insertModuleConfig('page',$args);
return $output;
}
/**
* @brief Upload attachments
**/
function procUploadFile() {
// Basic variables setting
$upload_target_srl = Context::get('upload_target_srl');
$module_srl = Context::get('module_srl');
// Create the controller object file class
$oFileController = &getController('file');
$output = $oFileController->insertFile($module_srl, $upload_target_srl);
// Attachment to the output of the list, java script
$oFileController->printUploadedFileList($upload_target_srl);
}
/**
* @brief Delete the attachment
* Delete individual files in the editor using
**/
function procDeleteFile() {
// Basic variable setting(upload_target_srl and module_srl set)
$upload_target_srl = Context::get('upload_target_srl');
$module_srl = Context::get('module_srl');
$file_srl = Context::get('file_srl');
// Create the controller object file class
$oFileController = &getController('file');
if($file_srl) $output = $oFileController->deleteFile($file_srl, $this->grant->manager);
// Attachment to the output of the list, java script
$oFileController->printUploadedFileList($upload_target_srl);
}
/**
* @brief Clear widget cache files of the specified page
**/
function procPageAdminRemoveWidgetCache() {
$module_srl = Context::get('module_srl');
$oModuleModel = &getModel('module');
$columnList = array('module_srl', 'content');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
$content = $module_info->content;
// widget controller re-run of the cache files
$oWidgetController = &getController('widget');
$oWidgetController->recompileWidget($content);
if($module_info->page_type == 'WIDGET')
{
$cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.cache.php", _XE_PATH_, $module_info->module_srl, Context::getLangType(), Context::getSslStatus());
$mcacheFile = sprintf("%sfiles/cache/page/%d.%s.%s.m.cache.php", _XE_PATH_, $module_info->module_srl, Context::getLangType(), Context::getSslStatus());
}
else if($module_info->page_type == 'OUTSIDE')
{
$cache_file = sprintf("%sfiles/cache/opage/%d.cache.php", _XE_PATH_, $module_info->module_srl);
if($module_info->mpath)
{
$mcacheFile = sprintf("%sfiles/cache/opage/%d.m.cache.php", _XE_PATH_, $module_info->module_srl);
}
}
if(file_exists($cache_file)) FileHandler::removeFile($cache_file);
if(file_exists($mcacheFile)) FileHandler::removeFile($mcacheFile);
}
function procPageAdminArticleDocumentInsert()
switch ($args->page_type)
{
$logged_info = Context::get('logged_info');
$oModuleModel = &getModel('module');
$grant = $oModuleModel->getGrant($this->module_info, $logged_info);
if (!$grant->manager)
{
return new Object(-1, 'msg_not_permitted');
}
$obj = Context::getRequestVars();
$obj->module_srl = $this->module_info->module_srl;
$obj->is_notice = 'N';
settype($obj->title, "string");
if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
//그래도 없으면 Untitled
if($obj->title == '') $obj->title = 'Untitled';
// document module의 model 객체 생성
$oDocumentModel = &getModel('document');
// document module의 controller 객체 생성
$oDocumentController = &getController('document');
// 이미 존재하는 글인지 체크
$oDocument = $oDocumentModel->getDocument($obj->document_srl, true);
$bAnonymous = false;
// 이미 존재하는 경우 수정
if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
{
$output = $oDocumentController->updateDocument($oDocument, $obj);
$msg_code = 'success_updated';
// 그렇지 않으면 신규 등록
}
else
{
if($obj->ismobile == 'Y')
case 'WIDGET' :
{
$target = 'mdocument_srl';
unset($args->skin);
unset($args->mskin);
unset($args->path);
unset($args->mpath);
break;
}
else
case 'ARTICLE' :
{
$target = 'document_srl';
unset($args->page_caching_interval);
unset($args->path);
unset($args->mpath);
break;
}
$output = $oDocumentController->insertDocument($obj, $bAnonymous);
$msg_code = 'success_registed';
$document_srl = $output->get('document_srl');
$oModuleController = &getController('module');
$this->module_info->{$target} = $document_srl;
$oModuleController->updateModule($this->module_info);
}
// 오류 발생시 멈춤
if(!$output->toBool()) return $output;
// 결과를 리턴
$this->add('mid', Context::get('mid'));
$this->add('document_srl', $output->get('document_srl'));
$this->add('is_mobile', $obj->ismobile);
// 성공 메세지 등록
$this->setMessage($msg_code);
case 'OUTSIDE' :
{
unset($args->skin);
unset($args->mskin);
break;
}
}
// Insert/update depending on module_srl
if(!$args->module_srl)
{
$output = $oModuleController->insertModule($args);
$msg_code = 'success_registed';
}
else
{
$output = $oModuleController->updateModule($args);
$msg_code = 'success_updated';
}
if(!$output->toBool()) return $output;
}
?>
$this->add("page", Context::get('page'));
$this->add('module_srl',$output->get('module_srl'));
$this->setMessage($msg_code);
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'module_srl', $output->get('module_srl'), 'act', 'dispPageAdminInfo');
$this->setRedirectUrl($returnUrl);
}
/**
* @brief Page Modify
*/
function procPageAdminUpdate()
{
$this->procPageAdminInsert();
}
function putDocumentsInPageToArray($target, &$array)
{
if(!$target) return;
preg_match_all('!<img hasContent="true" ([^>]+)!is', $target, $matches);
$pattern = '!document_srl="(\d+)"!';
foreach($matches[1] as $match)
{
$match2 = null;
preg_match($pattern, $match, $match2);
if(count($match2))
{
$array[(int)$match2[1]] = 1;
}
}
}
/**
* @brief Save page edits
*/
function procPageAdminInsertContent()
{
$module_srl = Context::get('module_srl');
$content = Context::get('content');
if(!$module_srl) return new Object(-1,'msg_invalid_request');
$mcontent = Context::get('mcontent');
$type = Context::get('type');
// Guhaeom won information page
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if($type == "mobile")
{
if(!$mcontent) $mcontent = '';
$module_info->mcontent = $mcontent;
}
else
{
if(!isset($content)) $content ='';
$module_info->content = $content;
}
$document_srls = array();
$this->putDocumentsInPageToArray($module_info->content, $document_srls);
$this->putDocumentsInPageToArray($module_info->mcontent, $document_srls);
$oDocumentModel = &getModel('document');
$oDocumentController = &getController('document');
$obj->module_srl = $module_srl;
$obj->list_count = 99999999;
$output = $oDocumentModel->getDocumentList($obj);
if(count($output->data))
{
foreach($output->data as $document)
{
if($document_srls[$document->document_srl]) continue;
$oDocumentController->deleteDocument($document->document_srl, true);
}
}
// Creates an object of the controller module module
$oModuleController = &getController('module');
// Save
$output = $oModuleController->updateModule($module_info);
if(!$output->toBool()) return $output;
// On the page, change the validity status of the attached file
$oFileController = &getController('file');
$oFileController->setFilesValid($module_info->module_srl);
// Create cache file
//$this->procPageAdminRemoveWidgetCache();
$this->add("module_srl", $module_info->module_srl);
$this->add("page", Context::get('page'));
$this->add("mid", $module_info->mid);
$this->setMessage($msg_code);
}
/**
* @brief Delete page
*/
function procPageAdminDelete()
{
$module_srl = Context::get('module_srl');
// Get an original
$oModuleController = &getController('module');
$output = $oModuleController->deleteModule($module_srl);
if(!$output->toBool()) return $output;
$this->add('module','page');
$this->add('page',Context::get('page'));
$this->setMessage('success_deleted');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'module_srl', $output->get('module_srl'), 'act', 'dispPageAdminInfo');
$this->setRedirectUrl($returnUrl);
}
/**
* @brief Additional pages of basic information
*/
function procPageAdminInsertConfig()
{
// Get the basic information
$args = Context::getRequestVars();
// Insert by creating the module Controller object
$oModuleController = &getController('module');
$output = $oModuleController->insertModuleConfig('page',$args);
return $output;
}
/**
* @brief Upload attachments
*/
function procUploadFile()
{
// Basic variables setting
$upload_target_srl = Context::get('upload_target_srl');
$module_srl = Context::get('module_srl');
// Create the controller object file class
$oFileController = &getController('file');
$output = $oFileController->insertFile($module_srl, $upload_target_srl);
// Attachment to the output of the list, java script
$oFileController->printUploadedFileList($upload_target_srl);
}
/**
* @brief Delete the attachment
* Delete individual files in the editor using
*/
function procDeleteFile()
{
// Basic variable setting(upload_target_srl and module_srl set)
$upload_target_srl = Context::get('upload_target_srl');
$module_srl = Context::get('module_srl');
$file_srl = Context::get('file_srl');
// Create the controller object file class
$oFileController = &getController('file');
if($file_srl) $output = $oFileController->deleteFile($file_srl, $this->grant->manager);
// Attachment to the output of the list, java script
$oFileController->printUploadedFileList($upload_target_srl);
}
/**
* @brief Clear widget cache files of the specified page
*/
function procPageAdminRemoveWidgetCache()
{
$module_srl = Context::get('module_srl');
$oModuleModel = &getModel('module');
$columnList = array('module_srl', 'content');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
$content = $module_info->content;
// widget controller re-run of the cache files
$oWidgetController = &getController('widget');
$oWidgetController->recompileWidget($content);
if($module_info->page_type == 'WIDGET')
{
$cache_file = sprintf("%sfiles/cache/page/%d.%s.%s.cache.php", _XE_PATH_, $module_info->module_srl, Context::getLangType(), Context::getSslStatus());
$mcacheFile = sprintf("%sfiles/cache/page/%d.%s.%s.m.cache.php", _XE_PATH_, $module_info->module_srl, Context::getLangType(), Context::getSslStatus());
}
else if($module_info->page_type == 'OUTSIDE')
{
$cache_file = sprintf("%sfiles/cache/opage/%d.cache.php", _XE_PATH_, $module_info->module_srl);
if($module_info->mpath)
{
$mcacheFile = sprintf("%sfiles/cache/opage/%d.m.cache.php", _XE_PATH_, $module_info->module_srl);
}
}
if(file_exists($cache_file)) FileHandler::removeFile($cache_file);
if(file_exists($mcacheFile)) FileHandler::removeFile($mcacheFile);
}
function procPageAdminArticleDocumentInsert()
{
$logged_info = Context::get('logged_info');
$oModuleModel = &getModel('module');
$grant = $oModuleModel->getGrant($this->module_info, $logged_info);
if (!$grant->manager)
{
return new Object(-1, 'msg_not_permitted');
}
$obj = Context::getRequestVars();
$obj->module_srl = $this->module_info->module_srl;
$obj->is_notice = 'N';
settype($obj->title, "string");
if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
//그래도 없으면 Untitled
if($obj->title == '') $obj->title = 'Untitled';
// document module의 model 객체 생성
$oDocumentModel = &getModel('document');
// document module의 controller 객체 생성
$oDocumentController = &getController('document');
// 이미 존재하는 글인지 체크
$oDocument = $oDocumentModel->getDocument($obj->document_srl, true);
$bAnonymous = false;
// 이미 존재하는 경우 수정
if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
{
$output = $oDocumentController->updateDocument($oDocument, $obj);
$msg_code = 'success_updated';
// 그렇지 않으면 신규 등록
}
else
{
if($obj->ismobile == 'Y')
{
$target = 'mdocument_srl';
}
else
{
$target = 'document_srl';
}
$output = $oDocumentController->insertDocument($obj, $bAnonymous);
$msg_code = 'success_registed';
$document_srl = $output->get('document_srl');
$oModuleController = &getController('module');
$this->module_info->{$target} = $document_srl;
$oModuleController->updateModule($this->module_info);
}
// 오류 발생시 멈춤
if(!$output->toBool()) return $output;
// 결과를 리턴
$this->add('mid', Context::get('mid'));
$this->add('document_srl', $output->get('document_srl'));
$this->add('is_mobile', $obj->ismobile);
// 성공 메세지 등록
$this->setMessage($msg_code);
}
}
/* End of file page.admin.controller.php */
/* Location: ./modules/page/page.admin.controller.php */

View file

@ -1,372 +1,386 @@
<?php
/**
* @class pageAdminView
* @author NHN (developers@xpressengine.com)
* @brief page admin view of the module class
**/
/**
* @class pageAdminView
* @author NHN (developers@xpressengine.com)
* @brief page admin view of the module class
*/
class pageAdminView extends page
{
var $module_srl = 0;
var $list_count = 20;
var $page_count = 10;
class pageAdminView extends page {
var $module_srl = 0;
var $list_count = 20;
var $page_count = 10;
/**
* @brief Initialization
**/
function init() {
// Pre-check if module_srl exists. Set module_info if exists
$module_srl = Context::get('module_srl');
// Create module model object
$oModuleModel = &getModel('module');
// module_srl two come over to save the module, putting the information in advance
if($module_srl) {
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if(!$module_info) {
Context::set('module_srl','');
$this->act = 'list';
} else {
ModuleModel::syncModuleToSite($module_info);
$this->module_info = $module_info;
Context::set('module_info',$module_info);
}
}
// Get a list of module categories
$module_category = $oModuleModel->getModuleCategories();
Context::set('module_category', $module_category);
//Security
$security = new Security();
$security->encodeHTML('module_category..title');
// Get a template path (page in the administrative template tpl putting together)
$this->setTemplatePath($this->module_path.'tpl');
}
/**
* @brief Manage a list of pages showing
**/
function dispPageAdminContent() {
$args->sort_index = "module_srl";
$args->page = Context::get('page');
$args->list_count = 40;
$args->page_count = 10;
$args->s_module_category_srl = Context::get('module_category_srl');
$search_target_list = array('s_mid','s_browser_title');
$search_target = Context::get('search_target');
$search_keyword = Context::get('search_keyword');
if(in_array($search_target,$search_target_list) && $search_keyword) $args->{$search_target} = $search_keyword;
$output = executeQuery('page.getPageList', $args);
$oModuleModel = &getModel('module');
$page_list = $oModuleModel->addModuleExtraVars($output->data);
moduleModel::syncModuleToSite($page_list);
// To write to a template context:: set
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_list', $output->data);
Context::set('page_navigation', $output->page_navigation);
//Security
$security = new Security();
$security->encodeHTML('page_list..browser_title');
$security->encodeHTML('page_list..mid');
$security->encodeHTML('module_info.');
// Set a template file
$this->setTemplateFile('index');
}
/**
* @brief Information output of the selected page
**/
function dispPageAdminInfo() {
// Get module_srl by GET parameter
$module_srl = Context::get('module_srl');
$module_info = Context::get('module_info');
// If you do not value module_srl just showing the index page
if(!$module_srl) return $this->dispPageAdminContent();
// If the layout is destined to add layout information haejum (layout_title, layout)
if($module_info->layout_srl) {
$oLayoutModel = &getModel('layout');
$layout_info = $oLayoutModel->getLayout($module_info->layout_srl);
$module_info->layout = $layout_info->layout;
$module_info->layout_title = $layout_info->layout_title;
}
// Get a layout list
$oLayoutModel = &getModel('layout');
$layout_list = $oLayoutModel->getLayoutList();
Context::set('layout_list', $layout_list);
$mobile_layout_list = $oLayoutModel->getLayoutList(0,"M");
Context::set('mlayout_list', $mobile_layout_list);
// Set a template file
if ($this->module_info->page_type == 'ARTICLE'){
$oModuleModel = &getModel('module');
$skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list',$skin_list);
$mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins");
Context::set('mskin_list', $mskin_list);
/**
* @brief Initialization
*/
function init()
{
// Pre-check if module_srl exists. Set module_info if exists
$module_srl = Context::get('module_srl');
// Create module model object
$oModuleModel = &getModel('module');
// module_srl two come over to save the module, putting the information in advance
if($module_srl)
{
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if(!$module_info)
{
Context::set('module_srl','');
$this->act = 'list';
}
else
{
ModuleModel::syncModuleToSite($module_info);
$this->module_info = $module_info;
Context::set('module_info',$module_info);
}
}
// Get a list of module categories
$module_category = $oModuleModel->getModuleCategories();
Context::set('module_category', $module_category);
//Security
$security = new Security();
$security->encodeHTML('module_category..title');
//Security
$security = new Security();
$security->encodeHTML('layout_list..layout');
$security->encodeHTML('layout_list..title');
$security->encodeHTML('mlayout_list..layout');
$security->encodeHTML('mlayout_list..title');
$security->encodeHTML('module_info.');
// Get a template path (page in the administrative template tpl putting together)
$this->setTemplatePath($this->module_path.'tpl');
}
$this->setTemplateFile('page_info');
}
/**
* @brief Manage a list of pages showing
*/
function dispPageAdminContent()
{
$args->sort_index = "module_srl";
$args->page = Context::get('page');
$args->list_count = 40;
$args->page_count = 10;
$args->s_module_category_srl = Context::get('module_category_srl');
/**
* @brief Additional settings page showing
* For additional settings in a service module in order to establish links with other modules peyijiim
**/
function dispPageAdminPageAdditionSetup() {
// call by reference content from other modules to come take a year in advance for putting the variable declaration
$content = '';
$search_target_list = array('s_mid','s_browser_title');
$search_target = Context::get('search_target');
$search_keyword = Context::get('search_keyword');
if(in_array($search_target,$search_target_list) && $search_keyword) $args->{$search_target} = $search_keyword;
$oEditorView = &getView('editor');
$oEditorView->triggerDispEditorAdditionSetup($content);
Context::set('setup_content', $content);
// Set a template file
$this->setTemplateFile('addition_setup');
$output = executeQuery('page.getPageList', $args);
$oModuleModel = &getModel('module');
$page_list = $oModuleModel->addModuleExtraVars($output->data);
moduleModel::syncModuleToSite($page_list);
$security = new Security();
$security->encodeHTML('module_info.');
}
// To write to a template context:: set
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('page_list', $output->data);
Context::set('page_navigation', $output->page_navigation);
//Security
$security = new Security();
$security->encodeHTML('page_list..browser_title');
$security->encodeHTML('page_list..mid');
$security->encodeHTML('module_info.');
/**
* @brief Add Page Form Output
**/
function dispPageAdminInsert() {
// Get module_srl by GET parameter
$module_srl = Context::get('module_srl');
// Get and set module information if module_srl exists
if($module_srl) {
$oModuleModel = &getModel('module');
$columnList = array('module_srl', 'mid', 'module_category_srl', 'browser_title', 'layout_srl', 'use_mobile', 'mlayout_srl');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
if($module_info->module_srl == $module_srl) Context::set('module_info',$module_info);
else {
unset($module_info);
unset($module_srl);
}
}
// Get a layout list
$oLayoutModel = &getModel('layout');
$layout_list = $oLayoutModel->getLayoutList();
Context::set('layout_list', $layout_list);
// Set a template file
$this->setTemplateFile('index');
}
$mobile_layout_list = $oLayoutModel->getLayoutList(0,"M");
Context::set('mlayout_list', $mobile_layout_list);
/**
* @brief Information output of the selected page
*/
function dispPageAdminInfo()
{
// Get module_srl by GET parameter
$module_srl = Context::get('module_srl');
$module_info = Context::get('module_info');
// If you do not value module_srl just showing the index page
if(!$module_srl) return $this->dispPageAdminContent();
// If the layout is destined to add layout information haejum (layout_title, layout)
if($module_info->layout_srl)
{
$oLayoutModel = &getModel('layout');
$layout_info = $oLayoutModel->getLayout($module_info->layout_srl);
$module_info->layout = $layout_info->layout;
$module_info->layout_title = $layout_info->layout_title;
}
// Get a layout list
$oLayoutModel = &getModel('layout');
$layout_list = $oLayoutModel->getLayoutList();
Context::set('layout_list', $layout_list);
$oModuleModel = &getModel('module');
$skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list',$skin_list);
$mobile_layout_list = $oLayoutModel->getLayoutList(0,"M");
Context::set('mlayout_list', $mobile_layout_list);
// Set a template file
if($this->module_info->page_type == 'ARTICLE')
{
$oModuleModel = &getModel('module');
$skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list',$skin_list);
$mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins");
Context::set('mskin_list', $mskin_list);
}
//Security
$security = new Security();
$security->encodeHTML('layout_list..layout');
$security->encodeHTML('layout_list..title');
$security->encodeHTML('mlayout_list..layout');
$security->encodeHTML('mlayout_list..title');
//Security
$security = new Security();
$security->encodeHTML('layout_list..layout');
$security->encodeHTML('layout_list..title');
$security->encodeHTML('mlayout_list..layout');
$security->encodeHTML('mlayout_list..title');
$security->encodeHTML('module_info.');
// Set a template file
$this->setTemplateFile('page_insert');
}
$this->setTemplateFile('page_info');
}
function dispPageAdminMobileContent()
/**
* @brief Additional settings page showing
* For additional settings in a service module in order to establish links with other modules peyijiim
*/
function dispPageAdminPageAdditionSetup()
{
// call by reference content from other modules to come take a year in advance for putting the variable declaration
$content = '';
$oEditorView = &getView('editor');
$oEditorView->triggerDispEditorAdditionSetup($content);
Context::set('setup_content', $content);
// Set a template file
$this->setTemplateFile('addition_setup');
$security = new Security();
$security->encodeHTML('module_info.');
}
/**
* @brief Add Page Form Output
*/
function dispPageAdminInsert()
{
// Get module_srl by GET parameter
$module_srl = Context::get('module_srl');
// Get and set module information if module_srl exists
if($module_srl)
{
if($this->module_info->page_type == 'OUTSIDE')
{
return $this->stop(-1, 'msg_invalid_request');
}
if($this->module_srl)
{
Context::set('module_srl',$this->module_srl);
}
$oPageMobile = &getMobile('page');
$oPageMobile->module_info = $this->module_info;
$page_type_name = strtolower($this->module_info->page_type);
$method = '_get' . ucfirst($page_type_name) . 'Content';
if (method_exists($oPageMobile, $method))
{
$page_content = $oPageMobile->{$method}();
}
$oModuleModel = &getModel('module');
$columnList = array('module_srl', 'mid', 'module_category_srl', 'browser_title', 'layout_srl', 'use_mobile', 'mlayout_srl');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
if($module_info->module_srl == $module_srl) Context::set('module_info',$module_info);
else
{
return new Object(-1, sprintf('%s method is not exists', $method));
}
Context::set('module_info', $this->module_info);
Context::set('page_content', $page_content);
$this->setTemplateFile('mcontent');
}
function dispPageAdminMobileContentModify()
{
Context::set('module_info', $this->module_info);
if ($this->module_info->page_type == 'WIDGET')
{
$this->_setWidgetTypeContentModify(true);
}
else if ($this->module_info->page_type == 'ARTICLE')
{
$this->_setArticleTypeContentModify(true);
unset($module_info);
unset($module_srl);
}
}
// Get a layout list
$oLayoutModel = &getModel('layout');
$layout_list = $oLayoutModel->getLayoutList();
Context::set('layout_list', $layout_list);
/**
* @brief Edit Page Content
**/
function dispPageAdminContentModify() {
// Set the module information
Context::set('module_info', $this->module_info);
$mobile_layout_list = $oLayoutModel->getLayoutList(0,"M");
Context::set('mlayout_list', $mobile_layout_list);
if ($this->module_info->page_type == 'WIDGET')
{
$this->_setWidgetTypeContentModify();
}
else if ($this->module_info->page_type == 'ARTICLE')
{
$this->_setArticleTypeContentModify();
}
}
$oModuleModel = &getModel('module');
$skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list',$skin_list);
$mskin_list = $oModuleModel->getSkins($this->module_path, "m.skins");
Context::set('mskin_list', $mskin_list);
function _setWidgetTypeContentModify($isMobile = false)
//Security
$security = new Security();
$security->encodeHTML('layout_list..layout');
$security->encodeHTML('layout_list..title');
$security->encodeHTML('mlayout_list..layout');
$security->encodeHTML('mlayout_list..title');
// Set a template file
$this->setTemplateFile('page_insert');
}
function dispPageAdminMobileContent()
{
if($this->module_info->page_type == 'OUTSIDE')
{
// Setting contents
if($isMobile)
{
$content = Context::get('mcontent');
if(!$content) $content = $this->module_info->mcontent;
$templateFile = 'page_mobile_content_modify';
}
else
{
$content = Context::get('content');
if(!$content) $content = $this->module_info->content;
$templateFile = 'page_content_modify';
}
Context::set('content', $content);
// Convert them to teach the widget
$oWidgetController = &getController('widget');
$content = $oWidgetController->transWidgetCode($content, true, !$isMobile);
// $content = str_replace('$', '&#36;', $content);
Context::set('page_content', $content);
// Set widget list
$oWidgetModel = &getModel('widget');
$widget_list = $oWidgetModel->getDownloadedWidgetList();
Context::set('widget_list', $widget_list);
//Security
$security = new Security();
$security->encodeHTML('widget_list..title','module_info.mid');
// Set a template file
$this->setTemplateFile($templateFile);
}
function _setArticleTypeContentModify($isMobile = false)
{
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument(0, true);
if($isMobile)
{
Context::set('isMobile', 'Y');
$target = 'mdocument_srl';
}
else
{
Context::set('isMobile', 'N');
$target = 'document_srl';
}
if ($this->module_info->{$target})
{
$document_srl = $this->module_info->{$target};
$oDocument->setDocument($document_srl);
Context::set('document_srl', $document_srl);
}
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_article.xml');
Context::set('oDocument', $oDocument);
Context::set('mid', $this->module_info->mid);
$this->setTemplateFile('article_content_modify');
return $this->stop(-1, 'msg_invalid_request');
}
/**
* @brief Delete page output
**/
function dispPageAdminDelete() {
$module_srl = Context::get('module_srl');
if(!$module_srl) return $this->dispContent();
$oModuleModel = &getModel('module');
$columnList = array('module_srl', 'module', 'mid');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
Context::set('module_info',$module_info);
// Set a template file
$this->setTemplateFile('page_delete');
$security = new Security();
$security->encodeHTML('module_info.');
}
/**
* @brief Rights Listing
**/
function dispPageAdminGrantInfo() {
// Common module settings page, call rights
$oModuleAdminModel = &getAdminModel('module');
$grant_content = $oModuleAdminModel->getModuleGrantHTML($this->module_info->module_srl, $this->xml_info->grant);
Context::set('grant_content', $grant_content);
$this->setTemplateFile('grant_list');
$security = new Security();
$security->encodeHTML('module_info.');
}
/**
* Display skin setting page
*/
function dispPageAdminSkinInfo()
if($this->module_srl)
{
$oModuleAdminModel = &getAdminModel('module');
$skin_content = $oModuleAdminModel->getModuleSkinHTML($this->module_info->module_srl);
Context::set('skin_content', $skin_content);
$this->setTemplateFile('skin_info');
Context::set('module_srl',$this->module_srl);
}
/**
* Display mobile skin setting page
*/
function dispPageAdminMobileSkinInfo()
$oPageMobile = &getMobile('page');
$oPageMobile->module_info = $this->module_info;
$page_type_name = strtolower($this->module_info->page_type);
$method = '_get' . ucfirst($page_type_name) . 'Content';
if(method_exists($oPageMobile, $method))
{
$oModuleAdminModel = &getAdminModel('module');
$skin_content = $oModuleAdminModel->getModuleMobileSkinHTML($this->module_info->module_srl);
Context::set('skin_content', $skin_content);
$this->setTemplateFile('skin_info');
$page_content = $oPageMobile->{$method}();
}
}
?>
else
{
return new Object(-1, sprintf('%s method is not exists', $method));
}
Context::set('module_info', $this->module_info);
Context::set('page_content', $page_content);
$this->setTemplateFile('mcontent');
}
function dispPageAdminMobileContentModify()
{
Context::set('module_info', $this->module_info);
if ($this->module_info->page_type == 'WIDGET')
{
$this->_setWidgetTypeContentModify(true);
}
else if ($this->module_info->page_type == 'ARTICLE')
{
$this->_setArticleTypeContentModify(true);
}
}
/**
* @brief Edit Page Content
*/
function dispPageAdminContentModify()
{
// Set the module information
Context::set('module_info', $this->module_info);
if ($this->module_info->page_type == 'WIDGET')
{
$this->_setWidgetTypeContentModify();
}
else if ($this->module_info->page_type == 'ARTICLE')
{
$this->_setArticleTypeContentModify();
}
}
function _setWidgetTypeContentModify($isMobile = false)
{
// Setting contents
if($isMobile)
{
$content = Context::get('mcontent');
if(!$content) $content = $this->module_info->mcontent;
$templateFile = 'page_mobile_content_modify';
}
else
{
$content = Context::get('content');
if(!$content) $content = $this->module_info->content;
$templateFile = 'page_content_modify';
}
Context::set('content', $content);
// Convert them to teach the widget
$oWidgetController = &getController('widget');
$content = $oWidgetController->transWidgetCode($content, true, !$isMobile);
// $content = str_replace('$', '&#36;', $content);
Context::set('page_content', $content);
// Set widget list
$oWidgetModel = &getModel('widget');
$widget_list = $oWidgetModel->getDownloadedWidgetList();
Context::set('widget_list', $widget_list);
//Security
$security = new Security();
$security->encodeHTML('widget_list..title','module_info.mid');
// Set a template file
$this->setTemplateFile($templateFile);
}
function _setArticleTypeContentModify($isMobile = false)
{
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument(0, true);
if($isMobile)
{
Context::set('isMobile', 'Y');
$target = 'mdocument_srl';
}
else
{
Context::set('isMobile', 'N');
$target = 'document_srl';
}
if($this->module_info->{$target})
{
$document_srl = $this->module_info->{$target};
$oDocument->setDocument($document_srl);
Context::set('document_srl', $document_srl);
}
Context::addJsFilter($this->module_path.'tpl/filter', 'insert_article.xml');
Context::set('oDocument', $oDocument);
Context::set('mid', $this->module_info->mid);
$this->setTemplateFile('article_content_modify');
}
/**
* @brief Delete page output
*/
function dispPageAdminDelete()
{
$module_srl = Context::get('module_srl');
if(!$module_srl) return $this->dispContent();
$oModuleModel = &getModel('module');
$columnList = array('module_srl', 'module', 'mid');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
Context::set('module_info',$module_info);
// Set a template file
$this->setTemplateFile('page_delete');
$security = new Security();
$security->encodeHTML('module_info.');
}
/**
* @brief Rights Listing
*/
function dispPageAdminGrantInfo()
{
// Common module settings page, call rights
$oModuleAdminModel = &getAdminModel('module');
$grant_content = $oModuleAdminModel->getModuleGrantHTML($this->module_info->module_srl, $this->xml_info->grant);
Context::set('grant_content', $grant_content);
$this->setTemplateFile('grant_list');
$security = new Security();
$security->encodeHTML('module_info.');
}
/**
* Display skin setting page
*/
function dispPageAdminSkinInfo()
{
$oModuleAdminModel = &getAdminModel('module');
$skin_content = $oModuleAdminModel->getModuleSkinHTML($this->module_info->module_srl);
Context::set('skin_content', $skin_content);
$this->setTemplateFile('skin_info');
}
/**
* Display mobile skin setting page
*/
function dispPageAdminMobileSkinInfo()
{
$oModuleAdminModel = &getAdminModel('module');
$skin_content = $oModuleAdminModel->getModuleMobileSkinHTML($this->module_info->module_srl);
Context::set('skin_content', $skin_content);
$this->setTemplateFile('skin_info');
}
}
/* End of file page.admin.view.php */
/* Location: ./modules/page/page.admin.view.php */

View file

@ -1,25 +1,26 @@
<?php
/**
* @class pageAPI
* @author NHN (developers@xpressengine.com)
* @brief View Action page for the module API processing
**/
/**
* @class pageAPI
* @author NHN (developers@xpressengine.com)
* @brief View Action page for the module API processing
*/
class pageAPI extends page
{
/**
* @brief Page information
*/
function dispPageIndex(&$oModule)
{
$page_content = Context::get('page_content');
$oWidgetController = &getController('widget');
class pageAPI extends page {
$requestMethod = Context::getRequestMethod();
Context::setResponseMethod('HTML');
$oWidgetController->triggerWidgetCompile($page_content);
Context::setResponseMethod($requestMethod);
/**
* @brief Page information
**/
function dispPageIndex(&$oModule) {
$page_content = Context::get('page_content');
$oWidgetController = &getController('widget');
$requestMethod = Context::getRequestMethod();
Context::setResponseMethod('HTML');
$oWidgetController->triggerWidgetCompile($page_content);
Context::setResponseMethod($requestMethod);
$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,78 +1,87 @@
<?php
/**
* @class page
* @author NHN (developers@xpressengine.com)
* @brief high class of the module page
**/
/**
* @class page
* @author NHN (developers@xpressengine.com)
* @brief high class of the module page
*/
class page extends ModuleObject
{
/**
* @brief Implement if additional tasks are necessary when installing
*/
function moduleInstall()
{
// page generated from the cache directory to use
FileHandler::makeDir('./files/cache/page');
class page extends ModuleObject {
return new Object();
}
/**
* @brief Implement if additional tasks are necessary when installing
**/
function moduleInstall() {
// page generated from the cache directory to use
FileHandler::makeDir('./files/cache/page');
/**
* @brief a method to check if successfully installed
*/
function checkUpdate()
{
$output = executeQuery('page.pageTypeOpageCheck');
if($output->toBool() && $output->data) return true;
return new Object();
}
$output = executeQuery('page.pageTypeNullCheck');
if($output->toBool() && $output->data) return true;
/**
* @brief a method to check if successfully installed
**/
function checkUpdate() {
$output = executeQuery('page.pageTypeOpageCheck');
if ($output->toBool() && $output->data) return true;
return false;
}
$output = executeQuery('page.pageTypeNullCheck');
if ($output->toBool() && $output->data) return true;
return false;
}
/**
* @brief Execute update
**/
function moduleUpdate() {
// opage module instance update
$output = executeQueryArray('page.pageTypeOpageCheck');
if ($output->toBool() && count($output->data) > 0){
foreach($output->data as $val){
$args->module_srl = $val->module_srl;
$args->name = 'page_type';
$args->value= 'OUTSIDE';
$in_out = executeQuery('page.insertPageType', $args);
}
$output = executeQuery('page.updateAllOpage');
if(!$output->toBool()) return $output;
/**
* @brief Execute update
*/
function moduleUpdate()
{
// opage module instance update
$output = executeQueryArray('page.pageTypeOpageCheck');
if($output->toBool() && count($output->data) > 0)
{
foreach($output->data as $val)
{
$args->module_srl = $val->module_srl;
$args->name = 'page_type';
$args->value= 'OUTSIDE';
$in_out = executeQuery('page.insertPageType', $args);
}
$output = executeQuery('page.updateAllOpage');
if(!$output->toBool()) return $output;
}
// old page module instance update
$output = executeQueryArray('page.pageTypeNullCheck');
$skin_update_srls = array();
if ($output->toBool() && $output->data){
foreach($output->data as $val){
$args->module_srl = $val->module_srl;
$args->name = 'page_type';
$args->value= 'WIDGET';
$in_out = executeQuery('page.insertPageType', $args);
// old page module instance update
$output = executeQueryArray('page.pageTypeNullCheck');
$skin_update_srls = array();
if($output->toBool() && $output->data)
{
foreach($output->data as $val)
{
$args->module_srl = $val->module_srl;
$args->name = 'page_type';
$args->value= 'WIDGET';
$in_out = executeQuery('page.insertPageType', $args);
$skin_update_srls[] = $val->module_srl;
}
$skin_update_srls[] = $val->module_srl;
}
if (count($skin_update_srls)>0){
$skin_args->module_srls = implode(',',$skin_update_srls);
$skin_args->is_skin_fix = "Y";
$ouput = executeQuery('page.updateSkinFix', $skin_args);
}
return new Object(0,'success_updated');
}
}
/**
* @brief Re-generate the cache file
**/
function recompileCache() {
}
}
?>
if(count($skin_update_srls)>0)
{
$skin_args->module_srls = implode(',',$skin_update_srls);
$skin_args->is_skin_fix = "Y";
$ouput = executeQuery('page.updateSkinFix', $skin_args);
}
return new Object(0,'success_updated');
}
/**
* @brief Re-generate the cache file
*/
function recompileCache()
{
}
}
/* End of file page.class.php */
/* Location: ./modules/page/page.class.php */

View file

@ -1,102 +1,114 @@
<?php
/**
* @class documentController
* @author NHN (developers@xpressengine.com)
* @brief controller class of the document module
**/
/**
* @class documentController
* @author NHN (developers@xpressengine.com)
* @brief controller class of the document module
*/
class pageController extends page
{
var $target_path = '';
class pageController extends page {
/**
* @brief Initialization
*/
function init() { }
var $target_path = '';
/**
* @brief Extract a title
*/
function getTitle($content)
{
preg_match('!<title([^>]*)>(.*?)<\/title>!is', $content, $buff);
return trim($buff[2]);
}
/**
* @brief Initialization
**/
function init() { }
/**
* @brief Extract header script
*/
function getHeadScript($content)
{
// remove the title tag
$content = preg_replace('!<title([^>]*)>(.*?)<\/title>!is','', $content);
// Remove meta tags
$content = preg_replace('!<(\/){0,1}meta([^>]*)>!is','', $content);
// Extract information such as <link, <style, <script and so on
preg_match_all('!<link([^>]*)>!is', $content, $link_buff);
for($i=0;$i<count($link_buff[0]);$i++)
{
$tmp_str = trim($link_buff[0][$i]);
if(!$tmp_str) continue;
$header_script .= $tmp_str."\n";
}
/**
* @brief Extract a title
**/
function getTitle($content) {
preg_match('!<title([^>]*)>(.*?)<\/title>!is', $content, $buff);
return trim($buff[2]);
}
preg_match_all('!<(style|script)(.*?)<\/(style|script)>!is', $content, $script_buff);
for($i=0;$i<count($script_buff[0]);$i++)
{
$tmp_str = trim($script_buff[0][$i]);
if(!$tmp_str) continue;
$header_script .= $tmp_str."\n";
}
/**
* @brief Extract header script
**/
function getHeadScript($content) {
// remove the title tag
$content = preg_replace('!<title([^>]*)>(.*?)<\/title>!is','', $content);
// Remove meta tags
$content = preg_replace('!<(\/){0,1}meta([^>]*)>!is','', $content);
// Extract information such as <link, <style, <script and so on
preg_match_all('!<link([^>]*)>!is', $content, $link_buff);
for($i=0;$i<count($link_buff[0]);$i++) {
$tmp_str = trim($link_buff[0][$i]);
if(!$tmp_str) continue;
$header_script .= $tmp_str."\n";
}
return $header_script;
}
preg_match_all('!<(style|script)(.*?)<\/(style|script)>!is', $content, $script_buff);
for($i=0;$i<count($script_buff[0]);$i++) {
$tmp_str = trim($script_buff[0][$i]);
if(!$tmp_str) continue;
$header_script .= $tmp_str."\n";
}
/**
* @brief Extract the contents of the body
*/
function getBodyScript($content)
{
// Extract content
preg_match('!<body([^>]*)>(.*?)<\/body>!is', $content, $body_buff);
$body_script = $body_buff[2];
// Remove link, style, script, etc.
$body_script = preg_replace('!<link([^>]*)>!is', '', $body_script);
$body_script = preg_replace('!<(style|script)(.*?)<\/(style|script)>!is', '', $body_script);
return $body_script;
}
return $header_script;
}
/**
* @brief Change the value of src, href in the content
*/
function replaceSrc($content, $path)
{
$url_info = parse_url($path);
$host = sprintf("%s://%s%s",$url_info['scheme'],$url_info['host'],$url_info['port']?':'.$url_info['port']:'');
$this->host = $host.'/';
$path = $url_info['path'];
if(substr($path,-1)=='/') $path = substr($path,-1);
$t = explode('/',$path);
$_t = array();
for($i=0,$c=count($t)-1;$i<$c;$i++)
{
$v = trim($t[$i]);
if(!$v) continue;
$_t[] = $v;
}
$path = $host.'/'.implode('/',$_t);
if(substr($path,-1)!='/') $path .= '/';
$this->path = $path;
$content = preg_replace_callback('/(src=|href=|url\()("|\')?([^"\'\)]+)("|\'\))?/is',array($this,'_replacePath'),$content);
/**
* @brief Extract the contents of the body
**/
function getBodyScript($content) {
// Extract content
preg_match('!<body([^>]*)>(.*?)<\/body>!is', $content, $body_buff);
$body_script = $body_buff[2];
// Remove link, style, script, etc.
$body_script = preg_replace('!<link([^>]*)>!is', '', $body_script);
$body_script = preg_replace('!<(style|script)(.*?)<\/(style|script)>!is', '', $body_script);
return $body_script;
}
return $content;
}
/**
* @brief Change the value of src, href in the content
**/
function replaceSrc($content, $path) {
$url_info = parse_url($path);
$host = sprintf("%s://%s%s",$url_info['scheme'],$url_info['host'],$url_info['port']?':'.$url_info['port']:'');
$this->host = $host.'/';
$path = $url_info['path'];
if(substr($path,-1)=='/') $path = substr($path,-1);
$t = explode('/',$path);
$_t = array();
for($i=0,$c=count($t)-1;$i<$c;$i++) {
$v = trim($t[$i]);
if(!$v) continue;
$_t[] = $v;
}
$path = $host.'/'.implode('/',$_t);
if(substr($path,-1)!='/') $path .= '/';
$this->path = $path;
$content = preg_replace_callback('/(src=|href=|url\()("|\')?([^"\'\)]+)("|\'\))?/is',array($this,'_replacePath'),$content);
return $content;
}
function _replacePath($matches) {
$val = trim($matches[3]);
if(preg_match('/^(http|https|ftp|telnet|mms|mailto)/i',$val)) return $matches[0];
if(substr($val,0,2)=='./') {
$path = $this->path.substr($val,2);
} elseif(substr($val,0,1)=='/') {
$path = $this->host.substr($val,1);
} else {
$path = $this->path.$val;
}
return sprintf("%s%s%s%s", $matches[1], $matches[2], $path, $matches[4]);
}
}
?>
function _replacePath($matches)
{
$val = trim($matches[3]);
if(preg_match('/^(http|https|ftp|telnet|mms|mailto)/i',$val)) return $matches[0];
if(substr($val,0,2)=='./')
{
$path = $this->path.substr($val,2);
}
elseif(substr($val,0,1)=='/')
{
$path = $this->host.substr($val,1);
}
else
{
$path = $this->path.$val;
}
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,29 +1,33 @@
<?php
require_once(_XE_PATH_.'modules/page/page.view.php');
class pageMobile extends pageView {
function init() {
class pageMobile extends pageView
{
function init()
{
// Get a template path (page in the administrative template tpl putting together)
$this->setTemplatePath($this->module_path.'tpl');
switch($this->module_info->page_type)
{
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->interval = (int)($this->module_info->page_caching_interval);
break;
}
case 'OUTSIDE' : {
$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->path = $this->module_info->mpath;
break;
}
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->interval = (int)($this->module_info->page_caching_interval);
break;
}
case 'OUTSIDE' :
{
$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->path = $this->module_info->mpath;
break;
}
}
}
function dispPageIndex() {
function dispPageIndex()
{
// Variables used in the template Context:: set()
if($this->module_srl) Context::set('module_srl',$this->module_srl);
@ -31,7 +35,7 @@ class pageMobile extends pageView {
$method = '_get' . ucfirst($page_type_name) . 'Content';
if (method_exists($this, $method)) $page_content = $this->{$method}();
else return new Object(-1, sprintf('%s method is not exists', $method));
Context::set('module_info', $this->module_info);
Context::set('page_content', $page_content);
@ -43,39 +47,39 @@ class pageMobile extends pageView {
// Arrange a widget ryeolro
if($this->module_info->mcontent)
{
$cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
$interval = (int)($this->module_info->page_caching_interval);
if($interval>0)
$cache_file = sprintf("%sfiles/cache/page/%d.%s.m.cache.php", _XE_PATH_, $this->module_info->module_srl, Context::getLangType());
$interval = (int)($this->module_info->page_caching_interval);
if($interval>0)
{
if(!file_exists($cache_file) || filesize($cache_file) < 1)
if(!file_exists($cache_file) || filesize($cache_file) < 1)
{
$mtime = 0;
}
else
else
{
$mtime = filemtime($cache_file);
}
if($mtime + $interval*60 > time())
if($mtime + $interval*60 > time())
{
$page_content = FileHandler::readFile($cache_file);
$page_content = FileHandler::readFile($cache_file);
$page_content = preg_replace('@<\!--#Meta:@', '<!--Meta:', $page_content);
}
}
else
{
$oWidgetController = &getController('widget');
$page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
FileHandler::writeFile($cache_file, $page_content);
}
}
$oWidgetController = &getController('widget');
$page_content = $oWidgetController->transWidgetCode($this->module_info->mcontent);
FileHandler::writeFile($cache_file, $page_content);
}
}
else
{
if(file_exists($cache_file))
if(file_exists($cache_file))
{
FileHandler::removeFile($cache_file);
}
$page_content = $this->module_info->mcontent;
}
$page_content = $this->module_info->mcontent;
}
}
else
{
@ -95,8 +99,8 @@ class pageMobile extends pageView {
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument(0, true);
if ($this->module_info->mdocument_srl)
if($this->module_info->mdocument_srl)
{
$document_srl = $this->module_info->mdocument_srl;
$oDocument->setDocument($document_srl);
@ -104,7 +108,7 @@ class pageMobile extends pageView {
}
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));
}
@ -118,15 +122,17 @@ class pageMobile extends pageView {
return $page_content;
}
function _getOutsideContent(){
function _getOutsideContent()
{
// 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);
else $content = $this->executeFile($this->path, $this->interval, $this->cache_file);
}
return $content;
}
}
?>
/* End of file page.mobile.php */
/* Location: ./modules/page/page.mobile.php */

View file

@ -1,212 +1,233 @@
<?php
/**
* @class pageView
* @author NHN (developers@xpressengine.com)
* @brief page view class of the module
**/
/**
* @class pageView
* @author NHN (developers@xpressengine.com)
* @brief page view class of the module
*/
class pageView extends page
{
var $module_srl = 0;
var $list_count = 20;
var $page_count = 10;
var $cache_file;
var $interval;
var $path;
class pageView extends page {
/**
* @brief Initialization
*/
function init()
{
// Get a template path (page in the administrative template tpl putting together)
$this->setTemplatePath($this->module_path.'tpl');
var $module_srl = 0;
var $list_count = 20;
var $page_count = 10;
var $cache_file;
var $interval;
var $path;
/**
* @brief Initialization
**/
function init() {
// Get a template path (page in the administrative template tpl putting together)
$this->setTemplatePath($this->module_path.'tpl');
switch($this->module_info->page_type)
{
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->interval = (int)($this->module_info->page_caching_interval);
break;
}
case 'OUTSIDE' : {
$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->path = $this->module_info->path;
break;
}
}
}
/**
* @brief General request output
**/
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 return new Object(-1, sprintf('%s method is not exists', $method));
Context::set('module_info', $this->module_info);
Context::set('page_content', $page_content);
$this->setTemplateFile('content');
}
function _getWidgetContent(){
if($this->interval>0) {
if(!file_exists($this->cache_file)) $mtime = 0;
else $mtime = filemtime($this->cache_file);
if($mtime + $this->interval*60 > time()) {
$page_content = FileHandler::readFile($this->cache_file);
$page_content = preg_replace('@<\!--#Meta:@', '<!--Meta:', $page_content);
} else {
$oWidgetController = &getController('widget');
$page_content = $oWidgetController->transWidgetCode($this->module_info->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;
}
return $page_content;
switch($this->module_info->page_type)
{
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->interval = (int)($this->module_info->page_caching_interval);
break;
}
case 'OUTSIDE' :
{
$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->path = $this->module_info->path;
break;
}
}
}
function _getArticleContent(){
$oTemplate = &TemplateHandler::getInstance();
/**
* @brief General request output
*/
function dispPageIndex()
{
// Variables used in the template Context:: set()
if($this->module_srl) Context::set('module_srl',$this->module_srl);
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument(0, true);
if ($this->module_info->document_srl){
$document_srl = $this->module_info->document_srl;
$oDocument->setDocument($document_srl);
Context::set('document_srl', $document_srl);
}
Context::set('oDocument', $oDocument);
$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 return new Object(-1, sprintf('%s method is not exists', $method));
if ($this->module_info->skin)
Context::set('module_info', $this->module_info);
Context::set('page_content', $page_content);
$this->setTemplateFile('content');
}
function _getWidgetContent()
{
if($this->interval>0)
{
if(!file_exists($this->cache_file)) $mtime = 0;
else $mtime = filemtime($this->cache_file);
if($mtime + $this->interval*60 > time())
{
$templatePath = (sprintf($this->module_path.'skins/%s', $this->module_info->skin));
$page_content = FileHandler::readFile($this->cache_file);
$page_content = preg_replace('@<\!--#Meta:@', '<!--Meta:', $page_content);
}
else
{
$templatePath = ($this->module_path.'skins/default');
$oWidgetController = &getController('widget');
$page_content = $oWidgetController->transWidgetCode($this->module_info->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;
}
return $page_content;
}
$page_content = $oTemplate->compile($templatePath, 'content');
function _getArticleContent()
{
$oTemplate = &TemplateHandler::getInstance();
return $page_content;
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument(0, true);
if($this->module_info->document_srl)
{
$document_srl = $this->module_info->document_srl;
$oDocument->setDocument($document_srl);
Context::set('document_srl', $document_srl);
}
Context::set('oDocument', $oDocument);
if ($this->module_info->skin)
{
$templatePath = (sprintf($this->module_path.'skins/%s', $this->module_info->skin));
}
else
{
$templatePath = ($this->module_path.'skins/default');
}
function _getOutsideContent(){
// check if it is http or internal file
if($this->path) {
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);
}
return $content;
$page_content = $oTemplate->compile($templatePath, 'content');
return $page_content;
}
function _getOutsideContent()
{
// check if it is http or internal file
if($this->path)
{
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);
}
/**
* @brief Save the file and return if a file is requested by http
**/
function getHtmlPage($path, $caching_interval, $cache_file) {
// Verify cache
if($caching_interval > 0 && file_exists($cache_file) && filemtime($cache_file) + $caching_interval*60 > time()) {
return $content;
}
$content = FileHandler::readFile($cache_file);
/**
* @brief Save the file and return if a file is requested by http
*/
function getHtmlPage($path, $caching_interval, $cache_file)
{
// Verify cache
if($caching_interval > 0 && file_exists($cache_file) && filemtime($cache_file) + $caching_interval*60 > time())
{
$content = FileHandler::readFile($cache_file);
}
else
{
FileHandler::getRemoteFile($path, $cache_file);
$content = FileHandler::readFile($cache_file);
}
// Create opage controller
$oPageController = &getController('page');
// change url of image, css, javascript and so on if the page is from external server
$content = $oPageController->replaceSrc($content, $path);
// Change the document to utf-8 format
$buff->content = $content;
$buff = Context::convertEncoding($buff);
$content = $buff->content;
// Extract a title
$title = $oPageController->getTitle($content);
if($title) Context::setBrowserTitle($title);
// Extract header script
$head_script = $oPageController->getHeadScript($content);
if($head_script) Context::addHtmlHeader($head_script);
// Extract content from the body
$body_script = $oPageController->getBodyScript($content);
if(!$body_script) $body_script = $content;
} else {
return $content;
}
FileHandler::getRemoteFile($path, $cache_file);
$content = FileHandler::readFile($cache_file);
/**
* @brief Create a cache file in order to include if it is an internal file
*/
function executeFile($path, $caching_interval, $cache_file)
{
// Cancel if the file doesn't exist
if(!file_exists($path)) return;
// Get a path and filename
$tmp_path = explode('/',$cache_file);
$filename = $tmp_path[count($tmp_path)-1];
$filepath = preg_replace('/'.$filename."$/i","",$cache_file);
// Verify cache
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);
// Read a target file and get content
ob_start();
@include($path);
$content = ob_get_clean();
// Replace relative path to the absolute path
$this->path = str_replace('\\', '/', realpath(dirname($path))) . '/';
$content = preg_replace_callback('/(target=|src=|href=|url\()("|\')?([^"\'\)]+)("|\'\))?/is',array($this,'_replacePath'),$content);
$content = preg_replace_callback('/(<!--%import\()(\")([^"]+)(\")/is',array($this,'_replacePath'),$content);
}
// Create opage controller
$oPageController = &getController('page');
// change url of image, css, javascript and so on if the page is from external server
$content = $oPageController->replaceSrc($content, $path);
// Change the document to utf-8 format
$buff->content = $content;
$buff = Context::convertEncoding($buff);
$content = $buff->content;
// Extract a title
$title = $oPageController->getTitle($content);
if($title) Context::setBrowserTitle($title);
// Extract header script
$head_script = $oPageController->getHeadScript($content);
if($head_script) Context::addHtmlHeader($head_script);
// Extract content from the body
$body_script = $oPageController->getBodyScript($content);
if(!$body_script) $body_script = $content;
FileHandler::writeFile($cache_file, $content);
// Include and then Return the result
if(!file_exists($cache_file)) return;
// Attempt to compile
$oTemplate = &TemplateHandler::getInstance();
$script = $oTemplate->compileDirect($filepath, $filename);
return $content;
}
FileHandler::writeFile($cache_file, $script);
}
/**
* @brief Create a cache file in order to include if it is an internal file
**/
function executeFile($path, $caching_interval, $cache_file) {
// Cancel if the file doesn't exist
if(!file_exists($path)) return;
// Get a path and filename
$tmp_path = explode('/',$cache_file);
$filename = $tmp_path[count($tmp_path)-1];
$filepath = preg_replace('/'.$filename."$/i","",$cache_file);
// Verify cache
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);
// Read a target file and get content
ob_start();
@include($path);
$content = ob_get_clean();
// Replace relative path to the absolute path
$this->path = str_replace('\\', '/', realpath(dirname($path))) . '/';
$content = preg_replace_callback('/(target=|src=|href=|url\()("|\')?([^"\'\)]+)("|\'\))?/is',array($this,'_replacePath'),$content);
$content = preg_replace_callback('/(<!--%import\()(\")([^"]+)(\")/is',array($this,'_replacePath'),$content);
$__Context = &$GLOBALS['__Context__'];
$__Context->tpl_path = $filepath;
FileHandler::writeFile($cache_file, $content);
// Include and then Return the result
if(!file_exists($cache_file)) return;
// Attempt to compile
$oTemplate = &TemplateHandler::getInstance();
$script = $oTemplate->compileDirect($filepath, $filename);
ob_start();
@include($cache_file);
$content = ob_get_clean();
FileHandler::writeFile($cache_file, $script);
}
return $content;
}
$__Context = &$GLOBALS['__Context__'];
$__Context->tpl_path = $filepath;
ob_start();
@include($cache_file);
$content = ob_get_clean();
return $content;
}
function _replacePath($matches) {
$val = trim($matches[3]);
// Pass if the path is external or starts with /, #, { characters
// /=absolute path, #=hash in a page, {=Template syntax
if(strpos($val, '.') === FALSE || preg_match('@^((?:http|https|ftp|telnet|mms)://|(?:mailto|javascript):|[/#{])@i',$val)) {
function _replacePath($matches)
{
$val = trim($matches[3]);
// Pass if the path is external or starts with /, #, { characters
// /=absolute path, #=hash in a page, {=Template syntax
if(strpos($val, '.') === FALSE || preg_match('@^((?:http|https|ftp|telnet|mms)://|(?:mailto|javascript):|[/#{])@i',$val))
{
return $matches[0];
// In case of .. , get a path
} elseif(preg_match('/^\.\./i',$val)) {
$p = Context::pathToUrl($this->path);
return sprintf("%s%s%s%s",$matches[1],$matches[2],$p.$val,$matches[4]);
}
if(substr($val,0,2)=='./') $val = substr($val,2);
// In case of .. , get a path
}
else if(preg_match('/^\.\./i',$val))
{
$p = Context::pathToUrl($this->path);
$path = 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]);
}
return $path;
}
}
?>
if(substr($val,0,2)=='./') $val = substr($val,2);
$p = Context::pathToUrl($this->path);
$path = sprintf("%s%s%s%s",$matches[1],$matches[2],$p.$val,$matches[4]);
return $path;
}
}
/* End of file page.view.php */
/* Location: ./modules/page/page.view.php */

View file

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