Updated Database component
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
7e7924e97e
commit
802be5f8c3
23 changed files with 338 additions and 111 deletions
|
|
@ -31,6 +31,14 @@ abstract class Wootook_Core_Database_Adapter_Adapter
|
||||||
return $this->_tablePrefix;
|
return $this->_tablePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTable($table)
|
||||||
|
{
|
||||||
|
return $this->getTablePrefix() . $table;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Wootook_Core_Database_Sql_Select
|
* @return Wootook_Core_Database_Sql_Select
|
||||||
*/
|
*/
|
||||||
|
|
@ -123,7 +131,8 @@ abstract class Wootook_Core_Database_Adapter_Adapter
|
||||||
{
|
{
|
||||||
$statement = $this->prepare($sql);
|
$statement = $this->prepare($sql);
|
||||||
if (!$statement->execute()) {
|
if (!$statement->execute()) {
|
||||||
throw new Wootook_Core_Exception_Database_AdapterError($this, 'Could not execute query.');
|
$message = sprintf('[SQLSTATE %s] Could not execute query: %s', $statement->errorState(), $statement->errorMessage());
|
||||||
|
throw new Wootook_Core_Exception_Database_StatementError($statement, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $statement;
|
return $statement;
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,15 @@ class Wootook_Core_Database_ConnectionManager
|
||||||
|
|
||||||
$options = $event->getData('options');
|
$options = $event->getData('options');
|
||||||
|
|
||||||
|
try {
|
||||||
$connection = $this->load($engine, false, array($params, $options));
|
$connection = $this->load($engine, false, array($params, $options));
|
||||||
|
} catch (Wootook_Core_Exception_Database_AdapterError $e) {
|
||||||
|
//Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!$connection) {
|
||||||
|
throw new Wootook_Core_Exception_DataAccessException('Could not find data connection handler.');
|
||||||
|
}
|
||||||
|
|
||||||
if (($prefix = Wootook::getConfig("resource/database/{$connectionName}/table_prefix")) !== null) {
|
if (($prefix = Wootook::getConfig("resource/database/{$connectionName}/table_prefix")) !== null) {
|
||||||
$connection->setTablePrefix($prefix);
|
$connection->setTablePrefix($prefix);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ abstract class Wootook_Core_Database_Sql_DmlQuery
|
||||||
$this->_init($tableName);
|
$this->_init($tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Wootook_Core_Database_Adapter_Adapter
|
||||||
|
*/
|
||||||
public function getConnection()
|
public function getConnection()
|
||||||
{
|
{
|
||||||
return $this->_connection;
|
return $this->_connection;
|
||||||
|
|
@ -265,7 +268,7 @@ abstract class Wootook_Core_Database_Sql_DmlQuery
|
||||||
public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement)
|
public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement)
|
||||||
{
|
{
|
||||||
foreach ($this->_placeholders as $placeholder) {
|
foreach ($this->_placeholders as $placeholder) {
|
||||||
$placeholder->befrePrepare($statement);
|
$placeholder->beforePrepare($statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,15 @@
|
||||||
class Wootook_Core_Database_Sql_Placeholder_Expression
|
class Wootook_Core_Database_Sql_Placeholder_Expression
|
||||||
extends Wootook_Core_Database_Sql_Placeholder_Placeholder
|
extends Wootook_Core_Database_Sql_Placeholder_Placeholder
|
||||||
{
|
{
|
||||||
|
protected $_expression = null;
|
||||||
|
|
||||||
|
public function __construct($expression)
|
||||||
|
{
|
||||||
|
$this->_expression = (string) $expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return $this->_expression;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,22 +4,22 @@ abstract class Wootook_Core_Database_Sql_Placeholder_Placeholder
|
||||||
{
|
{
|
||||||
abstract public function __toString();
|
abstract public function __toString();
|
||||||
|
|
||||||
abstract public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement)
|
public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function afterPrepare(Wootook_Core_Database_Statement_Statement $statement)
|
public function afterPrepare(Wootook_Core_Database_Statement_Statement $statement)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function beforeExcute(Wootook_Core_Database_Statement_Statement $statement)
|
public function beforeExcute(Wootook_Core_Database_Statement_Statement $statement)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function afterExecute(Wootook_Core_Database_Statement_Statement $statement)
|
public function afterExecute(Wootook_Core_Database_Statement_Statement $statement)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,10 @@ abstract class Wootook_Core_Database_Sql_Select
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if ($column instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||||
|
$this->_placeholders[] = $column;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_parts[self::COLUMNS][] = array(
|
$this->_parts[self::COLUMNS][] = array(
|
||||||
'table' => $table,
|
'table' => $table,
|
||||||
'alias' => null,
|
'alias' => null,
|
||||||
|
|
@ -120,17 +124,17 @@ abstract class Wootook_Core_Database_Sql_Select
|
||||||
$this->column($fields);
|
$this->column($fields);
|
||||||
if (is_array($table)) {
|
if (is_array($table)) {
|
||||||
$alias = key($table);
|
$alias = key($table);
|
||||||
$table = current($table);
|
$table = $this->_connection->getTable(current($table));
|
||||||
|
|
||||||
if ($schema !== null) {
|
if ($schema !== null) {
|
||||||
$this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($schema)}{$this->_connection->quoteIdentifier($this->_connection->getTable($table))} AS {$this->_connection->quoteIdentifier($alias)}"
|
$this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($schema)}{$this->_connection->quoteIdentifier($table)} AS {$this->_connection->quoteIdentifier($alias)}"
|
||||||
. "\n ON {$condition}";
|
. "\n ON {$condition}";
|
||||||
} else {
|
} else {
|
||||||
$this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($this->_connection->getTable($table))} AS {$this->_connection->quoteIdentifier($alias)}"
|
$this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($table)} AS {$this->_connection->quoteIdentifier($alias)}"
|
||||||
. "\n ON {$condition}";
|
. "\n ON {$condition}";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($this->_connection->getTable($table))}"
|
$this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($table)}"
|
||||||
. "\n ON {$condition}";
|
. "\n ON {$condition}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,8 +237,6 @@ abstract class Wootook_Core_Database_Sql_Select
|
||||||
$fields[] = "({$field['field']})";
|
$fields[] = "({$field['field']})";
|
||||||
}
|
}
|
||||||
} else if ($field['field'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
} else if ($field['field'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||||
$field['field']->prepare($this);
|
|
||||||
|
|
||||||
if ($field['alias'] !== null) {
|
if ($field['alias'] !== null) {
|
||||||
$fields[] = "({$field['field']}) AS {$field['alias']}";
|
$fields[] = "({$field['field']}) AS {$field['alias']}";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -256,7 +258,7 @@ abstract class Wootook_Core_Database_Sql_Select
|
||||||
if (!empty($fields)) {
|
if (!empty($fields)) {
|
||||||
return 'SELECT ' . implode(", ", $fields);
|
return 'SELECT ' . implode(", ", $fields);
|
||||||
}
|
}
|
||||||
return '*';
|
return 'SELECT *';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderFrom()
|
public function renderFrom()
|
||||||
|
|
|
||||||
|
|
@ -241,4 +241,66 @@ class Wootook_Core_Database_Statement_Pdo_Mysql
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function closeCursor()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->_handler->closeCursor();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function nextRowset()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->_handler->nextRowset();
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function errorCode()
|
||||||
|
{
|
||||||
|
return $this->_handler->errorCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function errorInfo()
|
||||||
|
{
|
||||||
|
return $this->_handler->errorInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function errorMessage()
|
||||||
|
{
|
||||||
|
$info = $this->_handler->errorInfo();
|
||||||
|
|
||||||
|
return $info[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function errorState()
|
||||||
|
{
|
||||||
|
$info = $this->_handler->errorInfo();
|
||||||
|
|
||||||
|
return $info[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,11 +136,41 @@ abstract class Wootook_Core_Database_Statement_Statement
|
||||||
*/
|
*/
|
||||||
abstract public function columnCount();
|
abstract public function columnCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function errorCode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function errorMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
abstract public function errorInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function errorState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
abstract public function rowCount();
|
abstract public function rowCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
abstract public function closeCursor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
abstract public function nextRowset();
|
||||||
|
|
||||||
public function current()
|
public function current()
|
||||||
{
|
{
|
||||||
return $this->_currentRow;
|
return $this->_currentRow;
|
||||||
|
|
|
||||||
|
|
@ -67,18 +67,16 @@ SQL_EOF;
|
||||||
$idValues = func_get_arg(0);
|
$idValues = func_get_arg(0);
|
||||||
$database = $this->getReadConnection();
|
$database = $this->getReadConnection();
|
||||||
|
|
||||||
|
$select = $database->select()
|
||||||
|
->from(array('main_table' => $database->getTable($this->getTableName())))
|
||||||
|
->limit(1);
|
||||||
|
|
||||||
$idFields = array();
|
$idFields = array();
|
||||||
foreach ($this->_idFieldNames as $field) {
|
foreach ($this->_idFieldNames as $field) {
|
||||||
$idFields[] = "{$field}=:{$field}";
|
$select->where("{$database->quoteIdentifier($field)}=:{$field}");
|
||||||
}
|
}
|
||||||
$idFields = '(' . implode(') AND (', $idFields) . ')';
|
|
||||||
|
|
||||||
$sql =<<<SQL_EOF
|
$statement = $database->prepare($select);
|
||||||
SELECT * FROM {$database->getTable(self::getTableName())}
|
|
||||||
WHERE $idFields
|
|
||||||
LIMIT 1
|
|
||||||
SQL_EOF;
|
|
||||||
$statement = $database->prepare($sql);
|
|
||||||
$statement->execute($idValues);
|
$statement->execute($idValues);
|
||||||
|
|
||||||
$datas = $statement->fetch(PDO::FETCH_ASSOC);
|
$datas = $statement->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
@ -86,7 +84,9 @@ SQL_EOF;
|
||||||
throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id combination could not be found.');
|
throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id combination could not be found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_data = $datas;
|
$this->_data = array();
|
||||||
|
$this->getDataMapper()->decode($this, $datas);
|
||||||
|
|
||||||
$this->_isLoaded = true;
|
$this->_isLoaded = true;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class Wootook_Core_Exception_Database_StatementError
|
class Wootook_Core_Exception_Database_StatementError
|
||||||
extends Wootook_Core_Exception_RuntimeException
|
extends Wootook_Core_Exception_RuntimeException
|
||||||
implements Wootook_Core_Exception_Database_Error
|
implements Wootook_Core_Exception_Database_Error
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,12 @@ class Wootook_Core_Mvc_Controller_Request_Http
|
||||||
protected $_controllerKey = 'controller';
|
protected $_controllerKey = 'controller';
|
||||||
protected $_moduleKey = 'module';
|
protected $_moduleKey = 'module';
|
||||||
|
|
||||||
|
protected $_queryVars = array();
|
||||||
|
protected $_postVars = array();
|
||||||
|
protected $_cookieVars = array();
|
||||||
|
protected $_serverVars = array();
|
||||||
|
protected $_postFiles = array();
|
||||||
|
|
||||||
public function __construct(Array $options = array())
|
public function __construct(Array $options = array())
|
||||||
{
|
{
|
||||||
parent::__construct($options);
|
parent::__construct($options);
|
||||||
|
|
@ -64,6 +70,22 @@ class Wootook_Core_Mvc_Controller_Request_Http
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->_queryVars = $_GET;
|
||||||
|
$this->_postVars = $_POST;
|
||||||
|
$this->_cookieVars = $_COOKIE;
|
||||||
|
$this->_serverVars = $_SERVER;
|
||||||
|
$this->_postFiles = $_FILES;
|
||||||
|
|
||||||
|
$this->clearData();
|
||||||
|
|
||||||
|
$this->addData($this->_serverVars);
|
||||||
|
$this->addData($this->_cookieVars);
|
||||||
|
$this->addData($this->_queryVars);
|
||||||
|
$this->addData($this->_postVars);
|
||||||
|
}
|
||||||
|
|
||||||
public function setParam($key, $value)
|
public function setParam($key, $value)
|
||||||
{
|
{
|
||||||
return $this->setData($key, $value);
|
return $this->setData($key, $value);
|
||||||
|
|
@ -74,86 +96,103 @@ class Wootook_Core_Mvc_Controller_Request_Http
|
||||||
if ($this->hasData($key)) {
|
if ($this->hasData($key)) {
|
||||||
return $this->getData($key);
|
return $this->getData($key);
|
||||||
}
|
}
|
||||||
if (isset($_POST[$key])) {
|
if ($this->hasPost($key)) {
|
||||||
return $_POST[$key];
|
return $this->getPost($key);
|
||||||
}
|
}
|
||||||
if (isset($_GET[$key])) {
|
if ($this->hasQuery($key)) {
|
||||||
return $_GET[$key];
|
return $this->getQuery($key);
|
||||||
}
|
}
|
||||||
if (isset($_FILES[$key])) {
|
if ($this->hasCookie($key)) {
|
||||||
return $_FILES[$key];
|
return $this->getCookie($key);
|
||||||
}
|
}
|
||||||
if (isset($_COOKIE[$key])) {
|
|
||||||
return $_COOKIE[$key];
|
return $this->getServer($key, $default);
|
||||||
}
|
|
||||||
if (isset($_SERVER[$key])) {
|
|
||||||
return $_SERVER[$key];
|
|
||||||
}
|
|
||||||
return $default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQuery($key, $default = null)
|
public function getQuery($key, $default = null)
|
||||||
{
|
{
|
||||||
if (!isset($_GET[$key])) {
|
if (!isset($this->_queryVars[$key])) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
return $_GET[$key];
|
return $this->_queryVars[$key];
|
||||||
}
|
|
||||||
|
|
||||||
public function getFile($key, $default = null)
|
|
||||||
{
|
|
||||||
if (!isset($_FILES[$key])) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return $_FILES[$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCookie($key, $default = null)
|
|
||||||
{
|
|
||||||
if (!isset($_COOKIE[$key])) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return unserialize(stripslashes($_COOKIE[$key]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRawCookie($key, $default = null)
|
|
||||||
{
|
|
||||||
if (!isset($_COOKIE[$key])) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return $_COOKIE[$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPost($key, $default = null)
|
|
||||||
{
|
|
||||||
if (!isset($_POST[$key])) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return $_POST[$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getServer($key, $default = null)
|
|
||||||
{
|
|
||||||
if (!isset($_SERVER[$key])) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return $_SERVER[$key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllQueryData()
|
public function getAllQueryData()
|
||||||
{
|
{
|
||||||
return $_GET;
|
return $this->_queryVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllFilesData()
|
public function hasQuery($key)
|
||||||
{
|
{
|
||||||
return $_FILES;
|
return isset($this->_queryVars[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setQuery($key, $value)
|
||||||
|
{
|
||||||
|
$this->_queryVars[$key] = (string) $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unsetQuery($key)
|
||||||
|
{
|
||||||
|
unset($this->_queryVars[$key]);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPost($key, $default = null)
|
||||||
|
{
|
||||||
|
if (!isset($this->_postVars[$key])) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
return $this->_postVars[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllPostData()
|
||||||
|
{
|
||||||
|
return $this->_postVars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasPost($key)
|
||||||
|
{
|
||||||
|
return isset($this->_postVars[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPost($key, $value)
|
||||||
|
{
|
||||||
|
$this->_postVars[$key] = (string) $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unsetPost($key)
|
||||||
|
{
|
||||||
|
unset($this->_postVars[$key]);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCookie($key, $default = null)
|
||||||
|
{
|
||||||
|
if (!isset($this->_cookieVars[$key])) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
return unserialize(stripslashes($this->_cookieVars[$key]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRawCookie($key, $default = null)
|
||||||
|
{
|
||||||
|
if (!isset($this->_cookieVars[$key])) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
return $this->_cookieVars[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllCookieData()
|
public function getAllCookieData()
|
||||||
{
|
{
|
||||||
$data = array();
|
$data = array();
|
||||||
foreach ($_COOKIE as $key => $value) {
|
foreach ($this->_cookieVars as $key => $value) {
|
||||||
$data[$key] = unserialize(stripslashes($value));
|
$data[$key] = unserialize(stripslashes($value));
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
|
|
@ -161,17 +200,59 @@ class Wootook_Core_Mvc_Controller_Request_Http
|
||||||
|
|
||||||
public function getAllRawCookieData()
|
public function getAllRawCookieData()
|
||||||
{
|
{
|
||||||
return $_COOKIE;
|
return $this->_cookieVars;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllPostData()
|
public function hasCookie($key)
|
||||||
{
|
{
|
||||||
return $_POST;
|
return isset($this->_cookieVars[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCookie($key, $value)
|
||||||
|
{
|
||||||
|
$this->_cookieVars[$key] = addslashes(serialize((string) $value));
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRawCookie($key, $value)
|
||||||
|
{
|
||||||
|
$this->_cookieVars[$key] = (string) $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unsetCookie($key)
|
||||||
|
{
|
||||||
|
unset($this->_cookieVars[$key]);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getServer($key, $default = null)
|
||||||
|
{
|
||||||
|
if (!isset($this->_serverVars[$key])) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
return $this->_serverVars[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllServerData()
|
public function getAllServerData()
|
||||||
{
|
{
|
||||||
return $_SERVER;
|
return $this->_serverVars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFile($key, $default = null)
|
||||||
|
{
|
||||||
|
if (!isset($this->_postFiles[$key])) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
return $this->_postFiles[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllFilesData()
|
||||||
|
{
|
||||||
|
return $this->_postFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPost()
|
public function isPost()
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,13 @@
|
||||||
abstract class Wootook_Core_Mvc_Controller_Request_Request
|
abstract class Wootook_Core_Mvc_Controller_Request_Request
|
||||||
extends Wootook_Object
|
extends Wootook_Object
|
||||||
{
|
{
|
||||||
|
public function __construct(Array $data = array())
|
||||||
|
{
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
parent::__construct($data);
|
||||||
|
}
|
||||||
|
|
||||||
public function setParam($key, $value)
|
public function setParam($key, $value)
|
||||||
{
|
{
|
||||||
return $this->setData($key, $value);
|
return $this->setData($key, $value);
|
||||||
|
|
@ -16,6 +23,8 @@ abstract class Wootook_Core_Mvc_Controller_Request_Request
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract public function init();
|
||||||
|
|
||||||
abstract public function getModuleName();
|
abstract public function getModuleName();
|
||||||
abstract public function getControllerName();
|
abstract public function getControllerName();
|
||||||
abstract public function getActionName();
|
abstract public function getActionName();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
abstract class Wootook_Core_Resource_CollectionAbstract
|
abstract class Wootook_Core_Resource_EntityCollection
|
||||||
implements Iterator, Countable
|
implements Iterator, Countable
|
||||||
{
|
{
|
||||||
protected $_connection = null;
|
protected $_connection = null;
|
||||||
|
|
@ -39,7 +39,8 @@ abstract class Wootook_Core_Resource_CollectionAbstract
|
||||||
public function getSelect()
|
public function getSelect()
|
||||||
{
|
{
|
||||||
if ($this->_select === null) {
|
if ($this->_select === null) {
|
||||||
$this->_select = $this->getReadConnection()->select($this->_entityTable);
|
$this->_select = $this->getReadConnection()
|
||||||
|
->select(array('main_table' => $this->getReadConnection()->getTable($this->_entityTable)));
|
||||||
|
|
||||||
$this->_prepareSelect($this->_select);
|
$this->_prepareSelect($this->_select);
|
||||||
}
|
}
|
||||||
|
|
@ -122,6 +122,15 @@ class Wootook_Empire_Model_Planet
|
||||||
return self::factory($planetId);
|
return self::factory($planetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __construct(Array $data = array(), Wootook_Player_Model_Entity $player = null)
|
||||||
|
{
|
||||||
|
parent::__construct($data);
|
||||||
|
|
||||||
|
if ($player !== null) {
|
||||||
|
$this->setPlayer($player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function _init()
|
public function _init()
|
||||||
{
|
{
|
||||||
$this->_tableName = 'planets';
|
$this->_tableName = 'planets';
|
||||||
|
|
@ -258,7 +267,7 @@ class Wootook_Empire_Model_Planet
|
||||||
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton();
|
||||||
$production = Wootook_Empire_Helper_Config_Production::getSingleton();
|
$production = Wootook_Empire_Helper_Config_Production::getSingleton();
|
||||||
|
|
||||||
if (!$this->isPlanet()) {
|
if (!$this->isPlanet() || !$this->getPlayer()) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -437,7 +446,8 @@ class Wootook_Empire_Model_Planet
|
||||||
public function getPlayer()
|
public function getPlayer()
|
||||||
{
|
{
|
||||||
if ($this->_player === null && $this->getPlayerId()) {
|
if ($this->_player === null && $this->getPlayerId()) {
|
||||||
$this->_player = Wootook_Player_Model_Entity::factory($this->getPlayerId());
|
$this->_player = new Wootook_Player_Model_Entity();
|
||||||
|
$this->_player->load($this->getPlayerId());
|
||||||
}
|
}
|
||||||
return $this->_player;
|
return $this->_player;
|
||||||
}
|
}
|
||||||
|
|
@ -445,6 +455,7 @@ class Wootook_Empire_Model_Planet
|
||||||
public function setPlayer(Wootook_Player_Model_Entity $player)
|
public function setPlayer(Wootook_Player_Model_Entity $player)
|
||||||
{
|
{
|
||||||
$this->_player = $player;
|
$this->_player = $player;
|
||||||
|
$this->setData('id_owner', $player->getId());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
@ -756,7 +767,7 @@ class Wootook_Empire_Model_Planet
|
||||||
*/
|
*/
|
||||||
public function getBuildingQueue()
|
public function getBuildingQueue()
|
||||||
{
|
{
|
||||||
if ($this->_builder === null) {
|
if ($this->_builder === null && $this->getPlayer()) {
|
||||||
$this->_builder = new Wootook_Empire_Model_Planet_Builder($this, $this->getPlayer());
|
$this->_builder = new Wootook_Empire_Model_Planet_Builder($this, $this->getPlayer());
|
||||||
}
|
}
|
||||||
return $this->_builder;
|
return $this->_builder;
|
||||||
|
|
@ -843,12 +854,12 @@ class Wootook_Empire_Model_Planet
|
||||||
{
|
{
|
||||||
$adapter = Wootook_Core_Database_ConnectionManager::getSingleton()
|
$adapter = Wootook_Core_Database_ConnectionManager::getSingleton()
|
||||||
->getConnection('core_read');
|
->getConnection('core_read');
|
||||||
$select = $adapter->select(array('galaxy' => 'galaxy'));
|
$select = $adapter->select(array('galaxy' => $adapter->getTable('galaxy')));
|
||||||
$select
|
$select
|
||||||
->column(array(
|
->column(array(
|
||||||
'galaxy' => 'galaxy.galaxy',
|
'galaxy' => 'galaxy',
|
||||||
'system' => 'galaxy.system',
|
'system' => 'system',
|
||||||
'count' => 'COUNT(*)'
|
'count' => new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)')
|
||||||
))
|
))
|
||||||
->group('galaxy.galaxy')
|
->group('galaxy.galaxy')
|
||||||
->group('galaxy.system')
|
->group('galaxy.system')
|
||||||
|
|
@ -860,7 +871,7 @@ class Wootook_Empire_Model_Planet
|
||||||
|
|
||||||
if ($galaxyList !== null) {
|
if ($galaxyList !== null) {
|
||||||
array_walk($galaxyList, array(__CLASS__, '_cleanItemRanges'));
|
array_walk($galaxyList, array(__CLASS__, '_cleanItemRanges'));
|
||||||
$select->where('galaxy.galaxy IN(' . implode(', ', $galaxyList) . ')');
|
$select->where('galaxy', array(array(Wootook_Core_Database_Sql_Select::OPERATOR_IN => $galaxyList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($systemList === null && Wootook::getGameConfig('user/registration/system_list')) {
|
if ($systemList === null && Wootook::getGameConfig('user/registration/system_list')) {
|
||||||
|
|
@ -869,7 +880,7 @@ class Wootook_Empire_Model_Planet
|
||||||
|
|
||||||
if ($systemList !== null) {
|
if ($systemList !== null) {
|
||||||
array_walk($systemList, array(__CLASS__, '_cleanItemRanges'));
|
array_walk($systemList, array(__CLASS__, '_cleanItemRanges'));
|
||||||
$select->where('galaxy.system IN(' . implode(', ', $systemList) . ')');
|
$select->where('system', array(array(Wootook_Core_Database_Sql_Select::OPERATOR_IN => $systemList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$orders = array(
|
$orders = array(
|
||||||
|
|
@ -879,7 +890,7 @@ class Wootook_Empire_Model_Planet
|
||||||
"RAND() / 1000",
|
"RAND() / 1000",
|
||||||
);
|
);
|
||||||
$select
|
$select
|
||||||
->order('((' . implode(') * (', $orders) . '))', 'ASC')
|
->order(new Wootook_Core_Database_Sql_Placeholder_Expression('((' . implode(') * (', $orders) . '))'), 'ASC')
|
||||||
//->order("ABS(galaxy.system - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/systems'))} / 2))", 'ASC')
|
//->order("ABS(galaxy.system - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/systems'))} / 2))", 'ASC')
|
||||||
//->order("ABS(galaxy.galaxy - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/galaxies'))} / 2))", 'ASC')
|
//->order("ABS(galaxy.galaxy - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/galaxies'))} / 2))", 'ASC')
|
||||||
//->order("1.5 / COUNT(*)", 'ASC')
|
//->order("1.5 / COUNT(*)", 'ASC')
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Wootook_Empire_Resource_Fleet_Collection
|
class Wootook_Empire_Resource_Fleet_Collection
|
||||||
extends Wootook_Core_Resource_CollectionAbstract
|
extends Wootook_Core_Resource_EntityCollection
|
||||||
{
|
{
|
||||||
protected function _construct()
|
protected function _construct()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Wootook_Empire_Resource_Planet_Collection
|
class Wootook_Empire_Resource_Planet_Collection
|
||||||
extends Wootook_Core_Resource_CollectionAbstract
|
extends Wootook_Core_Resource_EntityCollection
|
||||||
{
|
{
|
||||||
protected function _construct()
|
protected function _construct()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ class Wootook_Player_Model_Entity
|
||||||
'user_agent' => $request->getServer('HTTP_USER_AGENT')
|
'user_agent' => $request->getServer('HTTP_USER_AGENT')
|
||||||
));
|
));
|
||||||
|
|
||||||
$player->getWriteConnection()->beginTransaction();
|
//$player->getWriteConnection()->beginTransaction();
|
||||||
|
|
||||||
$player->save();
|
$player->save();
|
||||||
|
|
||||||
|
|
@ -150,9 +150,9 @@ class Wootook_Player_Model_Entity
|
||||||
if (!$statement->execute()) {
|
if (!$statement->execute()) {
|
||||||
throw new Wootook_Empire_Exception_RuntimeException('No more planet to colonize!'); // Oops, no more free place
|
throw new Wootook_Empire_Exception_RuntimeException('No more planet to colonize!'); // Oops, no more free place
|
||||||
}
|
}
|
||||||
} catch (PDOException $e) {
|
} catch (Wootook_Core_Exception_Database_Error $e) {
|
||||||
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
|
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
|
||||||
$this->getWriteConnection()->rollback();
|
//$this->getWriteConnection()->rollback();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ class Wootook_Player_Model_Entity
|
||||||
throw new Wootook_Empire_Exception_RuntimeException('No more planet to colonize!'); // Oops, no more free place
|
throw new Wootook_Empire_Exception_RuntimeException('No more planet to colonize!'); // Oops, no more free place
|
||||||
}
|
}
|
||||||
|
|
||||||
$collection = new Wootook_Empire_Resource_Planet_Collection($player->getReadConneciton());
|
$collection = new Wootook_Empire_Resource_Planet_Collection($player->getReadConnection());
|
||||||
$collection->addTypeToFilter(Wootook_Empire_Model_Planet::TYPE_PLANET)
|
$collection->addTypeToFilter(Wootook_Empire_Model_Planet::TYPE_PLANET)
|
||||||
->addFieldToFilter('galaxy', $systemInfo['galaxy'])
|
->addFieldToFilter('galaxy', $systemInfo['galaxy'])
|
||||||
->addFieldToFilter('system', $systemInfo['system'])
|
->addFieldToFilter('system', $systemInfo['system'])
|
||||||
|
|
@ -178,8 +178,8 @@ class Wootook_Player_Model_Entity
|
||||||
$finalPosition = $positions[$key];
|
$finalPosition = $positions[$key];
|
||||||
|
|
||||||
$planet = $player->createNewPlanet(
|
$planet = $player->createNewPlanet(
|
||||||
$systemInfo->getData('galaxy'),
|
$systemInfo['galaxy'],
|
||||||
$systemInfo->getData('system'),
|
$systemInfo['system'],
|
||||||
$finalPosition,
|
$finalPosition,
|
||||||
Wootook_Empire_Model_Planet::TYPE_PLANET,
|
Wootook_Empire_Model_Planet::TYPE_PLANET,
|
||||||
Wootook::getRequest()->getParam('planet'),
|
Wootook::getRequest()->getParam('planet'),
|
||||||
|
|
@ -200,21 +200,21 @@ class Wootook_Player_Model_Entity
|
||||||
|
|
||||||
$player->save();
|
$player->save();
|
||||||
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
} catch (Wootook_Core_Exception_DataAccessException $e) {
|
||||||
$player->getWriteConnection()->rollback();
|
//$player->getWriteConnection()->rollback();
|
||||||
$session = Wootook_Core_Model_Session::factory(Wootook_Player_Model_Entity::SESSION_KEY);
|
$session = Wootook_Core_Model_Session::factory(Wootook_Player_Model_Entity::SESSION_KEY);
|
||||||
|
|
||||||
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
|
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
|
||||||
$session->addError($e->getMessage());
|
$session->addError($e->getMessage());
|
||||||
return null;
|
return null;
|
||||||
} catch (Wootook_Empire_Exception_RuntimeException $e) {
|
} catch (Wootook_Empire_Exception_RuntimeException $e) {
|
||||||
$player->getWriteConnection()->rollback();
|
//$player->getWriteConnection()->rollback();
|
||||||
$session = Wootook_Core_Model_Session::factory(Wootook_Player_Model_Entity::SESSION_KEY);
|
$session = Wootook_Core_Model_Session::factory(Wootook_Player_Model_Entity::SESSION_KEY);
|
||||||
|
|
||||||
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
|
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
|
||||||
$session->addError($e->getMessage());
|
$session->addError($e->getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$player->getWriteConnection()->commit();
|
//$player->getWriteConnection()->commit();
|
||||||
|
|
||||||
return $player;
|
return $player;
|
||||||
}
|
}
|
||||||
|
|
@ -230,10 +230,9 @@ class Wootook_Player_Model_Entity
|
||||||
$size = mt_rand(floor($factor / 10), ceil($factor * 5 / 4)) + mt_rand(0, $fuzz);
|
$size = mt_rand(floor($factor / 10), ceil($factor * 5 / 4)) + mt_rand(0, $fuzz);
|
||||||
}
|
}
|
||||||
|
|
||||||
$now = time();
|
$now = new Wootook_Core_DateTime();
|
||||||
$planet = new Wootook_Empire_Model_Planet();
|
$planet = new Wootook_Empire_Model_Planet(array(), $this);
|
||||||
$planet
|
$planet
|
||||||
->setData('id_owner', $this->getId())
|
|
||||||
->setData('name', $name)
|
->setData('name', $name)
|
||||||
->setData('galaxy', $galaxy)
|
->setData('galaxy', $galaxy)
|
||||||
->setData('system', $system)
|
->setData('system', $system)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Wootook_Player_Resource_Entity_Collection
|
class Wootook_Player_Resource_Entity_Collection
|
||||||
extends Wootook_Core_Resource_CollectionAbstract
|
extends Wootook_Core_Resource_EntityCollection
|
||||||
{
|
{
|
||||||
public function _construct()
|
public function _construct()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Wootook_Player_Resource_Message_Collection
|
class Wootook_Player_Resource_Message_Collection
|
||||||
extends Wootook_Core_Resource_CollectionAbstract
|
extends Wootook_Core_Resource_EntityCollection
|
||||||
{
|
{
|
||||||
public function _construct()
|
public function _construct()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
'resource' => array(
|
'resource' => array(
|
||||||
'database' => array(
|
'database' => array(
|
||||||
'default' => array(
|
'default' => array(
|
||||||
'engine' => 'mysql',
|
'engine' => 'pdo_mysql',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
),
|
),
|
||||||
'params' => array(
|
'params' => array(
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,6 @@ $session['speed'] = $speedArray;
|
||||||
$session['consumption'] = $consumptionArray;
|
$session['consumption'] = $consumptionArray;
|
||||||
$session['capacity'] = $capacityArray;
|
$session['capacity'] = $capacityArray;
|
||||||
|
|
||||||
var_dump($_SESSION);
|
|
||||||
if (empty($fleetArray)) {
|
if (empty($fleetArray)) {
|
||||||
message($lang['fl_unselectall'], $lang['fl_error'], "fleet." . PHPEXT, 1);
|
message($lang['fl_unselectall'], $lang['fl_error'], "fleet." . PHPEXT, 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,6 @@ $mission = isset($_POST['target_mission']) ? $_POST['target_mission'] : 0;
|
||||||
|
|
||||||
$SpeedFactor = GetGameSpeedFactor();
|
$SpeedFactor = GetGameSpeedFactor();
|
||||||
$AllFleetSpeed = GetFleetMaxSpeed($fleetArray, 0, $user);
|
$AllFleetSpeed = GetFleetMaxSpeed($fleetArray, 0, $user);
|
||||||
var_dump($AllFleetSpeed, $fleetArray);
|
|
||||||
$MaxFleetSpeed = min($AllFleetSpeed);
|
$MaxFleetSpeed = min($AllFleetSpeed);
|
||||||
|
|
||||||
$distance = GetTargetDistance($planetrow->getGalaxy(), $galaxy, $planetrow->getSystem(), $system, $planetrow->getPosition(), $planet);
|
$distance = GetTargetDistance($planetrow->getGalaxy(), $galaxy, $planetrow->getSystem(), $system, $planetrow->getPosition(), $planet);
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ if (isset($_SERVER['REQUEST_URI'])) {
|
||||||
if ($offset == (strlen($_SERVER['REQUEST_URI']) - 1)) {
|
if ($offset == (strlen($_SERVER['REQUEST_URI']) - 1)) {
|
||||||
$baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strpos(substr($_SERVER['REQUEST_URI'], 0, -1), '/')) . '/';
|
$baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strpos(substr($_SERVER['REQUEST_URI'], 0, -1), '/')) . '/';
|
||||||
} else {
|
} else {
|
||||||
$baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strrpos(substr($_SERVER['REQUEST_URI'], 0, $offset), '/', strlen($_SERVER['REQUEST_URI']) - $offset - 1)) . '/';
|
$baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strpos(substr($_SERVER['REQUEST_URI'], 0, $offset), '/', strlen($_SERVER['REQUEST_URI']) - $offset - 1)) . '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$session = Wootook::getSession('install');
|
$session = Wootook::getSession('install');
|
||||||
|
|
@ -230,6 +230,7 @@ case 'install':
|
||||||
'web' => array(
|
'web' => array(
|
||||||
'url' => array(
|
'url' => array(
|
||||||
'base' => $request->getPost('url_path'),
|
'base' => $request->getPost('url_path'),
|
||||||
|
'link' => $request->getPost('url_path'),
|
||||||
'skin' => $request->getPost('url_path') . 'skin/',
|
'skin' => $request->getPost('url_path') . 'skin/',
|
||||||
'js' => $request->getPost('url_path') . 'js/',
|
'js' => $request->getPost('url_path') . 'js/',
|
||||||
'css' => $request->getPost('url_path') . 'css/',
|
'css' => $request->getPost('url_path') . 'css/',
|
||||||
|
|
@ -239,6 +240,7 @@ case 'install':
|
||||||
'path' => array(
|
'path' => array(
|
||||||
'base' => ROOT_PATH,
|
'base' => ROOT_PATH,
|
||||||
'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR,
|
'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR,
|
||||||
|
'design' => ROOT_PATH . 'application' . DIRECTORY_SEPARATOR . 'design' . DIRECTORY_SEPARATOR,
|
||||||
),
|
),
|
||||||
'date' => array(
|
'date' => array(
|
||||||
'timezone' => $request->getPost('timezone')
|
'timezone' => $request->getPost('timezone')
|
||||||
|
|
@ -515,7 +517,7 @@ case 'install':
|
||||||
|
|
||||||
if ($request->getPost('email') != $request->getPost('email_confirm')) {
|
if ($request->getPost('email') != $request->getPost('email_confirm')) {
|
||||||
$session->setData('step', STEP_PROFILE);
|
$session->setData('step', STEP_PROFILE);
|
||||||
$session->setFormData($request->getData());
|
$session->setFormData($request->getAllDatas());
|
||||||
$session->addError(Wootook::__('Both e-mails does not match.'));
|
$session->addError(Wootook::__('Both e-mails does not match.'));
|
||||||
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE)));
|
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE)));
|
||||||
$response->sendHeaders();
|
$response->sendHeaders();
|
||||||
|
|
@ -526,16 +528,17 @@ case 'install':
|
||||||
$user = Wootook_Player_Model_Entity::register($request->getPost('username'), $request->getPost('email'), $request->getPost('password'));
|
$user = Wootook_Player_Model_Entity::register($request->getPost('username'), $request->getPost('email'), $request->getPost('password'));
|
||||||
} catch (Wootook_Empire_Exception_RuntimeException $e) {
|
} catch (Wootook_Empire_Exception_RuntimeException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$layout->getMessagesBlock()->prepareMessages('user');
|
$layout->getMessagesBlock()->prepareMessages('user');
|
||||||
if (!$user || !$user->getId()) {
|
if (!$user || !$user->getId()) {
|
||||||
$session->setData('step', STEP_PROFILE);
|
$session->setData('step', STEP_PROFILE);
|
||||||
$session->setFormData($request->getData());
|
$session->setFormData($request->getAllDatas());
|
||||||
$session->addError(Wootook::__('Could not create user.'));
|
$session->addError(Wootook::__('Could not create user.'));
|
||||||
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE)));
|
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE)));
|
||||||
$response->sendHeaders();
|
$response->sendHeaders();
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
Wootook_Player_Model_Entity::setLoggedIn($user);
|
Wootook_Player_Model_Session::getSingleton()->setLoggedIn($user);
|
||||||
|
|
||||||
$user->setData('authlevel', LEVEL_ADMIN)->save();
|
$user->setData('authlevel', LEVEL_ADMIN)->save();
|
||||||
|
|
||||||
|
|
@ -543,7 +546,7 @@ case 'install':
|
||||||
}
|
}
|
||||||
|
|
||||||
$session->setData('step', STEP_CONFIG);
|
$session->setData('step', STEP_CONFIG);
|
||||||
//$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_CONFIG)));
|
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_CONFIG)));
|
||||||
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'summary')));
|
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'summary')));
|
||||||
$response->sendHeaders();
|
$response->sendHeaders();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue