Fixed login
Started building page cleanup Modified code pools Backported layout/blocks/templates 3-step view system Reforged Overview page Moved graphics, added topnav template, fixed number render bug Added BCMath optionnal usage Updated BC Math comparison for capped resources Fixed planet resource production updates Various additions Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
3fd8832b45
commit
f2d4b0f7e2
384 changed files with 2727 additions and 1364 deletions
85
includes/application/code/core/Legacies.php
Normal file
85
includes/application/code/core/Legacies.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
class Legacies
|
||||
{
|
||||
private static $_listeners = array();
|
||||
|
||||
private static $_translators = array();
|
||||
|
||||
public static $request = null;
|
||||
public static $response = null;
|
||||
|
||||
protected static $_now = null;
|
||||
|
||||
public static function registerListener($event, $listener)
|
||||
{
|
||||
if (!isset(self::$_listeners[$event])) {
|
||||
self::$_listeners[$event] = array();
|
||||
}
|
||||
self::$_listeners[$event][] = $listener;
|
||||
}
|
||||
|
||||
public static function clearAllListeners()
|
||||
{
|
||||
self::$_listeners = array();
|
||||
}
|
||||
|
||||
public static function clearEventListeners($event)
|
||||
{
|
||||
if (isset(self::$_listeners[$event])) {
|
||||
self::$_listeners[$event] = array();
|
||||
}
|
||||
}
|
||||
|
||||
public static function dispatchEvent($event, $params)
|
||||
{
|
||||
if (!isset(self::$_listeners[$event])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$eventObject = new Legacies_Core_Event($params);
|
||||
foreach (self::$_listeners[$event] as $listener) {
|
||||
call_user_func($listener, $eventObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSession($namespace)
|
||||
{
|
||||
return Legacies_Core_Model_Session::factory($namespace);
|
||||
}
|
||||
|
||||
public static function getTranslator($locale = 'fr_FR')
|
||||
{
|
||||
if (!isset($translator[$locale])) {
|
||||
$path = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'locale';
|
||||
$translator[$locale] = new Legacies_Core_Model_Translator($path, $locale);
|
||||
}
|
||||
return $translator[$locale];
|
||||
}
|
||||
|
||||
public static function translate($locale, $message, Array $args)
|
||||
{
|
||||
return self::getTranslator($locale)->translateArgs($message, $args);
|
||||
}
|
||||
|
||||
public static function __($message, $_ = null)
|
||||
{
|
||||
$args = func_get_args();
|
||||
array_shift($args);
|
||||
|
||||
return self::getTranslator(self::getLocale())->translate($message, $args);
|
||||
}
|
||||
|
||||
public static function getLocale()
|
||||
{
|
||||
return 'fr_FR';
|
||||
}
|
||||
|
||||
public static function now()
|
||||
{
|
||||
if (self::$_now === null) {
|
||||
self::$_now = time();
|
||||
}
|
||||
return self::$_now;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue