phpcms2008删除文章到回收站后不能生成栏目和首页静态页的问题
2015-09-10 11:25
399 查看
用phpcms2008做网站,我把一个栏目设为生成静态页面,在此栏目中删除文章到回收站后,不能生成自动栏目和首页静态页,这似乎是个bug,既然已经放到了回收站,就应该自动生成新的栏目和首页静态页!于是我自己做了修改。
一、研究过程:
在content.inc.php 中, 有 case 'add' 和 case 'edit' 代码段, 二者中分别有 $c->add 或 $c->edit 函数; 均来自于content.class.php 文件;在 content.class.php 中, add和edit 函数均包含 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.php的function 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;
一、研究过程:
在content.inc.php 中, 有 case 'add' 和 case 'edit' 代码段, 二者中分别有 $c->add 或 $c->edit 函数; 均来自于content.class.php 文件;在 content.class.php 中, add和edit 函数均包含 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.php的function 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;
相关文章推荐
- PHP_后台不能上传图片的几种常见问题
- 取得“距离某天还有多少天多少小时”的函数
- php将mysql数据库整库导出生成sql文件
- PHP中返回上一页的问题
- 在php中使输出的alert内容换行
- PHP整型溢出
- session_start()与UTF-8
- PHP截取字符函数
- php中的strpos函数问题
- php中iconv可将字符串从原始编码转化为指定的编码格式
- php的字符串操作与正则表达式
- php定时任务
- ThinkPHP函数详解之M方法和R方法
- 欢迎使用CSDN-markdown编辑器
- 如何创建phpinfo查看php信息?
- 一个简单的PHP短信群发
- 简单PHPexcel
- 基于PHP的crontab定时任务管理
- yii2 验证码详细代码
- 将php和mysql加入环境变量