function showattachshtml() { global $_G, $_SGLOBAL, $perpage, $wheresql, $BASESCRIPT; $perpage = 12; $page = intval($_GET['page']); $page = $page > 0 ? $page : 1; $limitsql = ' ORDER BY itemid DESC LIMIT ' . ($page - 1) * $perpage . ', ' . $perpage; $_GET['albumid'] = intval($_GET['albumid']); $attachhtmllist = ''; $selectsql = 'SELECT * FROM ' . tname('photoitems'); $countsql = 'SELECT COUNT(itemid) FROM ' . tname('photoitems'); if ($_GET['albumid'] > 0) { $wheresql .= " AND albumid='{$_GET['albumid']}'"; } elseif ($_GET['albumid'] == -1) { //albumid -1 為默認相冊,0 為全部圖片 $wheresql .= " AND albumid='0'"; } $query = DB::query($selectsql . $wheresql . $limitsql); while ($pic = DB::fetch($query)) { $attachhtmllist .= showattachrow($pic); } $count = DB::result_first($countsql . $wheresql); $multiurl = "{$BASESCRIPT}?action=ajax_editor&cont=imgattachlist&albumid={$_GET[albumid]}"; $multipage = multi($count, $perpage, $page, $multiurl, 1); $attachliststr = <<<EOF \t\t<div id="import_div"> \t\t\t{$attachhtmllist} \t\t</div> \t\t<div style="clear:both;">{$multipage}</div> \t\t<style> \t\t\t#pagetd .pages{margin-top:10px;} \t\t</style> \t\t<script type="text/javascript"> \t\t\t\$("#imgattachlist .pages a").click( \t\t\t\tfunction() { \t\t\t\t\t\$("#e_cont").load(this.href); \t\t\t\t\treturn false; \t\t\t\t} \t\t\t); \t\t\t\$("#import_div .photoimg_desc a").click( \t\t\t\tfunction() { \t\t\t\t\tvar msgeditor; \t\t\t\t\tmsgeditor=\$("#message")[0].editor; \t\t\t\t\tmsgeditor.pasteHTML('<img aid="'+this.name+'" src="'+this.href+'" alt="'+this.title+'" />'); \t\t\t\t\treturn false; \t\t\t\t} \t\t\t); \t\t</script> EOF; return $attachliststr; }
function showattachshtml() { global $_G, $_SGLOBAL, $_SC, $list_pic, $count, $maxpage, $perpage, $page, $tid, $firstonly, $sqlaids, $norepeat, $albumid, $minsize; $step = 0; $attachhtmllist = $sqlaids = $comma = ''; foreach ($list_pic['attachments'] as $pic) { $step++; $sqlaids .= "{$comma}'{$pic[aid]}'"; $comma = ', '; $attachhtmllist .= showattachrow($pic); } $multiurl = "admin.php?action=import&step=3"; $multipage = multi($count, $perpage, $page, $multiurl, 1); echo ' <script charset="utf-8" src="static/js/viewgoodspic.js" type="text/javascript"></script> <div id="import_div">'; echo $attachhtmllist; echo ' </div> <div style="clear:both;"><table><tr><td style="width:30px;vertical-align:middle;height:25px;"><input style="float:left;" type="checkbox" checked="" name="chkall" onclick="checkall(this.form, \'item\')" /></td><td style="width:30px;vertical-align:middle;height:30px;">' . lang('selectall') . '</td><td id="pagetd" style="width:500px;vertical-align:middle;">' . $multipage . '</td></tr></table></div> <style> #pagetd .pages{margin-top:10px;} </style> '; if ($sqlaids) { //去重檢查的sql $repeats = array(); $query = DB::query('SELECT bbsaid FROM ' . tname('photoitems') . " WHERE bbsaid IN ({$sqlaids}) GROUP BY bbsaid"); while ($temprow = DB::fetch($query)) { $repeats[] = '"' . $temprow['bbsaid'] . '"'; } $repeatjsarr = implode(', ', $repeats); echo ' <script type="text/javascript"> var repeataids = new Array(' . $repeatjsarr . '); ' . (!empty($_GET['jump']) ? ' //控制跳轉下一頁的js var jumpurl = "admin.php?action=import&step=3&page="; if(repeataids.length == $(".photo_div").length) { if(' . $page . ' == ' . $maxpage . ') { jumpurl = "admin.php?action=import"; } else { jumpurl += ' . ($page + 1) . '; } window.location.href = jumpurl; }' : '') . ' //去重檢查的js function norepeatcheck() { var norepeatst = $("#norepeat")[0].checked; if(norepeatst){ setnorepeat(); }else{ unsetnorepeat(); } } function setnorepeat() { for(i=0; i<repeataids.length; i++) { $("#check_"+repeataids[i]).attr({"disabled":"disable"}); $("#desc_"+repeataids[i]).attr({"disabled":"disable"}); $("#photodiv_"+repeataids[i]).fadeOut("1000"); } jSetCookie("' . $_SC['cookiepre'] . 'i_norepeat", 1, 900); norepeatst = true; } function unsetnorepeat() { for(i=0; i<repeataids.length; i++) { $("#photodiv_"+repeataids[i]).fadeIn("600"); $("#check_"+repeataids[i]).attr({"disabled":""}); $("#desc_"+repeataids[i]).attr({"disabled":""}); } jSetCookie("' . $_SC['cookiepre'] . 'i_norepeat", 0, 900); norepeatst = false; } //js設置cookie的方法 function jSetCookie(key, value, lifetime) { var exp = new Date(); exp.setTime(exp.getTime() + lifetime*1000); document.cookie = key + "="+ escape (value) + ";expires=" + exp.toGMTString(); } //js取出cookie function jGetCookie(key) { var ckarr = document.cookie.match(new RegExp("(^| )"+key+"=([^;]*)(;|$)")); if(ckarr != null) return unescape(ckarr[2]); return null; } //頁面初始化時執行去重檢查 $(function(){ norepeatcheck();}); </script> '; } }