filesite
7 months ago
5 changed files with 117 additions and 4 deletions
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
<?php |
||||
/** |
||||
* My Controller |
||||
*/ |
||||
require_once __DIR__ . '/../../../lib/DirScanner.php'; |
||||
require_once __DIR__ . '/../../../plugins/Parsedown.php'; |
||||
require_once __DIR__ . '/SiteController.php'; |
||||
|
||||
Class MyController extends SiteController { |
||||
|
||||
public function actionIndex() { |
||||
//判断是否已经登录,自动跳转到自己的添加视频网址 |
||||
$loginedUser = Common::getUserFromSession(); |
||||
if (empty($loginedUser['username'])) { |
||||
return $this->redirect('/site/login/'); |
||||
}else if (!empty(FSC::$app['config']['multipleUserUriParse']) && FSC::$app['user_id'] != $loginedUser['username']) { |
||||
$shareUrl = "/{$loginedUser['username']}/my/"; |
||||
return $this->redirect($shareUrl); |
||||
} |
||||
|
||||
|
||||
//获取数据 |
||||
$menus = array(); //菜单,一级目录 |
||||
$htmlReadme = ''; //Readme.md 内容,底部网站详细介绍 |
||||
$menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 |
||||
|
||||
$scanner = new DirScanner(); |
||||
$scanner->setWebRoot(FSC::$app['config']['content_directory']); |
||||
$dirTree = $scanner->scan(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'], 3); |
||||
$scanResults = $scanner->getScanResults(); |
||||
|
||||
$readmeFile = $scanner->getDefaultReadme(); |
||||
if (!empty($readmeFile)) { |
||||
if (!empty($readmeFile['sort'])) { |
||||
$menus_sorted = explode("\n", $readmeFile['sort']); |
||||
} |
||||
|
||||
$Parsedown = new Parsedown(); |
||||
$content = file_get_contents($readmeFile['realpath']); |
||||
$htmlReadme = $Parsedown->text($content); |
||||
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); |
||||
} |
||||
|
||||
//获取tags分类 |
||||
$tags = $this->getTags($dirTree); |
||||
|
||||
//排序 |
||||
if (!empty($menus_sorted) && !empty($tags)) { |
||||
$tags = $this->sortTags($menus_sorted, $tags); |
||||
} |
||||
|
||||
//昵称支持 |
||||
$nickname = $this->getNickname($readmeFile); |
||||
|
||||
$pageTitle = $defaultTitle = '个人中心 | ' . FSC::$app['config']['site_name']; |
||||
$viewName = 'index'; |
||||
$params = compact( |
||||
'dirTree', 'scanResults', 'menus', 'htmlReadme', |
||||
'tags', 'nickname' |
||||
); |
||||
return $this->render($viewName, $params, $pageTitle); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
<?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']; |
||||
} |
||||
|
||||
?><main class="g_main_lay g_main_border"> |
||||
<div class="g_form_style"> |
||||
<div class="vercenter"> |
||||
<strong class="nickname"><?=htmlspecialchars($viewData['nickname'], ENT_QUOTES)?></strong> |
||||
(<a href="###">修改</a>) |
||||
<p class="mt10"> |
||||
<a href="/site/logout">退出登录</a> |
||||
</p> |
||||
</div> |
||||
<hr> |
||||
<ul class="mg_menus"> |
||||
<li><a href="###">管理分类</a></li> |
||||
<li><a href="###">管理收藏</a></li> |
||||
</ul> |
||||
</div> |
||||
</main> |
Loading…
Reference in new issue