Updated installer

Added Website and Game models
Updted config loading

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2011-12-15 22:10:35 +01:00
commit 5393be4daf
39 changed files with 779 additions and 661 deletions

View file

@ -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 {

View file

@ -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);

View file

@ -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();
}
}

View file

@ -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}

View file

@ -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;
}
}

View file

@ -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;
}
}
}

View file

@ -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;
}
}

View file

@ -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)) {

View file

@ -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';

View file

@ -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

View 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';
}
}

View file

@ -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;
}

View 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';
}
}

View file

@ -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);
}
}

View file

@ -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';

View file

@ -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);

View file

@ -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);

View file

@ -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;
}
}
}

View file

@ -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;
}
}
}

View file

@ -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) {

View file

@ -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;
}
/**