Initial commit
This commit is contained in:
commit
d7619777af
915 changed files with 59386 additions and 0 deletions
74
includes/application/code/community/Legacies.php
Normal file
74
includes/application/code/community/Legacies.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
class Legacies
|
||||
{
|
||||
private static $_listeners = array();
|
||||
|
||||
private static $_translators = array();
|
||||
|
||||
public static $request = null;
|
||||
public static $response = 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;
|
||||
}
|
||||
|
||||
foreach (self::$_listeners[$event] as $listener) {
|
||||
call_user_func($listener, $params);
|
||||
}
|
||||
}
|
||||
|
||||
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 vsprintf(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';
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue