diff --git a/src/system/taglib/channel.lib.php b/src/system/taglib/channel.lib.php index 40df44c4..0455c7f2 100755 --- a/src/system/taglib/channel.lib.php +++ b/src/system/taglib/channel.lib.php @@ -1,9 +1,14 @@ CAttribute->Items, $attlist); + FillAttsDefault($ctag->CAttribute->Items,$attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = $ctag->GetInnerText(); $line = empty($row) ? 100 : $row; @@ -49,19 +54,23 @@ function lib_channel(&$ctag, &$refObj) if ($type == '' || $type == 'sun') $type = 'son'; if ($innertext == '') $innertext = GetSysTemplets("channel_list.htm"); if ($type == 'top') { - $sql = "SELECT * FROM `#@__arctype` WHERE reid=0 AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $line"; + $sql = "SELECT * FROM `#@__arctype` WHERE reid=0 AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $row"; } else if ($type == 'son') { if ($typeid == 0) return ''; - $sql = "SELECT * FROM `#@__arctype` WHERE reid='$typeid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $line"; + $sql = "SELECT * FROM `#@__arctype` WHERE reid='$typeid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $row"; } else if ($type == 'self') { if ($reid == 0) return ''; - $sql = "SELECT * FROM `#@__arctype` WHERE reid='$reid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $line"; + $sql = "SELECT * FROM `#@__arctype` WHERE reid='$reid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $row"; } $needRel = false; $dtp2 = new DedeTagParse(); $dtp2->SetNameSpace('field', '[', ']'); $dtp2->LoadSource($innertext); - //检查是否有子栏目,并返回rel提示用于二级菜单 + $dsql2 = clone $dsql; + $dsql->SetQuery($sql); + $dsql->Execute(); + $line = $row; + //检查是否有子栏目,并返回rel提示(用于二级菜单) if (preg_match('#:rel#', $innertext)) $needRel = true; if (empty($sql)) return ''; $dsql->SetQuery($sql); @@ -69,15 +78,15 @@ function lib_channel(&$ctag, &$refObj) $totalRow = $dsql->GetTotalRow(); //如果用子栏目模式,当没有子栏目时显示同级栏目 if ($type == 'son' && $reid != 0 && $totalRow == 0) { - $sql = "SELECT * FROM `#@__arctype` WHERE reid='$reid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $line"; + $sql = "SELECT * FROM `#@__arctype` WHERE reid='$reid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $row"; $dsql->SetQuery($sql); $dsql->Execute(); } $GLOBALS['autoindex'] = 0; for ($i = 0; $i < $line; $i++) { - if ($col > 1) $likeType .= "
\r\n"; + if ($col > 1) $likeType .= "
"; for ($j = 0; $j < $col; $j++) { - if ($col > 1) $likeType .= "
\r\n"; + if ($col > 1) $likeType .= "
"; if ($row = $dsql->GetArray()) { $row['sonids'] = $row['rel'] = ''; if ($needRel) { @@ -86,41 +95,91 @@ function lib_channel(&$ctag, &$refObj) else $row['rel'] = " rel='dropmenu{$row['id']}'"; } //处理同级栏目中,当前栏目的样式 - if (($row['id'] == $typeid || ($topid == $row['id'] && $type == 'top')) && $currentstyle != '') { - $linkOkstr = $currentstyle; - $row['typelink'] = GetOneTypeUrlA($row); - $linkOkstr = str_replace("~rel~", $row['rel'], $linkOkstr); - $linkOkstr = str_replace("~id~", $row['id'], $linkOkstr); - $linkOkstr = str_replace("~typename~", $row['typename'], $linkOkstr); - $linkOkstr = str_replace("~cnoverview~", $row['cnoverview'], $linkOkstr); - $linkOkstr = str_replace("~enname~", $row['enname'], $linkOkstr); - $linkOkstr = str_replace("~enoverview~", $row['enoverview'], $linkOkstr); - $linkOkstr = str_replace("~typelink~", $row['typelink'], $linkOkstr); - $linkOkstr = str_replace("~bigpic~", $row['bigpic'], $linkOkstr); - $linkOkstr = str_replace("~litimg~", $row['litimg'], $linkOkstr); - $likeType .= $linkOkstr; + if (($row['id'] == $typeid || ($topid == $row['id'] && $type == 'top') ) && $currentstyle != '') { + if ($currentstyle != '') { + $linkOkstr = $currentstyle; + $row['typelink'] = GetOneTypeUrlA($row); + $linkOkstr = str_replace("~rel~", $row['rel'], $linkOkstr); + $linkOkstr = str_replace("~id~", $row['id'], $linkOkstr); + $linkOkstr = str_replace("~typename~", $row['typename'], $linkOkstr); + $linkOkstr = str_replace("~cnoverview~", $row['cnoverview'], $linkOkstr); + $linkOkstr = str_replace("~enname~", $row['enname'], $linkOkstr); + $linkOkstr = str_replace("~enoverview~", $row['enoverview'], $linkOkstr); + $linkOkstr = str_replace("~typelink~", $row['typelink'], $linkOkstr); + $linkOkstr = str_replace("~bigpic~", $row['bigpic'], $linkOkstr); + $linkOkstr = str_replace("~litimg~", $row['litimg'], $linkOkstr); + $likeType .= $linkOkstr; + } } else { $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row); if (is_array($dtp2->CTags)) { - foreach ($dtp2->CTags as $tagid => $ctag) { - if (isset($row[$ctag->GetName()])) $dtp2->Assign($tagid, $row[$ctag->GetName()]); + foreach($dtp2->CTags as $tagid=>$ctag) { + if (isset($row[$ctag->GetName()])) { + $dtp2->Assign($tagid,$row[$ctag->GetName()]); + } else if (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName())) { + $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2)); + } } } $likeType .= $dtp2->GetResult(); } } - if ($col > 1) $likeType .= "
\r\n"; + if ($col > 1) $likeType .= ""; $GLOBALS['autoindex']++; } if ($col > 1) { $i += $col - 1; - $likeType .= "
\r\n"; + $likeType .= "
"; } } + reset($dsql2); $dsql->FreeResult(); - if ($cacheid != '') { - WriteCacheBlock($cacheid, $likeType); + return $likeType; +} +function lib_channel_son($ctag, $typeid = 0, $dsql2) +{ + $attlist = 'row|100,col|1,currentstyle|,notypeid|0'; + FillAttsDefault($ctag->CAttribute->Items,$attlist); + extract($ctag->CAttribute->Items, EXTR_SKIP); + $innertext = $ctag->GetInnerText(); + $dsql3 = clone $dsql2; + $likeType = ''; + if ($notypeid != 0) { + $tpsql = $tpsql."and not(id in($notypeid)) "; + } + $sql = "SELECT * FROM `#@__arctype` WHERE reid='$typeid' AND ishidden<>1 ORDER BY sortrank ASC LIMIT 0, $row"; + $dtp2 = new DedeTagParse(); + $dtp2->SetNameSpace("field","[","]"); + $dtp2->LoadSource($innertext); + $dsql2->SetQuery($sql); + $dsql2->Execute(); + $line = $row; + for ($i = 0; $i < $line; $i++) { + if ($col > 1) $likeType .= "
"; + for ($j = 0; $j < $col; $j++) { + if ($col > 1) $likeType .= "
"; + if ($row = $dsql2->GetArray()) { + $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row); + if (is_array($dtp2->CTags)) { + foreach($dtp2->CTags as $tagid=>$ctag) { + if (isset($row[$ctag->GetName()])) { + $dtp2->Assign($tagid,$row[$ctag->GetName()]); + } else if (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName())) { + $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql3)); + } + } + } + $likeType .= $dtp2->GetResult(); + } + if ($col > 1) $likeType .= "
"; + } + if ($col > 1) { + $i += $col - 1; + $likeType .= "
"; + } } + reset($dsql3); + $dsql2->FreeResult(); return $likeType; } ?> \ No newline at end of file