Refactored Controller
Refactored Database adapters Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
690a7f60f3
commit
03efb85c0b
76 changed files with 502 additions and 457 deletions
|
|
@ -96,11 +96,11 @@ if (defined('IN_ADMIN')) {
|
|||
include ROOT_PATH . 'includes/constants.php';
|
||||
|
||||
Wootook_Core_ErrorProfiler::register();
|
||||
Wootook_Core_Model_Config_Events::registerEvents();
|
||||
Wootook_Core_Helper_Config_Events::registerEvents();
|
||||
|
||||
if (!defined('IN_INSTALL') && 0 === filesize(APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'local.php')) {
|
||||
if (!defined('IN_INSTALL') && !Wootook::fileExists(APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'local.php')) {
|
||||
Wootook::getResponse()
|
||||
->setRedirect(Wootook::getStaticUrl('install/'), Wootook_Core_Controller_Response_Http::REDIRECT_TEMPORARY)
|
||||
->setRedirect(Wootook::getStaticUrl('install/'), Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_TEMPORARY)
|
||||
->sendHeaders();
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ if (!defined('DISABLE_IDENTITY_CHECK')) {
|
|||
}
|
||||
|
||||
if (!Wootook::getGameConfig('game/general/active') && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) {
|
||||
$layout = new Wootook_Core_Layout(Wootook_Core_Layout::DOMAIN_FRONTEND);
|
||||
$layout = new Wootook_Core_Model_Layout(Wootook_Core_Model_Layout::DOMAIN_FRONTEND);
|
||||
$layout->load('message');
|
||||
|
||||
$block = $layout->getBlock('message');
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class Legacies_Empire
|
|||
|
||||
public static function getFieldName($id)
|
||||
{
|
||||
$fieldsAlias = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fieldsAlias = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
if (!isset($fieldsAlias[$id])) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Legacies_Empire_Block_Planet_ResearchLab
|
|||
|
||||
public function _initChildBlocks()
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
|
||||
/** @var Wootook_Core_Block_Concat $parentBlock */
|
||||
$parentBlock = $this->getLayout()->getBlock('item-list.items');
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class Legacies_Empire_Block_Planet_Shipyard
|
|||
|
||||
public function _initChildBlocks()
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
|
||||
/** @var Wootook_Core_Block_Concat $parentBlock */
|
||||
$parentBlock = $this->getLayout()->getBlock('item-list.items');
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
|
|||
*/
|
||||
public function checkAvailability($technologyId)
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
|
||||
if (!$types->is($technologyId, Legacies_Empire::TYPE_RESEARCH)) {
|
||||
return false;
|
||||
|
|
@ -117,7 +117,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
|
|||
*/
|
||||
public function getBuildingTime($technologyId, $level)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
|
||||
Math::setPrecision(50);
|
||||
$firstLevelTime = $prices[$technologyId][Legacies_Empire::BASE_BUILDING_TIME];
|
||||
|
|
@ -150,8 +150,8 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
|
|||
*/
|
||||
public function getResourcesNeeded($technologyId, $level)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
|
||||
if (!isset($prices[$technologyId])) {
|
||||
return array();
|
||||
|
|
@ -178,7 +178,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
|
|||
*/
|
||||
public function updateQueue(Wootook_Core_DateTime $time)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
$startingTime = clone $this->_currentPlanet->getData(self::FIELD_DATETIME);
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
|
|||
return $this;
|
||||
}
|
||||
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
|
||||
if (!Math::isPositive($level)) {
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
|
|||
*/
|
||||
public function checkAvailability($shipId)
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
|
||||
if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) {
|
||||
return false;
|
||||
|
|
@ -106,9 +106,9 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
|
|||
*/
|
||||
public function getMaximumBuildableElementsCount($shipId)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
|
||||
$qty = 0;
|
||||
foreach ($resources as $resourceId => $_) {
|
||||
|
|
@ -182,7 +182,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
|
|||
*/
|
||||
public function getBuildingTime($shipId, $qty)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
|
||||
Math::setPrecision(50);
|
||||
$buildingTime = Math::mul($prices[$shipId][Legacies_Empire::BASE_BUILDING_TIME], $qty);
|
||||
|
|
@ -210,8 +210,8 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
|
|||
*/
|
||||
public function getResourcesNeeded($shipId, $qty)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
|
||||
if (!isset($prices[$shipId])) {
|
||||
return array();
|
||||
|
|
@ -249,7 +249,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
|
|||
*/
|
||||
public function updateQueue(Wootook_Core_DateTime $time)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
$elapsedTime = $time->getTimestamp() - $this->_currentPlanet->getData('b_hangar')->getTimestamp();
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
|
|||
return $this;
|
||||
}
|
||||
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) {
|
||||
return $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Legacies_Empire_Model_Planet_Ship_LargeTransport
|
|||
|
||||
public function getBaseSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
|
||||
return $prices[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Legacies_Empire_Model_Planet_Ship_LightTransport
|
|||
|
||||
public function getBaseSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
|
||||
if ($player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) {
|
||||
return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class Legacies_Empire_Model_Planet_Ship_Supernova
|
|||
|
||||
public function getBaseSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
|
||||
if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE &&
|
||||
$player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/agpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* 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 Legacies_Officers_Model_Observer
|
||||
{
|
||||
public static function planetUpdateListener($eventData)
|
||||
{
|
||||
if (isset($eventData['planet'])) {
|
||||
$planet = $eventData['planet'];
|
||||
|
||||
$player = $planet->getPlayer();
|
||||
|
||||
$level = floor(sqrt($player->getData('xpminier') / 500));
|
||||
if ($player->getData('lvl_minier') < $level) {
|
||||
$difference = $level - $player->getData('lvl_minier');
|
||||
if ($difference == 1) {
|
||||
Wootook::getSession(Wootook_Player_Model_Entity::SESSION_KEY)
|
||||
->addInfo('You gained 1 miner level.');
|
||||
} else {
|
||||
Wootook::getSession(Wootook_Player_Model_Entity::SESSION_KEY)
|
||||
->addInfo('You gained %1$d miner level.', (int) $difference);
|
||||
}
|
||||
}
|
||||
|
||||
$level = floor(sqrt($player->getData('xpraid')));
|
||||
if ($player->getData('lvl_raid') < $level) {
|
||||
$difference = $level - $player->getData('lvl_raid');
|
||||
if ($difference == 1) {
|
||||
Wootook::getSession(Wootook_Player_Model_Entity::SESSION_KEY)
|
||||
->addInfo('You gained 1 raider level.');
|
||||
} else {
|
||||
Wootook::getSession(Wootook_Player_Model_Entity::SESSION_KEY)
|
||||
->addInfo('You gained %1$d raider level.', (int) $difference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,14 +81,14 @@ class Wootook
|
|||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var Wootook_Core_Config_Adapter_Abstract
|
||||
* @var Wootook_Core_Helper_Config_ConfigHandler
|
||||
*/
|
||||
private static $_config = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var Wootook_Core_Config_Adapter_Abstract
|
||||
* @var Wootook_Core_Helper_Config_ConfigHandler
|
||||
*/
|
||||
private static $_globalConfig = null;
|
||||
|
||||
|
|
@ -296,12 +296,12 @@ class Wootook
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Wootook_Core_Controller_Request_Http
|
||||
* @return Wootook_Core_Mvc_Controller_Request_Http
|
||||
*/
|
||||
public static function getRequest()
|
||||
{
|
||||
if (self::$_request === null) {
|
||||
self::$_request = new Wootook_Core_Controller_Request_Http();
|
||||
self::$_request = new Wootook_Core_Mvc_Controller_Request_Http();
|
||||
}
|
||||
return self::$_request;
|
||||
}
|
||||
|
|
@ -312,12 +312,12 @@ class Wootook
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Wootook_Core_Controller_Response_Http
|
||||
* @return Wootook_Core_Mvc_Controller_Response_Http
|
||||
*/
|
||||
public static function getResponse()
|
||||
{
|
||||
if (self::$_response === null) {
|
||||
self::$_response = new Wootook_Core_Controller_Response_Http();
|
||||
self::$_response = new Wootook_Core_Mvc_Controller_Response_Http();
|
||||
}
|
||||
return self::$_response;
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ class Wootook
|
|||
return $config;
|
||||
}
|
||||
|
||||
$adapter = Wootook_Core_Database::getConnection('core_read');
|
||||
$adapter = Wootook_Core_Database_Adapter_Pdo_Mysql::getConnection('core_read');
|
||||
$select = $adapter->select('core_config');
|
||||
|
||||
switch ($type) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Wootook_Core_App
|
|||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @var Wootook_Core_Config_Adapter_Abstract
|
||||
* @var Wootook_Core_Config_Adapter_Adapter
|
||||
*/
|
||||
private $_globalConfig = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@ class Wootook_Core_Block_Messages
|
|||
foreach ($this->_storages as $namespace) {
|
||||
$session = Wootook::getSession($namespace);
|
||||
|
||||
foreach ($session->getMessages() as $messageLevel => $messageList) {
|
||||
$messageList = $session->getMessages();
|
||||
if (!is_array($messageList)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($messageList as $messageLevel => $messageList) {
|
||||
if (!isset($messages[$messageLevel])) {
|
||||
$messages[$messageLevel] = $messageList;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -16,15 +16,15 @@ class Wootook_Core_Block_Template
|
|||
$package = $this->getLayout()->getPackage();
|
||||
$theme = $this->getLayout()->getTheme();
|
||||
|
||||
if ($package !== Wootook_Core_Layout::DEFAULT_PACKAGE) {
|
||||
if ($theme !== Wootook_Core_Layout::DEFAULT_THEME) {
|
||||
if ($package !== Wootook_Core_Model_Layout::DEFAULT_PACKAGE) {
|
||||
if ($theme !== Wootook_Core_Model_Layout::DEFAULT_THEME) {
|
||||
$path = sprintf($pattern, $package, $theme);
|
||||
if (Wootook::fileExists($path)) {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
$path = sprintf($pattern, $package, Wootook_Core_Layout::DEFAULT_THEME);
|
||||
$path = sprintf($pattern, $package, Wootook_Core_Model_Layout::DEFAULT_THEME);
|
||||
if (Wootook::fileExists($path)) {
|
||||
return $path;
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ class Wootook_Core_Block_Template
|
|||
->addException(new Wootook_Core_Exception_RuntimeException("No layout defined."));
|
||||
}
|
||||
|
||||
$path = sprintf($pattern, Wootook_Core_Layout::DEFAULT_PACKAGE, Wootook_Core_Layout::DEFAULT_THEME);
|
||||
$path = sprintf($pattern, Wootook_Core_Model_Layout::DEFAULT_PACKAGE, Wootook_Core_Model_Layout::DEFAULT_THEME);
|
||||
if (Wootook::fileExists($path)) {
|
||||
return $path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Config_Adapter_Abstract
|
||||
extends Wootook_Core_Config_Node
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Config_Adapter_Adapter
|
||||
extends Wootook_Core_Config_Node
|
||||
{
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Config_Adapter_Array
|
||||
extends Wootook_Core_Config_Adapter_Abstract
|
||||
extends Wootook_Core_Config_Adapter_Adapter
|
||||
{
|
||||
public function __construct($filename = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_ErrorController
|
||||
extends Wootook_Core_Controller_Action
|
||||
class Wootook_Core_Controller_ErrorController
|
||||
extends Wootook_Core_Mvc_Controller_Action
|
||||
{
|
||||
public function noRouteAction()
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_IndexController
|
||||
extends Wootook_Core_Controller_Action
|
||||
class Wootook_Core_Controller_IndexController
|
||||
extends Wootook_Core_Mvc_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Database
|
||||
extends PDO
|
||||
{
|
||||
const DEFAULT_CONNECTION_NAME = 'default';
|
||||
|
||||
protected static $_connections = array();
|
||||
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
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getSingleton()
|
||||
{
|
||||
return self::getConnection(self::DEFAULT_CONNECTION_NAME);
|
||||
}
|
||||
|
||||
public function quoteIdentifier($identifier)
|
||||
{
|
||||
return "`$identifier`";
|
||||
}
|
||||
|
||||
public static function getConnection($connectionName)
|
||||
{
|
||||
if (empty($connectionName) || $connectionName === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isset(self::$_connections[$connectionName])) {
|
||||
if (isset(self::$_connectionAliases[$connectionName])) {
|
||||
return self::$_connectionAliases[$connectionName];
|
||||
}
|
||||
|
||||
$connectionConfig = Wootook::getConfig("resource/database/{$connectionName}");
|
||||
if ($connectionConfig === null) {
|
||||
return null;
|
||||
}
|
||||
if ($alias = $connectionConfig->use) {
|
||||
self::$_connectionAliases[$connectionName] = self::getConnection($alias);
|
||||
|
||||
return self::$_connectionAliases[$connectionName];
|
||||
}
|
||||
|
||||
self::$_connections[$connectionName] = self::_initConnection($connectionName,
|
||||
$connectionConfig->engine, $connectionConfig->params, $connectionConfig->options);
|
||||
}
|
||||
|
||||
return self::$_connections[$connectionName];
|
||||
}
|
||||
|
||||
private static function _initConnection($connectionName, $engine, $params, $options = array())
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$params = new Wootook_Core_Config_Node($params);
|
||||
} else if (!$params instanceof Wootook_Core_Config_Node) {
|
||||
$params = new Wootook_Core_Config_Node(array());
|
||||
}
|
||||
|
||||
if ($options instanceof Wootook_Core_Config_Node) {
|
||||
$options = $options->toArray();
|
||||
} else if (!is_array($options)) {
|
||||
$options = array();
|
||||
}
|
||||
|
||||
$hostname = $params->hostname;
|
||||
$username = $params->username;
|
||||
$password = $params->password;
|
||||
$database = $params->database;
|
||||
|
||||
if (empty($params->hostname) || empty($params->username) || empty($params->database)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$dsn = "mysql:dbname={$params->database};host={$params->hostname}";
|
||||
if (is_numeric($params->port)) {
|
||||
$dsn .= ";port={$params->port}";
|
||||
}
|
||||
|
||||
$event = Wootook::dispatchEvent('database.prepare-options', array(
|
||||
'name' => $connectionName,
|
||||
'options' => array_merge(self::$options, $options)
|
||||
));
|
||||
|
||||
$options = $event->getData('options');
|
||||
|
||||
$connection = new self($dsn, $params->username, $params->password, $options);
|
||||
$connection->_dsn = $dsn;
|
||||
$connection->_username = $username;
|
||||
|
||||
if (defined('DEBUG')) {
|
||||
$connection->_password = $password;
|
||||
}
|
||||
|
||||
if (($prefix = Wootook::getConfig("resource/database/{$connectionName}/table_prefix")) !== null) {
|
||||
$connection->setTablePrefix($prefix);
|
||||
}
|
||||
|
||||
Wootook::dispatchEvent('database.init', array(
|
||||
'name' => $connectionName,
|
||||
'handler' => $connection
|
||||
));
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
public function setTablePrefix($prefix)
|
||||
{
|
||||
$this->_tablePrefix = $prefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTablePrefix()
|
||||
{
|
||||
return $this->_tablePrefix;
|
||||
}
|
||||
|
||||
public function getTable($name)
|
||||
{
|
||||
return $this->getTablePrefix() . $name;
|
||||
}
|
||||
|
||||
public function select($tableName = null)
|
||||
{
|
||||
return new Wootook_Core_Database_Sql_Mysql_Select($this, $tableName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Database_Adapter_Pdo_Mysql
|
||||
extends Wootook_Core_Database_Adapter_Adapter
|
||||
{
|
||||
protected $_tablePrefix = null;
|
||||
protected $_dsn = null;
|
||||
protected $_username = null;
|
||||
protected $_password = null;
|
||||
|
||||
public function quoteIdentifier($identifier)
|
||||
{
|
||||
return "`$identifier`";
|
||||
}
|
||||
|
||||
public function setTablePrefix($prefix)
|
||||
{
|
||||
$this->_tablePrefix = $prefix;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTablePrefix()
|
||||
{
|
||||
return $this->_tablePrefix;
|
||||
}
|
||||
|
||||
public function getTable($name)
|
||||
{
|
||||
return $this->getTablePrefix() . $name;
|
||||
}
|
||||
|
||||
public function select($tableName = null)
|
||||
{
|
||||
return new Wootook_Core_Database_Sql_Mysql_Select($this, $tableName);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Database_Orm_DataMapper
|
||||
extends Wootook_Core_PluginLoader_Abstract
|
||||
extends Wootook_Core_PluginLoader_PluginLoader
|
||||
{
|
||||
protected $_rules = array();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ abstract class Wootook_Core_Database_Resource
|
|||
public function getReadConnection()
|
||||
{
|
||||
if ($this->_readConnection === null) {
|
||||
$this->_readConnection = Wootook_Core_Database::getConnection('core_read');
|
||||
$this->_readConnection = $this->getConnection('core_read');
|
||||
}
|
||||
|
||||
return $this->_readConnection;
|
||||
|
|
@ -45,10 +45,10 @@ abstract class Wootook_Core_Database_Resource
|
|||
|
||||
public function setReadConnection($connection)
|
||||
{
|
||||
if ($connection instanceof Wootook_Core_Database) {
|
||||
if ($connection instanceof Wootook_Core_Database_Adapter_Pdo_Mysql) {
|
||||
$this->_readConnection = $connection;
|
||||
} else if (is_string($connection)) {
|
||||
$this->_readConnection = Wootook_Core_Database::getConnection($connection);
|
||||
$this->_readConnection = $this->getConnection($connection);
|
||||
} else {
|
||||
throw new Wootook_Core_Exception_RuntimeException(
|
||||
'First parameter should be either a database connection object or a string identifier.');
|
||||
|
|
@ -60,17 +60,17 @@ abstract class Wootook_Core_Database_Resource
|
|||
public function getWriteConnection()
|
||||
{
|
||||
if ($this->_writeConnection === null) {
|
||||
$this->_writeConnection = Wootook_Core_Database::getConnection('core_write');
|
||||
$this->_writeConnection = $this->getConnection('core_write');
|
||||
}
|
||||
return $this->_writeConnection;
|
||||
}
|
||||
|
||||
public function setWriteConnection($connection)
|
||||
{
|
||||
if ($connection instanceof Wootook_Core_Database) {
|
||||
if ($connection instanceof Wootook_Core_Database_Adapter_Pdo_Mysql) {
|
||||
$this->_readConnection = $connection;
|
||||
} else if (is_string($connection)) {
|
||||
$this->_readConnection = Wootook_Core_Database::getConnection($connection);
|
||||
$this->_readConnection = $this->getConnection($connection);
|
||||
} else {
|
||||
throw new Wootook_Core_Exception_RuntimeException(
|
||||
'First parameter should be either a database connection object or a string identifier.');
|
||||
|
|
|
|||
|
|
@ -3,24 +3,42 @@
|
|||
class Wootook_Core_Database_Sql_Mysql_Select
|
||||
extends Wootook_Core_Database_Sql_Select
|
||||
{
|
||||
protected function _prepareSql()
|
||||
public function renderColumns()
|
||||
{
|
||||
$fields = array();
|
||||
foreach ($this->_parts[self::COLUMNS] as $field) {
|
||||
if ($field['field'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$field['field']->process($this);
|
||||
|
||||
if ($field['alias'] !== null) {
|
||||
$fields[] = "{$field['field']} AS {$field['alias']}";
|
||||
} else {
|
||||
$fields[] = "{$field['field']}";
|
||||
}
|
||||
} else if ($field['alias'] !== null) {
|
||||
if ($field['table'] !== null) {
|
||||
$fields[] = "{$field['table']}.{$field['field']} AS {$field['alias']}";
|
||||
} else {
|
||||
$fields[] = "{$field['field']} AS {$field['alias']}";
|
||||
}
|
||||
} else if ($field['table'] !== null) {
|
||||
$fields[] = "{$field['table']}.{$field['field']}";
|
||||
} else {
|
||||
$fields[] = "{$field['field']}";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fields)) {
|
||||
return implode(", ", $fields);
|
||||
}
|
||||
return '*';
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->_parts[self::UNION])) {
|
||||
$fields = array();
|
||||
foreach ($this->_parts[self::COLUMNS] as $field) {
|
||||
$fieldName = current($field);
|
||||
$fieldAlias = key($field);
|
||||
if (is_string($fieldAlias)) {
|
||||
$fields[] = "{$fieldName} AS {$fieldAlias}";
|
||||
} else {
|
||||
$fields[] = $fieldName;
|
||||
}
|
||||
}
|
||||
if (!empty($fields)) {
|
||||
$fields = implode(", ", $fields);
|
||||
} else {
|
||||
$fields = '*';
|
||||
}
|
||||
$fields = $this->renderColumns();
|
||||
|
||||
if (!empty($this->_parts[self::WHERE])) {
|
||||
$where = 'WHERE (' . implode(") AND (", $this->_parts[self::WHERE]) . ')';
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,62 +1,34 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Database_Sql_Select
|
||||
implements Wootook_Core_Database_Sql_Dml
|
||||
{
|
||||
const COLUMNS = 'COLUMNS';
|
||||
const FROM = 'FROM';
|
||||
const JOIN = 'JOIN';
|
||||
const WHERE = 'WHERE';
|
||||
const ORDER = 'ORDER';
|
||||
const UNION = 'UNION';
|
||||
const LIMIT = 'LIMIT';
|
||||
const OFFSET = 'OFFSET';
|
||||
const GROUP = 'GROUP';
|
||||
const HAVING = 'HAVING';
|
||||
|
||||
const JOIN_INNER = 'INNER';
|
||||
const JOIN_OUTER = 'OUTER';
|
||||
const JOIN_LEFT = 'LEFT';
|
||||
const JOIN_RIGHT = 'RIGHT';
|
||||
|
||||
protected $_parts = array(
|
||||
self::COLUMNS => array(),
|
||||
self::FROM => array(),
|
||||
self::JOIN => array(),
|
||||
self::WHERE => array(),
|
||||
self::ORDER => array(),
|
||||
self::UNION => array(),
|
||||
self::LIMIT => array(),
|
||||
self::OFFSET => array(),
|
||||
self::GROUP => array(),
|
||||
);
|
||||
|
||||
protected $_connection = null;
|
||||
|
||||
public function __construct(Wootook_Core_Database $connection, $tableName = null)
|
||||
protected function _init($tableName = null)
|
||||
{
|
||||
$this->_connection = $connection;
|
||||
|
||||
if ($tableName !== null) {
|
||||
$this->from($tableName);
|
||||
}
|
||||
}
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->_connection;
|
||||
}
|
||||
|
||||
public function setConnection(Wootook_Core_Database $connection)
|
||||
{
|
||||
$this->_connection = $connection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _init()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tableName
|
||||
* @deprecated
|
||||
*/
|
||||
public function setTableName($tableName)
|
||||
{
|
||||
$this->from($tableName);
|
||||
|
|
@ -64,32 +36,61 @@ abstract class Wootook_Core_Database_Sql_Select
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function getTableName()
|
||||
{
|
||||
$table = $this->_parts[self::FROM];
|
||||
$table = current($this->_parts[self::FROM]);
|
||||
|
||||
return $table['table'];
|
||||
}
|
||||
|
||||
public function quote($data)
|
||||
public function reset($part = null)
|
||||
{
|
||||
return $this->getConnection()->quote($data);
|
||||
if ($part === null) {
|
||||
$this->_parts = array(
|
||||
self::COLUMNS => array(),
|
||||
self::FROM => array(),
|
||||
self::JOIN => array(),
|
||||
self::WHERE => array(),
|
||||
self::ORDER => array(),
|
||||
self::UNION => array(),
|
||||
self::LIMIT => array(),
|
||||
self::OFFSET => array(),
|
||||
self::GROUP => array(),
|
||||
);
|
||||
} else if (isset($this->_parts[$part])) {
|
||||
$this->_parts[$part] = array();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function column($column = '*', $alias = null)
|
||||
public function column($column = '*', $table = null)
|
||||
{
|
||||
if (is_array($column)) {
|
||||
foreach ($column as $alias => $field) {
|
||||
if (is_int($alias)) {
|
||||
$this->_parts[self::COLUMNS][] = array($field);
|
||||
$this->_parts[self::COLUMNS][] = array(
|
||||
'table' => $table,
|
||||
'alias' => null,
|
||||
'field' => $field
|
||||
);
|
||||
} else {
|
||||
$this->_parts[self::COLUMNS][] = array($alias => $field);
|
||||
$this->_parts[self::COLUMNS][] = array(
|
||||
'table' => $table,
|
||||
'alias' => $alias,
|
||||
'field' => $field
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if ($alias === null || is_int($alias)) {
|
||||
$this->_parts[self::COLUMNS][] = array($column);
|
||||
} else {
|
||||
$this->_parts[self::COLUMNS][] = array($alias => $column);
|
||||
$this->_parts[self::COLUMNS][] = array(
|
||||
'table' => $table,
|
||||
'alias' => null,
|
||||
'field' => $column
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -113,13 +114,6 @@ abstract class Wootook_Core_Database_Sql_Select
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function where($condition)
|
||||
{
|
||||
$this->_parts[self::WHERE][] = $condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function join($table, $condition, $fields = array('*'), $mode = self::JOIN_INNER)
|
||||
{
|
||||
$database = $this->getConnection();
|
||||
|
|
@ -178,14 +172,6 @@ abstract class Wootook_Core_Database_Sql_Select
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function limit($limit, $offset = null)
|
||||
{
|
||||
$this->_parts[self::LIMIT] = intval($limit);
|
||||
$this->_parts[self::OFFSET] = $offset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function group($groupField)
|
||||
{
|
||||
$this->_parts[self::GROUP][] = $groupField;
|
||||
|
|
@ -193,15 +179,55 @@ abstract class Wootook_Core_Database_Sql_Select
|
|||
return $this;
|
||||
}
|
||||
|
||||
abstract protected function _prepareSql();
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->_prepareSql();
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
public function toString()
|
||||
public function toString($part = null)
|
||||
{
|
||||
return $this->_prepareSql();
|
||||
if ($part === null) {
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
switch ($part) {
|
||||
case self::COLUMNS:
|
||||
return $this->renderColumns();
|
||||
break;
|
||||
case self::FROM:
|
||||
return $this->renderFrom();
|
||||
break;
|
||||
case self::WHERE:
|
||||
return $this->renderWhere();
|
||||
break;
|
||||
case self::JOIN:
|
||||
return $this->renderJoin();
|
||||
break;
|
||||
case self::ORDER:
|
||||
return $this->renderOrder();
|
||||
break;
|
||||
case self::UNION:
|
||||
return $this->renderUnion();
|
||||
break;
|
||||
case self::LIMIT:
|
||||
return $this->renderLimit();
|
||||
break;
|
||||
case self::GROUP:
|
||||
return $this->renderGroup();
|
||||
break;
|
||||
case self::HAVING:
|
||||
return $this->renderHaving();
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
abstract public function renderColumns();
|
||||
abstract public function renderFrom();
|
||||
abstract public function renderJoin();
|
||||
abstract public function renderOrder();
|
||||
abstract public function renderUnion();
|
||||
abstract public function renderGroup();
|
||||
abstract public function renderHaving();
|
||||
}
|
||||
|
|
@ -45,6 +45,9 @@ abstract class Wootook_Core_Entity
|
|||
throw new Wootook_Core_Exception_DataAccessException('Could not load data: no read connection configured.');
|
||||
}
|
||||
|
||||
$select = $database->select()
|
||||
->from($database->getTable($this->getTableName()))
|
||||
->where($idFieldName)
|
||||
$sql =<<<SQL_EOF
|
||||
SELECT * FROM {$database->getTable($this->getTableName())}
|
||||
WHERE {$idFieldName}=:id
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class Wootook_Core_Form
|
|||
return $this->_session;
|
||||
}
|
||||
|
||||
public function setRequest(Wootook_Core_Controller_Request_Http $request)
|
||||
public function setRequest(Wootook_Core_Mvc_Controller_Request_Http $request)
|
||||
{
|
||||
$this->_request = $request;
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ class Wootook_Core_Form
|
|||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @return Wootook_Core_Controller_Request_Http
|
||||
* @return Wootook_Core_Mvc_Controller_Request_Http
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Form_ElementLoader
|
||||
extends Wootook_Core_PluginLoader_Abstract
|
||||
extends Wootook_Core_PluginLoader_PluginLoader
|
||||
{
|
||||
protected $_form = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Form_ValidatorLoader
|
||||
extends Wootook_Core_PluginLoader_Abstract
|
||||
extends Wootook_Core_PluginLoader_PluginLoader
|
||||
{
|
||||
protected $_form = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Model_Config_Abstract
|
||||
abstract class Wootook_Core_Helper_Config_ConfigHandler
|
||||
extends Wootook_Core_Model
|
||||
implements Iterator, Countable
|
||||
{
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Core_Model_Config_Events
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Core_Helper_Config_Events
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Core_Model_Config_Modules
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Core_Helper_Config_Modules
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
* @subpackage Wootook_Core
|
||||
* @category layout
|
||||
*/
|
||||
class Wootook_Core_Layout
|
||||
class Wootook_Core_Model_Layout
|
||||
extends Wootook_Core_Model
|
||||
{
|
||||
const DEFAULT_PACKAGE = 'base';
|
||||
|
|
@ -110,7 +110,7 @@ class Wootook_Core_Layout
|
|||
|
||||
public function _init()
|
||||
{
|
||||
$modules = Wootook_Core_Model_Config_Modules::getSingleton();
|
||||
$modules = Wootook_Core_Helper_Config_Modules::getSingleton();
|
||||
|
||||
foreach ($modules['block'] as $module => $moduleNamespaces) {
|
||||
foreach ($moduleNamespaces as $namespace => $path) {
|
||||
|
|
@ -130,7 +130,7 @@ class Wootook_Core_Layout
|
|||
$this->setPackage(Wootook::getWebsiteConfig('package'));
|
||||
$this->setTheme(Wootook::getGameConfig('theme'));
|
||||
|
||||
$parser = new Wootook_Core_Layout_Parser();
|
||||
$parser = new Wootook_Core_Model_Layout_Parser();
|
||||
foreach ($fileList as $layoutFile) {
|
||||
try {
|
||||
if (preg_match('#\.php$#', $layoutFile)) {
|
||||
|
|
@ -331,7 +331,7 @@ class Wootook_Core_Layout
|
|||
* @param string $module
|
||||
* @param string $namespace
|
||||
* @param string|null $path
|
||||
* @return Wootook_Core_Layout
|
||||
* @return Wootook_Core_Model_Layout
|
||||
*/
|
||||
public function registerBlockNamespace($module, $namespace, $path = null)
|
||||
{
|
||||
|
|
@ -352,7 +352,7 @@ class Wootook_Core_Layout
|
|||
* @since 1.5.0
|
||||
* @param string $module
|
||||
* @param string $namespace
|
||||
* @return Wootook_Core_Layout
|
||||
* @return Wootook_Core_Model_Layout
|
||||
*/
|
||||
public function unregisterBlockNamespace($module, $namespace)
|
||||
{
|
||||
|
|
@ -501,7 +501,7 @@ class Wootook_Core_Layout
|
|||
*
|
||||
* @since 1.5.0
|
||||
* @param string $domain
|
||||
* @return Wootook_Core_Layout
|
||||
* @return Wootook_Core_Model_Layout
|
||||
*/
|
||||
public function setDomain($domain)
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Layout_Parser
|
||||
class Wootook_Core_Model_Layout_Parser
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Controller_Action
|
||||
abstract class Wootook_Core_Mvc_Controller_Action
|
||||
{
|
||||
private $_request = null;
|
||||
private $_response = null;
|
||||
|
||||
private $_layout = null;
|
||||
|
||||
public function __construct(Wootook_Core_Controller_Request_Http $request, Wootook_Core_Controller_Response_Http $response)
|
||||
public function __construct(Wootook_Core_Mvc_Controller_Request_Http $request, Wootook_Core_Mvc_Controller_Response_Http $response)
|
||||
{
|
||||
$this->setRequest($request);
|
||||
$this->setResponse($response);
|
||||
|
|
@ -25,14 +25,14 @@ abstract class Wootook_Core_Controller_Action
|
|||
{
|
||||
}
|
||||
|
||||
public function setRequest(Wootook_Core_Controller_Request_Http $request)
|
||||
public function setRequest(Wootook_Core_Mvc_Controller_Request_Http $request)
|
||||
{
|
||||
$this->_request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setResponse(Wootook_Core_Controller_Response_Http $response)
|
||||
public function setResponse(Wootook_Core_Mvc_Controller_Response_Http $response)
|
||||
{
|
||||
$this->_response = $response;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ abstract class Wootook_Core_Controller_Action
|
|||
|
||||
/**
|
||||
*
|
||||
* @return Wootook_Core_Controller_Request_Http
|
||||
* @return Wootook_Core_Mvc_Controller_Request_Http
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
|
|
@ -50,7 +50,7 @@ abstract class Wootook_Core_Controller_Action
|
|||
|
||||
/**
|
||||
*
|
||||
* @return Wootook_Core_Controller_Response_Http
|
||||
* @return Wootook_Core_Mvc_Controller_Response_Http
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ abstract class Wootook_Core_Controller_Action
|
|||
$this->getResponse()->setIsDispatched(false);
|
||||
}
|
||||
|
||||
protected function _redirect($uri, Array $params = array(), $code = Wootook_Core_Controller_Response_Http::REDIRECT_FOUND)
|
||||
protected function _redirect($uri, Array $params = array(), $code = Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_FOUND)
|
||||
{
|
||||
$this->getResponse()
|
||||
->setIsDispatched(false)
|
||||
|
|
@ -82,7 +82,7 @@ abstract class Wootook_Core_Controller_Action
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function _redirectUrl($url, $code = Wootook_Core_Controller_Response_Http::REDIRECT_FOUND)
|
||||
protected function _redirectUrl($url, $code = Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_FOUND)
|
||||
{
|
||||
$this->getResponse()->setRedirect($url, $code);
|
||||
|
||||
|
|
@ -116,12 +116,12 @@ abstract class Wootook_Core_Controller_Action
|
|||
|
||||
protected function _initLayout()
|
||||
{
|
||||
return new Wootook_Core_Layout(Wootook_Core_Layout::DOMAIN_FRONTEND);
|
||||
return new Wootook_Core_Model_Layout(Wootook_Core_Model_Layout::DOMAIN_FRONTEND);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Wootook_Core_Layout
|
||||
* @return Wootook_Core_Model_Layout
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Controller_Front
|
||||
class Wootook_Core_Mvc_Controller_Front
|
||||
{
|
||||
const ROUTE_DEFAULT = 'default';
|
||||
const ROUTE_ERROR = 'error';
|
||||
|
|
@ -49,8 +49,8 @@ class Wootook_Core_Controller_Front
|
|||
protected $_request = null;
|
||||
protected $_response = null;
|
||||
|
||||
public function __construct(Wootook_Core_Controller_Request_Abstract $request,
|
||||
Wootook_Core_Controller_Response_Abstract $response)
|
||||
public function __construct(Wootook_Core_Mvc_Controller_Request_Request $request,
|
||||
Wootook_Core_Mvc_Controller_Response_Response $response)
|
||||
{
|
||||
$this->_request = $request;
|
||||
$this->_response = $response;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Controller_Request_Http
|
||||
extends Wootook_Core_Controller_Request_Abstract
|
||||
class Wootook_Core_Mvc_Controller_Request_Http
|
||||
extends Wootook_Core_Mvc_Controller_Request_Request
|
||||
{
|
||||
protected $_baseUrl = null;
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Controller_Request_Abstract
|
||||
abstract class Wootook_Core_Mvc_Controller_Request_Request
|
||||
extends Wootook_Object
|
||||
{
|
||||
public function setParam($key, $value)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Core_Controller_Response_Http
|
||||
extends Wootook_Core_Controller_Response_Abstract
|
||||
class Wootook_Core_Mvc_Controller_Response_Http
|
||||
extends Wootook_Core_Mvc_Controller_Response_Response
|
||||
{
|
||||
const REDIRECT_MOVED_PERMANENTLY = 301;
|
||||
const REDIRECT_FOUND = 302;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_Controller_Response_Abstract
|
||||
abstract class Wootook_Core_Mvc_Controller_Response_Response
|
||||
extends Wootook_Object
|
||||
{
|
||||
protected $_isDispatched = false;
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
abstract class Wootook_Core_PluginLoader_Abstract
|
||||
abstract class Wootook_Core_PluginLoader_PluginLoader
|
||||
{
|
||||
protected $_pluginInstances = array();
|
||||
protected $_namespaces = array();
|
||||
|
||||
public function load($pluginName, $useSingleton = false)
|
||||
public function load($pluginName, $useSingleton = false, Array $constructorParams = array())
|
||||
{
|
||||
if (isset($this->_pluginInstances[$pluginName])) {
|
||||
return $this->_pluginInstances[$pluginName];
|
||||
|
|
@ -25,7 +25,7 @@ abstract class Wootook_Core_PluginLoader_Abstract
|
|||
continue;
|
||||
}
|
||||
|
||||
return $this->_load($className, $useSingleton);
|
||||
return $this->_load($className, $useSingleton, $constructorParams);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -50,7 +50,7 @@ abstract class Wootook_Core_PluginLoader_Abstract
|
|||
return $this;
|
||||
}
|
||||
|
||||
abstract protected function _load($className, $useSingleton);
|
||||
abstract protected function _load($className, $useSingleton, Array $constructorParams = array());
|
||||
|
||||
public function getPlugin($pluginName)
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
|||
|
||||
protected $_items = array();
|
||||
|
||||
public function __construct(Wootook_Core_Database $connection = null)
|
||||
public function __construct(Wootook_Core_Database_Adapter_Pdo_Mysql $connection = null)
|
||||
{
|
||||
$this->setReadConnection($connection);
|
||||
|
||||
|
|
@ -65,19 +65,15 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
|||
|
||||
public function getReadConnection()
|
||||
{
|
||||
if ($this->_connection === null) {
|
||||
$this->_connection = Wootook_Core_Database::getConnection('core_read');
|
||||
}
|
||||
|
||||
return $this->_connection;
|
||||
}
|
||||
|
||||
public function setReadConnection($connection)
|
||||
{
|
||||
if ($connection instanceof Wootook_Core_Database) {
|
||||
if ($connection instanceof Wootook_Core_Database_Adapter_Pdo_Mysql) {
|
||||
$this->_connection = $connection;
|
||||
} else if (is_string($connection)) {
|
||||
$this->_connection = Wootook_Core_Database::getConnection($connection);
|
||||
$this->_connection = Wootook_Core_Database_Adapter_Pdo_Mysql::getConnection($connection);
|
||||
} else {
|
||||
throw new Wootook_Core_Exception_RuntimeException(
|
||||
'First parameter should be either a database connection object or a string identifier.');
|
||||
|
|
@ -251,9 +247,37 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
|||
|
||||
$adapter = $this->getReadConnection();
|
||||
|
||||
$simpleOperatorList = array(
|
||||
'eq' => '=',
|
||||
'neq' => '!=',
|
||||
'lt' => '<',
|
||||
'gt' => '>',
|
||||
'lteq' => '<=',
|
||||
'gteq' => '>='
|
||||
);
|
||||
|
||||
if (in_array($operator, $simpleOperatorList)) {
|
||||
if ($value === true) {
|
||||
return "{$adapter->quoteIdentifier($field)}{$simpleOperatorList[$operator]}TRUE";
|
||||
} else if ($value === false) {
|
||||
return "{$adapter->quoteIdentifier($field)}{$simpleOperatorList[$operator]}FALSE";
|
||||
} else {
|
||||
return "{$adapter->quoteIdentifier($field)}{$simpleOperatorList[$operator]}{$adapter->quote($value)}";
|
||||
}
|
||||
}
|
||||
|
||||
switch (strtolower($operator)) {
|
||||
case 'null':
|
||||
if ($value == false) {
|
||||
return "{$adapter->quoteIdentifier($field)} IS NOT NULL";
|
||||
} else {
|
||||
return "{$adapter->quoteIdentifier($field)} IS NULL";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'and':
|
||||
case 'or':
|
||||
case 'xor':
|
||||
$where = array();
|
||||
foreach ($value as $valueItem) {
|
||||
$subOperator = key($valueItem);
|
||||
|
|
@ -283,24 +307,7 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
|||
return '((' . implode(') ' . strtoupper($operator) . ' (', $where) . '))';
|
||||
}
|
||||
break;
|
||||
case 'eq':
|
||||
return "{$adapter->quoteIdentifier($field)}={$adapter->quote($value)}";
|
||||
break;
|
||||
case 'neq':
|
||||
return "{$adapter->quoteIdentifier($field)}!={$adapter->quote($value)}";
|
||||
break;
|
||||
case 'lt':
|
||||
return "{$adapter->quoteIdentifier($field)}<{$adapter->quote($value)}";
|
||||
break;
|
||||
case 'gt':
|
||||
return "{$adapter->quoteIdentifier($field)}>{$adapter->quote($value)}";
|
||||
break;
|
||||
case 'lteq':
|
||||
return "{$adapter->quoteIdentifier($field)}<={$adapter->quote($value)}";
|
||||
break;
|
||||
case 'gteq':
|
||||
return "{$adapter->quoteIdentifier($field)}>={$adapter->quote($value)}";
|
||||
break;
|
||||
|
||||
case 'in':
|
||||
$valueList = array();
|
||||
foreach ($value as $setValue) {
|
||||
|
|
@ -309,6 +316,7 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
|||
$implodedList = implode(',', $valueList);
|
||||
return "{$adapter->quoteIdentifier($field)} IN({$implodedList})";
|
||||
break;
|
||||
|
||||
case 'nin':
|
||||
$valueList = array();
|
||||
foreach ($value as $setValue) {
|
||||
|
|
@ -317,18 +325,29 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
|||
$implodedList = implode(',', $valueList);
|
||||
return "{$adapter->quoteIdentifier($field)} NOT IN({$implodedList})";
|
||||
break;
|
||||
|
||||
case 'finset':
|
||||
return "0 < FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})";
|
||||
if (is_array($value)) {
|
||||
$subField = current($value);
|
||||
$subOperator = key($value);
|
||||
|
||||
if (in_array($subOperator, $simpleOperatorList)) {
|
||||
return "FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)}){$simpleOperatorList[$operator]}{$adapter->quoteIdentifier($subField)}";
|
||||
}
|
||||
} else {
|
||||
return "0 < FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'nfinset':
|
||||
return "0 = FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})";
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
$dateValues = array();
|
||||
$mapper = $this->getDataMapper()->load('DateTime');
|
||||
if (isset($value['from'])) {
|
||||
if ($value['from'] instanceof Wootook_Core_DateTime) {
|
||||
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($mapper->encode($value['from']))}";
|
||||
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($this->getDataMapper()->load('DateTime')->encode($value['from']))}";
|
||||
} else if (is_string($value['from'])) {
|
||||
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($value['from'])}";
|
||||
} else if (is_numeric($value['from'])) {
|
||||
|
|
@ -337,7 +356,7 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
|||
}
|
||||
if (isset($value['to'])) {
|
||||
if ($value['to'] instanceof Wootook_Core_DateTime) {
|
||||
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($mapper->encode($value['to']))}";
|
||||
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($this->getDataMapper()->load('DateTime')->encode($value['to']))}";
|
||||
} else if (is_string($value['to'])) {
|
||||
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($value['to'])}";
|
||||
} else if (is_numeric($value['to'])) {
|
||||
|
|
@ -348,6 +367,7 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
|||
return '(' . implode(' AND ', $dateValues) . ')';
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class Wootook_Core_Setup_Updater
|
|||
public function setSetupConnection($connection)
|
||||
{
|
||||
if (is_string($connection)) {
|
||||
$this->_setupConnection = Wootook_Core_Database::getConnection($connection);
|
||||
$this->_setupConnection = Wootook_Core_Database_Adapter_Pdo_Mysql::getConnection($connection);
|
||||
} else {
|
||||
$this->_setupConnection = $connection;
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ class Wootook_Core_Setup_Updater
|
|||
/**
|
||||
*
|
||||
* Enter description here ...
|
||||
* @return Wootook_Core_Database
|
||||
* @return Wootook_Core_Database_Adapter_Pdo_Mysql
|
||||
*/
|
||||
public function getSetupConnection()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -186,14 +186,14 @@ class Wootook_Core_View
|
|||
$theme = $this->getLayout()->getTheme();
|
||||
}
|
||||
if ($theme === null || empty($theme)) {
|
||||
$theme = Wootook_Core_Layout::DEFAULT_THEME;
|
||||
$theme = Wootook_Core_Model_Layout::DEFAULT_THEME;
|
||||
}
|
||||
|
||||
if ($package === null || empty($package)) {
|
||||
$package = $this->getLayout()->getPackage();
|
||||
}
|
||||
if ($package === null || empty($package)) {
|
||||
$package = Wootook_Core_Layout::DEFAULT_PACKAGE;
|
||||
$package = Wootook_Core_Model_Layout::DEFAULT_PACKAGE;
|
||||
}
|
||||
$domain = $this->getLayout()->getDomain();
|
||||
|
||||
|
|
@ -216,11 +216,11 @@ class Wootook_Core_View
|
|||
if (Wootook::fileExists(sprintf($pathPattern, $package, $theme))) {
|
||||
return sprintf($urlPattern, $package, $theme);
|
||||
}
|
||||
if (Wootook::fileExists(sprintf($pathPattern, $package, Wootook_Core_Layout::DEFAULT_THEME))) {
|
||||
return sprintf($urlPattern, $package, Wootook_Core_Layout::DEFAULT_THEME);
|
||||
if (Wootook::fileExists(sprintf($pathPattern, $package, Wootook_Core_Model_Layout::DEFAULT_THEME))) {
|
||||
return sprintf($urlPattern, $package, Wootook_Core_Model_Layout::DEFAULT_THEME);
|
||||
}
|
||||
|
||||
return sprintf($urlPattern, Wootook_Core_Layout::DEFAULT_PACKAGE, Wootook_Core_Layout::DEFAULT_THEME);
|
||||
return sprintf($urlPattern, Wootook_Core_Model_Layout::DEFAULT_PACKAGE, Wootook_Core_Model_Layout::DEFAULT_THEME);
|
||||
}
|
||||
|
||||
public function setPartial($name, $content)
|
||||
|
|
@ -292,7 +292,7 @@ class Wootook_Core_View
|
|||
|
||||
/**
|
||||
*
|
||||
* @return Wootook_Core_Layout
|
||||
* @return Wootook_Core_Model_Layout
|
||||
*/
|
||||
public function getLayout()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class Wootook_Empire_Block_Planet_Buildings
|
|||
|
||||
public function _initChildBlocks()
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
$type = Legacies_Empire::TYPE_BUILDING_PLANET;
|
||||
if ($this->getPlanet()->isMoon()) {
|
||||
$type = Legacies_Empire::TYPE_BUILDING_MOON;
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Empire_Model_Game_Combat
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Empire_Helper_Config_Combat
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Empire_Model_Game_FieldsAlias
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Empire_Helper_Config_FieldsAlias
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Empire_Model_Game_Prices
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Empire_Helper_Config_Prices
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Empire_Model_Game_Production
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Empire_Helper_Config_Production
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Empire_Model_Game_Requirements
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Empire_Helper_Config_Requirements
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Empire_Model_Game_Resources
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Empire_Helper_Config_Resources
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
* @uses Wootook_Object
|
||||
* @uses Legacies_Empire
|
||||
*/
|
||||
class Wootook_Empire_Model_Game_Types
|
||||
extends Wootook_Core_Model_Config_Abstract
|
||||
class Wootook_Empire_Helper_Config_Types
|
||||
extends Wootook_Core_Helper_Config_ConfigHandler
|
||||
implements Wootook_Core_Singleton
|
||||
{
|
||||
private static $_singleton = null;
|
||||
|
|
@ -141,8 +141,8 @@ abstract class Wootook_Empire_Model_BuilderAbstract
|
|||
*/
|
||||
public function checkAvailability($typeId)
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$requirements = Wootook_Empire_Model_Game_Requirements::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
$requirements = Wootook_Empire_Helper_Config_Requirements::getSingleton();
|
||||
|
||||
if (!isset($requirements[$typeId]) || empty($requirements[$typeId])) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ class Wootook_Empire_Model_Planet
|
|||
public function updateStorages($time = null)
|
||||
{
|
||||
Math::setPrecision(50);
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
foreach ($resources->getAllDatas() as $resource => $resourceData) {
|
||||
if (!isset($resourceData['storage']) || $resourceData['storage'] === null) {
|
||||
continue;
|
||||
|
|
@ -232,7 +232,7 @@ class Wootook_Empire_Model_Planet
|
|||
|
||||
public function updateBuildingFields()
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
|
||||
if ($this->isPlanet()) {
|
||||
$filter = Legacies_Empire::TYPE_BUILDING_PLANET;
|
||||
|
|
@ -254,9 +254,9 @@ class Wootook_Empire_Model_Planet
|
|||
|
||||
public function updateResourceProduction()
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$production = Wootook_Empire_Model_Game_Production::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
$production = Wootook_Empire_Helper_Config_Production::getSingleton();
|
||||
|
||||
if (!$this->isPlanet()) {
|
||||
return $this;
|
||||
|
|
@ -382,7 +382,7 @@ class Wootook_Empire_Model_Planet
|
|||
|
||||
public function updateResources(Wootook_Core_DateTime $time = null)
|
||||
{
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
|
||||
if ($time === null) {
|
||||
$time = new Wootook_Core_DateTime();
|
||||
|
|
@ -407,7 +407,7 @@ class Wootook_Empire_Model_Planet
|
|||
|
||||
public static function getProductionElementInstance($buildingId)
|
||||
{
|
||||
$production = Wootook_Empire_Model_Game_Production::getSingleton();
|
||||
$production = Wootook_Empire_Helper_Config_Production::getSingleton();
|
||||
|
||||
if (!isset(self::$_productionInstances[$buildingId])) {
|
||||
if (!isset($production[$buildingId])) {
|
||||
|
|
@ -647,29 +647,29 @@ class Wootook_Empire_Model_Planet
|
|||
|
||||
public function getElement($elementId)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
return $this->getData($fields[$elementId]);
|
||||
}
|
||||
|
||||
public function setElement($elementId, $level)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
return $this->setData($fields[$elementId], $level);
|
||||
}
|
||||
|
||||
public function hasElement($elementId, $levelRequired = 0)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
return $this->hasData($fields[$elementId]) && Math::comp($this->getElement($elementId), $levelRequired) > 0;
|
||||
}
|
||||
|
||||
public function appendBuildingQueue($buildingId, $destroy = false, Wootook_Core_DateTime $time = null)
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
|
||||
if ($time === null) {
|
||||
$time = new Wootook_Core_DateTime();
|
||||
|
|
@ -922,7 +922,7 @@ class Wootook_Empire_Model_Planet
|
|||
|
||||
public function getResourceAmount($resourceType)
|
||||
{
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
|
||||
$resourceConfig = $resources->getData($resourceType);
|
||||
if ($resourceConfig === null) {
|
||||
|
|
@ -933,7 +933,7 @@ class Wootook_Empire_Model_Planet
|
|||
|
||||
public function getResourceCap($resourceType)
|
||||
{
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
|
||||
$resourceConfig = $resources->getData($resourceType);
|
||||
if ($resourceConfig === null) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class Wootook_Empire_Model_Planet_Builder
|
|||
*/
|
||||
public function checkAvailability($buildingId)
|
||||
{
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
|
||||
if (!$types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) {
|
||||
return false;
|
||||
|
|
@ -116,7 +116,7 @@ class Wootook_Empire_Model_Planet_Builder
|
|||
*/
|
||||
public function getBuildingTime($buildingId, $level)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
|
||||
Math::setPrecision(50);
|
||||
$firstLevelTime = $prices[$buildingId][Legacies_Empire::BASE_BUILDING_TIME];
|
||||
|
|
@ -149,8 +149,8 @@ class Wootook_Empire_Model_Planet_Builder
|
|||
*/
|
||||
public function getResourcesNeeded($buildingId, $level)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$resources = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
|
||||
if (!isset($prices[$buildingId])) {
|
||||
return array();
|
||||
|
|
@ -176,7 +176,7 @@ class Wootook_Empire_Model_Planet_Builder
|
|||
*/
|
||||
public function updateQueue(Wootook_Core_DateTime $time)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
$startingTime = clone $this->_currentPlanet->getData('b_building');
|
||||
|
||||
|
|
@ -239,7 +239,7 @@ class Wootook_Empire_Model_Planet_Builder
|
|||
return $this;
|
||||
}
|
||||
|
||||
$types = Wootook_Empire_Model_Game_Types::getSingleton();
|
||||
$types = Wootook_Empire_Helper_Config_Types::getSingleton();
|
||||
|
||||
if (!Math::isPositive($level)) {
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Empire_Model_Planet_PluginLoader
|
||||
extends Wootook_Core_PluginLoader_Abstract
|
||||
extends Wootook_Core_PluginLoader_PluginLoader
|
||||
{
|
||||
protected $_currentPlayer = null;
|
||||
protected $_currentPlanet = null;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ abstract class Wootook_Empire_Model_Planet_ShipAbstract
|
|||
{
|
||||
public function getBaseSpeed(Wootook_Player_Model_Entity $player)
|
||||
{
|
||||
$prices = Wootook_Empire_Model_Game_Prices::getSingleton();
|
||||
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton();
|
||||
|
||||
return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@
|
|||
* @author Greg
|
||||
*
|
||||
*/
|
||||
class Wootook_Player_AccountController
|
||||
extends Wootook_Core_Controller_Action
|
||||
class Wootook_Player_Controller_AccountController
|
||||
extends Wootook_Core_Mvc_Controller_Action
|
||||
{
|
||||
public function loginAction()
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Player_OverviewController
|
||||
extends Wootook_Player_Controller_Registered
|
||||
class Wootook_Player_Controller_OverviewController
|
||||
extends Wootook_Player_Mvc_Controller_Registered
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
|
|
@ -9,7 +9,7 @@ class Wootook_Player_OverviewController
|
|||
$this->renderLayout();
|
||||
/*
|
||||
$this->getResponse()
|
||||
->setRedirect(Wootook::getStaticUrl('overview.php'), Wootook_Core_Controller_Response_Http::REDIRECT_TEMPORARY);
|
||||
->setRedirect(Wootook::getStaticUrl('overview.php'), Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_TEMPORARY);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
@ -250,7 +250,7 @@ class Wootook_Player_Model_Entity
|
|||
->setData('b_building', $now)
|
||||
;
|
||||
|
||||
$resourceList = Wootook_Empire_Model_Game_Resources::getSingleton();
|
||||
$resourceList = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||
$resourceConfig = Wootook::getGameConfig('resources/initial');
|
||||
foreach ($resourceList as $resource => $resourceData) {
|
||||
if ($resourceData['field'] === null || !isset($resourceConfig[$resource])) {
|
||||
|
|
@ -496,21 +496,21 @@ class Wootook_Player_Model_Entity
|
|||
|
||||
public function getElement($elementId)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
return $this->getData($fields[$elementId]);
|
||||
}
|
||||
|
||||
public function setElement($elementId, $level)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
return $this->setData($fields[$elementId], $level);
|
||||
}
|
||||
|
||||
public function hasElement($elementId, $levelRequired = 0)
|
||||
{
|
||||
$fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
|
||||
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
|
||||
|
||||
return $this->hasData($fields[$elementId]) && Math::comp($this->getElement($elementId), $levelRequired) > 0;
|
||||
}
|
||||
|
|
@ -565,7 +565,7 @@ class Wootook_Player_Model_Entity
|
|||
return;
|
||||
}
|
||||
|
||||
if (!isset($eventData['layout']) || !$eventData['layout'] instanceof Wootook_Core_Layout) {
|
||||
if (!isset($eventData['layout']) || !$eventData['layout'] instanceof Wootook_Core_Model_Layout) {
|
||||
return;
|
||||
}
|
||||
$layout = $eventData['layout'];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Wootook_Player_Controller_Registered
|
||||
extends Wootook_Core_Controller_Action
|
||||
class Wootook_Player_Mvc_Controller_Registered
|
||||
extends Wootook_Core_Mvc_Controller_Action
|
||||
{
|
||||
public function getSession()
|
||||
{
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php return array(
|
||||
'install' => array(
|
||||
'update' => '2columns-left',
|
||||
'update' => array('2columns-left'),
|
||||
'reference' => array(
|
||||
'content' => array(
|
||||
'children' => array(
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
),
|
||||
|
||||
'install.intro' => array(
|
||||
'update' => 'install',
|
||||
'update' => array('install'),
|
||||
'reference' => array(
|
||||
'content' => array(
|
||||
'children' => array(
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
),
|
||||
|
||||
'install.step.system' => array(
|
||||
'update' => 'install',
|
||||
'update' => array('install'),
|
||||
'reference' => array(
|
||||
'content' => array(
|
||||
'children' => array(
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
),
|
||||
|
||||
'install.step.database' => array(
|
||||
'update' => 'install',
|
||||
'update' => array('install'),
|
||||
'reference' => array(
|
||||
'content' => array(
|
||||
'children' => array(
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
),
|
||||
|
||||
'install.step.universe' => array(
|
||||
'update' => 'install',
|
||||
'update' => array('install'),
|
||||
'reference' => array(
|
||||
'content' => array(
|
||||
'children' => array(
|
||||
|
|
@ -114,7 +114,7 @@
|
|||
),
|
||||
|
||||
'install.step.profile' => array(
|
||||
'update' => 'install',
|
||||
'update' => array('install'),
|
||||
'reference' => array(
|
||||
'content' => array(
|
||||
'children' => array(
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
),
|
||||
|
||||
'install.summary' => array(
|
||||
'update' => 'install',
|
||||
'update' => array('install'),
|
||||
'reference' => array(
|
||||
'content' => array(
|
||||
'children' => array(
|
||||
|
|
|
|||
Loading…
Reference in a new issue