Updated install and fixed bugs

Added session messages display
Fixed field and validator loading.
Updated form validation
Updated root config management
Muted error reporting in file evaluation
Added menu updates
Fixed galaxy data access error
Fixed config bug
Added HTTP request method checks
Added Form manager
Fixed core bugs

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2011-11-08 08:56:53 +01:00
commit 9636b4bb00
69 changed files with 2434 additions and 789 deletions

View file

@ -197,7 +197,7 @@ class Wootook
return self::$_defaultLocale;
}
public function getPreferredLocale($availableLocales = array())
public static function getPreferredLocale($availableLocales = array())
{
if (empty($availableLocales)) {
return self::getDefaultLocale();
@ -255,6 +255,9 @@ class Wootook
return self::$_now;
}
/**
* @return Wootook_Core_Controller_Request_Http
*/
public static function getRequest()
{
if (self::$_request === null) {
@ -268,6 +271,9 @@ class Wootook
self::$_request = $request;
}
/**
* @return Wootook_Core_Controller_Response_Http
*/
public static function getResponse()
{
if (self::$_response === null) {
@ -281,11 +287,20 @@ class Wootook
self::$_response = $response;
}
public static function getConfig($path = null)
private static function _loadConfig()
{
if (self::$_config === null) {
self::$_config = include ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php';
if (!is_array(self::$_config)) {
self::$_config = array();
}
}
}
public static function getConfig($path = null)
{
self::_loadConfig();
if ($path === null || !is_string($path)) {
return self::$_config;
@ -300,6 +315,25 @@ class Wootook
return $config;
}
public static function setConfig($path = null, $value)
{
self::_loadConfig();
if ($path === null || !is_string($path)) {
return self::$_config;
}
$config = &self::$_config;
foreach (explode('/', $path) as $chunk) {
if (!isset($config[$chunk])) {
$config[$chunk] = array();
}
$config = &$config[$chunk];
}
$config = $value;
return true;
}
public static function getBaseUrl()
{
return self::getConfig('global/web/base_url');
@ -333,10 +367,13 @@ class Wootook
return false;
}
Wootook_Core_ErrorProfiler::sleep();
if (($fp = @fopen($path, 'r', true)) === false) {
Wootook_Core_ErrorProfiler::wakeup();
return false;
}
fclose($fp);
Wootook_Core_ErrorProfiler::wakeup();
return true;
}
}

View file

@ -0,0 +1,43 @@
<?php
class Wootook_Core_Block_Messages
extends Wootook_Core_Block_Template
{
protected $_storages = array();
public function prepareMessages($namespace)
{
$this->_storages[] = $namespace;
}
public function renderGroupedHtml()
{
$messages = array();
foreach ($this->_storages as $namespace) {
$session = Wootook::getSession($namespace);
foreach ($session->getData('messages') as $messageLevel => $messageList) {
if (!isset($messages[$messageLevel])) {
$messages[$messageLevel] = $messageList;
} else {
$messages[$messageLevel] += $messageList;
}
}
}
rsort($messages, SORT_NUMERIC);
$output = '<div class="messages">';
foreach ($messages as $messageLevel => $messageList) {
$output .= "<ul class=\"{$messageLevel}\">";
foreach ($messageList as $message) {
$output .= "<li>{$message}</li>";
}
$output .= '</ul>';
}
$output .= '</div>';
return $output;
}
}

View file

@ -84,6 +84,40 @@ class Wootook_Core_Controller_Request_Http
return $_SERVER[$key];
}
public function getAllQueryData()
{
return $_GET;
}
public function getAllFilesData()
{
return $_FILES;
}
public function getAllCookieData()
{
$data = array();
foreach ($_COOKIE as $key => $value) {
$data[$key] = unserialize(stripslashes($value));
}
return $data;
}
public function getAllRawCookieData()
{
return $_COOKIE;
}
public function getAllPostData()
{
return $_POST;
}
public function getAllServerData()
{
return $_SERVER;
}
public function isPost()
{
if (strtoupper($this->getServer('REQUEST_METHOD')) == 'POST') {
@ -92,6 +126,22 @@ class Wootook_Core_Controller_Request_Http
return false;
}
public function isPut()
{
if (strtoupper($this->getServer('REQUEST_METHOD')) == 'PUT') {
return true;
}
return false;
}
public function isHead()
{
if (strtoupper($this->getServer('REQUEST_METHOD')) == 'HEAD') {
return true;
}
return false;
}
public function isGet()
{
if (strtoupper($this->getServer('REQUEST_METHOD')) == 'GET') {

View file

@ -81,7 +81,7 @@ class Wootook_Core_Controller_Response_Http
return $this;
}
public function setRawHeader($name, $value)
public function setRawHeader($value)
{
if (!isset($this->_data['raw_headers']) || !is_array($this->_data['raw_headers'])) {
$this->clearRawHeaders();

View file

@ -0,0 +1,175 @@
<?php
class Wootook_Core_Form
{
protected $_fields = array();
protected $_request = null;
/**
*
* Field class loader
* @var Wootook_Core_Form_FieldLoader
*/
protected $_fieldLoader = null;
/**
*
* Validator class loader
* @var Wootook_Core_Form_ValidatorLoader
*/
protected $_validatorLoader = null;
/**
*
* Enter description here ...
* @var Wootook_Core_Model_Session
*/
protected $_session = null;
public function __construct(Wootook_Core_Model_Session $session, Array $fields = array())
{
$this->_session = $session;
$this->_fieldLoader = new Wootook_Core_Form_FieldLoader($this, array(
'Wootook_Core_Form_Field_' => 'Wootook/Core/Form/Field'
));
$this->_validatorLoader = new Wootook_Core_Form_ValidatorLoader($this, array(
'Wootook_Core_Form_Validator_' => 'Wootook/Core/Form/Validator'
));
$this->addField('__formkey', 'text', array('form_key' => 'formKey'));
foreach ($fields as $fieldName => $fieldConfig) {
if (is_string($fieldConfig)) {
$this->addField($fieldName, $fieldConfig);
} else if ($fieldConfig instanceof Wootook_Core_Form_FieldAbstract) {
$this->addField($fieldName, $fieldConfig);
} else {
if (isset($fieldConfig['validators'])) {
$this->addField($fieldName, $fieldConfig['type'], $fieldConfig['validators']);
} else {
$this->addField($fieldName, $fieldConfig['type']);
}
}
}
}
public function validate()
{
foreach ($this->_fields as $field) {
$field->validate();
}
}
/**
*
* Enter description here ...
* @param string $name
* @param string|Wootook_Core_Form_FieldAbstract $type
* @return Wootook_Core_Form
*/
public function addField($name, $type = 'text', Array $validators = array())
{
if ($type instanceof Wootook_Core_Form_FieldAbstract) {
$this->_fields[$name] = $name;
$this->_fields[$name]->setForm($this);
} else {
$field = $this->_fieldLoader->load($type);
if ($field === null) {
trigger_error(sprintf('Field %1$s (type: %2$s) could not be created.', $name, $type), E_USER_WARNING);
return $this;
}
$this->_fields[$name] = $field;
}
$this->_fields[$name]->setName($name);
foreach ($validators as $validatorName => $validatorType) {
if ($validatorType instanceof Wootook_Core_Form_FieldAbstract) {
$this->_fields[$name]->addValidator($validatorType, $validatorName);
} else {
$validator = $this->_validatorLoader->load($validatorType);
if ($validator === null) {
trigger_error(sprintf('Validator %1$s (type: %2$s) could not be created.', $validatorName, $validatorType), E_USER_WARNING);
return $this;
}
$this->_fields[$name]->addValidator($validator, $validatorName);
}
}
return $this;
}
/**
*
* Enter description here ...
* @param string $name
* @return Wootook_Core_Form_FieldAbstract
*/
public function getField($name)
{
if (!isset($this->_fields[$name])) {
return null;
}
return $this->_fields[$name];
}
/**
*
* Enter description here ...
* @param string $name
* @return Wootook_Core_Model_Session
*/
public function getSession()
{
return $this->_session;
}
public function setRequest(Wootook_Core_Controller_Request_Http $request)
{
$this->_request = $request;
return $this;
}
/**
*
* Enter description here ...
* @return Wootook_Core_Controller_Request_Http
*/
public function getRequest()
{
return $this->_request;
}
public function getData()
{
$request = $this->getRequest();
if ($request === null) {
return array();
}
if ($request->isPost()) {
return $request->getAllPostData();
}
return $request->getAllQueryData();
}
public function populate(Array $datas = array())
{
$request = $this->getRequest();
foreach ($this->_fields as $fieldName => $field) {
if (isset($datas[$fieldName])) {
$field->populate($datas[$fieldName]);
} else if ($request->isPost()) {
$field->populate($request->getPost($fieldName));
} else {
$field->populate($request->getQuery($fieldName));
}
}
}
}

View file

@ -0,0 +1,11 @@
<?php
class Wootook_Core_Form_Field_Text
extends Wootook_Core_Form_FieldAbstract
{
public function getType()
{
return 'text';
}
}

View file

@ -0,0 +1,104 @@
<?php
abstract class Wootook_Core_Form_FieldAbstract
{
protected $_name = null;
protected $_form = null;
protected $_value = null;
protected $_validators = array();
public function __construct(Wootook_Core_Form $form = null)
{
if ($form !== null) {
$this->setForm($form);
}
}
abstract public function getType();
public function validate()
{
$data = $this->getData();
foreach ($this->_validators as $validator) {
if (!$validator->validate($this, $data)) {
return false;
}
}
return true;
}
public function setName($name)
{
$this->_name = $name;
return $this;
}
public function getName()
{
return $this->_name;
}
public function setForm(Wootook_Core_Form $form)
{
$this->_form = $form;
return $this;
}
public function getForm()
{
return $this->_form;
}
public function getData()
{
return $this->_value;
}
public function populate($value)
{
$this->_value = $value;
return $this;
}
public function addValidator(Wootook_Core_Form_ValidatorAbstract $validator, $name = null)
{
if ($name === null) {
$this->_validators = array();
$name = 'default';
}
$this->_validators[$name] = $validator;
return $this;
}
public function getValidator($name)
{
if (!isset($this->_validators[$name])) {
return null;
}
return $this->_validators[$name];
}
public function clearValidator($name)
{
if (isset($this->_validators[$name])) {
unset($this->_validators[$name]);
}
return $this;
}
public function clearAllValidators()
{
$this->_validators = array();
return $this;
}
}

View file

@ -0,0 +1,36 @@
<?php
class Wootook_Core_Form_FieldLoader
extends Wootook_Core_Plugin_LoaderAbstract
{
protected $_form = null;
public function __construct(Wootook_Core_Form $form, Array $namespaces = array())
{
$this->_form = $form;
foreach ($namespaces as $namespace => $path) {
if (is_int($namespace)) {
$this->registerNamespace($path);
} else {
$this->registerNamespace($namespace, $path);
}
}
}
protected function _load($className, $useSingleton)
{
$reflection = new ReflectionClass($className);
if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) {
$method = $reflection->getMethod('getSingleton');
return $method->invoke(null);
}
try {
return $reflection->newInstance($this->_form);
} catch (ReflectionException $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
return null;
}
}
}

View file

@ -0,0 +1,22 @@
<?php
class Wootook_Core_Form_Validator_Alnum
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#[^[:alnum:]]#');
}
public function validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
if ($this->_validate($field, $data)) {
$this->_getSession($field)
->addError('Field "%s" should only contain alphanumeric characters.', $field->getName());
return false;
}
return true;
}
}

View file

@ -0,0 +1,22 @@
<?php
class Wootook_Core_Form_Validator_Alnum
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#[^[:alpha:]]#');
}
public function validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
if ($this->_validate($field, $data)) {
$this->_getSession($field)
->addError('Field "%s" should only contain alphabetic characters.', $field->getName());
return false;
}
return true;
}
}

