From 9a1f44eed6faae479f516336458bbf2c7702dbed Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 27 Apr 2015 21:07:48 +0000 Subject: [PATCH] Member list commit --- _sakura/changelog.json | 16 +++- _sakura/components/Users.php | 26 ++++- _sakura/sakura.php | 2 +- _sakura/templates/yuuno/main/memberlist.tpl | 101 ++++++++++++++++++++ content/data/yuuno/css/yuuno.css | 66 ++++++++++--- main/.htaccess | 10 ++ main/members.php | 27 ++++++ 7 files changed, 231 insertions(+), 17 deletions(-) create mode 100644 _sakura/templates/yuuno/main/memberlist.tpl create mode 100644 main/members.php diff --git a/_sakura/changelog.json b/_sakura/changelog.json index bcfeeda..4a3bf9a 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -14,7 +14,8 @@ "20150427.3", "20150427.4", "20150427.5", - "20150427.6" + "20150427.6", + "20150427.7" ] @@ -772,6 +773,19 @@ "change": "Remove origin check on CloudFlare country header." } + ], + + "20150427.7": [ + + { + "type": "ADD", + "change": "Add members page." + }, + { + "type": "ADD", + "change": "Add members page pagination." + } + ] } diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php index bcc0617..b1fe829 100644 --- a/_sakura/components/Users.php +++ b/_sakura/components/Users.php @@ -847,6 +847,30 @@ class Users { } + // Get users in rank + public static function getUsersInRank($rankId, $users = null) { + + // Get all users (or use the supplied user list to keep server load down) + if(!$users) + $users = self::getAllUsers(); + + // Make output array + $rank = array(); + + // Go over all users and check if they have the rank id + foreach($users as $user) { + + // If so store the user's row in the array + if(self::checkIfUserHasRanks([$rankId], $user, true)) + $rank[] = $user; + + } + + // Then return the array with the user rows + return $rank; + + } + // Get all users public static function getAllUsers($includeInactive = true) { @@ -860,7 +884,7 @@ class Users { foreach($getUsers as $user) { // Skip if inactive and not include deactivated users - if(!$includeInactive && $user['rank_main'] < 2) + if(!$includeInactive && self::checkIfUserHasRanks([0, 1], $user, true)) continue; $users[$user['id']] = $user; diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 4d36c49..82ad45f 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20150427.6'); +define('SAKURA_VERSION', '20150427.7'); define('SAKURA_VLABEL', 'Heliotrope'); define('SAKURA_VTYPE', 'Development'); define('SAKURA_COLOUR', '#DF73FF'); diff --git a/_sakura/templates/yuuno/main/memberlist.tpl b/_sakura/templates/yuuno/main/memberlist.tpl new file mode 100644 index 0000000..7440bfa --- /dev/null +++ b/_sakura/templates/yuuno/main/memberlist.tpl @@ -0,0 +1,101 @@ +{% include 'global/header.tpl' %} + {% if user.checklogin %} +
+

{% if not page.active %}All members{% else %}{{ page.ranks[page.active].name }}{% if page.ranks[page.active].multi %}s{% endif %}{% endif %}

+

{% if not page.active %}The entire user list.{% else %}{{ page.ranks[page.active].description }}{% endif %}

+ + {% if page.notfound %} +

The requested rank was not found!

