1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Remove proxying of pages, remove deliver copyright background in own request

This commit is contained in:
Tim Düsterhus 2013-01-27 22:41:36 +01:00
parent 71936e14d6
commit 98943f9309
10 changed files with 69 additions and 169 deletions

View File

@ -43,23 +43,6 @@ class LeaveAction extends \wcf\action\AbstractAction {
*/ */
public $userData = array(); public $userData = array();
/**
* shortcut for the active request
* @see wcf\system\request\Request::getRequestObject()
*/
public $request = null;
/**
* Disallows direct access.
*
* @see wcf\page\IPage::__run()
*/
public function __run() {
if (($this->request = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()) === $this) throw new IllegalLinkException();
parent::__run();
}
/** /**
* @see \wcf\action\IAction::execute() * @see \wcf\action\IAction::execute()
*/ */

View File

@ -162,30 +162,14 @@ public function readParameters() {
$this->request = $this; $this->request = $this;
switch ($this->action) { switch ($this->action) {
case 'Message':
$this->request = new ChatMessagePage();
$this->request->__run();
exit;
case 'Log': case 'Log':
$this->request = new LogPage(); $this->request = new LogPage();
$this->request->__run(); $this->request->__run();
exit; exit;
case 'RefreshRoomList':
$this->request = new RoomListPage();
$this->request->__run();
exit;
case 'Send': case 'Send':
$this->request = new \chat\form\ChatForm(); $this->request = new \chat\form\ChatForm();
$this->request->__run(); $this->request->__run();
exit; exit;
case 'Leave':
$this->request = new \chat\action\LeaveAction();
$this->request->__run();
exit;
case 'Copyright':
$this->request = new CopyrightPage();
$this->request->__run();
exit;
} }
if (isset($_REQUEST['id'])) $this->roomID = (int) $_REQUEST['id']; if (isset($_REQUEST['id'])) $this->roomID = (int) $_REQUEST['id'];

View File

@ -13,6 +13,11 @@
* @subpackage page * @subpackage page
*/ */
class CopyrightPage extends \wcf\page\AbstractPage { class CopyrightPage extends \wcf\page\AbstractPage {
/**
* @see wcf\page\AbstractPage::$loginRequired
*/
public $loginRequired = true;
/** /**
* @see \wcf\page\AbstractPage::$neededModules * @see \wcf\page\AbstractPage::$neededModules
*/ */
@ -25,61 +30,26 @@ class CopyrightPage extends \wcf\page\AbstractPage {
/** /**
* shortcut for the active request * shortcut for the active request
* @see wcf\system\request\Request::getRequestObject() * @see \wcf\system\request\Request::getRequestObject()
*/ */
public $request = null; public $request = null;
/**
* @see \wcf\page\AbstractPage::$templateName
*/
public $templateName = '__copyright'; public $templateName = '__copyright';
/** /**
* Disallows direct access. * @see \wcf\page\IPage::assignVariables()
*
* @see wcf\page\IPage::__run()
*/ */
public function __run() { public function assignVariables() {
if (($this->request = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()) === $this) throw new IllegalLinkException(); parent::assignVariables();
parent::__run();
}
/**
* @see \wcf\page\IPage::readParameters()
*/
public function readParameters() {
// ###
// ## ##
// # #
// # ##### #
// # # # #
// # # * * # #
// # # # #
// # # # #
// # ### #
// # #
// #######
// # # # #
// # # # #
// # # # #
if (isset($_GET['sheep'])) $this->useTemplate = false;
}
/**
* @see \wcf\page\IPage::show()
*/
public function show() {
// guests are not supported
if (!WCF::getUser()->userID) {
throw new \wcf\system\exception\PermissionDeniedException();
}
parent::show();
if ($this->useTemplate) exit;
@header('Content-type: image/png');
\wcf\util\HeaderUtil::sendNoCacheHeaders();
$images = explode("\n\n", file_get_contents(__FILE__, null, null, __COMPILER_HALT_OFFSET__+2)); $images = explode("\n\n", file_get_contents(__FILE__, null, null, __COMPILER_HALT_OFFSET__+2));
echo base64_decode($images[array_rand($images)]);
exit; WCF::getTPL()->assign(array(
'background' => str_replace("\n", '', $images[array_rand($images)])
));
} }
} }
// @codingStandardsIgnoreStart // @codingStandardsIgnoreStart

View File

@ -13,7 +13,7 @@
* @package be.bastelstu.chat * @package be.bastelstu.chat
* @subpackage page * @subpackage page
*/ */
class ChatMessagePage extends \wcf\page\AbstractPage { class NewMessagesPage extends \wcf\page\AbstractPage {
/** /**
* @see wcf\page\AbstractPage::$loginRequired * @see wcf\page\AbstractPage::$loginRequired
*/ */
@ -55,23 +55,6 @@ class ChatMessagePage extends \wcf\page\AbstractPage {
*/ */
public $useTemplate = false; public $useTemplate = false;
/**
* shortcut for the active request
* @see wcf\system\request\Request::getRequestObject()
*/
public $request = null;
/**
* Disallows direct access.
*
* @see wcf\page\IPage::__run()
*/
public function __run() {
if (($this->request = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()) === $this) throw new IllegalLinkException();
parent::__run();
}
/** /**
* @see \wcf\page\Page::readData() * @see \wcf\page\Page::readData()
*/ */

View File

@ -6,7 +6,7 @@
use \wcf\system\WCF; use \wcf\system\WCF;
/** /**
* Outputs roomlist * Outputs roomlist.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2013 Tim Düsterhus * @copyright 2010-2013 Tim Düsterhus
@ -47,23 +47,6 @@ class RoomListPage extends \wcf\page\AbstractPage {
*/ */
public $useTemplate = false; public $useTemplate = false;
/**
* shortcut for the active request
* @see wcf\system\request\Request::getRequestObject()
*/
public $request = null;
/**
* Disallows direct access.
*
* @see wcf\page\IPage::__run()
*/
public function __run() {
if (($this->request = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()) === $this) throw new IllegalLinkException();
parent::__run();
}
/** /**
* @see \wcf\page\IPage::readData() * @see \wcf\page\IPage::readData()
*/ */

View File

@ -18,7 +18,7 @@ public function execute($eventObj, $className, $eventName) {
$route = new \wcf\system\request\Route('chatAction'); $route = new \wcf\system\request\Route('chatAction');
$route->setSchema('/{controller}/{action}/{id}'); $route->setSchema('/{controller}/{action}/{id}');
$route->setParameterOption('controller', null, 'Chat'); $route->setParameterOption('controller', null, 'Chat');
$route->setParameterOption('action', null, '(Message|Log|Send|RefreshRoomList|Copyright|Leave)'); $route->setParameterOption('action', null, '(Log|Send)');
$route->setParameterOption('id', null, '\d+', true); $route->setParameterOption('id', null, '\d+', true);
$eventObj->addRoute($route); $eventObj->addRoute($route);
} }

View File

@ -2,11 +2,10 @@
* Styles for Tims Chat * Styles for Tims Chat
* *
* @author Tim Düsterhus, Maximilian Mader * @author Tim Düsterhus, Maximilian Mader
* @copyright 2010-2012 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> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package be.bastelstu.wcf.chat * @package be.bastelstu.wcf.chat
*/ */
#tplChat { #tplChat {
#content { #content {
#timsChatRoomContent { #timsChatRoomContent {
@ -301,10 +300,10 @@
.textShadow(@wcfContentBackgroundColor); .textShadow(@wcfContentBackgroundColor);
} }
#timsChatCopyrightDialog { #timsChatCopyrightDialog > div {
background-position: right center; background-position: right center;
background-repeat: no-repeat; background-repeat: no-repeat;
min-height: 50%; min-height: 150px;
} }
.badgeBG(@backgroundColor) when (lightness(@backgroundColor) < 50%) { .badgeBG(@backgroundColor) when (lightness(@backgroundColor) < 50%) {

View File

@ -1,47 +1,49 @@
{if $__chat->isActiveApplication()} {if $__chat->isActiveApplication()}
{if $templateName != '__copyright'}<address id="timsChatCopyright" class="copyright marginTop">{lang}chat.general.copyright{/lang}</address> {if $templateName != '__copyright'}<address id="timsChatCopyright" class="copyright marginTop">{lang}chat.general.copyright{/lang}</address>
{elseif $templateName == '__copyright'} {elseif $templateName == '__copyright'}
<dl> <div style="background-image: url('data:image/png;base64,{$background}');">
<dt>{lang}chat.general.copyright.leader{/lang}</dt> <dl>
<dd> <dt>{lang}chat.general.copyright.leader{/lang}</dt>
<ul> <dd>
<li><a href="http://tims.bastelstu.be/">Tim Düsterhus</a></li> <ul>
</ul> <li><a href="http://tims.bastelstu.be/">Tim Düsterhus</a></li>
</dd> </ul>
</dl> </dd>
<dl> </dl>
<dt>{lang}chat.general.copyright.developer{/lang}</dt> <dl>
<dd> <dt>{lang}chat.general.copyright.developer{/lang}</dt>
<ul> <dd>
<li><a href="http://tims.bastelstu.be/">Tim Düsterhus</a></li> <ul>
<li><a href="https://github.com/max-m">Maximilian Mader</a></li> <li><a href="http://tims.bastelstu.be/">Tim Düsterhus</a></li>
</ul> <li><a href="https://github.com/max-m">Maximilian Mader</a></li>
</dd> </ul>
</dl> </dd>
<dl> </dl>
<dt>{lang}chat.general.copyright.graphics{/lang}</dt> <dl>
<dd> <dt>{lang}chat.general.copyright.graphics{/lang}</dt>
<ul> <dd>
<li><a href="http://www.cls-design.com/">Tom</a></li> <ul>
</ul> <li><a href="http://www.cls-design.com/">Tom</a></li>
</dd> </ul>
</dl> </dd>
{*<dl> </dl>
<dt>{lang}chat.general.copyright.translation{/lang}</dt> {*<dl>
<dd> <dt>{lang}chat.general.copyright.translation{/lang}</dt>
<dd>
</dd> </dd>
</dl>*} </dl>*}
<dl> <dl>
<dt>{lang}chat.general.copyright.thanks{/lang}</dt> <dt>{lang}chat.general.copyright.thanks{/lang}</dt>
<dd> <dd>
<ul> <ul>
<li><a href="http://www.wbbaddons.de/user/2020-noone/">-noone-</a></li> <li><a href="http://www.wbbaddons.de/user/2020-noone/">-noone-</a></li>
<li>Gabi</li> <li>Gabi</li>
<li><a href="https://github.com/Leon-">Stefan Hahn</a></li> <li><a href="https://github.com/Leon-">Stefan Hahn</a></li>
<li><a href="http://www.wbbaddons.de">Martin Schwendowius</a></li> <li><a href="http://www.wbbaddons.de">Martin Schwendowius</a></li>
</ul> </ul>
</dd> </dd>
</dl> </dl>
</div>
{/if} {/if}
{/if} {/if}

View File

@ -27,8 +27,8 @@
chat = new be.bastelstu.Chat({ chat = new be.bastelstu.Chat({
reloadTime: {@CHAT_RELOADTIME}, reloadTime: {@CHAT_RELOADTIME},
unloadURL: '{link controller="Chat" action="Leave"}{/link}', unloadURL: '{link application="chat" controller="Leave"}{/link}',
messageURL: '{link controller="Chat" action="Message"}{/link}', messageURL: '{link application="chat" controller="NewMessages"}{/link}',
socketIOPath: '{@CHAT_SOCKET_IO_PATH|encodeJS}' socketIOPath: '{@CHAT_SOCKET_IO_PATH|encodeJS}'
}, (new WCF.Template('{ldelim}$title} - {'chat.general.title'|language|encodeJS} - {PAGE_TITLE|language|encodeJS}')).compile(), (new WCF.Template('{@$messageTemplate|encodeJS}')).compile()); }, (new WCF.Template('{ldelim}$title} - {'chat.general.title'|language|encodeJS} - {PAGE_TITLE|language|encodeJS}')).compile(), (new WCF.Template('{@$messageTemplate|encodeJS}')).compile());
{event name='didInit'} {event name='didInit'}
@ -44,7 +44,7 @@
$('#timsChatCopyright').click(function (event) { $('#timsChatCopyright').click(function (event) {
event.preventDefault(); event.preventDefault();
if (!$.wcfIsset('timsChatCopyrightDialog')) $('<fieldset id="timsChatCopyrightDialog"></fieldset>').appendTo('body'); if (!$.wcfIsset('timsChatCopyrightDialog')) $('<fieldset id="timsChatCopyrightDialog"></fieldset>').appendTo('body');
$('#timsChatCopyrightDialog').load('{link application='chat' controller='Chat' action='Copyright'}{/link}', function() { $('#timsChatCopyrightDialog').load('{link application='chat' controller='Copyright'}{/link}', function() {
WCF.showDialog('timsChatCopyrightDialog', { title: 'Tims Chat{if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}' }); WCF.showDialog('timsChatCopyrightDialog', { title: 'Tims Chat{if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}' });
}); });
}); });
@ -60,10 +60,6 @@
</script> </script>
<style type="text/css"> <style type="text/css">
#timsChatCopyrightDialog {
background-image: url("{link application='chat' controller='Chat' action='Copyright' sheep=1}{/link}");
}
{assign var='type' value='\chat\data\message\Message::TYPE_'} {assign var='type' value='\chat\data\message\Message::TYPE_'}
.timsChatMessage{$type|concat:'JOIN'|constant}, .timsChatMessage{$type|concat:'LEAVE'|constant}, .timsChatMessage{$type|concat:'JOIN'|constant}, .timsChatMessage{$type|concat:'LEAVE'|constant},
.timsChatMessage{$type|concat:'INFORMATION'|constant}, .timsChatMessage{$type|concat:'ERROR'|constant} { .timsChatMessage{$type|concat:'INFORMATION'|constant}, .timsChatMessage{$type|concat:'ERROR'|constant} {

View File

@ -2,7 +2,7 @@
<nav class="timsChatSidebarTabs"> <nav class="timsChatSidebarTabs">
<ul> <ul>
<li id="toggleUsers" class="active"><a title="{lang}chat.general.users{/lang}">{lang}chat.general.users{/lang} <span class="badge">0</span></a></li> <li id="toggleUsers" class="active"><a title="{lang}chat.general.users{/lang}">{lang}chat.general.users{/lang} <span class="badge">0</span></a></li>
<li id="toggleRooms"><a title="{lang}chat.general.rooms{/lang}" data-refresh-url="{link application='chat' controller="Chat" action="RefreshRoomList"}{/link}">{lang}chat.general.rooms{/lang} <span class="badge">{#$rooms|count}</span><span class="ajaxLoad icon icon32 icon-spinner"></span></a></li> <li id="toggleRooms"><a title="{lang}chat.general.rooms{/lang}" data-refresh-url="{link application='chat' controller='RoomList'}{/link}">{lang}chat.general.rooms{/lang} <span class="badge">{#$rooms|count}</span><span class="ajaxLoad icon icon32 icon-spinner"></span></a></li>
</ul> </ul>
</nav> </nav>