issue 2662 counter, document

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12241 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-11-16 08:05:15 +00:00
parent e665650392
commit 77a1c3e89f
12 changed files with 4563 additions and 4059 deletions

View file

@ -3,16 +3,16 @@
* Admin view class of counter module
*
* @author NHN (developers@xpressengine.com)
**/
class counterAdminView extends counter {
*/
class counterAdminView extends counter
{
/**
* Initialization
*
* @return void
**/
function init() {
*/
function init()
{
// set the template path
$this->setTemplatePath($this->module_path.'tpl');
}
@ -21,8 +21,9 @@
* Admin page
*
* @return Object
**/
function dispCounterAdminIndex() {
*/
function dispCounterAdminIndex()
{
// set today's if no date is given
$selected_date = Context::get('selected_date');
if(!$selected_date) $selected_date = date("Ymd");
@ -36,7 +37,8 @@
Context::set('selected_day_counter', $status[$selected_date]);
// get data by time, day, month, and year
$type = Context::get('type');
if(!$type) {
if(!$type)
{
$type = 'day';
Context::set('type',$type);
}
@ -46,6 +48,6 @@
// display
$this->setTemplateFile('index');
}
}
?>
/* End of file counter.admin.view.php */
/* Location: ./modules/counter/counter.admin.view.php */

View file

@ -3,15 +3,15 @@
* High class of counter module
*
* @author NHN (developers@xpressengine.com)
**/
class counter extends ModuleObject {
*/
class counter extends ModuleObject
{
/**
* Implement if additional tasks are necessary when installing
* @return Object
**/
function moduleInstall() {
*/
function moduleInstall()
{
$oCounterController = &getController('counter');
// add a row for the total visit history
//$oCounterController->insertTotalStatus();
@ -25,8 +25,9 @@
* method if successfully installed
*
* @return bool
**/
function checkUpdate() {
*/
function checkUpdate()
{
// Add site_srl to the counter
$oDB = &DB::getInstance();
if(!$oDB->isColumnExists('counter_log', 'site_srl')) return true;
@ -39,8 +40,9 @@
* Module update
*
* @return Object
**/
function moduleUpdate() {
*/
function moduleUpdate()
{
// Add site_srl to the counter
$oDB = &DB::getInstance();
if(!$oDB->isColumnExists('counter_log', 'site_srl')) $oDB->addColumn('counter_log','site_srl','number',11,0,true);
@ -53,8 +55,10 @@
* re-generate the cache file
*
* @return Object
**/
function recompileCache() {
*/
function recompileCache()
{
}
}
?>
/* End of file counter.class.php */
/* Location: ./modules/counter/counter.class.php */

View file

@ -3,16 +3,16 @@
* Counter module's controller class
*
* @author NHN (developers@xpressengine.com)
**/
class counterController extends counter {
*/
class counterController extends counter
{
/**
* Initialization
*
* @return void
**/
function init() {
*/
function init()
{
}
/**
@ -20,16 +20,18 @@
* If want use below function, you can use 'counterExecute' function instead this function
*
* @return void
**/
function procCounterExecute() {
*/
function procCounterExecute()
{
}
/**
* Counter logs
*
* @return void
**/
function counterExecute() {
*/
function counterExecute()
{
$oDB = &DB::getInstance();
$oDB->begin();
@ -38,17 +40,23 @@
// Check the logs
$oCounterModel = &getModel('counter');
// Register today's row if not exist
if(!$oCounterModel->isInsertedTodayStatus($site_srl)) {
if(!$oCounterModel->isInsertedTodayStatus($site_srl))
{
$this->insertTodayStatus(0,$site_srl);
// check user if the previous row exists
} else {
}
else
{
// If unregistered IP
if(!$oCounterModel->isLogged($site_srl)) {
if(!$oCounterModel->isLogged($site_srl))
{
// Leave logs
$this->insertLog($site_srl);
// Register unique and pageview
$this->insertUniqueVisitor($site_srl);
} else {
}
else
{
// Register pageview
$this->insertPageView($site_srl);
}
@ -62,8 +70,9 @@
*
* @param integer $site_srl
* @return Object result of count query
**/
function insertLog($site_srl=0) {
*/
function insertLog($site_srl=0)
{
$args->regdate = date("YmdHis");
$args->user_agent = substr ($_SERVER['HTTP_USER_AGENT'], 0, 250);
$args->site_srl = $site_srl;
@ -75,15 +84,19 @@
*
* @param integer $site_srl
* @return void
**/
function insertUniqueVisitor($site_srl=0) {
if($site_srl) {
*/
function insertUniqueVisitor($site_srl=0)
{
if($site_srl)
{
$args->regdate = '0';
$args->site_srl = $site_srl;
$output = executeQuery('counter.updateSiteCounterUnique', $args);
$args->regdate = date('Ymd');
$output = executeQuery('counter.updateSiteCounterUnique', $args);
} else {
}
else
{
$args->regdate = '0';
$output = executeQuery('counter.updateCounterUnique', $args);
$args->regdate = date('Ymd');
@ -96,15 +109,19 @@
*
* @param integer $site_srl
* @return void
**/
function insertPageView($site_srl=0) {
if($site_srl) {
*/
function insertPageView($site_srl=0)
{
if($site_srl)
{
$args->regdate = '0';
$args->site_srl = $site_srl;
executeQuery('counter.updateSiteCounterPageview', $args);
$args->regdate = date('Ymd');
executeQuery('counter.updateSiteCounterPageview', $args);
} else {
}
else
{
$args->regdate = '0';
executeQuery('counter.updateCounterPageview', $args);
$args->regdate = date('Ymd');
@ -117,13 +134,17 @@
*
* @param integer $site_srl
* @return void
**/
function insertTotalStatus($site_srl=0) {
*/
function insertTotalStatus($site_srl=0)
{
$args->regdate = 0;
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
executeQuery('counter.insertSiteTodayStatus', $args);
} else {
}
else
{
executeQuery('counter.insertTodayStatus', $args);
}
}
@ -134,17 +155,21 @@
* @param integer $regdate date(YYYYMMDD) type
* @param integer $site_srl
* @return void
**/
function insertTodayStatus($regdate = 0, $site_srl=0) {
*/
function insertTodayStatus($regdate = 0, $site_srl=0)
{
if($regdate) $args->regdate = $regdate;
else $args->regdate = date("Ymd");
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$query_id = 'counter.insertSiteTodayStatus';
$u_args->site_srl = $site_srl; // /< when inserting a daily row, attempt to inser total rows(where regdate=0) together
executeQuery($query_id, $u_args);
} else {
}
else
{
$query_id = 'counter.insertTodayStatus';
executeQuery($query_id); // /< when inserting a daily row, attempt to inser total rows(where regdate=0) together
}
@ -160,11 +185,13 @@
*
* @param integer $site_srl
* @return void
**/
function deleteSiteCounterLogs($site_srl) {
*/
function deleteSiteCounterLogs($site_srl)
{
$args->site_srl = $site_srl;
executeQuery('counter.deleteSiteCounter',$args);
executeQuery('counter.deleteSiteCounterLog',$args);
}
}
?>
/* End of file counter.controller.php */
/* Location: ./modules/counter/counter.controller.php */

View file

@ -3,16 +3,16 @@
* Model class of counter module
*
* @author NHN (developers@xpressengine.com)
**/
class counterModel extends counter {
*/
class counterModel extends counter
{
/**
* Initialization
*
* @return void
**/
function init() {
*/
function init()
{
}
/**
@ -20,8 +20,9 @@
*
* @param integer $site_srl Site_srl
* @return bool
**/
function isLogged($site_srl=0) {
*/
function isLogged($site_srl=0)
{
$args->regdate = date("Ymd");
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
$args->site_srl = $site_srl;
@ -34,13 +35,17 @@
*
* @param integer $site_srl Site_srl
* @return bool
**/
function isInsertedTodayStatus($site_srl=0) {
*/
function isInsertedTodayStatus($site_srl=0)
{
$args->regdate = date("Ymd");
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteTodayStatus', $args);
} else {
}
else
{
$output = executeQuery('counter.getTodayStatus', $args);
}
return $output->data->count?true:false;
@ -52,22 +57,29 @@
* @param mixed $selected_date Date(YYYYMMDD) list
* @param integer $site_srl Site_srl
* @return Object
**/
function getStatus($selected_date, $site_srl = 0) {
*/
function getStatus($selected_date, $site_srl = 0)
{
// If more than one date logs are selected
if(is_array($selected_date)) {
if(is_array($selected_date))
{
$date_count = count($selected_date);
$args->regdate = implode(',',$selected_date);
// If a single date log is selected
} else {
}
else
{
if(strlen($selected_date) == 8) $selected_date = $selected_date;
$args->regdate = $selected_date;
}
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatusDays', $args);
} else {
}
else
{
$output = executeQuery('counter.getCounterStatusDays', $args);
}
$status = $output->data;
@ -77,7 +89,8 @@
if(!is_array($status)) $status = array($status);
unset($output);
foreach($status as $key => $val) {
foreach($status as $key => $val)
{
$output[substr($val->regdate,0,8)] = $val;
}
return $output;
@ -90,29 +103,38 @@
* @param integer $selected_date Date(YYYYMMDD)
* @param integer $site_srl Site_srl
* @return Object
**/
function getHourlyStatus($type='hour', $selected_date, $site_srl=0) {
*/
function getHourlyStatus($type='hour', $selected_date, $site_srl=0)
{
$max = 0;
$sum = 0;
switch($type) {
switch($type)
{
case 'year' :
// Get a date to start counting
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteStartLogDate', $args);
} else {
}
else
{
$output = executeQuery('counter.getStartLogDate');
}
$start_year = substr($output->data->regdate,0,4);
if(!$start_year) $start_year = date("Y");
for($i=$start_year;$i<=date("Y");$i++) {
for($i=$start_year;$i<=date("Y");$i++)
{
unset($args);
$args->start_date = sprintf('%04d0000', $i);
$args->end_date = sprintf('%04d1231', $i);
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
} else {
}
else
{
$output = executeQuery('counter.getCounterStatus', $args);
}
$count = (int)$output->data->unique_visitor;
@ -124,24 +146,30 @@
case 'week' :
$time = strtotime($selected_date);
$w = date("D");
while(date("D",$time) != "Sun") {
while(date("D",$time) != "Sun")
{
$time += 60*60*24;
}
$time -= 60*60*24;
while(date("D",$time)!="Sun") {
while(date("D",$time)!="Sun")
{
$thisWeek[] = date("Ymd",$time);
$time -= 60*60*24;
}
$thisWeek[] = date("Ymd",$time);
asort($thisWeek);
foreach($thisWeek as $day) {
foreach($thisWeek as $day)
{
unset($args);
$args->start_date = $day;
$args->end_date = $day;
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
} else {
}
else
{
$output = executeQuery('counter.getCounterStatus', $args);
}
$count = (int)$output->data->unique_visitor;
@ -152,14 +180,18 @@
break;
case 'month' :
$year = substr($selected_date, 0, 4);
for($i=1;$i<=12;$i++) {
for($i=1;$i<=12;$i++)
{
unset($args);
$args->start_date = sprintf('%04d%02d00', $year, $i);
$args->end_date = sprintf('%04d%02d31', $year, $i);
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
} else {
}
else
{
$output = executeQuery('counter.getCounterStatus', $args);
}
$count = (int)$output->data->unique_visitor;
@ -169,14 +201,18 @@
}
break;
case 'hour' :
for($i=0;$i<24;$i++) {
for($i=0;$i<24;$i++)
{
unset($args);
$args->start_date = sprintf('%08d%02d0000', $selected_date, $i);
$args->end_date = sprintf('%08d%02d5959', $selected_date, $i);
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterLogStatus', $args);
} else {
}
else
{
$args->site_srl = 0;
$output = executeQuery('counter.getCounterLogStatus', $args);
}
@ -190,14 +226,18 @@
$year = substr($selected_date, 0, 4);
$month = substr($selected_date, 4, 2);
$end_day = date('t', mktime(0,0,0,$month,1,$year));
for($i=1;$i<=$end_day;$i++) {
for($i=1;$i<=$end_day;$i++)
{
unset($args);
$args->start_date = sprintf('%04d%02d%02d', $year, $month, $i);
$args->end_date = sprintf('%04d%02d%02d', $year, $month, $i);
if($site_srl) {
if($site_srl)
{
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteCounterStatus', $args);
} else {
}
else
{
$output = executeQuery('counter.getCounterStatus', $args);
}
$count = (int)$output->data->unique_visitor;
@ -214,4 +254,5 @@
}
}
?>
/* End of file counter.model.php */
/* Location: ./modules/counter/counter.model.php */

View file

@ -7,19 +7,22 @@
* @package /modules/document
* @version 0.1
*/
class documentAdminController extends document {
class documentAdminController extends document
{
/**
* Initialization
* @return void
*/
function init() {
function init()
{
}
/**
* Remove the selected docs from admin page
* @return void
*/
function procDocumentAdminDeleteChecked() {
function procDocumentAdminDeleteChecked()
{
// error appears if no doc is selected
$cart = Context::get('cart');
if(!$cart) return $this->stop('msg_cart_is_null');
@ -28,7 +31,8 @@
if(!$document_count) return $this->stop('msg_cart_is_null');
// Delete a doc
$oDocumentController = &getController('document');
for($i=0;$i<$document_count;$i++) {
for($i=0;$i<$document_count;$i++)
{
$document_srl = trim($document_srl_list[$i]);
if(!$document_srl) continue;
@ -45,7 +49,8 @@
* @param int $category_srl
* @return Object
*/
function moveDocumentModule($document_srl_list, $module_srl, $category_srl) {
function moveDocumentModule($document_srl_list, $module_srl, $category_srl)
{
if(!count($document_srl_list)) return;
$oDocumentModel = &getModel('document');
@ -59,12 +64,14 @@
$triggerObj->category_srl = $category_srl;
// Call a trigger (before)
$output = ModuleHandler::triggerCall('document.moveDocumentModule', 'before', $triggerObj);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
for($i=count($document_srl_list)-1;$i>=0;$i--) {
for($i=count($document_srl_list)-1;$i>=0;$i--)
{
$document_srl = $document_srl_list[$i];
$oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists()) continue;
@ -74,7 +81,8 @@
unset($obj);
$obj = $oDocument->getObjectVars();
// Move the attached file if the target module is different
if($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles()) {
if($module_srl != $obj->module_srl && $oDocument->hasUploadedFiles())
{
$oFileController = &getController('file');
$files = $oDocument->getUploadedFiles();
@ -86,14 +94,18 @@
$file_info['tmp_name'] = $val->uploaded_filename;
$file_info['name'] = $val->source_filename;
$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, $val->download_count, true);
if($inserted_file && $inserted_file->toBool()) {
if($inserted_file && $inserted_file->toBool())
{
// for image/video files
if($val->direct_download == 'Y') {
if($val->direct_download == 'Y')
{
$source_filename = substr($val->uploaded_filename,2);
$target_filename = substr($inserted_file->get('uploaded_filename'),2);
$obj->content = str_replace($source_filename, $target_filename, $obj->content);
// For binary files
} else {
}
else
{
$obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content);
$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
}
@ -119,42 +131,47 @@
return $output;
}
// Set 0 if a new category doesn't exist after catergory change
if($source_category_srl != $category_srl) {
if($source_category_srl != $category_srl)
{
if($source_category_srl) $oDocumentController->updateCategoryCount($oDocument->get('module_srl'), $source_category_srl);
if($category_srl) $oDocumentController->updateCategoryCount($module_srl, $category_srl);
}
}
$args->document_srls = implode(',',$document_srl_list);
$args->module_srl = $module_srl;
// move the comment
$output = executeQuery('comment.updateCommentModule', $args);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
$output = executeQuery('comment.updateCommentListModule', $args);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
// move the trackback
$output = executeQuery('trackback.updateTrackbackModule', $args);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
// Tags
$output = executeQuery('tag.updateTagModule', $args);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
// Call a trigger (before)
$output = ModuleHandler::triggerCall('document.moveDocumentModule', 'after', $triggerObj);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
@ -183,7 +200,8 @@
* @param int $category_srl
* @return object
*/
function copyDocumentModule($document_srl_list, $module_srl, $category_srl) {
function copyDocumentModule($document_srl_list, $module_srl, $category_srl)
{
if(!count($document_srl_list)) return;
$oDocumentModel = &getModel('document');
@ -199,7 +217,8 @@
$triggerObj->category_srl = $category_srl;
// Call a trigger (before)
$output = ModuleHandler::triggerCall('document.copyDocumentModule', 'before', $triggerObj);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
@ -219,7 +238,8 @@
}
}
for($i=count($document_srl_list)-1;$i>=0;$i--) {
for($i=count($document_srl_list)-1;$i>=0;$i--)
{
$document_srl = $document_srl_list[$i];
$oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists()) continue;
@ -245,21 +265,26 @@
$obj->comment_count = 0;
$obj->trackback_count = 0;
// Pre-register the attachment
if($oDocument->hasUploadedFiles()) {
if($oDocument->hasUploadedFiles())
{
$files = $oDocument->getUploadedFiles();
foreach($files as $key => $val) {
foreach($files as $key => $val)
{
$file_info = array();
$file_info['tmp_name'] = $val->uploaded_filename;
$file_info['name'] = $val->source_filename;
$oFileController = &getController('file');
$inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, 0, true);
// if image/video files
if($val->direct_download == 'Y') {
if($val->direct_download == 'Y')
{
$source_filename = substr($val->uploaded_filename,2);
$target_filename = substr($inserted_file->get('uploaded_filename'),2);
$obj->content = str_replace($source_filename, $target_filename, $obj->content);
// If binary file
} else {
}
else
{
$obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $obj->content);
$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
}
@ -268,7 +293,8 @@
// Write a post
$output = $oDocumentController->insertDocument($obj, true, true);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
@ -291,34 +317,42 @@
}
// Move the comments
if($oDocument->getCommentCount()) {
if($oDocument->getCommentCount())
{
$oCommentModel = &getModel('comment');
$comment_output = $oCommentModel->getCommentList($document_srl, 0, true, 99999999);
$comments = $comment_output->data;
if(count($comments)) {
if(count($comments))
{
$oCommentController = &getController('comment');
$success_count = 0;
$p_comment_srl = array();
foreach($comments as $comment_obj) {
foreach($comments as $comment_obj)
{
$comment_srl = getNextSequence();
$p_comment_srl[$comment_obj->comment_srl] = $comment_srl;
// Pre-register the attachment
if($comment_obj->uploaded_count) {
if($comment_obj->uploaded_count)
{
$files = $oFileModel->getFiles($comment_obj->comment_srl, true);
foreach($files as $key => $val) {
foreach($files as $key => $val)
{
$file_info = array();
$file_info['tmp_name'] = $val->uploaded_filename;
$file_info['name'] = $val->source_filename;
$oFileController = &getController('file');
$inserted_file = $oFileController->insertFile($file_info, $module_srl, $comment_srl, 0, true);
// if image/video files
if($val->direct_download == 'Y') {
if($val->direct_download == 'Y')
{
$source_filename = substr($val->uploaded_filename,2);
$target_filename = substr($inserted_file->get('uploaded_filename'),2);
$comment_obj->content = str_replace($source_filename, $target_filename, $comment_obj->content);
// If binary file
} else {
}
else
{
$comment_obj->content = str_replace('file_srl='.$val->file_srl, 'file_srl='.$inserted_file->get('file_srl'), $comment_obj->content);
$comment_obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $comment_obj->content);
}
@ -335,17 +369,18 @@
if($output->toBool()) $success_count ++;
}
$oDocumentController->updateCommentCount($obj->document_srl, $success_count, $comment_obj->nick_name, true);
}
}
// Move the trackbacks
if($oDocument->getTrackbackCount()) {
if($oDocument->getTrackbackCount())
{
$oTrackbackModel = &getModel('trackback');
$trackbacks = $oTrackbackModel->getTrackbackList($oDocument->document_srl);
if(count($trackbacks)) {
if(count($trackbacks))
{
$success_count = 0;
foreach($trackbacks as $trackback_obj) {
foreach($trackbacks as $trackback_obj)
{
$trackback_obj->trackback_srl = getNextSequence();
$trackback_obj->module_srl = $obj->module_srl;
$trackback_obj->document_srl = $obj->document_srl;
@ -363,7 +398,8 @@
// Call a trigger (before)
$triggerObj->copied_srls = $copied_srls;
$output = ModuleHandler::triggerCall('document.copyDocumentModule', 'after', $triggerObj);
if(!$output->toBool()) {
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
@ -380,15 +416,18 @@
* @param int $module_srl
* @return object
*/
function deleteModuleDocument($module_srl) {
function deleteModuleDocument($module_srl)
{
$args->module_srl = $module_srl;
$oDocumentModel = &getModel('document');
$args->module_srl = $module_srl;
$document_list = $oDocumentModel->getDocumentList($args);
$documents = $document_list->data;
$output = executeQuery('document.deleteModuleDocument', $args);
if (is_array($documents)){
foreach ($documents as $oDocument){
if(is_array($documents))
{
foreach ($documents as $oDocument)
{
$document_srl_list[] = $oDocument->document_srl;
}
}
@ -413,7 +452,8 @@
* Save the default settings of the document module
* @return object
*/
function procDocumentAdminInsertConfig() {
function procDocumentAdminInsertConfig()
{
// Get the basic information
$config = Context::gets('thumbnail_type');
// Insert by creating the module Controller object
@ -428,10 +468,12 @@
* Revoke declaration of the blacklisted posts
* @return object
*/
function procDocumentAdminCancelDeclare() {
function procDocumentAdminCancelDeclare()
{
$document_srl = trim(Context::get('document_srl'));
if($document_srl) {
if($document_srl)
{
$args->document_srl = $document_srl;
$output = executeQuery('document.deleteDeclaredDocuments', $args);
if(!$output->toBool()) return $output;
@ -442,7 +484,8 @@
* Delete all thumbnails
* @return void
*/
function procDocumentAdminDeleteAllThumbnail() {
function procDocumentAdminDeleteAllThumbnail()
{
// delete all of thumbnail_ *. jpg files from files/attaches/images/ directory (prior versions to 1.0.4)
$this->deleteThumbnailFile('./files/attach/images');
// delete a directory itself, files/cache/thumbnails (thumbnail policies have changed since version 1.0.5)
@ -455,7 +498,8 @@
* Delete thumbnails with subdirectory
* @return void
*/
function deleteThumbnailFile($path) {
function deleteThumbnailFile($path)
{
$directory = dir($path);
while($entry = $directory->read()) {
if ($entry != "." && $entry != "..") {
@ -474,7 +518,8 @@
* Add or modify extra variables of the module
* @return void|object
*/
function procDocumentAdminInsertExtraVar() {
function procDocumentAdminInsertExtraVar()
{
$module_srl = Context::get('module_srl');
$var_idx = Context::get('var_idx');
$name = Context::get('name');
@ -487,7 +532,8 @@
if(!$module_srl || !$name || !$eid) return new Object(-1,'msg_invalid_request');
// set the max value if idx is not specified
if(!$var_idx) {
if(!$var_idx)
{
$obj->module_srl = $module_srl;
$output = executeQuery('document.getDocumentMaxExtraKeyIdx', $obj);
$var_idx = $output->data->var_idx+1;
@ -498,7 +544,8 @@
$obj->var_idx = $var_idx;
$obj->eid = $eid;
$output = executeQuery('document.isExistsExtraKey', $obj);
if(!$output->toBool() || $output->data->count) {
if(!$output->toBool() || $output->data->count)
{
return new Object(-1, 'msg_extra_name_exists');
}
@ -517,7 +564,8 @@
* Delete extra variables of the module
* @return void|object
*/
function procDocumentAdminDeleteExtraVar() {
function procDocumentAdminDeleteExtraVar()
{
$module_srl = Context::get('module_srl');
$var_idx = Context::get('var_idx');
if(!$module_srl || !$var_idx) return new Object(-1,'msg_invalid_request');
@ -533,7 +581,8 @@
* Control the order of extra variables
* @return void|object
*/
function procDocumentAdminMoveExtraVar() {
function procDocumentAdminMoveExtraVar()
{
$type = Context::get('type');
$module_srl = Context::get('module_srl');
$var_idx = Context::get('var_idx');
@ -560,7 +609,8 @@
unset($args);
// update immediately if there is no idx to change
if(!$extra_keys[$new_idx]) {
if(!$extra_keys[$new_idx])
{
$args->module_srl = $module_srl;
$args->var_idx = $var_idx;
$args->new_idx = $new_idx;
@ -569,7 +619,9 @@
$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
if(!$output->toBool()) return $output;
// replace if exists
} else {
}
else
{
$args->module_srl = $module_srl;
$args->var_idx = $new_idx;
$args->new_idx = -10000;
@ -598,7 +650,8 @@
* Insert alias for document
* @return void|object
*/
function procDocumentAdminInsertAlias() {
function procDocumentAdminInsertAlias()
{
$args = Context::gets('module_srl','document_srl', 'alias_title');
$alias_srl = Context::get('alias_srl');
if(!$alias_srl)
@ -621,7 +674,8 @@
* Delete alias for document
* @return void|object
*/
function procDocumentAdminDeleteAlias() {
function procDocumentAdminDeleteAlias()
{
$document_srl = Context::get('document_srl');
$alias_srl = Context::get('target_srl');
$args->alias_srl = $alias_srl;
@ -635,7 +689,8 @@
* Restor document from trash
* @return void|object
*/
function procDocumentAdminRestoreTrash() {
function procDocumentAdminRestoreTrash()
{
$trash_srl = Context::get('trash_srl');
$this->restoreTrash($trash_srl);
}
@ -716,16 +771,19 @@
//FILE restore
$oDocument = $oDocumentModel->getDocument($originObject->document_srl);
// If the post was not temorarily saved, set the attachment's status to be valid
if($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl) {
if($oDocument->hasUploadedFiles() && $originObject->member_srl != $originObject->module_srl)
{
$args->upload_target_srl = $oDocument->document_srl;
$args->isvalid = 'Y';
$output = executeQuery('file.updateFileValid', $args);
}
// call a trigger (after)
if($output->toBool()) {
if($output->toBool())
{
$trigger_output = ModuleHandler::triggerCall('document.restoreTrash', 'after', $originObject);
if(!$trigger_output->toBool()) {
if(!$trigger_output->toBool())
{
$oDB->rollback();
return $trigger_output;
}
@ -755,4 +813,5 @@
return $output;
}
}
?>
/* End of file document.admin.controller.php */
/* Location: ./modules/document/document.admin.controller.php */

View file

@ -7,12 +7,14 @@
* @package /modules/document
* @version 0.1
*/
class documentAdminModel extends document {
class documentAdminModel extends document
{
/**
* Initialization
* @return void
*/
function init() {
function init()
{
}
/**
@ -20,12 +22,14 @@
* @param object $obj
* @return object
*/
function getDocumentTrashList($obj) {
function getDocumentTrashList($obj)
{
// check a list and its order
if(!in_array($obj->sort_index, array('list_order','delete_date','title'))) $obj->sort_index = 'list_order';
if(!in_array($obj->order_type, array('desc','asc'))) $obj->order_type = 'asc';
// get a module_srl if mid is returned instead of modul_srl
if ($obj->mid) {
if($obj->mid)
{
$oModuleModel = &getModel('module');
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
unset($obj->mid);
@ -54,7 +58,8 @@
$keys = array_keys($data);
$virtual_number = $keys[0];
foreach($data as $key => $attribute) {
foreach($data as $key => $attribute)
{
$oDocument = null;
$oDocument = new documentItem();
$oDocument->setAttribute($attribute, false);
@ -72,7 +77,8 @@
* @param int $trash_srl
* @return object
*/
function getDocumentTrash($trash_srl) {
function getDocumentTrash($trash_srl)
{
$args->trash_srl = $trash_srl;
$output = executeQuery('document.getTrash', $args);
@ -89,7 +95,8 @@
* @param array $statusList
* @return int
*/
function getDocumentCountByDate($date = '', $moduleSrlList = array(), $statusList = array()) {
function getDocumentCountByDate($date = '', $moduleSrlList = array(), $statusList = array())
{
if($date) $args->regDate = date('Ymd', strtotime($date));
if(count($moduleSrlList)>0) $args->moduleSrlList = $moduleSrlList;
if(count($statusList)>0) $args->statusList = $statusList;
@ -100,4 +107,5 @@
return $output->data->count;
}
}
?>
/* End of file document.admin.model.php */
/* Location: ./modules/document/document.admin.model.php */

View file

@ -7,12 +7,14 @@
* @package /modules/document
* @version 0.1
*/
class documentAdminView extends document {
class documentAdminView extends document
{
/**
* Initialization
* @return void
*/
function init() {
function init()
{
// check current location in admin menu
$oModuleModel = &getModel('module');
$info = $oModuleModel->getModuleActionXml('document');
@ -30,7 +32,8 @@
* Display a list(administrative)
* @return void
*/
function dispDocumentAdminList() {
function dispDocumentAdminList()
{
// option to get a list
$args->page = Context::get('page'); // /< Page
$args->list_count = 30; // /< the number of posts to display on a single page
@ -61,7 +64,8 @@
// set a search option used in the template
$count_search_option = count($this->search_option);
for($i=0;$i<$count_search_option;$i++) {
for($i=0;$i<$count_search_option;$i++)
{
$search_option[$this->search_option[$i]] = Context::getLang($this->search_option[$i]);
}
Context::set('search_option', $search_option);
@ -75,7 +79,8 @@
* Set a document module
* @return void
*/
function dispDocumentAdminConfig() {
function dispDocumentAdminConfig()
{
$oDocumentModel = &getModel('document');
$config = $oDocumentModel->getDocumentConfig();
Context::set('config',$config);
@ -89,7 +94,8 @@
* Display a report list on the admin page
* @return void
*/
function dispDocumentAdminDeclared() {
function dispDocumentAdminDeclared()
{
// option for a list
$args->page = Context::get('page'); // /< Page
$args->list_count = 30; // /< the number of posts to display on a single page
@ -104,10 +110,12 @@
// get a list
$declared_output = executeQuery('document.getDeclaredList', $args);
if($declared_output->data && count($declared_output->data)) {
if($declared_output->data && count($declared_output->data))
{
$document_list = array();
foreach($declared_output->data as $key => $document) {
foreach($declared_output->data as $key => $document)
{
$document_list[$key] = new documentItem();
$document_list[$key]->setAttribute($document);
}
@ -130,7 +138,8 @@
* Display a alias list on the admin page
* @return void
*/
function dispDocumentAdminAlias() {
function dispDocumentAdminAlias()
{
$args->document_srl = Context::get('document_srl');
if(!$args->document_srl) return $this->dispDocumentAdminList();
@ -159,7 +168,8 @@
* Display a trash list on the admin page
* @return void
*/
function dispDocumentAdminTrashList() {
function dispDocumentAdminTrashList()
{
// options for a list
$args->page = Context::get('page'); // /< Page
$args->list_count = 30; // /< the number of posts to display on a single page
@ -185,4 +195,5 @@
$this->setTemplateFile('document_trash_list');
}
}
?>
/* End of file document.admin.view.php */
/* Location: ./modules/document/document.admin.view.php */

View file

@ -130,30 +130,36 @@ class document extends ModuleObject
* Execute update
* @return Object
*/
function moduleUpdate() {
function moduleUpdate()
{
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
// 2007. 7. 25: Add a column(notify_message) for notification
if(!$oDB->isColumnExists("documents","notify_message")) {
if(!$oDB->isColumnExists("documents","notify_message"))
{
$oDB->addColumn('documents',"notify_message","char",1);
}
// 2007. 8. 23: create a clustered index in the document table
if(!$oDB->isIndexExists("documents","idx_module_list_order")) {
if(!$oDB->isIndexExists("documents","idx_module_list_order"))
{
$oDB->addIndex("documents","idx_module_list_order", array("module_srl","list_order"));
}
if(!$oDB->isIndexExists("documents","idx_module_update_order")) {
if(!$oDB->isIndexExists("documents","idx_module_update_order"))
{
$oDB->addIndex("documents","idx_module_update_order", array("module_srl","update_order"));
}
if(!$oDB->isIndexExists("documents","idx_module_readed_count")) {
if(!$oDB->isIndexExists("documents","idx_module_readed_count"))
{
$oDB->addIndex("documents","idx_module_readed_count", array("module_srl","readed_count"));
}
if(!$oDB->isIndexExists("documents","idx_module_voted_count")) {
if(!$oDB->isIndexExists("documents","idx_module_voted_count"))
{
$oDB->addIndex("documents","idx_module_voted_count", array("module_srl","voted_count"));
}
// 2007. 10. 17 Add a trigger to delete all posts together when the module is deleted
@ -172,12 +178,14 @@ class document extends ModuleObject
// 2008. 02. 18 create a composite index on the columns(module_srl + document_srl) (checked by Manian))
if(!$oDB->isIndexExists("documents","idx_module_document_srl")) $oDB->addIndex("documents","idx_module_document_srl", array("module_srl","document_srl"));
// 2008. 04. 23 Add a column(blamed count)
if(!$oDB->isColumnExists("documents", "blamed_count")) {
if(!$oDB->isColumnExists("documents", "blamed_count"))
{
$oDB->addColumn('documents', 'blamed_count', 'number', 11, 0, true);
$oDB->addIndex('documents', 'idx_blamed_count', array('blamed_count'));
}
if(!$oDB->isIndexExists("documents","idx_module_blamed_count")) {
if(!$oDB->isIndexExists("documents","idx_module_blamed_count"))
{
$oDB->addIndex('documents', 'idx_module_blamed_count', array('module_srl', 'blamed_count'));
}
@ -194,24 +202,28 @@ class document extends ModuleObject
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before'))
$oModuleController->insertTrigger('module.dispAdditionSetup', 'document', 'view', 'triggerDispDocumentAdditionSetup', 'before');
// 2009. 03. 09 Add a column(lang_code) to the documnets table
if(!$oDB->isColumnExists("documents","lang_code")) {
if(!$oDB->isColumnExists("documents","lang_code"))
{
$db_info = Context::getDBInfo();
$oDB->addColumn('documents',"lang_code","varchar",10, $db_info->lang_code);
$obj->lang_code = $db_info->lang_type;
executeQuery('document.updateDocumentsLangCode', $obj);
}
// 2009. 03. 11 Check the index in the document_extra_vars table
if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) {
if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars"))
{
$oDB->addIndex("document_extra_vars", "unique_extra_vars", array("module_srl","document_srl","var_idx","lang_code"), true);
}
if($oDB->isIndexExists("document_extra_vars", "unique_module_vars")) {
if($oDB->isIndexExists("document_extra_vars", "unique_module_vars"))
{
$oDB->dropIndex("document_extra_vars", "unique_module_vars", true);
}
// 2009. 03. 19: Add a column(eid)
// 2009. 04. 12: Fixed the issue(#17922959) that changes another column values when adding eid column
if(!$oDB->isColumnExists("document_extra_keys","eid")) {
if(!$oDB->isColumnExists("document_extra_keys","eid"))
{
$oDB->addColumn("document_extra_keys","eid","varchar",40);
$output = executeQuery('document.getGroupsExtraKeys', $obj);
@ -225,12 +237,15 @@ class document extends ModuleObject
}
}
if(!$oDB->isColumnExists("document_extra_vars","eid")) {
if(!$oDB->isColumnExists("document_extra_vars","eid"))
{
$oDB->addColumn("document_extra_vars","eid","varchar",40);
$obj->var_idx = '-1,-2';
$output = executeQuery('document.getGroupsExtraVars', $obj);
if($output->toBool() && $output->data && count($output->data)) {
foreach($output->data as $extra_vars) {
if($output->toBool() && $output->data && count($output->data))
{
foreach($output->data as $extra_vars)
{
$args->module_srl = $extra_vars->module_srl;
$args->var_idx = $extra_vars->idx;
$args->new_eid = "extra_vars".$extra_vars->idx;
@ -240,7 +255,8 @@ class document extends ModuleObject
}
// 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table
if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) {
if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order"))
{
$oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl","module_srl","var_idx"), false);
}
@ -312,7 +328,8 @@ class document extends ModuleObject
* Re-generate the cache file
* @return void
*/
function recompileCache() {
function recompileCache()
{
}
/**
@ -343,4 +360,5 @@ class document extends ModuleObject
else $this->getDefaultStatus();
}
}
?>
/* End of file document.class.php */
/* Location: ./modules/document/document.class.php */

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,8 @@
* @package /modules/document
* @version 0.1
*/
class documentItem extends Object {
class documentItem extends Object
{
/**
* Document number
* @var int
@ -51,14 +52,16 @@
* @param array columnList
* @return void
*/
function documentItem($document_srl = 0, $load_extra_vars = true, $columnList = array()) {
function documentItem($document_srl = 0, $load_extra_vars = true, $columnList = array())
{
$this->document_srl = $document_srl;
$this->columnList = $columnList;
$this->_loadFromDB($load_extra_vars);
}
function setDocument($document_srl, $load_extra_vars = true) {
function setDocument($document_srl, $load_extra_vars = true)
{
$this->document_srl = $document_srl;
$this->_loadFromDB($load_extra_vars);
}
@ -68,16 +71,19 @@
* @param bool $load_extra_vars
* @return void
*/
function _loadFromDB($load_extra_vars = true) {
function _loadFromDB($load_extra_vars = true)
{
if(!$this->document_srl) return;
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport() && !count($this->columnList)){
if($oCacheHandler->isSupport() && !count($this->columnList))
{
$cache_key = 'object_document_item:'.$this->document_srl;
$output = $oCacheHandler->get($cache_key);
}
if(!$output) {
if(!$output)
{
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args, $this->columnList);
//insert in cache
@ -87,8 +93,10 @@
$this->setAttribute($output->data,$load_extra_vars);
}
function setAttribute($attribute,$load_extra_vars=true) {
if(!$attribute->document_srl) {
function setAttribute($attribute,$load_extra_vars=true)
{
if(!$attribute->document_srl)
{
$this->document_srl = null;
return;
}
@ -96,7 +104,8 @@
$this->lang_code = $attribute->lang_code;
$this->adds($attribute);
// Tags
if($this->get('tags')) {
if($this->get('tags'))
{
$tags = explode(',',$this->get('tags'));
$tag_count = count($tags);
for($i=0;$i<$tag_count;$i++) if(trim($tags[$i])) $tag_list[] = trim($tags[$i]);
@ -105,18 +114,21 @@
$oDocumentModel = &getModel('document');
$GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl] = $this;
if($load_extra_vars) {
if($load_extra_vars)
{
$oDocumentModel->setToAllDocumentExtraVars();
$this->add('title', $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl]->get('title'));
$this->add('content', $GLOBALS['XE_DOCUMENT_LIST'][$this->document_srl]->get('content'));
}
}
function isExists() {
function isExists()
{
return $this->document_srl ? true : false;
}
function isGranted() {
function isGranted()
{
if($_SESSION['own_document'][$this->document_srl]) return true;
if(!Context::get('is_logged')) return false;
@ -133,11 +145,13 @@
return false;
}
function setGrant() {
function setGrant()
{
$_SESSION['own_document'][$this->document_srl] = true;
}
function isAccessible() {
function isAccessible()
{
return $_SESSION['accessible'][$this->document_srl]==true?true:false;
}
@ -149,15 +163,18 @@
return $this->get('comment_status') == 'ALLOW' ? true : false;
}
function allowTrackback() {
function allowTrackback()
{
static $allow_trackback_status = null;
if(is_null($allow_trackback_status)) {
if(is_null($allow_trackback_status))
{
// If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module.
$oModuleModel = &getModel('module');
$trackback_config = $oModuleModel->getModuleConfig('trackback');
if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
else {
else
{
$module_srl = $this->get('module_srl');
// Check settings of each module
$module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl);
@ -168,45 +185,54 @@
return $allow_trackback_status;
}
function isLocked() {
function isLocked()
{
if(!$this->isExists()) return false;
return $this->get('comment_status') == 'ALLOW' ? false : true;
}
function isEditable() {
function isEditable()
{
if($this->isGranted() || !$this->get('member_srl')) return true;
return false;
}
function isSecret() {
function isSecret()
{
$oDocumentModel = &getModel('document');
return $this->get('status') == $oDocumentModel->getConfigStatus('secret') ? true : false;
}
function isNotice() {
function isNotice()
{
return $this->get('is_notice') == 'Y' ? true : false;
}
function useNotify() {
function useNotify()
{
return $this->get('notify_message')=='Y' ? true : false;
}
function doCart() {
function doCart()
{
if(!$this->document_srl) return false;
if($this->isCarted()) $this->removeCart();
else $this->addCart();
}
function addCart() {
function addCart()
{
$_SESSION['document_management'][$this->document_srl] = true;
}
function removeCart() {
function removeCart()
{
unset($_SESSION['document_management'][$this->document_srl]);
}
function isCarted() {
function isCarted()
{
return $_SESSION['document_management'][$this->document_srl];
}
@ -216,7 +242,8 @@
* @param string $content
* @return void
*/
function notify($type, $content) {
function notify($type, $content)
{
if(!$this->document_srl) return;
// return if it is not useNotify
if(!$this->useNotify()) return;
@ -236,22 +263,25 @@
$oCommunicationController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, false);
}
function getLangCode() {
function getLangCode()
{
return $this->get('lang_code');
}
function getIpAddress() {
function getIpAddress()
{
if($this->isGranted()) return $this->get('ipaddress');
return preg_replace('/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/','*.$2.$3.$4', $this->get('ipaddress'));
}
function isExistsHomepage() {
function isExistsHomepage()
{
if(trim($this->get('homepage'))) return true;
return false;
}
function getHomepageUrl() {
function getHomepageUrl()
{
$url = trim($this->get('homepage'));
if(!$url) return;
@ -260,23 +290,28 @@
return $url;
}
function getMemberSrl() {
function getMemberSrl()
{
return $this->get('member_srl');
}
function getUserID() {
function getUserID()
{
return htmlspecialchars($this->get('user_id'));
}
function getUserName() {
function getUserName()
{
return htmlspecialchars($this->get('user_name'));
}
function getNickName() {
function getNickName()
{
return htmlspecialchars($this->get('nick_name'));
}
function getTitleText($cut_size = 0, $tail='...') {
function getTitleText($cut_size = 0, $tail='...')
{
if(!$this->document_srl) return;
if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
@ -285,7 +320,8 @@
return $title;
}
function getTitle($cut_size = 0, $tail='...') {
function getTitle($cut_size = 0, $tail='...')
{
if(!$this->document_srl) return;
$title = $this->getTitleText($cut_size, $tail);
@ -299,7 +335,8 @@
else return htmlspecialchars($title);
}
function getContentText($strlen = 0) {
function getContentText($strlen = 0)
{
if(!$this->document_srl) return;
if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
@ -359,7 +396,8 @@
return $m[0];
}
function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false) {
function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false)
{
if(!$this->document_srl) return;
if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
@ -372,11 +410,13 @@
// Define a link if using a rewrite module
$oContext = &Context::getInstance();
if($oContext->allow_rewrite) {
if($oContext->allow_rewrite)
{
$content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content);
}
// To display a pop-up menu
if($add_popup_menu) {
if($add_popup_menu)
{
$content = sprintf(
'%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>',
$content,
@ -384,7 +424,8 @@
);
}
// If additional content information is set
if($add_content_info) {
if($add_content_info)
{
$memberSrl = $this->get('member_srl');
if($memberSrl < 0)
{
@ -399,11 +440,14 @@
$this->document_srl, $memberSrl
);
// Add xe_content class although accessing content is not required
} else {
}
else
{
if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
}
// Change the image path to a valid absolute path if resource_realpath is true
if($resource_realpath) {
if($resource_realpath)
{
$content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content);
}
@ -418,7 +462,8 @@
* @param bool $add_xe_content_class
* @return string
*/
function getTransContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true) {
function getTransContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true)
{
$oEditorController = &getController('editor');
$content = $this->getContent($add_popup_menu, $add_content_info, $resource_realpath, $add_xe_content_class);
@ -427,7 +472,8 @@
return $content;
}
function getSummary($str_size = 50, $tail = '...') {
function getSummary($str_size = 50, $tail = '...')
{
$content = $this->getContent(false,false);
// For a newlink, inert a whitespace
@ -454,11 +500,13 @@
return $content;
}
function getRegdate($format = 'Y.m.d H:i:s') {
function getRegdate($format = 'Y.m.d H:i:s')
{
return zdate($this->get('regdate'), $format);
}
function getRegdateTime() {
function getRegdateTime()
{
$regdate = $this->get('regdate');
$year = substr($regdate,0,4);
$month = substr($regdate,4,2);
@ -469,7 +517,8 @@
return mktime($hour,$min,$sec,$month,$day,$year);
}
function getRegdateGM() {
function getRegdateGM()
{
return $this->getRegdate('D, d M Y H:i:s').' '.$GLOBALS['_time_zone'];
}
@ -478,11 +527,13 @@
return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2);
}
function getUpdate($format = 'Y.m.d H:i:s') {
function getUpdate($format = 'Y.m.d H:i:s')
{
return zdate($this->get('last_update'), $format);
}
function getUpdateTime() {
function getUpdateTime()
{
$year = substr($this->get('last_update'),0,4);
$month = substr($this->get('last_update'),4,2);
$day = substr($this->get('last_update'),6,2);
@ -492,7 +543,8 @@
return mktime($hour,$min,$sec,$month,$day,$year);
}
function getUpdateGM() {
function getUpdateGM()
{
return gmdate("D, d M Y H:i:s", $this->getUpdateTime());
}
@ -501,11 +553,13 @@
return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2);
}
function getPermanentUrl() {
function getPermanentUrl()
{
return getFullUrl('','document_srl',$this->get('document_srl'));
}
function getTrackbackUrl() {
function getTrackbackUrl()
{
if(!$this->document_srl) return;
// Generate a key to prevent spams
$oTrackbackModel = &getModel('trackback');
@ -516,76 +570,91 @@
* Update readed count
* @return void
*/
function updateReadedCount() {
function updateReadedCount()
{
$oDocumentController = &getController('document');
if($oDocumentController->updateReadedCount($this)) {
if($oDocumentController->updateReadedCount($this))
{
$readed_count = $this->get('readed_count');
$this->add('readed_count', $readed_count+1);
}
}
function isExtraVarsExists() {
function isExtraVarsExists()
{
if(!$this->get('module_srl')) return false;
$oDocumentModel = &getModel('document');
$extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl'));
return count($extra_keys)?true:false;
}
function getExtraVars() {
function getExtraVars()
{
if(!$this->get('module_srl') || !$this->document_srl) return null;
$oDocumentModel = &getModel('document');
return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl);
}
function getExtraValue($idx) {
function getExtraValue($idx)
{
$extra_vars = $this->getExtraVars();
return $extra_vars[$idx]->value;
}
function getExtraValueHTML($idx) {
function getExtraValueHTML($idx)
{
$extra_vars = $this->getExtraVars();
if(is_array($extra_vars) && array_key_exists($idx,$extra_vars)){
if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
{
return $extra_vars[$idx]->getValueHTML();
}else{
}
else
{
return '';
}
}
function getExtraEidValue($eid) {
function getExtraEidValue($eid)
{
$extra_vars = $this->getExtraVars();
if($extra_vars)
{
// Handle extra variable(eid)
foreach($extra_vars as $idx => $key) {
foreach($extra_vars as $idx => $key)
{
$extra_eid[$key->eid] = $key;
}
}
return $extra_eid[$eid]->value;
}
function getExtraEidValueHTML($eid) {
function getExtraEidValueHTML($eid)
{
$extra_vars = $this->getExtraVars();
// Handle extra variable(eid)
foreach($extra_vars as $idx => $key) {
foreach($extra_vars as $idx => $key)
{
$extra_eid[$key->eid] = $key;
}
return $extra_eid[$eid]->getValueHTML();
}
function getExtraVarsValue($key) {
function getExtraVarsValue($key)
{
$extra_vals = unserialize($this->get('extra_vars'));
$val = $extra_vals->$key;
return $val;
}
function getCommentCount() {
function getCommentCount()
{
return $this->get('comment_count');
}
function getComments() {
function getComments()
{
if(!$this->getCommentCount()) return;
if(!$this->isGranted() && $this->isSecret()) return;
// cpage is a number of comment pages
@ -605,13 +674,15 @@
// If admin priviledge is granted on parent posts, you can read its child posts.
$accessible = array();
$comment_list = array();
foreach($output->data as $key => $val) {
foreach($output->data as $key => $val)
{
$oCommentItem = new commentItem();
$oCommentItem->setAttribute($val);
// If permission is granted to the post, you can access it temporarily
if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
// If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post
if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true) {
if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true)
{
$oCommentItem->setAccessible();
}
$comment_list[$val->comment_srl] = $oCommentItem;
@ -624,11 +695,13 @@
return $comment_list;
}
function getTrackbackCount() {
function getTrackbackCount()
{
return $this->get('trackback_count');
}
function getTrackbacks() {
function getTrackbacks()
{
if(!$this->document_srl) return;
if(!$this->allowTrackback() || !$this->get('trackback_count')) return;
@ -637,13 +710,15 @@
return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
}
function thumbnailExists($width = 80, $height = 0, $type = '') {
function thumbnailExists($width = 80, $height = 0, $type = '')
{
if(!$this->document_srl) return false;
if(!$this->getThumbnail($width, $height, $type)) return false;
return true;
}
function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') {
function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
{
// Return false if the document doesn't exist
if(!$this->document_srl) return;
// If not specify its height, create a square
@ -651,9 +726,11 @@
// Return false if neither attachement nor image files in the document
if(!$this->get('uploaded_count') && !preg_match("!<img!is", $this->get('content'))) return;
// Get thumbnai_type information from document module's configuration
if(!in_array($thumbnail_type, array('crop','ratio'))) {
if(!in_array($thumbnail_type, array('crop','ratio')))
{
$config = $GLOBALS['__document_config__'];
if(!$config) {
if(!$config)
{
$oDocumentModel = &getModel('document');
$config = $oDocumentModel->getDocumentConfig();
$GLOBALS['__document_config__'] = $config;
@ -665,7 +742,8 @@
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_url = Context::getRequestUri().$thumbnail_file;
// Return false if thumbnail file exists and its size is 0. Otherwise, return its path
if(file_exists($thumbnail_file)) {
if(file_exists($thumbnail_file))
{
if(filesize($thumbnail_file)<1) return false;
else return $thumbnail_url;
}
@ -673,11 +751,14 @@
$source_file = null;
$is_tmp_file = false;
// Find an iamge file among attached files if exists
if($this->get('uploaded_count')) {
if($this->get('uploaded_count'))
{
$oFileModel = &getModel('file');
$file_list = $oFileModel->getFiles($this->document_srl);
if(count($file_list)) {
foreach($file_list as $file) {
if(count($file_list))
{
foreach($file_list as $file)
{
if($file->direct_download!='Y') continue;
if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$file->source_filename)) continue;
@ -688,22 +769,27 @@
}
}
// If not exists, file an image file from the content
if(!$source_file) {
if(!$source_file)
{
$content = $this->get('content');
$target_src = null;
preg_match_all("!src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER);
$cnt = count($matches);
for($i=0;$i<$cnt;$i++) {
for($i=0;$i<$cnt;$i++)
{
$target_src = trim($matches[$i][2]);
if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$target_src)) continue;
if(preg_match('/\/(common|modules|widgets|addons|layouts)\//i', $target_src)) continue;
else {
else
{
if(!preg_match('/^(http|https):\/\//i',$target_src)) $target_src = Context::getRequestUri().$target_src;
$tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111,999999).$this->document_srl));
if(!is_dir('./files/cache/tmp')) FileHandler::makeDir('./files/cache/tmp');
FileHandler::getRemoteFile($target_src, $tmp_file);
if(!file_exists($tmp_file)) continue;
else {
else
{
list($_w, $_h, $_t, $_a) = @getimagesize($tmp_file);
if($_w<$width || $_h<$height) continue;
@ -715,7 +801,8 @@
}
}
if($source_file){
if($source_file)
{
$output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
}
if($is_tmp_file) FileHandler::removeFile($source_file);
@ -733,7 +820,8 @@
* @param int $time_interval
* @return array
*/
function getExtraImages($time_interval = 43200) {
function getExtraImages($time_interval = 43200)
{
if(!$this->document_srl) return;
// variables for icon list
$buffs = array();
@ -787,7 +875,8 @@
* @param int $time_check
* @return string
*/
function printExtraImages($time_check = 43200) {
function printExtraImages($time_check = 43200)
{
if(!$this->document_srl) return;
// Get the icon directory
$path = sprintf('%s%s',getUrl(), 'modules/document/tpl/icons/');
@ -796,13 +885,15 @@
if(!count($buffs)) return;
$buff = null;
foreach($buffs as $key => $val) {
foreach($buffs as $key => $val)
{
$buff .= sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val);
}
return $buff;
}
function hasUploadedFiles() {
function hasUploadedFiles()
{
if(!$this->document_srl) return;
if($this->isSecret() && !$this->isGranted()) return false;
@ -829,7 +920,8 @@
* Return Editor html
* @return string
*/
function getEditor() {
function getEditor()
{
$module_srl = $this->get('module_srl');
if(!$module_srl) $module_srl = Context::get('module_srl');
@ -842,7 +934,8 @@
* Authority to write a comment and to write a document is separated
* @return bool
*/
function isEnableComment() {
function isEnableComment()
{
// Return false if not authorized, if a secret document, if the document is set not to allow any comment
if (!$this->allowComment()) return false;
if(!$this->isGranted() && $this->isSecret()) return false;
@ -854,7 +947,8 @@
* Return comment editor's html
* @return string
*/
function getCommentEditor() {
function getCommentEditor()
{
if(!$this->isEnableComment()) return;
$oEditorModel = &getModel('editor');
@ -865,7 +959,8 @@
* Return author's profile image
* @return string
*/
function getProfileImage() {
function getProfileImage()
{
if(!$this->isExists() || !$this->get('member_srl')) return;
$oMemberModel = &getModel('member');
$profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
@ -878,19 +973,22 @@
* Return author's signiture
* @return string
*/
function getSignature() {
function getSignature()
{
// Pass if a document doesn't exist
if(!$this->isExists() || !$this->get('member_srl')) return;
// Get signature information
$oMemberModel = &getModel('member');
$signature = $oMemberModel->getSignature($this->get('member_srl'));
// Check if a maximum height of signiture is set in the member module
if(!isset($GLOBALS['__member_signature_max_height'])) {
if(!isset($GLOBALS['__member_signature_max_height']))
{
$oModuleModel = &getModel('module');
$member_config = $oModuleModel->getModuleConfig('member');
$GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height;
}
if($signature) {
if($signature)
{
$max_signature_height = $GLOBALS['__member_signature_max_height'];
if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
}
@ -903,7 +1001,8 @@
* @param array $matches
* @return mixed
*/
function replaceResourceRealPath($matches) {
function replaceResourceRealPath($matches)
{
return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]);
}
@ -956,7 +1055,8 @@
* Returns the document's mid in order to construct SEO friendly URLs
* @return string
*/
function getDocumentMid() {
function getDocumentMid()
{
$model = &getModel('module');
$module = $model->getModuleInfoByModuleSrl($this->get('module_srl'));
return $module->mid;
@ -966,7 +1066,8 @@
* Returns the document's type (document/page/wiki/board/etc)
* @return string
*/
function getDocumentType() {
function getDocumentType()
{
$model = &getModel('module');
$module = $model->getModuleInfoByModuleSrl($this->get('module_srl'));
return $module->module;
@ -976,7 +1077,8 @@
* Returns the document's alias
* @return string
*/
function getDocumentAlias() {
function getDocumentAlias()
{
$oDocumentModel = &getModel('document');
return $oDocumentModel->getAlias($this->document_srl);
}
@ -985,7 +1087,8 @@
* Returns the document's actual title (browser_title)
* @return string
*/
function getModuleName() {
function getModuleName()
{
$model = &getModel('module');
$module = $model->getModuleInfoByModuleSrl($this->get('module_srl'));
return $module->browser_title;
@ -995,6 +1098,6 @@
{
$this->getModuleName();
}
}
?>
/* End of file document.item.php */
/* Location: ./modules/document/document.item.php */

View file

@ -7,12 +7,14 @@
* @package /modules/document
* @version 0.1
*/
class documentModel extends document {
class documentModel extends document
{
/**
* Initialization
* @return void
*/
function init() {
function init()
{
}
/**
@ -20,7 +22,8 @@
* @param int $document_srl
* @return void
*/
function isGranted($document_srl) {
function isGranted($document_srl)
{
return $_SESSION['own_document'][$document_srl];
}
@ -45,13 +48,15 @@
* Extra variables for each article will not be processed bulk select and apply the macro city
* @return void
*/
function setToAllDocumentExtraVars() {
function setToAllDocumentExtraVars()
{
static $checked_documents = array();
// XE XE_DOCUMENT_LIST all documents that the object referred to the global variable settings
if(!count($GLOBALS['XE_DOCUMENT_LIST'])) return;
// Find all called the document object variable has been set extension
$document_srls = array();
foreach($GLOBALS['XE_DOCUMENT_LIST'] as $key => $val) {
foreach($GLOBALS['XE_DOCUMENT_LIST'] as $key => $val)
{
if(!$val->document_srl || $checked_documents[$val->document_srl]) continue;
$checked_documents[$val->document_srl] = true;
$document_srls[] = $val->document_srl;
@ -61,8 +66,10 @@
// Expand variables mijijeongdoen article about a current visitor to the extension of the language code, the search variable
//$obj->document_srl = implode(',',$document_srls);
$output = $this->getDocumentExtraVarsFromDB($document_srls);
if($output->toBool() && $output->data) {
foreach($output->data as $key => $val) {
if($output->toBool() && $output->data)
{
foreach($output->data as $key => $val)
{
if(!isset($val->value)) continue;
if(!$extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0]) $extra_vars[$val->module_srl][$val->document_srl][$val->var_idx][0] = trim($val->value);
$extra_vars[$val->document_srl][$val->var_idx][$val->lang_code] = trim($val->value);
@ -70,7 +77,8 @@
}
$user_lang_code = Context::getLangType();
for($i=0,$c=count($document_srls);$i<$c;$i++) {
for($i=0,$c=count($document_srls);$i<$c;$i++)
{
$document_srl = $document_srls[$i];
unset($vars);
@ -81,8 +89,10 @@
$vars = $extra_vars[$document_srl];
$document_lang_code = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->get('lang_code');
// Expand the variable processing
if(count($extra_keys)) {
foreach($extra_keys as $idx => $key) {
if(count($extra_keys))
{
foreach($extra_keys as $idx => $key)
{
$extra_keys[$idx] = clone($key);
$val = $vars[$idx];
if(isset($val[$user_lang_code])) $v = $val[$user_lang_code];
@ -101,7 +111,8 @@
// Information processing
if($vars[-2][$user_lang_code]) $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->add('content',$vars[-2][$user_lang_code]);
if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code]){
if($vars[-1][$user_lang_code] || $vars[-2][$user_lang_code])
{
unset($checked_documents[$document_srl]);
}
@ -117,10 +128,12 @@
* @param array $columnList
* @return documentItem
*/
function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array()) {
function getDocument($document_srl=0, $is_admin = false, $load_extra_vars=true, $columnList = array())
{
if(!$document_srl) return new documentItem();
if(!isset($GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) || $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->columnListKey != serialize($columnList)) {
if(!isset($GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) || $GLOBALS['XE_DOCUMENT_LIST'][$document_srl]->columnListKey != serialize($columnList))
{
$oDocument = new documentItem($document_srl, $load_extra_vars, $columnList);
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
if($load_extra_vars) $this->setToAllDocumentExtraVars();
@ -139,11 +152,15 @@
* @param array $columnList
* @return array value type is documentItem
*/
function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array()) {
if(is_array($document_srls)) {
function getDocuments($document_srls, $is_admin = false, $load_extra_vars=true, $columnList = array())
{
if(is_array($document_srls))
{
$list_count = count($document_srls);
$document_srls = implode(',',$document_srls);
} else {
}
else
{
$list_count = 1;
}
$args->document_srls = $document_srls;
@ -156,11 +173,13 @@
if(!is_array($document_list)) $document_list = array($document_list);
$document_count = count($document_list);
foreach($document_list as $key => $attribute) {
foreach($document_list as $key => $attribute)
{
$document_srl = $attribute->document_srl;
if(!$document_srl) continue;
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) {
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
{
$oDocument = null;
$oDocument = new documentItem();
$oDocument->setAttribute($attribute, false);
@ -174,8 +193,10 @@
if($load_extra_vars) $this->setToAllDocumentExtraVars();
$output = null;
if(count($result)) {
foreach($result as $document_srl => $val) {
if(count($result))
{
foreach($result as $document_srl => $val)
{
$output[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
}
}
@ -191,12 +212,14 @@
* @param array $columnList
* @return Object
*/
function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array()) {
function getDocumentList($obj, $except_notice = false, $load_extra_vars=true, $columnList = array())
{
$sort_check = $this->_setSortIndex($obj, $load_extra_vars);
$obj->sort_index = $sort_check->sort_index;
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()){
if($oCacheHandler->isSupport())
{
$object_key = 'object:'.$obj->module_srl.'_category_srl:'.$obj->category_srl.'_list_count:'.$obj->list_count.'_search_target:'.$obj->search_target.'_search_keyword:'.$obj->search_keyword.'_page'.$obj->page.'_sort_index:'.$obj->sort_index.'_order_type:'.$obj->order_type;
$cache_key = $oCacheHandler->getGroupKey('documentList', $object_key);
$output = $oCacheHandler->get($cache_key);
@ -218,13 +241,15 @@
// document.getDocumentList query execution
// Query_id if you have a group by clause getDocumentListWithinTag getDocumentListWithinComment or used again to perform the query because
$groupByQuery = array('document.getDocumentListWithinComment' => 1, 'document.getDocumentListWithinTag' => 1);
if(isset($groupByQuery[$query_id])) {
if(isset($groupByQuery[$query_id]))
{
$group_args = clone($args);
$group_args->sort_index = 'documents.'.$args->sort_index;
$output = executeQueryArray($query_id, $group_args);
if(!$output->toBool()||!count($output->data)) return $output;
foreach($output->data as $key => $val) {
foreach($output->data as $key => $val)
{
if($val->document_srl) $target_srls[] = $val->document_srl;
}
@ -242,7 +267,9 @@
$output->total_count = $page_navigation->total_count;
$output->total_page = $page_navigation->total_page;
$output->page = $page_navigation->cur_page;
} else {
}
else
{
$output = executeQueryArray($query_id, $args, $columnList);
}
}
@ -258,16 +285,20 @@
$virtual_number = $keys[0];
}
if($except_notice) {
foreach($data as $key => $attribute) {
if($except_notice)
{
foreach($data as $key => $attribute)
{
if($attribute->is_notice == 'Y') $virtual_number --;
}
}
foreach($data as $key => $attribute) {
foreach($data as $key => $attribute)
{
if($except_notice && $attribute->is_notice == 'Y') continue;
$document_srl = $attribute->document_srl;
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) {
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
{
$oDocument = null;
$oDocument = new documentItem();
$oDocument->setAttribute($attribute, false);
@ -277,13 +308,14 @@
$output->data[$virtual_number] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
$virtual_number --;
}
if($load_extra_vars) $this->setToAllDocumentExtraVars();
if(count($output->data)) {
foreach($output->data as $number => $document) {
if(count($output->data))
{
foreach($output->data as $number => $document)
{
$output->data[$number] = $GLOBALS['XE_DOCUMENT_LIST'][$document->document_srl];
}
}
@ -299,17 +331,20 @@
* @param array $columnList
* @return object|void
*/
function getNoticeList($obj, $columnList = array()) {
function getNoticeList($obj, $columnList = array())
{
$args->module_srl = $obj->module_srl;
$args->category_srl= $obj->category_srl;
$output = executeQueryArray('document.getNoticeList', $args, $columnList);
if(!$output->toBool()||!$output->data) return;
foreach($output->data as $key => $val) {
foreach($output->data as $key => $val)
{
$document_srl = $val->document_srl;
if(!$document_srl) continue;
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl]) {
if(!$GLOBALS['XE_DOCUMENT_LIST'][$document_srl])
{
$oDocument = null;
$oDocument = new documentItem();
$oDocument->setAttribute($val, false);
@ -319,7 +354,8 @@
}
$this->setToAllDocumentExtraVars();
foreach($result->data as $document_srl => $val) {
foreach($result->data as $document_srl => $val)
{
$result->data[$document_srl] = $GLOBALS['XE_DOCUMENT_LIST'][$document_srl];
}
@ -332,8 +368,10 @@
* @param int $module_srl
* @return array
*/
function getExtraKeys($module_srl) {
if(is_null($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) {
function getExtraKeys($module_srl)
{
if(is_null($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
{
$oExtraVar = &ExtraVar::getInstance($module_srl);
$obj->module_srl = $module_srl;
$obj->sort_index = 'var_idx';
@ -399,8 +437,10 @@
* @param int $document_srl
* @return array
*/
function getExtraVars($module_srl, $document_srl) {
if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl])) {
function getExtraVars($module_srl, $document_srl)
{
if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl]))
{
// Extended to extract the values of variables set
$oDocument = $this->getDocument($document_srl, false);
$GLOBALS['XE_DOCUMENT_LIST'][$document_srl] = $oDocument;
@ -415,7 +455,8 @@
* Printing, scrap, recommendations and negative, reported the Add Features
* @return void
*/
function getDocumentMenu() {
function getDocumentMenu()
{
// Post number and the current login information requested Wanted
$document_srl = Context::get('target_srl');
$mid = Context::get('cur_mid');
@ -428,8 +469,8 @@
$oDocumentController = &getController('document');
// Members must be a possible feature
if($logged_info->member_srl) {
if($logged_info->member_srl)
{
$oDocumentModel = &getModel('document');
$columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress');
$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
@ -439,13 +480,15 @@
$oModuleModel = &getModel('module');
$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
if($document_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl){
if($document_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl)
{
// Add a Referral Button
$url = sprintf("doCallModuleAction('document','procDocumentVoteUp','%s')", $document_srl);
$oDocumentController->addDocumentPopupMenu($url,'cmd_vote','','javascript');
}
if($document_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl){
if($document_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl)
{
// Add button to negative
$url= sprintf("doCallModuleAction('document','procDocumentVoteDown','%s')", $document_srl);
$oDocumentController->addDocumentPopupMenu($url,'cmd_vote_down','','javascript');
@ -465,11 +508,13 @@
// Call a trigger (after)
ModuleHandler::triggerCall('document.getDocumentMenu', 'after', $menu_list);
// If you are managing to find posts by ip
if($logged_info->is_admin == 'Y') {
if($logged_info->is_admin == 'Y')
{
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl); //before setting document recycle
if($oDocument->isExists()) {
if($oDocument->isExists())
{
// Find a post equivalent to ip address
$url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','ipaddress','search_keyword',$oDocument->getIpAddress());
$oDocumentController->addDocumentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress');
@ -481,7 +526,8 @@
// Changing the language of pop-up menu
$menus = Context::get('document_popup_menu_list');
$menus_count = count($menus);
for($i=0;$i<$menus_count;$i++) {
for($i=0;$i<$menus_count;$i++)
{
$menus[$i]->str = Context::getLang($menus[$i]->str);
}
// Wanted to finally clean pop-up menu list
@ -494,7 +540,8 @@
* @param object $search_obj
* @return int
*/
function getDocumentCount($module_srl, $search_obj = NULL) {
function getDocumentCount($module_srl, $search_obj = NULL)
{
// Additional search options
$args->module_srl = $module_srl;
$args->s_title = $search_obj->s_title;
@ -516,7 +563,8 @@
* @param object $search_obj
* @return array
*/
function getDocumentCountByGroupStatus($search_obj = NULL) {
function getDocumentCountByGroupStatus($search_obj = NULL)
{
// Additional search options
$args->module_srl = $search_obj->module_srl;
$args->s_title = $search_obj->s_title;
@ -555,7 +603,8 @@
* @param object $opt
* @return int
*/
function getDocumentPage($oDocument, $opt) {
function getDocumentPage($oDocument, $opt)
{
$this->_setSearchOption($opt, $args, $query_id, $use_division);
$sort_check = $this->_setSortIndex($args, TRUE);
@ -595,18 +644,22 @@
* @param array $columnList
* @return object
*/
function getCategory($category_srl, $columnList = array()) {
function getCategory($category_srl, $columnList = array())
{
$args->category_srl = $category_srl;
$output = executeQuery('document.getCategory', $args, $columnList);
$node = $output->data;
if(!$node) return;
if($node->group_srls) {
if($node->group_srls)
{
$group_srls = explode(',',$node->group_srls);
unset($node->group_srls);
$node->group_srls = $group_srls;
} else {
}
else
{
unset($node->group_srls);
$node->group_srls = array();
}
@ -618,7 +671,8 @@
* @param int $category_srl
* @return bool
*/
function getCategoryChlidCount($category_srl) {
function getCategoryChlidCount($category_srl)
{
$args->category_srl = $category_srl;
$output = executeQuery('document.getChildCategoryCount',$args);
if($output->data->count > 0) return true;
@ -632,11 +686,13 @@
* @param array $columnList
* @return array
*/
function getCategoryList($module_srl, $columnList = array()) {
function getCategoryList($module_srl, $columnList = array())
{
// Category of the target module file swollen
$filename = sprintf("./files/cache/document_category/%s.php", $module_srl);
// If the target file to the cache file regeneration category
if(!file_exists($filename)) {
if(!file_exists($filename))
{
$oDocumentController = &getController('document');
if(!$oDocumentController->makeCategoryFile($module_srl)) return array();
}
@ -655,11 +711,13 @@
* @param int $depth
* @return void
*/
function _arrangeCategory(&$document_category, $list, $depth) {
function _arrangeCategory(&$document_category, $list, $depth)
{
if(!count($list)) return;
$idx = 0;
$list_order = array();
foreach($list as $key => $val) {
foreach($list as $key => $val)
{
$obj = null;
$obj->mid = $val['mid'];
$obj->module_srl = $val['module_srl'];
@ -682,14 +740,15 @@
$list_order[$idx++] = $obj->category_srl;
// If you have a parent category of child nodes apply data
if($obj->parent_srl) {
if($obj->parent_srl)
{
$parent_srl = $obj->parent_srl;
$document_count = $obj->document_count;
$expand = $obj->expand;
if($selected) $expand = true;
while($parent_srl) {
while($parent_srl)
{
$document_category[$parent_srl]->document_count += $document_count;
$document_category[$parent_srl]->childs[] = $obj->category_srl;
$document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs);
@ -713,7 +772,8 @@
* @param int $category_srl
* @return int
*/
function getCategoryDocumentCount($module_srl, $category_srl) {
function getCategoryDocumentCount($module_srl, $category_srl)
{
$args->module_srl = $module_srl;
$args->category_srl = $category_srl;
$output = executeQuery('document.getCategoryDocumentCount', $args);
@ -725,9 +785,11 @@
* @param int $module_srl
* @return string
*/
function getCategoryXmlFile($module_srl) {
function getCategoryXmlFile($module_srl)
{
$xml_file = sprintf('files/cache/document_category/%s.xml.php',$module_srl);
if(!file_exists($xml_file)) {
if(!file_exists($xml_file))
{
$oDocumentController = &getController('document');
$oDocumentController->makeCategoryFile($module_srl);
}
@ -739,9 +801,11 @@
* @param int $module_srl
* @return string
*/
function getCategoryPhpFile($module_srl) {
function getCategoryPhpFile($module_srl)
{
$php_file = sprintf('files/cache/document_category/%s.php',$module_srl);
if(!file_exists($php_file)) {
if(!file_exists($php_file))
{
$oDocumentController = &getController('document');
$oDocumentController->makeCategoryFile($module_srl);
}
@ -753,8 +817,10 @@
* @param object $obj
* @return object
*/
function getMonthlyArchivedList($obj) {
if($obj->mid) {
function getMonthlyArchivedList($obj)
{
if($obj->mid)
{
$oModuleModel = &getModel('module');
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
unset($obj->mid);
@ -776,8 +842,10 @@
* @param object $obj
* @return object
*/
function getDailyArchivedList($obj) {
if($obj->mid) {
function getDailyArchivedList($obj)
{
if($obj->mid)
{
$oModuleModel = &getModel('module');
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
unset($obj->mid);
@ -799,15 +867,18 @@
* Get a list for a particular module
* @return void|Object
*/
function getDocumentCategories() {
function getDocumentCategories()
{
if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
$module_srl = Context::get('module_srl');
$categories= $this->getCategoryList($module_srl);
$lang = Context::get('lang');
// No additional category
$output = "0,0,{$lang->none_category}\n";
if($categories){
foreach($categories as $category_srl => $category) {
if($categories)
{
foreach($categories as $category_srl => $category)
{
$output .= sprintf("%d,%d,%s\n",$category_srl, $category->depth,$category->title);
}
}
@ -818,8 +889,10 @@
* Wanted to set document information
* @return object
*/
function getDocumentConfig() {
if(!$GLOBALS['__document_config__']) {
function getDocumentConfig()
{
if(!$GLOBALS['__document_config__'])
{
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('document');
if(!$config->thumbnail_type) $config->thumbnail_type = 'crop';
@ -834,7 +907,8 @@
* @param int $module_srl
* @return string
*/
function getExtraVarsHTML($module_srl) {
function getExtraVarsHTML($module_srl)
{
// Bringing existing extra_keys
$extra_keys = $this->getExtraKeys($module_srl);
Context::set('extra_keys', $extra_keys);
@ -851,7 +925,8 @@
* @param int $module_srl
* @return string
*/
function getCategoryHTML($module_srl) {
function getCategoryHTML($module_srl)
{
$category_xml_file = $this->getCategoryXmlFile($module_srl);
Context::set('category_xml_file', $category_xml_file);
@ -876,7 +951,8 @@
* Manager on the page to add information about a particular menu from the server after compiling tpl compiled a direct return html
* @return void|Object
*/
function getDocumentCategoryTplInfo() {
function getDocumentCategoryTplInfo()
{
$oModuleModel = &getModel('module');
$oMemberModel = &getModel('member');
// Get information on the menu for the parameter settings
@ -927,7 +1003,8 @@
$args->title = $title;
$output = executeQuery('document.getDocumentSrlByTitle', $args);
if(!$output->data) return null;
else {
else
{
if(is_array($output->data)) return $output->data[0]->document_srl;
return $output->data->document_srl;
}
@ -938,7 +1015,8 @@
* @param int $document_srl
* @return string|void
*/
function getAlias($document_srl){
function getAlias($document_srl)
{
if(!$document_srl) return null;
$args->document_srl = $document_srl;
$output = executeQueryArray('document.getAliases', $args);
@ -980,7 +1058,8 @@
* @param object $obj
* @return object
*/
function getTrashList($obj) {
function getTrashList($obj)
{
// Variable check
$args->category_srl = $obj->category_srl?$obj->category_srl:null;
$args->sort_index = $obj->sort_index;
@ -991,8 +1070,10 @@
// Search options
$search_target = $obj->search_target;
$search_keyword = $obj->search_keyword;
if($search_target && $search_keyword) {
switch($search_target) {
if($search_target && $search_keyword)
{
switch($search_target)
{
case 'title' :
case 'content' :
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
@ -1039,10 +1120,11 @@
}
}
$output = executeQueryArray('document.getTrashList', $args);
if($output->data){
foreach($output->data as $key => $attribute) {
if($output->data)
{
foreach($output->data as $key => $attribute)
{
$oDocument = null;
$oDocument = new documentItem();
$oDocument->setAttribute($attribute, false);
@ -1072,10 +1154,13 @@
$oModuleModel = &getModel('module');
$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
if($point == -1){
if($point == -1)
{
if($document_config->use_vote_down!='S') return new Object(-1, 'msg_invalid_request');
$args->below_point = 0;
}else{
}
else
{
if($document_config->use_vote_up!='S') return new Object(-1, 'msg_invalid_request');
$args->more_point = 0;
}
@ -1086,8 +1171,10 @@
if(!$output->toBool()) return $output;
$oMemberModel = &getModel('member');
if($output->data){
foreach($output->data as $k => $d){
if($output->data)
{
foreach($output->data as $k => $d)
{
$profile_image = $oMemberModel->getProfileImage($d->member_srl);
$output->data[$k]->src = $profile_image->src;
}
@ -1132,7 +1219,8 @@
else
{
$check_array = array();
foreach($extra_output->data as $val){
foreach($extra_output->data as $val)
{
$check_array[] = $val->eid;
}
if(!in_array($sortIndex, $check_array)) $sortIndex = 'list_order';
@ -1180,7 +1268,8 @@
if(!isset($orderType[$args->order_type])) $args->order_type = 'asc';
// If that came across mid module_srl instead of a direct module_srl guhaejum
if($searchOpt->mid) {
if($searchOpt->mid)
{
$oModuleModel = &getModel('module');
$args->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
unset($searchOpt->mid);
@ -1194,7 +1283,6 @@
if(is_array($searchOpt->exclude_module_srl)) $args->exclude_module_srl = implode(',', $searchOpt->exclude_module_srl);
else $args->exclude_module_srl = $searchOpt->exclude_module_srl;
// only admin document list, temp document showing
if($searchOpt->statusList) $args->statusList = $searchOpt->statusList;
else
@ -1206,7 +1294,8 @@
}
// Category is selected, further sub-categories until all conditions
if($args->category_srl) {
if($args->category_srl)
{
$category_list = $this->getCategoryList($args->module_srl);
$category_info = $category_list[$args->category_srl];
$category_info->childs[] = $args->category_srl;
@ -1223,8 +1312,10 @@
$search_target = $searchOpt->search_target;
$search_keyword = $searchOpt->search_keyword;
if($search_target && $search_keyword) {
switch($search_target) {
if($search_target && $search_keyword)
{
switch($search_target)
{
case 'title' :
case 'content' :
if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword);
@ -1305,7 +1396,8 @@
/**
* If it is true, use_division changed to use the document division
*/
if($use_division) {
if($use_division)
{
// Division begins
$division = (int)Context::get('division');
@ -1344,7 +1436,8 @@
$last_division = (int)Context::get('last_division');
// Division after division from the 5000 value of the specified Wanted
if(!$last_division) {
if(!$last_division)
{
$last_division_args->module_srl = $args->module_srl;
$last_division_args->exclude_module_srl = $args->exclude_module_srl;
$last_division_args->list_count = 1;
@ -1354,7 +1447,8 @@
$last_division_args->page = 5001;
$output = executeQuery($divisionSqlID, $last_division_args, array('list_order'));
if($output->data) {
if($output->data)
{
$item = array_pop($output->data);
$last_division = $item->list_order;
}
@ -1379,4 +1473,5 @@
}
}
}
?>
/* End of file document.model.php */
/* Location: ./modules/document/document.model.php */

View file

@ -7,12 +7,14 @@
* @package /modules/document
* @version 0.1
*/
class documentView extends document {
class documentView extends document
{
/**
* Initialization
* @return void
*/
function init() {
function init()
{
}
/**
@ -20,7 +22,8 @@
* I make it out to find the geulman;;
* @return void|Object
*/
function dispDocumentPrint() {
function dispDocumentPrint()
{
// Bring a list of variables needed to implement
$document_srl = Context::get('document_srl');
@ -50,7 +53,8 @@
* Preview
* @return void
*/
function dispDocumentPreview() {
function dispDocumentPreview()
{
Context::set('layout','none');
$content = Context::get('content');
@ -62,18 +66,22 @@
* Selected by the administrator for the document management
* @return void|Object
*/
function dispDocumentManageDocument() {
function dispDocumentManageDocument()
{
if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
// Taken from a list of selected sessions
$flag_list = $_SESSION['document_management'];
if(count($flag_list)) {
foreach($flag_list as $key => $val) {
if(count($flag_list))
{
foreach($flag_list as $key => $val)
{
if(!is_bool($val)) continue;
$document_srl_list[] = $key;
}
}
if(count($document_srl_list)) {
if(count($document_srl_list))
{
$oDocumentModel = &getModel('document');
$document_list = $oDocumentModel->getDocuments($document_srl_list, $this->grant->is_admin);
Context::set('document_list', $document_list);
@ -89,7 +97,6 @@
Context::set('mid',$module_info->mid);
Context::set('browser_title',$module_info->browser_title);
// Select Pop-up layout
$this->setLayoutPath('./common/tpl');
$this->setLayoutFile('popup_layout');
@ -104,11 +111,13 @@
* @param string $obj
* @return Object
*/
function triggerDispDocumentAdditionSetup(&$obj) {
function triggerDispDocumentAdditionSetup(&$obj)
{
$current_module_srl = Context::get('module_srl');
$current_module_srls = Context::get('module_srls');
if(!$current_module_srl && !$current_module_srls) {
if(!$current_module_srl && !$current_module_srls)
{
// Get information of the current module
$current_module_info = Context::get('current_module_info');
$current_module_srl = $current_module_info->module_srl;
@ -160,4 +169,5 @@
$this->setTemplateFile('saved_list_popup');
}
}
?>
/* End of file document.view.php */
/* Location: ./modules/document/document.view.php */