织梦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增加复制文档功能

猜你喜欢

转载自www.cnblogs.com/gaowy/p/9948846.html