Browse Source

add tag and keyword filter for fav management

master
filesite 6 months ago
parent
commit
6d42c8f7c4
  1. 9
      themes/tajian/controller/MyController.php
  2. 30
      themes/tajian/views/my/favs.php
  3. 1
      www/css/tajian.css

9
themes/tajian/controller/MyController.php

@ -102,9 +102,16 @@ Class MyController extends SiteController { @@ -102,9 +102,16 @@ Class MyController extends SiteController {
//管理收藏
public function actionFavs() {
//分类筛选支持
$selectTag = $this->get('tag', '');
$searchKeyword = $this->get('keyword', '');
if (!empty($searchKeyword)) {
$searchKeyword = Common::cleanSpecialChars($searchKeyword);
}
$defaultTitle = "管理收藏";
$viewName = 'favs';
return $this->actionIndex($viewName, $defaultTitle);
return $this->actionIndex($viewName, $defaultTitle, compact('selectTag', 'searchKeyword'));
}
//分享收藏夹

30
themes/tajian/views/my/favs.php

@ -34,6 +34,23 @@ $allTags = Html::getTagNames($viewData['tags']); @@ -34,6 +34,23 @@ $allTags = Html::getTagNames($viewData['tags']);
</div>
<h3 class="mt20">你已收藏 <?=$total_my_videos?> 个视频</h3>
<p class="mt10">勾选视频下方的分类,将该视频归类到对应的分类;取消勾选,则将视频从该分类中移除。</p>
<form action="" metho="GET">
<select name="tag">
<option value="">选择分类</option>
<?php
foreach($allTags as $tagName) {
$selected = !empty($viewData['selectTag']) && $viewData['selectTag'] == $tagName ? ' selected' : '';
echo <<<eof
<option value="{$tagName}"{$selected}>{$tagName}</option>
eof;
}
?>
</select>
<input type="text" name="keyword" class="ipt" placeholder="输入关键词" value="<?=htmlspecialchars($viewData['searchKeyword'])?>">
<button type="submit" class="btn-primary">筛选</button>
</form>
<div class="videos_list clearfix" id="favmg">
<?php
@ -47,6 +64,18 @@ $allTags = Html::getTagNames($viewData['tags']); @@ -47,6 +64,18 @@ $allTags = Html::getTagNames($viewData['tags']);
continue;
}
$myTags = Html::getFavsTags($file['filename'], $viewData['tags']);
//分类筛选支持
if (!empty($viewData['selectTag']) && !in_array($viewData['selectTag'], $myTags)) {
continue;
}
//关键词搜索支持
if (!empty($viewData['searchKeyword']) && strpos($file['title'], $viewData['searchKeyword']) === false) {
continue;
}
$snapshot = !empty($file['cover']) ? Html::getCDNImageUrl($imgPreffix . $file['cover']) : '/img/default.png';
$title = !empty($file['title']) ? Html::mb_substr($file['title'], 0, 33, 'utf-8') : $file['filename'];
@ -58,7 +87,6 @@ $allTags = Html::getTagNames($viewData['tags']); @@ -58,7 +87,6 @@ $allTags = Html::getTagNames($viewData['tags']);
$imgAlt = $index < 4 ? " alt=\"{$title}\"" : '';
$imgCls = $index < 4 ? '' : 'lazy';
$myTags = Html::getFavsTags($file['filename'], $viewData['tags']);
$tagsHtml = '';
foreach ($allTags as $tagName) {

1
www/css/tajian.css

@ -256,6 +256,7 @@ a:link{text-decoration:none} @@ -256,6 +256,7 @@ a:link{text-decoration:none}
.btn-primary:hover,.btn-danger:hover{font-weight:500}
.bi{width:1em;height:1em;display:inline-block;vertical-align:-.125em;fill:currentcolor}
.tajian_index .pfav{float:left;width:50%;min-height:60px;font-size:16px}
select,.ipt{padding:4px}
.stats{background-color:#EEE;padding:10px 10px 4px 10px}
.stats .col{display:inline-block;padding:13px 4px;width:30%;max-width:128px;background:#444;color:#FFF;margin-right:4px;margin-bottom:6px;text-align:center}

Loading…
Cancel
Save