Browse Source

add index view for user

master
filesite 7 months ago
parent
commit
9a7c3233b6
  1. 16
      themes/tajian/controller/ListController.php
  2. 25
      themes/tajian/controller/SiteController.php
  3. 100
      themes/tajian/views/site/myindex.php
  4. 3
      www/css/tajian.css

16
themes/tajian/controller/ListController.php

@ -85,20 +85,4 @@ Class ListController extends SiteController {
return $breads; return $breads;
} }
//根据tag的filenames获取它们的files数据,数据结构保持跟原file一致
protected function getTagFiles($tag, $scanResults) {
$files = array();
if (empty($tag['files'])) {return $files;}
foreach($tag['files'] as $filename) {
foreach($scanResults as $id => $item) {
if (!empty($item['filename']) && $item['filename'] == $filename && $item['extension'] == 'url') {
$files[$id] = $item;
}
}
}
return $files;
}
} }

25
themes/tajian/controller/SiteController.php

@ -63,12 +63,19 @@ Class SiteController extends Controller {
$tags = $this->sortTags($menus_sorted, $tags); $tags = $this->sortTags($menus_sorted, $tags);
} }
//根据tag获取相关数据,并传给视图;调整视图兼容tag的数据结构
if (!empty($tags)) {
foreach($tags as $id => $tag) {
$scanResults[$id]['files'] = $this->getTagFiles($tag, $scanResults);
}
}
//昵称支持 //昵称支持
$nickname = $this->getNickname($readmeFile); $nickname = $this->getNickname($readmeFile);
$pageTitle = $defaultTitle = "{$nickname}的视频收藏夹 | " . FSC::$app['config']['site_name']; $pageTitle = $defaultTitle = "{$nickname}的视频收藏夹 | " . FSC::$app['config']['site_name'];
$viewName = 'index'; $viewName = 'myindex';
$params = compact( $params = compact(
'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'tags', 'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'tags',
'nickname' 'nickname'
@ -145,6 +152,22 @@ Class SiteController extends Controller {
return $sorted_tags; return $sorted_tags;
} }
//根据tag的filenames获取它们的files数据,数据结构保持跟原file一致
protected function getTagFiles($tag, $scanResults) {
$files = array();
if (empty($tag['files'])) {return $files;}
foreach($tag['files'] as $filename) {
foreach($scanResults as $id => $item) {
if (!empty($item['filename']) && $item['filename'] == $filename && $item['extension'] == 'url') {
$files[$id] = $item;
}
}
}
return $files;
}
protected function getNickname($readmeFile) { protected function getNickname($readmeFile) {
$nickname = ''; $nickname = '';

100
themes/tajian/views/site/myindex.php

@ -0,0 +1,100 @@
<?php
//常用方法
require_once __DIR__ . '/../../../../plugins/Html.php';
$imgPreffix = '/' . FSC::$app['config']['content_directory'] . FSC::$app['config']['tajian']['data_dir'];
$linkPrefix = '';
//多用户路径支持
if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['user_id'])) {
$linkPrefix = '/' . FSC::$app['user_id'];
}
if (!empty($breadcrumbs)) {
echo <<<eof
<div class="breadcrumbs">
<a href="{$linkPrefix}/">首页</a> &gt;&gt;
eof;
foreach($breadcrumbs as $bread) {
if ($bread['id'] != $selectedId) {
echo <<<eof
<a href="{$bread['url']}">{$bread['name']}</a> /
eof;
}else {
echo <<<eof
<strong>{$bread['name']}</strong>
eof;
}
}
echo <<<eof
</div>
eof;
}
?>
<main class="g_main_lay">
<div class="videos_list clearfix">
<?php
$videoExts = array('url');
if (!empty($viewData['tags'])) { //显示tags分类
foreach($viewData['tags'] as $id => $item) {
//输出分类名称
echo <<<eof
<div class="tgroup">
<a href="{$linkPrefix}/list/?id={$id}" class="morelink">&gt;&gt;更多</a>
<h3>{$item['name']}</h3>
</div>
<div class="clearfix">
eof;
$category = $viewData['scanResults'][$item['id']];
if (!empty($category['files'])) { //一级目录支持,目录下直接存放视频文件
$cate_files = Html::sortFilesByCreateTime($category['files'], 'desc'); //按创建时间排序
foreach($cate_files as $index => $file) {
//跳过非.url文件,且最多显示 8 个
if (!in_array($file['extension'], $videoExts) || empty($file['shortcut']) || $index >= 8) {
continue;
}
$snapshot = !empty($file['cover']) ? $imgPreffix . $file['cover'] : '/img/default.png';
$title = !empty($file['title']) ? Html::mb_substr($file['title'], 0, 33, 'utf-8') : $file['filename'];
$platform = Html::getShareVideosPlatform($file['shortcut']['url']);
$pubDate = date('m/d', $file['fstat']['ctime']);
$imgSrc = $index < 8 ? " src=\"{$snapshot}\"" : '';
$imgAlt = $index < 8 ? " alt=\"{$title}\"" : '';
echo <<<eof
<div class="vl_list_main advideo-item">
<div class="video_img_vl">
<a href="{$file['shortcut']['url']}" target="_blank">
<img data-original="{$snapshot}" class="lazy"{$imgSrc}{$imgAlt}>
</a>
</div>
<div class="video_title_vl">
<a href="{$file['shortcut']['url']}" target="_blank">
<span class="duration">{$platform}</span>
<strong>{$pubDate},{$title}</strong>
</a>
</div>
</div>
eof;
}
}
echo <<<eof
</div>
eof;
}
}
?>
</div>
</main>

3
www/css/tajian.css

@ -88,7 +88,8 @@ a:link{text-decoration:none;}
-webkit-line-clamp: 2; /* 这里是超出几行省略 */ -webkit-line-clamp: 2; /* 这里是超出几行省略 */
overflow: hidden; overflow: hidden;
} }
.tgroup{padding-right:5px;padding-top:10px}
.morelink{float:right;font-size:13px;margin-top:3px}
/* 首页 end*/ /* 首页 end*/
/* 联系我们 */ /* 联系我们 */

Loading…
Cancel
Save