View file

@ -0,0 +1,21 @@
<?php
class Wootook_Core_Form_Validator_Email
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#^[[:alnum:]\._\-]@[[:alnum:]\._\-]\.[a-z]{2,}$#');
}
public function validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
if (!$this->_validate($field, $data)) {
$this->_getSession($field)
->addError('Field "%s" should contain an email.', $field->getName());
return false;
}
return true;
}
}

View file

@ -0,0 +1,20 @@
<?php
class Wootook_Core_Form_Validator_FormKey
extends Wootook_Core_Form_ValidatorAbstract
{
public function validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
$form = $field->getForm();
$session = $form->getSession();
if ($session->getFormKey(false) == $data) {
return true;
}
$this->_getSession($field)
->addError('CSRF token failure.', $field->getName());
return false;
}
}

View file

@ -0,0 +1,22 @@
<?php
class Wootook_Core_Form_Validator_Hex
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#(?:0x)?[^0-9a-f]#i');
}
public function validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
if ($this->_validate($field, $data)) {
$this->_getSession($field)
->addError('Field "%s" should only contain numeric characters.', $field->getName());
return false;
}
return true;
}
}

View file

@ -0,0 +1,21 @@
<?php
class Wootook_Core_Form_Validator_Email
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#^[[:alnum:]\._\-]\.[a-z]{2,}$#');
}
public function validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
if (!$this->_validate($field, $data)) {
$this->_getSession($field)
->addError('Field "%s" should contain a host name.', $field->getName());
return false;
}
return true;
}
}

View file

@ -0,0 +1,22 @@
<?php
class Wootook_Core_Form_Validator_Numeric
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#[^[:digit:]]#');
}
public function validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
if ($this->_validate($field, $data)) {
$this->_getSession($field)
->addError('Field "%s" should only contain numeric characters.', $field->getName());
return false;
}
return true;
}
}

View file

@ -0,0 +1,28 @@
<?php
class Wootook_Core_Form_Validator_Regex
extends Wootook_Core_Form_ValidatorAbstract
{
protected $_expression = null;
public function __construct($expression)
{
$this->_expression = $expression;
}
public function validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
if (!$this->_validate($field, $data)) {
$this->_getSession($field)
->addError('Field "%s" does not match the validation pattern.', $field->getName());
return false;
}
return true;
}
protected function _validate(Wootook_Core_Form_FieldAbstract $field, $data)
{
return preg_match($this->_expression, $data);
}
}

View file

@ -0,0 +1,15 @@
<?php
abstract class Wootook_Core_Form_ValidatorAbstract
{
abstract public function validate(Wootook_Core_Form_FieldAbstract $field, $data);
protected function _getSession(Wootook_Core_Form_FieldAbstract $field)
{
$form = $field->getForm();
if (!$form instanceof Wootook_Core_Form) {
return null;
}
return $form->getSession();
}
}

View file

@ -0,0 +1,36 @@
<?php
class Wootook_Core_Form_ValidatorLoader
extends Wootook_Core_Plugin_LoaderAbstract
{
protected $_form = null;
public function __construct(Wootook_Core_Form $form, Array $namespaces = array())
{
$this->_form = $form;
foreach ($namespaces as $namespace => $path) {
if (is_int($namespace)) {
$this->registerNamespace($path);
} else {
$this->registerNamespace($namespace, $path);
}
}
}
protected function _load($className, $useSingleton)
{
$reflection = new ReflectionClass($className);
if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) {
$method = $reflection->getMethod('getSingleton');
return $method->invoke(null);
}
try {
return $reflection->newInstance();
} catch (ReflectionException $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
return null;
}
}
}

View file

@ -8,6 +8,8 @@ class Wootook_Core_Layout
protected $_blocks = array();
protected $_messageBlock = null;
protected $_view = null;
protected $_eventPrefix = 'layout';
protected $_eventObject = 'layout';
@ -31,19 +33,16 @@ class Wootook_Core_Layout
}
}
$config = include ROOT_PATH . 'config.php';
$fileList = array();
if (isset($config['global'])) {
if (isset($config['global']['layout'])) {
$fileList = $config['global']['layout'];
}
if (isset($config['global']['package'])) {
$this->setPackage($config['global']['package']);
}
if (isset($config['global']['theme'])) {
$this->setTheme($config['global']['theme']);
}
$fileList = Wootook::getConfig('global/layout');
if (!is_array($fileList) || empty($fileList)) {
$fileList = $this->getAllDatas();
} else {
$fileList = array_merge($fileList, $this->getAllDatas());
}
$this->_data = array();
$this->setPackage(Wootook::getConfig('global/package'));
$this->setTheme(Wootook::getConfig('global/theme'));
foreach ($fileList as $layoutFile) {
foreach (include $this->_getLayoutPath($layoutFile) as $layoutId => $layoutConfig) {
@ -57,6 +56,8 @@ class Wootook_Core_Layout
}
}
$this->_messageBlock = $this->createBlock('core/messages', 'messages');
return $this;
}
@ -86,6 +87,9 @@ class Wootook_Core_Layout
$layoutUpdates = array();
$layoutConfig = array();
foreach (array_reverse($layoutConfigs) as $config) {
if (!is_array($config)) {
continue;
}
$layoutConfig = array_merge($layoutConfig, $config);
if (isset($layoutConfig['reference'])) {
@ -374,6 +378,10 @@ class Wootook_Core_Layout
public function render()
{
if (!$this->_view instanceof Wootook_Core_View) {
throw new Wootook_Core_Exception_RuntimeException(Wootook::__('No root view declared.'));
}
$scriptPath = $this->getScriptPath();
foreach ($this->_blocks as $block) {
if ($block instanceof Wootook_Core_Block_Template) {
@ -407,8 +415,17 @@ class Wootook_Core_Layout
return $path;
}
trigger_error(Legacies::__("Layout file '%s' does not exist.", $file), E_USER_NOTICE);
trigger_error(Wootook::__("Layout file '%s' does not exist.", $file), E_USER_NOTICE);
return null;
}
/**
*
* @return Wootook_Core_Block_Messages
*/
public function getMessagesblock()
{
return $this->_messageBlock;
}
}

View file

@ -8,6 +8,13 @@ abstract class Wootook_Core_Model_Config_Abstract
{
$config = Wootook::getConfig('global/storyline');
if ($config === null || empty($config)) {
$config = array(
'universe' => 'default',
'episode' => 'default'
);
}
$path = 'gamedata' . DIRECTORY_SEPARATOR . $config['universe'] . DIRECTORY_SEPARATOR
. $config['episode'] . DIRECTORY_SEPARATOR . $filename . '.php';

View file

@ -128,7 +128,7 @@ class Wootook_Core_Model_Session
return $this->addMessage(vsprintf($message, $args), self::DEBUG);
}
public function getFormKey($reset = false)
public function getFormKey($reset = true)
{
if (!$this->getData('form_key')) {
$this->setData('form_key', uniqid());
@ -136,10 +136,32 @@ class Wootook_Core_Model_Session
}
$key = $this->getData('form_key');
if ($reset == true) {
if ($reset !== true) {
$this->setData('form_key', uniqid());
}
return $key;
}
public function setFormData(Array $data = array())
{
if (isset($data['__formkey'])) {
unset($data['__formkey']);
}
$this->setData('form_data', $data);
return $this;
}
public function getFormData($key = null, $default = null)
{
$data = $this->getData('form_data');
if ($key === null) {
return $data;
} else if (isset($data[$key])) {
return $data[$key];
}
return $default;
}
}

View file

@ -15,7 +15,7 @@ abstract class Wootook_Core_Plugin_LoaderAbstract
$className = $namespace . ucfirst($pluginName);
$fileName = $path . DIRECTORY_SEPARATOR . ucfirst($pluginName) . '.php';
if (!file_exists($fileName)) {
if (!Wootook::fileExists($fileName)) {
continue;
}
@ -26,7 +26,7 @@ abstract class Wootook_Core_Plugin_LoaderAbstract
return $this->_load($className, $useSingleton);
}
return $this;
return null;
}
public function registerNamespace($namespace, $path = null)
@ -48,7 +48,7 @@ abstract class Wootook_Core_Plugin_LoaderAbstract
return $this;
}
abstract protected function _load($className);
abstract protected function _load($className, $useSingleton);
public function getPlugin($pluginName)
{

View file

@ -3,10 +3,14 @@
class Wootook_Core_Time
{
public static function init()
public static function init($timezone = null)
{
$config = include ROOT_PATH . 'config.php';
$timezone = $config['global']['date']['timezone'];
if ($timezone === null) {
$timezone = Wootook::getConfig('global/date/timezone');
}
if ($timezone === null) {
$timezone = 'GMT';
}
date_default_timezone_set($timezone);
}

View file

@ -142,7 +142,16 @@ class Wootook_Core_View
$theme = Wootook_Core_Layout::DEFAULT_THEME;
}
return Wootook::getSkinUrl($package, $theme, $uri, $params);
$pattern = ROOT_PATH . DIRECTORY_SEPARATOR . 'skin/%s/%s/{$uri}';
if (Wootook::fileExists(sprintf($pattern, $package, $theme))) {
return Wootook::getSkinUrl($package, $theme, $uri, $params);
}
if (Wootook::fileExists(sprintf($pattern, $package, Wootook_Core_Layout::DEFAULT_THEME))) {
return Wootook::getSkinUrl($package, Wootook_Core_Layout::DEFAULT_THEME, $uri, $params);
}
return Wootook::getSkinUrl(Wootook_Core_Layout::DEFAULT_PACKAGE, Wootook_Core_Layout::DEFAULT_THEME, $uri, $params);
}
public function setPartial($name, $content)

View file

@ -26,6 +26,11 @@ class Wootook_Empire_Model_Planet
*/
protected $_moon = null;
/**
* @var Wootook_Empire_Model_Planet
*/
protected $_planet = null;
/**
* @var Wootook_Empire_Model_Planet_Builder
*/
@ -175,10 +180,14 @@ class Wootook_Empire_Model_Planet
public function getGalaxyData()
{
$entity = new Wootook_Empire_Model_Galaxy_Position();
$entity->load(array('id_planet' => $this->getId()));
if ($this->isPlanet()) {
$entity = new Wootook_Empire_Model_Galaxy_Position();
$entity->load(array('id_planet' => $this->getId()));
return $entity;
return $entity;
}
return $this->getPlanet()->getGalaxyData();
}
public function updateStorages($time = null)
@ -533,10 +542,62 @@ class Wootook_Empire_Model_Planet
));
$this->_moon = $statement->current();
if ($this->_moon !== null && $this->_moon instanceof self) {
$this->_moon->setPlanet($this);
}
}
return $this->_moon;
}
public function setMoon(Wootook_Empire_Model_Planet $moon)
{
$this->_moon = $moon;
return $this;
}
public function getPlanet()
{
static $statement = null;
if ($this->isPlanet()) {
return null;
}
if ($this->_planet === null) {
if ($statement === null) {
$statement = new Wootook_Core_Collection(array('planet' => 'planets'), get_class($this));
$statement
->where('galaxy=:galaxy')
->where('system=:system')
->where('planet=:position')
->where('planet_type=' . strval(self::TYPE_PLANET))
;
}
$statement->load(array(
'galaxy' => $this->getGalaxy(),
'system' => $this->getSystem(),
'position' => $this->getPosition()
));
$this->_planet = $statement->current();
if ($this->_planet !== null && $this->_planet instanceof self) {
$this->_planet->setMoon($this);
}
}
return $this->_planet;
}
public function setPlanet(Wootook_Empire_Model_Planet $planet)
{
$this->_planet = $planet;
return $this;
}
public function setGalaxy($galaxy)
{
$this->setData('galaxy', $galaxy);

View file

@ -555,6 +555,10 @@ class Wootook_Empire_Model_User
$layout = $eventData['layout'];
$navigation = $layout->getBlock('navigation');
$navigation->addLink('tools/admin', 'Admin Panel', 'Admin Panel', 'admin/index.php', array(), array('admin'));
if (!defined('IN_ADMIN')) {
$navigation->addLink('tools/admin', 'Admin Panel', 'Admin Panel', 'admin/overview.php', array(), array('admin'));
} else {
$navigation->addLink('tools/back', 'Go back to the game', 'Go back to the game', 'overview.php', array(), array('admin'));
}
}
}