phpcms2008删除文章到回收站后不能生成栏目和首页静态页的问题

用phpcms2008做网站,我把一个栏目设为生成静态页面,在此栏目中删除文章到回收站后,不能生成自动栏目和首页静态页,这似乎是个bug,既然已经放到了回收站,就应该自动生成新的栏目和首页静态页!于是我自己做了修改。


一、研究过程:

content.inc.php 有 case 'add' 和 case  'edit' 代码段二者中分别有 $c->add 或  $c->edit 函数;  均来自于content.class.php 文件;在 content.class.php , addedit 函数均包含 log_write函数调用语句均为:  $this->log_write($contentid, '', '', $data['islink']);

log_write函数中,语句 if($islink==99) $this->html->show($contentid, $this->is_update_related);    这个show函数很关键,它来自于html.class.php 文件,show函数中以下代码段用来生成首页和栏目页的静态页面

 

if($is_update_related)

{

           $this->index();

$pages = intval($PHPCMS['autoupdatelist']);

$catids = explode(',', $CATEGORY[$r['catid']]['arrparentid']);

$catids[] = $r['catid'];

foreach($catids as $cid)

{

if($cid == 0) continue;

for($i=0; $i<=$pages; $i++)

{

if($CATEGORY[$cid]['child']==1 && $i>0) continue;

$this->category($cid, $i);

}

}

 

}

 

注意从栏目中 删除新闻到 回收站 和 彻底删除回收站中文章,分别对应了 content.inc.php 中的 case 'cancel' 和  case 'delete' 代码段.

 


我的测试过程:

 

1、在 global.func.php 中添加了一个自定义函数 

 

function  writeToFileByZy($txt )

{

    $myfile = fopen("---------zyzyzyfile----.txt", "a+") or die("Unable to open file!");

    fwrite($myfile, $txt."\r\n");

   fclose($myfile);

}

 

2、 content.class.phpfunction log_write 函数 中加入代码:

 

//=======我自己的一句测试代码=========

writeToFileByZy( $contentid.'|ishtml=='.$this->ishtml."|is_update_related==" . $this->is_update_related ."|islink== ". $islink );

 

用来测试 add edit 、cancel操作的各个值,写入---------zyzyzyfile----.txt 的结果如下:

 

9873|ishtml==1|is_update_related==1|islink== 99 [add edit 操作]

9874|ishtml==0|is_update_related==1|islink== 99[cancel 操作 ]

由于cancel 操作时, ishtml==0,所以不会调用$this->html->show($contentid, $this->is_update_related);

因此没有执行show函数中的 生成栏目页和首页的代码.

 

解决办法其实很简单:

 

在 content.inc.php 的 cancle 中 加入以下蓝色代码即可:

 

   case 'cancel':

if(!$allow_manage) showmessage('无管理权限!');

$c->status($contentid, 0);

  

   //====自己加的代码,用来解决删除新闻到回收站后,栏目页和首页不重新生成后台命令静态页的问题

        require_once 'html.class.php';

      $zy_html = new html();

//注意:因为有可能一次删除多个新闻到回收站,所以$contentid 是个数组,$id才是新闻的contentid 字段值

 

    if(is_array($contentid))  

    {

foreach($contentid as $id)

{

$zy_html->show($id, 1);

}

   }

else

{

   $zy_html->show($contentid, 1);

}

      //====自己加的代码 over 

  

showmessage('操作成功!', $forward);

break;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值