Browse Source

multiple fav management added

master
filesite 6 months ago
parent
commit
b59a43bdc8
  1. 55
      plugins/Common.php
  2. 34
      themes/tajian/controller/MyController.php
  3. 1
      themes/tajian/views/my/index.php
  4. 34
      themes/tajian/views/my/switchdir.php
  5. 5
      themes/tajian/views/site/tajian.php
  6. 4
      www/img/people.svg

55
plugins/Common.php

@ -92,11 +92,18 @@ Class Common { @@ -92,11 +92,18 @@ Class Common {
}
//根据手机号码获取映射的用户名
//支持数组格式,一个手机号码管理多个收藏夹
public static function getMappedUsername($cellphone){
$username = $cellphone;
if (!empty(FSC::$app['config']['tajian_user_map']) && !empty(FSC::$app['config']['tajian_user_map'][$username])) {
$username = FSC::$app['config']['tajian_user_map'][$username];
$user_map = FSC::$app['config']['tajian_user_map'];
if (!empty($user_map[$cellphone])) {
$userDirs = $user_map[$cellphone];
if (is_string($userDirs)) {
$username = $userDirs;
}else if (is_array($userDirs) && !empty($userDirs)) {
$username = $userDirs[0];
}
}else {
$username = self::getUserId($cellphone);
}
@ -104,6 +111,37 @@ Class Common { @@ -104,6 +111,37 @@ Class Common {
return $username;
}
public static function getMyDirs($cellphone){
$userDirs = array();
$user_map = FSC::$app['config']['tajian_user_map'];
if (!empty($user_map[$cellphone])) {
if (is_string($user_map[$cellphone])) {
array_push($userDirs, $user_map[$cellphone]);
}else if (is_array($user_map[$cellphone])) {
$userDirs = $user_map[$cellphone];
}
}
return $userDirs;
}
public static function getNicknameByDir($dir, $username){
$rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory'];
$dirPath = str_replace($username, $dir, $rootDir);
$filepath = "{$dirPath}/README_nickname.txt";
$nickname = $username;
if (file_exists($filepath)) {
$nickname = file_get_contents($filepath);
if (!empty($nickname)) {
$nickname = trim($nickname);
}
}
return $nickname;
}
//判断用户数据目录是否存在
public static function getUserDataDir($cellphone) {
$rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory'];
@ -161,6 +199,19 @@ Class Common { @@ -161,6 +199,19 @@ Class Common {
return compact('login_time', 'username', 'friends_code', 'cellphone');
}
public static function switchUserDir($dir) {
if(session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
$currentDir = $_SESSION['username'];
FSC::$app['config']['content_directory'] = str_replace($currentDir, $dir, FSC::$app['config']['content_directory']);
$_SESSION['username'] = $dir;
return $_SESSION['username'];
}
//从session里获取用户数据
public static function getUserFromSession() {
if(session_status() !== PHP_SESSION_ACTIVE) {

34
themes/tajian/controller/MyController.php

@ -8,7 +8,7 @@ require_once __DIR__ . '/SiteController.php'; @@ -8,7 +8,7 @@ require_once __DIR__ . '/SiteController.php';
Class MyController extends SiteController {
public function actionIndex($viewName = 'index', $defaultTitle = '个人中心') {
public function actionIndex($viewName = 'index', $defaultTitle = '个人中心', $viewData = array()) {
//判断是否已经登录,自动跳转到自己的添加视频网址
$loginedUser = Common::getUserFromSession();
if (empty($loginedUser['username'])) {
@ -18,6 +18,14 @@ Class MyController extends SiteController { @@ -18,6 +18,14 @@ Class MyController extends SiteController {
return $this->redirect($shareUrl);
}
//账号切换支持
$goDir = $this->get('dir', '');
if (!empty($goDir) && !empty($loginedUser['cellphone'])) {
$myDirs = Common::getMyDirs($loginedUser['cellphone']);
if (in_array($goDir, $myDirs)) {
Common::switchUserDir($goDir);
}
}
//获取数据
$htmlReadme = ''; //Readme.md 内容,底部网站详细介绍
@ -62,6 +70,11 @@ Class MyController extends SiteController { @@ -62,6 +70,11 @@ Class MyController extends SiteController {
'cateId', 'dirTree', 'scanResults',
'htmlReadme', 'tags', 'nickname'
);
if (!empty($viewData)) {
$params = array_merge($params, $viewData);
}
return $this->render($viewName, $params, $pageTitle);
}
@ -100,4 +113,23 @@ Class MyController extends SiteController { @@ -100,4 +113,23 @@ Class MyController extends SiteController {
return $this->actionIndex($viewName, $defaultTitle);
}
//切换收藏夹
public function actionDirs() {
$myDirs = $myNicks = array();
$loginedUser = Common::getUserFromSession();
if (!empty($loginedUser['cellphone'])) {
$myDirs = Common::getMyDirs($loginedUser['cellphone']);
if (!empty($myDirs)) {
foreach($myDirs as $dir) {
$myNicks[$dir] = Common::getNicknameByDir($dir, $loginedUser['username']);
}
}
}
$defaultTitle = "切换账号";
$viewName = 'switchdir';
return $this->actionIndex($viewName, $defaultTitle, compact('myDirs', 'myNicks'));
}
}

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

@ -25,6 +25,7 @@ if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['use @@ -25,6 +25,7 @@ if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['use
<li><a href="<?=$linkPrefix?>/my/favs"><img src="/img/favorite.png" alt="favorite" width="20"> 管理收藏</a></li>
<li><a href="<?=$linkPrefix?>/my/tags"><img src="/img/collection.svg" alt="collection" width="18"> 管理分类</a></li>
<li><a href="<?=$linkPrefix?>/my/share"><img src="/img/share-fill.svg" alt="share favorite" width="18"> 分享收藏</a></li>
<li><a href="<?=$linkPrefix?>/my/dirs"><img src="/img/people.svg" alt="share favorite" width="18"> 切换账号</a></li>
</ul>
</div>
</main>

34
themes/tajian/views/my/switchdir.php

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
<?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">
<div class="g_form_style">
<div class="vercenter">
<strong class="nickname">点击切换</strong>
</div>
<hr>
<ul class="mg_menus">
<?php
if (!empty($viewData['myNicks'])) {
foreach($viewData['myNicks'] as $dir => $nickname) {
echo <<<eof
<li><a href="{$linkPrefix}/my/index?dir={$dir}">{$dir} {$nickname}</a></li>
eof;
}
}else {
echo <<<eof
<li>你还没有创建聚宝盆哦!</li>
eof;
}
?>
</ul>
</div>
</main>

5
themes/tajian/views/site/tajian.php

@ -88,7 +88,10 @@ eof; @@ -88,7 +88,10 @@ eof;
<li>快手</li>
<li>西瓜视频</li>
</ul>
<p class="pl20 pt20">更多App和网站将陆续增加。。。</p>
<p class="pl20 pt20">
更多视频App和网站将陆续增加;
<br><strong>任意网站</strong>收藏限VIP用户使用,如需开通请联系客服邮箱(machete#filesite.io,替换#为@)。
</p>
<h3 class="h3title pl20">Ta荐核心数据</h3>
<div class="stats pl20">

4
www/img/people.svg

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-people" viewBox="0 0 16 16">
<path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1zm-7.978-1L7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002-.014.002zM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4m3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0M6.936 9.28a6 6 0 0 0-1.23-.247A7 7 0 0 0 5 9c-4 0-5 3-5 4q0 1 1 1h4.216A2.24 2.24 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816M4.92 10A5.5 5.5 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275ZM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0m3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4"/>
</svg>

After

Width:  |  Height:  |  Size: 738 B

Loading…
Cancel
Save