pixmicat

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/ @ 885  →  / @ 886
/Modules/mod_catalog/mod_catalog.php
@@ -5,13 +5,14 @@
*/
 
class mod_catalog{
var $CATALOG_NUMBER;
var $CATALOG_NUMBER, $USE_SEARCH_CODE;
 
function mod_catalog(){
global $PMS;
$PMS->hookModuleMethod('ModulePage', 'mod_catalog'); // 向系統登記模組專屬獨立頁面
 
$this->CATALOG_NUMBER = 20; // 相簿模式一頁最多顯示個數 (視文章是否有貼圖而有實際變動)
$this->USE_SEARCH_CODE = true; // 使用搜尋程序來建立相簿?
}
 
/* Get the name of module */
@@ -21,7 +22,7 @@
 
/* Get the module version infomation */
function getModuleVersionInfo(){
return '4th.Release.2 (v071109)';
return '4th.Release.3 (v130717)';
}
 
/* 自動掛載:頂部連結列 */
@@ -34,13 +35,16 @@
function hookHeadCSS(&$style, $isReply){
$style .= '<style type="text/css">
div.list { float: left; margin: 5px; width: '.MAX_RW.'px; height: '.MAX_RH.'px; } /* (相簿模式) div 框格設定 */
div.list input { width:14px; height:14px; }
div.list .tools { position: absolute; overflow:hidden; width:18px; height:18px; }
div.list .tools-expend { position: absolute; overflow:hidden; width:auto; }
</style>
';
}
 
/* 模組獨立頁面 */
function ModulePage(){
global $PMS, $PIO, $FileIO;
global $PTE, $PMS, $PIO, $FileIO;
 
$thisPage = $PMS->getModulePageURL('mod_catalog'); // 基底位置
$dat = ''; // HTML Buffer
@@ -48,40 +52,77 @@
$pageMax = ceil($listMax / $this->CATALOG_NUMBER) - 1; // 分頁最大編號
$page = isset($_GET['page']) ? intval($_GET['page']) : 0; // 目前所在分頁頁數
if($page < 0 || $page > $pageMax) exit('Page out of range.'); // $page 超過範圍
$plist = $PIO->fetchPostList(0, $this->CATALOG_NUMBER * $page, $this->CATALOG_NUMBER); // 取得定位正確的 N 筆資料號碼
$post = $PIO->fetchPosts($plist); // 取出資料
if(!$this->USE_SEARCH_CODE && !isset($_GET['search'])) {
$plist = $PIO->fetchPostList(0, $this->CATALOG_NUMBER * $page, $this->CATALOG_NUMBER); // 取得定位正確的 N 筆資料號碼
$post = $PIO->fetchPosts($plist); // 取出資料
} else {
$post = $PIO->searchPost(array('.'), 'ext', 'AND');
$pageMax = ceil(count($post) / $this->CATALOG_NUMBER) - 1;
$post = array_slice($post, $this->CATALOG_NUMBER * $page, $this->CATALOG_NUMBER);
}
$post_count = count($post);
 
$PMS->hookModuleMethod('Head', array(&$this, 'hookHeadCSS'));
head($dat);
$dat .= '<div id="contents">
[<a href="'.PHP_SELF2.'?'.time().'">回到版面</a>]
<div class="bar_reply">相簿模式</div>
<div class="bar_reply">相簿模式'.(@$_GET['style']=='detail'?' <a href="'.$thisPage.($page?'&amp;page='.$page:'').(isset($_GET['search'])?'&amp;search':'').'&amp;style=simple">■</a>':' <a href="'.$thisPage.($page?'&amp;page='.$page:'').(isset($_GET['search'])?'&amp;search':'').'&amp;style=detail">≡</a>').'</div>
';
if($_GET['style']=='detail'){
$dat .= '<script>
function hover(obj,ishover){
if(ishover) obj.className="tools-expend";
else obj.className="tools";
}
</script>
<form action="'.PHP_SELF.'" method="post">';
}
 
// 逐步取資料
for($i = 0; $i < $post_count; $i++){
list($imgw, $imgh, $tw, $th, $tim, $ext) = array($post[$i]['imgw'], $post[$i]['imgh'],$post[$i]['tw'], $post[$i]['th'], $post[$i]['tim'], $post[$i]['ext']);
list($no, $resto, $imgw, $imgh, $tw, $th, $tim, $ext, $now) = array($post[$i]['no'], $post[$i]['resto'], $post[$i]['imgw'], $post[$i]['imgh'],$post[$i]['tw'], $post[$i]['th'], $post[$i]['tim'], $post[$i]['ext'], $post[$i]['now']);
if($FileIO->imageExists($tim.$ext)){
$dat .= '<div class="list"><a href="'.$FileIO->getImageURL($tim.$ext).'" rel="_blank"><img src="'.$FileIO->getImageURL($tim.'s.jpg').'" style="'.$this->OptimizeImageWH($tw, $th).'" title="'.$imgw.'x'.$imgh.'" alt="'.$tim.$ext.'" /></a></div>'."\n";
$dat .= '<div class="list">'.(@$_GET['style']=='detail'?'<div class="tools" onmouseover="hover(this,true)" onmouseout="hover(this,false)"><input type="checkbox" name="'.$no.'" value="delete" /><a href="'.PHP_SELF.'?res='.($resto?$resto:$no).'#r'.$no.'">†</a></div>':'').'<a href="'.$FileIO->getImageURL($tim.$ext).'" rel="_blank"><img src="'.$FileIO->getImageURL($tim.'s.jpg').'" style="'.$this->OptimizeImageWH($tw, $th).'" title="'.(@$_GET['style']=='detail'?'No.'.$no.($resto?'('.$resto.')':'').' '.$now.' ':'').$imgw.'x'.$imgh.'" alt="'.$tim.$ext.'" /></a></div>'."\n";
}
}
 
$dat .= '</div>
$dat .= '</div><hr />';
 
<hr />
if(@$_GET['style']=='detail') {
$adminMode = adminAuthenticate('check'); // 前端管理模式
$adminFunc = ''; // 前端管理選擇
if($adminMode){
$adminFunc = '<select name="func"><option value="delete">'._T('admin_delete').'</option>';
$funclist = array();
$dummy = '';
$PMS->useModuleMethods('AdminFunction', array('add', &$funclist, null, &$dummy)); // "AdminFunction" Hook Point
foreach($funclist as $f) $adminFunc .= '<option value="'.$f[0].'">'.$f[1].'</option>'."\n";
$adminFunc .= '</select>';
}
 
$pte_vals = array('{$DEL_HEAD_TEXT}' => '<input type="hidden" name="mode" value="usrdel" />'._T('del_head'),
'{$DEL_IMG_ONLY_FIELD}' => '<input type="checkbox" name="onlyimgdel" id="onlyimgdel" value="on" />',
'{$DEL_IMG_ONLY_TEXT}' => _T('del_img_only'),
'{$DEL_PASS_TEXT}' => ($adminMode ? $adminFunc : '')._T('del_pass'),
'{$DEL_PASS_FIELD}' => '<input type="password" name="pwd" size="8" value="" />',
'{$DEL_SUBMIT_BTN}' => '<input type="submit" value="'._T('del_btn').'" />');
$dat .= $PTE->ParseBlock('DELFORM', $pte_vals).'</form>';
}
 
$dat .= '
 
<div id="page_switch">
<table border="1" style="float: left;"><tr>
';
if($page) $dat .= '<td><a href="'.$thisPage.'&amp;page='.($page - 1).'">上一頁</a></td>';
if($page) $dat .= '<td><a href="'.$thisPage.'&amp;page='.($page - 1).(@$_GET['style']=='detail'?'&amp;style=detail':'').(isset($_GET['search'])?'&amp;search':'').'">上一頁</a></td>';
else $dat .= '<td style="white-space: nowrap;">第一頁</td>';
$dat .= '<td>';
for($i = 0; $i <= $pageMax; $i++){
if($i==$page) $dat .= '[<b>'.$i.'</b>] ';
else $dat .= '[<a href="'.$thisPage.'&amp;page='.$i.'">'.$i.'</a>] ';
else $dat .= '[<a href="'.$thisPage.'&amp;page='.$i.(@$_GET['style']=='detail'?'&amp;style=detail':'').(isset($_GET['search'])?'&amp;search':'').'">'.$i.'</a>] ';
}
$dat .= '</td>';
if($page < $pageMax) $dat .= '<td><a href="'.$thisPage.'&amp;page='.($page + 1).'">下一頁</a></td>';
if($page < $pageMax) $dat .= '<td><a href="'.$thisPage.'&amp;page='.($page + 1).(@$_GET['style']=='detail'?'&amp;style=detail':'').(isset($_GET['search'])?'&amp;search':'').'">下一頁</a></td>';
else $dat .= '<td style="white-space: nowrap;">最後一頁</td>';
$dat .= '
</tr></table>