给category list增加聚焦效果

This commit is contained in:
祁宁 2014-04-09 12:44:53 +08:00
parent 542620a9af
commit 99f6e2f8a7
2 changed files with 22 additions and 10 deletions

View File

@ -727,6 +727,7 @@ class Widget_Archive extends Widget_Abstract_Contents
* @param Typecho_Db_Query $select 查询对象
* @param boolean $hasPushed 是否已经压入队列
* @return void
* @throws Typecho_Widget_Exception
*/
private function singleHandle(Typecho_Db_Query $select, &$hasPushed)
{
@ -868,6 +869,7 @@ class Widget_Archive extends Widget_Abstract_Contents
* @param Typecho_Db_Query $select 查询对象
* @param boolean $hasPushed 是否已经压入队列
* @return void
* @throws Typecho_Widget_Exception
*/
private function categoryHandle(Typecho_Db_Query $select, &$hasPushed)
{
@ -890,15 +892,19 @@ class Widget_Archive extends Widget_Abstract_Contents
$categorySelect->where('slug = ?', $directory[count($directory) - 1]);
}
$category = $this->db->fetchRow($categorySelect,
array($this->widget('Widget_Metas_Category_List'), 'filter'));
if (!$category
|| (isset($directory) && ($this->request->directory != implode('/', $category['directory'])))) {
$category = $this->db->fetchRow($categorySelect);
if (empty($category)) {
throw new Typecho_Widget_Exception(_t('分类不存在'), 404);
}
$children = $this->widget('Widget_Metas_Category_List')->getAllChildren($category['mid']);
$categoryListWidget = $this->widget('Widget_Metas_Category_List', 'current=' . $category['mid']);
$category = $categoryListWidget->filter($category);
if (isset($directory) && ($this->request->directory != implode('/', $category['directory']))) {
throw new Typecho_Widget_Exception(_t('父级分类不存在'), 404);
}
$children = $categoryListWidget->getAllChildren($category['mid']);
$children[] = $category['mid'];
/** fix sql92 by 70 */
@ -949,6 +955,7 @@ class Widget_Archive extends Widget_Abstract_Contents
* @param Typecho_Db_Query $select 查询对象
* @param boolean $hasPushed 是否已经压入队列
* @return void
* @throws Typecho_Widget_Exception
*/
private function tagHandle(Typecho_Db_Query $select, &$hasPushed)
{
@ -1017,6 +1024,7 @@ class Widget_Archive extends Widget_Abstract_Contents
* @param Typecho_Db_Query $select 查询对象
* @param boolean $hasPushed 是否已经压入队列
* @return void
* @throws Typecho_Widget_Exception
*/
private function authorHandle(Typecho_Db_Query $select, &$hasPushed)
{

View File

@ -91,12 +91,11 @@ class Widget_Metas_Category_List extends Widget_Abstract_Metas
* @param mixed $request request对象
* @param mixed $response response对象
* @param mixed $params 参数列表
* @return void
*/
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);
$this->parameter->setDefault('ignore=0');
$this->parameter->setDefault('ignore=0&current=');
/** 初始化回调函数 */
if (function_exists('treeViewCategories')) {
@ -145,7 +144,7 @@ class Widget_Metas_Category_List extends Widget_Abstract_Metas
$classes = array();
if ($categoryOptions->itemClass) {
$classes[] = $singleCommentOptions->itemClass;
$classes[] = $categoryOptions->itemClass;
}
$classes[] = 'category-level-' . $this->levels;
@ -160,6 +159,12 @@ class Widget_Metas_Category_List extends Widget_Abstract_Metas
echo ' category-parent';
}
if ($this->mid == $this->parameter->current) {
echo ' category-active';
} else if (isset($this->_children[$this->mid]) && in_array($this->parameter->current, $this->_children[$this->mid])) {
echo ' category-parent-active';
}
echo '"><a href="' . $this->permalink . '">' . $this->name . '</a>';
if ($categoryOptions->showCount) {
@ -312,7 +317,6 @@ class Widget_Metas_Category_List extends Widget_Abstract_Metas
* 根据深度余数输出
*
* @access public
* @param string $param 需要输出的值
* @return void
*/
public function levelsAlt()