issue 2662 install, integration_search

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12249 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-11-19 01:26:43 +00:00
parent e7177034b3
commit 9aefe700b6
10 changed files with 1720 additions and 1577 deletions

View file

@ -1,294 +1,314 @@
<?php <?php
/** /**
* @class installAdminController * @class installAdminController
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief admin controller class of the install module * @brief admin controller class of the install module
**/ */
class installAdminController extends install
{
/**
* @brief Initialization
*/
function init()
{
}
class installAdminController extends install { /**
* @brief Install the module
*/
function procInstallAdminInstall()
{
$module_name = Context::get('module_name');
if(!$module_name) return new object(-1, 'invalid_request');
$oInstallController = &getController('install');
$oInstallController->installModule($module_name, './modules/'.$module_name);
/** $this->setMessage('success_installed');
* @brief Initialization }
**/
function init() {
}
/** /**
* @brief Install the module * @brief Upate the module
**/ */
function procInstallAdminInstall() { function procInstallAdminUpdate()
$module_name = Context::get('module_name'); {
if(!$module_name) return new object(-1, 'invalid_request'); set_time_limit(0);
$module_name = Context::get('module_name');
if(!$module_name) return new object(-1, 'invalid_request');
$oInstallController = &getController('install'); $oModule = &getModule($module_name, 'class');
$oInstallController->installModule($module_name, './modules/'.$module_name); if($oModule) $output = $oModule->moduleUpdate();
else $output = new Object(-1, 'invalid_request');
$this->setMessage('success_installed'); return $output;
} }
/** /**
* @brief Upate the module * @brief Change settings
**/ */
function procInstallAdminUpdate() { function procInstallAdminSaveTimeZone()
set_time_limit(0); {
$module_name = Context::get('module_name'); $admin_ip_list = Context::get('admin_ip_list');
if(!$module_name) return new object(-1, 'invalid_request');
$oModule = &getModule($module_name, 'class'); $admin_ip_list = preg_replace("/[\r|\n|\r\n]+/",",",$admin_ip_list);
if($oModule) $output = $oModule->moduleUpdate(); $admin_ip_list = preg_replace("/\s+/","",$admin_ip_list);
else $output = new Object(-1, 'invalid_request'); if(preg_match('/(<\?|<\?php|\?>)/xsm', $admin_ip_list))
return $output;
}
/**
* @brief Change settings
**/
function procInstallAdminSaveTimeZone() {
$admin_ip_list = Context::get('admin_ip_list');
$admin_ip_list = preg_replace("/[\r|\n|\r\n]+/",",",$admin_ip_list);
$admin_ip_list = preg_replace("/\s+/","",$admin_ip_list);
if(preg_match('/(<\?|<\?php|\?>)/xsm', $admin_ip_list))
{
$admin_ip_list = '';
}
$default_url = Context::get('default_url');
if($default_url && !preg_match('/^(http|https):\/\//i', $default_url)) $default_url = 'http://'.$default_url;
$use_ssl = Context::get('use_ssl');
if(!$use_ssl) $use_ssl = 'none';
$http_port = Context::get('http_port');
$https_port = Context::get('https_port');
$use_cdn = Context::get('use_cdn');
if($use_cdn != 'Y') $use_cdn = 'N';
$use_rewrite = Context::get('use_rewrite');
if($use_rewrite!='Y') $use_rewrite = 'N';
$use_sso = Context::get('use_sso');
if($use_sso !='Y') $use_sso = 'N';
$use_db_session = Context::get('use_db_session');
if($use_db_session!='Y') $use_db_session = 'N';
$qmail_compatibility = Context::get('qmail_compatibility');
if($qmail_compatibility!='Y') $qmail_compatibility = 'N';
$use_html5 = Context::get('use_html5');
if(!$use_html5) $use_html5 = 'N';
$db_info = Context::getDBInfo();
$db_info->default_url = $default_url;
$db_info->qmail_compatibility = $qmail_compatibility;
$db_info->use_db_session = $use_db_session;
$db_info->use_rewrite = $use_rewrite;
$db_info->use_sso = $use_sso;
$db_info->use_ssl = $use_ssl;
$db_info->use_cdn = $use_cdn;
$db_info->use_html5 = $use_html5;
$db_info->admin_ip_list = $admin_ip_list;
if($http_port) $db_info->http_port = (int) $http_port;
else if($db_info->http_port) unset($db_info->http_port);
if($https_port) $db_info->https_port = (int) $https_port;
else if($db_info->https_port) unset($db_info->https_port);
unset($db_info->lang_type);
Context::setDBInfo($db_info);
$oInstallController = &getController('install');
$oInstallController->makeConfigFile();
if($default_url)
{
$site_args->site_srl = 0;
$site_args->domain = $default_url;
$oModuleController = &getController('module');
$oModuleController->updateSite($site_args);
}
$this->setRedirectUrl(Context::get('error_return_url'));
}
function procInstallAdminUpdateIndexModule()
{ {
if(!Context::get('index_module_srl') || !Context::get('menu_item_srl')) $admin_ip_list = '';
{ }
return new Object(-1, 'msg_invalid_request');
}
$default_url = Context::get('default_url');
if($default_url && !preg_match('/^(http|https):\/\//i', $default_url)) $default_url = 'http://'.$default_url;
$use_ssl = Context::get('use_ssl');
if(!$use_ssl) $use_ssl = 'none';
$http_port = Context::get('http_port');
$https_port = Context::get('https_port');
$use_cdn = Context::get('use_cdn');
if($use_cdn != 'Y') $use_cdn = 'N';
$use_rewrite = Context::get('use_rewrite');
if($use_rewrite!='Y') $use_rewrite = 'N';
$use_sso = Context::get('use_sso');
if($use_sso !='Y') $use_sso = 'N';
$use_db_session = Context::get('use_db_session');
if($use_db_session!='Y') $use_db_session = 'N';
$qmail_compatibility = Context::get('qmail_compatibility');
if($qmail_compatibility!='Y') $qmail_compatibility = 'N';
$use_html5 = Context::get('use_html5');
if(!$use_html5) $use_html5 = 'N';
$db_info = Context::getDBInfo();
$db_info->default_url = $default_url;
$db_info->qmail_compatibility = $qmail_compatibility;
$db_info->use_db_session = $use_db_session;
$db_info->use_rewrite = $use_rewrite;
$db_info->use_sso = $use_sso;
$db_info->use_ssl = $use_ssl;
$db_info->use_cdn = $use_cdn;
$db_info->use_html5 = $use_html5;
$db_info->admin_ip_list = $admin_ip_list;
if($http_port) $db_info->http_port = (int) $http_port;
else if($db_info->http_port) unset($db_info->http_port);
if($https_port) $db_info->https_port = (int) $https_port;
else if($db_info->https_port) unset($db_info->https_port);
unset($db_info->lang_type);
Context::setDBInfo($db_info);
$oInstallController = &getController('install');
$oInstallController->makeConfigFile();
if($default_url)
{
$site_args->site_srl = 0; $site_args->site_srl = 0;
$site_args->index_module_srl = Context::get('index_module_srl'); $site_args->domain = $default_url;
$oModuleController = &getController('module'); $oModuleController = &getController('module');
$oModuleController->updateSite($site_args); $oModuleController->updateSite($site_args);
}
$this->setRedirectUrl(Context::get('error_return_url'));
}
// get menu item info function procInstallAdminUpdateIndexModule()
$menuItemSrl = Context::get('menu_item_srl'); {
$oMenuAdminModel = &getAdminModel('menu'); if(!Context::get('index_module_srl') || !Context::get('menu_item_srl'))
$output = $oMenuAdminModel->getMenuItemInfo($menuItemSrl); {
return new Object(-1, 'msg_invalid_request');
}
// update homeSitemap.php cache file $site_args->site_srl = 0;
$oMenuAdminController = &getAdminController('menu'); $site_args->index_module_srl = Context::get('index_module_srl');
$homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile(); $oModuleController = &getController('module');
if(file_exists($homeMenuCacheFile)) $oModuleController->updateSite($site_args);
// get menu item info
$menuItemSrl = Context::get('menu_item_srl');
$oMenuAdminModel = &getAdminModel('menu');
$output = $oMenuAdminModel->getMenuItemInfo($menuItemSrl);
// update homeSitemap.php cache file
$oMenuAdminController = &getAdminController('menu');
$homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();
if(file_exists($homeMenuCacheFile))
{
@include($homeMenuCacheFile);
}
if(!$homeMenuSrl || $homeMenuSrl != $output->menu_srl)
{
$oMenuAdminController->makeHomemenuCacheFile($output->menu_srl);
}
$this->setMessage('success_updated');
}
function procInstallAdminRemoveFTPInfo()
{
$ftp_config_file = Context::getFTPConfigFile();
if(file_exists($ftp_config_file)) unlink($ftp_config_file);
if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']);
$this->setMessage('success_deleted');
}
function procInstallAdminSaveFTPInfo()
{
$ftp_info = Context::getFTPInfo();
$ftp_info->ftp_user = Context::get('ftp_user');
$ftp_info->ftp_port = Context::get('ftp_port');
$ftp_info->ftp_host = Context::get('ftp_host');
$ftp_info->ftp_pasv = Context::get('ftp_pasv');
if(!$ftp_info->ftp_pasv) $ftp_info->ftp_pasv = "N";
$ftp_info->sftp = Context::get('sftp');
$ftp_root_path = Context::get('ftp_root_path');
if(substr($ftp_root_path, strlen($ftp_root_path)-1) == "/")
{
$ftp_info->ftp_root_path = $ftp_root_path;
}
else
{
$ftp_info->ftp_root_path = $ftp_root_path.'/';
}
if(ini_get('safe_mode'))
{
$ftp_info->ftp_password = Context::get('ftp_password');
}
$buff = '<?php if(!defined("__ZBXE__")) exit();'."\n";
foreach($ftp_info as $key => $val)
{
if(!$val) continue;
if(preg_match('/(<\?|<\?php|\?>)/xsm', preg_replace('/\s/', '', $val)))
{ {
@include($homeMenuCacheFile); continue;
} }
$buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'","\\'",$val));
if(!$homeMenuSrl || $homeMenuSrl != $output->menu_srl)
{
$oMenuAdminController->makeHomemenuCacheFile($output->menu_srl);
}
$this->setMessage('success_updated');
} }
$buff .= "?>";
$config_file = Context::getFTPConfigFile();
FileHandler::WriteFile($config_file, $buff);
if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']);
function procInstallAdminRemoveFTPInfo() { $this->setMessage('success_updated');
$ftp_config_file = Context::getFTPConfigFile(); $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigFtp');
if(file_exists($ftp_config_file)) unlink($ftp_config_file); $this->setRedirectUrl($returnUrl);
if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']); }
$this->setMessage('success_deleted');
}
function procInstallAdminSaveFTPInfo() { function procInstallAdminConfig()
$ftp_info = Context::getFTPInfo(); {
$ftp_info->ftp_user = Context::get('ftp_user'); $use_mobile_view = Context::get('use_mobile_view');
$ftp_info->ftp_port = Context::get('ftp_port'); if($use_mobile_view!='Y') $use_mobile_view = 'N';
$ftp_info->ftp_host = Context::get('ftp_host');
$ftp_info->ftp_pasv = Context::get('ftp_pasv');
if(!$ftp_info->ftp_pasv) $ftp_info->ftp_pasv = "N";
$ftp_info->sftp = Context::get('sftp');
$ftp_root_path = Context::get('ftp_root_path'); $time_zone = Context::get('time_zone');
if (substr($ftp_root_path, strlen($ftp_root_path)-1) == "/") {
$ftp_info->ftp_root_path = $ftp_root_path;
} else {
$ftp_info->ftp_root_path = $ftp_root_path.'/';
}
if(ini_get('safe_mode')) { $db_info = Context::getDBInfo();
$ftp_info->ftp_password = Context::get('ftp_password'); $db_info->use_mobile_view = $use_mobile_view;
} $db_info->time_zone = $time_zone;
$buff = '<?php if(!defined("__ZBXE__")) exit();'."\n"; unset($db_info->lang_type);
foreach($ftp_info as $key => $val) { Context::setDBInfo($db_info);
if(!$val) continue; $oInstallController = &getController('install');
if(preg_match('/(<\?|<\?php|\?>)/xsm', preg_replace('/\s/', '', $val))) $oInstallController->makeConfigFile();
{
continue; $site_args->site_srl = 0;
} $site_args->index_module_srl = Context::get('index_module_srl');//
$buff .= sprintf("\$ftp_info->%s = '%s';\n", $key, str_replace("'","\\'",$val)); $site_args->default_language = Context::get('change_lang_type');//
} $oModuleController = &getController('module');
$buff .= "?>"; $oModuleController->updateSite($site_args);
$config_file = Context::getFTPConfigFile();
FileHandler::WriteFile($config_file, $buff); //언어 선택
if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']); $selected_lang = Context::get('selected_lang');
$this->saveLangSelected($selected_lang);
//모듈 설정 저장(썸네일, 풋터스크립트)
$config->thumbnail_type = Context::get('thumbnail_type');
$config->htmlFooter = Context::get('htmlFooter');
$config->siteTitle = Context::get('site_title');
$this->setModulesConfig($config);
//파비콘
$favicon = Context::get('favicon');
$this->saveIcon($favicon,'favicon.ico');
//모바일아이콘
$mobicon = Context::get('mobicon');
$this->saveIcon($mobicon,'mobicon.png');
$this->setRedirectUrl(Context::get('error_return_url'));
}
//from procInstallAdminSaveTimeZone
/**
* @brief Supported languages (was procInstallAdminSaveLangSelected)
*/
function saveLangSelected($selected_lang)
{
$langs = $selected_lang;
$lang_supported = Context::loadLangSupported();
$buff = null;
for($i=0;$i<count($langs);$i++)
{
$buff .= sprintf("%s,%s\n", $langs[$i], $lang_supported[$langs[$i]]);
$this->setMessage('success_updated');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigFtp');
$this->setRedirectUrl($returnUrl);
} }
FileHandler::writeFile(_XE_PATH_.'files/config/lang_selected.info', trim($buff));
//$this->setMessage('success_updated');
}
function procInstallAdminConfig(){ /* 썸내일 보여주기 방식 변경.*/
$use_mobile_view = Context::get('use_mobile_view'); function setModulesConfig($config)
if($use_mobile_view!='Y') $use_mobile_view = 'N'; {
$time_zone = Context::get('time_zone');
$db_info = Context::getDBInfo(); if(!$config->thumbnail_type || $config->thumbnail_type != 'ratio' ) $args->thumbnail_type = 'crop';
$db_info->use_mobile_view = $use_mobile_view; else $args->thumbnail_type = 'ratio';
$db_info->time_zone = $time_zone;
unset($db_info->lang_type); $oModuleController = &getController('module');
Context::setDBInfo($db_info); $oModuleController->insertModuleConfig('document',$args);
$oInstallController = &getController('install');
$oInstallController->makeConfigFile();
$site_args->site_srl = 0; unset($args);
$site_args->index_module_srl = Context::get('index_module_srl');//
$site_args->default_language = Context::get('change_lang_type');//
$oModuleController = &getController('module');
$oModuleController->updateSite($site_args);
//언어 선택 $args->htmlFooter = $config->htmlFooter;
$selected_lang = Context::get('selected_lang'); $args->siteTitle = $config->siteTitle;
$this->saveLangSelected($selected_lang); $oModuleController->insertModuleConfig('module',$args);
//모듈 설정 저장(썸네일, 풋터스크립트) return $output;
$config->thumbnail_type = Context::get('thumbnail_type'); }
$config->htmlFooter = Context::get('htmlFooter');
$config->siteTitle = Context::get('site_title');
$this->setModulesConfig($config);
//파비콘 function saveIcon($icon,$iconname)
$favicon = Context::get('favicon'); {
$this->saveIcon($favicon,'favicon.ico'); $mobicon_size = array('57','114');
$target_file = $icon['tmp_name'];
$type = $icon['type'];
$target_filename = _XE_PATH_.'files/attach/xeicon/'.$iconname;
//모바일아이콘 list($width, $height, $type_no, $attrs) = @getimagesize($target_file);
$mobicon = Context::get('mobicon'); if($iconname == 'favicon.ico' && preg_match('/^.*(icon).*$/',$type))
$this->saveIcon($mobicon,'mobicon.png'); {
$fitHeight = $fitWidth = '16';
$this->setRedirectUrl(Context::get('error_return_url'));
} }
else if($iconname == 'mobicon.png' && preg_match('/^.*(png).*$/',$type) && in_array($height,$mobicon_size) && in_array($width,$mobicon_size))
//from procInstallAdminSaveTimeZone {
/** $fitHeight = $fitWidth = $height;
* @brief Supported languages (was procInstallAdminSaveLangSelected)
**/
function saveLangSelected($selected_lang){
$langs = $selected_lang;
$lang_supported = Context::loadLangSupported();
$buff = null;
for($i=0;$i<count($langs);$i++) {
$buff .= sprintf("%s,%s\n", $langs[$i], $lang_supported[$langs[$i]]);
}
FileHandler::writeFile(_XE_PATH_.'files/config/lang_selected.info', trim($buff));
//$this->setMessage('success_updated');
} }
else
/* 썸내일 보여주기 방식 변경.*/ {
function setModulesConfig($config){ return false;
if(!$config->thumbnail_type || $config->thumbnail_type != 'ratio' ) $args->thumbnail_type = 'crop';
else $args->thumbnail_type = 'ratio';
$oModuleController = &getController('module');
$oModuleController->insertModuleConfig('document',$args);
unset($args);
$args->htmlFooter = $config->htmlFooter;
$args->siteTitle = $config->siteTitle;
$oModuleController->insertModuleConfig('module',$args);
return $output;
} }
//FileHandler::createImageFile($target_file, $target_filename, $fitHeight, $fitWidth, $ext);
FileHandler::copyFile($target_file, $target_filename);
}
function saveIcon($icon,$iconname){ }
$mobicon_size = array('57','114'); /* End of file install.admin.controller.php */
$target_file = $icon['tmp_name']; /* Location: ./modules/install/install.admin.controller.php */
$type = $icon['type'];
$target_filename = _XE_PATH_.'files/attach/xeicon/'.$iconname;
list($width, $height, $type_no, $attrs) = @getimagesize($target_file);
if($iconname == 'favicon.ico' && preg_match('/^.*(icon).*$/',$type)){
$fitHeight = $fitWidth = '16';
} else if($iconname == 'mobicon.png' && preg_match('/^.*(png).*$/',$type) && in_array($height,$mobicon_size) && in_array($width,$mobicon_size)) {
$fitHeight = $fitWidth = $height;
} else{
return false;
}
//FileHandler::createImageFile($target_file, $target_filename, $fitHeight, $fitWidth, $ext);
FileHandler::copyFile($target_file, $target_filename);
}
}
?>

View file

@ -1,37 +1,41 @@
<?php <?php
/** /**
* @class install * @class install
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief install module of the high class * @brief install module of the high class
**/ */
class install extends ModuleObject
{
/**
* @brief Implement if additional tasks are necessary when installing
*/
function moduleInstall()
{
return new Object();
}
class install extends ModuleObject { /**
* @brief a method to check if successfully installed
*/
function checkUpdate()
{
return false;
}
/** /**
* @brief Implement if additional tasks are necessary when installing * @brief Execute update
**/ */
function moduleInstall() { function moduleUpdate()
return new Object(); {
} return new Object();
}
/** /**
* @brief a method to check if successfully installed * @brief Re-generate the cache file
**/ */
function checkUpdate() { function recompileCache()
return false; {
} }
}
/** /* End of file install.class.php */
* @brief Execute update /* Location: ./modules/install/install.class.php */
**/
function moduleUpdate() {
return new Object();
}
/**
* @brief Re-generate the cache file
**/
function recompileCache() {
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
<?php <?php
class installModel extends install
class installModel extends install { {
var $pwd; var $pwd;
function getSFTPList() function getSFTPList()
@ -21,7 +21,8 @@ class installModel extends install {
$dh = @opendir($curpwd); $dh = @opendir($curpwd);
if(!$dh) return new Object(-1, 'msg_ftp_invalid_path'); if(!$dh) return new Object(-1, 'msg_ftp_invalid_path');
$list = array(); $list = array();
while(($file = readdir($dh)) !== false) { while(($file = readdir($dh)) !== false)
{
if(is_dir($curpwd.$file)) if(is_dir($curpwd.$file))
{ {
$file .= "/"; $file .= "/";
@ -77,8 +78,10 @@ class installModel extends install {
{ {
require_once(_XE_PATH_.'libs/ftp.class.php'); require_once(_XE_PATH_.'libs/ftp.class.php');
$oFtp = new ftp(); $oFtp = new ftp();
if($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)){ if($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
if($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) { {
if($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
{
$_list = $oFtp->ftp_rawlist($this->pwd); $_list = $oFtp->ftp_rawlist($this->pwd);
$oFtp->ftp_quit(); $oFtp->ftp_quit();
} }
@ -91,8 +94,10 @@ class installModel extends install {
} }
$list = array(); $list = array();
if($_list){ if($_list)
foreach($_list as $k => $v){ {
foreach($_list as $k => $v)
{
$src = null; $src = null;
$src->data = $v; $src->data = $v;
$res = Context::convertEncoding($src); $res = Context::convertEncoding($src);
@ -103,4 +108,5 @@ class installModel extends install {
$this->add('list', $list); $this->add('list', $list);
} }
} }
?> /* End of file install.model.php */
/* Location: ./modules/install/install.model.php */

View file

@ -1,140 +1,153 @@
<?php <?php
/** /**
* @class installView * @class installView
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief View class of install module * @brief View class of install module
**/ */
class installView extends install
{
var $install_enable = false;
class installView extends install { /**
* @brief Initialization
*/
function init()
{
// Set browser title
Context::setBrowserTitle(Context::getLang('introduce_title'));
// Specify the template path
$this->setTemplatePath($this->module_path.'tpl');
// Error occurs if already installed
if(Context::isInstalled()) return $this->stop('msg_already_installed');
// Install a controller
$oInstallController = &getController('install');
$this->install_enable = $oInstallController->checkInstallEnv();
// If the environment is installable, execute installController::makeDefaultDirectory()
if($this->install_enable) $oInstallController->makeDefaultDirectory();
}
var $install_enable = false; /**
* @brief Display license messages
/** */
* @brief Initialization function dispInstallIntroduce()
**/ {
function init() { $install_config_file = FileHandler::getRealPath('./config/install.config.php');
// Set browser title if(file_exists($install_config_file))
Context::setBrowserTitle(Context::getLang('introduce_title'));
// Specify the template path
$this->setTemplatePath($this->module_path.'tpl');
// Error occurs if already installed
if(Context::isInstalled()) return $this->stop('msg_already_installed');
// Install a controller
$oInstallController = &getController('install');
$this->install_enable = $oInstallController->checkInstallEnv();
// If the environment is installable, execute installController::makeDefaultDirectory()
if($this->install_enable) $oInstallController->makeDefaultDirectory();
}
/**
* @brief Display license messages
**/
function dispInstallIntroduce() {
$install_config_file = FileHandler::getRealPath('./config/install.config.php');
if(file_exists($install_config_file)){
include $install_config_file;
if(is_array($install_config)){
foreach($install_config as $k => $v)
{
$v = ($k == 'db_table_prefix') ? $v.'_' : $v;
Context::set($k,$v,true);
}
unset($GLOBALS['__DB__']);
Context::set('install_config', true, true);
$oInstallController = &getController('install');
$output = $oInstallController->procInstall();
if (!$output->toBool()) return $output;
header("location: ./");
Context::close();
exit;
}
}
Context::set('l', Context::getLangType());
$this->setTemplateFile('introduce');
}
/**
* @brief Display messages about installation environment
**/
function dispInstallCheckEnv() {
$useRewrite = $this->useRewriteModule() ? 'Y' : 'N';
$_SESSION['use_rewrite'] = $useRewrite;
Context::set('use_rewrite', $useRewrite);
$this->setTemplateFile('check_env');
}
/**
* @brief Choose a DB
**/
function dispInstallSelectDB() {
// Display check_env if it is not installable
if(!$this->install_enable) return $this->dispInstallCheckEnv();
// Enter ftp information
if(ini_get('safe_mode') && !Context::isFTPRegisted()) {
Context::set('progressMenu', '3');
$this->setTemplateFile('ftp');
} else {
Context::set('progressMenu', '4');
$this->setTemplateFile('select_db');
}
}
/**
* @brief Display a screen to enter DB and administrator's information
**/
function dispInstallDBForm() {
// Display check_env if not installable
if(!$this->install_enable) return $this->dispInstallCheckEnv();
// Return to the start-up screen if db_type is not specified
if(!Context::get('db_type')) return $this->dispInstallSelectDB();
// Output the file, disp_db_info_form.html
$tpl_filename = sprintf('form.%s', Context::get('db_type'));
$this->setTemplateFile($tpl_filename);
}
/**
* @brief Display a screen to enter DB and administrator's information
**/
function dispInstallConfigForm() {
// Display check_env if not installable
if(!$this->install_enable) return $this->dispInstallCheckEnv();
include _XE_PATH_.'files/config/tmpDB.config.php';
Context::set('use_rewrite', $_SESSION['use_rewrite']);
Context::set('time_zone', $GLOBALS['time_zone']);
Context::set('db_type', $db_info->db_type);
$this->setTemplateFile('config_form');
}
function useRewriteModule()
{ {
if(function_exists('apache_get_modules') && in_array('mod_rewrite',apache_get_modules())) include $install_config_file;
if(is_array($install_config))
{ {
return true; foreach($install_config as $k => $v)
{
$v = ($k == 'db_table_prefix') ? $v.'_' : $v;
Context::set($k,$v,true);
}
unset($GLOBALS['__DB__']);
Context::set('install_config', true, true);
$oInstallController = &getController('install');
$output = $oInstallController->procInstall();
if (!$output->toBool()) return $output;
header("location: ./");
Context::close();
exit;
} }
require_once(_XE_PATH_.'classes/httprequest/XEHttpRequest.class.php');
$httpRequest = new XEHttpRequest($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT']);
$xeInstallPath = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php', 1));
$output = $httpRequest->send($xeInstallPath.'modules/install/conf/info.xml');
return (strpos($output->body, '<?xml') !== 0);
} }
/** Context::set('l', Context::getLangType());
* @brief Display a screen to enter DB and administrator's information $this->setTemplateFile('introduce');
**/ }
function dispInstallManagerForm() {
// Display check_env if not installable
if(!$this->install_enable) {
return $this->dispInstallCheckEnv();
}
$this->setTemplateFile('admin_form'); /**
} * @brief Display messages about installation environment
} */
?> function dispInstallCheckEnv()
{
$useRewrite = $this->useRewriteModule() ? 'Y' : 'N';
$_SESSION['use_rewrite'] = $useRewrite;
Context::set('use_rewrite', $useRewrite);
$this->setTemplateFile('check_env');
}
/**
* @brief Choose a DB
*/
function dispInstallSelectDB()
{
// Display check_env if it is not installable
if(!$this->install_enable) return $this->dispInstallCheckEnv();
// Enter ftp information
if(ini_get('safe_mode') && !Context::isFTPRegisted())
{
Context::set('progressMenu', '3');
$this->setTemplateFile('ftp');
}
else
{
Context::set('progressMenu', '4');
$this->setTemplateFile('select_db');
}
}
/**
* @brief Display a screen to enter DB and administrator's information
*/
function dispInstallDBForm()
{
// Display check_env if not installable
if(!$this->install_enable) return $this->dispInstallCheckEnv();
// Return to the start-up screen if db_type is not specified
if(!Context::get('db_type')) return $this->dispInstallSelectDB();
// Output the file, disp_db_info_form.html
$tpl_filename = sprintf('form.%s', Context::get('db_type'));
$this->setTemplateFile($tpl_filename);
}
/**
* @brief Display a screen to enter DB and administrator's information
*/
function dispInstallConfigForm()
{
// Display check_env if not installable
if(!$this->install_enable) return $this->dispInstallCheckEnv();
include _XE_PATH_.'files/config/tmpDB.config.php';
Context::set('use_rewrite', $_SESSION['use_rewrite']);
Context::set('time_zone', $GLOBALS['time_zone']);
Context::set('db_type', $db_info->db_type);
$this->setTemplateFile('config_form');
}
function useRewriteModule()
{
if(function_exists('apache_get_modules') && in_array('mod_rewrite',apache_get_modules()))
{
return true;
}
require_once(_XE_PATH_.'classes/httprequest/XEHttpRequest.class.php');
$httpRequest = new XEHttpRequest($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT']);
$xeInstallPath = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php', 1));
$output = $httpRequest->send($xeInstallPath.'modules/install/conf/info.xml');
return (strpos($output->body, '<?xml') !== 0);
}
/**
* @brief Display a screen to enter DB and administrator's information
*/
function dispInstallManagerForm()
{
// Display check_env if not installable
if(!$this->install_enable)
{
return $this->dispInstallCheckEnv();
}
$this->setTemplateFile('admin_form');
}
}
/* End of file install.view.php */
/* Location: ./modules/install/install.view.php */

View file

@ -1,116 +1,126 @@
<?php <?php
/** /**
* The admin view class of the integration_search module * The admin view class of the integration_search module
*
* @author NHN (developers@xpressengine.com)
*/
class integration_searchAdminController extends integration_search
{
/**
* Initialization
* *
* @author NHN (developers@xpressengine.com) * @return void
**/ */
function init()
{
}
class integration_searchAdminController extends integration_search { /**
/** * Save Settings
* Initialization *
* * @return mixed
* @return void */
**/ function procIntegration_searchAdminInsertConfig()
function init() {
// Get configurations (using module model object)
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('integration_search');
$args->skin = Context::get('skin');
$args->target = Context::get('target');
$args->target_module_srl = Context::get('target_module_srl');
if(!$args->target_module_srl) $args->target_module_srl = '';
$args->skin_vars = $config->skin_vars;
$oModuleController = &getController('module');
$output = $oModuleController->insertModuleConfig('integration_search',$args);
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispIntegration_searchAdminContent');
return $this->setRedirectUrl($returnUrl, $output);
}
/**
* Save the skin information
*
* @return mixed
*/
function procIntegration_searchAdminInsertSkin()
{
// Get configurations (using module model object)
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('integration_search');
$args->skin = $config->skin;
$args->target_module_srl = $config->target_module_srl;
// Get skin information (to check extra_vars)
$skin_info = $oModuleModel->loadSkinInfo($this->module_path, $config->skin);
// Check received variables (delete the basic variables such as mo, act, module_srl, page)
$obj = Context::getRequestVars();
unset($obj->act);
unset($obj->module_srl);
unset($obj->page);
// Separately handle if the extra_vars is an image type in the original skin_info
if($skin_info->extra_vars)
{ {
foreach($skin_info->extra_vars as $vars)
{
if($vars->type!='image') continue;
$image_obj = $obj->{$vars->name};
// Get a variable on a request to delete
$del_var = $obj->{"del_".$vars->name};
unset($obj->{"del_".$vars->name});
if($del_var == 'Y')
{
FileHandler::removeFile($module_info->{$vars->name});
continue;
}
// Use the previous data if not uploaded
if(!$image_obj['tmp_name'])
{
$obj->{$vars->name} = $module_info->{$vars->name};
continue;
}
// Ignore if the file is not successfully uploaded
if(!is_uploaded_file($image_obj['tmp_name']))
{
unset($obj->{$vars->name});
continue;
}
// Ignore if the file is not an image
if(!preg_match("/\.(jpg|jpeg|gif|png)$/i", $image_obj['name']))
{
unset($obj->{$vars->name});
continue;
}
// Upload the file to a path
$path = sprintf("./files/attach/images/%s/", $module_srl);
// Create a directory
if(!FileHandler::makeDir($path)) return false;
$filename = $path.$image_obj['name'];
// Move the file
if(!move_uploaded_file($image_obj['tmp_name'], $filename))
{
unset($obj->{$vars->name});
continue;
}
// Change a variable
unset($obj->{$vars->name});
$obj->{$vars->name} = $filename;
}
} }
// Serialize and save
$args->skin_vars = serialize($obj);
/** $oModuleController = &getController('module');
* Save Settings $output = $oModuleController->insertModuleConfig('integration_search',$args);
*
* @return mixed
**/
function procIntegration_searchAdminInsertConfig() {
// Get configurations (using module model object)
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('integration_search');
$args->skin = Context::get('skin'); $this->setMessage('success_updated', 'info');
$args->target = Context::get('target');
$args->target_module_srl = Context::get('target_module_srl');
if(!$args->target_module_srl) $args->target_module_srl = '';
$args->skin_vars = $config->skin_vars;
$oModuleController = &getController('module'); $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispIntegration_searchAdminSkinInfo');
$output = $oModuleController->insertModuleConfig('integration_search',$args); return $this->setRedirectUrl($returnUrl, $output);
}
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispIntegration_searchAdminContent'); }
return $this->setRedirectUrl($returnUrl, $output); /* End of file integration_search.admin.controller.php */
} /* Location: ./modules/integration_search/integration_search.admin.controller.php */
/**
* Save the skin information
*
* @return mixed
**/
function procIntegration_searchAdminInsertSkin() {
// Get configurations (using module model object)
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('integration_search');
$args->skin = $config->skin;
$args->target_module_srl = $config->target_module_srl;
// Get skin information (to check extra_vars)
$skin_info = $oModuleModel->loadSkinInfo($this->module_path, $config->skin);
// Check received variables (delete the basic variables such as mo, act, module_srl, page)
$obj = Context::getRequestVars();
unset($obj->act);
unset($obj->module_srl);
unset($obj->page);
// Separately handle if the extra_vars is an image type in the original skin_info
if($skin_info->extra_vars) {
foreach($skin_info->extra_vars as $vars) {
if($vars->type!='image') continue;
$image_obj = $obj->{$vars->name};
// Get a variable on a request to delete
$del_var = $obj->{"del_".$vars->name};
unset($obj->{"del_".$vars->name});
if($del_var == 'Y') {
FileHandler::removeFile($module_info->{$vars->name});
continue;
}
// Use the previous data if not uploaded
if(!$image_obj['tmp_name']) {
$obj->{$vars->name} = $module_info->{$vars->name};
continue;
}
// Ignore if the file is not successfully uploaded
if(!is_uploaded_file($image_obj['tmp_name'])) {
unset($obj->{$vars->name});
continue;
}
// Ignore if the file is not an image
if(!preg_match("/\.(jpg|jpeg|gif|png)$/i", $image_obj['name'])) {
unset($obj->{$vars->name});
continue;
}
// Upload the file to a path
$path = sprintf("./files/attach/images/%s/", $module_srl);
// Create a directory
if(!FileHandler::makeDir($path)) return false;
$filename = $path.$image_obj['name'];
// Move the file
if(!move_uploaded_file($image_obj['tmp_name'], $filename)) {
unset($obj->{$vars->name});
continue;
}
// Change a variable
unset($obj->{$vars->name});
$obj->{$vars->name} = $filename;
}
}
// Serialize and save
$args->skin_vars = serialize($obj);
$oModuleController = &getController('module');
$output = $oModuleController->insertModuleConfig('integration_search',$args);
$this->setMessage('success_updated', 'info');
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispIntegration_searchAdminSkinInfo');
return $this->setRedirectUrl($returnUrl, $output);
}
}
?>

View file

@ -1,99 +1,104 @@
<?php <?php
/** /**
* The admin view class of the integration_search module * The admin view class of the integration_search module
* *
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
class integration_searchAdminView extends integration_search
class integration_searchAdminView extends integration_search { {
/** /**
* Cofiguration of integration serach module * Cofiguration of integration serach module
* *
* @var object module config * @var object module config
*/ */
var $config = null; var $config = null;
/** /**
* Initialization * Initialization
* *
* @return void * @return void
**/ */
function init() { function init()
// Get configurations (using module model object) {
$oModuleModel = &getModel('module'); // Get configurations (using module model object)
$this->config = $oModuleModel->getModuleConfig('integration_search'); $oModuleModel = &getModel('module');
Context::set('config',$this->config); $this->config = $oModuleModel->getModuleConfig('integration_search');
Context::set('config',$this->config);
$this->setTemplatePath($this->module_path."/tpl/");
}
/** $this->setTemplatePath($this->module_path."/tpl/");
* Module selection and skin set }
*
* @return Object
**/
function dispIntegration_searchAdminContent() {
// Get a list of skins(themes)
$oModuleModel = &getModel('module');
$skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list',$skin_list);
// Get a list of module categories
$module_categories = $oModuleModel->getModuleCategories();
// Generated mid Wanted list
$obj->site_srl = 0;
// Shown below as obsolete comments - modify by cherryfilter /**
/*$mid_list = $oModuleModel->getMidList($obj); * Module selection and skin set
// module_category and module combination *
if($module_categories) { * @return Object
foreach($mid_list as $module_srl => $module) { */
$module_categories[$module->module_category_srl]->list[$module_srl] = $module; function dispIntegration_searchAdminContent()
} {
} else { // Get a list of skins(themes)
$module_categories[0]->list = $mid_list; $oModuleModel = &getModel('module');
} $skin_list = $oModuleModel->getSkins($this->module_path);
Context::set('skin_list',$skin_list);
// Get a list of module categories
$module_categories = $oModuleModel->getModuleCategories();
// Generated mid Wanted list
$obj->site_srl = 0;
Context::set('mid_list',$module_categories);*/ // Shown below as obsolete comments - modify by cherryfilter
/*$mid_list = $oModuleModel->getMidList($obj);
// module_category and module combination
if($module_categories) {
foreach($mid_list as $module_srl => $module) {
$module_categories[$module->module_category_srl]->list[$module_srl] = $module;
}
} else {
$module_categories[0]->list = $mid_list;
}
$security = new Security(); Context::set('mid_list',$module_categories);*/
$security->encodeHTML('skin_list..title');
// Sample Code $security = new Security();
Context::set('sample_code', htmlspecialchars('<form action="{getUrl()}" method="get"><input type="hidden" name="vid" value="{$vid}" /><input type="hidden" name="mid" value="{$mid}" /><input type="hidden" name="act" value="IS" /><input type="text" name="is_keyword" value="{$is_keyword}" /><span class="btn"><input type="submit" value="{$lang->cmd_search}" /></span></form>') ); $security->encodeHTML('skin_list..title');
$this->setTemplateFile("index"); // Sample Code
} Context::set('sample_code', htmlspecialchars('<form action="{getUrl()}" method="get"><input type="hidden" name="vid" value="{$vid}" /><input type="hidden" name="mid" value="{$mid}" /><input type="hidden" name="act" value="IS" /><input type="text" name="is_keyword" value="{$is_keyword}" /><span class="btn"><input type="submit" value="{$lang->cmd_search}" /></span></form>') );
/** $this->setTemplateFile("index");
* Skin Settings }
*
* @return Object
**/
function dispIntegration_searchAdminSkinInfo() {
$oModuleModel = &getModel('module');
$skin_info = $oModuleModel->loadSkinInfo($this->module_path, $this->config->skin);
$skin_vars = unserialize($this->config->skin_vars);
// value for skin_info extra_vars
if(count($skin_info->extra_vars)) {
foreach($skin_info->extra_vars as $key => $val) {
$name = $val->name;
$type = $val->type;
$value = $skin_vars->{$name};
if($type=="checkbox"&&!$value) $value = array();
$skin_info->extra_vars[$key]->value= $value;
}
}
Context::set('skin_info', $skin_info);
Context::set('skin_vars', $skin_vars);
$config = $oModuleModel->getModuleConfig('integration_search'); /**
Context::set('module_info', unserialize($config->skin_vars)); * Skin Settings
*
$security = new Security(); * @return Object
$security->encodeHTML('skin_info...'); */
function dispIntegration_searchAdminSkinInfo()
$this->setTemplateFile("skin_info"); {
} $oModuleModel = &getModel('module');
} $skin_info = $oModuleModel->loadSkinInfo($this->module_path, $this->config->skin);
?> $skin_vars = unserialize($this->config->skin_vars);
// value for skin_info extra_vars
if(count($skin_info->extra_vars))
{
foreach($skin_info->extra_vars as $key => $val)
{
$name = $val->name;
$type = $val->type;
$value = $skin_vars->{$name};
if($type=="checkbox"&&!$value) $value = array();
$skin_info->extra_vars[$key]->value= $value;
}
}
Context::set('skin_info', $skin_info);
Context::set('skin_vars', $skin_vars);
$config = $oModuleModel->getModuleConfig('integration_search');
Context::set('module_info', unserialize($config->skin_vars));
$security = new Security();
$security->encodeHTML('skin_info...');
$this->setTemplateFile("skin_info");
}
}
/* End of file integration_search.admin.view.php */
/* Location: ./modules/integration_search/integration_search.admin.view.php */

View file

@ -1,81 +1,83 @@
<?php <?php
/** /**
* The view class of the integration_search module * The view class of the integration_search module
*
* @author NHN (developers@xpressengine.com)
*/
class integration_search extends ModuleObject
{
/**
* Implement if additional tasks are necessary when installing
* *
* @author NHN (developers@xpressengine.com) * @return Object
**/ */
function moduleInstall()
{
// Registered in action forward
$oModuleController = &getController('module');
$oModuleController->insertActionForward('integration_search', 'view', 'IS');
class integration_search extends ModuleObject { return new Object();
}
/** /**
* Implement if additional tasks are necessary when installing * Check methoda whether successfully installed
* *
* @return Object * @return bool
**/ */
function moduleInstall() { function checkUpdate()
// Registered in action forward {
$oModuleController = &getController('module'); $oModuleModel = &getModel('module');
$oModuleController->insertActionForward('integration_search', 'view', 'IS'); $config = $oModuleModel->getModuleConfig('integration_search');
return new Object(); if($config->skin)
}
/**
* Check methoda whether successfully installed
*
* @return bool
**/
function checkUpdate()
{ {
$oModuleModel = &getModel('module'); $config_parse = explode('.', $config->skin);
$config = $oModuleModel->getModuleConfig('integration_search'); if(count($config_parse) > 1)
if($config->skin)
{ {
$config_parse = explode('.', $config->skin); $template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]);
if (count($config_parse) > 1) if(is_dir($template_path)) return true;
}
}
return false;
}
/**
* Execute update
*
* @return Object
*/
function moduleUpdate()
{
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('message');
if($config->skin)
{
$config_parse = explode('.', $config->skin);
if(count($config_parse) > 1)
{
$template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]);
if(is_dir($template_path))
{ {
$template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]); $config->skin = implode('|@|', $config_parse);
if(is_dir($template_path)) return true; $oModuleController = &getController('module');
$oModuleController->updateModuleConfig('integration_search', $config);
} }
} }
return false; }
}
/** return new Object(0, 'success_updated');
* Execute update }
*
* @return Object
**/
function moduleUpdate()
{
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('message');
if($config->skin) /**
{ * Re-generate the cache file
$config_parse = explode('.', $config->skin); *
if (count($config_parse) > 1) * @return void
{ */
$template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]); function recompileCache()
if(is_dir($template_path)) {
{ }
$config->skin = implode('|@|', $config_parse); }
$oModuleController = &getController('module'); /* End of file integration_search.class.php */
$oModuleController->updateModuleConfig('integration_search', $config); /* Location: ./modules/integration_search/integration_search.class.php */
}
}
}
return new Object(0, 'success_updated');
}
/**
* Re-generate the cache file
*
* @return void
**/
function recompileCache() {
}
}
?>

View file

@ -1,246 +1,270 @@
<?php <?php
/** /**
* The model class of integration module * The model class of integration module
*
* @author NHN (developers@xpressengine.com)
*/
class integration_searchModel extends module
{
/**
* Initialization
* *
* @author NHN (developers@xpressengine.com) * @return void
**/ */
function init()
{
}
class integration_searchModel extends module { /**
/** * Search documents
* Initialization *
* * @param string $target choose target. exclude or include for $module_srls_list
* @return void * @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038
**/ * @param string $search_target Target
function init() { * @param string $search_keyword Keyword
} * @param integer $page page of page navigation
* @param integer $list_count list count of page navigation
*
* @return Object output document list
*/
function getDocuments($target, $module_srls_list, $search_target, $search_keyword, $page=1, $list_count = 20)
{
if(is_array($module_srls_list)) $module_srls_list = implode(',',$module_srls_list);
/** if($target == 'exclude')
* Search documents {
* $module_srls_list .= ',0'; // exclude 'trash'
* @param string $target choose target. exclude or include for $module_srls_list if ($module_srls_list{0} == ',') $module_srls_list = substr($module_srls_list, 1);
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038 $args->exclude_module_srl = $module_srls_list;
* @param string $search_target Target }
* @param string $search_keyword Keyword else
* @param integer $page page of page navigation {
* @param integer $list_count list count of page navigation $args->module_srl = $module_srls_list;
* $args->exclude_module_srl = '0'; // exclude 'trash'
* @return Object output document list }
**/
function getDocuments($target, $module_srls_list, $search_target, $search_keyword, $page=1, $list_count = 20) {
if(is_array($module_srls_list)) $module_srls_list = implode(',',$module_srls_list);
if($target == 'exclude') { $args->page = $page;
$module_srls_list .= ',0'; // exclude 'trash' $args->list_count = $list_count;
if ($module_srls_list{0} == ',') $module_srls_list = substr($module_srls_list, 1); $args->page_count = 10;
$args->exclude_module_srl = $module_srls_list; $args->search_target = $search_target;
} else { $args->search_keyword = $search_keyword;
$args->module_srl = $module_srls_list; $args->sort_index = 'list_order';
$args->exclude_module_srl = '0'; // exclude 'trash' $args->order_type = 'asc';
} $args->statusList = array('PUBLIC');
if(!$args->module_srl) unset($args->module_srl);
// Get a list of documents
$oDocumentModel = &getModel('document');
$args->page = $page; return $oDocumentModel->getDocumentList($args);
$args->list_count = $list_count; }
$args->page_count = 10;
$args->search_target = $search_target;
$args->search_keyword = $search_keyword;
$args->sort_index = 'list_order';
$args->order_type = 'asc';
$args->statusList = array('PUBLIC');
if(!$args->module_srl) unset($args->module_srl);
// Get a list of documents
$oDocumentModel = &getModel('document');
return $oDocumentModel->getDocumentList($args); /**
} * Search comment
*
* @param string $target choose target. exclude or include for $module_srls_list
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038
* @param string $search_keyword Keyword
* @param integer $page page of page navigation
* @param integer $list_count list count of page navigation
*
* @return Object output comment list
*/
function getComments($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20)
{
if(is_array($module_srls_list))
{
if (count($module_srls_list) > 0) $module_srls = implode(',',$module_srls_list);
else $module_srls = 0;
}
else
{
$module_srls = ($module_srls_list)?$module_srls_list:0;
}
if($target == 'exclude') $args->exclude_module_srl = $module_srls;
else $args->module_srl = $module_srls;
/** $args->page = $page;
* Search comment $args->list_count = $list_count;
* $args->page_count = 10;
* @param string $target choose target. exclude or include for $module_srls_list $args->search_target = 'content';
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038 $args->search_keyword = $search_keyword;
* @param string $search_keyword Keyword $args->sort_index = 'list_order';
* @param integer $page page of page navigation $args->order_type = 'asc';
* @param integer $list_count list count of page navigation // Get a list of documents
* $oCommentModel = &getModel('comment');
* @return Object output comment list $output = $oCommentModel->getTotalCommentList($args);
**/ if(!$output->toBool()|| !$output->data) return $output;
function getComments($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20) { return $output;
if(is_array($module_srls_list)){ }
if (count($module_srls_list) > 0) $module_srls = implode(',',$module_srls_list);
else $module_srls = 0; /**
* Search trackbacks
*
* @param string $target choose target. exclude or include for $module_srls_list
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038
* @param string $search_target Target
* @param string $search_keyword Keyword
* @param integer $page page of page navigation
* @param integer $list_count list count of page navigation
*
* @return Object output trackback list
*/
function getTrackbacks($target, $module_srls_list, $search_target = "title", $search_keyword, $page=1, $list_count = 20)
{
if(is_array($module_srls_list)) $module_srls = implode(',',$module_srls_list);
else $module_srls = $module_srls_list;
if($target == 'exclude') $args->exclude_module_srl = $module_srls;
else $args->module_srl = $module_srls;
$args->page = $page;
$args->list_count = $list_count;
$args->page_count = 10;
$args->search_target = $search_target;
$args->search_keyword = $search_keyword;
$args->sort_index = 'list_order';
$args->order_type = 'asc';
// Get a list of documents
$oTrackbackModel = &getAdminModel('trackback');
$output = $oTrackbackModel->getTotalTrackbackList($args);
if(!$output->toBool()|| !$output->data) return $output;
return $output;
}
/**
* Search file
*
* @param string $target choose target. exclude or include for $module_srls_list
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038
* @param string $search_keyword Keyword
* @param integer $page page of page navigation
* @param integer $list_count list count of page navigation
* @param string $direct_download Y or N
*
* @return Object output file list
*/
function _getFiles($target, $module_srls_list, $search_keyword, $page, $list_count, $direct_download = 'Y')
{
if(is_array($module_srls_list)) $module_srls = implode(',',$module_srls_list);
else $module_srls = $module_srls_list;
if($target == 'exclude') $args->exclude_module_srl = $module_srls;
else $args->module_srl = $module_srls;
$args->page = $page;
$args->list_count = $list_count;
$args->page_count = 10;
$args->search_target = 'filename';
$args->search_keyword = $search_keyword;
$args->sort_index = 'files.file_srl';
$args->order_type = 'desc';
$args->isvalid = 'Y';
$args->direct_download = $direct_download=='Y'?'Y':'N';
// Get a list of documents
$oFileAdminModel = &getAdminModel('file');
$output = $oFileAdminModel->getFileList($args);
if(!$output->toBool() || !$output->data) return $output;
$list = array();
foreach($output->data as $key => $val)
{
$obj = null;
$obj->filename = $val->source_filename;
$obj->download_count = $val->download_count;
if(substr($val->download_url,0,2)=='./') $val->download_url = substr($val->download_url,2);
$obj->download_url = Context::getRequestUri().$val->download_url;
$obj->target_srl = $val->upload_target_srl;
$obj->file_size = $val->file_size;
// Images
if(preg_match('/\.(jpg|jpeg|gif|png)$/i', $val->source_filename))
{
$obj->type = 'image';
$thumbnail_path = sprintf('files/cache/thumbnails/%s',getNumberingPath($val->file_srl, 3));
if(!is_dir($thumbnail_path)) FileHandler::makeDir($thumbnail_path);
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, 120, 120, 'crop');
$thumbnail_url = Context::getRequestUri().$thumbnail_file;
if(!file_exists($thumbnail_file)) FileHandler::createImageFile($val->uploaded_filename, $thumbnail_file, 120, 120, 'jpg', 'crop');
$obj->src = sprintf('<img src="%s" alt="%s" width="%d" height="%d" />', $thumbnail_url, htmlspecialchars($obj->filename), 120, 120);
// Videos
} }
else { else if(preg_match('/\.(swf|flv|wmv|avi|mpg|mpeg|asx|asf|mp3)$/i', $val->source_filename))
$module_srls = ($module_srls_list)?$module_srls_list:0; {
$obj->type = 'multimedia';
$obj->src = sprintf('<script>displayMultimedia("%s",120,120);</script>', $obj->download_url);
// Others
}
else
{
$obj->type = 'binary';
$obj->src = '';
} }
if($target == 'exclude') $args->exclude_module_srl = $module_srls;
else $args->module_srl = $module_srls;
$args->page = $page; $list[] = $obj;
$args->list_count = $list_count; $target_list[] = $val->upload_target_srl;
$args->page_count = 10; }
$args->search_target = 'content'; $output->data = $list;
$args->search_keyword = $search_keyword;
$args->sort_index = 'list_order';
$args->order_type = 'asc';
// Get a list of documents
$oCommentModel = &getModel('comment');
$output = $oCommentModel->getTotalCommentList($args);
if(!$output->toBool()|| !$output->data) return $output;
return $output;
}
/** $oDocumentModel = &getModel('document');
* Search trackbacks $document_list = $oDocumentModel->getDocuments($target_list);
* if($document_list) foreach($document_list as $key => $val)
* @param string $target choose target. exclude or include for $module_srls_list {
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038 foreach($output->data as $k => $v)
* @param string $search_target Target {
* @param string $search_keyword Keyword if($v->target_srl== $val->document_srl)
* @param integer $page page of page navigation {
* @param integer $list_count list count of page navigation $output->data[$k]->url = $val->getPermanentUrl();
* $output->data[$k]->regdate = $val->getRegdate("Y-m-d H:i");
* @return Object output trackback list $output->data[$k]->nick_name = $val->getNickName();
**/ }
function getTrackbacks($target, $module_srls_list, $search_target = "title", $search_keyword, $page=1, $list_count = 20) { }
if(is_array($module_srls_list)) $module_srls = implode(',',$module_srls_list); }
else $module_srls = $module_srls_list;
if($target == 'exclude') $args->exclude_module_srl = $module_srls;
else $args->module_srl = $module_srls;
$args->page = $page;
$args->list_count = $list_count;
$args->page_count = 10;
$args->search_target = $search_target;
$args->search_keyword = $search_keyword;
$args->sort_index = 'list_order';
$args->order_type = 'asc';
// Get a list of documents
$oTrackbackModel = &getAdminModel('trackback');
$output = $oTrackbackModel->getTotalTrackbackList($args);
if(!$output->toBool()|| !$output->data) return $output;
return $output;
}
/** $oCommentModel = &getModel('comment');
* Search file $comment_list = $oCommentModel->getComments($target_list);
* if($comment_list) foreach($comment_list as $key => $val)
* @param string $target choose target. exclude or include for $module_srls_list {
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038 foreach($output->data as $k => $v)
* @param string $search_keyword Keyword {
* @param integer $page page of page navigation if($v->target_srl== $val->comment_srl)
* @param integer $list_count list count of page navigation {
* @param string $direct_download Y or N $output->data[$k]->url = $val->getPermanentUrl();
* $output->data[$k]->regdate = $val->getRegdate("Y-m-d H:i");
* @return Object output file list $output->data[$k]->nick_name = $val->getNickName();
**/ }
function _getFiles($target, $module_srls_list, $search_keyword, $page, $list_count, $direct_download = 'Y') { }
if(is_array($module_srls_list)) $module_srls = implode(',',$module_srls_list); }
else $module_srls = $module_srls_list;
if($target == 'exclude') $args->exclude_module_srl = $module_srls;
else $args->module_srl = $module_srls;
$args->page = $page;
$args->list_count = $list_count;
$args->page_count = 10;
$args->search_target = 'filename';
$args->search_keyword = $search_keyword;
$args->sort_index = 'files.file_srl';
$args->order_type = 'desc';
$args->isvalid = 'Y';
$args->direct_download = $direct_download=='Y'?'Y':'N';
// Get a list of documents
$oFileAdminModel = &getAdminModel('file');
$output = $oFileAdminModel->getFileList($args);
if(!$output->toBool() || !$output->data) return $output;
$list = array(); return $output;
foreach($output->data as $key => $val) { }
$obj = null;
$obj->filename = $val->source_filename;
$obj->download_count = $val->download_count;
if(substr($val->download_url,0,2)=='./') $val->download_url = substr($val->download_url,2);
$obj->download_url = Context::getRequestUri().$val->download_url;
$obj->target_srl = $val->upload_target_srl;
$obj->file_size = $val->file_size;
// Images
if(preg_match('/\.(jpg|jpeg|gif|png)$/i', $val->source_filename)) {
$obj->type = 'image';
$thumbnail_path = sprintf('files/cache/thumbnails/%s',getNumberingPath($val->file_srl, 3)); /**
if(!is_dir($thumbnail_path)) FileHandler::makeDir($thumbnail_path); * Search Multimedia. call function _getFiles().
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, 120, 120, 'crop'); *
$thumbnail_url = Context::getRequestUri().$thumbnail_file; * @param string $target choose target. exclude or include for $module_srls_list
if(!file_exists($thumbnail_file)) FileHandler::createImageFile($val->uploaded_filename, $thumbnail_file, 120, 120, 'jpg', 'crop'); * @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038
$obj->src = sprintf('<img src="%s" alt="%s" width="%d" height="%d" />', $thumbnail_url, htmlspecialchars($obj->filename), 120, 120); * @param string $search_keyword Keyword
// Videos * @param integer $page page of page navigation
} elseif(preg_match('/\.(swf|flv|wmv|avi|mpg|mpeg|asx|asf|mp3)$/i', $val->source_filename)) { * @param integer $list_count list count of page navigation
$obj->type = 'multimedia'; *
$obj->src = sprintf('<script>displayMultimedia("%s",120,120);</script>', $obj->download_url); * @return Object
// Others */
} else { function getImages($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20)
$obj->type = 'binary'; {
$obj->src = ''; return $this->_getFiles($target, $module_srls_list, $search_keyword, $page, $list_count);
} }
$list[] = $obj; /**
$target_list[] = $val->upload_target_srl; * Search for attachments. call function _getFiles().
} *
$output->data = $list; * @param string $target choose target. exclude or include for $module_srls_list
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038
$oDocumentModel = &getModel('document'); * @param string $search_keyword Keyword
$document_list = $oDocumentModel->getDocuments($target_list); * @param integer $page page of page navigation
if($document_list) foreach($document_list as $key => $val) { * @param integer $list_count list count of page navigation
foreach($output->data as $k => $v) { *
if($v->target_srl== $val->document_srl) { * @return Object
$output->data[$k]->url = $val->getPermanentUrl(); */
$output->data[$k]->regdate = $val->getRegdate("Y-m-d H:i"); function getFiles($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20)
$output->data[$k]->nick_name = $val->getNickName(); {
} return $this->_getFiles($target, $module_srls_list, $search_keyword, $page, $list_count, 'N');
} }
} }
/* End of file integration_search.model.php */
$oCommentModel = &getModel('comment'); /* Location: ./modules/integration_search/integration_search.model.php */
$comment_list = $oCommentModel->getComments($target_list);
if($comment_list) foreach($comment_list as $key => $val) {
foreach($output->data as $k => $v) {
if($v->target_srl== $val->comment_srl) {
$output->data[$k]->url = $val->getPermanentUrl();
$output->data[$k]->regdate = $val->getRegdate("Y-m-d H:i");
$output->data[$k]->nick_name = $val->getNickName();
}
}
}
return $output;
}
/**
* Search Multimedia. call function _getFiles().
*
* @param string $target choose target. exclude or include for $module_srls_list
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038
* @param string $search_keyword Keyword
* @param integer $page page of page navigation
* @param integer $list_count list count of page navigation
*
* @return Object
**/
function getImages($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20) {
return $this->_getFiles($target, $module_srls_list, $search_keyword, $page, $list_count);
}
/**
* Search for attachments. call function _getFiles().
*
* @param string $target choose target. exclude or include for $module_srls_list
* @param string $module_srls_list module_srl list to string type. ef - 102842,59392,102038
* @param string $search_keyword Keyword
* @param integer $page page of page navigation
* @param integer $list_count list count of page navigation
*
* @return Object
**/
function getFiles($target, $module_srls_list, $search_keyword, $page=1, $list_count = 20) {
return $this->_getFiles($target, $module_srls_list, $search_keyword, $page, $list_count, 'N');
}
}
?>

