Skip to content
Permalink
Browse files

add wishlist displays to user and dahsboard

  • Loading branch information...
Fauxil-Fox committed Jun 7, 2018
1 parent 2e2f30f commit 0f19f150542ffa8bcac34d6015503593548dc845
Showing with 129 additions and 51 deletions.
  1. +53 −32 Dashboard/index.php
  2. +76 −19 User/index.php
@@ -5,8 +5,9 @@
require_once REAL_ROOTDIR."src/initializer.php";
use \Catalyst\Character\Character;
use \Catalyst\CommissionType\CommissionType;
use \Catalyst\Integrations\SocialMedia;
use \Catalyst\Images\{Folders,Image};
use \Catalyst\Images\Image;
use \Catalyst\Page\{UniversalFunctions, Values};
use \Catalyst\HTTPCode;
use \Catalyst\User\User;
@@ -81,40 +82,60 @@
<div class="divider"></div>
<div class="section">
<h4>Wishlist</h4>
<?php
// $types = $_SESSION["user"]->getWishlistAsObjects();
// $types = array_filter($types, function($type) {
// if (User::isLoggedIn() && $_SESSION["user"]->isNsfw()) {
// return true;
// }
// if (!in_array("MATURE", $type->getAttrs()) && !in_array("EXPLICIT", $type->getAttrs())) {
// return true;
// }
// return in_array("SAFE", $type->getAttrs());
// });
$cards = [];
// foreach ($types as $type) {
// $img = $type->getPrimaryImage();
// $artist = $type->getArtistPage();
// $cards[] = '<div class="col s8 m4 l3">'.$type->getImage()->getCard(
// $type->getName(),
// $artist->getName()."\n".$type->getBlurb(),
// true,
// ROOTDIR."Artist/".$artist->getUrl()."/",
// [
// $artist->getColor(),
// $type->isOpen() ? $type->getBaseCost() : "CLOSED"
// ]
// ).'</div>';
// }
?>
<?php if (count($cards) === 0): ?>
<?php
$ids = $_SESSION["user"]->getWishlistCommissionTypeIds();
$commissionTypes = [];
foreach ($ids as $id) {
$commissionTypes[] = new CommissionType($id);
}
$commissionTypes = array_filter($commissionTypes, function(CommissionType $type) : bool {
// if it shouldn't be visible, don't show it (wishlist can contain these)
if (!$type->isVisible()) {
return false;
}
if (User::isCurrentUserNsfw()) {
return true;
}
// if known SAFE then leave in
if (in_array("SAFE", $type->getAttributes())) {
return true;
}
// if NOT SFW and mature or explicit, say no
if (in_array("MATURE", $type->getAttributes()) || in_array("EXPLICIT", $type->getAttributes())) {
return false;
}
// not explicitly marked any way
return true;
});
$commissionTypes = array_unique($commissionTypes);
$cards = [];
foreach ($commissionTypes as $type) {
$cards[] = '<div class="col s8 m4 l3">'.$type->getImage()->getCard(
$type->getName()." by ".$type->getArtistPage()->getName(),
$type->getBlurb(),
true,
ROOTDIR."Artist/".$type->getArtistPage()->getUrl()."/#ct-".$type->getToken(),
[
$type->getArtistPage()->getColor(),
(
$type->isAcceptingCommissions() ||
$type->isAcceptingTrades() ||
$type->isAcceptingRequests()
) ? $type->getBaseCost() : "CLOSED",
]
).'</div>';
}
?>
<?php if (count($cards) === 0): ?>
<p class="flow-text">Your wishlist is empty!</p>
<?php else: ?>
<?php else: ?>
<div class="horizontal-scrollable-container row">
<?= implode("", $cards) ?>
<?= implode("", $cards) ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
@@ -5,6 +5,7 @@
require_once REAL_ROOTDIR."src/initializer.php";
use \Catalyst\Character\Character;
use \Catalyst\CommissionType\CommissionType;
use \Catalyst\HTTPCode;
use \Catalyst\Integrations\SocialMedia;
use \Catalyst\Message\Message;
@@ -84,27 +85,83 @@
<div class="divider"></div>
<div class="section">
<h4>Characters</h4>
<?php
$characters = Character::getPublicCharactersFromUser($user);
$cards = [];
foreach ($characters as $character) {
$cardContents = $character->getImage()->getCard($character->getName(), "", true, ROOTDIR."Character/View/".$character->getToken()."/", [], false);
if (!empty($cardContents)) {
$cards[] = '<div class="col s8 m4 l3">'.$cardContents.'</div>';
}
}
?>
<?php if (count($cards) === 0): ?>
<p class="flow-text">This user has no public characters</p>
<?php else: ?>
<div class="horizontal-scrollable-container row">
<?= implode("", $cards) ?>
</div>
<?php endif; ?>
<?php
$characters = Character::getPublicCharactersFromUser($user);
$cards = [];
foreach ($characters as $character) {
$cardContents = $character->getImage()->getCard($character->getName(), "", true, ROOTDIR."Character/View/".$character->getToken()."/", [], false);
if (!empty($cardContents)) {
$cards[] = '<div class="col s8 m4 l3">'.$cardContents.'</div>';
}
}
?>
<?php if (count($cards) === 0): ?>
<p class="flow-text">This user has no public characters</p>
<?php else: ?>
<div class="horizontal-scrollable-container row">
<?= implode("", $cards) ?>
</div>
<?php endif; ?>
</div>
<div class="divider"></div>
<!-- <div class="section"> -->
<!-- <h4>Wishlist</h4> -->
<div class="divider"></div>
<div class="section">
<h4>Wishlist</h4>
<?php
$ids = $user->getWishlistCommissionTypeIds();
$commissionTypes = [];
foreach ($ids as $id) {
$commissionTypes[] = new CommissionType($id);
}
$commissionTypes = array_filter($commissionTypes, function(CommissionType $type) : bool {
// if it shouldn't be visible, don't show it (wishlist can contain these)
if (!$type->isVisible()) {
return false;
}
if (User::isCurrentUserNsfw()) {
return true;
}
// if known SAFE then leave in
if (in_array("SAFE", $type->getAttributes())) {
return true;
}
// if NOT SFW and mature or explicit, say no
if (in_array("MATURE", $type->getAttributes()) || in_array("EXPLICIT", $type->getAttributes())) {
return false;
}
// not explicitly marked any way
return true;
});
$commissionTypes = array_unique($commissionTypes);
$cards = [];
foreach ($commissionTypes as $type) {
$cards[] = '<div class="col s8 m4 l3">'.$type->getImage()->getCard(
$type->getName()." by ".$type->getArtistPage()->getName(),
$type->getBlurb(),
true,
ROOTDIR."Artist/".$type->getArtistPage()->getUrl()."/#ct-".$type->getToken(),
[
$type->getArtistPage()->getColor(),
(
$type->isAcceptingCommissions() ||
$type->isAcceptingTrades() ||
$type->isAcceptingRequests()
) ? $type->getBaseCost() : "CLOSED",
]
).'</div>';
}
?>
<?php if (count($cards) === 0): ?>
<p class="flow-text">This user has not added anything to their wishlist!</p>
<?php else: ?>
<div class="horizontal-scrollable-container row">
<?= implode("", $cards) ?>
</div>
<?php endif; ?>
</div>
<?php
endif;
require_once Values::FOOTER_INC;

0 comments on commit 0f19f15

Please sign in to comment.
You can’t perform that action at this time.