dedecms5.7GBK修改多栏目发布一篇文章(根据副栏目)

时间: 2012-12-12 / 分类: dedecms / 浏览次数: 2,697 views / 0个评论 发表评论

给个破客户弄的~

本机测试了,发好了,又要弄分类,奶奶的,弄好了,结果还申请退款了

算了~我当研究技术了,碰上这么个破客户

其实DEDE发布文章首先是在微表获取一个文章ID

    //生成文档ID
    $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$adminid);

我们判断一下,如果有副栏目,就多生成几个

//判断副栏目
if(!empty($typeid2)){
$typeid2arr=explode(‘,’,$typeid2);
$typeid2=””;//处理后去掉副栏目
for($i=0;$i<count($typeid2arr);$i++) {
$arcID2[$i] = GetIndexKey($arcrank,$typeid2arr[$i],$sortrank,$channelid,$senddate,$adminid);
}
}

为了干净一些,我把处理后的副栏目去掉了

主栏目处理不变

主栏目处理完以后,开始副栏目处理

//副栏目处理过程
if(count($typeid2arr)>0) {
$typeid2=””;//处理后去掉副栏目,确保确实去掉了
for($i=0;$i<count($typeid2arr);$i++) {

    //分析处理附加表数据
    $inadd_f = $inadd_v = ”;
    if(!empty($dede_addonfields))
    {
        $addonfields = explode(‘;’,$dede_addonfields);
        if(is_array($addonfields))
        {
            foreach($addonfields as $v)
            {
                if($v==”) continue;
                $vs = explode(‘,’,$v);
                if($vs[1]==’htmltext’||$vs[1]==’textdata’)
                {
                    ${$vs[0]} = AnalyseHtmlBody(${$vs[0]},$description,$litpic,$keywords,$vs[1]);
                }
                else
                {
                    if(!isset(${$vs[0]})) ${$vs[0]} = ”;
                    ${$vs[0]} = GetFieldValueA(${$vs[0]},$vs[1],$arcID2[$i]);
                }
                $inadd_f .= ‘,’.$vs[0];
                $inadd_v .= ” ,'”.${$vs[0]}.”‘ “;
            }
        }
    }

    //处理图片文档的自定义属性
    if($litpic!=” && !preg_match(“#p#”, $flag))
    {
        $flag = ($flag==” ? ‘p’ : $flag.’,p’);
    }
    if($redirecturl!=” && !preg_match(“#j#”, $flag))
    {
        $flag = ($flag==” ? ‘j’ : $flag.’,j’);
    }
   
    //跳转网址的文档强制为动态
    if(preg_match(“#j#”, $flag)) $ismake = -1;

 


    //保存到主表
    $query = “INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,
    color,writer,source,litpic,pubdate,senddate,mid,voteid,notpost,description,keywords,filename,dutyadmin,weight)
    VALUES (‘$arcID2[$i]’,’$typeid2arr[$i]’,’$typeid2′,’$sortrank’,’$flag’,’$ismake’,’$channelid’,’$arcrank’,’$click’,’$money’,
    ‘$title’,’$shorttitle’,’$color’,’$writer’,’$source’,’$litpic’,’$pubdate’,’$senddate’,
    ‘$adminid’,’$voteid’,’$notpost’,’$description’,’$keywords’,’$filename’,’$adminid’,’$weight’);”;

    if(!$dsql->ExecuteNoneQuery($query))
    {
        $gerr = $dsql->GetError();
        $dsql->ExecuteNoneQuery(“DELETE FROM `#@__arctiny` WHERE id=’$arcID2[$i]'”);
        ShowMsg(“把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCms官方。”.str_replace(‘”‘,”,$gerr),”javascript:;”);
        exit();
    }

    //保存到附加表
    $cts = $dsql->GetOne(“SELECT addtable FROM `#@__channeltype` WHERE id=’$channelid’ “);
    $addtable = trim($cts[‘addtable’]);
    if(empty($addtable))
    {
        $dsql->ExecuteNoneQuery(“DELETE FROM `#@__archives` WHERE id=’$arcID2[$i]'”);
        $dsql->ExecuteNoneQuery(“DELETE FROM `#@__arctiny` WHERE id=’$arcID2[$i]'”);
        ShowMsg(“没找到当前模型[{$channelid}]的主表信息,无法完成操作!。”,”javascript:;”);
        exit();
    }
    $useip = GetIP();
    $templet = empty($templet) ? ” : $templet;
    $query = “INSERT INTO `{$addtable}`(aid,typeid,redirecturl,templet,userip,body{$inadd_f}) Values(‘$arcID2[$i]’,’$typeid2arr[$i]’,’$redirecturl’,’$templet’,’$useip’,’$body'{$inadd_v})”;
    if(!$dsql->ExecuteNoneQuery($query))
    {
        $gerr = $dsql->GetError();
        $dsql->ExecuteNoneQuery(“Delete From `#@__archives` where id=’$arcID2[$i]'”);
        $dsql->ExecuteNoneQuery(“Delete From `#@__arctiny` where id=’$arcID2[$i]'”);
        ShowMsg(“把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCms官方。”.str_replace(‘”‘,”,$gerr),”javascript:;”);
        exit();
    }
    //生成HTML
    InsertTags($tags,$arcID2[$i]);
    if($cfg_remote_site==’Y’ && $isremote==”1″)
    {   
        if($serviterm!=””){
            list($servurl,$servuser,$servpwd) = explode(‘,’,$serviterm);
            $config=array( ‘hostname’ => $servurl, ‘username’ => $servuser, ‘password’ => $servpwd,’debug’ => ‘TRUE’);
        }else{
            $config=array();
        }
        if(!$ftp->connect($config)) exit(‘Error:None FTP Connection!’);
    }
 $picTitle = false;
 if(count($_SESSION[‘bigfile_info’]) > 0)
 {
  foreach ($_SESSION[‘bigfile_info’] as $k => $v)
  {
   if(!empty($v))
   {
    $pictitle = ${‘picinfook’.$k};
    $titleSet = ”;
    if(!empty($pictitle))
    {
     $picTitle = TRUE;
     $titleSet = “,title='{$pictitle}'”;
    }
    $dsql->ExecuteNoneQuery(“UPDATE `#@__uploads` SET arcid='{$arcID2[$i]}'{$titleSet} WHERE url LIKE ‘{$v}’; “);
   }
  }
 }
    $artUrl = MakeArt($arcID2[$i],true,true,$isremote);
    if($artUrl==”)
    {
        $artUrl = $cfg_phpurl.”/view.php?aid=$arcID2[$i]”;
    }
    ClearMyAddon($arcID2[$i], $title);
  }//for
 }//if

//副栏目处理结束

这个是文章模型的

其实其他模型也是差不多的道理

 

发表评论

你必须 登录后 才能留言!