diff --git a/.gitignore b/.gitignore index 2068fc6a..294e7bf2 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,4 @@ src/data/sqlite_error_trace.inc src/static/soft/*/ src/static/userup/*/ src/static/js/*.js -src/apps/special/*.html +src/apps/special/*.html \ No newline at end of file diff --git a/src/admin/makehtml_taglist.php b/src/admin/makehtml_taglist.php index 3912d271..01836f2a 100644 --- a/src/admin/makehtml_taglist.php +++ b/src/admin/makehtml_taglist.php @@ -27,6 +27,7 @@ if ($action == "search") { "data" => $result, ); echo json_encode($result); + exit; } $result = array( "code" => 200, diff --git a/src/admin/makehtml_taglist_action.php b/src/admin/makehtml_taglist_action.php index 40130ff6..80069db7 100644 --- a/src/admin/makehtml_taglist_action.php +++ b/src/admin/makehtml_taglist_action.php @@ -18,7 +18,8 @@ if (empty($upall)) $upall = 0; //是否更新全部 0为更新单个 1为更新 if (empty($ctagid)) $ctagid = 0; //当前处理的tagid if (empty($maxpagesize)) $maxpagesize = 50; $tagid = isset($tagid) ? intval($tagid) : 0; - +$tagsdir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir); +// 生成 if ($tagid > 0) { $upall = 0; //更新单个模式 $ctagid = $tagid; @@ -26,33 +27,30 @@ if ($tagid > 0) { $upall = 1; //更新全部模式 } $allfinish = false; //是否全部完成 - +// 判断生成模式 if ($upall == 1 && $ctagid == 0) { - $rr = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE mktime <> uptime LIMIT 1"); + $rr = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE mktime <> uptime OR mktime = 0 LIMIT 1"); if (!empty($rr) && count($rr) > 0) { $ctagid = $rr['id']; } else { $allfinish = true; } } - if ($ctagid == 0 && $allfinish) { $dlist = new TagList('', 'tag.htm'); + $dlist->SetTagsDir($tagsdir); $dlist->MakeHtml(1, 10); - - $reurl = '../a/tags/'; + $reurl = '..'.$tagsdir; ShowMsg("完成TAG更新浏览TAG首页", "javascript:;"); exit; } - - $tag = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id='$ctagid' LIMIT 0,1;"); - -MkdirAll($cfg_basedir."/a/tags", $cfg_dir_purview); - +// 创建TAGS目录 +MkdirAll($cfg_basedir.$cfg_tags_dir, $cfg_dir_purview); if (is_array($tag) && count($tag) > 0) { - $dlist = new TagList($tag['tag'], 'taglist.htm'); + $dlist = new TagList($tag['id'], 'taglist.htm'); $dlist->CountRecord(); + $dlist->SetTagsDir($tagsdir); $ntotalpage = $dlist->TotalPage; if ($ntotalpage <= $maxpagesize) { @@ -69,19 +67,15 @@ if (is_array($tag) && count($tag) > 0) { $onefinish = $nextpage >= $ntotalpage && $finishType; if (($upall == 0 && $onefinish) || ($upall == 1 && $allfinish && $onefinish)) { $dlist = new TagList('', 'tag.htm'); + $dlist->SetTagsDir($tagsdir); $dlist->MakeHtml(1, 10); - $reurl = '../a/tags/'; + $reurl = '..'.$tagsdir; if ($upall == 1) { ShowMsg("完成TAG更新浏览TAG首页", "javascript:;"); } else { $query = "UPDATE `#@__tagindex` SET mktime=uptime WHERE id='$ctagid' "; $dsql->ExecuteNoneQuery($query); - - if (empty($tag['tag_pinyin'])) { - $tag = $dsql->GetOne("SELECT * FROM `#@__tagindex` WHERE id='$ctagid' LIMIT 0,1;"); - } - - $reurl .= $tag['tag_pinyin']; + $reurl .= '/'.$ctagid; ShowMsg("完成TAG更新:[".$tag['tag']."]浏览TAG首页", "javascript:;"); } exit(); @@ -89,6 +83,9 @@ if (is_array($tag) && count($tag) > 0) { if ($finishType) { //完成了一个跳到下一个 if ($upall == 1) { + $now = time(); + $query = "UPDATE `#@__tagindex` SET uptime={$now} WHERE id='$ctagid' "; + $dsql->ExecuteNoneQuery($query); $query = "UPDATE `#@__tagindex` SET mktime=uptime WHERE id='$ctagid' "; $dsql->ExecuteNoneQuery($query); $ctagid = 0; diff --git a/src/admin/tags_main.php b/src/admin/tags_main.php index a5b92519..eb27562a 100644 --- a/src/admin/tags_main.php +++ b/src/admin/tags_main.php @@ -78,7 +78,8 @@ else if ($action == 'delete') { $title = empty($title) ? "" : HtmlReplace($title, 0); $kw = empty($kw) ? "" : HtmlReplace($kw, 0); $des = empty($des) ? "" : HtmlReplace($des, 0); - $dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET title='{$title}',keywords='{$kw}',`description`='{$des}' WHERE id = {$tid}"); + $now = time(); + $dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET title='{$title}',keywords='{$kw}',`description`='{$des}',`uptime`='{$now}' WHERE id = {$tid}"); echo json_encode(array('code' => 200, 'result' => true)); } /* diff --git a/src/admin/templets/makehtml_taglist.htm b/src/admin/templets/makehtml_taglist.htm index 29521b84..9212c97a 100644 --- a/src/admin/templets/makehtml_taglist.htm +++ b/src/admin/templets/makehtml_taglist.htm @@ -13,6 +13,8 @@ $(function(){ $('#tagid').select2({ language: "zh-CN", + allowClear: true, + placeholder:"请选择一个标签", ajax: { url: 'makehtml_taglist.php?action=search', delay: 500, @@ -48,12 +50,32 @@ + 0) { + $row = $dsql->GetOne("Select tag From `#@__tagindex` where id = '$tagid' "); + ?> +
+ |
您还可以尝试通过搜索程序去搜索这个关键词:前往搜索>"; + $msg = "系统无此标签,可能已经移除"; ShowMsg($msg, "-1"); exit(); } - //确定是否存在tag_pinyin - if (empty($this->TagInfos['tag_pinyin'])) { - $this->TagInfos['tag_pinyin'] = $this->TagPinyinExists($this->Tag) ? GetPinyin($this->Tag).$this->TagInfos['id'] : GetPinyin($this->Tag); - $this->dsql->ExecNoneQuery("UPDATE `#@__tagindex` SET tag_pinyin = '{$this->TagInfos['tag_pinyin']}' WHERE tag LIKE '{$this->Tag}'"); - } $this->Fields['title'] = empty($this->TagInfos['title']) ? $this->Fields['title'] : $this->TagInfos['title']; $this->Fields['keywords'] = empty($this->TagInfos['keywords']) ? $this->Fields['keywords'] : $this->TagInfos['keywords']; $this->Fields['description'] = empty($this->TagInfos['description']) ? $this->Fields['description'] : $this->TagInfos['description']; @@ -93,12 +88,6 @@ class TagList $envs['url_type'] = 4; $envs['value'] = $keyword; } - function TagPinyinExists($tag) - { - $tag_py = GetPinyin($tag); - $row = $this->dsql->GetOne("Select count(*) as dd From `#@__tagindex` where tag_pinyin like '{$tag_py}' "); - return $row['dd'] > 0; - } //php4构造函数 function TagList($keyword, $templet) { @@ -170,13 +159,15 @@ class TagList */ function Display() { - $makeDir = empty($this->Tag) ? $this->GetTruePath()."/a/tags/index.html" : $this->GetTruePath()."/a/tags/".GetPinyin($this->Tag)."/index.html"; + global $cfg_cmspath,$cfg_tags_dir; + $tagsDir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir); + $makeDir = empty($this->Tag) ? $this->GetTruePath().$tagsDir."/index.html" : $this->GetTruePath().$tagsDir."/".$this->Tag."/index.html"; if (file_exists($makeDir)) { header('HTTP/1.1 301 Moved Permanently'); if (!empty($this->Tag)) { - header('Location:../a/tags/'.GetPinyin($this->Tag)."/"); + header('Location:..'.$tagsDir.'/'.GetPinyin($this->Tag)."/"); } else { - header('Location:../a/tags/'); + header('Location:..'.$tagsDir.'/'); } exit; } @@ -578,6 +569,14 @@ class TagList $truepath = $GLOBALS["cfg_basedir"]; return $truepath; } + + function SetTagsDir($dir = '') + { + global $cfg_tags_dir,$cfg_cmspath; + if ($dir == "") $dir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir); + $this->tagsDir = $dir; + } + //生成静态Tag function MakeHtml($startpage = 1, $makepagesize = 0) { @@ -587,8 +586,8 @@ class TagList //初步给固定值的标记赋值 $this->ParseTempletsFirst(); if ($this->Tag == "") { - MkdirAll($this->GetTruePath()."/a/tags/", $cfg_dir_purview); - $this->dtp->SaveTo($this->GetTruePath()."/a/tags/index.html"); + MkdirAll($this->GetTruePath().$this->tagsDir, $cfg_dir_purview); + $this->dtp->SaveTo($this->GetTruePath().$this->tagsDir."/index.html"); } else { $totalpage = ceil($this->TotalResult / $this->PageSize); if ($totalpage == 0) { @@ -605,7 +604,7 @@ class TagList if ($endpage == 1) { $endpage = 2; } - $makeDir = $this->GetTruePath()."/a/tags/".$this->TagInfos['tag_pinyin']."/"; + $makeDir = $this->GetTruePath().$this->tagsDir.'/'.$this->TagInfos['id']."/"; MkdirAll($makeDir, $cfg_dir_purview); for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) { $this->ParseDMFields($this->PageNo, 1); diff --git a/src/system/taglib/tag.lib.php b/src/system/taglib/tag.lib.php index 3a3234a6..86158609 100755 --- a/src/system/taglib/tag.lib.php +++ b/src/system/taglib/tag.lib.php @@ -10,7 +10,7 @@ */ function lib_tag(&$ctag, &$refObj) { - global $dsql, $envs, $cfg_cmsurl; + global $dsql, $envs, $cfg_cmsurl,$cfg_tags_dir; //属性处理 $attlist = "row|30,sort|new,getall|0,typeid|0"; FillAttsDefault($ctag->CAttribute->Items, $attlist); @@ -20,11 +20,8 @@ function lib_tag(&$ctag, &$refObj) $revalue = ''; $ltype = $sort; $num = $row; - $dd = $dsql->GetOne("SELECT ROUND(AVG(total)) as tt FROM `#@__tagindex`"); //取一个平均 - if (!$dd['tt']) { - $dd['tt'] = 0; - } - $addsql = "WHERE 1=1 AND total >= {$dd['tt']}"; + $addsql = "WHERE 1=1"; + $tagsdir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir); if ($getall == 0 && isset($refObj->Fields['tags']) && !empty($refObj->Fields['aid'])) { $dsql->SetQuery("SELECT tid FROM `#@__taglist` WHERE aid = '{$refObj->Fields['aid']}' "); $dsql->Execute(); @@ -56,9 +53,9 @@ function lib_tag(&$ctag, &$refObj) $row['keyword'] = $row['tag']; $row['tag'] = dede_htmlspecialchars($row['tag']); if (isset($envs['makeTag']) && $envs['makeTag'] == 1) { - $row['link'] = $cfg_cmsurl."/a/tags/".GetPinyin($row['keyword'])."/"; + $row['link'] = $cfg_cmsurl.$tagsdir."/".$row['id']."/"; } else { - $row['link'] = $cfg_cmsurl."/apps/tags.php?/".urlencode($row['keyword'])."/"; + $row['link'] = $cfg_cmsurl."/apps/tags.php?/".$row['id']."/"; } $row['highlight'] = mt_rand(1, 10); foreach ($ctp->CTags as $tagid => $ctag) { |