Browse Source

add page my/

master
filesite 7 months ago
parent
commit
dd95d72483
  1. 8
      plugins/Common.php
  2. 66
      themes/tajian/controller/MyController.php
  3. 5
      themes/tajian/controller/SiteController.php
  4. 27
      themes/tajian/views/my/index.php
  5. 15
      www/css/tajian.css

8
plugins/Common.php

@ -148,4 +148,12 @@ Class Common {
return compact('login_time', 'username', 'friends_code'); return compact('login_time', 'username', 'friends_code');
} }
public static function logoutUserFromSession() {
if(session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
return session_destroy();
}
} }

66
themes/tajian/controller/MyController.php

@ -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);
}
}

5
themes/tajian/controller/SiteController.php

@ -252,4 +252,9 @@ Class SiteController extends Controller {
return $this->render($viewName, $params, $pageTitle); return $this->render($viewName, $params, $pageTitle);
} }
public function actionLogout() {
$logout = Common::logoutUserFromSession();
return $this->redirect('/site/login');
}
} }

27
themes/tajian/views/my/index.php

@ -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>

15
www/css/tajian.css

@ -17,7 +17,7 @@ a{color:#464c5c;}
.vercenter{text-align:center !important;} .vercenter{text-align:center !important;}
.verbold{font-weight:bold !important;} .verbold{font-weight:bold !important;}
.opacityshow{opacity:1 !important;} .opacityshow{opacity:1 !important;}
a:hover{text-decoration:none;} a:hover{text-decoration:none;color:darkblue;}
a:active{text-decoration:none;} a:active{text-decoration:none;}
a:visited{text-decoration:none;} a:visited{text-decoration:none;}
a:link{text-decoration:none;} a:link{text-decoration:none;}
@ -70,7 +70,7 @@ a:link{text-decoration:none;}
/* 主内容 */ /* 主内容 */
.g_main_lay{padding:0 2% 0 3.4%;margin-top:18px;min-height:280px;position:relative;max-width:1700px;} .g_main_lay{padding:0 2% 0 3.4%;margin-top:18px;min-height:360px;position:relative;max-width:1700px;}
.g_main_border{border-top:solid 1px #eeeeee;} .g_main_border{border-top:solid 1px #eeeeee;}
.vl_list_main{float:left;width:25%;margin:10px 0 22px 0;position:relative} .vl_list_main{float:left;width:25%;margin:10px 0 22px 0;position:relative}
.video-menu-ow{border-bottom:1px solid rgba(0,0,0,.1)} .video-menu-ow{border-bottom:1px solid rgba(0,0,0,.1)}
@ -244,18 +244,25 @@ a:link{text-decoration:none;}
.tajian_index .kfwx{float:right;border-radius:6px} .tajian_index .kfwx{float:right;border-radius:6px}
.tajian_index .loginbtn{border:1px solid #50509d;background-color:#50509d;color:#FFF;padding:3px 10px;border-radius:4px} .tajian_index .loginbtn{border:1px solid #50509d;background-color:#50509d;color:#FFF;padding:3px 10px;border-radius:4px}
/* 注册 */ /* 注册/登录 */
.twocol label{display:block} .twocol label{display:block}
.twocol input{width:62%} .twocol input{width:62%}
.twocol button{margin-left:4px} .twocol button{margin-left:4px}
/* 个人中心 */
.nickname{font-size:20px}
.mg_menus{margin-top:20px}
.mg_menus li{display:inline-block;width:45%;margin:5px;border:1px solid #DDD;border-radius:5px;text-align:center;vertical-align:middle;}
.mg_menus li a{display:block;padding:15px 10px}
.mg_menus li a:hover{background-color:lightblue;color:#FFF;font-weight:bold}
/* layout index */ /* layout index */
body.layout_index{background-color:#e5f1f3} body.layout_index{background-color:#e5f1f3}
.layout_index .top_nav .verMiddle{vertical-align:baseline !important} .layout_index .top_nav .verMiddle{vertical-align:baseline !important}
.layout_index .footer{border-top:1px solid #DDD;padding-top:20px} .layout_index .footer{border-top:1px solid #DDD;padding-top:20px}
.layout_index .top_nav{padding-left:20%;padding-right:20%} .layout_index .top_nav{padding-left:20%;padding-right:20%}
.layout_index .mt65{margin-top:65px} .layout_index .mt65{margin-top:65px}
.layout_index .mt10{margin-top:10px} .mt10,.layout_index .mt10{margin-top:10px}
.layout_index .ml20{margin-left:20px} .layout_index .ml20{margin-left:20px}
.layout_index .pl20{padding-left:20px} .layout_index .pl20{padding-left:20px}
.layout_index .pt20{padding-top:20px} .layout_index .pt20{padding-top:20px}

Loading…
Cancel
Save