pixmicat

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/PMC2Prototype/ @ 375  →  /PMC2Prototype/ @ 376
/PMC2Prototype/resource/xmlhttp.js
@@ -67,25 +67,26 @@
if(template.match(/<!--&SEPARATE-->([\s\S]*)<!--\/&SEPARATE-->/)){ Trender.PTE.cache.SEPARATE = RegExp.$1.replace(/&nbsp;/g, '&#160;'); }
},
_replaceMain : function(obj){
var arrLabels = {'{$NO}' : obj.no, '{$SUB}' : obj.sub, '{$NAME}' : obj.name, '{$NOW}' : obj.now, '{$COM}' : obj.com} //, '{$CATEGORY}' : $category, '{$QUOTEBTN}' : $QUOTEBTN, '{$IMG_BAR}' : $IMG_BAR, '{$IMG_SRC}' : $imgsrc, '{$WARN_BEKILL}' : $WARN_BEKILL, '{$QUOTEBTN}' : $QUOTEBTN};
var arrLabels = {'{$NO}' : obj.no, '{$SUB}' : obj.sub, '{$NAME}' : obj.name, '{$NOW}' : obj.now, '{$COM}' : obj.com, '{$CATEGORY}' : obj.category, '{$QUOTEBTN}' : '', '{$REPLYBTN}' : '', '{$IMG_BAR}' : obj.imgbar, '{$IMG_SRC}' : obj.imgsrc, '{$WARN_OLD}' : obj.WARN_OLD, '{$WARN_BEKILL}' : obj.WARN_BEKILL, '{$QUOTEBTN}' : '', '{$WARN_ENDREPLY}' : obj.WARN_ENDREPLY, '{$WARN_HIDEPOST}' : obj.hiddenReply};
var dat = Trender.PTE._evalIf(Trender.PTE.cache.MAIN, arrLabels);
for(l in arrLabels){
dat = dat.replace(new RegExp(l.replace('$', '\\$'), 'g'), arrLabels[l]);
}
for(l in arrLabels){ dat = dat.replace(new RegExp(l.replace('$', '\\$'), 'g'), arrLabels[l]); }
return dat;
},
_replaceReply : function(obj){
var arrLabels = {'{$NO}' : obj.no, '{$SUB}' : obj.sub, '{$NAME}' : obj.name, '{$NOW}' : obj.now, '{$COM}' : obj.com} //, '{$CATEGORY}' : $category, '{$QUOTEBTN}' : $QUOTEBTN, '{$IMG_BAR}' : $IMG_BAR, '{$IMG_SRC}' : $imgsrc, '{$WARN_BEKILL}' : $WARN_BEKILL, '{$QUOTEBTN}' : $QUOTEBTN};
var arrLabels = {'{$NO}' : obj.no, '{$SUB}' : obj.sub, '{$NAME}' : obj.name, '{$NOW}' : obj.now, '{$COM}' : obj.com, '{$CATEGORY}' : obj.category, '{$QUOTEBTN}' : '', '{$IMG_BAR}' : obj.imgbar, '{$IMG_SRC}' : obj.imgsrc, '{$WARN_BEKILL}' : obj.WARN_BEKILL, '{$QUOTEBTN}' : ''};
var dat = Trender.PTE._evalIf(Trender.PTE.cache.REPLY, arrLabels);
for(l in arrLabels){
dat = dat.replace(new RegExp(l.replace('$', '\\$'), 'g'), arrLabels[l]);
}
for(var l in arrLabels){ dat = dat.replace(new RegExp(l.replace('$', '\\$'), 'g'), arrLabels[l]); }
return dat;
},
_replaceSeparate : function(){
return Trender.PTE.cache.SEPARATE;
},
_evalIf : function(dat, arrLabels){
var vari, ifTrue, ifFalse;
while(dat.match(/(<!--&IF\((\$.*),\'(.*)\',\'(.*)\'\)-->)/)){
vari = RegExp.$2; ifTrue = RegExp.$3; ifFalse = RegExp.$4;
dat = dat.replace(RegExp.$1, (arrLabels['{'+vari+'}'] ? ifTrue : ifFalse));
}
return dat;
},
init : function(){
/PMC2Prototype/resource/pixmicat_ajax.tmpl
@@ -36,6 +36,7 @@
<tr><td class="Form_bg"><b>標 題</b></td><td><input class="hide" value="DO NOT FIX THIS" type="text" name="sub" /><input type="text" name="<?php echo PMCCore_getConfig('FIELDTRAP.SUBJECT');?>" id="fsub" size="28" /><input type="submit" name="sendbtn" value="送 出" /></td></tr>
<tr><td class="Form_bg"><b>內 文</b></td><td><textarea name="<?php echo PMCCore_getConfig('FIELDTRAP.COMMENT');?>" id="fcom" cols="48" rows="4" style="width: 400px; height: 80px;"></textarea><textarea name="com" class="hide" cols="48" rows="4">EID OG SMAPS</textarea></td></tr>
<tr><td class="Form_bg"><b>附加圖檔</b></td><td><input type="file" name="upfile" id="fupfile" size="25" /> <input class="hide" type="checkbox" name="reply" value="yes" />[<input type="checkbox" name="noimg" id="noimg" value="on" /><label for="noimg">無貼圖</label>] [<input type="checkbox" name="up_series" id="up_series" value="on" /><label for="up_series">連貼機能</label>]</td></tr>
<tr><td class="Form_bg"><b>類別標籤</b></td><td><input type="text" name="category" size="28" /><small>(請以 , 逗號分隔多個標籤)</small></td></tr>
<tr><td class="Form_bg"><b>刪除用密碼</b></td><td><input type="password" name="pwd" size="8" maxlength="8" value="" /><small>(刪除文章用。英數字8字元以內)</small></td></tr>
<tr><td colspan="2">
<div id="postinfo">
/PMC2Prototype/action/action_ajax.php
@@ -13,12 +13,22 @@
function updateCache(){
global $PIO, $FileIO;
 
$kill_sensor = $old_sensor = false; $arr_kill = $arr_old = array(); // 預測系統啟動旗標及記錄陣列
$arr_kill = $arr_old = array(); // 預測系統啟動旗標及記錄陣列
$threads = $PIO->fetchThreadList(); $threadsCount = count($threads); // 全討論串列表
$threadsPerPage = PMCCore_getConfig('PAGE_DEF'); // 每頁顯示討論串數
$maxThreadsPerPage = $threadsCount > $threadsPerPage ? $threadsPerPage : $threadsCount;
$pageEnd = ceil($threadsCount / $threadsPerPage); // 頁面編號最後值
 
// 預測過舊文章和將被刪除檔案
if($PIO->postCount() >= PMCCore_getConfig('LOG_MAX') * 0.95){
$arr_old = array_flip($PIO->fetchPostList()); // 過舊文章陣列
}
$tmp_total_size = $FileIO->getImageTotalSize();
$tmp_STORAGE_MAX = PMCCore_getConfig('STORAGE.MAX') * (($tmp_total_size >= PMCCore_getConfig('STORAGE.MAX')) ? 1 : 0.95); // 預估上限值
if(PMCCore_getConfig('STORAGE.LIMIT') && ($tmp_total_size >= $tmp_STORAGE_MAX)){
$arr_kill = $PIO->delOldAttachments($tmp_total_size, $tmp_STORAGE_MAX); // 過舊附檔陣列
}
 
for($i = 1; $i <= $pageEnd; $i++){
$thdat = '{"status":"OK","pageMax":'.$pageEnd.',"pageCurrent":'.$i.',"threads":[';
$arrThreads = array();
@@ -26,8 +36,13 @@
// make every threads in one page
$pid = ($i - 1) * $threadsPerPage + $p;
$tid = $PIO->fetchPostList($threads[$pid]); // 取得特定討論串之編號結構
$post = $PIO->fetchPosts($tid); // 取出資料
$arrThreads[] = arrangeThread($post); // 輸出 JSON
 
$RESstart = count($tid) - PMCCore_getConfig('RE_DEF'); if($RESstart < 1) $RESstart = 1; // 開始
// $RESstart, $RESamount 拿去算新討論串結構 (部分回應隱藏)
$tree_cut = array_slice($tid, $RESstart, PMCCore_getConfig('RE_DEF')); array_unshift($tree_cut, $threads[$pid]); // 取出特定範圍回應
$post = $PIO->fetchPosts($tree_cut); // 取得文章架構內容
 
$arrThreads[] = arrangeThread($post, $RESstart - 1, $arr_kill, $arr_old); // 輸出 JSON
if($pid >= $threadsCount - 1) break;
}
$thdat .= implode(',', $arrThreads).']}';
@@ -40,14 +55,51 @@
}
 
// 輸出討論串 JSON 結構
function arrangeThread($post){
function arrangeThread($post, $hiddenReply, $arr_kill, $arr_old){
global $PIO, $FileIO;
$dat = '';
$postCount = count($post);
extract($post[0]);
$dat = '{"no":'.$no.',"now":"'.$now.'","name":"'.$name.'","email":"'.$email.'","sub":"'.$sub.'","com":"'.$com.'","replies":[';
$arrReplies = array();
for($i = 1; $i < $postCount; $i++){
for($i = 0; $i < $postCount; $i++){
$IMG_SRC = $IMG_BAR = '';
extract($post[$i]);
$arrReplies[] = '{"no":'.$no.',"now":"'.$now.'","name":"'.$name.'","email":"'.$email.'","sub":"'.$sub.'","com":"'.$com.'"}';
// 修整資料以便輸出為 JSON
 
// 圖檔
if($ext && $FileIO->imageExists($tim.$ext)){
$imageURL = $FileIO->getImageURL($tim.$ext); // image URL
$thumbURL = $FileIO->getImageURL($tim.'s.jpg'); // thumb URL
 
$IMG_SRC = '<a href=\\"'.$imageURL.'" rel=\\"_blank\\"><img src=\\"nothumb.gif\\" class=\\"img\\" alt=\\"'.$imgsize.'\\" title=\\"'.$imgsize.'\\" /></a>'; // 預設顯示圖樣式 (無預覽圖時)
if($tw && $th){
if($FileIO->imageExists($tim.'s.jpg')){ // 有預覽圖
$img_thumb = '<small>'._T('img_sample').'</small>';
$IMG_SRC = '<a href=\\"'.$imageURL.'\\" rel=\\"_blank\\"><img src=\\"'.$thumbURL.'\\" style=\\"width: '.$tw.'px; height: '.$th.'px;\\" class=\\"img\\" alt=\\"'.$imgsize.'\\" title=\\"'.$imgsize.'\\" /></a>';
}elseif($ext=='.swf') $IMG_SRC = ''; // swf檔案不需預覽圖
}
if(PMCCore_getConfig('SHOW_IMGWH')) $imgwh_bar = ', '.$imgw.'x'.$imgh; // 顯示附加圖檔之原檔長寬尺寸
$IMG_BAR = _T('img_filename').'<a href=\\"'.$imageURL.'\\" rel=\\"_blank\\">'.$tim.$ext.'</a>-('.$imgsize.$imgwh_bar.') '.$img_thumb;
}
 
// 提示標籤
$WARN_BEKILL = isset($arr_kill[$no]) ? '<span class=\\"warn_txt\\">'._T('warn_sizelimit').'</span><br />' : ''; // 預測刪除過大檔
if(!$i){ // 首篇 Only
$WARN_OLD = (isset($arr_old[$no]) && $arr_old[$no] + 1 >= PMCCore_getConfig('LOG_MAX') * 0.95) ? '<span class=\\"warn_txt\\">'._T('warn_oldthread').'</span><br />' : '';
$WARN_ENDREPLY = $PIO->getPostStatus($status, 'TS') ? '<span class=\\"warn_txt\\">'._T('warn_locked').'</span><br />' : '';
$hiddenReply = $hiddenReply ? '<span class=\\"warn_txt2\\">'._T('notice_omitted', $hiddenReply).'</span><br />' : '';
}
 
// 類別
$ary_category = explode(',', str_replace('&#44;', ',', $category)); $ary_category = array_map('trim', $ary_category);
$ary_category_count = count($ary_category);
$ary_category2 = array();
for($p = 0; $p < $ary_category_count; $p++){
if($c = $ary_category[$p]) $ary_category2[] = '<a href=\\"'.PMCCore_getConfig('ENV.PHP_SELF').'/search_ajax/category/'.urlencode($c).'\\">'.$c.'</a>';
}
$category = implode(', ', $ary_category2);
 
if($i===0){ $dat = '{"hiddenReply":"'.$hiddenReply.'","no":'.$no.',"now":"'.$now.'","name":"'.$name.'","email":"'.$email.'","sub":"'.$sub.'","com":"'.$com.'","category":"'.$category.'","imgsrc":"'.$IMG_SRC.'","imgbar":"'.$IMG_BAR.'","WARN_BEKILL":"'.$WARN_BEKILL.'","WARN_OLD":"'.$WARN_OLD.'","WARN_ENDREPLY":"'.$WARN_ENDREPLY.'","replies":['; continue; }
$arrReplies[] = '{"no":'.$no.',"now":"'.$now.'","name":"'.$name.'","email":"'.$email.'","sub":"'.$sub.'","com":"'.$com.'","category":"'.$category.'","imgsrc":"'.$IMG_SRC.'","imgbar":"'.$IMG_BAR.'","WARN_BEKILL":"'.$WARN_BEKILL.'"}';
}
if(count($arrReplies)) $dat .= implode(',', $arrReplies);
$dat .= ']}';