+ {% else %} +
+ {% if page.sort == page.sorts[2] %} + + + + + + + + + + + + + + + + + + + + + + {% for count,user in page.users[page.page] %} + + + + + + + + + + + {% endfor %} +
No.UsernameRegisteredLast onlineUser titleCountry
No.UsernameRegisteredLast onlineUser titleCountry
+ #{{ count + 1 }} + + {{ user.username }} + + {{ user.regdate|date("l Y-m-d H:i T") }} + + {% if user.lastdate == 0 %}Never logged in.{% else %}{{ user.lastdate|date("l Y-m-d H:i T") }}{% endif %} + + {% if not user.usertitle %}{{ page.ranks[user.rank_main].title }}{% else %}{{ user.usertitle }}{% endif %} + + {% if user.country|lower == 'eu' %}?{% else %}{{ user.country }}{% endif %} +
+ {% else %} + {% for user in page.users[page.page] %} + {# These comment tags are here to prevent the link extending too far + #}
{# + #}{{ user.username }}{# + #}{# + #}{{ user.username }}{# + #}{# + #}
{# + #}
+ {% endfor %} + {% endif %} +
+ {% endif %} + {% if page.users|length > 1 %} +

[ + {% for count,navpage in page.users %} + {{ count + 1 }} + {% endfor %} + ]

+ {% endif %} +
+ {% else %} +
+

Login to view this page!

+ If you actually are logged in something went wrong and you should report this to the administrator.
+ If you aren't logged in please log in or create an account if you don't have one. +
+ {% endif %} +{% include 'global/footer.tpl' %} diff --git a/content/data/yuuno/css/yuuno.css b/content/data/yuuno/css/yuuno.css index 2ce2daa..1b150a7 100644 --- a/content/data/yuuno/css/yuuno.css +++ b/content/data/yuuno/css/yuuno.css @@ -875,7 +875,7 @@ h1.stylised { .membersPage a { color: inherit; } -.membersPage .groupBox, .membersPage .userBox { +.membersPage .userBox { background: linear-gradient(180deg, #C2AFFE, #B19EED) no-repeat scroll left top / cover #C2AFFE; margin: 7px; border-radius: 5px; @@ -885,35 +885,73 @@ h1.stylised { vertical-align: top; transition: box-shadow .2s; } -.membersPage .groupBox { - padding: 5px; - font-size: 15px; - min-width: 150px; - text-shadow: 0 0 1em #888; -} .membersPage .userBox { padding: 10px; line-height: 330%; - width: 200px; - height: 230px; } -.membersPage .groupBox:hover, .membersPage .userBox:hover { +.membersPage .userBox:hover { box-shadow: 0 0 1em #000; cursor: pointer; } -.membersPage .groupBox:active, .membersPage .userBox:active { +.membersPage .userBox:active { box-shadow: 0 0 1.5em #609; } .membersPage .userBox img { - width: 200px; - height: 200px; - display: block; margin: 0 auto; } .membersPage .userBox .userBoxUserName { font-weight: 700; } +.membersPage .boxes .userBox { + width: 200px; + height: 230px; +} +.membersPage .boxes .userBox img { + width: 200px; + height: 200px; + display: block; +} + +.membersPage .rectangles .userBox { + width: 200px; + height: 100px; + text-align: left; +} +.membersPage .rectangles .userBox img { + width: 100px; + height: 100px; + display: inline-block; +} +.membersPage .rectangles .userBox .userBoxUserName { + display: inline-block; + vertical-align: top; + padding: 30px 10px; +} + +.membersPage .list table { + margin: 10px auto; + background: #C2AFFE; + box-shadow: 0 0 3px #9475B2; + border: 1px solid #9475B2; + max-width: 1024px; + width: auto; + border-radius: 3px; + border-spacing: 0; +} +.membersPage .list table td, +.membersPage .list table th { + padding: 4px 8px; +} +.membersPage .list thead th { + border-bottom: 1px solid #9475B2; + background: #A586C4; +} +.membersPage .list tfoot th { + border-top: 1px solid #9475B2; + background: #A586C4; +} + /* Drop Down Styling */ .dropDown { display: inline-block; diff --git a/main/.htaccess b/main/.htaccess index 6b6c40b..906d924 100644 --- a/main/.htaccess +++ b/main/.htaccess @@ -30,6 +30,16 @@ RewriteRule ^news?/?$ news.php RewriteRule ^news/([0-9]+)$ news.php?id=$1 RewriteRule ^news.xml$ news.php?xml +## Members +RewriteRule ^members?/?$ members.php +RewriteRule ^members/([a-z]+)?/?$ members.php?sort=$1 +RewriteRule ^members/([0-9]+)?/?$ members.php?rank=$1 +RewriteRule ^members/p([0-9]+)?/?$ members.php?page=$1 +RewriteRule ^members/([a-z]+)/([0-9]+)?/?$ members.php?sort=$1&rank=$2 +RewriteRule ^members/([0-9]+)/p([0-9]+)?/?$ members.php?rank=$1&page=$2 +RewriteRule ^members/([a-z]+)/p([0-9]+)?/?$ members.php?sort=$1&page=$2 +RewriteRule ^members/([a-z]+)/([0-9]+)/p([0-9]+)?/?$ members.php?sort=$1&rank=$2&page=$3 + ## Profiles RewriteRule ^u$|u/$ profile.php RewriteRule ^u/([A-Za-z0-9_-\s\.]+)?/?$ profile.php?u=$1 diff --git a/main/members.php b/main/members.php new file mode 100644 index 0000000..cd3a4c5 --- /dev/null +++ b/main/members.php @@ -0,0 +1,27 @@ + ($_MEMBERLIST_RANKS = Users::getAllRanks()), + 'active' => ($_MEMBERLIST_ACTIVE = (isset($_GET['rank']) && $_GET['rank'] && array_key_exists($_GET['rank'], $_MEMBERLIST_RANKS) ? $_GET['rank'] : 0)), + 'notfound' => ($_MEMBERLIST_NFOUND = (isset($_GET['rank']) && !array_key_exists($_GET['rank'], $_MEMBERLIST_RANKS) && $_GET['rank'] != 0)), + 'sorts' => ($_MEMBERLIST_SORTS = ['boxes', 'rectangles', 'list']), + 'sort' => isset($_GET['sort']) && $_GET['sort'] && in_array($_GET['sort'], $_MEMBERLIST_SORTS) ? $_GET['sort'] : $_MEMBERLIST_SORTS[0], + 'title' => isset($_GET['rank']) && $_GET['rank'] && !$_MEMBERLIST_NFOUND ? 'Viewing '. $_MEMBERLIST_RANKS[$_GET['rank']]['name'] . ($_MEMBERLIST_RANKS[$_GET['rank']]['multi'] ? 's' : '') : 'Member List', + 'page' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0, + 'users' => array_chunk($_MEMBERLIST_ACTIVE && !$_MEMBERLIST_NFOUND ? Users::getUsersInRank($_MEMBERLIST_ACTIVE) : Users::getAllUsers(), 30, true) + +]; + +// Print page contents +print Templates::render('main/memberlist.tpl', $renderData);