花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來到素材無憂網(wǎng),按 + 收藏我們
登錄 注冊 退出 找回密碼

織夢DEDE 在后臺(tái)添加欄目文檔的批量復(fù)制功能

時(shí)間: 2019-09-04 19:55 閱讀: 作者:素材無憂網(wǎng)

如果想要把一個(gè)欄目的所有文檔復(fù)制到另一個(gè)欄目中如果沒有好的辦法就只能一個(gè)一個(gè)的重新建立,為了避免這種浪費(fèi)時(shí)間的事,我們就在后臺(tái)寫一個(gè)批量復(fù)制的功能。下面是實(shí)現(xiàn)功能的具體步驟


修改文件dede/templets/content_batch_up.htm

  修改頭部腳本函數(shù)ShowHideMove()

   function ShowHideMove()
    {
        var selBox = document.getElementByIdx_x('moveradio');
        var selBox2 = document.getElementByIdx_x('copyradio');//edited by adan;090508
        var obj = document.getElementByIdx_x('moveField');
        if(selBox.checked||selBox2.checked) obj.style.display = "block";//edited by adan;090508
        else  obj.style.display = "none";
    }

  添加復(fù)制欄目按鈕

  查找

<input name="action" type="radio" class="np" value="move" id="moveradio" onClick="ShowHideMove()" />
        移動(dòng)文檔

  后面添加

    <input name="action" type="radio" class="np" value="copy" id="copyradio" onClick="ShowHideMove()" /><!--added by adan;090508-->
        復(fù)制欄目文檔

  修改文件dede/content_batch_action.PHP

  首先刪除文件最后的兩段代碼

//刪除空標(biāo)題內(nèi)容
else if($action=='delnulltitle')
{
    $dsql->SetQuery("Select id From dede_archives where trim(title)='' ");
    $dsql->Execute('x');
    $tdd = 0;
    while($row = $dsql->GetObject('x'))
    {
        if(DelArc($row->id))
        {
            $tdd++;
        }
    }
    ShowMsg("成功刪除 $tdd 條記錄!","JavaScript:;");
    exit();
}

//修正縮略圖錯(cuò)誤
else if($action=='modddpic')
{
    $dsql->ExecuteNoneQuery("Update dede_archives set litpic='' where trim(litpic)='litpic' ");
    ShowMsg("成功修正縮略圖錯(cuò)誤!","javascript:;");
    exit();
}

  上面2段代碼,官方人員竟然把上面2段代碼搞重復(fù)了,先汗一個(gè)!

  然后在最后添加下面代碼

//start 添加復(fù)制欄目文章功能 added by adan;090508
else if($action=='copy')
{
  if(empty($typeid))
  {
         ShowMsg('該操作必須指定欄目!','javascript:;');    
         exit();
    }
  $typeold = $dsql->GetOne("Select * From `dede_arctype` where id='$typeid'; ");
  $typenew = $dsql->GetOne("Select * From `dede_arctype` where id='$newtypeid'; ");
  if(!is_array($typenew))
  {
      $dsql->Close();
    ShowMsg("無法檢測復(fù)制到的新欄目的信息,不能完成操作!","javascript:;");
      exit();
  }
  if($typenew['ispart']!=0)
  {
      $dsql->Close();
    ShowMsg("你不能把數(shù)據(jù)復(fù)制到非最終列表的欄目!","javascript:;");
      exit();
  }
  if($typenew['channeltype']!=$typeold['channeltype'])
  {
      $dsql->Close();
    ShowMsg("不能把數(shù)據(jù)復(fù)制到內(nèi)容類型不同的欄目!","javascript:;");
      exit();
  }
    $gwhere .= " And channel='".$typenew['channeltype']."' And title like '%$keyword%'";

    $ch = $dsql->GetOne("Select addtable From `dede_channeltype` where id={$typenew['channeltype']} ");
    $addtable = $ch['addtable'];

    $dsql->SetQuery("Select * From `dede_archives` where typeid='$typeid'");
    $dsql->Execute('c');
    $tdd = 0;
    while($row = $dsql->GetObject('c'))
    {
        $senddate = time();
        $sortrank = AddDay($senddate,0);//第二個(gè)參數(shù)是排序值,參考article_add.php
      $ID = $row->id;

        $typeid = $newtypeid;//$newtypeid
        $sortrank = $row->sortrank;
        $flag = $row->flag;
        $ismake = $row->ismake;
        $channelid = $row->channel;
        $arcrank = $row->arcrank;
        $click = $row->click;
        $money = $row->money;
        $title = addslashes($row->title);//需要添加addslashes()轉(zhuǎn)換; adan;090508
        $shorttitle = $row->shorttitle;
        $color = $row->color;
        $writer = $row->writer;
        $source = $row->source;
        $litpic = $row->litpic;
        $pubdate = $row->pubdate;
        $adminid = $cuserLogin->getUserID();
        $notpost = $row->notpost;
        $description = addslashes($row->description);//需要添加addslashes()轉(zhuǎn)換; adan;090508
        $keywords = $row->keywords;

      require_once(DEDEADMIN."/inc/inc_archives_functions.php");
      //生成文檔ID
      $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$adminid);

      if(empty($arcID))
      {
          ShowMsg("無法獲得主鍵,因此無法進(jìn)行后續(xù)操作!","-1");
          exit();
      }
        //加入數(shù)據(jù)表dede_archives的SQL語句
        //----------------------------------
        $inQuery = "INSERT INTO `dede_archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
        color,writer,source,litpic,pubdate,senddate,mid,lastpost,scores,goodpost,badpost,notpost,description,keywords,filename)
        VALUES ('$arcID','$typeid','','$sortrank','$flag','$ismake','$channelid','$arcrank','0','$money',
        '$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate',
        '$adminid','0','0','0','0','0','$description','$keywords','');";

      if(!$dsql->ExecuteNoneQuery($inQuery))
      {
          $gerr = $dsql->GetError();
          $dsql->ExecuteNoneQuery("Delete From `dede_arctiny` where id='$arcID'");
          ShowMsg("把數(shù)據(jù)保存到數(shù)據(jù)庫主表 `dede_archives` 時(shí)出錯(cuò),請把相關(guān)信息提交給DedeCms官方。".str_replace('"','',$gerr),"javascript:;");
          exit();
      }
 
      //保存到附加表
      $cts = $dsql->GetOne("Select addtable From `dede_channeltype` where id='$channelid' ");
      $addtable = trim($cts['addtable']);
      if(empty($addtable))
      {
          $dsql->ExecuteNoneQuery("Delete From `dede_archives` where id='$arcID'");
          $dsql->ExecuteNoneQuery("Delete From `dede_arctiny` where id='$arcID'");
          ShowMsg("沒找到當(dāng)前模型[{$channelid}]的主表信息,無法完成操作!。","javascript:;");
          exit();
      }
      $useip = GetIP();
        $redirecturl = $addRow['redirecturl'];
        $templet = $addRow['templet'];
        $addRow = $dsql->GetOne("Select * from `{$addtable}` where aid='$ID'");
        $body = addslashes($addRow["body"]);

      $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,templet,userip,body) Values('$arcID','$typeid','$redirecturl','$templet','$useip','$body')";
      if(!$dsql->ExecuteNoneQuery($query))
      {
          $gerr = $dsql->GetError();
          $dsql->ExecuteNoneQuery("Delete From `dede_archives` where id='$arcID'");
          $dsql->ExecuteNoneQuery("Delete From `dede_arctiny` where id='$arcID'");
          ShowMsg("把數(shù)據(jù)保存到數(shù)據(jù)庫附加表 `{$addtable}` 時(shí)出錯(cuò),請把相關(guān)信息提交給DedeCms官方。".str_replace('"','',$gerr),"javascript:;");
          exit();
      }
      else $tdd++;
    }
  if($tdd>0)
  {
      $jumpurl  = "makehtml_archives_action.php?endid=$endid&startid=$startid";
    $jumpurl .= "&typeid=$newtypeid&pagesize=20&seltime=$seltime";
    $jumpurl .= "&stime=".urlencode($starttime)."&etime=".urlencode($endtime);
      ShowMsg("成功復(fù)制了 $tdd 條記錄,準(zhǔn)備重新生成HTML...",$jumpurl);
  }
  else ShowMsg("完成操作,沒復(fù)制任何數(shù)據(jù)...","javascript:;");
  exit();
}

版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!

轉(zhuǎn)載請注明: 織夢DEDE 在后臺(tái)添加欄目文檔的批量復(fù)制功能

標(biāo)簽:  
相關(guān)文章
模板推薦