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

Avoid caching of old versions of JS-File

This commit is contained in:
Tim Düsterhus 2011-11-27 13:33:44 +01:00
parent 8114472189
commit 0a1c65db17
2 changed files with 26 additions and 4 deletions

View File

@ -1,7 +1,8 @@
<?php <?php
namespace wcf\page; namespace wcf\page;
use \wcf\system\WCF;
use \wcf\data\chat; use \wcf\data\chat;
use \wcf\system\cache\CacheHandler;
use \wcf\system\WCF;
/** /**
* Shows the chat-interface * Shows the chat-interface
@ -13,6 +14,7 @@
* @subpackage page * @subpackage page
*/ */
class ChatPage extends AbstractPage { class ChatPage extends AbstractPage {
public $chatVersion = '';
//public $neededModules = array('CHAT_ACTIVE'); //public $neededModules = array('CHAT_ACTIVE');
//public $neededPermissions = array('user.chat.canEnter'); //public $neededPermissions = array('user.chat.canEnter');
public $room = null; public $room = null;
@ -27,6 +29,7 @@ public function assignVariables() {
parent::assignVariables(); parent::assignVariables();
WCF::getTPL()->assign(array( WCF::getTPL()->assign(array(
'chatVersion' => $this->chatVersion,
'room' => $this->room, 'room' => $this->room,
'roomID' => $this->roomID, 'roomID' => $this->roomID,
'rooms' => $this->rooms, 'rooms' => $this->rooms,
@ -34,6 +37,20 @@ public function assignVariables() {
)); ));
} }
public function readChatVersion() {
CacheHandler::getInstance()->addResource(
'packages',
WCF_DIR.'cache/cache.packages.php',
'wcf\system\cache\builder\PackageCacheBuilder'
);
$packages = CacheHandler::getInstance()->get('packages');
foreach ($packages as $package) {
if ($package->package != 'timwolla.wcf.chat') continue;
$this->chatVersion = $package->packageVersion;
break;
}
}
/** /**
* @see \wcf\page\IPage::readData() * @see \wcf\page\IPage::readData()
*/ */
@ -69,8 +86,8 @@ public function readData() {
'color2' => 0x00FF00 'color2' => 0x00FF00
)); ));
$smilies = \wcf\data\smiley\SmileyCache::getInstance()->getSmilies(); $this->readDefaultSmileys();
$this->smilies = $smilies[null]; $this->readChatVersion();
} }
/** /**
@ -82,6 +99,11 @@ public function readParameters() {
if (isset($_GET['id'])) $this->roomID = (int) $_GET['id']; if (isset($_GET['id'])) $this->roomID = (int) $_GET['id'];
} }
public function readDefaultSmileys() {
$smilies = \wcf\data\smiley\SmileyCache::getInstance()->getSmilies();
$this->smilies = $smilies[null];
}
/** /**
* @see \wcf\page\IPage::show() * @see \wcf\page\IPage::show()
*/ */

View File

@ -1 +1 @@
{if $templateName == 'chat'}<script type="text/javascript" src="{@RELATIVE_WCF_DIR}js/TimWolla.WCF.Chat.js"></script>{/if} {if $templateName == 'chat'}<script type="text/javascript" src="{@RELATIVE_WCF_DIR}js/TimWolla.WCF.Chat.js{if $chatVersion|isset}?version={$chatVersion}{/if}"></script>{/if}