1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Adding PageMenuItem for chat

This commit is contained in:
Tim Düsterhus 2011-11-27 12:46:10 +01:00
parent c92e1079c3
commit 5c72cd52be
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace wcf\system\menu\page;
/**
* PageMenuItemProvider for chat.
*
* @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat
* @subpackage system.menu.page
*/
class ChatPageMenuItemProvider extends DefaultPageMenuItemProvider {
/**
* Hides the button when there is no valid room
*
* @see wcf\system\menu\page\PageMenuItemProvider::isVisible()
*/
public function isVisible() {
try {
\wcf\data\chat\room\ChatRoom::getCache()->seek(0);
return true;
}
catch (\OutOfBoundsException $e) {
return false;
}
}
}

10
pagemenu.xml Normal file
View File

@ -0,0 +1,10 @@
<?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/pagemnu.xsd">
<import>
<pagemenuitem name="wcf.header.menu.chat">
<link>index.php/Chat</link>
<position>header</position>
<classname>wcf\system\menu\page\ChatPageMenuItemProvider</classname>
</pagemenuitem>
</import>
</data>