Updated installer
Added Website and Game models Updted config loading Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
fcd1f5b740
commit
5393be4daf
39 changed files with 779 additions and 661 deletions
|
|
@ -129,211 +129,6 @@ SQL_EOF;
|
|||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('core_website')} (
|
||||
`website_id` TINYINT UNSIGNED NOT NULL,
|
||||
`code` VARCHAR(64) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`sort_order` TINYINT UNSIGNED NOT NULL,
|
||||
`default_group_id` TINYINT UNSIGNED NOT NULL,
|
||||
`is_default` BOOL NOT NULL,
|
||||
`is_staging` BOOL NOT NULL,
|
||||
`is_active` BOOL NOT NULL,
|
||||
PRIMARY KEY (`webste_id`),
|
||||
UNIQUE (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('core_game_group')} (
|
||||
`group_id` TINYINT UNSIGNED NOT NULL,
|
||||
`website_id` TINYINT UNSIGNED NOT NULL,
|
||||
`code` VARCHAR(64) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`sort_order` TINYINT UNSIGNED NOT NULL,
|
||||
`is_default` BOOL NOT NULL,
|
||||
PRIMARY KEY (`group_id`),
|
||||
INDEX (`webste_id`),
|
||||
UNIQUE (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('core_game')} (
|
||||
`game_id` SMALLINT UNSIGNED NOT NULL,
|
||||
`group_id` TINYINT UNSIGNED NOT NULL,
|
||||
`website_id` TINYINT UNSIGNED NOT NULL,
|
||||
`code` VARCHAR(64) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`sort_order` TINYINT UNSIGNED NOT NULL,
|
||||
`is_default` BOOL NOT NULL,
|
||||
`is_staging` BOOL NOT NULL,
|
||||
`is_active` BOOL NOT NULL,
|
||||
PRIMARY KEY (`group_id`),
|
||||
INDEX (`webste_id`),
|
||||
UNIQUE (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('core_website')} (`website_id`, `code`, `name`, `sort_order`, `default_group_id`, `is_default`, `is_staging`, `is_active`)
|
||||
VALUES
|
||||
(0, "admin", "Administration", 0, 0, 0, 0, 1),
|
||||
(1, "default", "Default Website", 1, 1, 1, 0, 1);
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('core_game_group')} (`group_id`, `website_id`, `code`, `name`, `sort_order`, `is_default`)
|
||||
VALUES
|
||||
(0, 0, "admin", "Administration", 0, 0),
|
||||
(1, 1, "default", "Default Group", 1, 1);
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('core_game')} (`game_id`, `group_id`, `website_id`, `code`, `name`, `sort_order`, `is_default`, `is_staging`, `is_active`)
|
||||
VALUES
|
||||
(0, 0, 0, "admin", "Administration", 0, 0, 0, 1),
|
||||
(1, 1, 1, "default", "Default Game", 1, 1, 0, 1);
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('core_config')} (
|
||||
`website_id` TINYINT UNSIGNED NOT NULL,
|
||||
`game_id` TINYINT UNSIGNED NOT NULL,
|
||||
`config_path` VARCHAR(64) NOT NULL,
|
||||
`config_value` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`website_id`, `game_id`, `config_path`),
|
||||
INDEX (`website_id`),
|
||||
INDEX (`game_id`),
|
||||
INDEX (`config_path`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT IGNORE INTO {$this->getTableName('core_config')} (`webste_id`, `game_id`, `config_path`, `config_value`) VALUES
|
||||
(1, 1, 'resource/base-income/metal', '20'),
|
||||
(1, 1, 'resource/base-income/cristal', '10'),
|
||||
(1, 1, 'resource/base-income/deuterium', '0'),
|
||||
(1, 1, 'resource/base-income/energy', '0'),
|
||||
|
||||
(1, 1, 'resource/initial/fields', '163'),
|
||||
(1, 1, 'resource/initial/metal', '500'),
|
||||
(1, 1, 'resource/initial/cristal', '500'),
|
||||
(1, 1, 'resource/initial/deuterium', '0'),
|
||||
(1, 1, 'resource/initial/energy', '0'),
|
||||
|
||||
(1, 1, 'game/general/name', 'Wootook'),
|
||||
(1, 1, 'game/general/boards-url', 'http://wootook.org/board/'),
|
||||
(1, 1, 'game/general/extra-url-title', 'Wootook!'),
|
||||
(1, 1, 'game/general/extra-url', 'http://wootook.org/'),
|
||||
(1, 1, 'game/general/active', '1'),
|
||||
(1, 1, 'game/general/closing-message', 'Le jeu est clos pour le moment.'),
|
||||
(1, 1, 'game/general/locale', 'fr_FR'),
|
||||
|
||||
(1, 1, 'game/resource/multiplier', '1000'),
|
||||
(1, 1, 'game/speed/general', '2500'),
|
||||
(1, 1, 'game/speed/fleet', '2500'),
|
||||
|
||||
(1, 1, 'game/debris/metal-percent', '30'),
|
||||
(1, 1, 'game/debris/cristal-percent', '30'),
|
||||
(1, 1, 'game/debris/deuterium-percent', '0'),
|
||||
(1, 1, 'game/debris/energy-percent', '0'),
|
||||
|
||||
(1, 1, 'game/debris/fleet', '1'),
|
||||
(1, 1, 'game/debris/defense', '0'),
|
||||
|
||||
(1, 1, 'game/noob-protection/active', '0'),
|
||||
(1, 1, 'game/noob-protection/points-cap', '5000'),
|
||||
(1, 1, 'game/noob-protection/multiplier', '5'),
|
||||
|
||||
(0, 0, 'web/cookie/name', '__wtk'),
|
||||
(0, 0, 'web/cookie/time', '2592000'),
|
||||
(0, 0, 'web/cookie/domain', ''),
|
||||
(0, 0, 'web/cookie/path', ''),
|
||||
|
||||
(0, 0, 'engine/options/bbcode', '1'),
|
||||
(0, 0, 'engine/options/ga', '1'),
|
||||
(0, 0, 'engine/options/announces', '0'),
|
||||
(0, 0, 'engine/options/retailer', '0'),
|
||||
(0, 0, 'engine/options/notes', '0'),
|
||||
(0, 0, 'engine/options/chat', '0'),
|
||||
(0, 0, 'engine/options/banner', '0'),
|
||||
(0, 0, 'engine/options/vacation-min-time', '172800'),
|
||||
|
||||
(0, 0, 'game/news/active', '0'),
|
||||
(0, 0, 'game/news/content', 'Bienvenue sur le nouveau serveur de jeu Wootook!'),
|
||||
|
||||
(0, 0, 'engine/ban/duration', '86400'),
|
||||
|
||||
(0, 0, 'engine/bot/active', '0'),
|
||||
(0, 0, 'engine/bot/name', 'Woot'),
|
||||
(0, 0, 'engine/bot/email', 'contact@wootook.org'),
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- (0, 0, 'game_speed', '2500'),
|
||||
-- (0, 0, 'fleet_speed', '2500'),
|
||||
-- (0, 0, 'resource_multiplier', '1000'),
|
||||
|
||||
-- (0, 0, 'metal_basic_income', '20'),
|
||||
-- (0, 0, 'cristal_basic_income', '10'),
|
||||
-- (0, 0, 'deuterium_basic_income', '0'),
|
||||
-- (0, 0, 'energy_basic_income', '0'),
|
||||
|
||||
-- (0, 0, 'Fleet_Cdr', '30'),
|
||||
-- (0, 0, 'Defs_Cdr', '30'),
|
||||
-- (0, 0, 'initial_fields', '5000'),
|
||||
-- (0, 0, 'COOKIE_NAME', 'wootook'),
|
||||
-- (0, 0, 'game_name', 'Wootook'),
|
||||
-- (0, 0, 'game_disable', '1'),
|
||||
-- (0, 0, 'close_reason', 'Le jeu est clos pour le moment.'),
|
||||
(0, 0, 'BuildLabWhileRun', '0'),
|
||||
-- (0, 0, 'urlaubs_modus_erz', '1'),
|
||||
-- (0, 0, 'noobprotection', '1'),
|
||||
-- (0, 0, 'noobprotectiontime', '5000'),
|
||||
-- (0, 0, 'noobprotectionmulti', '5'),
|
||||
-- (0, 0, 'forum_url', 'http://wootook.org/board/'),
|
||||
-- (0, 0, 'OverviewNewsFrame', '1'),
|
||||
-- (0, 0, 'OverviewNewsTEXT', 'Bienvenue sur le nouveau serveur Wootook'),
|
||||
-- (0, 0, 'OverviewExternChat', '0'),
|
||||
-- (0, 0, 'OverviewExternChatCmd', ''),
|
||||
-- (0, 0, 'OverviewBanner', '0'),
|
||||
-- (0, 0, 'OverviewClickBanner', ''),
|
||||
(0, 0, 'ExtCopyFrame', '0'),
|
||||
(0, 0, 'ExtCopyOwner', ''),
|
||||
(0, 0, 'ExtCopyFunct', ''),
|
||||
-- (0, 0, 'ForumBannerFrame', '0'),
|
||||
-- (0, 0, 'stat_settings', '1000'),
|
||||
-- (0, 0, 'link_enable', '0'),
|
||||
-- (0, 0, 'link_name', ''),
|
||||
-- (0, 0, 'link_url', ''),
|
||||
-- (0, 0, 'enable_announces', '1'),
|
||||
-- (0, 0, 'enable_marchand', '1'),
|
||||
-- (0, 0, 'enable_notes', '1'),
|
||||
-- (0, 0, 'bot_name', 'Isaac'),
|
||||
-- (0, 0, 'bot_adress', 'contact@wootook.org'),
|
||||
-- (0, 0, 'banner_source_post', '../images/bann.png'),
|
||||
-- (0, 0, 'ban_duration', '30'),
|
||||
-- (0, 0, 'enable_bot', '0'),
|
||||
-- (0, 0, 'enable_bbcode', '1');
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('declared')} (
|
||||
`declarator` TEXT NOT NULL,
|
||||
|
|
@ -755,8 +550,8 @@ $this->query($sql);
|
|||
/*
|
||||
* Galaxy positions generation
|
||||
*/
|
||||
$galaxyCount = Wootook::getConfig('default/engine/universe/galaxies');
|
||||
$systemCount = Wootook::getConfig('default/engine/universe/systems');
|
||||
$galaxyCount = Wootook::getConfig('engine/universe/galaxies');
|
||||
$systemCount = Wootook::getConfig('engine/universe/systems');
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('galaxy')}
|
||||
|
|
|
|||
|
|
@ -40,124 +40,118 @@
|
|||
*
|
||||
*/
|
||||
|
||||
$this->setSetupConnection('legacies_setup');
|
||||
$this->setSetupConnection('core_setup');
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/aks')};
|
||||
DROP TABLE {$this->getTableName('aks')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/alliance')};
|
||||
DROP TABLE {$this->getTableName('alliance')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/annonce')};
|
||||
DROP TABLE {$this->getTableName('annonce')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/banned')};
|
||||
DROP TABLE {$this->getTableName('banned')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/buddy')};
|
||||
DROP TABLE {$this->getTableName('buddy')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/chat')};
|
||||
DROP TABLE {$this->getTableName('chat')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/config')};
|
||||
DROP TABLE {$this->getTableName('declared')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/declared')};
|
||||
DROP TABLE {$this->getTableName('errors')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/errors')};
|
||||
DROP TABLE {$this->getTableName('fleets')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/fleets')};
|
||||
DROP TABLE {$this->getTableName('galaxy')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/galaxy')};
|
||||
DROP TABLE {$this->getTableName('iraks')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/iraks')};
|
||||
DROP TABLE {$this->getTableName('lunas')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/lunas')};
|
||||
DROP TABLE {$this->getTableName('messages')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/messages')};
|
||||
DROP TABLE {$this->getTableName('multi')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/multi')};
|
||||
DROP TABLE {$this->getTableName('notes')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/notes')};
|
||||
DROP TABLE {$this->getTableName('planets')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/planets')};
|
||||
DROP TABLE {$this->getTableName('rw')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/rw')};
|
||||
DROP TABLE {$this->getTableName('statpoints')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/statpoints')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('legacies/users')};
|
||||
DROP TABLE {$this->getTableName('users')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
|
|
|||
|
|
@ -106,6 +106,18 @@ class Wootook
|
|||
*/
|
||||
protected static $_gameConfigs = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var array
|
||||
*/
|
||||
protected static $_ignoreDatabaseConfig = false;
|
||||
|
||||
protected static $_websitesById = array();
|
||||
protected static $_websitesByCode = array();
|
||||
protected static $_gamesById = array();
|
||||
protected static $_gamesByCode = array();
|
||||
|
||||
/**
|
||||
* Registers an event listener to be called later in the application.
|
||||
*
|
||||
|
|
@ -200,9 +212,11 @@ class Wootook
|
|||
|
||||
public static function getLocale()
|
||||
{
|
||||
$availableLocales = self::$_config->getConfig('global/locales');
|
||||
|
||||
return self::getPreferredLocale($availableLocales);
|
||||
$availableLocales = self::getWebsiteConfig('locales');
|
||||
if ($availableLocales !== null) {
|
||||
return self::getPreferredLocale($availableLocales->toArray());
|
||||
}
|
||||
return self::getPreferredLocale();
|
||||
}
|
||||
|
||||
public static function setDefaultLocale($locale)
|
||||
|
|
@ -310,36 +324,52 @@ class Wootook
|
|||
|
||||
public static function loadConfig($filename = null)
|
||||
{
|
||||
if ($filename === null) {
|
||||
$filename = ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php';
|
||||
}
|
||||
|
||||
self::$_config = new Wootook_Core_Config_Adapter_Array($filename);
|
||||
|
||||
self::$_globalConfig = clone self::$_config['default'];
|
||||
self::$_globalConfig->merge(self::$_config['global']);
|
||||
|
||||
self::_appendDatabaseConfig(self::$_globalConfig);
|
||||
|
||||
self::$_websiteConfigs = array();
|
||||
self::$_gameConfigs = array();
|
||||
|
||||
self::$_config = new Wootook_Core_Config_Adapter_Array();
|
||||
try {
|
||||
if (!is_array($filename)) {
|
||||
if ($filename === null) {
|
||||
$filename = ROOT_PATH . 'config.php';
|
||||
}
|
||||
self::$_config->load($filename);
|
||||
} else {
|
||||
self::$_config->setData($filename);
|
||||
}
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
self::$_globalConfig = new Wootook_Core_Config_Node(array(), self::$_config);
|
||||
self::$_ignoreDatabaseConfig = true;
|
||||
return self::$_config;
|
||||
}
|
||||
|
||||
self::$_globalConfig = clone self::$_config['default'];
|
||||
if (isset(self::$_config['global'])) {
|
||||
self::$_globalConfig->merge(self::$_config['global']);
|
||||
}
|
||||
|
||||
self::_appendDatabaseConfig(self::$_globalConfig);
|
||||
|
||||
return self::$_config;
|
||||
}
|
||||
|
||||
protected static function _appendDatabaseConfig(Wootook_Core_Config_Node $config, $type = 'global', $id = 0)
|
||||
protected static function _appendDatabaseConfig(Wootook_Core_Config_Node $config, $type = 'global', $model = null)
|
||||
{
|
||||
if (self::$_ignoreDatabaseConfig) {
|
||||
return $config;
|
||||
}
|
||||
|
||||
$collection = new Wootook_Core_Collection('core_config', 'Wootook_Core_Model_Config');
|
||||
|
||||
switch ($type) {
|
||||
case 'website':
|
||||
$collection->where('website_id = :website_id');
|
||||
$collection->load(array('website_id' => $id));
|
||||
$collection->load(array('website_id' => $model->getId()));
|
||||
break;
|
||||
|
||||
case 'game':
|
||||
$collection->where('game_id = :game_id');
|
||||
$collection->load(array('game_id' => $id));
|
||||
$collection->load(array('game_id' => $model->getId()));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -356,26 +386,126 @@ class Wootook
|
|||
return $config;
|
||||
}
|
||||
|
||||
public static function getWebsite($websiteId)
|
||||
{
|
||||
if (is_numeric($websiteId)) {
|
||||
if (isset(self::$_websitesById[$websiteId])) {
|
||||
return self::$_websitesById[$websiteId];
|
||||
}
|
||||
$website = new Wootook_Core_Model_Website();
|
||||
try {
|
||||
$website->load($websiteId);
|
||||
$websiteCode = $website->getData('code');
|
||||
|
||||
self::$_websitesById[$websiteId] = $website;
|
||||
self::$_websitesByCode[$websiteCode] = $website;
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
throw new Wootook_Core_Exception_RuntimeException('Could not load website entity.', null, $e);
|
||||
}
|
||||
|
||||
return $website;
|
||||
} else {
|
||||
if (isset(self::$_websitesByCode[$websiteId])) {
|
||||
return self::$_websitesByCode[$websiteId];
|
||||
}
|
||||
$website = new Wootook_Core_Model_Website();
|
||||
try {
|
||||
$website->load($websiteId, 'code');
|
||||
$websiteId = $website->getId();
|
||||
$websiteCode = $website->getData('code');
|
||||
|
||||
self::$_websitesById[$websiteId] = $website;
|
||||
self::$_websitesByCode[$websiteCode] = $website;
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
throw new Wootook_Core_Exception_RuntimeException('Could not load website entity.', null, $e);
|
||||
}
|
||||
|
||||
return $website;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getGame($gameId)
|
||||
{
|
||||
if (is_numeric($gameId)) {
|
||||
if (isset(self::$_gamesById[$gameId])) {
|
||||
return self::$_gamesById[$gameId];
|
||||
}
|
||||
$game = new Wootook_Core_Model_Game();
|
||||
try {
|
||||
$game->load($gameId);
|
||||
$gameCode = $game->getData('code');
|
||||
|
||||
self::$_gamesById[$gameId] = $game;
|
||||
self::$_gamesByCode[$gameCode] = $game;
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
throw new Wootook_Core_Exception_RuntimeException('Could not load game entity.', null, $e);
|
||||
}
|
||||
|
||||
return $game;
|
||||
} else {
|
||||
if (isset(self::$_gamesByCode[$gameId])) {
|
||||
return self::$_gamesByCode[$gameId];
|
||||
}
|
||||
$game = new Wootook_Core_Model_Game();
|
||||
try {
|
||||
$game->load($gameId, 'code');
|
||||
$gameId = $game->getId();
|
||||
$gameCode = $game->getData('code');
|
||||
|
||||
self::$_gamesById[$gameId] = $game;
|
||||
self::$_gamesByCode[$gameCode] = $game;
|
||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||
throw new Wootook_Core_Exception_RuntimeException('Could not load game entity.', null, $e);
|
||||
}
|
||||
|
||||
return $game;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setWebsite($websiteId, $website)
|
||||
{
|
||||
$websiteKey = $website->getData('code');
|
||||
self::$_websitesById[$websiteId] = $website;
|
||||
self::$_websitesByCode[$websiteKey] = $website;
|
||||
}
|
||||
|
||||
public static function setGame($gameId, $game)
|
||||
{
|
||||
$gameKey = $game->getData('code');
|
||||
self::$_gameById[$gameId] = $game;
|
||||
self::$_gameByCode[$gameKey] = $game;
|
||||
}
|
||||
|
||||
protected static function _initWebsiteConfig($websiteId)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
$websiteId = 1;
|
||||
try {
|
||||
$website = self::getWebsite($websiteId);
|
||||
} catch (Wootook_Core_Exception_RuntimeException $e) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
|
||||
return null;
|
||||
}
|
||||
$websiteKey = $website->getData('code');
|
||||
$websiteId = $website->getId();
|
||||
|
||||
if (!isset(self::$_websiteConfigs[$websiteId])) {
|
||||
self::$_websiteConfigs[$websiteId] = clone self::$_globalConfig;
|
||||
|
||||
$websiteConfig = self::$_config->getConfig("website/{$websiteId}");
|
||||
if ($websiteConfig !== null) {
|
||||
self::$_websiteConfigs[$websiteId]->merge($websiteConfig);
|
||||
if (!isset(self::$_websiteConfigs[$websiteKey])) {
|
||||
self::$_websiteConfigs[$websiteKey] = clone self::$_config['default'];
|
||||
if (isset(self::$_config['frontend'])) {
|
||||
self::$_websiteConfigs[$websiteKey]->merge(self::$_config['frontend']);
|
||||
}
|
||||
|
||||
self::_appendDatabaseConfig(self::$_websiteConfigs[$websiteId], 'website', $websiteId);
|
||||
$websiteConfig = self::$_config->getConfig("website/{$websiteKey}");
|
||||
if ($websiteConfig !== null) {
|
||||
self::$_websiteConfigs[$websiteKey]->merge($websiteConfig);
|
||||
}
|
||||
|
||||
self::_appendDatabaseConfig(self::$_websiteConfigs[$websiteKey], 'website', $website);
|
||||
}
|
||||
|
||||
return self::$_websiteConfigs[$websiteId];
|
||||
return self::$_websiteConfigs[$websiteKey];
|
||||
}
|
||||
|
||||
protected static function _initGameConfig($gameId)
|
||||
|
|
@ -384,23 +514,33 @@ class Wootook
|
|||
self::loadConfig();
|
||||
}
|
||||
|
||||
$websiteId = 1;
|
||||
$gameId = 1;
|
||||
|
||||
if (!isset(self::$_gameConfigs[$gameId])) {
|
||||
self::_initWebsiteConfig($websiteId);
|
||||
|
||||
self::$_gameConfigs[$gameId] = clone self::$_websiteConfigs[$websiteId];
|
||||
|
||||
$gameConfig = self::$_config->getConfig("game/{$gameId}");
|
||||
if ($gameConfig !== null) {
|
||||
self::$_gameConfigs[$gameId]->merge($gameConfig);
|
||||
}
|
||||
|
||||
self::_appendDatabaseConfig(self::$_gameConfigs[$gameId], 'game', $gameId);
|
||||
try {
|
||||
$game = self::getGame($gameId);
|
||||
} catch (Wootook_Core_Exception_RuntimeException $e) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::$_gameConfigs[$gameId];
|
||||
$gameKey = $game->getData('code');
|
||||
$gameId = $game->getId();
|
||||
$websiteId = $game->getData('website_id');
|
||||
|
||||
if (!isset(self::$_gameConfigs[$gameKey])) {
|
||||
$websiteConfig = self::_initWebsiteConfig($websiteId);
|
||||
if ($websiteConfig === null) {
|
||||
return null;
|
||||
}
|
||||
self::$_gameConfigs[$gameKey] = clone $websiteConfig;
|
||||
|
||||
$gameConfig = self::$_config->getConfig("game/{$gameKey}");
|
||||
if ($gameConfig !== null) {
|
||||
self::$_gameConfigs[$gameKey]->merge($gameConfig);
|
||||
}
|
||||
|
||||
self::_appendDatabaseConfig(self::$_gameConfigs[$gameKey], 'game', $game);
|
||||
}
|
||||
|
||||
return self::$_gameConfigs[$gameKey];
|
||||
}
|
||||
|
||||
public static function getConfig($path = null)
|
||||
|
|
@ -415,36 +555,46 @@ class Wootook
|
|||
return self::$_globalConfig;
|
||||
}
|
||||
|
||||
public static function getWebsiteConfig($path = null, $websiteId = null)
|
||||
public static function getWebsiteConfig($path = null, $websiteKey = null)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
$websiteId = 1;
|
||||
if ($websiteKey === null) {
|
||||
$websiteKey = Wootook_Core_Model_Website::DEFAULT_CODE;
|
||||
}
|
||||
|
||||
self::_initWebsiteConfig($websiteId);
|
||||
$config = self::_initWebsiteConfig($websiteKey);
|
||||
if ($config === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($path !== null) {
|
||||
return self::$_websiteConfigs[$websiteId]->getConfig($path);
|
||||
return $config->getConfig($path);
|
||||
}
|
||||
return self::$_websiteConfigs[$websiteId];
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function getGameConfig($path = null, $gameId = null)
|
||||
public static function getGameConfig($path = null, $gameKey = null)
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
$gameId = 1;
|
||||
if ($gameKey === null) {
|
||||
$gameKey = Wootook_Core_Model_Game::DEFAULT_CODE;
|
||||
}
|
||||
|
||||
self::_initGameConfig($gameId);
|
||||
$config = self::_initGameConfig($gameKey);
|
||||
if ($config === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($path !== null) {
|
||||
return self::$_gameConfigs[$gameId]->getConfig($path);
|
||||
return $config->getConfig($path);
|
||||
}
|
||||
return self::$_gameConfigs[$gameId];
|
||||
return $config;
|
||||
}
|
||||
|
||||
public static function setConfig($path, $value, $websiteId = null, $gameId = null)
|
||||
|
|
@ -453,12 +603,23 @@ class Wootook
|
|||
self::loadConfig();
|
||||
}
|
||||
|
||||
$updater = new Wootook_Core_Model_Config();
|
||||
$updater->setPath($path)->setValue($value);
|
||||
if ($websiteId !== null) {
|
||||
$updater->setWebsiteId($websiteId);
|
||||
if (!self::$_ignoreDatabaseConfig) {
|
||||
$updater = new Wootook_Core_Model_Config();
|
||||
$updater->setPath($path)->setValue($value);
|
||||
if ($websiteId !== null) {
|
||||
$updater->setWebsiteId($websiteId);
|
||||
if ($gameId !== null) {
|
||||
$updater->setGameId($gameId);
|
||||
self::$_gameConfigs[$gameId]->setConfig($path, $value);
|
||||
} else {
|
||||
self::$_websiteConfigs[$websiteId]->setConfig($path, $value);
|
||||
}
|
||||
} else {
|
||||
self::$_globalConfig->setConfig($path, $value);
|
||||
}
|
||||
$updater->save();
|
||||
} else if ($websiteId !== null) {
|
||||
if ($gameId !== null) {
|
||||
$updater->setGameId($gameId);
|
||||
self::$_gameConfigs[$gameId]->setConfig($path, $value);
|
||||
} else {
|
||||
self::$_websiteConfigs[$websiteId]->setConfig($path, $value);
|
||||
|
|
@ -466,14 +627,13 @@ class Wootook
|
|||
} else {
|
||||
self::$_globalConfig->setConfig($path, $value);
|
||||
}
|
||||
$updater->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getBaseUrl()
|
||||
{
|
||||
return self::$_config->getConfig('global/web/base_url');
|
||||
return self::getConfig('web/base_url');
|
||||
}
|
||||
|
||||
public static function getSkinUrl($package, $theme, $uri, Array $params = array())
|
||||
|
|
@ -504,13 +664,13 @@ class Wootook
|
|||
return false;
|
||||
}
|
||||
|
||||
Wootook_Core_ErrorProfiler::sleep();
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->sleep();
|
||||
if (($fp = @fopen($path, 'r', true)) === false) {
|
||||
Wootook_Core_ErrorProfiler::wakeup();
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
|
||||
return false;
|
||||
}
|
||||
fclose($fp);
|
||||
Wootook_Core_ErrorProfiler::wakeup();
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,14 +14,10 @@ class Wootook_Core_Block_Messages
|
|||
{
|
||||
$messages = array();
|
||||
|
||||
var_dump($this->_storages);
|
||||
foreach ($this->_storages as $namespace) {
|
||||
$session = Wootook::getSession($namespace);
|
||||
var_dump($session);
|
||||
|
||||
foreach ($session->getMessages() as $messageLevel => $messageList) {
|
||||
var_dump(array($messageLevel => $messageList));
|
||||
|
||||
if (!isset($messages[$messageLevel])) {
|
||||
$messages[$messageLevel] = $messageList;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ class Wootook_Core_Config_Adapter_Array
|
|||
$data = include $filename;
|
||||
|
||||
if (!is_array($data)) {
|
||||
throw new Wootook_Core_Exception_DataAccessException(
|
||||
Wootook::__('Configuration file could not be loaded.'));
|
||||
throw new Wootook_Core_Exception_DataAccessException('Configuration file could not be loaded.');
|
||||
}
|
||||
|
||||
$this->_init($data);
|
||||
|
|
|
|||
|
|
@ -47,21 +47,22 @@ class Wootook_Core_Config_Node
|
|||
$length = count($explodedPath);
|
||||
$currentNode = $this;
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
if (!$currentNode->offsetExists($explodedPath[$i])) {
|
||||
$newNode = new Wootook_Core_Config_Node(array(), $currentNode);
|
||||
$currentNode->offsetSet($explodedPath[$i], $newNode);
|
||||
if ($i < ($length - 1)) {
|
||||
if (!$currentNode->offsetExists($explodedPath[$i])) {
|
||||
$newNode = new Wootook_Core_Config_Node(array(), $currentNode);
|
||||
$currentNode->offsetSet($explodedPath[$i], $newNode);
|
||||
}
|
||||
} else if (is_array($value)) {
|
||||
$currentNode->offsetSet($explodedPath[$i], new self($value, $this));
|
||||
break;
|
||||
} else {
|
||||
$currentNode->offsetSet($explodedPath[$i], $value);
|
||||
break;
|
||||
}
|
||||
|
||||
$currentNode = $currentNode->offsetGet($explodedPath[$i]);
|
||||
|
||||
if ($i >= ($length - 1)) {
|
||||
if (is_array($value)) {
|
||||
$currentNode->offsetSet($explodedPath[$i], new self($value, $this));
|
||||
} else {
|
||||
$currentNode->offsetSet($explodedPath[$i], $value);
|
||||
}
|
||||
break;
|
||||
} else if (!$currentNode instanceof Wootook_Core_Config_Node) {
|
||||
if (!$currentNode instanceof Wootook_Core_Config_Node) {
|
||||
throw new Wootook_Core_Exception_RuntimeException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,16 @@ abstract class Wootook_Core_Entity
|
|||
{
|
||||
$id = func_get_arg(0);
|
||||
|
||||
$idFieldName = self::getIdFieldName();
|
||||
if (func_num_args() >= 2) {
|
||||
$idFieldName = func_get_arg(1);
|
||||
} else {
|
||||
$idFieldName = $this->getIdFieldName();
|
||||
}
|
||||
|
||||
$database = $this->getReadConnection();
|
||||
if ($database === null) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Could not load data: no read connection configured.');
|
||||
}
|
||||
|
||||
$sql =<<<SQL_EOF
|
||||
SELECT * FROM {$database->getTable($this->getTableName())}
|
||||
|
|
@ -77,6 +85,10 @@ SQL_EOF;
|
|||
$values[$idFieldName] = $this->getId();
|
||||
|
||||
$database = $this->getWriteConnection();
|
||||
if ($database === null) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Could not load data: no write connection configured.');
|
||||
}
|
||||
|
||||
$sql =<<<SQL_EOF
|
||||
UPDATE {$database->getTable($this->getTableName())}
|
||||
SET {$fieldsImploded}
|
||||
|
|
@ -101,6 +113,10 @@ SQL_EOF;
|
|||
$tokensImploded = implode(', ', $tokens);
|
||||
|
||||
$database = $this->getWriteConnection();
|
||||
if ($database === null) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Could not load data: no write connection configured.');
|
||||
}
|
||||
|
||||
$sql =<<<SQL_EOF
|
||||
INSERT INTO {$database->getTable($this->getTableName())} ($fieldsImploded)
|
||||
VALUES ({$tokensImploded})
|
||||
|
|
@ -128,6 +144,10 @@ SQL_EOF;
|
|||
$fieldsImploded = implod(', ', $fields);
|
||||
$idFieldName = self::getIdFieldName();
|
||||
$database = $this->getWriteConnection();
|
||||
if ($database === null) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Could not load data: no write connection configured.');
|
||||
}
|
||||
|
||||
$sql =<<<SQL_EOF
|
||||
DELETE {$database->getTable($this->getTableName())}
|
||||
WHERE {$idFieldName}=:{$idFieldName}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Wootook_Core_ErrorProfiler
|
|||
|
||||
private static $_isTraceRegistered = false;
|
||||
|
||||
private static $_listen = true;
|
||||
private $_listen = true;
|
||||
|
||||
private $_mute = false;
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ class Wootook_Core_ErrorProfiler
|
|||
|
||||
public function errorManager($errno, $errstr, $errfile = null, $errline = null, Array $errcontext = array())
|
||||
{
|
||||
if (!self::$_listen) {
|
||||
if (!$this->_listen) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -92,10 +92,10 @@ class Wootook_Core_ErrorProfiler
|
|||
|
||||
public function exceptionManager($exception)
|
||||
{
|
||||
if (!self::$_listen) {
|
||||
if (!$this->_listen) {
|
||||
return;
|
||||
}
|
||||
$this->_exceptions[] = $exception;
|
||||
$this->_exceptions[] = new Wootook_Core_Exception_Exception('Uncaught Exception: ' . $exception->getMessage(), null, $exception);
|
||||
}
|
||||
|
||||
protected function _renderError($id, $error)
|
||||
|
|
@ -171,7 +171,19 @@ ERROR_EOF;
|
|||
$index++;
|
||||
echo "Message #{$index}". PHP_EOL;
|
||||
echo $exception->getMessage() . PHP_EOL;
|
||||
echo $exception->getTraceAsString();
|
||||
echo $exception->getTraceAsString() . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
|
||||
$child = 0;
|
||||
$current = $exception;
|
||||
while (($current = $current->getPrevious()) !== null) {
|
||||
$child++;
|
||||
echo " Child level #{$child}". PHP_EOL;
|
||||
echo " " . $current->getMessage() . PHP_EOL;
|
||||
echo $current->getTraceAsString() . PHP_EOL;
|
||||
echo PHP_EOL;
|
||||
}
|
||||
echo PHP_EOL;
|
||||
}
|
||||
echo '</pre>';
|
||||
}
|
||||
|
|
@ -204,13 +216,13 @@ ERROR_EOF;
|
|||
}
|
||||
}
|
||||
|
||||
public static function sleep()
|
||||
public function sleep()
|
||||
{
|
||||
self::$_listen = false;
|
||||
$this->_listen = false;
|
||||
}
|
||||
|
||||
public static function wakeup()
|
||||
public function wakeup()
|
||||
{
|
||||
self::$_listen = true;
|
||||
$this->_listen = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,4 +4,22 @@ class Wootook_Core_Exception_Exception
|
|||
extends Exception
|
||||
implements Wootook_Core_Exception
|
||||
{
|
||||
protected $_previous = null;
|
||||
|
||||
public function __construct($message = null, $code = null, $previous = null)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 50300) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
} else {
|
||||
parent::__construct($message, $code);
|
||||
$this->_previous = $previous;
|
||||
}
|
||||
}
|
||||
|
||||
public function __call($method, $params)
|
||||
{
|
||||
if (strtolower($method) == 'getprevious') {
|
||||
return $this->_previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,4 +4,29 @@ class Wootook_Core_Exception_RuntimeException
|
|||
extends RuntimeException
|
||||
implements Wootook_Core_Exception
|
||||
{
|
||||
protected $_previous = null;
|
||||
|
||||
public function __construct($message = null, $code = null, $previous = null)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 50300) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
} else {
|
||||
parent::__construct($message, $code);
|
||||
$this->_previous = $previous;
|
||||
}
|
||||
}
|
||||
|
||||
public function __call($method, $params)
|
||||
{
|
||||
if (strtolower($method) == 'getprevious') {
|
||||
return $this->_previous;
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return <<<STRING_EOF
|
||||
|
||||
STRING_EOF;
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,10 @@ class Wootook_Core_Layout
|
|||
}
|
||||
}
|
||||
|
||||
$fileList = Wootook::getConfig('global/layout');
|
||||
$fileList = Wootook::getConfig('layout');
|
||||
if ($fileList instanceof Wootook_Core_Config_Node) {
|
||||
$fileList = $fileList->toArray();
|
||||
}
|
||||
if (!is_array($fileList) || empty($fileList)) {
|
||||
$fileList = $this->getAllDatas();
|
||||
} else {
|
||||
|
|
@ -41,8 +44,8 @@ class Wootook_Core_Layout
|
|||
}
|
||||
$this->_data = array();
|
||||
|
||||
$this->setPackage(Wootook::getConfig('global/package'));
|
||||
$this->setTheme(Wootook::getConfig('global/theme'));
|
||||
$this->setPackage(Wootook::getConfig('package'));
|
||||
$this->setTheme(Wootook::getConfig('theme'));
|
||||
|
||||
foreach ($fileList as $layoutFile) {
|
||||
foreach (include $this->_getLayoutPath($layoutFile) as $layoutId => $layoutConfig) {
|
||||
|
|
@ -186,12 +189,12 @@ class Wootook_Core_Layout
|
|||
$className = $namespace . $block;
|
||||
$fileName = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $block) . '.php';
|
||||
|
||||
Wootook_Core_ErrorProfiler::sleep();
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->sleep();
|
||||
if (!($fp = @fopen($fileName, 'r', true))) {
|
||||
Wootook_Core_ErrorProfiler::wakeup();
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
|
||||
continue;
|
||||
}
|
||||
Wootook_Core_ErrorProfiler::wakeup();
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
|
||||
fclose($fp);
|
||||
|
||||
if (!class_exists($className, true)) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@
|
|||
class Wootook_Core_Model_Config
|
||||
extends Wootook_Core_Entity_SubTable
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
||||
protected $_eventPrefix = 'core.config';
|
||||
protected $_eventObject = 'config';
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@ abstract class Wootook_Core_Model_Config_Abstract
|
|||
{
|
||||
protected function _initData($filename)
|
||||
{
|
||||
$config = Wootook::getConfig('global/storyline');
|
||||
$config = Wootook::getConfig('storyline');
|
||||
|
||||
if ($config === null || empty($config)) {
|
||||
if ($config === null) {
|
||||
$config = array(
|
||||
'universe' => 'default',
|
||||
'episode' => 'default'
|
||||
);
|
||||
} else {
|
||||
$config = $config->toArray();
|
||||
}
|
||||
|
||||
$path = 'gamedata' . DIRECTORY_SEPARATOR . $config['universe'] . DIRECTORY_SEPARATOR
|
||||
|
|
|
|||
23
application/code/core/Wootook/Core/Model/Game.php
Normal file
23
application/code/core/Wootook/Core/Model/Game.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
*
|
||||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Core_Model_Game
|
||||
extends Wootook_Core_Entity
|
||||
{
|
||||
const DEFAULT_CODE = 'default';
|
||||
|
||||
protected $_eventPrefix = 'core.game';
|
||||
protected $_eventObject = 'game';
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
$this->_tableName = 'core_game';
|
||||
$this->_idFieldName = 'game_id';
|
||||
}
|
||||
}
|
||||
|
|
@ -51,15 +51,16 @@ class Wootook_Core_Model_Session
|
|||
}
|
||||
|
||||
$this->_data = &$_SESSION[$namespace];
|
||||
$this->_data['messages'] = array();
|
||||
if (!isset($this->_data['messages'])) {
|
||||
$this->_data['messages'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
public function getMessages($clear = true)
|
||||
{
|
||||
$messages = $this->_data['messages'];
|
||||
if ($clear == true) {
|
||||
var_dump($this->_data['messages']);
|
||||
//$this->_data['messages'] = array();
|
||||
$this->_data['messages'] = array();
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
|
|
|
|||
23
application/code/core/Wootook/Core/Model/Website.php
Normal file
23
application/code/core/Wootook/Core/Model/Website.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
*
|
||||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Core_Model_Website
|
||||
extends Wootook_Core_Entity
|
||||
{
|
||||
const DEFAULT_CODE = 'default';
|
||||
|
||||
protected $_eventPrefix = 'core.website';
|
||||
protected $_eventObject = 'website';
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
$this->_tableName = 'core_website';
|
||||
$this->_idFieldName = 'website_id';
|
||||
}
|
||||
}
|
||||
|
|
@ -55,10 +55,10 @@ class Wootook_Core_Setup_Updater
|
|||
|
||||
public function grant($tableName, $connectionName, $perms = null)
|
||||
{
|
||||
$hostname = Wootook::getConfig("global/database/{$connectionName}/params/hostname");
|
||||
$username = Wootook::getConfig("global/database/{$connectionName}/params/username");
|
||||
$database = Wootook::getConfig("global/database/{$connectionName}/params/database");
|
||||
$password = Wootook::getConfig("global/database/{$connectionName}/params/password");
|
||||
$hostname = Wootook::getConfig("database/{$connectionName}/params/hostname");
|
||||
$username = Wootook::getConfig("database/{$connectionName}/params/username");
|
||||
$database = Wootook::getConfig("database/{$connectionName}/params/database");
|
||||
$password = Wootook::getConfig("database/{$connectionName}/params/password");
|
||||
|
||||
if ($perms === null) {
|
||||
$perms = 'ALL PRIVILEGES';
|
||||
|
|
@ -79,10 +79,10 @@ SQL_EOF;
|
|||
|
||||
public function revoke($tableName, $connectionName, $perms = null)
|
||||
{
|
||||
$hostname = Wootook::getConfig("global/database/{$connectionName}/params/hostname");
|
||||
$username = Wootook::getConfig("global/database/{$connectionName}/params/username");
|
||||
$database = Wootook::getConfig("global/database/{$connectionName}/params/database");
|
||||
$password = Wootook::getConfig("global/database/{$connectionName}/params/password");
|
||||
$hostname = Wootook::getConfig("database/{$connectionName}/params/hostname");
|
||||
$username = Wootook::getConfig("database/{$connectionName}/params/username");
|
||||
$database = Wootook::getConfig("database/{$connectionName}/params/database");
|
||||
$password = Wootook::getConfig("database/{$connectionName}/params/password");
|
||||
|
||||
if ($perms === null) {
|
||||
$perms = 'ALL PRIVILEGES';
|
||||
|
|
@ -111,10 +111,13 @@ SQL_EOF;
|
|||
return Wootook::getConfig($path);
|
||||
}
|
||||
|
||||
public function getGameConfig($path)
|
||||
public function getWebsiteConfig($path = null, $websiteId = null)
|
||||
{
|
||||
$config = Wootook_Core_Model_Config::getSingleton();
|
||||
return Wootook::getWebsiteConfig($path, $websiteId);
|
||||
}
|
||||
|
||||
return $config->getData($path);
|
||||
public function getGameConfig($path = null, $gameId = null)
|
||||
{
|
||||
return Wootook::getGameConfig($path, $gameId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class Wootook_Core_Time
|
|||
public static function init($timezone = null)
|
||||
{
|
||||
if ($timezone === null) {
|
||||
$timezone = Wootook::getConfig('global/date/timezone');
|
||||
$timezone = Wootook::getConfig('date/timezone');
|
||||
}
|
||||
if ($timezone === null) {
|
||||
$timezone = 'GMT';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://www.wootook.com/
|
||||
*
|
||||
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
$this->setSetupConnection('core_setup');
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('core_website')} (
|
||||
`website_id` TINYINT UNSIGNED NOT NULL,
|
||||
`code` VARCHAR(64) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`sort_order` TINYINT UNSIGNED NOT NULL,
|
||||
`default_group_id` TINYINT UNSIGNED NOT NULL,
|
||||
`is_default` BOOL NOT NULL,
|
||||
`is_staging` BOOL NOT NULL,
|
||||
`is_active` BOOL NOT NULL,
|
||||
PRIMARY KEY (`website_id`),
|
||||
UNIQUE (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('core_game_group')} (
|
||||
`group_id` TINYINT UNSIGNED NOT NULL,
|
||||
`website_id` TINYINT UNSIGNED NOT NULL,
|
||||
`code` VARCHAR(64) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`sort_order` TINYINT UNSIGNED NOT NULL,
|
||||
`is_default` BOOL NOT NULL,
|
||||
PRIMARY KEY (`group_id`),
|
||||
INDEX (`website_id`),
|
||||
UNIQUE (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('core_game')} (
|
||||
`game_id` SMALLINT UNSIGNED NOT NULL,
|
||||
`group_id` TINYINT UNSIGNED NOT NULL,
|
||||
`website_id` TINYINT UNSIGNED NOT NULL,
|
||||
`code` VARCHAR(64) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`sort_order` TINYINT UNSIGNED NOT NULL,
|
||||
`is_default` BOOL NOT NULL,
|
||||
`is_staging` BOOL NOT NULL,
|
||||
`is_active` BOOL NOT NULL,
|
||||
PRIMARY KEY (`group_id`),
|
||||
INDEX (`website_id`),
|
||||
UNIQUE (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('core_website')} (`website_id`, `code`, `name`, `sort_order`, `default_group_id`, `is_default`, `is_staging`, `is_active`)
|
||||
VALUES
|
||||
(0, "admin", "Administration", 0, 0, 0, 0, 1),
|
||||
(1, "default", "Default Website", 1, 1, 1, 0, 1);
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('core_game_group')} (`group_id`, `website_id`, `code`, `name`, `sort_order`, `is_default`)
|
||||
VALUES
|
||||
(0, 0, "admin", "Administration", 0, 0),
|
||||
(1, 1, "default", "Default Group", 1, 1);
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('core_game')} (`game_id`, `group_id`, `website_id`, `code`, `name`, `sort_order`, `is_default`, `is_staging`, `is_active`)
|
||||
VALUES
|
||||
(0, 0, 0, "admin", "Administration", 0, 0, 0, 1),
|
||||
(1, 1, 1, "default", "Default Game", 1, 1, 0, 1);
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('core_config')} (
|
||||
`website_id` TINYINT UNSIGNED NOT NULL,
|
||||
`game_id` TINYINT UNSIGNED NOT NULL,
|
||||
`config_path` VARCHAR(64) NOT NULL,
|
||||
`config_value` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`website_id`, `game_id`, `config_path`),
|
||||
INDEX (`website_id`),
|
||||
INDEX (`game_id`),
|
||||
INDEX (`config_path`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT IGNORE INTO {$this->getTableName('core_config')} (`website_id`, `game_id`, `config_path`, `config_value`) VALUES
|
||||
(1, 1, 'resource/base-income/metal', '20'),
|
||||
(1, 1, 'resource/base-income/cristal', '10'),
|
||||
(1, 1, 'resource/base-income/deuterium', '0'),
|
||||
(1, 1, 'resource/base-income/energy', '0'),
|
||||
|
||||
(1, 1, 'resource/initial/fields', '163'),
|
||||
(1, 1, 'resource/initial/metal', '500'),
|
||||
(1, 1, 'resource/initial/cristal', '500'),
|
||||
(1, 1, 'resource/initial/deuterium', '0'),
|
||||
(1, 1, 'resource/initial/energy', '0'),
|
||||
|
||||
(1, 1, 'game/general/name', 'Wootook'),
|
||||
(1, 1, 'game/general/boards-url', 'http://wootook.org/board/'),
|
||||
(1, 1, 'game/general/extra-url-title', 'Wootook!'),
|
||||
(1, 1, 'game/general/extra-url', 'http://wootook.org/'),
|
||||
(1, 1, 'game/general/active', '1'),
|
||||
(1, 1, 'game/general/closing-message', 'Le jeu est clos pour le moment.'),
|
||||
(1, 1, 'game/general/locale', 'fr_FR'),
|
||||
|
||||
(1, 1, 'game/resource/multiplier', '1000'),
|
||||
(1, 1, 'game/speed/general', '2500'),
|
||||
(1, 1, 'game/speed/fleet', '2500'),
|
||||
|
||||
(1, 1, 'game/debris/metal-percent', '30'),
|
||||
(1, 1, 'game/debris/cristal-percent', '30'),
|
||||
(1, 1, 'game/debris/deuterium-percent', '0'),
|
||||
(1, 1, 'game/debris/energy-percent', '0'),
|
||||
|
||||
(1, 1, 'game/debris/fleet', '1'),
|
||||
(1, 1, 'game/debris/defense', '0'),
|
||||
|
||||
(1, 1, 'game/noob-protection/active', '0'),
|
||||
(1, 1, 'game/noob-protection/points-cap', '5000'),
|
||||
(1, 1, 'game/noob-protection/multiplier', '5'),
|
||||
|
||||
(0, 0, 'web/cookie/name', '__wtk'),
|
||||
(0, 0, 'web/cookie/time', '2592000'),
|
||||
(0, 0, 'web/cookie/domain', ''),
|
||||
(0, 0, 'web/cookie/path', ''),
|
||||
|
||||
(0, 0, 'engine/options/bbcode', '1'),
|
||||
(0, 0, 'engine/options/ga', '1'),
|
||||
(0, 0, 'engine/options/announces', '0'),
|
||||
(0, 0, 'engine/options/retailer', '0'),
|
||||
(0, 0, 'engine/options/notes', '0'),
|
||||
(0, 0, 'engine/options/chat', '0'),
|
||||
(0, 0, 'engine/options/banner', '0'),
|
||||
(0, 0, 'engine/options/vacation-min-time', '172800'),
|
||||
|
||||
(0, 0, 'game/news/active', '0'),
|
||||
(0, 0, 'game/news/content', 'Bienvenue sur le nouveau serveur de jeu Wootook!'),
|
||||
|
||||
(0, 0, 'engine/ban/duration', '86400'),
|
||||
|
||||
(0, 0, 'engine/bot/active', '0'),
|
||||
(0, 0, 'engine/bot/name', 'Woot'),
|
||||
(0, 0, 'engine/bot/email', 'contact@wootook.org');
|
||||
SQL_EOF;
|
||||
/**
|
||||
* TODO: change these paths
|
||||
* (0, 0, 'BuildLabWhileRun', '0')
|
||||
* (0, 0, 'ExtCopyFrame', '0')
|
||||
* (0, 0, 'ExtCopyOwner', '')
|
||||
* (0, 0, 'ExtCopyFunct', '')
|
||||
*/
|
||||
|
||||
$this->query($sql);
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license Modified BSD
|
||||
* @see https://github.com/gplanchat/one.platform
|
||||
*
|
||||
* Copyright (c) 2009-2010, Grégory PLANCHAT <g.planchat at gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of Grégory PLANCHAT nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing One.Platform.
|
||||
*
|
||||
*/
|
||||
|
||||
$this->setSetupConnection('legacies_setup');
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('core_website')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('core_game_group')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('core_game')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
DROP TABLE {$this->getTableName('core_config')};
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
|
@ -4,4 +4,22 @@ class Wootook_Empire_Exception_Exception
|
|||
extends Exception
|
||||
implements Wootook_Empire_Exception
|
||||
{
|
||||
protected $_previous = null;
|
||||
|
||||
public function __construct($message = null, $code = null, $previous = null)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 50300) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
} else {
|
||||
parent::__construct($message, $code);
|
||||
$this->_previous = $previous;
|
||||
}
|
||||
}
|
||||
|
||||
public function __call($method, $params)
|
||||
{
|
||||
if (strtolower($method) == 'getprevious') {
|
||||
return $this->_previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,4 +4,22 @@ class Wootook_Empire_Exception_RuntimeException
|
|||
extends RuntimeException
|
||||
implements Wootook_Empire_Exception
|
||||
{
|
||||
protected $_previous = null;
|
||||
|
||||
public function __construct($message = null, $code = null, $previous = null)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 50300) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
} else {
|
||||
parent::__construct($message, $code);
|
||||
$this->_previous = $previous;
|
||||
}
|
||||
}
|
||||
|
||||
public function __call($method, $params)
|
||||
{
|
||||
if (strtolower($method) == 'getprevious') {
|
||||
return $this->_previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -960,7 +960,7 @@ class Wootook_Empire_Model_Planet
|
|||
$key = array_rand($positions, 1);
|
||||
$finalPosition = $positions[$key];
|
||||
|
||||
$user->createNewPlanet(
|
||||
$planet = $user->createNewPlanet(
|
||||
$systemInfo->getData('galaxy'),
|
||||
$systemInfo->getData('system'),
|
||||
$finalPosition,
|
||||
|
|
@ -992,10 +992,8 @@ class Wootook_Empire_Model_Planet
|
|||
->group('galaxy.system')
|
||||
;
|
||||
|
||||
$config = Wootook_Core_Model_Config::getSingleton();
|
||||
|
||||
if ($galaxyList === null && $config->hasData('user/registration/galaxy_list')) {
|
||||
$galaxyList = explode(',', $config->getData('user/registration/galaxy_list'));
|
||||
if ($galaxyList === null && Wootook::getGameConfig('user/registration/galaxy_list')) {
|
||||
$galaxyList = explode(',', Wootook::getGameConfig('user/registration/galaxy_list'));
|
||||
}
|
||||
|
||||
if ($galaxyList !== null) {
|
||||
|
|
@ -1003,8 +1001,8 @@ class Wootook_Empire_Model_Planet
|
|||
$collection->where('galaxy.galaxy IN(' . implode(', ', $galaxyList) . ')');
|
||||
}
|
||||
|
||||
if ($systemList === null && $config->hasData('user/registration/system_list')) {
|
||||
$systemList = explode(',', $config->getData('user/registration/system_list'));
|
||||
if ($systemList === null && Wootook::getGameConfig('user/registration/system_list')) {
|
||||
$systemList = explode(',', Wootook::getGameConfig('user/registration/system_list'));
|
||||
}
|
||||
|
||||
if ($systemList !== null) {
|
||||
|
|
|
|||
|
|
@ -252,9 +252,9 @@ class Wootook_Empire_Model_User
|
|||
$size = mt_rand(floor($factor / 10), ceil($factor * 5 / 4)) + mt_rand(0, $fuzz);
|
||||
}
|
||||
|
||||
$planet = new self();
|
||||
$planet = new Wootook_Empire_Model_Planet();
|
||||
$planet
|
||||
->setData('id_owner', $user->getId())
|
||||
->setData('id_owner', $this->getId())
|
||||
->setData('name', $name)
|
||||
->setData('galaxy', $galaxy)
|
||||
->setData('system', $system)
|
||||
|
|
@ -271,12 +271,19 @@ class Wootook_Empire_Model_User
|
|||
$planet->setData($resourceData['production_field'], $resourceConfig[$resource]);
|
||||
}
|
||||
|
||||
$planet->save();
|
||||
|
||||
var_dump($planet->getId());
|
||||
die();
|
||||
|
||||
Wootook::dispatchEvent('planet.init', array(
|
||||
'planet' => $planet,
|
||||
'user' => $user
|
||||
'user' => $this
|
||||
));
|
||||
|
||||
$planet->save();
|
||||
|
||||
return $planet;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue