Implemented williams frontend design.

This commit is contained in:
Keir 2015-12-16 00:22:55 +00:00
parent 958399be59
commit b5149d2da7
31 changed files with 166 additions and 41 deletions

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 227 KiB

After

Width:  |  Height:  |  Size: 227 KiB

View File

@ -1,5 +1,35 @@
<?php class Message
{
const TYPE_DISPLAY_NAMES = array("Chat", "PM");
const TYPE_CHAT = 0;
const TYPE_PM = 1;
static function init()
{
}
/**
* @param $type
* @return int
*/
public static function getTypeFromString($type)
{
if (strcmp($type, "CHAT") == 0)
{
return self::TYPE_CHAT;
}
else if (strcmp($type, "PM") == 0)
{
return self::TYPE_PM;
}
else
{
return -1;
}
}
/** @var Player */
private $sender;
@ -9,7 +39,7 @@
/** @var DateTime */
private $timestamp;
/** @var String */
/** @var Int */
private $type;
/** @var String */
@ -20,7 +50,7 @@
* @param Player $sender
* @param Player[] $recipients
* @param DateTime $dateTime
* @param String $type
* @param Int $type
* @param Message
*/
function Message($sender, $recipients, $dateTime, $type, $message)
@ -56,6 +86,9 @@
return $this->timestamp;
}
/**
* @return Int
*/
public function getType()
{
return $this->type;

View File

@ -6,7 +6,7 @@
/** @var String */
private $serverName;
/** @var String */
/** @var Player */
private $suspect;
/** @var SplObjectStorage */
@ -16,7 +16,7 @@
* Report constructor.
* @param Int $id
* @param String $serverName
* @param String $suspect
* @param Player $suspect
* @param SplObjectStorage $reporters
*/
function Report($id, $serverName, $suspect, $reporters)
@ -44,7 +44,7 @@
}
/**
* @return String
* @return Player
*/
public function getSuspect()
{

View File

@ -5,7 +5,7 @@ require_once('report.php');
require_once('message.php');
require_once('player.php');
$dataDir = 'data/';
const dataDir = 'data/';
// In Java this is "DateTimeFormatter.ISO_LOCAL_DATE_TIME"
$jsonDateTimeFormat = 'Y-m-d\TH:i:s';
@ -17,7 +17,7 @@ if (!isset($_GET['identifier']) || empty($_GET['identifier']))
}
$identifier = removeBadCharacters($_GET['identifier']); // prevents escaping
$filePath = $dataDir . $identifier . '.json';
$filePath = dataDir . $identifier . '.json';
if (!file_exists($filePath))
{
@ -37,30 +37,6 @@ function toDataArray($filename)
return json_decode(file_get_contents($filename), true);
}
/**
* @param Snapshot $snapshot
*/
function displayMessages($snapshot)
{
echo '<p>';
foreach ($snapshot->getMessages() as $message) {
echo getMessageHTML($message) . "<br />\n";
}
echo '</p>';
}
/**
* @param Message $message
* @return string
*/
function getMessageHTML($message)
{
$sender = $message->getSender();
return '[' . $message->getType() . '] <span data-player-uuid="' . $sender->getUUID() . '">' . $sender->getUsername() . '</span> - ' . $message->getMessage();
}
/**
* @param String $identifier
* @param array $snapshotData Snapshot data array.
@ -118,7 +94,7 @@ function getMessage($players, $messageData, $timezone)
$sender = getPlayer($players, $messageData['sender']);
$recipients = getPlayersFromUUIDs($players, $messageData['recipients']);
$dateTime = parseDateTime($messageData['time'], $timezone);
$type = $messageData['type'];
$type = Message::getTypeFromString($messageData['type']);
$message = $messageData['message'];
return new Message($sender, $recipients, $dateTime, $type, $message);
@ -213,14 +189,129 @@ function removeBadCharacters($input)
return preg_replace('/[^A-Za-z0-9_\-]/', '_', $input);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Snapshot for Report #<?php echo $report->getId() ?></title>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/tiger.css">
<link href='https://fonts.googleapis.com/css?family=Crete+Round' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<title>Report #<?php $report->getId() ?> &middot; Mineplex</title>
<script>
$("#test").click(function (){
alert("test!");
});
</script>
</head>
<body>
<?php
displayMessages($snapshot);
?>
<script type="text/javascript" src="main.js"></script>
<div id="wrapper">
<div id="header">
<img src="img/logo.png" height="70px" width="70px" />
<h1>Report System</h1>
<!-- <h2><i class="fa fa-camera"></i>&nbsp;&nbsp; Chat Snap</h2> -->
</div>
<div id="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter a chat snap report ID...">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button"><i class="fa fa-search"></i> Search</button>
</span>
</div>
</div>
<div id="content">
<div>
<hr>
<h2 style="font-family: 'Oswald', sans-serif; text-align: center;">
Report #<?= $report->getId() ?>
</h2>
<hr>
</div>
<div class="row">
<div id="chat" class="col-lg-7">
<h4><i class="fa fa-comments"></i>&nbsp;&nbsp;&nbsp;Chat Log</h4>
<hr>
<div id="log" class="text-muted ">
<?php
$messages = $snapshot->getMessages();
foreach($messages as $message):
$typeId = $message->getType();
$typeDisplayName = Message::TYPE_DISPLAY_NAMES[$typeId];
$isPM = strcmp($typeId, Message::TYPE_PM) == 0;
// If this is a PM, then the "-> <recipient>" suffix will be applied.
$involved = $message->getSender()->getUsername() . ($isPM ? " -> " . $message->getRecipients()[0]->getUsername() : "");
?>
<span class="label <?php if($isPM) echo "label-primary chat pm"; else echo "label-info chat"; ?>" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
<span class="black"><?= $involved; ?>:</span> <?= $message->getMessage(); ?>
<?php if ($message != end($messages)){ // Don't break on the last element ?>
<br>
<?php } ?>
<?php endforeach; ?>
</div>
</div>
<div id="users" class="col-lg-5">
<h4><i class="fa fa-info-circle"></i>&nbsp;&nbsp;&nbsp;Information</h4>
<hr>
<div class="row">
<div class="col-lg-1">
<i class="fa fa-calendar"></i><br>
<i class="fa fa-clock-o"></i><br>
<i class="fa fa-user-plus"></i><br>
<i class="fa fa-user-times"></i><br>
<i class="fa fa-gavel"></i><br>
</div>
<div class="col-lg-11">
<?php
$dateTime = $snapshot->getTimeGenerated();
$date = $dateTime->format('n/j/y');
$time = $dateTime->format('g:i A');
$reporters = array();
foreach ($report->getReporters() as $reporter)
{
$reporters[count($reporters)] = $reporter->getUsername();
}
$reportersString = implode(", ", $reporters);
?>
<span class="label label-pill label-default"><?= $date ?></span><br>
<span class="label label-pill label-default"><?= $time ?></span><br>
<span class="label label-pill label-success">Reported by <?= $reportersString ?></span><br>
<span class="label label-pill label-danger">Suspect is <?= $report->getSuspect()->getUsername() ?></span><br>
<span class="label label-pill label-warning">Staff Member assigned is TODO</span><br><!-- TODO -->
</div>
</div>
<br>
<h4><i class="fa fa-users"></i>&nbsp;&nbsp;&nbsp;Users</h4>
<hr>
<?php foreach($snapshot->getPlayers() as $player): ?>
<img src="http://cravatar.eu/avatar/<?= $player->getUUID() ?>/55.png" class="pull-left" />
&nbsp;&nbsp;<b class="name"><?= $player->getUsername() ?></b> <span class="label label-staff name">TODO</span><br> <!-- TODO -->
&nbsp;<code style="font-size: 11px;"><?= $player->getUUID() ?></code>
<br><br>
<?php endforeach; ?>
</div>
</div>
</div>
<div id="footer">
<a href="http://www.mineplex.com"><img src="img/logo-full.png" width="225px" /></a>
<div class="btn-group pull-right indent-link" style="font-family: 'Crete Round', serif; padding-top: 10px;">
<a href="http://www.mineplex.com" class="btn btn-link btn-small text-muted">Home</a>
<a href="http://www.mineplex.com/shop/" class="btn btn-link btn-small text-muted">Shop</a>
<a href="http://www.mineplex.com/forums/" class="btn btn-link btn-small text-muted">Forums</a>
<a href="http://www.mineplex.com/supporthub/" class="btn btn-link btn-small text-muted">Support</a>
</div>
</div>
</div>
</body>
</html>

View File

@ -5,5 +5,6 @@ package mineplex.core.chatsnap;
*/
public enum MessageType
{
CHAT, PRIVATE;
CHAT,
PM;
}

View File

@ -36,7 +36,7 @@ public class Snapshot implements Comparable<Snapshot>
public Snapshot(UUID sender, UUID recipient, String message)
{
this(MessageType.PRIVATE, sender, Collections.singletonList(recipient), message, LocalDateTime.now());
this(MessageType.PM, sender, Collections.singletonList(recipient), message, LocalDateTime.now());
}
public Snapshot(UUID sender, Collection<UUID> recipients, String message)
@ -52,9 +52,9 @@ public class Snapshot implements Comparable<Snapshot>
_message = checkNotNull(message);
_time = checkNotNull(time);
if (messageType == MessageType.PRIVATE && recipients.size() > 1)
if (messageType == MessageType.PM && recipients.size() > 1)
{
throw new IllegalArgumentException("Snapshot type PRIVATE may not have more than 1 recipient.");
throw new IllegalArgumentException("Snapshot type PM may not have more than 1 recipient.");
}
}