View file

@ -1,134 +1,140 @@
<?php <?php
/** /**
* The view class of the integration_search module * The view class of the integration_search module
* *
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
class integration_searchView extends integration_search
class integration_searchView extends integration_search { {
/** /**
* Target mid * Target mid
* @var array target mid * @var array target mid
*/ */
var $target_mid = array(); var $target_mid = array();
/** /**
* Skin * Skin
* @var string skin name * @var string skin name
*/ */
var $skin = 'default'; var $skin = 'default';
/** /**
* Initialization * Initialization
* *
* @return void * @return void
**/ */
function init() { function init()
} {
}
/** /**
* Search Result * Search Result
* *
* @return Object * @return Object
**/ */
function IS() { function IS()
$oFile = &getClass('file'); {
$oModuleModel = &getModel('module'); $oFile = &getClass('file');
// Check permissions $oModuleModel = &getModel('module');
if(!$this->grant->access) return new Object(-1,'msg_not_permitted'); // Check permissions
if(!$this->grant->access) return new Object(-1,'msg_not_permitted');
$config = $oModuleModel->getModuleConfig('integration_search'); $config = $oModuleModel->getModuleConfig('integration_search');
if(!$config->skin) if(!$config->skin)
{
$config->skin = 'default';
$template_path = sprintf('%sskins/%s', $this->module_path, $config->skin);
}
else
{
//check theme
$config_parse = explode('|@|', $config->skin);
if (count($config_parse) > 1)
{
$template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]);
}
else
{ {
$config->skin = 'default';
$template_path = sprintf('%sskins/%s', $this->module_path, $config->skin); $template_path = sprintf('%sskins/%s', $this->module_path, $config->skin);
} }
else }
// Template path
$this->setTemplatePath($template_path);
Context::set('module_info', unserialize($config->skin_vars));
$target = $config->target;
if(!$target) $target = 'include';
if(empty($config->target_module_srl))
$module_srl_list = array();
else
$module_srl_list = explode(',',$config->target_module_srl);
// Set a variable for search keyword
$is_keyword = Context::get('is_keyword');
// Set page variables
$page = (int)Context::get('page');
if(!$page) $page = 1;
// Search by search tab
$where = Context::get('where');
// Create integration search model object
if($is_keyword)
{
$oIS = &getModel('integration_search');
switch($where)
{ {
//check theme case 'document' :
$config_parse = explode('|@|', $config->skin); $search_target = Context::get('search_target');
if (count($config_parse) > 1) if(!in_array($search_target, array('title','content','title_content','tag'))) $search_target = 'title';
{ Context::set('search_target', $search_target);
$template_path = sprintf('./themes/%s/modules/integration_search/', $config_parse[0]);
} $output = $oIS->getDocuments($target, $module_srl_list, $search_target, $is_keyword, $page, 10);
else Context::set('output', $output);
{ $this->setTemplateFile("document", $page);
$template_path = sprintf('%sskins/%s', $this->module_path, $config->skin); break;
} case 'comment' :
$output = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 10);
Context::set('output', $output);
$this->setTemplateFile("comment", $page);
break;
case 'trackback' :
$search_target = Context::get('search_target');
if(!in_array($search_target, array('title','url','blog_name','excerpt'))) $search_target = 'title';
Context::set('search_target', $search_target);
$output = $oIS->getTrackbacks($target, $module_srl_list, $search_target, $is_keyword, $page, 10);
Context::set('output', $output);
$this->setTemplateFile("trackback", $page);
break;
case 'multimedia' :
$output = $oIS->getImages($target, $module_srl_list, $is_keyword, $page,20);
Context::set('output', $output);
$this->setTemplateFile("multimedia", $page);
break;
case 'file' :
$output = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 20);
Context::set('output', $output);
$this->setTemplateFile("file", $page);
break;
default :
$output['document'] = $oIS->getDocuments($target, $module_srl_list, 'title', $is_keyword, $page, 5);
$output['comment'] = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 5);
$output['trackback'] = $oIS->getTrackbacks($target, $module_srl_list, 'title', $is_keyword, $page, 5);
$output['multimedia'] = $oIS->getImages($target, $module_srl_list, $is_keyword, $page, 5);
$output['file'] = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 5);
Context::set('search_result', $output);
Context::set('search_target', 'title');
$this->setTemplateFile("index", $page);
break;
} }
// Template path }
$this->setTemplatePath($template_path); else
Context::set('module_info', unserialize($config->skin_vars)); {
$this->setTemplateFile("no_keywords");
}
$target = $config->target; $security = new Security();
if(!$target) $target = 'include'; $security->encodeHTML('is_keyword', 'search_target', 'where', 'page');
}
if (empty($config->target_module_srl)) }
$module_srl_list = array(); /* End of file integration_search.view.php */
else /* Location: ./modules/integration_search/integration_search.view.php */
$module_srl_list = explode(',',$config->target_module_srl);
// Set a variable for search keyword
$is_keyword = Context::get('is_keyword');
// Set page variables
$page = (int)Context::get('page');
if(!$page) $page = 1;
// Search by search tab
$where = Context::get('where');
// Create integration search model object
if($is_keyword) {
$oIS = &getModel('integration_search');
switch($where) {
case 'document' :
$search_target = Context::get('search_target');
if(!in_array($search_target, array('title','content','title_content','tag'))) $search_target = 'title';
Context::set('search_target', $search_target);
$output = $oIS->getDocuments($target, $module_srl_list, $search_target, $is_keyword, $page, 10);
Context::set('output', $output);
$this->setTemplateFile("document", $page);
break;
case 'comment' :
$output = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 10);
Context::set('output', $output);
$this->setTemplateFile("comment", $page);
break;
case 'trackback' :
$search_target = Context::get('search_target');
if(!in_array($search_target, array('title','url','blog_name','excerpt'))) $search_target = 'title';
Context::set('search_target', $search_target);
$output = $oIS->getTrackbacks($target, $module_srl_list, $search_target, $is_keyword, $page, 10);
Context::set('output', $output);
$this->setTemplateFile("trackback", $page);
break;
case 'multimedia' :
$output = $oIS->getImages($target, $module_srl_list, $is_keyword, $page,20);
Context::set('output', $output);
$this->setTemplateFile("multimedia", $page);
break;
case 'file' :
$output = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 20);
Context::set('output', $output);
$this->setTemplateFile("file", $page);
break;
default :
$output['document'] = $oIS->getDocuments($target, $module_srl_list, 'title', $is_keyword, $page, 5);
$output['comment'] = $oIS->getComments($target, $module_srl_list, $is_keyword, $page, 5);
$output['trackback'] = $oIS->getTrackbacks($target, $module_srl_list, 'title', $is_keyword, $page, 5);
$output['multimedia'] = $oIS->getImages($target, $module_srl_list, $is_keyword, $page, 5);
$output['file'] = $oIS->getFiles($target, $module_srl_list, $is_keyword, $page, 5);
Context::set('search_result', $output);
Context::set('search_target', 'title');
$this->setTemplateFile("index", $page);
break;
}
} else {
$this->setTemplateFile("no_keywords");
}
$security = new Security();
$security->encodeHTML('is_keyword', 'search_target', 'where', 'page');
}
}
?>