Add dashboard box with online-list

This commit is contained in:
Tim Düsterhus 2013-01-31 16:02:14 +01:00
parent d734d99c9f
commit 5a5a2c9ad1
4 changed files with 72 additions and 2 deletions

9
dashboardBox.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/dashboardBox.xsd">
<import>
<dashboardbox name="be.bastelstu.chat.onlineList">
<classname><![CDATA[chat\system\dashboard\box\OnlineListDashboardBox]]></classname>
<boxtype>content</boxtype>
</dashboardbox>
</import>
</data>

View File

@ -0,0 +1,46 @@
<?php
namespace chat\system\dashboard\box;
use chat\data;
/**
* Dashboard box that shows chatters.
*
* @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.chat
* @subpackage system.dashboard.box
*/
class OnlineListDashboardBox extends \wcf\system\dashboard\box\AbstractContentDashboardBox {
/**
* all rooms in the current installation
* @var array<\chat\data\room\Room>
*/
public $rooms = array();
/**
* @see wcf\system\dashboard\box\IDashboardBox::init()
*/
public function init(\wcf\data\dashboard\box\DashboardBox $box, \wcf\page\IPage $page) {
parent::init($box, $page);
$this->rooms = data\room\Room::getCache();
foreach ($this->rooms as $key => $room) {
if (!$room->canEnter()) unset($this->rooms[$key]);
}
}
/**
* @see wcf\system\dashboard\box\AbstractContentDashboardBox::render()
*/
protected function render() {
if (count($this->rooms)) {
\wcf\system\WCF::getTPL()->assign(array(
'rooms' => $this->rooms
));
return \wcf\system\WCF::getTPL()->fetch('dashboardBoxOnlineList', 'chat');
}
}
}

View File

@ -36,7 +36,8 @@
<instruction type="acpMenu">acpMenu.xml</instruction>
<instruction type="userGroupOption">userGroupOption.xml</instruction>
<instruction type="cronjob">cronjob.xml</instruction>
<instruction type="script">acp/be.bastelstu.chat.install.php</instruction>
<instruction type="dashboardBox">dashboardBox.xml</instruction>
<instruction type="script" run="standalone">acp/be.bastelstu.chat.install.php</instruction>
</instructions>
<instructions type="update" fromversion="3.0.0 Alpha *">
@ -53,6 +54,7 @@
<instruction type="acpMenu">acpMenu.xml</instruction>
<instruction type="userGroupOption">userGroupOption.xml</instruction>
<instruction type="cronjob">cronjob.xml</instruction>
<instruction type="script">acp/be.bastelstu.chat.update.php</instruction>
<instruction type="dashboardBox">dashboardBox.xml</instruction>
<instruction type="script" run="standalone">acp/be.bastelstu.chat.update.php</instruction>
</instructions>
</package>

View File

@ -0,0 +1,13 @@
<header class="boxHeadline boxSubHeadline">
<hgroup>
<h1>{lang}chat.header.menu.chat{/lang}</h1>
</hgroup>
</header>
<div class="container marginTop">
<ul>
{foreach from=$rooms item='room'}
<li><strong>{$room}</strong>: <ul class="dataList">{implode from=$room->getUsers() item='user'}<li><a href="{link controller='User' object=$user}{/link}" class="userLink" data-user-id="{$user->userID}">{$user}</a></li>{/implode}</ul>
{/foreach}
</ul>
</div>