国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.8KB

  1. <?php
  2. /**
  3. * 生成Tag操作
  4. *
  5. * @version $Id: makehtml_taglist_action.php 1 11:17 2020年8月19日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2021, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('sys_MakeHtml');
  13. require_once(DEDEINC."/arc.taglist.class.php");
  14. if (empty($pageno)) $pageno = 0;
  15. if (empty($mkpage)) $mkpage = 1;
  16. if (empty($upall)) $upall = 0; // 是否更新全部 0为更新单个 1为更新全部
  17. if (empty($ctagid)) $ctagid = 0; // 当前处理的tagid
  18. if (empty($maxpagesize)) $maxpagesize = 50;
  19. $tagid = isset($tagid) ? intval($tagid) : 0;
  20. if ($tagid > 0) {
  21. $upall = 0; // 更新单个模式
  22. $ctagid = $tagid;
  23. } else {
  24. $upall = 1; // 更新全部模式
  25. }
  26. $allfinish = false; // 是否全部完成
  27. $dd = $dsql->GetOne("SELECT ROUND(AVG(total)) as tt FROM `#@__tagindex`"); // 取一个平均
  28. if ($upall == 1 && $ctagid == 0) {
  29. $rr = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE mktime <> uptime AND total > {$dd['tt']} LIMIT 1");
  30. if (!empty($rr) && count($rr) > 0) {
  31. $ctagid = $rr['id'];
  32. } else {
  33. $allfinish = true;
  34. }
  35. }
  36. if ($ctagid == 0 && $allfinish) {
  37. $reurl = '../a/tags/';
  38. ShowMsg("完成TAG更新<a href='$reurl' target='_blank'>浏览TAG首页</a>", "javascript:;");
  39. exit;
  40. }
  41. $tag = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id='$ctagid' LIMIT 0,1;");
  42. MkdirAll($cfg_basedir."/a/tags", $cfg_dir_purview);
  43. if (is_array($tag) && count($tag) > 0) {
  44. $dlist = new TagList($tag['tag'], 'taglist.htm');
  45. $dlist->CountRecord();
  46. $ntotalpage = $dlist->TotalPage;
  47. if ($ntotalpage <= $maxpagesize) {
  48. $dlist->MakeHtml('', '');
  49. $finishType = TRUE; // 生成一个TAG完成
  50. } else {
  51. $reurl = $dlist->MakeHtml($mkpage, $maxpagesize);
  52. $finishType = FALSE;
  53. $mkpage = $mkpage + $maxpagesize;
  54. if ($mkpage >= ($ntotalpage + 1)) $finishType = TRUE;
  55. }
  56. $nextpage = $pageno + 1;
  57. $onefinish = $nextpage >= $ntotalpage && $finishType;
  58. if (($upall == 0 && $onefinish) || ($upall == 1 && $allfinish && $onefinish)) {
  59. $dlist = new TagList('', 'tag.htm');
  60. $dlist->MakeHtml(1, 10);
  61. $reurl = '../a/tags/';
  62. if ($upall == 1) {
  63. ShowMsg("完成TAG更新<a href='$reurl' target='_blank'>浏览TAG首页</a>", "javascript:;");
  64. } else {
  65. $query = "UPDATE `#@__tagindex` SET mktime=uptime WHERE id='$ctagid' ";
  66. $dsql->ExecuteNoneQuery($query);
  67. if (empty($tag['tag_pinyin'])) {
  68. $tag = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id='$ctagid' LIMIT 0,1;");
  69. }
  70. $reurl .= $tag['tag_pinyin'];
  71. ShowMsg("完成TAG更新:[".$tag['tag']."]<a href='$reurl' target='_blank'>浏览TAG首页</a>", "javascript:;");
  72. }
  73. exit();
  74. } else {
  75. if ($finishType) {
  76. // 完成了一个跳到下一个
  77. if ($upall == 1) {
  78. $query = "UPDATE `#@__tagindex` SET mktime=uptime WHERE id='$ctagid' ";
  79. $dsql->ExecuteNoneQuery($query);
  80. $ctagid = 0;
  81. $nextpage = 0;
  82. }
  83. $gourl = "makehtml_taglist_action.php?maxpagesize=$maxpagesize&tagid=$tagid&pageno=$nextpage&upall=$upall&ctagid=$ctagid";
  84. ShowMsg("成功生成TAG:[".$tag['tag']."],继续进行操作", $gourl, 0, 100);
  85. exit();
  86. } else {
  87. // 继续当前这个
  88. $gourl = "makehtml_taglist_action.php?mkpage=$mkpage&maxpagesize=$maxpagesize&tagid=$tagid&pageno=$pageno&upall=$upall&ctagid=$ctagid";
  89. ShowMsg("成功生成TAG:[".$tag['tag']."],继续进行操作...", $gourl, 0, 100);
  90. exit();
  91. }
  92. }
  93. }