Updated install script
Fixed CSS issues Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
5acde87794
commit
4bb4693d2e
26 changed files with 917 additions and 330 deletions
159
application/code/core/Generations/Empire.php
Normal file
159
application/code/core/Generations/Empire.php
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @author Greg
|
||||
*
|
||||
*/
|
||||
|
||||
class Generations_Empire
|
||||
{
|
||||
const TYPE_BUILDING = 'building';
|
||||
const TYPE_RESEARCH = 'technology';
|
||||
const TYPE_SHIP = 'fleet';
|
||||
const TYPE_DEFENSE = 'defense';
|
||||
const TYPE_SPECIAL = 'special';
|
||||
const TYPE_PRODUCTION = 'prodution';
|
||||
const TYPE_FLEET_MISSION = 'mission';
|
||||
|
||||
const RESOURCE_GOLD = 'gold';
|
||||
const RESOURCE_TITANIUM = 'titanium';
|
||||
const RESOURCE_ZIRCONIUM = 'zirconium';
|
||||
const RESOURCE_TRITIUM = 'tritium';
|
||||
const RESOURCE_POPULATION = 'population';
|
||||
const RESOURCE_ENERGY = 'energy';
|
||||
|
||||
const RESOURCE_MULTIPLIER = 'multiplier';
|
||||
const RESOURCE_CLASS = 'class';
|
||||
const BASE_BUILDING_TIME = 'base_time';
|
||||
|
||||
const SHIPS_CONSUMPTION_PRIMARY = 'primary_consumption';
|
||||
const SHIPS_CELERITY_PRIMARY = 'primary_speed';
|
||||
const SHIPS_CONSUMPTION_SECONDARY = 'secondary_consumption';
|
||||
const SHIPS_CELERITY_SECONDARY = 'secondary_speed';
|
||||
const SHIPS_CAPACITY_PRIMARY = 'primary_capacity';
|
||||
const SHIPS_CAPACITY_SECONDARY = 'secondary_capacity';
|
||||
|
||||
const ID_BUILDING_GOLD_MINE = 1;
|
||||
const ID_BUILDING_GERMANUIM_MINE = 2;
|
||||
const ID_BUILDING_DEUTERIUM_SYNTHETISER = 3;
|
||||
const ID_BUILDING_SOLAR_PLANT = 4;
|
||||
const ID_BUILDING_FUSION_REACTOR = 12;
|
||||
const ID_BUILDING_ROBOTIC_FACTORY = 14;
|
||||
const ID_BUILDING_NANITE_FACTORY = 15;
|
||||
const ID_BUILDING_SHIPYARD = 21;
|
||||
const ID_BUILDING_METAL_STORAGE = 22;
|
||||
const ID_BUILDING_CRISTAL_STORAGE = 23;
|
||||
const ID_BUILDING_DEUTERIUM_TANK = 24;
|
||||
const ID_BUILDING_RESEARCH_LAB = 31;
|
||||
const ID_BUILDING_TERRAFORMER = 33;
|
||||
const ID_BUILDING_ALLIANCE_DEPOT = 34;
|
||||
const ID_BUILDING_LUNAR_BASE = 41;
|
||||
const ID_BUILDING_SENSOR_PHALANX = 42;
|
||||
const ID_BUILDING_JUMP_GATE = 43;
|
||||
const ID_BUILDING_MISSILE_SILO = 44;
|
||||
|
||||
const ID_RESEARCH_ESPIONAGE_TECHNOLOGY = 106;
|
||||
const ID_RESEARCH_COMPUTER_TECHNOLOGY = 108;
|
||||
const ID_RESEARCH_WEAPON_TECHNOLOGY = 109;
|
||||
const ID_RESEARCH_SHIELDING_TECHNOLOGY = 110;
|
||||
const ID_RESEARCH_ARMOUR_TECHNOLOGY = 111;
|
||||
const ID_RESEARCH_ENERGY_TECHNOLOGY = 113;
|
||||
const ID_RESEARCH_HYPERSPACE_TECHNOLOGY = 114;
|
||||
const ID_RESEARCH_COMBUSTION_DRIVE = 115;
|
||||
const ID_RESEARCH_IMPULSE_DRIVE = 117;
|
||||
const ID_RESEARCH_HYPERSPACE_DRIVE = 118;
|
||||
const ID_RESEARCH_LASER_TECHNOLOGY = 120;
|
||||
const ID_RESEARCH_ION_TECHNOLOGY = 121;
|
||||
const ID_RESEARCH_PLASMA_TECHNOLOGY = 122;
|
||||
const ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK = 123;
|
||||
const ID_RESEARCH_EXPEDITION_TECHNOLOGY = 124;
|
||||
const ID_RESEARCH_ASTROPHYSICS = 124;
|
||||
const ID_RESEARCH_GRAVITON_TECHNOLOGY = 199;
|
||||
|
||||
const ID_SHIP_LIGHT_TRANSPORT = 202;
|
||||
const ID_SHIP_LARGE_TRANSPORT = 203;
|
||||
const ID_SHIP_LIGHT_FIGHTER = 204;
|
||||
const ID_SHIP_HEAVY_FIGHTER = 205;
|
||||
const ID_SHIP_CRUISER = 206;
|
||||
const ID_SHIP_BATTLESHIP = 207;
|
||||
const ID_SHIP_COLONY_SHIP = 208;
|
||||
const ID_SHIP_RECYCLER = 209;
|
||||
const ID_SHIP_SPY_DRONE = 210;
|
||||
const ID_SHIP_BOMBER = 211;
|
||||
const ID_SHIP_SOLAR_SATELLITE = 212;
|
||||
const ID_SHIP_DESTRUCTOR = 213;
|
||||
const ID_SHIP_DEATH_STAR = 214;
|
||||
const ID_SHIP_BATTLECRUISER = 215;
|
||||
const ID_SHIP_SUPERNOVA = 216;
|
||||
|
||||
const ID_DEFENSE_ROCKET_LAUNCHER = 401;
|
||||
const ID_DEFENSE_LIGHT_LASER = 402;
|
||||
const ID_DEFENSE_HEAVY_LASER = 403;
|
||||
const ID_DEFENSE_ION_CANNON = 404;
|
||||
const ID_DEFENSE_GAUSS_CANNON = 405;
|
||||
const ID_DEFENSE_PLASMA_TURRET = 406;
|
||||
const ID_DEFENSE_SMALL_SHIELD_DOME = 407;
|
||||
const ID_DEFENSE_LARGE_SHIELD_DOME = 408;
|
||||
|
||||
const ID_SPECIAL_ANTIBALLISTIC_MISSILE = 502;
|
||||
const ID_SPECIAL_INTERPLANETARY_MISSILE = 503;
|
||||
|
||||
const ID_COMBAT_SHIELDS = 'shield';
|
||||
const ID_COMBAT_FIREPOWER = 'attack';
|
||||
const ID_COMBAT_RAPID_FIRE = 'rapidfire';
|
||||
|
||||
const ID_MISSION_ATTACK = 1;
|
||||
const ID_MISSION_GROUP_ATTACK = 2;
|
||||
const ID_MISSION_TRANSPORT = 3;
|
||||
const ID_MISSION_STATION = 4;
|
||||
const ID_MISSION_STATION_ALLY = 5;
|
||||
const ID_MISSION_SPY = 6;
|
||||
const ID_MISSION_SETTLE_COLONY = 7;
|
||||
const ID_MISSION_RECYCLE = 8;
|
||||
const ID_MISSION_DESTROY = 9;
|
||||
const ID_MISSION_MISSILES = 10;
|
||||
const ID_MISSION_BLOCUS = 11;
|
||||
const ID_MISSION_BLOCUS = 11;
|
||||
const ID_MISSION_EXPEDITION = 15;
|
||||
|
||||
public static function getFieldName($id)
|
||||
{
|
||||
$fieldsAlias = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
|
||||
if (!isset($fieldsAlias[$id])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $fieldsAlias[$id];
|
||||
}
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
$this->setSetupConnection('core_setup');
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/aks')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('aks')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(50) NULL,
|
||||
`teilnehmer` TEXT NULL,
|
||||
|
|
@ -48,7 +48,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/alliance')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('alliance')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`ally_name` VARCHAR(32) NOT NULL,
|
||||
`ally_tag` VARCHAR(8) NOT NULL,
|
||||
|
|
@ -71,7 +71,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/annonce')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('annonce')} (
|
||||
`id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user` TEXT NOT NULL,
|
||||
`galaxie` TINYINT UNSIGNED NOT NULL,
|
||||
|
|
@ -89,7 +89,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/banned')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('banned')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`who` BIGINT UNSIGNED NOT NULL,
|
||||
`theme` TEXT NOT NULL,
|
||||
|
|
@ -105,7 +105,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/buddy')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('buddy')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`sender` BIGINT UNSIGNED NOT NULL,
|
||||
`owner` BIGINT UNSIGNED NOT NULL,
|
||||
|
|
@ -118,7 +118,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/chat')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('chat')} (
|
||||
`messageid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user` VARCHAR(255) NOT NULL,
|
||||
`message` TEXT NOT NULL,
|
||||
|
|
@ -130,7 +130,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/config')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('config')} (
|
||||
`config_name` VARCHAR(64) NOT NULL,
|
||||
`config_value` TEXT NOT NULL,
|
||||
UNIQUE KEY (`config_name`)
|
||||
|
|
@ -140,32 +140,40 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
INSERT INTO {$this->getTableName('legacies/config')} (`config_name`, `config_value`) VALUES
|
||||
INSERT IGNORE INTO {$this->getTableName('config')} (`config_name`, `config_value`) VALUES
|
||||
-- ('game/1/resource/income/base/metal', '20'),
|
||||
-- ('game/1/resource/income/base/cristal', '10'),
|
||||
-- ('game/1/resource/income/base/deuterium', '0'),
|
||||
-- ('game/1/resource/income/base/energy', '0'),
|
||||
-- ('game/1/resource/multiplier', '1000'),
|
||||
|
||||
-- ('game/1/speed/general', '2500'),
|
||||
-- ('game/1/speed/fleet', '2500'),
|
||||
|
||||
('game_speed', '2500'),
|
||||
('fleet_speed', '2500'),
|
||||
('resource_multiplier', '1000'),
|
||||
('Fleet_Cdr', '30'),
|
||||
('Defs_Cdr', '30'),
|
||||
('initial_fields', '5000'),
|
||||
('COOKIE_NAME', 'xnova-legacies'),
|
||||
('game_name', 'Wootook:Legacies'),
|
||||
('game_disable', '1'),
|
||||
('close_reason', 'Le jeu est clos pour le moment!'),
|
||||
|
||||
('metal_basic_income', '20'),
|
||||
('cristal_basic_income', '10'),
|
||||
('deuterium_basic_income', '0'),
|
||||
('energy_basic_income', '0'),
|
||||
|
||||
('Fleet_Cdr', '30'),
|
||||
('Defs_Cdr', '30'),
|
||||
('initial_fields', '5000'),
|
||||
('COOKIE_NAME', 'wootook'),
|
||||
('game_name', 'Wootook'),
|
||||
('game_disable', '1'),
|
||||
('close_reason', 'Le jeu est clos pour le moment!'),
|
||||
('BuildLabWhileRun', '0'),
|
||||
('LastSettedGalaxyPos', '1'),
|
||||
('LastSettedSystemPos', '1'),
|
||||
('LastSettedPlanetPos', '1'),
|
||||
('urlaubs_modus_erz', '1'),
|
||||
('noobprotection', '1'),
|
||||
('noobprotectiontime', '5000'),
|
||||
('noobprotectionmulti', '5'),
|
||||
('forum_url', 'http://board.xnova-ng.org/'),
|
||||
('OverviewNewsFrame', '1'),
|
||||
('OverviewNewsTEXT', 'Bienvenue sur le nouveau serveur Wootook Legacies'),
|
||||
('OverviewNewsTEXT', 'Bienvenue sur le nouveau serveur Wootook'),
|
||||
('OverviewExternChat', '0'),
|
||||
('OverviewExternChatCmd', ''),
|
||||
('OverviewBanner', '0'),
|
||||
|
|
@ -182,18 +190,17 @@ INSERT INTO {$this->getTableName('legacies/config')} (`config_name`, `config_val
|
|||
('enable_marchand', '1'),
|
||||
('enable_notes', '1'),
|
||||
('bot_name', 'XNoviana Reali'),
|
||||
('bot_adress', 'xnova@xnova.fr'),
|
||||
('bot_adress', 'contact@wootook.org'),
|
||||
('banner_source_post', '../images/bann.png'),
|
||||
('ban_duration', '30'),
|
||||
('enable_bot', '0'),
|
||||
('enable_bbcode', '1'),
|
||||
('debug', '0');
|
||||
('enable_bbcode', '1');
|
||||
SQL_EOF;
|
||||
|
||||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/declared')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('declared')} (
|
||||
`declarator` TEXT NOT NULL,
|
||||
`declared_1` TEXT NOT NULL,
|
||||
`declared_2` TEXT NOT NULL,
|
||||
|
|
@ -206,7 +213,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/errors')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('errors')} (
|
||||
`error_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`error_sender` VARCHAR(32) NOT NULL,
|
||||
`error_time` TIMESTAMP NOT NULL,
|
||||
|
|
@ -219,7 +226,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/fleets')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('fleets')} (
|
||||
`fleet_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`fleet_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`fleet_mission` TINYINT UNSIGNED NOT NULL,
|
||||
|
|
@ -251,7 +258,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/galaxy')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('galaxy')} (
|
||||
`galaxy` TINYINT UNSIGNED NOT NULL,
|
||||
`system` SMALLINT UNSIGNED NOT NULL,
|
||||
`planet` TINYINT UNSIGNED NOT NULL,
|
||||
|
|
@ -270,7 +277,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/iraks')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('iraks')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`zeit` TIMESTAMP NOT NULL,
|
||||
`galaxy` TINYINT UNSIGNED NOT NULL,
|
||||
|
|
@ -290,7 +297,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/lunas')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('lunas')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_luna` BIGINT UNSIGNED NOT NULL,
|
||||
`name` VARCHAR(100) NOT NULL DEFAULT 'Lune',
|
||||
|
|
@ -310,7 +317,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/messages')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('messages')} (
|
||||
`message_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`message_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`message_sender` BIGINT UNSIGNED NOT NULL,
|
||||
|
|
@ -326,7 +333,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/multi')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('multi')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`player` BIGINT UNSIGNED NOT NULL,
|
||||
`sharer` BIGINT UNSIGNED NOT NULL,
|
||||
|
|
@ -338,7 +345,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/notes')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('notes')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`owner` BIGINT UNSIGNED NOT NULL,
|
||||
`time` TIMESTAMP NOT NULL,
|
||||
|
|
@ -352,7 +359,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/planets')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('planets')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(100) NOT NULL,
|
||||
`id_owner` BIGINT UNSIGNED NOT NULL,
|
||||
|
|
@ -445,7 +452,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/rw')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('rw')} (
|
||||
`id_owner1` BIGINT UNSIGNED NOT NULL,
|
||||
`id_owner2` BIGINT UNSIGNED NOT NULL,
|
||||
`rid` VARCHAR(72) NOT NULL,
|
||||
|
|
@ -461,7 +468,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/statpoints')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('statpoints')} (
|
||||
`id_owner` BIGINT UNSIGNED NOT NULL,
|
||||
`id_ally` BIGINT UNSIGNED NOT NULL,
|
||||
`stat_type` TINYINT UNSIGNED NOT NULL,
|
||||
|
|
@ -498,7 +505,7 @@ SQL_EOF;
|
|||
$this->query($sql);
|
||||
|
||||
$sql = <<<SQL_EOF
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/users')} (
|
||||
CREATE TABLE IF NOT EXISTS {$this->getTableName('users')} (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`username` VARCHAR(100) NOT NULL, -- FIXME
|
||||
`password` VARCHAR(64) NOT NULL, -- FIXME
|
||||
|
|
@ -287,20 +287,22 @@ class Wootook
|
|||
self::$_response = $response;
|
||||
}
|
||||
|
||||
private static function _loadConfig()
|
||||
public static function loadConfig()
|
||||
{
|
||||
if (self::$_config === null) {
|
||||
self::$_config = include ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php';
|
||||
self::$_config = include ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php';
|
||||
|
||||
if (!is_array(self::$_config)) {
|
||||
self::$_config = array();
|
||||
}
|
||||
if (!is_array(self::$_config)) {
|
||||
self::$_config = array();
|
||||
}
|
||||
|
||||
return self::$_config;
|
||||
}
|
||||
|
||||
public static function getConfig($path = null)
|
||||
{
|
||||
self::_loadConfig();
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
if ($path === null || !is_string($path)) {
|
||||
return self::$_config;
|
||||
|
|
@ -317,7 +319,9 @@ class Wootook
|
|||
|
||||
public static function setConfig($path, $value)
|
||||
{
|
||||
self::_loadConfig();
|
||||
if (self::$_config === null) {
|
||||
self::loadConfig();
|
||||
}
|
||||
|
||||
if ($path === null || !is_string($path)) {
|
||||
return self::$_config = $value;
|
||||
|
|
@ -338,6 +342,8 @@ class Wootook
|
|||
{
|
||||
file_put_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php',
|
||||
'<' . '?p' . 'hp ' . var_export($config, true) . ';');
|
||||
|
||||
self::$_config = $config;
|
||||
}
|
||||
|
||||
public static function getBaseUrl()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Setup_Exception_RuntimeException
|
||||
extends Wootook_Core_Exception_RuntimeException
|
||||
implements Wootook_Core_Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Setup_Exception_VersionStageError
|
||||
extends Wootook_Core_Setup_Exception_RuntimeException
|
||||
implements Wootook_Core_Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Setup_Exception_VersionValueError
|
||||
extends Wootook_Core_Setup_Exception_RuntimeException
|
||||
implements Wootook_Core_Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -29,14 +29,28 @@ class Wootook_Core_Setup_Updater
|
|||
public function getSetupConnection()
|
||||
{
|
||||
if ($this->_setupConnection === null) {
|
||||
return Wootook_Database::getSingleton();
|
||||
$this->setSetupConnection('default');
|
||||
}
|
||||
return $this->_setupConnection;
|
||||
}
|
||||
|
||||
public function getTable($tableName)
|
||||
public function getTableName($tableName)
|
||||
{
|
||||
$this->getSetupConnection()->getTable($tableName);
|
||||
return $this->getSetupConnection()->getTable($tableName);
|
||||
}
|
||||
|
||||
public function query($statement)
|
||||
{
|
||||
try {
|
||||
if (!$this->getSetupConnection()->query($statement)) {
|
||||
$info = $this->getSetupConnection()->errorInfo();
|
||||
throw new Wootook_Core_Setup_Exception_RuntimeException(
|
||||
Wootook::__('Query failed: SQLSTATE %s: %s.', $info[1], $info[2]));
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
|
||||
throw new Wootook_Core_Setup_Exception_RuntimeException($e->getMessage(), null, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function grant($tableName, $connectionName, $perms = null)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Setup_Model_Updater_ScriptQueue
|
||||
class Wootook_Core_Setup_Updater_ScriptQueue
|
||||
implements Iterator, Countable, ArrayAccess
|
||||
{
|
||||
const PCRE_FILE_PATTERN = '%^(?<action>install|upgrade|uninstall|downgrade)-(?<version1>[0-9]+\.[0-9]+\.[0-9]+)(?:\.(?<stage1>[a-z]+)(?<level1>[0-9]+))?(?:-(?<version2>[0-9]+\.[0-9]+\.[0-9]+)(?:\.(?<stage2>[a-z]+)(?<level2>[0-9]+))?)?$%';
|
||||
|
|
@ -36,27 +36,35 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
|
|||
}
|
||||
|
||||
if ($fromVersion === null) {
|
||||
$fromVersion = '0.0.0';
|
||||
$fromVersion = array(
|
||||
'version' => self::VERSION_NULL,
|
||||
'stage' => self::STAGE_STABLE,
|
||||
'level' => 0,
|
||||
);
|
||||
} else {
|
||||
preg_match(self::PCRE_VERSION_PATTERN, $fromVersion, $matches);
|
||||
$fromVersion = array(
|
||||
'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL,
|
||||
'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE,
|
||||
'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0,
|
||||
);
|
||||
}
|
||||
|
||||
if ($toVersion === null) {
|
||||
$toVersion = '0.0.0';
|
||||
$toVersion = array(
|
||||
'version' => self::VERSION_NULL,
|
||||
'stage' => self::STAGE_STABLE,
|
||||
'level' => 0,
|
||||
);
|
||||
} else {
|
||||
preg_match(self::PCRE_VERSION_PATTERN, $toVersion, $matches);
|
||||
$toVersion = array(
|
||||
'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL,
|
||||
'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE,
|
||||
'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0,
|
||||
);
|
||||
}
|
||||
|
||||
preg_match(self::PCRE_VERSION_PATTERN, $fromVersion, $matches);
|
||||
$fromVersion = array(
|
||||
'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL,
|
||||
'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE,
|
||||
'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0,
|
||||
);
|
||||
|
||||
preg_match(self::PCRE_VERSION_PATTERN, $toVersion, $matches);
|
||||
$toVersion = array(
|
||||
'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL,
|
||||
'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE,
|
||||
'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0,
|
||||
);
|
||||
|
||||
switch (version_compare($toVersion['version'], $fromVersion['version'])) {
|
||||
case 1:
|
||||
$this->_upgradeToVersion($fromVersion, $toVersion);
|
||||
|
|
@ -110,7 +118,7 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
|
|||
$this->_upgradeToVersion($fromVersion, $toVersion);
|
||||
}
|
||||
} else {
|
||||
throw new Wootook_Core_Exception_RuntimeException("Invalid version stage.");
|
||||
throw new Wootook_Core_Setup_Exception_VersionStageError("Invalid version stage.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -123,6 +131,13 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
|
|||
return $this->_finalVersion;
|
||||
}
|
||||
|
||||
public function getCurrentVersion()
|
||||
{
|
||||
$current = $this->current();
|
||||
|
||||
return $current['version'];
|
||||
}
|
||||
|
||||
protected function _installHighestInstaller($currentVersion, $toVersion)
|
||||
{
|
||||
$highestVersion = self::VERSION_NULL;
|
||||
|
|
@ -143,14 +158,16 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
|
|||
return $version;
|
||||
}
|
||||
|
||||
if (isset($this->_installVersions[$highestVersion][self::STAGE_RC])) {
|
||||
if (isset($this->_installVersions[$highestVersion][self::STAGE_STABLE])) {
|
||||
$stage = self::STAGE_STABLE;
|
||||
} else if (isset($this->_installVersions[$highestVersion][self::STAGE_RC])) {
|
||||
$stage = self::STAGE_RC;
|
||||
} else if (isset($this->_installVersions[$highestVersion][self::STAGE_BETA])) {
|
||||
$stage = self::STAGE_BETA;
|
||||
} else if (isset($this->_installVersions[$highestVersion][self::STAGE_ALPHA])) {
|
||||
$stage = self::STAGE_ALPHA;
|
||||
} else {
|
||||
throw new Wootook_Core_Exception_RuntimeException("Invalid version stage.");
|
||||
throw new Wootook_Core_Setup_Exception_VersionStageError("Invalid version stage.");
|
||||
}
|
||||
|
||||
$levelList = array_keys($this->_installVersions[$highestVersion][$stage]);
|
||||
|
|
@ -232,7 +249,7 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
|
|||
|
||||
$level = max(array_keys($versionPointer[$highestVersion][$stage]));
|
||||
} else {
|
||||
throw new Wootook_Core_Exception_RuntimeException("Invalid version value.");
|
||||
throw new Wootook_Core_Setup_Exception_VersionValueError("Invalid version value.");
|
||||
}
|
||||
|
||||
$currentVersion = array(
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ class Wootook_Database
|
|||
protected static $_connectionAliases = array();
|
||||
|
||||
protected $_tablePrefix = null;
|
||||
protected $_dsn = null;
|
||||
protected $_username = null;
|
||||
protected $_password = null;
|
||||
|
||||
public static $options = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||
|
|
@ -51,8 +54,9 @@ class Wootook_Database
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!($port = Wootook::getConfig("global/database/{$connectionName}/params/port")) || !is_numeric($port)) {
|
||||
$port = 3306;
|
||||
$dsn = "mysql:dbname={$database};host={$hostname}";
|
||||
if (($port = Wootook::getConfig("global/database/{$connectionName}/params/port")) && is_numeric($port)) {
|
||||
$dsn .= ";port={$port}";
|
||||
}
|
||||
|
||||
$event = Wootook::dispatchEvent('database.prepare-options', array(
|
||||
|
|
@ -62,7 +66,10 @@ class Wootook_Database
|
|||
|
||||
$options = $event->getData('options');
|
||||
|
||||
$connection = new self("mysql:dbname={$database};host={$hostname};port={$port}", $username, $password, $options);
|
||||
$connection = new self($dsn, $username, $password, $options);
|
||||
$connection->_dsn = $dsn;
|
||||
$connection->_username = $username;
|
||||
$connection->_password = $password;
|
||||
|
||||
if (($prefix = Wootook::getConfig("global/database/{$connectionName}/table_prefix")) !== null) {
|
||||
$connection->setTablePrefix($prefix);
|
||||
|
|
|
|||
Loading…
Reference in a new issue