1. 程式人生 > >織夢CMS增加複製文件功能

織夢CMS增加複製文件功能

開啟後臺目錄(/dede)下archives_do.php約430行下新增:

  1 /*-----------------------------
  2 //複製文件
  3 ------------------------------*/
  4 elseif ($dopost == 'copyArchives') {
  5     CheckPurview('sys_ArcBatch');
  6     if (empty($totype)) {
  7         require_once(DEDEINC . '/typelink.class.php');
  8         if
(!empty($aid) && empty($qstr)) $qstr = $aid; 9 10 AjaxHead(); 11 $channelid = empty($channelid) ? 0 : $channelid; 12 $tl = new TypeLink($aid); 13 $typeOptions = $tl->GetOptionArray(0, $admin_catalogs, $channelid); 14 $typeOptions = "<select name='totype' style='width:90%'>
15 <option value='0'>請選擇複製到的位置...</option>\r\n 16 $typeOptions 17 </select>"; 18 19 //輸出AJAX可移動窗體 20 $divname = 'copyArchives'; 21 echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">\r\n";
22 echo " <div class='titLeft'>複製文件</div>\r\n"; 23 echo " <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='關閉' title='關閉' /></div>\r\n"; 24 echo "</div>\r\n"; 25 echo "<form name='quickeditform' action='archives_do.php' method='post'>\r\n"; 26 echo "<input type='hidden' name='dopost' value='{$dopost}' />\r\n"; 27 echo "<input type='hidden' name='qstr' value='{$qstr}' />\r\n"; 28 echo "<table width='100%' style='margin-top:6px;z-index:9000;'>\r\n"; 29 ?> 30 <tr height='28'> 31 <td width="80" class='bline'> 目標欄目:</td> 32 <td class='bline'> 33 <?php echo $typeOptions; ?> 34 </td> 35 </tr> 36 <tr height='32'> 37 <td width="80" class='bline'> 文件ID:</td> 38 <td class='bline'> 39 <input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:310px;overflow:hidden;'/> 40 <br/> 41 複製到的目標欄目必須和選定的文件頻道型別一致,否則程式會自動勿略不符合的文件。 42 </td> 43 </tr> 44 <tr height='32'> 45 <td colspan='2' align='center' style='padding-top:12px'> 46 <input name="imageField" type="image" src="images/button_ok.gif" width="60" height="22" class="np" 47 border="0" style="cursor:pointer"/> 48    49 <img src="images/button_back.gif" width="60" height="22" border="0" 50 onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' style="cursor:pointer"/> 51 </td> 52 </td> 53 </tr> 54 </table> 55 </form> 56 <?php 57 //AJAX窗體結束 58 } else { 59 $totype = preg_replace("#[^0-9]#", '', $totype); 60 $typeInfos = $dsql->GetOne("SELECT tp.channeltype,tp.ispart,tp.channeltype,ch.maintable,ch.addtable,ch.issystem FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch on ch.id=tp.channeltype WHERE tp.id='$totype' "); 61 $idtype = "id"; 62 if (!is_array($typeInfos)) { 63 ShowMsg('引數錯誤!', '-1'); 64 exit(); 65 } 66 if ($typeInfos['ispart'] != 0) { 67 ShowMsg('文件儲存的欄目必須為最終列表欄目!', '-1'); 68 exit(); 69 } 70 if (empty($typeInfos['addtable'])) { 71 $typeInfos['maintable'] = '`#@__archives`'; 72 } 73 //增加單表模型判斷 74 if ($typeInfos['issystem'] == -1) { 75 $typeInfos['maintable'] = $typeInfos['addtable']; 76 $idtype = "aid"; 77 } 78 $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr)); 79 $arc = ''; 80 $j = 0; 81 $okids = array(); 82 $dsql->SetQuery("SELECT {$idtype},typeid FROM `{$typeInfos['maintable']}` WHERE {$idtype} in($arcids) AND channel='{$typeInfos['channeltype']}' "); 83 $dsql->Execute(); 84 while ($row = $dsql->GetArray()) { 85 if ($row['typeid'] != $totype) { 86 87 $dsql->ExecuteNoneQuery("insert into `#@__arctiny` (typeid,typeid2,arcrank,channel,senddate,sortrank,mid) select typeid,typeid2,arcrank,channel,senddate,sortrank,mid from `#@__arctiny` where id='{$row[$idtype]}'"); 88 89 $xid = $dsql->GetLastID(); 90 91 $dsql->ExecuteNoneQuery("insert into `{$typeInfos['maintable']}`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,keywords,lastpost,scores,goodpost,badpost,voteid,notpost,description,filename,dutyadmin,tackid,mtype,weight) select case when id>'0' then '$xid' else '' end, case when typeid>'0' then '$totype' else '' end,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,keywords ,lastpost,scores,goodpost,badpost,voteid,notpost,description,filename,dutyadmin,tackid,mtype,weight from `{$typeInfos['maintable']}` WHERE id='{$row[$idtype]}' "); 92 93 $dsql->ExecuteNoneQuery("insert into `{$typeInfos['addtable']}`(aid,typeid,body,redirecturl,templet,userip) select case when aid>'0' then '$xid' else '' end,$totype,body,redirecturl,templet,userip from `{$typeInfos['addtable']}` WHERE aid='{$row[$idtype]}' "); 94 95 $okids[] = $row[$idtype]; 96 $j++; 97 } 98 } 99 100 101 UpDateCatCache(); 102 $sql = " TRUNCATE TABLE `#@__arctiny`"; 103 $dsql->ExecuteNoneQuery($sql); 104 105 //匯入普通模型微資料 106 $sql = "INSERT INTO `#@__arctiny`(id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid) 107 SELECT id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid FROM `#@__archives` "; 108 $dsql->ExecuteNoneQuery($sql); 109 110 //匯入單表模型微資料 111 $dsql->SetQuery("SELECT id,addtable FROM `#@__channeltype` WHERE id < -1 "); 112 $dsql->Execute(); 113 $doarray = array(); 114 while($row = $dsql->GetArray()) 115 { 116 $tb = str_replace('#@__', $cfg_dbprefix, $row['addtable']); 117 if(empty($tb) || isset($doarray[$tb]) ) 118 { 119 continue; 120 } 121 else 122 { 123 $sql = "INSERT INTO `#@__arctiny`(id, typeid, typeid2, arcrank, channel, senddate, sortrank, mid) 124 SELECT aid, typeid, 0, arcrank, channel, senddate, 0, mid FROM `$tb` "; 125 $rs = $dsql->executenonequery($sql); 126 $doarray[$tb] = 1; 127 } 128 } 129 //更新HTML 130 foreach ($okids as $aid) { 131 $arc = new Archives($aid); 132 $arc->MakeHtml(); 133 } 134 ShowMsg("成功複製 $j 個文件!", $ENV_GOBACK_URL); 135 exit(); 136 } 137 }

 

開啟dede/js/list.js 搜尋 function moveArc(e, obj, cid)下約35行新增

 1 function copyArc(e, obj, cid){
 2     var qstr=getCheckboxItem();
 3     if(qstr=='')
 4     {
 5         alert('必須選擇一個或多個文件!');
 6         return;
 7     }
 8     LoadQuickDiv(e, 'archives_do.php?dopost=copyArchives&qstr='+qstr+'&channelid='+cid+'&rnd='+Math.random(), 'copyArchives', '450px', '180px');
 9     ChangeFullDiv('show');
10 }

 

開啟dede/js/list.js 搜尋  function ShowMenu(evt,obj,aid,atitle)裡面的

new ContextItem("推薦文件",function(){ adArc(aid); }),的下面新增

new ContextItem("複製(<u>C</u>)",function(){ copyToClipboard(atitle); }),

 

開啟dede/templets下的content_list.htm找到

<a href="javascript:;" onClick="moveArc(event,this,<?php echo (empty($channelid) ? 0 : $channelid); ?>)" class="layui-btn layui-btn-small">&nbsp;移動&nbsp;</a>

當前行的下方新增

<a href="javascript:;" onClick="copyArc(event,this,<?php echo (empty($channelid) ? 0 : $channelid); ?>);" class="coolbg"> 複製 </a>    

 轉自:織夢CMS增加複製文件功能