';
-
- return $output;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Block/Template.php b/src/application/code/core/Wootook/Core/Block/Template.php
deleted file mode 100644
index 1383a4e..0000000
--- a/src/application/code/core/Wootook/Core/Block/Template.php
+++ /dev/null
@@ -1,46 +0,0 @@
-getScriptPath() == '') {
- Wootook_Core_ErrorProfiler::getSingleton()
- ->addException(new Wootook_Core_Exception_RuntimeException("No script path defined in block {$this->getNameInLayout()}."));
- return null;
- }
-
- $pattern = "{$this->getScriptPath()}/%s/%s/scripts/{$file}";
- if (($layout = $this->getLayout()) !== null) {
- $package = $this->getLayout()->getPackage();
- $theme = $this->getLayout()->getTheme();
-
- 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_Model_Layout::DEFAULT_THEME);
- if (Wootook::fileExists($path)) {
- return $path;
- }
- }
- } else {
- Wootook_Core_ErrorProfiler::getSingleton()
- ->addException(new Wootook_Core_Exception_RuntimeException("No layout defined."));
- }
-
- $path = sprintf($pattern, Wootook_Core_Model_Layout::DEFAULT_PACKAGE, Wootook_Core_Model_Layout::DEFAULT_THEME);
- if (Wootook::fileExists($path)) {
- return $path;
- }
-
- Wootook_Core_ErrorProfiler::getSingleton()
- ->addException(new Wootook_Core_Exception_RuntimeException("Template '{$file}' could not be found."));
- return null;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Block/Text.php b/src/application/code/core/Wootook/Core/Block/Text.php
deleted file mode 100644
index dabe336..0000000
--- a/src/application/code/core/Wootook/Core/Block/Text.php
+++ /dev/null
@@ -1,28 +0,0 @@
-_content = $content;
-
- return $this;
- }
-
- public function getContent()
- {
- return $this->_content;
- }
-
- public function render()
- {
- $content = $this->getContent();
- if (empty($content)) {
- return null;
- }
- return $content;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Config/Adapter/Adapter.php b/src/application/code/core/Wootook/Core/Config/Adapter/Adapter.php
deleted file mode 100644
index bec4430..0000000
--- a/src/application/code/core/Wootook/Core/Config/Adapter/Adapter.php
+++ /dev/null
@@ -1,6 +0,0 @@
-load($filename);
- }
- }
-
- public function load($filename)
- {
- if (!file_exists($filename)) {
- throw new Wootook_Core_Exception_DataAccessException(sprintf('Could not load config file "%s"', $filename));
- }
- $data = include $filename;
-
- if (!is_array($data)) {
- throw new Wootook_Core_Exception_DataAccessException('Configuration file could not be loaded.');
- }
-
- $this->_init($data);
-
- return $this;
- }
-
- public function save($filename)
- {
- file_put_contents($filename, '<' . '?p' . 'hp return ' . var_export($this->toArray(), true) . ';');
-
- return $this;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Controller/ErrorController.php b/src/application/code/core/Wootook/Core/Controller/ErrorController.php
deleted file mode 100644
index 0a2e348..0000000
--- a/src/application/code/core/Wootook/Core/Controller/ErrorController.php
+++ /dev/null
@@ -1,11 +0,0 @@
-loadLayout('no-route');
- $this->renderLayout();
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Controller/IndexController.php b/src/application/code/core/Wootook/Core/Controller/IndexController.php
deleted file mode 100644
index c77c6f0..0000000
--- a/src/application/code/core/Wootook/Core/Controller/IndexController.php
+++ /dev/null
@@ -1,11 +0,0 @@
-loadLayout('home');
- $this->renderLayout();
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php b/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php
deleted file mode 100644
index 41d8bdb..0000000
--- a/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php
+++ /dev/null
@@ -1,199 +0,0 @@
-_handler;
- }
-
- public function getDataMapper()
- {
- return new Wootook_Core_Database_Orm_DataMapper();
- }
-
- /**
- *
- * @param string $prefix
- * @return Wootook_Core_Database_Adapter_Pdo_Mysql
- */
- public function setTablePrefix($prefix)
- {
- $this->_tablePrefix = $prefix;
-
- return $this;
- }
-
- /**
- * @return string
- */
- public function getTablePrefix()
- {
- return $this->_tablePrefix;
- }
-
- /**
- * @return string
- */
- public function getTable($table)
- {
- return $this->getTablePrefix() . $table;
- }
-
- /**
- * @return Wootook_Core_Database_Sql_Select
- */
- public function select()
- {
- return new Wootook_Core_Database_Sql_Select($this);
- }
-
- /**
- * @return Wootook_Core_Database_Sql_Insert
- */
- public function insert()
- {
- return new Wootook_Core_Database_Sql_Insert($this);
- }
-
- /**
- * @return Wootook_Core_Database_Sql_Update
- */
- public function update()
- {
- return new Wootook_Core_Database_Sql_Update($this);
- }
-
- /**
- * @return Wootook_Core_Database_Sql_Delete
- */
- public function delete()
- {
- return new Wootook_Core_Database_Sql_Delete($this);
- }
-
- /**
- * @param string $data
- * @return string
- */
- abstract public function quote($data);
-
- /**
- * @param string $identifier
- * @return string
- */
- abstract public function quoteIdentifier($identifier);
-
- /**
- * @param string $identifier
- * @return string
- */
- public function quoteInto($string, $values)
- {
- $parts = preg_split('#(:[\w_]+|[?])#', $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
-
- $result = '';
- if (is_array($values)) {
- $index = 0;
- foreach ($parts as $part) {
- if ($part == '?') {
- $result .= $this->quote($values[$index++]);
- } else if (!empty($part) && $part[0] == ':') {
- $key = substr($part, 1);
-
- if (isset($values[$key])) {
- $result .= $this->quote($values[$key]);
- } else if (isset($values[$part])) {
- $result .= $this->quote($values[$part]);
- } else {
- $result .= $part;
- }
- } else {
- $result .= $part;
- }
- }
- } else {
- foreach ($parts as $part) {
- if ($part == '?' || $part[0] == ':') {
- $result .= $this->quote($values);
- } else {
- $result .= $part;
- }
- }
- }
-
- return $result;
- }
-
- /**
- * @return Wootook_Core_Database_Statement_Statement
- */
- public function query($sql, Array $params = null)
- {
- $statement = $this->prepare($sql, $params);
- if (!$statement->execute()) {
- $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 bool
- */
- public function execute($sql, Array $params = null)
- {
- $statement = $this->prepare($sql);
- return $statement->execute($params);
- }
-
- /**
- * @return Wootook_Core_Database_Statement_Statement
- */
- abstract public function prepare($sql, Array $params = null);
-
- /**
- * @return bool
- */
- abstract public function beginTransaction();
-
- /**
- * @return bool
- */
- abstract public function commit();
-
- /**
- * @return bool
- */
- abstract public function rollback();
-
- /**
- * @return bool
- */
- abstract public function lastInsertId();
-
- /**
- * @return string
- */
- abstract public function errorCode();
-
- /**
- * @return string
- */
- abstract public function errorMessage();
-
- /**
- * @return array
- */
- abstract public function errorInfo();
-
- /**
- * @return string
- */
- abstract public function errorState();
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Adapter/Pdo/Mysql.php b/src/application/code/core/Wootook/Core/Database/Adapter/Pdo/Mysql.php
deleted file mode 100644
index 5270cf2..0000000
--- a/src/application/code/core/Wootook/Core/Database/Adapter/Pdo/Mysql.php
+++ /dev/null
@@ -1,170 +0,0 @@
-hostname};dbname={$config->database}";
- if (is_numeric($config->port)) {
- $dsn .= ";port={$config->database}";
- }
-
- if (!isset($options[Wootook_Core_Database_ConnectionManager::ATTR_ERRMODE])) {
- $options[Wootook_Core_Database_ConnectionManager::ATTR_ERRMODE] = Wootook_Core_Database_ConnectionManager::ERRMODE_EXCEPTION;
- }
-
- try {
- $this->_handler = new PDO($dsn, $config->username, $config->password, $options);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e);
- }
- }
-
- /**
- * (non-PHPdoc)
- * @see Wootook_Core_Database_Adapter_Adapter::quoteIdentifier()
- */
- public function quoteIdentifier($identifier)
- {
- return "`$identifier`";
- }
-
- public function quote($data)
- {
- try {
- return $this->_handler->quote($data);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e);
- }
- return null;
- }
-
- /**
- *
- * @param string $name
- * @return string
- */
- public function getTable($name)
- {
- return $this->getTablePrefix() . $name;
- }
-
- /**
- * @see Wootook_Core_Database_Adapter_Adapter::select()
- */
- public function select($tableName = null)
- {
- return new Wootook_Core_Database_Sql_Mysql_Select($this, $tableName);
- }
-
- /**
- * @return Wootook_Core_Database_Statement_Statement
- */
- public function prepare($sql, Array $params = null)
- {
- $statement = new Wootook_Core_Database_Statement_Pdo_Mysql($this, $sql);
-
- if ($params !== null) {
- foreach ($params as $paramKey => $paramValue) {
- $statement->bindValue($paramKey, $paramValue, $statement->getParamType($paramValue));
- }
- }
-
- return $statement;
- }
-
- /**
- * @return bool
- */
- public function beginTransaction()
- {
- try {
- return $this->_handler->beginTransaction();
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e);
- }
- return false;
- }
-
- /**
- * @return bool
- */
- public function commit()
- {
- try {
- return $this->_handler->commit();
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e);
- }
- return false;
- }
-
- /**
- * @return bool
- */
- public function rollback()
- {
- try {
- return $this->_handler->rollback();
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e);
- }
- return false;
- }
-
- /**
- * @return int
- */
- public function lastInsertId()
- {
- try {
- return $this->_handler->lastInsertId();
- } 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];
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Array.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Array.php
deleted file mode 100644
index f1db44d..0000000
--- a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Array.php
+++ /dev/null
@@ -1,15 +0,0 @@
-toArray());
- }
-
- public function decode($value)
- {
- return new Wootook_Core_Config_Node(parent::decode($value));
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/DateTime.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/DateTime.php
deleted file mode 100644
index 1e37d12..0000000
--- a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/DateTime.php
+++ /dev/null
@@ -1,38 +0,0 @@
-_format = self::DATE_FORMAT_MYSQL;
- } else {
- $this->_format = $format;
- }
- return $this;
- }
-
- public function getFormat()
- {
- return $this->_format;
- }
-
- public function encode($value)
- {
- if (!$value instanceof Wootook_Core_DateTime) {
- $value = new Wootook_Core_DateTime($value);
- }
-
- return $value->toString($this->getFormat());
- }
-
- public function decode($value)
- {
- return new Wootook_Core_DateTime($value, $this->getFormat());
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php
deleted file mode 100644
index a7e989c..0000000
--- a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php
+++ /dev/null
@@ -1,15 +0,0 @@
-_mapper = $mapper;
- }
-
- abstract public function encode($value);
-
- abstract public function decode($value);
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Object.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Object.php
deleted file mode 100644
index 7af245b..0000000
--- a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Object.php
+++ /dev/null
@@ -1,43 +0,0 @@
-_entityClass = $class;
-
- return $this;
- }
-
- public function getEntityClass()
- {
- return $this->_entityClass;
- }
-
- protected function _newInstance(Array $args = array())
- {
- if ($this->_reflectionClass === null && $this->_entityClass !== null) {
- $this->_reflectionClass = new ReflectionClass($this->_entityClass);
- }
-
- return $this->newInstanceArgs($args);
- }
-
- public function encode($value)
- {
- return parent::encode($value->getAllDatas());
- }
-
- public function decode($value)
- {
- $object = $this->_newInstance();
- $object->addData(parent::decode($value));
-
- return $object;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Database/Resource.php b/src/application/code/core/Wootook/Core/Database/Resource.php
deleted file mode 100644
index 5501b32..0000000
--- a/src/application/code/core/Wootook/Core/Database/Resource.php
+++ /dev/null
@@ -1,89 +0,0 @@
-_dataMapper === null) {
- $this->_dataMapper = new Wootook_Core_Database_Orm_DataMapper();
- }
- return $this->_dataMapper;
- }
-
- public function setTableName($tableName)
- {
- $this->_tableName = $tableName;
-
- return $this;
- }
-
- public function getTableName()
- {
- return $this->_tableName;
- }
-
- /**
- * @return Wootook_Core_Database_Adapter_Adapter
- */
- public function getReadConnection()
- {
- if ($this->_readConnection === null) {
- $this->_readConnection = Wootook_Core_Database_ConnectionManager::getSingleton()
- ->getConnection('core_read');
- }
-
- return $this->_readConnection;
- }
-
- public function setReadConnection($connection)
- {
- if ($connection instanceof Wootook_Core_Database_Adapter_Pdo_Mysql) {
- $this->_readConnection = $connection;
- } else if (is_string($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.');
- }
-
- return $this;
- }
-
- /**
- * @return Wootook_Core_Database_Adapter_Adapter
- */
- public function getWriteConnection()
- {
- if ($this->_writeConnection === null) {
- $this->_writeConnection = Wootook_Core_Database_ConnectionManager::getSingleton()
- ->getConnection('core_write');
- }
- return $this->_writeConnection;
- }
-
- public function setWriteConnection($connection)
- {
- if ($connection instanceof Wootook_Core_Database_Adapter_Pdo_Mysql) {
- $this->_readConnection = $connection;
- } else if (is_string($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.');
- }
-
- return $this;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Dml.php b/src/application/code/core/Wootook/Core/Database/Sql/Dml.php
deleted file mode 100644
index de0c17b..0000000
--- a/src/application/code/core/Wootook/Core/Database/Sql/Dml.php
+++ /dev/null
@@ -1,24 +0,0 @@
-setConnection($connection);
-
- $this->reset();
- $this->_init($tableName);
- }
-
- /**
- * @return Wootook_Core_Database_Adapter_Adapter
- */
- public function getConnection()
- {
- return $this->_connection;
- }
-
- public function setConnection(Wootook_Core_Database_Adapter_Adapter $connection)
- {
- $this->_connection = $connection;
-
- return $this;
- }
-
- protected function _init($param = null)
- {
- return $this;
- }
-
- public function getPart($part = null)
- {
- if ($part === null) {
- return $this->_parts;
- }
- if (isset($this->_parts[$part])) {
- return $this->_parts[$part];
- }
-
- return null;
- }
-
- public function quote($data)
- {
- return $this->getConnection()->quote($data);
- }
-
- public function quoteIdentifier($identifier)
- {
- return $this->getConnection()->quoteIdentifier($identifier);
- }
-
- public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement)
- {
- foreach ($this->_placeholders as $placeholder) {
- $placeholder->beforePrepare($statement);
- }
-
- return $this;
- }
-
- public function afterPrepare(Wootook_Core_Database_Statement_Statement $statement)
- {
- foreach ($this->_placeholders as $placeholder) {
- $placeholder->afterPrepare($statement);
- }
-
- return $this;
- }
-
- public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement)
- {
- foreach ($this->_placeholders as $placeholder) {
- $placeholder->beforeExecute($statement);
- }
-
- return $this;
- }
-
- public function afterExecute(Wootook_Core_Database_Statement_Statement $statement)
- {
- foreach ($this->_placeholders as $placeholder) {
- $placeholder->afterExecute($statement);
- }
-
- return $this;
- }
-
- public function prepare()
- {
- return $this->getConnection()->prepare($this);
- }
-
- public function execute(Array $params = null)
- {
- return $this->getConnection()->execute($this, $params);
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Mysql/Select.php b/src/application/code/core/Wootook/Core/Database/Sql/Mysql/Select.php
deleted file mode 100644
index 5e8c80c..0000000
--- a/src/application/code/core/Wootook/Core/Database/Sql/Mysql/Select.php
+++ /dev/null
@@ -1,6 +0,0 @@
-_expression = (string) $expression;
- $this->_params = $params;
- }
-
- public function __toString()
- {
- return $this->_expression;
- }
-
- public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement)
- {
- parent::beforeExecute($statement);
-
- foreach ($this->_params as $paramName => $value) {
- $statement->bindValue($paramName, $value, $statement->getParamType($value));
- }
-
- return $this;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Param.php b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Param.php
deleted file mode 100644
index 5a77287..0000000
--- a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Param.php
+++ /dev/null
@@ -1,31 +0,0 @@
-_paramName = $paramName;
- $this->_paramType = $type;
- $this->_value = $value;
- }
-
- public function __toString()
- {
- return ':' . $this->_paramName;
- }
-
- public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement)
- {
- parent::beforeExecute($statement);
-
- $type = $this->_paramType !== null ? $this->_paramType : $statement->getParamType($this->_value);
- $statement->bindValue($this->_paramName, $this->_value, $type);
-
- return $this;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php
deleted file mode 100644
index b601575..0000000
--- a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php
+++ /dev/null
@@ -1,31 +0,0 @@
-__toString();
- }
-
- abstract public function __toString();
-
- public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement)
- {
- return $this;
- }
-
- public function afterPrepare(Wootook_Core_Database_Statement_Statement $statement)
- {
- return $this;
- }
-
- public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement)
- {
- return $this;
- }
-
- public function afterExecute(Wootook_Core_Database_Statement_Statement $statement)
- {
- return $this;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Variable.php b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Variable.php
deleted file mode 100644
index 04e4217..0000000
--- a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Variable.php
+++ /dev/null
@@ -1,20 +0,0 @@
-_paramName = $paramName;
- $this->_paramType = $type;
- }
-
- public function __toString()
- {
- return ':' . $this->_paramName;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php b/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php
deleted file mode 100644
index 33b243d..0000000
--- a/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php
+++ /dev/null
@@ -1,321 +0,0 @@
-_query = $query;
-
- if ($this->_query instanceof Wootook_Core_Database_Sql_Dml) {
- $this->_query->beforePrepare($this);
- }
-
- try {
- $this->_handler = $this->_adapter->getDriverHandler()->prepare($this->_query);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
-
- if ($this->_query instanceof Wootook_Core_Database_Sql_Dml) {
- $this->_query->afterPrepare($this);
- }
-
- return $this;
- }
-
- /**
- *
- * @param string|int $column
- * @param mixed $param
- * @param int $type
- * @return Wootook_Core_Database_Statement_Statement
- */
- public function bindColumn($column, &$param, $type = null)
- {
- try {
- return $this->_handler->bindColumn($column, $param, $type);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
-
- return false;
- }
-
- /**
- *
- * @param string|int $parameter
- * @param mixed $variable
- * @param int $type
- * @param int $length
- * @param unknown_type $options
- * @return Wootook_Core_Database_Statement_Statement
- */
- public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
- {
- try {
- return $this->_handler->bindParam($parameter, $variable, $type, $length, $options);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return false;
- }
-
- /**
- *
- * @param string|int $parameter
- * @param mixed $value
- * @param int $type
- * @return Wootook_Core_Database_Statement_Statement
- */
- public function bindValue($parameter, $value, $type = null)
- {
- try {
- return $this->_handler->bindValue($parameter, $value, $type);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return false;
- }
-
- /**
- *
- * @param array $params
- * @return bool
- */
- public function execute(Array $params = null)
- {
- if ($this->_query instanceof Wootook_Core_Database_Sql_Dml) {
- $this->_query->beforeExecute($this);
- }
-
- try {
- $result = $this->_handler->execute($params);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
-
- if ($this->_query instanceof Wootook_Core_Database_Sql_Dml) {
- $this->_query->afterExecute($this);
- }
-
- return $result;
- }
-
- /**
- *
- * @param int $style
- * @param int $col
- * @return mixed
- */
- public function fetchAll($style = null, $col = null)
- {
- try {
- if ($style !== null) {
- if ($col !== null) {
- $result = $this->_handler->fetchAll($style, $col);
- } else {
- $result = $this->_handler->fetchAll($style);
- }
- } else {
- $result = $this->_handler->fetchAll($style);
- }
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return $result;
- }
-
- /**
- *
- * @param int $col
- * @return mixed
- */
- public function fetchColumn($col = 0)
- {
- try {
- return $this->_handler->fetchColumn($col);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return null;
- }
-
- /**
- *
- * @return Wootook_Core_Database_Adapter_Adapter
- */
- public function getAdapter()
- {
- return $this->_adapter;
- }
-
- /**
- *
- * @param string $key
- */
- public function getAttribute($key)
- {
- try {
- return $this->_handler->getAttribute($key);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return null;
- }
-
- /**
- *
- * @param string $key
- * @param mixed $value
- * @return Wootook_Core_Database_Statement_Statement
- */
- public function setAttribute($key, $value)
- {
- try {
- return $this->_handler->setAttribute($key, $value);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return false;
- }
-
- /**
- * @param unknown_type $mode
- * @return Wootook_Core_Database_Statement_Statement
- */
- public function setFetchMode($mode)
- {
- try {
- $params = func_get_args();
- return call_user_func_array($array($this->_handler, 'setFetchMode'), $params);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return false;
- }
-
- /**
- * @return int
- */
- public function columnCount()
- {
- try {
- return $this->_handler->columnCount();
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return 0;
- }
-
- /**
- * @return int
- */
- public function rowCount()
- {
- try {
- return $this->_handler->rowCount();
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return 0;
- }
-
- /**
- * @param int $col
- * @return mixed
- */
- public function fetch($style = null, $orientation = Wootook_Core_Database_ConnectionManager::FETCH_ORI_NEXT, $cursorOffset = 0)
- {
- try {
- return $this->_handler->fetch($style, $orientation, $cursorOffset);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- return null;
- }
-
- /**
- * @param string $class
- * @param array $config
- * @return Wootook_Object
- */
- public function fetchObject($class = 'Wootook_Object', Array $constructorArgs = array())
- {
- try {
- return $this->_handler->fetchObject($class, $constructorArgs);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
- }
- 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];
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Database/Statement/Statement.php b/src/application/code/core/Wootook/Core/Database/Statement/Statement.php
deleted file mode 100644
index 9e8875f..0000000
--- a/src/application/code/core/Wootook/Core/Database/Statement/Statement.php
+++ /dev/null
@@ -1,215 +0,0 @@
-_adapter = $adapter;
-
- $this->_init($sql);
- }
-
- abstract protected function _init($sql);
-
- /**
- *
- * @param string|int $column
- * @param mixed $param
- * @param int $type
- * @return Wootook_Core_Database_Statement_Statement
- */
- abstract public function bindColumn($column, &$param, $type = null);
-
- /**
- *
- * @param string|int $parameter
- * @param mixed $variable
- * @param int $type
- * @param int $length
- * @param unknown_type $options
- * @return Wootook_Core_Database_Statement_Statement
- */
- abstract public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null);
-
- /**
- *
- * @param string|int $parameter
- * @param mixed $value
- * @param int $type
- * @return Wootook_Core_Database_Statement_Statement
- */
- abstract public function bindValue($parameter, $value, $type = null);
-
- /**
- *
- * @param array $params
- * @return bool
- */
- abstract public function execute(Array $params = null);
-
- /**
- *
- * @param int $style
- * @param int $col
- * @return mixed
- */
- abstract public function fetch($style = null, $orientation = Wootook_Core_Database_ConnectionManager::FETCH_ORI_NEXT, $cursorOffset = 0);
-
- /**
- *
- * @param int $style
- * @param int $col
- * @return mixed
- */
- abstract public function fetchAll($style = null, $col = null);
-
- /**
- *
- * @param int $col
- * @return mixed
- */
- abstract public function fetchColumn($col = 0);
-
- /**
- *
- * @param string $class
- * @param array $config
- * @return Wootook_Object
- */
- abstract public function fetchObject($class = 'Wootook_Object', Array $constructorArgs = array());
-
- /**
- *
- * @param string $class
- * @param array $config
- * @return Wootook_Object
- */
- public function fetchEntity($class = 'Wootook_Core_Mvc_Model_Entity', Array $constructorArgs = array())
- {
- $reflection = new ReflectionClass($class);
- $object = $reflection->newInstanceArgs($constructorArgs);
-
- if (!$object instanceof Wootook_Object) {
- throw new Wootook_Core_Exception_Database_StatementError($this, 'Destination object should be a Wootook_Core_Mvc_Model_Entity instance.');
- }
-
- $data = $this->fetch(Wootook_Core_Database_ConnectionManager::FETCH_ASSOC);
- if ($data !== false) {
- $object->getDataMapper()->decode($object, $data);
- }
-
- return $object;
- }
-
- /**
- *
- * @return Wootook_Core_Database_Adapter_Adapter
- */
- abstract public function getAdapter();
-
- /**
- *
- * @param string $key
- */
- abstract public function getAttribute($key);
-
- /**
- *
- * @param string $key
- * @param mixed $value
- * @return Wootook_Core_Database_Statement_Statement
- */
- abstract public function setAttribute($key, $value);
-
- /**
- * @param unknown_type $mode
- * @return Wootook_Core_Database_Statement_Statement
- */
- abstract public function setFetchMode($mode);
-
- /**
- * @return int
- */
- 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
- */
- abstract public function rowCount();
-
- /**
- * @return bool
- */
- abstract public function closeCursor();
-
- /**
- * @return bool
- */
- abstract public function nextRowset();
-
- public function getParamType($value)
- {
- if (is_numeric($value)) {
- return Wootook_Core_Database_ConnectionManager::PARAM_INT;
- } else if (is_bool($value)) {
- return Wootook_Core_Database_ConnectionManager::PARAM_BOOL;
- } else if (is_string($value)) {
- return Wootook_Core_Database_ConnectionManager::PARAM_STR;
- }
-
- return null;
- }
-
- public function current()
- {
- return $this->_currentRow;
- }
-
- public function next()
- {
- $this->_currentRow = $this->fetch();
- $this->_currentIndex++;
- }
-
- public function key()
- {
- return $this->_currentIndex;
- }
-
- public function rewind()
- {
- return $this->_currentIndex;
- }
-
- public function valid()
- {
- $rows = $this->rowCount();
- return $rows > 0 && $this->_currentIndex <= $rows;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Email.php b/src/application/code/core/Wootook/Core/Email.php
deleted file mode 100644
index e94331e..0000000
--- a/src/application/code/core/Wootook/Core/Email.php
+++ /dev/null
@@ -1,51 +0,0 @@
-setTransport($transport);
- }
-
- public function setTransport(Wootook_Core_Email_Transport_Transport $transport)
- {
- $this->_transport = $transport;
- }
-
- /**
- * @return Wootook_Core_Email_Transport_Transport
- */
- public function getTransport()
- {
- return $this->_transport;
- }
-
- public function send($to, $from, $subject, $body, Array $headers = array())
- {
- try {
- $this->_transport
- ->addRecipient($to)
- ->setFrom($from)
- ->setSubject($subject)
- ->addPart(new Wootook_Core_Email_Part_Part($body))
- ->addHeaders($headers)
- ->connect()
- ->send()
- ;
- } catch (Wootook_Core_Exception_RuntimeException $e) {
- throw new Wootook_Core_Exception_RuntimeException('Could not send mail.', null, $e);
- }
-
- $this->_transport->disconnect();
-
- return $this;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Email/Part/Part.php b/src/application/code/core/Wootook/Core/Email/Part/Part.php
deleted file mode 100644
index 563a051..0000000
--- a/src/application/code/core/Wootook/Core/Email/Part/Part.php
+++ /dev/null
@@ -1,16 +0,0 @@
-_content = $content;
- }
-
- public function render()
- {
- return $this->_content;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Email/Transport/Transport.php b/src/application/code/core/Wootook/Core/Email/Transport/Transport.php
deleted file mode 100644
index fed059e..0000000
--- a/src/application/code/core/Wootook/Core/Email/Transport/Transport.php
+++ /dev/null
@@ -1,22 +0,0 @@
-_adapter = $adapter;
- }
-
- public function getAdapter()
- {
- return $this->_adapter;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Exception/Database/Error.php b/src/application/code/core/Wootook/Core/Exception/Database/Error.php
deleted file mode 100644
index 6d485fa..0000000
--- a/src/application/code/core/Wootook/Core/Exception/Database/Error.php
+++ /dev/null
@@ -1,5 +0,0 @@
-_statement = $statement;
- }
-
- public function getStatement()
- {
- return $this->_statement;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Exception/Deprecated.php b/src/application/code/core/Wootook/Core/Exception/Deprecated.php
deleted file mode 100644
index 75cbf77..0000000
--- a/src/application/code/core/Wootook/Core/Exception/Deprecated.php
+++ /dev/null
@@ -1,7 +0,0 @@
-= 50300) {
- parent::__construct($message, $code, $previous);
- } else {
- parent::__construct($message, $code);
- $this->_previous = $previous;
- }
- }
-
- public function __call($method, $params)
- {
- if (strtolower($method) == 'getprevious') {
- return $this->_previous;
- }
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Exception/GameError.php b/src/application/code/core/Wootook/Core/Exception/GameError.php
deleted file mode 100644
index ab228a8..0000000
--- a/src/application/code/core/Wootook/Core/Exception/GameError.php
+++ /dev/null
@@ -1,7 +0,0 @@
-= 50300) {
- parent::__construct($message, $code, $previous);
- } else {
- parent::__construct($message, $code);
- $this->_previous = $previous;
- }
- }
-
- public function __call($method, $params)
- {
- if (strtolower($method) == 'getprevious') {
- return $this->_previous;
- }
- }
-
- public function __toString()
- {
- return <<_form = $form;
-
- foreach ($namespaces as $namespace => $path) {
- if (is_int($namespace)) {
- $this->registerNamespace($path);
- } else {
- $this->registerNamespace($namespace, $path);
- }
- }
- }
-
- protected function _load($className, $useSingleton, Array $constructorParams = array())
- {
- $reflection = new ReflectionClass($className);
- if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) {
- $method = $reflection->getMethod('getSingleton');
- return $method->invoke(null);
- }
-
- try {
- return $reflection->newInstance($this->_form);
- } catch (ReflectionException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()
- ->addException($e);
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Alnum.php b/src/application/code/core/Wootook/Core/Form/Validator/Alnum.php
deleted file mode 100644
index cdacc4f..0000000
--- a/src/application/code/core/Wootook/Core/Form/Validator/Alnum.php
+++ /dev/null
@@ -1,21 +0,0 @@
-_validate($element, $data)) {
- $this->_getSession($element)
- ->addError('Field "%s" should only contain alphanumeric characters.', $element->getName());
-
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Alpha.php b/src/application/code/core/Wootook/Core/Form/Validator/Alpha.php
deleted file mode 100644
index fb091ce..0000000
--- a/src/application/code/core/Wootook/Core/Form/Validator/Alpha.php
+++ /dev/null
@@ -1,21 +0,0 @@
-_validate($element, $data)) {
- $this->_getSession($element)
- ->addError('Field "%s" should only contain alphabetic characters.', $element->getName());
-
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Email.php b/src/application/code/core/Wootook/Core/Form/Validator/Email.php
deleted file mode 100644
index 3ec8e21..0000000
--- a/src/application/code/core/Wootook/Core/Form/Validator/Email.php
+++ /dev/null
@@ -1,21 +0,0 @@
-_validate($element, $data)) {
- $this->_getSession($element)
- ->addError('Field "%s" should contain an email.', $element->getName());
-
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/Validator/FormKey.php b/src/application/code/core/Wootook/Core/Form/Validator/FormKey.php
deleted file mode 100644
index 11f49d0..0000000
--- a/src/application/code/core/Wootook/Core/Form/Validator/FormKey.php
+++ /dev/null
@@ -1,20 +0,0 @@
-getForm();
- $session = $form->getSession();
-
- if ($session->getFormKey(false) == $data) {
- return true;
- }
-
- $this->_getSession($field)
- ->addError('CSRF token failure.', $field->getName());
-
- return false;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Hex.php b/src/application/code/core/Wootook/Core/Form/Validator/Hex.php
deleted file mode 100644
index cbb2913..0000000
--- a/src/application/code/core/Wootook/Core/Form/Validator/Hex.php
+++ /dev/null
@@ -1,22 +0,0 @@
-_validate($element, $data)) {
- $this->_getSession($element)
- ->addError('Field "%s" should only contain numeric characters.', $element->getName());
-
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Host.php b/src/application/code/core/Wootook/Core/Form/Validator/Host.php
deleted file mode 100644
index 4d1f7f5..0000000
--- a/src/application/code/core/Wootook/Core/Form/Validator/Host.php
+++ /dev/null
@@ -1,21 +0,0 @@
-_validate($element, $data)) {
- $this->_getSession($element)
- ->addError('Field "%s" should contain a host name.', $element->getName());
-
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Numeric.php b/src/application/code/core/Wootook/Core/Form/Validator/Numeric.php
deleted file mode 100644
index 35f275d..0000000
--- a/src/application/code/core/Wootook/Core/Form/Validator/Numeric.php
+++ /dev/null
@@ -1,22 +0,0 @@
-_validate($element, $data)) {
- $this->_getSession($element)
- ->addError('Field "%s" should only contain numeric characters.', $element->getName());
-
- return false;
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Regex.php b/src/application/code/core/Wootook/Core/Form/Validator/Regex.php
deleted file mode 100644
index 172a787..0000000
--- a/src/application/code/core/Wootook/Core/Form/Validator/Regex.php
+++ /dev/null
@@ -1,28 +0,0 @@
-_expression = $expression;
- }
-
- public function validate(Wootook_Core_Form_ElementAbstract $element, $data)
- {
- if (!$this->_validate($element, $data)) {
- $this->_getSession($element)
- ->addError('Field "%s" does not match the validation pattern.', $element->getName());
-
- return false;
- }
- return true;
- }
-
- protected function _validate(Wootook_Core_Form_ElementAbstract $element, $data)
- {
- return preg_match($this->_expression, $data);
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/ValidatorAbstract.php b/src/application/code/core/Wootook/Core/Form/ValidatorAbstract.php
deleted file mode 100644
index d3f6da2..0000000
--- a/src/application/code/core/Wootook/Core/Form/ValidatorAbstract.php
+++ /dev/null
@@ -1,15 +0,0 @@
-getForm();
- if (!$form instanceof Wootook_Core_Form) {
- return null;
- }
- return $element->getSession();
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Form/ValidatorLoader.php b/src/application/code/core/Wootook/Core/Form/ValidatorLoader.php
deleted file mode 100644
index 123bd64..0000000
--- a/src/application/code/core/Wootook/Core/Form/ValidatorLoader.php
+++ /dev/null
@@ -1,37 +0,0 @@
-_form = $form;
-
- foreach ($namespaces as $namespace => $path) {
- if (is_int($namespace)) {
- $this->registerNamespace($path);
- } else {
- $this->registerNamespace($namespace, $path);
- }
- }
- }
-
- protected function _load($className, $useSingleton, Array $constructorParams = array())
- {
- $reflection = new ReflectionClass($className);
- if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) {
- $method = $reflection->getMethod('getSingleton');
- return $method->invoke(null);
- }
-
- try {
- return $reflection->newInstance();
- } catch (ReflectionException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()
- ->addException($e);
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php b/src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php
deleted file mode 100644
index 7421bad..0000000
--- a/src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php
+++ /dev/null
@@ -1,59 +0,0 @@
- 'default',
- 'episode' => 'default'
- );
- } else {
- $config = $config->toArray();
- }
-
- $path = 'gamedata' . DIRECTORY_SEPARATOR . $config['universe'] . DIRECTORY_SEPARATOR
- . $config['episode'] . DIRECTORY_SEPARATOR . $filename . '.php';
-
- foreach (include APPLICATION_PATH . $path as $elementId => $fieldName) {
- $this->setData($elementId, $fieldName);
- }
-
- return $this;
- }
-
- public function count()
- {
- return count($this->_data);
- }
-
- public function current()
- {
- return current($this->_data);
- }
-
- public function next()
- {
- return next($this->_data);
- }
-
- public function key()
- {
- return key($this->_data);
- }
-
- public function valid()
- {
- return $this->current() !== false;
- }
-
- public function rewind()
- {
- reset($this->_data);
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Helper/Config/Events.php b/src/application/code/core/Wootook/Core/Helper/Config/Events.php
deleted file mode 100644
index 30b0528..0000000
--- a/src/application/code/core/Wootook/Core/Helper/Config/Events.php
+++ /dev/null
@@ -1,56 +0,0 @@
- $listenerList) {
- foreach ($listenerList as $listener) {
- Wootook::registerListener($event, $listener);
- }
- }
- }
-
- protected function _init()
- {
- $this->_initData('events');
- return $this;
- }
-
- protected function _load()
- {
- // NOP
- return $this;
- }
-
- protected function _save()
- {
- // NOP
- return $this;
- }
-
- protected function _delete()
- {
- // NOP
- return $this;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Helper/Config/Modules.php b/src/application/code/core/Wootook/Core/Helper/Config/Modules.php
deleted file mode 100644
index 17d1a46..0000000
--- a/src/application/code/core/Wootook/Core/Helper/Config/Modules.php
+++ /dev/null
@@ -1,47 +0,0 @@
-_initData('modules');
- return $this;
- }
-
- protected function _load()
- {
- // NOP
- return $this;
- }
-
- protected function _save()
- {
- // NOP
- return $this;
- }
-
- protected function _delete()
- {
- // NOP
- return $this;
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Model/Config.php b/src/application/code/core/Wootook/Core/Model/Config.php
deleted file mode 100644
index 5607ddf..0000000
--- a/src/application/code/core/Wootook/Core/Model/Config.php
+++ /dev/null
@@ -1,61 +0,0 @@
-_tableName = 'core_config';
- $this->_idFieldNames = array('config_path', 'website_id', 'game_id');
- }
-
- public function setWebsiteId($websiteId)
- {
- return $this->setData('website_id', $websiteId);
- }
-
- public function getWebsiteId()
- {
- return $this->getData('website_id');
- }
-
- public function setGameId($gameId)
- {
- return $this->setData('game_id', $gameId);
- }
-
- public function getGameId()
- {
- return $this->getData('game_id');
- }
-
- public function setPath($path)
- {
- return $this->setData('config_path', $path);
- }
-
- public function getPath()
- {
- return $this->getData('config_path');
- }
-
- public function setValue($value)
- {
- return $this->setData('config_value', $value);
- }
-
- public function getValue()
- {
- return $this->getData('config_value');
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Model/Game.php b/src/application/code/core/Wootook/Core/Model/Game.php
deleted file mode 100644
index bc4c234..0000000
--- a/src/application/code/core/Wootook/Core/Model/Game.php
+++ /dev/null
@@ -1,23 +0,0 @@
-_tableName = 'core_game';
- $this->_idFieldName = 'game_id';
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Model/Translator.php b/src/application/code/core/Wootook/Core/Model/Translator.php
deleted file mode 100644
index 6d81883..0000000
--- a/src/application/code/core/Wootook/Core/Model/Translator.php
+++ /dev/null
@@ -1,37 +0,0 @@
-= 2) {
- $this->_translations[$line[0]] = $line[1];
- }
- }
- }
- }
-
- public function translate($message, $_ = null)
- {
- $args = func_get_args();
- array_shift($args);
-
- return $this->translateArgs($message, $args);
- }
-
- public function translateArgs($message, Array $args = array())
- {
- if (isset($this->_translations[$message])) {
- $message = $this->_translations[$message];
- }
-
- return vsprintf($message, $args);
- }
-}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Core/Model/Website.php b/src/application/code/core/Wootook/Core/Model/Website.php
deleted file mode 100644
index 018edac..0000000
--- a/src/application/code/core/Wootook/Core/Model/Website.php
+++ /dev/null
@@ -1,23 +0,0 @@
-_tableName = 'core_website';
- $this->_idFieldName = 'website_id';
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php
deleted file mode 100644
index 3a77073..0000000
--- a/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php
+++ /dev/null
@@ -1,35 +0,0 @@
-init();
-
- parent::__construct($data);
- }
-
- public function setParam($key, $value)
- {
- return $this->setData($key, $value);
- }
-
- public function getParam($key, $default = null)
- {
- if ($this->hasData($key)) {
- return $this->getData($key);
- }
- return $default;
- }
-
- abstract public function init();
-
- abstract public function getModuleName();
- abstract public function getControllerName();
- abstract public function getActionName();
-
- abstract public function setModuleName($name);
- abstract public function setControllerName($name);
- abstract public function setActionName($name);
-}
diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Response.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Response.php
deleted file mode 100644
index a36048a..0000000
--- a/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Response.php
+++ /dev/null
@@ -1,21 +0,0 @@
-_isDispatched = $dispatched;
-
- return $this;
- }
-
- public function isDispatched()
- {
- return $this->_isDispatched;
- }
-
- abstract public function render($send = true);
-}
diff --git a/src/application/code/core/Wootook/Core/Mvc/Model/Entity.php b/src/application/code/core/Wootook/Core/Mvc/Model/Entity.php
deleted file mode 100644
index 2c19005..0000000
--- a/src/application/code/core/Wootook/Core/Mvc/Model/Entity.php
+++ /dev/null
@@ -1,142 +0,0 @@
-_idFieldName = $fieldName;
-
- return $this;
- }
-
- public function getIdFieldName()
- {
- return $this->_idFieldName;
- }
-
- public function setId($id)
- {
- $this->setData($this->getIdFieldName(), $id);
-
- return $this;
- }
-
- public function getId()
- {
- return $this->getData($this->getIdFieldName());
- }
-
- protected function _load()
- {
- $id = func_get_arg(0);
-
- if (func_num_args() >= 2) {
- $idFieldName = func_get_arg(1);
- } else {
- $idFieldName = $this->getIdFieldName();
- }
-
- $database = $this->getReadConnection();
- if ($database === null) {
- throw new Wootook_Core_Exception_DataAccessException('Could not load data: no read connection configured.');
- }
-
- $select = $database->select()
- ->from(array('main_table' => $database->getTable($this->getTableName())))
- ->where($idFieldName, new Wootook_Core_Database_Sql_Placeholder_Param('id', $id))
- ->limit(1);
-
- $statement = $select->prepare();
- $statement->execute(array(
- 'id' => $id
- ));
-
- $datas = $statement->fetch(PDO::FETCH_ASSOC);
- if (!is_array($datas) || empty($datas)) {
- throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id could not be found.');
- }
- $realId = $datas[$this->getIdFieldName()];
- unset($datas[$this->getIdFieldName()]);
-
- $this->_data = array();
- $this->getDataMapper()->decode($this, $datas);
- $this->setId($realId);
-
- return $this;
- }
-
- protected function _save()
- {
- $adapter = $this->getWriteConnection();
-
- if ($adapter === null) {
- throw new Wootook_Core_Exception_DataAccessException('Could not save data: no write connection configured.');
- }
-
- if ($this->getId() !== null) {
- $update = $adapter->update()
- ->into($adapter->getTable($this->getTableName()))
- ->where(new Wootook_Core_Database_Sql_Placeholder_Expression("{$adapter->quoteIdentifier($this->getIdFieldName())}=:id", array('id' => $this->getId())));
-
- foreach ($this->getDataMapper()->encode($this, $this->getChangedDatas()) as $field => $value) {
- $update->set($field, new Wootook_Core_Database_Sql_Placeholder_Param($field, $value));
- }
- try {
- $statement = $update->prepare();
- $statement->execute();
- } catch (Wootook_Core_Exception_Database_AdapterError $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), null, $e);
- } catch (Wootook_Core_Exception_Database_StatementError $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), null, $e);
- }
- } else {
- $insert = $adapter->insert()
- ->into($adapter->getTable($this->getTableName()));
-
- foreach ($this->getDataMapper()->encode($this, $this->getAllDatas()) as $field => $value) {
- $insert->set($field, new Wootook_Core_Database_Sql_Placeholder_Param($field, $value));
- }
- try {
- $statement = $insert->prepare();
- $statement->execute();
-
- $id = $adapter->lastInsertId($adapter->getTable($this->getTableName()));
- $this->setId($id);
- } catch (Wootook_Core_Exception_Database_AdapterError $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), null, $e);
- } catch (Wootook_Core_Exception_Database_StatementError $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), null, $e);
- }
- }
-
- return $this;
- }
-
- protected function _delete()
- {
- $adapter = $this->getWriteConnection();
- if ($adapter === null) {
- throw new Wootook_Core_Exception_DataAccessException('Could not delete data: no write connection configured.');
- }
- $delete = $adapter
- ->delete()
- ->from($adapter->getTable($this->getTableName()))
- ->where($this->getIdFieldName(), $this->getId())
- ->limit(1);
-
- try {
- $statement = $adapter->prepare($delete);
- $statement->execute();
- } catch (Wootook_Core_Exception_Database_AdapterError $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not delete data: ' . $e->getMessage(), null, $e);
- } catch (Wootook_Core_Exception_Database_StatementError $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not delete data: ' . $e->getMessage(), null, $e);
- }
-
- return $this;
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Mvc/Model/Model.php b/src/application/code/core/Wootook/Core/Mvc/Model/Model.php
deleted file mode 100644
index e91265f..0000000
--- a/src/application/code/core/Wootook/Core/Mvc/Model/Model.php
+++ /dev/null
@@ -1,205 +0,0 @@
-
- * 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 .
- *
- * --> 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
- *
- */
-abstract class Wootook_Core_Mvc_Model_Model
- extends Wootook_Object
-{
- protected $_originalData = array();
-
- protected $_eventPrefix = null;
- protected $_eventObject = null;
-
- public function __construct(Array $data = array())
- {
- $this->_data = $data;
-
- $this->_init();
- $this->_setOriginalData();
- }
-
- abstract protected function _init();
-
- protected function _setOriginalData()
- {
- $this->_originalData = $this->_data;
- }
-
- public function getChangedDatas()
- {
- return array_diff_assoc($this->_data, $this->_originalData);
- }
-
- public function hasChangedDatas()
- {
- if (count($this->getChangedDatas()) > 0) {
- return true;
- }
- return false;
- }
-
- final public function save()
- {
- try {
- $params = func_get_args();
- call_user_func_array(array($this, '_beforeSave'), $params);
- call_user_func_array(array($this, '_save'), $params);
- call_user_func_array(array($this, '_afterSave'), $params);
- $this->_setOriginalData($this->_data);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), 0);
- }
- return $this;
- }
-
- abstract protected function _save();
-
- protected function _beforeSave()
- {
- Wootook::dispatchEvent('model.before-save', array('model' => $this));
-
- if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
- Wootook::dispatchEvent($this->_eventPrefix . '.before-save', array($this->_eventObject => $this));
- }
-
- return $this;
- }
-
- protected function _afterSave()
- {
- Wootook::dispatchEvent('model.after-save', array('model' => $this));
-
- if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
- Wootook::dispatchEvent($this->_eventPrefix . '.after-save', array($this->_eventObject => $this));
- }
-
- return $this;
- }
-
- final public function load()
- {
- try {
- $params = func_get_args();
- call_user_func_array(array($this, '_beforeLoad'), $params);
- call_user_func_array(array($this, '_load'), $params);
- call_user_func_array(array($this, '_afterLoad'), $params);
- $this->_setOriginalData($this->_data);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not load data: ' . $e->getMessage(), 0, $e);
- }
- return $this;
- }
-
- abstract protected function _load();
-
- protected function _beforeLoad()
- {
- Wootook::dispatchEvent('model.before-load', array('model' => $this));
-
- if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
- Wootook::dispatchEvent($this->_eventPrefix . '.before-load', array($this->_eventObject => $this));
- }
-
- return $this;
- }
-
- protected function _afterLoad()
- {
- Wootook::dispatchEvent('model.after-load', array('model' => $this));
-
- if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
- Wootook::dispatchEvent($this->_eventPrefix . '.after-load', array($this->_eventObject => $this));
- }
-
- return $this;
- }
-
- final public function delete()
- {
- try {
- $params = func_get_args();
- call_user_func_array(array($this, '_beforeDelete'), $params);
- call_user_func_array(array($this, '_delete'), $params);
- call_user_func_array(array($this, '_afterDelete'), $params);
- } catch (PDOException $e) {
- throw new Wootook_Core_Exception_DataAccessException('Could not delete entity: ' . $e->getMessage(), 0);
- }
- return $this;
- }
-
- abstract protected function _delete();
-
- protected function _beforeDelete()
- {
- Wootook::dispatchEvent('model.before-delete', array('model' => $this));
-
- if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
- Wootook::dispatchEvent($this->_eventPrefix . '.before-delete', array($this->_eventObject => $this));
- }
-
- return $this;
- }
-
- protected function _afterDelete()
- {
- Wootook::dispatchEvent('model.after-delete', array('model' => $this));
-
- if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
- Wootook::dispatchEvent($this->_eventPrefix . '.after-delete', array($this->_eventObject => $this));
- }
-
- return $this;
- }
-
- public function __set($key, $value)
- {
- return $this->setData($key, $value);
- }
-
- public function __get($key)
- {
- return $this->getData($key);
- }
-
- public function __unset($key)
- {
- return $this->unsetData($key);
- }
-
- public function __isset($key)
- {
- return $this->hasData($key);
- }
-}
diff --git a/src/application/code/core/Wootook/Core/Setup/Exception/RuntimeException.php b/src/application/code/core/Wootook/Core/Setup/Exception/RuntimeException.php
deleted file mode 100644
index 29a8002..0000000
--- a/src/application/code/core/Wootook/Core/Setup/Exception/RuntimeException.php
+++ /dev/null
@@ -1,7 +0,0 @@
-_setupConnection = Wootook_Core_Database_ConnectionManager::getSingleton()
- ->getConnection($connection);
- } else {
- $this->_setupConnection = $connection;
- }
-
- return $this;
- }
-
- /**
- *
- * Enter description here ...
- * @return Wootook_Core_Database_Adapter_Pdo_Mysql
- */
- public function getSetupConnection()
- {
- if ($this->_setupConnection === null) {
- $this->setSetupConnection('default');
- }
- return $this->_setupConnection;
- }
-
- public function getTableName($tableName)
- {
- return $this->getSetupConnection()->getTable($tableName);
- }
-
- public function query($statement)
- {
- try {
- if (!$this->getSetupConnection()->query($statement)) {
- $info = $this->getSetupConnection()->errorInfo();
- throw new Wootook_Core_Setup_Exception_RuntimeException(
- Wootook::__('Query failed: SQLSTATE %s: %s.', $info[1], $info[2]));
- }
- } catch (PDOException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
- throw new Wootook_Core_Setup_Exception_RuntimeException($e->getMessage(), null, $e);
- }
- }
-
- public function grant($tableName, $connectionName, $perms = null)
- {
- $hostname = Wootook::getConfig("database/{$connectionName}/params/hostname");
- $username = Wootook::getConfig("database/{$connectionName}/params/username");
- $database = Wootook::getConfig("database/{$connectionName}/params/database");
- $password = Wootook::getConfig("database/{$connectionName}/params/password");
-
- if ($perms === null) {
- $perms = 'ALL PRIVILEGES';
- } else if (is_array($perms)) {
- $perms = implode(' ', $perms);
- }
-
- $sql =<<getTable($tableName)}
-TO '{$username}@{$hostname}' IDENTIFIED BY '$password'
-SQL_EOF;
-
- $this->getSetupConnection()->query($sql);
-
- return $this;
- }
-
- public function revoke($tableName, $connectionName, $perms = null)
- {
- $hostname = Wootook::getConfig("database/{$connectionName}/params/hostname");
- $username = Wootook::getConfig("database/{$connectionName}/params/username");
- $database = Wootook::getConfig("database/{$connectionName}/params/database");
- $password = Wootook::getConfig("database/{$connectionName}/params/password");
-
- if ($perms === null) {
- $perms = 'ALL PRIVILEGES';
- } else if (is_array($perms)) {
- $perms = implode(' ', $perms);
- }
-
- $sql =<<getTable($tableName)}
-FROM '{$username}@{$hostname}'
-SQL_EOF;
-
- $this->getSetupConnection()->query($sql);
-
- return $this;
- }
-
- public function run($script)
- {
- include $script;
- }
-
- public function getConfig($path = null)
- {
- return Wootook::getConfig($path);
- }
-
- public function getWebsiteConfig($path = null, $websiteId = null)
- {
- return Wootook::getWebsiteConfig($path, $websiteId);
- }
-
- public function getGameConfig($path = null, $gameId = null)
- {
- return Wootook::getGameConfig($path, $gameId);
- }
-}
diff --git a/src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php b/src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php
index 8d78612..a780d30 100644
--- a/src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php
+++ b/src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_Overview_DestroyPlanet
extends Wootook_Core_Block_Html_Form
diff --git a/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List.php b/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List.php
index 770fcbb..dd2c30a 100644
--- a/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List.php
+++ b/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_Overview_Fleet_List
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List/Item.php b/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List/Item.php
index cd1cffc..0a8fbc1 100644
--- a/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List/Item.php
+++ b/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List/Item.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_Overview_Fleet_List_Item
extends Wootook_Core_Block_Template
@@ -103,12 +131,12 @@ class Wootook_Empire_Block_Overview_Fleet_List_Item
public function getOriginPlanetName()
{
- return $this->getOriginPlanetName();
+ return $this->getFleetItem()->getOriginPlanetName();
}
public function getOriginPlanetCoords()
{
- return $this->getOriginPlanetCoords();
+ return $this->getFleetItem()->getOriginPlanetCoords();
}
public function getDestinationPlanet()
@@ -133,12 +161,12 @@ class Wootook_Empire_Block_Overview_Fleet_List_Item
public function getDestinationPlanetName()
{
- return $this->getDestinationPlanetName();
+ return $this->getFleetItem()->getDestinationPlanetName();
}
public function getDestinationPlanetCoords()
{
- return $this->getDestinationPlanetCoords();
+ return $this->getFleetItem()->getDestinationPlanetCoords();
}
public function getMissionLabel()
diff --git a/src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php b/src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php
index 24ece3e..8aebc64 100644
--- a/src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php
+++ b/src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_Overview_RenamePlanet
extends Wootook_Core_Block_Html_Form
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php
index dfffacd..eb65634 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
abstract class Wootook_Empire_Block_Planet_Builder_ItemAbstract
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php
index 962783a..38d33a9 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
abstract class Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract
extends Wootook_Empire_Block_Planet_Builder_ItemAbstract
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php
index baf9c71..93167af 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
abstract class Wootook_Empire_Block_Planet_Builder_QueueAbstract
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php
index 9cc98f2..c3a7ef9 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
abstract class Wootook_Empire_Block_Planet_BuilderAbstract
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Buildings.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings.php
index 77d4a86..5cbc9e4 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/Buildings.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_Planet_Buildings
extends Wootook_Empire_Block_Planet_BuilderAbstract
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php
index 1c4a970..3abe561 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php
@@ -1,7 +1,40 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Empire_Block_Planet_Buildings_Item
- extends Wootook_Empire_Block_Planet_Builder_ItemAbstract
+namespace Wootook\Empire\Block\Planet\Buildings;
+
+use Wootook\Core,
+ Wootook\Empire\Block\Planet\Builder;
+
+class Item
+ extends Builder\ItemAbstract
{
public function getLevel()
{
@@ -45,7 +78,7 @@ class Wootook_Empire_Block_Planet_Buildings_Item
$resourceConfig = array();
foreach ($resources as $resourceId => $resourceValue) {
- $resourceConfig[$resourceId] = new Wootook_Object(array(
+ $resourceConfig[$resourceId] = new Core\BaseObject($this->app(), array(
'resource_id' => $resourceId,
'value' => $resourceValue
));
@@ -69,4 +102,4 @@ class Wootook_Empire_Block_Planet_Buildings_Item
{
return $this->getBuildingTime($this->getNextLevel());
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php
index b1c3f55..cb9664a 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_Planet_Buildings_Queue
extends Wootook_Empire_Block_Planet_Builder_QueueAbstract
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php
index 6941b62..196814a 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php
@@ -28,14 +28,19 @@
*
*/
+namespace Wootook\Empire\Block\Planet\Buildings\Queue;
+
+use Wootook\Core,
+Wootook\Empire\Block\Planet\Builder\Queue;
+
/**
*
* Enter description here ...
* @author Greg
*
*/
-class Wootook_Empire_Block_Planet_Buildings_Queue_Item
- extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract
+class Item
+ extends Queue\ItemAbstract
{
protected $_itemIdField = 'building_id';
@@ -78,7 +83,7 @@ class Wootook_Empire_Block_Planet_Buildings_Queue_Item
$resourceConfig = array();
foreach ($resources as $resourceId => $resourceValue) {
- $resourceConfig[$resourceId] = new Wootook_Object(array(
+ $resourceConfig[$resourceId] = new Core\BaseObject($this->app(), array(
'resource_id' => $resourceId,
'value' => $resourceValue
));
@@ -102,4 +107,4 @@ class Wootook_Empire_Block_Planet_Buildings_Queue_Item
{
return $this->getBuildingTime($this->getNextLevel());
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Overview.php b/src/application/code/core/Wootook/Empire/Block/Planet/Overview.php
index f24f5dc..603e910 100644
--- a/src/application/code/core/Wootook/Empire/Block/Planet/Overview.php
+++ b/src/application/code/core/Wootook/Empire/Block/Planet/Overview.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_Planet_Overview
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Empire/Block/PlanetList.php b/src/application/code/core/Wootook/Empire/Block/PlanetList.php
index 4d1decf..4b54f75 100644
--- a/src/application/code/core/Wootook/Empire/Block/PlanetList.php
+++ b/src/application/code/core/Wootook/Empire/Block/PlanetList.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_PlanetList
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Empire/Block/Topnav.php b/src/application/code/core/Wootook/Empire/Block/Topnav.php
index 72a6d5b..1b31d84 100644
--- a/src/application/code/core/Wootook/Empire/Block/Topnav.php
+++ b/src/application/code/core/Wootook/Empire/Block/Topnav.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Block_Topnav
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Empire/Controller/BuildingsController.php b/src/application/code/core/Wootook/Empire/Controller/BuildingsController.php
index 6a5234b..777ac8c 100644
--- a/src/application/code/core/Wootook/Empire/Controller/BuildingsController.php
+++ b/src/application/code/core/Wootook/Empire/Controller/BuildingsController.php
@@ -1,10 +1,31 @@
+ * 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 .
+ *
+ * --> 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.
+ *
*/
class Wootook_Empire_Controller_BuildingsController
extends Wootook_Player_Mvc_Controller_Registered
diff --git a/src/application/code/core/Wootook/Empire/Exception.php b/src/application/code/core/Wootook/Empire/Exception.php
index e2bd909..9633dca 100644
--- a/src/application/code/core/Wootook/Empire/Exception.php
+++ b/src/application/code/core/Wootook/Empire/Exception.php
@@ -1,3 +1,31 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
interface Wootook_Empire_Exception extends Wootook_Exception {}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Empire/Exception/Exception.php b/src/application/code/core/Wootook/Empire/Exception/Exception.php
index b3154b8..fb0647b 100644
--- a/src/application/code/core/Wootook/Empire/Exception/Exception.php
+++ b/src/application/code/core/Wootook/Empire/Exception/Exception.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Exception_Exception
extends Exception
diff --git a/src/application/code/core/Wootook/Empire/Exception/Planet.php b/src/application/code/core/Wootook/Empire/Exception/Planet.php
index 36c2cf2..9a4f00b 100644
--- a/src/application/code/core/Wootook/Empire/Exception/Planet.php
+++ b/src/application/code/core/Wootook/Empire/Exception/Planet.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Exception_Planet
extends Wootook_Empire_Exception_RuntimeException
diff --git a/src/application/code/core/Wootook/Empire/Exception/RuntimeException.php b/src/application/code/core/Wootook/Empire/Exception/RuntimeException.php
index c4dcb32..7e03d1e 100644
--- a/src/application/code/core/Wootook/Empire/Exception/RuntimeException.php
+++ b/src/application/code/core/Wootook/Empire/Exception/RuntimeException.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Exception_RuntimeException
extends RuntimeException
diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Combat.php b/src/application/code/core/Wootook/Empire/Helper/Config/Combat.php
index 26a1bc8..f89db25 100644
--- a/src/application/code/core/Wootook/Empire/Helper/Config/Combat.php
+++ b/src/application/code/core/Wootook/Empire/Helper/Config/Combat.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Helper_Config_Combat
@@ -44,4 +72,4 @@ class Wootook_Empire_Helper_Config_Combat
// NOP
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php b/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php
index 101bc5f..f171de0 100644
--- a/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php
+++ b/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Helper_Config_FieldsAlias
@@ -44,4 +72,4 @@ class Wootook_Empire_Helper_Config_FieldsAlias
// NOP
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Labels.php b/src/application/code/core/Wootook/Empire/Helper/Config/Labels.php
index 94297a2..1e0b860 100644
--- a/src/application/code/core/Wootook/Empire/Helper/Config/Labels.php
+++ b/src/application/code/core/Wootook/Empire/Helper/Config/Labels.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Helper_Config_Labels
diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Prices.php b/src/application/code/core/Wootook/Empire/Helper/Config/Prices.php
index 1a328de..889e506 100644
--- a/src/application/code/core/Wootook/Empire/Helper/Config/Prices.php
+++ b/src/application/code/core/Wootook/Empire/Helper/Config/Prices.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Helper_Config_Prices
@@ -44,4 +72,4 @@ class Wootook_Empire_Helper_Config_Prices
// NOP
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Production.php b/src/application/code/core/Wootook/Empire/Helper/Config/Production.php
index d4539fc..11be14e 100644
--- a/src/application/code/core/Wootook/Empire/Helper/Config/Production.php
+++ b/src/application/code/core/Wootook/Empire/Helper/Config/Production.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Helper_Config_Production
@@ -44,4 +72,4 @@ class Wootook_Empire_Helper_Config_Production
// NOP
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php b/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php
index 04ea042..3a7c544 100644
--- a/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php
+++ b/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Helper_Config_Requirements
@@ -44,4 +72,4 @@ class Wootook_Empire_Helper_Config_Requirements
// NOP
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Resources.php b/src/application/code/core/Wootook/Empire/Helper/Config/Resources.php
index 8ce2483..212ebaa 100644
--- a/src/application/code/core/Wootook/Empire/Helper/Config/Resources.php
+++ b/src/application/code/core/Wootook/Empire/Helper/Config/Resources.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Helper_Config_Resources
@@ -44,4 +72,4 @@ class Wootook_Empire_Helper_Config_Resources
// NOP
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Types.php b/src/application/code/core/Wootook/Empire/Helper/Config/Types.php
index 9ef029d..ac3feaa 100644
--- a/src/application/code/core/Wootook/Empire/Helper/Config/Types.php
+++ b/src/application/code/core/Wootook/Empire/Helper/Config/Types.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Helper_Config_Types
@@ -52,4 +80,4 @@ class Wootook_Empire_Helper_Config_Types
}
return in_array($element, $this->getData($type));
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Model/Builder/Break.php b/src/application/code/core/Wootook/Empire/Model/Builder/Break.php
index a1bfc75..af6d5f7 100644
--- a/src/application/code/core/Wootook/Empire/Model/Builder/Break.php
+++ b/src/application/code/core/Wootook/Empire/Model/Builder/Break.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Model_Builder_Break
extends Exception
diff --git a/src/application/code/core/Wootook/Empire/Model/Builder/Item.php b/src/application/code/core/Wootook/Empire/Model/Builder/Item.php
index d590b81..0817b55 100644
--- a/src/application/code/core/Wootook/Empire/Model/Builder/Item.php
+++ b/src/application/code/core/Wootook/Empire/Model/Builder/Item.php
@@ -1,7 +1,39 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Empire_Model_Builder_Item
- extends Wootook_Object
+namespace Wootook\Empire\Model\Builder;
+
+use Wootook\Core;
+
+class Item
+ extends Core\BaseObject
{
protected $_index = null;
@@ -16,4 +48,4 @@ class Wootook_Empire_Model_Builder_Item
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Empire/Model/BuilderAbstract.php b/src/application/code/core/Wootook/Empire/Model/BuilderAbstract.php
index dc0899e..05e3306 100644
--- a/src/application/code/core/Wootook/Empire/Model/BuilderAbstract.php
+++ b/src/application/code/core/Wootook/Empire/Model/BuilderAbstract.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
abstract class Wootook_Empire_Model_BuilderAbstract
implements Countable, Serializable, Iterator
diff --git a/src/application/code/core/Wootook/Empire/Model/Fleet.php b/src/application/code/core/Wootook/Empire/Model/Fleet.php
index e622226..010c2b7 100644
--- a/src/application/code/core/Wootook/Empire/Model/Fleet.php
+++ b/src/application/code/core/Wootook/Empire/Model/Fleet.php
@@ -1,9 +1,37 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Empire_Model_Fleet
diff --git a/src/application/code/core/Wootook/Empire/Model/Galaxy/Position.php b/src/application/code/core/Wootook/Empire/Model/Galaxy/Position.php
index 2ce4b24..c2567c7 100644
--- a/src/application/code/core/Wootook/Empire/Model/Galaxy/Position.php
+++ b/src/application/code/core/Wootook/Empire/Model/Galaxy/Position.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Model_Galaxy_Position
extends Wootook_Core_Mvc_Model_Entity_SubTable
diff --git a/src/application/code/core/Wootook/Empire/Model/Planet.php b/src/application/code/core/Wootook/Empire/Model/Planet.php
index 980524f..1f099e5 100644
--- a/src/application/code/core/Wootook/Empire/Model/Planet.php
+++ b/src/application/code/core/Wootook/Empire/Model/Planet.php
@@ -1,8 +1,36 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
/**
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
* @uses Wootook_Player_Model_Entity
*/
@@ -164,7 +192,7 @@ class Wootook_Empire_Model_Planet
break;
}
- throw new Wootook_Core_Exception_RuntimeException(Wootook::__('Undefined method %s::%s.', get_class($this), $method));
+ throw new Wootook_Core_Exception_RuntimeException(\Wootook::__('Undefined method %s::%s.', get_class($this), $method));
}
/**
@@ -220,7 +248,7 @@ class Wootook_Empire_Model_Planet
$storageSize = Math::add(BASE_STORAGE_SIZE, $storageEnhancement);
- $event = Wootook::dispatchEvent($this->_eventPrefix . 'update-storage.resource', array(
+ $event = \Wootook::dispatchEvent($this->_eventPrefix . 'update-storage.resource', array(
'resource_id' => $resource,
'resource_data' => $resourceData,
'default_size' => $storageSize,
@@ -269,7 +297,7 @@ class Wootook_Empire_Model_Planet
}
if ($this->getPlayer()->isVacation()) {
- $resourceConfig = Wootook::getGameConfig('resource/base-income');
+ $resourceConfig = \Wootook::app()->getDefaultGame()->getConfig('resource/base-income');
foreach ($resources->getAllDatas() as $resource => $resourceData) {
$this->setData($resourceData['production_field'], $resourceConfig[$resource]);
}
@@ -362,7 +390,7 @@ class Wootook_Empire_Model_Planet
}
// Dispatch 'planet.update-production.before' event
- Wootook::dispatchEvent($this->_eventPrefix . '.update-production.before', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.update-production.before', array(
$this->_eventObject => $this,
'player' => $this->getPlayer(),
'productions' => $actualProduction
@@ -378,7 +406,7 @@ class Wootook_Empire_Model_Planet
}
// Dispatch 'planet.update-production.after' event
- Wootook::dispatchEvent($this->_eventPrefix . '.update-production.after', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.update-production.after', array(
$this->_eventObject => $this,
'player' => $this->getPlayer()
));
@@ -616,16 +644,16 @@ class Wootook_Empire_Model_Planet
}
if ($this->isDestroyed()) {
- throw new Wootook_Empire_Exception_Planet(Wootook::__('Planet is already destroyed.'));
+ throw new Wootook_Empire_Exception_Planet(\Wootook::__('Planet is already destroyed.'));
}
if ($this->getFleetCollection()->count() > 0) {
- throw new Wootook_Empire_Exception_Planet(Wootook::__("Could not delete planet until fleets aten't retuned."));
+ throw new Wootook_Empire_Exception_Planet(\Wootook::__("Could not delete planet until fleets aten't retuned."));
}
$player = $this->getPlayer();
if ($player->getHomePlanet()->getId() == $this->getId()) {
- throw new Wootook_Empire_Exception_Planet(Wootook::__("You can't destroy your home planet."));
+ throw new Wootook_Empire_Exception_Planet(\Wootook::__("You can't destroy your home planet."));
}
if ($player->getCurrentPlanet()->getId() == $this->getId()) {
@@ -695,7 +723,7 @@ class Wootook_Empire_Model_Planet
}
// Dispatch 'planet.building.append-queue.before' event
- Wootook::dispatchEvent($this->_eventPrefix . '.building.append-queue.before', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.building.append-queue.before', array(
'bulding_id' => $buildingId,
'level' => $this->getElement($buildingId),
$this->_eventObject => $this,
@@ -712,7 +740,7 @@ class Wootook_Empire_Model_Planet
$this->getBuildingQueue()->appendQueue($buildingId, $level, $time);
// Dispatch 'planet.shipyard.append-queue.after' event
- Wootook::dispatchEvent($this->_eventPrefix . '.building.append-queue.after', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.building.append-queue.after', array(
'bulding_id' => $buildingId,
'level' => $this->getElement($buildingId),
$this->_eventObject => $this,
@@ -730,7 +758,7 @@ class Wootook_Empire_Model_Planet
}
// Dispatch event
- Wootook::dispatchEvent($this->_eventPrefix . '.update-queue.before', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.update-queue.before', array(
'time' => &$time,
$this->_eventObject => $this,
'player' => $this->getPlayer()
@@ -739,7 +767,7 @@ class Wootook_Empire_Model_Planet
$this->getBuildingQueue()->updateQueue($time);
// Dispatch event
- Wootook::dispatchEvent($this->_eventPrefix . '.update-queue.after', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.update-queue.after', array(
'time' => $time,
$this->_eventObject => $this,
'player' => $this->getPlayer()
@@ -815,7 +843,7 @@ class Wootook_Empire_Model_Planet
try {
// Dispatch event. Throw an exception to break the avaliability.
- Wootook::dispatchEvent($this->_eventPrefix . '.check-availability', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.check-availability', array(
'ship_id' => $buildingId,
'shipyard' => $this,
$this->_eventObject => $this,
@@ -865,8 +893,8 @@ class Wootook_Empire_Model_Planet
->group('galaxy.system')
;
- if ($galaxyList === null && Wootook::getGameConfig('user/registration/galaxy_list')) {
- $galaxyList = explode(',', Wootook::getGameConfig('user/registration/galaxy_list'));
+ if ($galaxyList === null && \Wootook::app()->getDefaultGame()->getConfig('user/registration/galaxy_list')) {
+ $galaxyList = explode(',', \Wootook::app()->getDefaultGame()->getConfig('user/registration/galaxy_list'));
}
if ($galaxyList !== null) {
@@ -874,8 +902,8 @@ class Wootook_Empire_Model_Planet
$select->where('galaxy', array(array(Wootook_Core_Database_Sql_Select::OPERATOR_IN => $galaxyList)));
}
- if ($systemList === null && Wootook::getGameConfig('user/registration/system_list')) {
- $systemList = explode(',', Wootook::getGameConfig('user/registration/system_list'));
+ if ($systemList === null && \Wootook::app()->getDefaultGame()->getConfig('user/registration/system_list')) {
+ $systemList = explode(',', \Wootook::app()->getDefaultGame()->getConfig('user/registration/system_list'));
}
if ($systemList !== null) {
@@ -884,15 +912,15 @@ class Wootook_Empire_Model_Planet
}
$orders = array(
- "COUNT(*) / {$adapter->quote(Wootook::getGameConfig('engine/universe/positions'))}",
- "1 + ABS(galaxy.galaxy - CEIL({$adapter->quote(Wootook::getGameConfig('engine/universe/galaxies'))} / 2))",
- "1 + 2 * ABS(galaxy.system - CEIL({$adapter->quote(Wootook::getGameConfig('engine/universe/systems'))} / 2))",
+ "COUNT(*) / {$adapter->quote(\Wootook::app()->getDefaultGame()->getConfig('engine/universe/positions'))}",
+ "1 + ABS(galaxy.galaxy - CEIL({$adapter->quote(\\Wootook::app()->getDefaultGame()->getConfig('engine/universe/galaxies'))} / 2))",
+ "1 + 2 * ABS(galaxy.system - CEIL({$adapter->quote(\\Wootook::app()->getDefaultGame()->getConfig('engine/universe/systems'))} / 2))",
"RAND() / 1000",
);
$select
->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.galaxy - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/galaxies'))} / 2))", 'ASC')
+ //->order("ABS(galaxy.system - CEIL({$collection->quote(\\Wootook::app()->getDefaultGame()->getConfig('engine/universe/systems'))} / 2))", 'ASC')
+ //->order("ABS(galaxy.galaxy - CEIL({$collection->quote(\\Wootook::app()->getDefaultGame()->getConfig('engine/universe/galaxies'))} / 2))", 'ASC')
//->order("1.5 / COUNT(*)", 'ASC')
->order('RAND()', 'ASC');
diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php b/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php
index 2e40fd2..7980561 100644
--- a/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php
+++ b/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Model_Planet_Builder_Item
extends Wootook_Empire_Model_Builder_Item
diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/BuildingInterface.php b/src/application/code/core/Wootook/Empire/Model/Planet/BuildingInterface.php
index d9d694b..9434aa3 100644
--- a/src/application/code/core/Wootook/Empire/Model/Planet/BuildingInterface.php
+++ b/src/application/code/core/Wootook/Empire/Model/Planet/BuildingInterface.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
interface Wootook_Empire_Model_Planet_BuildingInterface
{
diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/PluginLoader.php b/src/application/code/core/Wootook/Empire/Model/Planet/PluginLoader.php
index d3cc37b..04da029 100644
--- a/src/application/code/core/Wootook/Empire/Model/Planet/PluginLoader.php
+++ b/src/application/code/core/Wootook/Empire/Model/Planet/PluginLoader.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Model_Planet_PluginLoader
extends Wootook_Core_PluginLoader_PluginLoader
diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/QueueInterface.php b/src/application/code/core/Wootook/Empire/Model/Planet/QueueInterface.php
index 7bd2c42..2d1380a 100644
--- a/src/application/code/core/Wootook/Empire/Model/Planet/QueueInterface.php
+++ b/src/application/code/core/Wootook/Empire/Model/Planet/QueueInterface.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
interface Wootook_Empire_Model_Planet_QueueInterface
{
diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/ResourceProductionInterface.php b/src/application/code/core/Wootook/Empire/Model/Planet/ResourceProductionInterface.php
index 9556195..604cab1 100644
--- a/src/application/code/core/Wootook/Empire/Model/Planet/ResourceProductionInterface.php
+++ b/src/application/code/core/Wootook/Empire/Model/Planet/ResourceProductionInterface.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
interface Wootook_Empire_Model_Planet_ResourceProductionInterface
{
diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/ShipAbstract.php b/src/application/code/core/Wootook/Empire/Model/Planet/ShipAbstract.php
index d108099..722dbb7 100644
--- a/src/application/code/core/Wootook/Empire/Model/Planet/ShipAbstract.php
+++ b/src/application/code/core/Wootook/Empire/Model/Planet/ShipAbstract.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
abstract class Wootook_Empire_Model_Planet_ShipAbstract
implements Wootook_Empire_Model_Planet_ShipInterface
diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php b/src/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php
index dc9863a..999cff4 100644
--- a/src/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php
+++ b/src/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
interface Wootook_Empire_Model_Planet_ShipInterface
{
diff --git a/src/application/code/core/Wootook/Empire/Model/Player/TechnologyInterface.php b/src/application/code/core/Wootook/Empire/Model/Player/TechnologyInterface.php
index 589914b..0fdb57f 100644
--- a/src/application/code/core/Wootook/Empire/Model/Player/TechnologyInterface.php
+++ b/src/application/code/core/Wootook/Empire/Model/Player/TechnologyInterface.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
interface Wootook_Empire_Model_Player_TechnologyInterface
{
diff --git a/src/application/code/core/Wootook/Empire/Resource/Fleet/Collection.php b/src/application/code/core/Wootook/Empire/Resource/Fleet/Collection.php
index ea399f3..1ecde5e 100644
--- a/src/application/code/core/Wootook/Empire/Resource/Fleet/Collection.php
+++ b/src/application/code/core/Wootook/Empire/Resource/Fleet/Collection.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Resource_Fleet_Collection
extends Wootook_Core_Resource_EntityCollection
diff --git a/src/application/code/core/Wootook/Empire/Resource/Planet/Collection.php b/src/application/code/core/Wootook/Empire/Resource/Planet/Collection.php
index fc3e8ee..dbf7999 100644
--- a/src/application/code/core/Wootook/Empire/Resource/Planet/Collection.php
+++ b/src/application/code/core/Wootook/Empire/Resource/Planet/Collection.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Empire_Resource_Planet_Collection
extends Wootook_Core_Resource_EntityCollection
diff --git a/src/application/code/core/Wootook/Exception.php b/src/application/code/core/Wootook/Exception.php
index c3b339a..80d3b8e 100644
--- a/src/application/code/core/Wootook/Exception.php
+++ b/src/application/code/core/Wootook/Exception.php
@@ -28,10 +28,12 @@
*
*/
+namespace Wootook;
+
/**
*
* Enter description here ...
* @author Greg
*
*/
-interface Wootook_Exception {}
\ No newline at end of file
+interface Exception {}
diff --git a/src/application/code/core/Wootook/Player/Block/Overview.php b/src/application/code/core/Wootook/Player/Block/Overview.php
index bf689f0..374e168 100644
--- a/src/application/code/core/Wootook/Player/Block/Overview.php
+++ b/src/application/code/core/Wootook/Player/Block/Overview.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Block_Overview
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Player/Block/TopBar.php b/src/application/code/core/Wootook/Player/Block/TopBar.php
index 9b7adaf..ecf19b3 100644
--- a/src/application/code/core/Wootook/Player/Block/TopBar.php
+++ b/src/application/code/core/Wootook/Player/Block/TopBar.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Block_TopBar
extends Wootook_Core_Block_Template
diff --git a/src/application/code/core/Wootook/Player/Controller/OverviewController.php b/src/application/code/core/Wootook/Player/Controller/OverviewController.php
index 97db0cf..a167551 100644
--- a/src/application/code/core/Wootook/Player/Controller/OverviewController.php
+++ b/src/application/code/core/Wootook/Player/Controller/OverviewController.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Controller_OverviewController
extends Wootook_Player_Mvc_Controller_Registered
diff --git a/src/application/code/core/Wootook/Player/Exception.php b/src/application/code/core/Wootook/Player/Exception.php
index 6a51351..9004d66 100644
--- a/src/application/code/core/Wootook/Player/Exception.php
+++ b/src/application/code/core/Wootook/Player/Exception.php
@@ -1,3 +1,31 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
interface Wootook_Player_Exception extends Wootook_Exception {}
\ No newline at end of file
diff --git a/src/application/code/core/Wootook/Player/Exception/Exception.php b/src/application/code/core/Wootook/Player/Exception/Exception.php
index 5e50e0a..7d5b9b1 100644
--- a/src/application/code/core/Wootook/Player/Exception/Exception.php
+++ b/src/application/code/core/Wootook/Player/Exception/Exception.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Exception_Exception
extends Exception
diff --git a/src/application/code/core/Wootook/Player/Exception/Session.php b/src/application/code/core/Wootook/Player/Exception/Session.php
index b546e5d..f6ae97f 100644
--- a/src/application/code/core/Wootook/Player/Exception/Session.php
+++ b/src/application/code/core/Wootook/Player/Exception/Session.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Exception_Session
extends Wootook_Player_Exception_RuntimeException
diff --git a/src/application/code/core/Wootook/Player/Model/Entity.php b/src/application/code/core/Wootook/Player/Model/Entity.php
index 389b8ba..4bfc6be 100644
--- a/src/application/code/core/Wootook/Player/Model/Entity.php
+++ b/src/application/code/core/Wootook/Player/Model/Entity.php
@@ -1,10 +1,38 @@
+ * 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 .
+ *
+ * --> 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 ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
class Wootook_Player_Model_Entity
@@ -627,11 +655,6 @@ class Wootook_Player_Model_Entity
return $this->getData('urlaubs_until');
}
- public function getLastLoginDate()
- {
- return $this->getData('onlinetime');
- }
-
public function setVacation($active = true)
{
$this->setData('urlaubs_modus', $active);
diff --git a/src/application/code/core/Wootook/Player/Model/Message.php b/src/application/code/core/Wootook/Player/Model/Message.php
index 0002d94..129f0f3 100644
--- a/src/application/code/core/Wootook/Player/Model/Message.php
+++ b/src/application/code/core/Wootook/Player/Model/Message.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Model_Message
extends Wootook_Core_Mvc_Model_Entity_SubTable
diff --git a/src/application/code/core/Wootook/Player/Model/Session.php b/src/application/code/core/Wootook/Player/Model/Session.php
index 9ae226c..85c463e 100644
--- a/src/application/code/core/Wootook/Player/Model/Session.php
+++ b/src/application/code/core/Wootook/Player/Model/Session.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Model_Session
extends Wootook_Core_Model_Session
diff --git a/src/application/code/core/Wootook/Player/Mvc/Controller/Registered.php b/src/application/code/core/Wootook/Player/Mvc/Controller/Registered.php
index 3374acf..9282caa 100644
--- a/src/application/code/core/Wootook/Player/Mvc/Controller/Registered.php
+++ b/src/application/code/core/Wootook/Player/Mvc/Controller/Registered.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Mvc_Controller_Registered
extends Wootook_Core_Mvc_Controller_Action
diff --git a/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php b/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php
index 3e2c1bc..e2288ad 100644
--- a/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php
+++ b/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Resource_Entity_Collection
extends Wootook_Core_Resource_EntityCollection
diff --git a/src/application/code/core/Wootook/Player/Resource/Message/Collection.php b/src/application/code/core/Wootook/Player/Resource/Message/Collection.php
index e6d9198..0a0921c 100644
--- a/src/application/code/core/Wootook/Player/Resource/Message/Collection.php
+++ b/src/application/code/core/Wootook/Player/Resource/Message/Collection.php
@@ -1,4 +1,32 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
class Wootook_Player_Resource_Message_Collection
extends Wootook_Core_Resource_EntityCollection
diff --git a/src/application/code/libraries/Wildfire/Stream.php b/src/application/code/libraries/Wildfire/Stream.php
deleted file mode 100644
index 9966a44..0000000
--- a/src/application/code/libraries/Wildfire/Stream.php
+++ /dev/null
@@ -1,1753 +0,0 @@
-
- * @license http://www.opensource.org/licenses/bsd-license.php
- * @package FirePHPCore
- */
-
-
-/**
- * Sends the given data to the FirePHP Firefox Extension.
- * The data can be displayed in the Firebug Console or in the
- * "Server" request tab.
- *
- * For more information see: http://www.firephp.org/
- *
- * @copyright Copyright (C) 2007-2009 Christoph Dorn
- * @author Christoph Dorn
- * @license http://www.opensource.org/licenses/bsd-license.php
- * @package FirePHPCore
- */
-class Wildfire_Stream {
-
- /**
- * FirePHP version
- *
- * @var string
- */
- const VERSION = '0.3'; // @pinf replace '0.3' with '%%package.version%%'
-
- /**
- * Firebug LOG level
- *
- * Logs a message to firebug console.
- *
- * @var string
- */
- const LOG = 'LOG';
-
- /**
- * Firebug INFO level
- *
- * Logs a message to firebug console and displays an info icon before the message.
- *
- * @var string
- */
- const INFO = 'INFO';
-
- /**
- * Firebug WARN level
- *
- * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise.
- *
- * @var string
- */
- const WARN = 'WARN';
-
- /**
- * Firebug ERROR level
- *
- * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count.
- *
- * @var string
- */
- const ERROR = 'ERROR';
-
- /**
- * Dumps a variable to firebug's server panel
- *
- * @var string
- */
- const DUMP = 'DUMP';
-
- /**
- * Displays a stack trace in firebug console
- *
- * @var string
- */
- const TRACE = 'TRACE';
-
- /**
- * Displays an exception in firebug console
- *
- * Increments the firebug error count.
- *
- * @var string
- */
- const EXCEPTION = 'EXCEPTION';
-
- /**
- * Displays an table in firebug console
- *
- * @var string
- */
- const TABLE = 'TABLE';
-
- /**
- * Starts a group in firebug console
- *
- * @var string
- */
- const GROUP_START = 'GROUP_START';
-
- /**
- * Ends a group in firebug console
- *
- * @var string
- */
- const GROUP_END = 'GROUP_END';
-
- /**
- * Singleton instance of FirePHP
- *
- * @var FirePHP
- */
- protected static $instance = null;
-
- /**
- * Flag whether we are logging from within the exception handler
- *
- * @var boolean
- */
- protected $inExceptionHandler = false;
-
- /**
- * Flag whether to throw PHP errors that have been converted to ErrorExceptions
- *
- * @var boolean
- */
- protected $throwErrorExceptions = true;
-
- /**
- * Flag whether to convert PHP assertion errors to Exceptions
- *
- * @var boolean
- */
- protected $convertAssertionErrorsToExceptions = true;
-
- /**
- * Flag whether to throw PHP assertion errors that have been converted to Exceptions
- *
- * @var boolean
- */
- protected $throwAssertionExceptions = false;
-
- /**
- * Wildfire protocol message index
- *
- * @var int
- */
- protected $messageIndex = 1;
-
- /**
- * Options for the library
- *
- * @var array
- */
- protected $options = array('maxDepth' => 10,
- 'maxObjectDepth' => 5,
- 'maxArrayDepth' => 5,
- 'useNativeJsonEncode' => true,
- 'includeLineNumbers' => true);
-
- /**
- * Filters used to exclude object members when encoding
- *
- * @var array
- */
- protected $objectFilters = array(
- 'firephp' => array('objectStack', 'instance', 'json_objectStack'),
- 'firephp_test_class' => array('objectStack', 'instance', 'json_objectStack')
- );
-
- /**
- * A stack of objects used to detect recursion during object encoding
- *
- * @var object
- */
- protected $objectStack = array();
-
- /**
- * Flag to enable/disable logging
- *
- * @var boolean
- */
- protected $enabled = true;
-
- /**
- * The insight console to log to if applicable
- *
- * @var object
- */
- protected $logToInsightConsole = null;
-
- /**
- * When the object gets serialized only include specific object members.
- *
- * @return array
- */
- public function __sleep()
- {
- return array('options','objectFilters','enabled');
- }
-
- /**
- * Gets singleton instance of FirePHP
- *
- * @param boolean $AutoCreate
- * @return FirePHP
- */
- public static function getInstance($AutoCreate = false)
- {
- if ($AutoCreate===true && !self::$instance) {
- self::init();
- }
- return self::$instance;
- }
-
- /**
- * Creates FirePHP object and stores it for singleton access
- *
- * @return FirePHP
- */
- public static function init()
- {
- return self::setInstance(new self());
- }
-
- /**
- * Set the instance of the FirePHP singleton
- *
- * @param FirePHP $instance The FirePHP object instance
- * @return FirePHP
- */
- public static function setInstance($instance)
- {
- return self::$instance = $instance;
- }
-
- /**
- * Set an Insight console to direct all logging calls to
- *
- * @param object $console The console object to log to
- * @return void
- */
- public function setLogToInsightConsole($console)
- {
- if(is_string($console)) {
- if(get_class($this)!='FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) {
- throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!');
- }
- $this->logToInsightConsole = $this->to('request')->console($console);
- } else {
- $this->logToInsightConsole = $console;
- }
- }
-
- /**
- * Enable and disable logging to Firebug
- *
- * @param boolean $Enabled TRUE to enable, FALSE to disable
- * @return void
- */
- public function setEnabled($Enabled)
- {
- $this->enabled = $Enabled;
- }
-
- /**
- * Check if logging is enabled
- *
- * @return boolean TRUE if enabled
- */
- public function getEnabled()
- {
- return $this->enabled;
- }
-
- /**
- * Specify a filter to be used when encoding an object
- *
- * Filters are used to exclude object members.
- *
- * @param string $Class The class name of the object
- * @param array $Filter An array of members to exclude
- * @return void
- */
- public function setObjectFilter($Class, $Filter)
- {
- $this->objectFilters[strtolower($Class)] = $Filter;
- }
-
- /**
- * Set some options for the library
- *
- * Options:
- * - maxDepth: The maximum depth to traverse (default: 10)
- * - maxObjectDepth: The maximum depth to traverse objects (default: 5)
- * - maxArrayDepth: The maximum depth to traverse arrays (default: 5)
- * - useNativeJsonEncode: If true will use json_encode() (default: true)
- * - includeLineNumbers: If true will include line numbers and filenames (default: true)
- *
- * @param array $Options The options to be set
- * @return void
- */
- public function setOptions($Options)
- {
- $this->options = array_merge($this->options,$Options);
- }
-
- /**
- * Get options from the library
- *
- * @return array The currently set options
- */
- public function getOptions()
- {
- return $this->options;
- }
-
- /**
- * Set an option for the library
- *
- * @param string $Name
- * @param mixed $Value
- * @throws Exception
- * @return void
- */
- public function setOption($Name, $Value)
- {
- if (!isset($this->options[$Name])) {
- throw $this->newException('Unknown option: ' . $Name);
- }
- $this->options[$Name] = $Value;
- }
-
- /**
- * Get an option from the library
- *
- * @param string $Name
- * @throws Exception
- * @return mixed
- */
- public function getOption($Name)
- {
- if (!isset($this->options[$Name])) {
- throw $this->newException('Unknown option: ' . $Name);
- }
- return $this->options[$Name];
- }
-
- /**
- * Register FirePHP as your error handler
- *
- * Will throw exceptions for each php error.
- *
- * @return mixed Returns a string containing the previously defined error handler (if any)
- */
- public function registerErrorHandler($throwErrorExceptions = false)
- {
- //NOTE: The following errors will not be caught by this error handler:
- // E_ERROR, E_PARSE, E_CORE_ERROR,
- // E_CORE_WARNING, E_COMPILE_ERROR,
- // E_COMPILE_WARNING, E_STRICT
-
- $this->throwErrorExceptions = $throwErrorExceptions;
-
- return set_error_handler(array($this,'errorHandler'));
- }
-
- /**
- * FirePHP's error handler
- *
- * Throws exception for each php error that will occur.
- *
- * @param int $errno
- * @param string $errstr
- * @param string $errfile
- * @param int $errline
- * @param array $errcontext
- */
- public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
- {
- // Don't throw exception if error reporting is switched off
- if (error_reporting() == 0) {
- return;
- }
- // Only throw exceptions for errors we are asking for
- if (error_reporting() & $errno) {
-
- $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline);
- if ($this->throwErrorExceptions) {
- throw $exception;
- } else {
- $this->fb($exception);
- }
- }
- }
-
- /**
- * Register FirePHP as your exception handler
- *
- * @return mixed Returns the name of the previously defined exception handler,
- * or NULL on error.
- * If no previous handler was defined, NULL is also returned.
- */
- public function registerExceptionHandler()
- {
- return set_exception_handler(array($this,'exceptionHandler'));
- }
-
- /**
- * FirePHP's exception handler
- *
- * Logs all exceptions to your firebug console and then stops the script.
- *
- * @param Exception $Exception
- * @throws Exception
- */
- function exceptionHandler($Exception)
- {
-
- $this->inExceptionHandler = true;
-
- header('HTTP/1.1 500 Internal Server Error');
-
- try {
- $this->fb($Exception);
- } catch (Exception $e) {
- echo 'We had an exception: ' . $e;
- }
- $this->inExceptionHandler = false;
- }
-
- /**
- * Register FirePHP driver as your assert callback
- *
- * @param boolean $convertAssertionErrorsToExceptions
- * @param boolean $throwAssertionExceptions
- * @return mixed Returns the original setting or FALSE on errors
- */
- public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false)
- {
- $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions;
- $this->throwAssertionExceptions = $throwAssertionExceptions;
-
- if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) {
- throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!');
- }
-
- return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler'));
- }
-
- /**
- * FirePHP's assertion handler
- *
- * Logs all assertions to your firebug console and then stops the script.
- *
- * @param string $file File source of assertion
- * @param int $line Line source of assertion
- * @param mixed $code Assertion code
- */
- public function assertionHandler($file, $line, $code)
- {
- if ($this->convertAssertionErrorsToExceptions) {
-
- $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line);
-
- if ($this->throwAssertionExceptions) {
- throw $exception;
- } else {
- $this->fb($exception);
- }
-
- } else {
- $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line));
- }
- }
-
- /**
- * Start a group for following messages.
- *
- * Options:
- * Collapsed: [true|false]
- * Color: [#RRGGBB|ColorName]
- *
- * @param string $Name
- * @param array $Options OPTIONAL Instructions on how to log the group
- * @return true
- * @throws Exception
- */
- public function group($Name, $Options = null)
- {
-
- if (!$Name) {
- throw $this->newException('You must specify a label for the group!');
- }
-
- if ($Options) {
- if (!is_array($Options)) {
- throw $this->newException('Options must be defined as an array!');
- }
- if (array_key_exists('Collapsed', $Options)) {
- $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false';
- }
- }
-
- return $this->fb(null, $Name, FirePHP::GROUP_START, $Options);
- }
-
- /**
- * Ends a group you have started before
- *
- * @return true
- * @throws Exception
- */
- public function groupEnd()
- {
- return $this->fb(null, null, FirePHP::GROUP_END);
- }
-
- /**
- * Log object with label to firebug console
- *
- * @see FirePHP::LOG
- * @param mixes $Object
- * @param string $Label
- * @return true
- * @throws Exception
- */
- public function log($Object, $Label = null, $Options = array())
- {
- return $this->fb($Object, $Label, FirePHP::LOG, $Options);
- }
-
- /**
- * Log object with label to firebug console
- *
- * @see FirePHP::INFO
- * @param mixes $Object
- * @param string $Label
- * @return true
- * @throws Exception
- */
- public function info($Object, $Label = null, $Options = array())
- {
- return $this->fb($Object, $Label, FirePHP::INFO, $Options);
- }
-
- /**
- * Log object with label to firebug console
- *
- * @see FirePHP::WARN
- * @param mixes $Object
- * @param string $Label
- * @return true
- * @throws Exception
- */
- public function warn($Object, $Label = null, $Options = array())
- {
- return $this->fb($Object, $Label, FirePHP::WARN, $Options);
- }
-
- /**
- * Log object with label to firebug console
- *
- * @see FirePHP::ERROR
- * @param mixes $Object
- * @param string $Label
- * @return true
- * @throws Exception
- */
- public function error($Object, $Label = null, $Options = array())
- {
- return $this->fb($Object, $Label, FirePHP::ERROR, $Options);
- }
-
- /**
- * Dumps key and variable to firebug server panel
- *
- * @see FirePHP::DUMP
- * @param string $Key
- * @param mixed $Variable
- * @return true
- * @throws Exception
- */
- public function dump($Key, $Variable, $Options = array())
- {
- if (!is_string($Key)) {
- throw $this->newException('Key passed to dump() is not a string');
- }
- if (strlen($Key)>100) {
- throw $this->newException('Key passed to dump() is longer than 100 characters');
- }
- if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $Key, $m)) {
- throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]');
- }
- return $this->fb($Variable, $Key, FirePHP::DUMP, $Options);
- }
-
- /**
- * Log a trace in the firebug console
- *
- * @see FirePHP::TRACE
- * @param string $Label
- * @return true
- * @throws Exception
- */
- public function trace($Label)
- {
- return $this->fb($Label, FirePHP::TRACE);
- }
-
- /**
- * Log a table in the firebug console
- *
- * @see FirePHP::TABLE
- * @param string $Label
- * @param string $Table
- * @return true
- * @throws Exception
- */
- public function table($Label, $Table, $Options = array())
- {
- return $this->fb($Table, $Label, FirePHP::TABLE, $Options);
- }
-
- /**
- * Insight API wrapper
- *
- * @see Insight_Helper::to()
- */
- public static function to()
- {
- $instance = self::getInstance();
- if (!method_exists($instance, "_to")) {
- throw new Exception("FirePHP::to() implementation not loaded");
- }
- $args = func_get_args();
- return call_user_func_array(array($instance, '_to'), $args);
- }
-
- /**
- * Insight API wrapper
- *
- * @see Insight_Helper::plugin()
- */
- public static function plugin()
- {
- $instance = self::getInstance();
- if (!method_exists($instance, "_plugin")) {
- throw new Exception("FirePHP::plugin() implementation not loaded");
- }
- $args = func_get_args();
- return call_user_func_array(array($instance, '_plugin'), $args);
- }
-
- /**
- * Check if FirePHP is installed on client
- *
- * @return boolean
- */
- public function detectClientExtension()
- {
- // Check if FirePHP is installed on client via User-Agent header
- if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) &&
- version_compare($m[1][0],'0.0.6','>=')) {
- return true;
- } else
- // Check if FirePHP is installed on client via X-FirePHP-Version header
- if (@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) &&
- version_compare($m[1][0],'0.0.6','>=')) {
- return true;
- }
- return false;
- }
-
- /**
- * Log varible to Firebug
- *
- * @see http://www.firephp.org/Wiki/Reference/Fb
- * @param mixed $Object The variable to be logged
- * @return true Return TRUE if message was added to headers, FALSE otherwise
- * @throws Exception
- */
- public function fb($Object)
- {
- if($this instanceof FirePHP_Insight && method_exists($this, '_logUpgradeClientMessage')) {
- if(!FirePHP_Insight::$upgradeClientMessageLogged) { // avoid infinite recursion as _logUpgradeClientMessage() logs a message
- $this->_logUpgradeClientMessage();
- }
- }
-
- static $insightGroupStack = array();
-
- if (!$this->getEnabled()) {
- return false;
- }
-
- if ($this->headersSent($filename, $linenum)) {
- // If we are logging from within the exception handler we cannot throw another exception
- if ($this->inExceptionHandler) {
- // Simply echo the error out to the page
- echo '
FirePHP ERROR: Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.
';
- } else {
- throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.');
- }
- }
-
- $Type = null;
- $Label = null;
- $Options = array();
-
- if (func_num_args()==1) {
- } else
- if (func_num_args()==2) {
- switch(func_get_arg(1)) {
- case self::LOG:
- case self::INFO:
- case self::WARN:
- case self::ERROR:
- case self::DUMP:
- case self::TRACE:
- case self::EXCEPTION:
- case self::TABLE:
- case self::GROUP_START:
- case self::GROUP_END:
- $Type = func_get_arg(1);
- break;
- default:
- $Label = func_get_arg(1);
- break;
- }
- } else
- if (func_num_args()==3) {
- $Type = func_get_arg(2);
- $Label = func_get_arg(1);
- } else
- if (func_num_args()==4) {
- $Type = func_get_arg(2);
- $Label = func_get_arg(1);
- $Options = func_get_arg(3);
- } else {
- throw $this->newException('Wrong number of arguments to fb() function!');
- }
-
- if($this->logToInsightConsole!==null && (get_class($this)=='FirePHP_Insight' || is_subclass_of($this, 'FirePHP_Insight'))) {
- $msg = $this->logToInsightConsole;
- if ($Object instanceof Exception) {
- $Type = self::EXCEPTION;
- }
- if($Label && $Type!=self::TABLE && $Type!=self::GROUP_START) {
- $msg = $msg->label($Label);
- }
- switch($Type) {
- case self::DUMP:
- case self::LOG:
- return $msg->log($Object);
- case self::INFO:
- return $msg->info($Object);
- case self::WARN:
- return $msg->warn($Object);
- case self::ERROR:
- return $msg->error($Object);
- case self::TRACE:
- return $msg->trace($Object);
- case self::EXCEPTION:
- return $this->plugin('engine')->handleException($Object, $msg);
- case self::TABLE:
- if (isset($Object[0]) && !is_string($Object[0]) && $Label) {
- $Object = array($Label, $Object);
- }
- return $msg->table($Object[0], array_slice($Object[1],1), $Object[1][0]);
- case self::GROUP_START:
- $insightGroupStack[] = $msg->group(md5($Label))->open();
- return $msg->log($Label);
- case self::GROUP_END:
- if(count($insightGroupStack)==0) {
- throw new Error('Too many groupEnd() as opposed to group() calls!');
- }
- $group = array_pop($insightGroupStack);
- return $group->close();
- default:
- return $msg->log($Object);
- }
- }
-
- if (!$this->detectClientExtension()) {
- return false;
- }
-
- $meta = array();
- $skipFinalObjectEncode = false;
-
- if ($Object instanceof Exception) {
-
- $meta['file'] = $this->_escapeTraceFile($Object->getFile());
- $meta['line'] = $Object->getLine();
-
- $trace = $Object->getTrace();
- if ($Object instanceof ErrorException
- && isset($trace[0]['function'])
- && $trace[0]['function']=='errorHandler'
- && isset($trace[0]['class'])
- && $trace[0]['class']=='FirePHP') {
-
- $severity = false;
- switch($Object->getSeverity()) {
- case E_WARNING: $severity = 'E_WARNING'; break;
- case E_NOTICE: $severity = 'E_NOTICE'; break;
- case E_USER_ERROR: $severity = 'E_USER_ERROR'; break;
- case E_USER_WARNING: $severity = 'E_USER_WARNING'; break;
- case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break;
- case E_STRICT: $severity = 'E_STRICT'; break;
- case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break;
- case E_DEPRECATED: $severity = 'E_DEPRECATED'; break;
- case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break;
- }
-
- $Object = array('Class'=>get_class($Object),
- 'Message'=>$severity.': '.$Object->getMessage(),
- 'File'=>$this->_escapeTraceFile($Object->getFile()),
- 'Line'=>$Object->getLine(),
- 'Type'=>'trigger',
- 'Trace'=>$this->_escapeTrace(array_splice($trace,2)));
- $skipFinalObjectEncode = true;
- } else {
- $Object = array('Class'=>get_class($Object),
- 'Message'=>$Object->getMessage(),
- 'File'=>$this->_escapeTraceFile($Object->getFile()),
- 'Line'=>$Object->getLine(),
- 'Type'=>'throw',
- 'Trace'=>$this->_escapeTrace($trace));
- $skipFinalObjectEncode = true;
- }
- $Type = self::EXCEPTION;
-
- } else
- if ($Type==self::TRACE) {
-
- $trace = debug_backtrace();
- if (!$trace) return false;
- for( $i=0 ; $i_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
- || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) {
- /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
- } else
- if (isset($trace[$i]['class'])
- && isset($trace[$i+1]['file'])
- && $trace[$i]['class']=='FirePHP'
- && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') {
- /* Skip fb() */
- } else
- if ($trace[$i]['function']=='fb'
- || $trace[$i]['function']=='trace'
- || $trace[$i]['function']=='send') {
-
- $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'',
- 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'',
- 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'',
- 'Message'=>$trace[$i]['args'][0],
- 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'',
- 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'',
- 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'',
- 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1)));
-
- $skipFinalObjectEncode = true;
- $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'';
- $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:'';
- break;
- }
- }
-
- } else
- if ($Type==self::TABLE) {
-
- if (isset($Object[0]) && is_string($Object[0])) {
- $Object[1] = $this->encodeTable($Object[1]);
- } else {
- $Object = $this->encodeTable($Object);
- }
-
- $skipFinalObjectEncode = true;
-
- } else
- if ($Type==self::GROUP_START) {
-
- if (!$Label) {
- throw $this->newException('You must specify a label for the group!');
- }
-
- } else {
- if ($Type===null) {
- $Type = self::LOG;
- }
- }
-
- if ($this->options['includeLineNumbers']) {
- if (!isset($meta['file']) || !isset($meta['line'])) {
-
- $trace = debug_backtrace();
- for( $i=0 ; $trace && $i_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
- || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) {
- /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
- } else
- if (isset($trace[$i]['class'])
- && isset($trace[$i+1]['file'])
- && $trace[$i]['class']=='FirePHP'
- && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') {
- /* Skip fb() */
- } else
- if (isset($trace[$i]['file'])
- && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') {
- /* Skip FB::fb() */
- } else {
- $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'';
- $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:'';
- break;
- }
- }
- }
- } else {
- unset($meta['file']);
- unset($meta['line']);
- }
-
- $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
- $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION);
-
- $structure_index = 1;
- if ($Type==self::DUMP) {
- $structure_index = 2;
- $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1');
- } else {
- $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
- }
-
- if ($Type==self::DUMP) {
- $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}';
- } else {
- $msg_meta = $Options;
- $msg_meta['Type'] = $Type;
- if ($Label!==null) {
- $msg_meta['Label'] = $Label;
- }
- if (isset($meta['file']) && !isset($msg_meta['File'])) {
- $msg_meta['File'] = $meta['file'];
- }
- if (isset($meta['line']) && !isset($msg_meta['Line'])) {
- $msg_meta['Line'] = $meta['line'];
- }
- $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']';
- }
-
- $parts = explode("\n",chunk_split($msg, 5000, "\n"));
-
- for( $i=0 ; $i2) {
- // Message needs to be split into multiple parts
- $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex,
- (($i==0)?strlen($msg):'')
- . '|' . $part . '|'
- . (($isetHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex,
- strlen($part) . '|' . $part . '|');
- }
-
- $this->messageIndex++;
-
- if ($this->messageIndex > 99999) {
- throw $this->newException('Maximum number (99,999) of messages reached!');
- }
- }
- }
-
- $this->setHeader('X-Wf-1-Index',$this->messageIndex-1);
-
- return true;
- }
-
- /**
- * Standardizes path for windows systems.
- *
- * @param string $Path
- * @return string
- */
- protected function _standardizePath($Path)
- {
- return preg_replace('/\\\\+/','/',$Path);
- }
-
- /**
- * Escape trace path for windows systems
- *
- * @param array $Trace
- * @return array
- */
- protected function _escapeTrace($Trace)
- {
- if (!$Trace) return $Trace;
- for( $i=0 ; $i_escapeTraceFile($Trace[$i]['file']);
- }
- if (isset($Trace[$i]['args'])) {
- $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']);
- }
- }
- return $Trace;
- }
-
- /**
- * Escape file information of trace for windows systems
- *
- * @param string $File
- * @return string
- */
- protected function _escapeTraceFile($File)
- {
- /* Check if we have a windows filepath */
- if (strpos($File,'\\')) {
- /* First strip down to single \ */
-
- $file = preg_replace('/\\\\+/','\\',$File);
-
- return $file;
- }
- return $File;
- }
-
- /**
- * Check if headers have already been sent
- *
- * @param string $Filename
- * @param integer $Linenum
- */
- protected function headersSent(&$Filename, &$Linenum)
- {
- return headers_sent($Filename, $Linenum);
- }
-
- /**
- * Send header
- *
- * @param string $Name
- * @param string $Value
- */
- protected function setHeader($Name, $Value)
- {
- return header($Name.': '.$Value);
- }
-
- /**
- * Get user agent
- *
- * @return string|false
- */
- protected function getUserAgent()
- {
- if (!isset($_SERVER['HTTP_USER_AGENT'])) return false;
- return $_SERVER['HTTP_USER_AGENT'];
- }
-
- /**
- * Get all request headers
- *
- * @return array
- */
- public static function getAllRequestHeaders() {
- static $_cached_headers = false;
- if($_cached_headers!==false) {
- return $_cached_headers;
- }
- $headers = array();
- if(function_exists('getallheaders')) {
- foreach( getallheaders() as $name => $value ) {
- $headers[strtolower($name)] = $value;
- }
- } else {
- foreach($_SERVER as $name => $value) {
- if(substr($name, 0, 5) == 'HTTP_') {
- $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value;
- }
- }
- }
- return $_cached_headers = $headers;
- }
-
- /**
- * Get a request header
- *
- * @return string|false
- */
- protected function getRequestHeader($Name)
- {
- $headers = self::getAllRequestHeaders();
- if (isset($headers[strtolower($Name)])) {
- return $headers[strtolower($Name)];
- }
- return false;
- }
-
- /**
- * Returns a new exception
- *
- * @param string $Message
- * @return Exception
- */
- protected function newException($Message)
- {
- return new Exception($Message);
- }
-
- /**
- * Encode an object into a JSON string
- *
- * Uses PHP's jeson_encode() if available
- *
- * @param object $Object The object to be encoded
- * @return string The JSON string
- */
- public function jsonEncode($Object, $skipObjectEncode = false)
- {
- if (!$skipObjectEncode) {
- $Object = $this->encodeObject($Object);
- }
-
- if (function_exists('json_encode')
- && $this->options['useNativeJsonEncode']!=false) {
-
- return json_encode($Object);
- } else {
- return $this->json_encode($Object);
- }
- }
-
- /**
- * Encodes a table by encoding each row and column with encodeObject()
- *
- * @param array $Table The table to be encoded
- * @return array
- */
- protected function encodeTable($Table)
- {
-
- if (!$Table) return $Table;
-
- $new_table = array();
- foreach($Table as $row) {
-
- if (is_array($row)) {
- $new_row = array();
-
- foreach($row as $item) {
- $new_row[] = $this->encodeObject($item);
- }
-
- $new_table[] = $new_row;
- }
- }
-
- return $new_table;
- }
-
- /**
- * Encodes an object including members with
- * protected and private visibility
- *
- * @param Object $Object The object to be encoded
- * @param int $Depth The current traversal depth
- * @return array All members of the object
- */
- protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1, $MaxDepth = 1)
- {
- if ($MaxDepth > $this->options['maxDepth']) {
- return '** Max Depth ('.$this->options['maxDepth'].') **';
- }
-
- $return = array();
-
- if (is_resource($Object)) {
-
- return '** '.(string)$Object.' **';
-
- } else
- if (is_object($Object)) {
-
- if ($ObjectDepth > $this->options['maxObjectDepth']) {
- return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **';
- }
-
- foreach ($this->objectStack as $refVal) {
- if ($refVal === $Object) {
- return '** Recursion ('.get_class($Object).') **';
- }
- }
- array_push($this->objectStack, $Object);
-
- $return['__className'] = $class = get_class($Object);
- $class_lower = strtolower($class);
-
- $reflectionClass = new ReflectionClass($class);
- $properties = array();
- foreach( $reflectionClass->getProperties() as $property) {
- $properties[$property->getName()] = $property;
- }
-
- $members = (array)$Object;
-
- foreach( $properties as $plain_name => $property ) {
-
- $name = $raw_name = $plain_name;
- if ($property->isStatic()) {
- $name = 'static:'.$name;
- }
- if ($property->isPublic()) {
- $name = 'public:'.$name;
- } else
- if ($property->isPrivate()) {
- $name = 'private:'.$name;
- $raw_name = "\0".$class."\0".$raw_name;
- } else
- if ($property->isProtected()) {
- $name = 'protected:'.$name;
- $raw_name = "\0".'*'."\0".$raw_name;
- }
-
- if (!(isset($this->objectFilters[$class_lower])
- && is_array($this->objectFilters[$class_lower])
- && in_array($plain_name,$this->objectFilters[$class_lower]))) {
-
- if (array_key_exists($raw_name,$members)
- && !$property->isStatic()) {
-
- $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1, $MaxDepth + 1);
-
- } else {
- if (method_exists($property,'setAccessible')) {
- $property->setAccessible(true);
- $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1, $MaxDepth + 1);
- } else
- if ($property->isPublic()) {
- $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1, $MaxDepth + 1);
- } else {
- $return[$name] = '** Need PHP 5.3 to get value **';
- }
- }
- } else {
- $return[$name] = '** Excluded by Filter **';
- }
- }
-
- // Include all members that are not defined in the class
- // but exist in the object
- foreach( $members as $raw_name => $value ) {
-
- $name = $raw_name;
-
- if ($name{0} == "\0") {
- $parts = explode("\0", $name);
- $name = $parts[2];
- }
-
- $plain_name = $name;
-
- if (!isset($properties[$name])) {
- $name = 'undeclared:'.$name;
-
- if (!(isset($this->objectFilters[$class_lower])
- && is_array($this->objectFilters[$class_lower])
- && in_array($plain_name,$this->objectFilters[$class_lower]))) {
-
- $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1, $MaxDepth + 1);
- } else {
- $return[$name] = '** Excluded by Filter **';
- }
- }
- }
-
- array_pop($this->objectStack);
-
- } elseif (is_array($Object)) {
-
- if ($ArrayDepth > $this->options['maxArrayDepth']) {
- return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **';
- }
-
- foreach ($Object as $key => $val) {
-
- // Encoding the $GLOBALS PHP array causes an infinite loop
- // if the recursion is not reset here as it contains
- // a reference to itself. This is the only way I have come up
- // with to stop infinite recursion in this case.
- if ($key=='GLOBALS'
- && is_array($val)
- && array_key_exists('GLOBALS',$val)) {
- $val['GLOBALS'] = '** Recursion (GLOBALS) **';
- }
-
- $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1, $MaxDepth + 1);
- }
- } else {
- if (self::is_utf8($Object)) {
- return $Object;
- } else {
- return utf8_encode($Object);
- }
- }
- return $return;
- }
-
- /**
- * Returns true if $string is valid UTF-8 and false otherwise.
- *
- * @param mixed $str String to be tested
- * @return boolean
- */
- protected static function is_utf8($str)
- {
- if(function_exists('mb_detect_encoding')) {
- return (mb_detect_encoding($str) == 'UTF-8');
- }
- $c=0; $b=0;
- $bits=0;
- $len=strlen($str);
- for($i=0; $i<$len; $i++){
- $c=ord($str[$i]);
- if ($c > 128){
- if (($c >= 254)) return false;
- elseif ($c >= 252) $bits=6;
- elseif ($c >= 248) $bits=5;
- elseif ($c >= 240) $bits=4;
- elseif ($c >= 224) $bits=3;
- elseif ($c >= 192) $bits=2;
- else return false;
- if (($i+$bits) > $len) return false;
- while($bits > 1){
- $i++;
- $b=ord($str[$i]);
- if ($b < 128 || $b > 191) return false;
- $bits--;
- }
- }
- }
- return true;
- }
-
- /**
- * Converts to and from JSON format.
- *
- * JSON (JavaScript Object Notation) is a lightweight data-interchange
- * format. It is easy for humans to read and write. It is easy for machines
- * to parse and generate. It is based on a subset of the JavaScript
- * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
- * This feature can also be found in Python. JSON is a text format that is
- * completely language independent but uses conventions that are familiar
- * to programmers of the C-family of languages, including C, C++, C#, Java,
- * JavaScript, Perl, TCL, and many others. These properties make JSON an
- * ideal data-interchange language.
- *
- * This package provides a simple encoder and decoder for JSON notation. It
- * is intended for use with client-side Javascript applications that make
- * use of HTTPRequest to perform server communication functions - data can
- * be encoded into JSON notation for use in a client-side javascript, or
- * decoded from incoming Javascript requests. JSON format is native to
- * Javascript, and can be directly eval()'ed with no further parsing
- * overhead
- *
- * All strings should be in ASCII or UTF-8 format!
- *
- * LICENSE: Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met: Redistributions of source code must retain the
- * above copyright notice, this list of conditions and the following
- * disclaimer. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * @category
- * @package Services_JSON
- * @author Michal Migurski
- * @author Matt Knapp
- * @author Brett Stimmerman
- * @author Christoph Dorn
- * @copyright 2005 Michal Migurski
- * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
- * @license http://www.opensource.org/licenses/bsd-license.php
- * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
- */
-
-
- /**
- * Keep a list of objects as we descend into the array so we can detect recursion.
- */
- private $json_objectStack = array();
-
-
- /**
- * convert a string from one UTF-8 char to one UTF-16 char
- *
- * Normally should be handled by mb_convert_encoding, but
- * provides a slower PHP-only method for installations
- * that lack the multibye string extension.
- *
- * @param string $utf8 UTF-8 character
- * @return string UTF-16 character
- * @access private
- */
- private function json_utf82utf16($utf8)
- {
- // oh please oh please oh please oh please oh please
- if (function_exists('mb_convert_encoding')) {
- return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
- }
-
- switch(strlen($utf8)) {
- case 1:
- // this case should never be reached, because we are in ASCII range
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return $utf8;
-
- case 2:
- // return a UTF-16 character from a 2-byte UTF-8 char
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x07 & (ord($utf8{0}) >> 2))
- . chr((0xC0 & (ord($utf8{0}) << 6))
- | (0x3F & ord($utf8{1})));
-
- case 3:
- // return a UTF-16 character from a 3-byte UTF-8 char
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr((0xF0 & (ord($utf8{0}) << 4))
- | (0x0F & (ord($utf8{1}) >> 2)))
- . chr((0xC0 & (ord($utf8{1}) << 6))
- | (0x7F & ord($utf8{2})));
- }
-
- // ignoring UTF-32 for now, sorry
- return '';
- }
-
- /**
- * encodes an arbitrary variable into JSON format
- *
- * @param mixed $var any number, boolean, string, array, or object to be encoded.
- * see argument 1 to Services_JSON() above for array-parsing behavior.
- * if var is a strng, note that encode() always expects it
- * to be in ASCII or UTF-8 format!
- *
- * @return mixed JSON string representation of input var or an error if a problem occurs
- * @access public
- */
- private function json_encode($var)
- {
-
- if (is_object($var)) {
- if (in_array($var,$this->json_objectStack)) {
- return '"** Recursion **"';
- }
- }
-
- switch (gettype($var)) {
- case 'boolean':
- return $var ? 'true' : 'false';
-
- case 'NULL':
- return 'null';
-
- case 'integer':
- return (int) $var;
-
- case 'double':
- case 'float':
- return (float) $var;
-
- case 'string':
- // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
- $ascii = '';
- $strlen_var = strlen($var);
-
- /*
- * Iterate over every character in the string,
- * escaping with a slash or encoding to UTF-8 where necessary
- */
- for ($c = 0; $c < $strlen_var; ++$c) {
-
- $ord_var_c = ord($var{$c});
-
- switch (true) {
- case $ord_var_c == 0x08:
- $ascii .= '\b';
- break;
- case $ord_var_c == 0x09:
- $ascii .= '\t';
- break;
- case $ord_var_c == 0x0A:
- $ascii .= '\n';
- break;
- case $ord_var_c == 0x0C:
- $ascii .= '\f';
- break;
- case $ord_var_c == 0x0D:
- $ascii .= '\r';
- break;
-
- case $ord_var_c == 0x22:
- case $ord_var_c == 0x2F:
- case $ord_var_c == 0x5C:
- // double quote, slash, slosh
- $ascii .= '\\'.$var{$c};
- break;
-
- case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
- // characters U-00000000 - U-0000007F (same as ASCII)
- $ascii .= $var{$c};
- break;
-
- case (($ord_var_c & 0xE0) == 0xC0):
- // characters U-00000080 - U-000007FF, mask 110XXXXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
- $c += 1;
- $utf16 = $this->json_utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xF0) == 0xE0):
- // characters U-00000800 - U-0000FFFF, mask 1110XXXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}));
- $c += 2;
- $utf16 = $this->json_utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xF8) == 0xF0):
- // characters U-00010000 - U-001FFFFF, mask 11110XXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}));
- $c += 3;
- $utf16 = $this->json_utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xFC) == 0xF8):
- // characters U-00200000 - U-03FFFFFF, mask 111110XX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}));
- $c += 4;
- $utf16 = $this->json_utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xFE) == 0xFC):
- // characters U-04000000 - U-7FFFFFFF, mask 1111110X
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}),
- ord($var{$c + 5}));
- $c += 5;
- $utf16 = $this->json_utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
- }
- }
-
- return '"'.$ascii.'"';
-
- case 'array':
- /*
- * As per JSON spec if any array key is not an integer
- * we must treat the the whole array as an object. We
- * also try to catch a sparsely populated associative
- * array with numeric keys here because some JS engines
- * will create an array with empty indexes up to
- * max_index which can cause memory issues and because
- * the keys, which may be relevant, will be remapped
- * otherwise.
- *
- * As per the ECMA and JSON specification an object may
- * have any string as a property. Unfortunately due to
- * a hole in the ECMA specification if the key is a
- * ECMA reserved word or starts with a digit the
- * parameter is only accessible using ECMAScript's
- * bracket notation.
- */
-
- // treat as a JSON object
- if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
-
- $this->json_objectStack[] = $var;
-
- $properties = array_map(array($this, 'json_name_value'),
- array_keys($var),
- array_values($var));
-
- array_pop($this->json_objectStack);
-
- foreach($properties as $property) {
- if ($property instanceof Exception) {
- return $property;
- }
- }
-
- return '{' . join(',', $properties) . '}';
- }
-
- $this->json_objectStack[] = $var;
-
- // treat it like a regular array
- $elements = array_map(array($this, 'json_encode'), $var);
-
- array_pop($this->json_objectStack);
-
- foreach($elements as $element) {
- if ($element instanceof Exception) {
- return $element;
- }
- }
-
- return '[' . join(',', $elements) . ']';
-
- case 'object':
- $vars = self::encodeObject($var);
-
- $this->json_objectStack[] = $var;
-
- $properties = array_map(array($this, 'json_name_value'),
- array_keys($vars),
- array_values($vars));
-
- array_pop($this->json_objectStack);
-
- foreach($properties as $property) {
- if ($property instanceof Exception) {
- return $property;
- }
- }
-
- return '{' . join(',', $properties) . '}';
-
- default:
- return null;
- }
- }
-
- /**
- * array-walking function for use in generating JSON-formatted name-value pairs
- *
- * @param string $name name of key to use
- * @param mixed $value reference to an array element to be encoded
- *
- * @return string JSON-formatted name-value pair, like '"name":value'
- * @access private
- */
- private function json_name_value($name, $value)
- {
- // Encoding the $GLOBALS PHP array causes an infinite loop
- // if the recursion is not reset here as it contains
- // a reference to itself. This is the only way I have come up
- // with to stop infinite recursion in this case.
- if ($name=='GLOBALS'
- && is_array($value)
- && array_key_exists('GLOBALS',$value)) {
- $value['GLOBALS'] = '** Recursion **';
- }
-
- $encoded_value = $this->json_encode($value);
-
- if ($encoded_value instanceof Exception) {
- return $encoded_value;
- }
-
- return $this->json_encode(strval($name)) . ':' . $encoded_value;
- }
-}
diff --git a/src/application/configs/modules/Wootook.php b/src/application/configs/modules/Wootook.php
new file mode 100644
index 0000000..c94c9e0
--- /dev/null
+++ b/src/application/configs/modules/Wootook.php
@@ -0,0 +1,17 @@
+ array(
+ 'modules' => array(
+ 'WootookCore' => array(
+ 'active' => true,
+ 'code-pool' => 'core'
+ ),
+ 'WootookPlayer' => array(
+ 'active' => false,
+ 'code-pool' => 'core',
+ 'dependencies' => array(
+ 'WootookCore' => '1.5.0'
+ )
+ )
+ )
+ )
+ );
diff --git a/src/application/configs/system.php b/src/application/configs/system.php
index 8246cb4..033ef82 100644
--- a/src/application/configs/system.php
+++ b/src/application/configs/system.php
@@ -52,7 +52,7 @@
),
'home' => array(
'title' => 'Welcome on Wootook!',
- 'formated-welcome-text' => '
Wootook make you an emperor.
Conquer outer space and master other players on Wootook.
'
+ 'formatted-welcome-text' => '
Wootook make you an emperor.
Conquer outer space and master other players on Wootook.
La centrale électrique solaire est la source d'énergie la plus abordable.
",
+ 'description' => "
La centrale électrique solaire est la source d'énergie la plus abordable.
Elle puise sa source des étoiles les plus proches de la planète sur laquelle elle est implantée. De ce fait, les planètes les plus proches du centre du système solaires produiront une plus grande quantité d'énergie que les planètes les plus éloignées.
Fruit de longues décénnies de recherche, le réacteur à fusion nucléaire est désormais une source d'énergie rentable.
Nourrie par l'énergie engendrée par la fusion des isotopes d'hydrogène, cette centrale génère plus d'énergie que toutes les autres sources d'énergie. La contrepartie à cette surgénération d'énergie, est son côut en deutérium.
",
+ 'description' => "
Fruit de longues décénnies de recherche, le réacteur à fusion nucléaire est désormais une source d'énergie rentable.
Nourrie par l'énergie engendrée par la fusion des isotopes d'hydrogène, cette centrale génère plus d'énergie que toutes les autres sources d'énergie disponibles aujourd'hui. La contrepartie à cette surgénération d'énergie est son côut en deutérium.
",
'image' => 'medias/klore/images/building/fusion-reactor.jpg'
),
diff --git a/src/application/modules/WootookCore/autoload_classmap.php b/src/application/modules/WootookCore/autoload_classmap.php
new file mode 100644
index 0000000..52d6e08
--- /dev/null
+++ b/src/application/modules/WootookCore/autoload_classmap.php
@@ -0,0 +1,168 @@
+ __DIR__ . '/src/Wootook/Core/App/App.php',
+ 'Wootook\\Core\\Base\\BaseObject' => __DIR__ . '/src/Wootook/Core/Base/BaseObject.php',
+ 'Wootook\\Core\\Base\\DataContainer' => __DIR__ . '/src/Wootook/Core/Base/DataContainer.php',
+ 'Wootook\\Core\\Base\\Service\\App' => __DIR__ . '/src/Wootook/Core/Base/Service/App.php',
+ 'Wootook\\Core\\Base\\Singleton' => __DIR__ . '/src/Wootook/Core/Base/Singleton.php',
+ 'Wootook\\Core\\Base\\Util\FileSystem' => __DIR__ . '/src/Wootook/Core/Base/Util/FileSystem.php',
+ 'Wootook\\Core\\Block\\Concat' => __DIR__ . '/src/Wootook/Core/Block/Concat.php',
+ 'Wootook\\Core\\Block\\Deprecated' => __DIR__ . '/src/Wootook/Core/Block/Deprecated.php',
+ 'Wootook\\Core\\Block\\Html\\Form' => __DIR__ . '/src/Wootook/Core/Block/Html/Form.php',
+ 'Wootook\\Core\\Block\\Html\\Head' => __DIR__ . '/src/Wootook/Core/Block/Html/Head.php',
+ 'Wootook\\Core\\Block\\Html\\Home' => __DIR__ . '/src/Wootook/Core/Block/Html/Home.php',
+ 'Wootook\\Core\\Block\\Html\\Navigation\\Link' => __DIR__ . '/src/Wootook/Core/Block/Html/Navigation/Link.php',
+ 'Wootook\\Core\\Block\\Html\\Navigation\\Menu' => __DIR__ . '/src/Wootook/Core/Block/Html/Navigation/Menu.php',
+ 'Wootook\\Core\\Block\\Html\\Navigation\\Node' => __DIR__ . '/src/Wootook/Core/Block/Html/Navigation/Node.php',
+ 'Wootook\\Core\\Block\\Html\\Page' => __DIR__ . '/src/Wootook/Core/Block/Html/Page.php',
+ 'Wootook\\Core\\Block\\Messages' => __DIR__ . '/src/Wootook/Core/Block/Messages.php',
+ 'Wootook\\Core\\Block\\Template' => __DIR__ . '/src/Wootook/Core/Block/Template.php',
+ 'Wootook\\Core\\Block\\Text' => __DIR__ . '/src/Wootook/Core/Block/Text.php',
+ 'Wootook\\Core\\Config\\Adapter\\Adapter' => __DIR__ . '/src/Wootook/Core/Config/Adapter/Adapter.php',
+ 'Wootook\\Core\\Config\\Adapter\\PhpArray' => __DIR__ . '/src/Wootook/Core/Config/Adapter/PhpArray.php',
+ 'Wootook\\Core\\Config\\Node' => __DIR__ . '/src/Wootook/Core/Config/Node.php',
+ 'Wootook\\Core\\Controller\\ErrorController' => __DIR__ . '/src/Wootook/Core/Controller/ErrorController.php',
+ 'Wootook\\Core\\Controller\\IndexController' => __DIR__ . '/src/Wootook/Core/Controller/IndexController.php',
+ 'Wootook\\Core\\Database\\Adapter\\Adapter' => __DIR__ . '/src/Wootook/Core/Database/Adapter/Adapter.php',
+ 'Wootook\\Core\\Database\\Adapter\\Mysql' => __DIR__ . '/src/Wootook/Core/Database/Adapter/Mysql.php',
+ 'Wootook\\Core\\Database\\Adapter\\Pdo' => __DIR__ . '/src/Wootook/Core/Database/Adapter/Pdo.php',
+ 'Wootook\\Core\\Database\\Adapter\\Pdo\\Mysql' => __DIR__ . '/src/Wootook/Core/Database/Adapter/Pdo/Mysql.php',
+ 'Wootook\\Core\\Database\\Adapter\\Pdo\\Sqlite' => __DIR__ . '/src/Wootook/Core/Database/Adapter/Pdo/Sqlite.php',
+ 'Wootook\\Core\\Database\\ConnectionManager' => __DIR__ . '/src/Wootook/Core/Database/ConnectionManager.php',
+ 'Wootook\\Core\\Database\\Orm\\DataMapper\\Config' => __DIR__ . '/src/Wootook/Core/Database/Orm/DataMapper/Config.php',
+ 'Wootook\\Core\\Database\\Orm\\DataMapper\\DateTime' => __DIR__ . '/src/Wootook/Core/Database/Orm/DataMapper/DateTime.php',
+ 'Wootook\\Core\\Database\\Orm\\DataMapper\\FieldMapper' => __DIR__ . '/src/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php',
+ 'Wootook\\Core\\Database\\Orm\\DataMapper\\PhpArray' => __DIR__ . '/src/Wootook/Core/Database/Orm/DataMapper/PhpArray.php',
+ 'Wootook\\Core\\Database\\Orm\\DataMapper\\PhpObject' => __DIR__ . '/src/Wootook/Core/Database/Orm/DataMapper/PhpObject.php',
+ 'Wootook\\Core\\Database\\Orm\\DataMapper' => __DIR__ . '/src/Wootook/Core/Database/Orm/DataMapper.php',
+ 'Wootook\\Core\\Database\\Resource\\DataMapper' => __DIR__ . '/src/Wootook/Core/Database/Resource/DataMapper.php',
+ 'Wootook\\Core\\Database\\Resource\\ReadConnection' => __DIR__ . '/src/Wootook/Core/Database/Resource/ReadConnection.php',
+ 'Wootook\\Core\\Database\\Resource\\WriteConnection' => __DIR__ . '/src/Wootook/Core/Database/Resource/WriteConnection.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Delete' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Delete.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Dml' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Dml.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\DmlQuery' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/DmlQuery.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Insert' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Insert.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Select' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Select.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Update' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Update.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Condition\\Condition' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Condition/Condition.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Condition\\LogicalOperator' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Condition/LogicalOperator.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Condition\\MathOperator' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Condition/MathOperator.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Column' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Column.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\ColumnAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/ColumnAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\From' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/From.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\FromAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/FromAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Into' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Into.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\IntoAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/IntoAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Limit' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Limit.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\LimitAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/LimitAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Set' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Set.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\SetAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/SetAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Where' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Where.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\WhereAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/WhereAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\Column' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Column.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\ColumnAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/ColumnAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\From' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/From.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\FromAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/FromAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\Into' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Into.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\IntoAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/IntoAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\Limit' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Limit.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\LimitAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/LimitAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\Set' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Set.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\SetAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/SetAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\Where' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Where.php',
+ 'Wootook\\Core\\Database\\Sql\\Dml\\Section\\Renderer\\WhereAware' => __DIR__ . '/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/WhereAware.php',
+ 'Wootook\\Core\\Database\\Sql\\Placeholder\\Expression' => __DIR__ . '/src/Wootook/Core/Database/Sql/Placeholder/Expression.php',
+ 'Wootook\\Core\\Database\\Sql\\Placeholder\\Param' => __DIR__ . '/src/Wootook/Core/Database/Sql/Placeholder/Param.php',
+ 'Wootook\\Core\\Database\\Sql\\Placeholder\\Placeholder' => __DIR__ . '/src/Wootook/Core/Database/Sql/Placeholder/Placeholder.php',
+ 'Wootook\\Core\\Database\\Sql\\Placeholder\\Variable' => __DIR__ . '/src/Wootook/Core/Database/Sql/Placeholder/Variable.php',
+ 'Wootook\\Core\\Database\\Statement\\Mysql' => __DIR__ . '/src/Wootook/Core/Database/Statement/Mysql.php',
+ 'Wootook\\Core\\Database\\Statement\\Pdo' => __DIR__ . '/src/Wootook/Core/Database/Statement/Pdo.php',
+ 'Wootook\\Core\\Database\\Statement\\Statement' => __DIR__ . '/src/Wootook/Core/Database/Statement/Statement.php',
+ 'Wootook\\Core\\DateTime\\DateInterval' => __DIR__ . '/src/Wootook/Core/DateTime/DateInterval.php',
+ 'Wootook\\Core\\DateTime\\DatePeriod' => __DIR__ . '/src/Wootook/Core/DateTime/DatePeriod.php',
+ 'Wootook\\Core\\DateTime\\DateTime' => __DIR__ . '/src/Wootook/Core/DateTime/DateTime.php',
+ 'Wootook\\Core\\DateTime\\DateTimeZone' => __DIR__ . '/src/Wootook/Core/DateTime/DateTimeZone.php',
+ 'Wootook\\Core\\DependencyInjection\\Definition\\ClassDefinition' => __DIR__ . '/src/Wootook/Core/DependencyInjection/Definition/ClassDefinition.php',
+ 'Wootook\\Core\\DependencyInjection\\Definition\\MethodDefinition' => __DIR__ . '/src/Wootook/Core/DependencyInjection/Definition/MethodDefinition.php',
+ 'Wootook\\Core\\DependencyInjection\\Definition\\ArgumentDefinition' => __DIR__ . '/src/Wootook/Core/DependencyInjection/Definition/ArgumentDefinition.php',
+ 'Wootook\\Core\\DependencyInjection\\Factory' => __DIR__ . '/src/Wootook/Core/DependencyInjection/Factory.php',
+ 'Wootook\\Core\\DependencyInjection\\Registry' => __DIR__ . '/src/Wootook/Core/DependencyInjection/Registry.php',
+ 'Wootook\\Core\\Email\\Email' => __DIR__ . '/src/Wootook/Core/Email/Email.php',
+ 'Wootook\\Core\\Email\\Part\\Part' => __DIR__ . '/src/Wootook/Core/Email/Part/Part.php',
+ 'Wootook\\Core\\Email\\Transport\\Sendmail' => __DIR__ . '/src/Wootook/Core/Email/Transport/Sendmail.php',
+ 'Wootook\\Core\\Email\\Transport\\Transport' => __DIR__ . '/src/Wootook/Core/Email/Transport/Transport.php',
+ 'Wootook\\Core\\Event\\Break' => __DIR__ . '/src/Wootook/Core/Event/Break.php',
+ 'Wootook\\Core\\Event\\Event' => __DIR__ . '/src/Wootook/Core/Event/Event.php',
+ 'Wootook\\Core\\Event\\EventTarget' => __DIR__ . '/src/Wootook/Core/Event/EventTarget.php',
+ 'Wootook\\Core\\Exception\\CoreException' => __DIR__ . '/src/Wootook/Core/Exception/CoreException.php',
+ 'Wootook\\Core\\Exception\\BadMethodCallException' => __DIR__ . '/src/Wootook/Core/Exception/BadMethodCallException.php',
+ 'Wootook\\Core\\Exception\\DataAccessException' => __DIR__ . '/src/Wootook/Core/Exception/DataAccessException.php',
+ 'Wootook\\Core\\Exception\\Database\\AdapterError' => __DIR__ . '/src/Wootook/Core/Exception/Database/AdapterError.php',
+ 'Wootook\\Core\\Exception\\Database\\Error' => __DIR__ . '/src/Wootook/Core/Exception/Database/Error.php',
+ 'Wootook\\Core\\Exception\\Database\\StatementError' => __DIR__ . '/src/Wootook/Core/Exception/Database/StatementError.php',
+ 'Wootook\\Core\\Exception\\DependencyInjection\\BadMethodCallException' => __DIR__ . '/src/Wootook/Core/Exception/DependencyInjection/BadMethodCallException.php',
+ 'Wootook\\Core\\Exception\\DependencyInjection\\InvalidArgumentException' => __DIR__ . '/src/Wootook/Core/Exception/DependencyInjection/InvalidArgumentException.php',
+ 'Wootook\\Core\\Exception\\DependencyInjection\\RuntimeException' => __DIR__ . '/src/Wootook/Core/Exception/DependencyInjection/RuntimeException.php',
+ 'Wootook\\Core\\Exception\\Deprecated' => __DIR__ . '/src/Wootook/Core/Exception/Deprecated.php',
+ 'Wootook\\Core\\Exception\\Exception' => __DIR__ . '/src/Wootook/Core/Exception/Exception.php',
+ 'Wootook\\Core\\Exception\\GameError' => __DIR__ . '/src/Wootook/Core/Exception/GameError.php',
+ 'Wootook\\Core\\Exception\\InvalidArgumentException' => __DIR__ . '/src/Wootook/Core/Exception/InvalidArgumentException.php',
+ 'Wootook\\Core\\Exception\\LayoutException' => __DIR__ . '/src/Wootook/Core/Exception/LayoutException.php',
+ 'Wootook\\Core\\Exception\\RuntimeException' => __DIR__ . '/src/Wootook/Core/Exception/RuntimeException.php',
+ 'Wootook\\Core\\Exception\\WebsiteError' => __DIR__ . '/src/Wootook/Core/Exception/WebsiteError.php',
+ 'Wootook\\Core\\Form\\Element\\BaseElement' => __DIR__ . '/src/Wootook/Core/Form/Element/BaseElement.php',
+ 'Wootook\\Core\\Form\\Element\\Button' => __DIR__ . '/src/Wootook/Core/Form/Element/Button.php',
+ 'Wootook\\Core\\Form\\Element\\Text' => __DIR__ . '/src/Wootook/Core/Form/Element/Text.php',
+ 'Wootook\\Core\\Form\\ElementLoader' => __DIR__ . '/src/Wootook/Core/Form/ElementLoader.php',
+ 'Wootook\\Core\\Form\\Form' => __DIR__ . '/src/Wootook/Core/Form/Form.php',
+ 'Wootook\\Core\\Form\\Validator\\Alnum' => __DIR__ . '/src/Wootook/Core/Form/Validator/Alnum.php',
+ 'Wootook\\Core\\Form\\Validator\\Alpha' => __DIR__ . '/src/Wootook/Core/Form/Validator/Alpha.php',
+ 'Wootook\\Core\\Form\\Validator\\BaseValidator' => __DIR__ . '/src/Wootook/Core/Form/Validator/BaseValidator.php',
+ 'Wootook\\Core\\Form\\Validator\\Email' => __DIR__ . '/src/Wootook/Core/Form/Validator/Email.php',
+ 'Wootook\\Core\\Form\\Validator\\FormKey' => __DIR__ . '/src/Wootook/Core/Form/Validator/FormKey.php',
+ 'Wootook\\Core\\Form\\Validator\\Hex' => __DIR__ . '/src/Wootook/Core/Form/Validator/Hex.php',
+ 'Wootook\\Core\\Form\\Validator\\Host' => __DIR__ . '/src/Wootook/Core/Form/Validator/Host.php',
+ 'Wootook\\Core\\Form\\Validator\\Numeric' => __DIR__ . '/src/Wootook/Core/Form/Validator/Numeric.php',
+ 'Wootook\\Core\\Form\\Validator\\Regex' => __DIR__ . '/src/Wootook/Core/Form/Validator/Regex.php',
+ 'Wootook\\Core\\Form\\ValidatorLoader' => __DIR__ . '/src/Wootook/Core/Form/ValidatorLoader.php',
+ 'Wootook\\Core\\Helper\\Config\\ConfigHandler' => __DIR__ . '/src/Wootook/Core/Helper/Config/ConfigHandler.php',
+ 'Wootook\\Core\\Helper\\Config\\Events' => __DIR__ . '/src/Wootook/Core/Helper/Config/Events.php',
+ 'Wootook\\Core\\Helper\\Config\\Modules' => __DIR__ . '/src/Wootook/Core/Helper/Config/Modules.php',
+ 'Wootook\\Core\\Layout\\Manager' => __DIR__ . '/src/Wootook/Core/Layout/Manager.php',
+ 'Wootook\\Core\\Layout\\Parser' => __DIR__ . '/src/Wootook/Core/Layout/Parser.php',
+ 'Wootook\\Core\\Model\\Config' => __DIR__ . '/src/Wootook/Core/Model/Config.php',
+ 'Wootook\\Core\\Model\\Game' => __DIR__ . '/src/Wootook/Core/Model/Game.php',
+ 'Wootook\\Core\\Model\\Image\\Png' => __DIR__ . '/src/Wootook/Core/Model/Image/Png.php',
+ 'Wootook\\Core\\Model\\Session' => __DIR__ . '/src/Wootook/Core/Model/Session.php',
+ 'Wootook\\Core\\Model\\Translator' => __DIR__ . '/src/Wootook/Core/Model/Translator.php',
+ 'Wootook\\Core\\Model\\Website' => __DIR__ . '/src/Wootook/Core/Model/Website.php',
+ 'Wootook\\Core\\Mvc\\Controller\\Action' => __DIR__ . '/src/Wootook/Core/Mvc/Controller/Action.php',
+ 'Wootook\\Core\\Mvc\\Controller\\Front' => __DIR__ . '/src/Wootook/Core/Mvc/Controller/Front.php',
+ 'Wootook\\Core\\Mvc\\Controller\\Request\\Http' => __DIR__ . '/src/Wootook/Core/Mvc/Controller/Request/Http.php',
+ 'Wootook\\Core\\Mvc\\Controller\\Request\\Request' => __DIR__ . '/src/Wootook/Core/Mvc/Controller/Request/Request.php',
+ 'Wootook\\Core\\Mvc\\Controller\\Response\\Http' => __DIR__ . '/src/Wootook/Core/Mvc/Controller/Response/Http.php',
+ 'Wootook\\Core\\Mvc\\Controller\\Response\\Response' => __DIR__ . '/src/Wootook/Core/Mvc/Controller/Response/Response.php',
+ 'Wootook\\Core\\Mvc\\Model\\Action\\Deletable' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Action/Deletable.php',
+ 'Wootook\\Core\\Mvc\\Model\\Action\\Delete' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Action/Delete.php',
+ 'Wootook\\Core\\Mvc\\Model\\Action\\Load' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Action/Load.php',
+ 'Wootook\\Core\\Mvc\\Model\\Action\\Loadable' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Action/Loadable.php',
+ 'Wootook\\Core\\Mvc\\Model\\Action\\Savable' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Action/Savable.php',
+ 'Wootook\\Core\\Mvc\\Model\\Action\\Save' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Action/Save.php',
+ 'Wootook\\Core\\Mvc\\Model\\Entity' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Entity.php',
+ 'Wootook\\Core\\Mvc\\Model\\EntityInterface' => __DIR__ . '/src/Wootook/Core/Mvc/Model/EntityInterface.php',
+ 'Wootook\\Core\\Mvc\\Model\\SubTable' => __DIR__ . '/src/Wootook/Core/Mvc/Model/SubTable.php',
+ 'Wootook\\Core\\Mvc\\Model\\Type\\Base' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Type/Base.php',
+ 'Wootook\\Core\\Mvc\\Model\\Type\\Full' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Type/Full.php',
+ 'Wootook\\Core\\Mvc\\Model\\Type\\Readonly' => __DIR__ . '/src/Wootook/Core/Mvc/Model/Type/Readonly.php',
+ 'Wootook\\Core\\Mvc\\View\\View' => __DIR__ . '/src/Wootook/Core/Mvc/View/View.php',
+ 'Wootook\\Core\\PluginLoader\\PluginLoader' => __DIR__ . '/src/Wootook/Core/PluginLoader/PluginLoader.php',
+ 'Wootook\\Core\\Profiler\\ErrorProfiler' => __DIR__ . '/src/Wootook/Core/Profiler/ErrorProfiler.php',
+ 'Wootook\\Core\\Resource\\Entity' => __DIR__ . '/src/Wootook/Core/Resource/Entity.php',
+ 'Wootook\\Core\\Resource\\EntityCollection\\Action\\Load' => __DIR__ . '/src/Wootook/Core/Resource/EntityCollection/Action/Load.php',
+ 'Wootook\\Core\\Resource\\EntityCollection\\Action\\Loadable' => __DIR__ . '/src/Wootook/Core/Resource/EntityCollection/Action/Loadable.php',
+ 'Wootook\\Core\\Resource\\EntityCollection' => __DIR__ . '/src/Wootook/Core/Resource/EntityCollection.php',
+ 'Wootook\\Core\\Setup\\Exception\\RuntimeException' => __DIR__ . '/src/Wootook/Core/Setup/Exception/RuntimeException.php',
+ 'Wootook\\Core\\Setup\\Exception\\VersionStageError' => __DIR__ . '/src/Wootook/Core/Setup/Exception/VersionStageError.php',
+ 'Wootook\\Core\\Setup\\Exception\\VersionValueError' => __DIR__ . '/src/Wootook/Core/Setup/Exception/VersionValueError.php',
+ 'Wootook\\Core\\Setup\\Updater\\ScriptQueue' => __DIR__ . '/src/Wootook/Core/Setup/Updater/ScriptQueue.php',
+ 'Wootook\\Core\\Setup\\Updater' => __DIR__ . '/src/Wootook/Core/Setup/Updater.php',
+);
diff --git a/src/application/modules/WootookCore/autoload_function.php b/src/application/modules/WootookCore/autoload_function.php
new file mode 100644
index 0000000..3cce3b6
--- /dev/null
+++ b/src/application/modules/WootookCore/autoload_function.php
@@ -0,0 +1,11 @@
+ array(
+ 'routes' => array(
+ 'default' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Segment',
+ 'options' => array(
+ 'route' => '/[:controller[/:action]]',
+ 'constraints' => array(
+ 'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
+ 'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
+ ),
+ 'defaults' => array(
+ 'controller' => 'IndexController',
+ 'action' => 'index',
+ ),
+ ),
+ ),
+ 'home' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Literal',
+ 'options' => array(
+ 'route' => '/',
+ 'defaults' => array(
+ 'controller' => 'IndexController',
+ 'action' => 'index',
+ ),
+ ),
+ ),
+ ),
+ ),
+ 'controller' => array(
+ 'classes' => array(
+ 'IndexController' => 'Application\Controller\IndexController'
+ ),
+ ),
+ 'view_manager' => array(
+ 'display_not_found_reason' => true,
+ 'display_exceptions' => true,
+ 'doctype' => 'HTML5',
+ 'not_found_template' => 'error/404',
+ 'exception_template' => 'error/index',
+ 'template_map' => array(
+ 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
+ 'index/index' => __DIR__ . '/../view/index/index.phtml',
+ 'error/404' => __DIR__ . '/../view/error/404.phtml',
+ 'error/index' => __DIR__ . '/../view/error/index.phtml',
+ ),
+ 'template_path_stack' => array(
+ 'application' => __DIR__ . '/../view',
+ ),
+ ),
+);
diff --git a/src/application/code/core/Wootook/Core/configs/module.php b/src/application/modules/WootookCore/config/module.php
similarity index 65%
rename from src/application/code/core/Wootook/Core/configs/module.php
rename to src/application/modules/WootookCore/config/module.php
index 9b01f6a..0ab6e23 100644
--- a/src/application/code/core/Wootook/Core/configs/module.php
+++ b/src/application/modules/WootookCore/config/module.php
@@ -1,13 +1,13 @@
array(
- 'Wootook_Core' => array(
- 'version' => '1.5.0'
+ 'global' => array(
+ 'modules' => array(
+ 'WootookCore' => array(
+ 'version' => '1.5.0'
)
),
- 'global' => array(
'models' => array(
'core' => array(
- 'namespace' => 'Warner_Core_Model_',
+ 'namespace' => 'Wootook\\Core\\Model',
'connection' => array(
'read' => 'core_read',
'write' => 'core_write',
@@ -17,17 +17,17 @@
),
'blocks' => array(
'core' => array(
- 'namespace' => 'Warner_Core_Block_'
+ 'namespace' => 'Wootook\\Core\\Block'
)
)
),
'frontend' => array(
'routes' => array(
'core' => array(
- 'modules' => array(
- 'core' => 'Wootook_Core'
+ 'controllers' => array(
+ 'core' => 'Wootook\\Core\\Controller'
)
)
)
)
- );
\ No newline at end of file
+ );
diff --git a/src/application/code/core/Wootook/Core/install/mysql5/install-1.5.0.php b/src/application/modules/WootookCore/install/mysql5/install-1.5.0.beta2.php
similarity index 100%
rename from src/application/code/core/Wootook/Core/install/mysql5/install-1.5.0.php
rename to src/application/modules/WootookCore/install/mysql5/install-1.5.0.beta2.php
diff --git a/src/application/code/core/Wootook/Core/install/mysql5/uninstall-1.5.0.php b/src/application/modules/WootookCore/install/mysql5/uninstall-1.5.0.beta2.php
similarity index 100%
rename from src/application/code/core/Wootook/Core/install/mysql5/uninstall-1.5.0.php
rename to src/application/modules/WootookCore/install/mysql5/uninstall-1.5.0.beta2.php
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/App/App.php b/src/application/modules/WootookCore/src/Wootook/Core/App/App.php
new file mode 100644
index 0000000..898527a
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/App/App.php
@@ -0,0 +1,498 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+
+namespace Wootook\Core\App;
+
+use Wootook\Core,
+ Wootook\Core\Config\Adapter as ConfigAdapter,
+ Wootook\Core\Database,
+ Wootook\Core\Exception as CoreException,
+ Wootook\Core\Mvc\Controller as MvcController,
+ Wootook\Core\Profiler;
+/**
+ *
+ */
+class App
+{
+ const ENV_PRODUCTION = 'prod';
+ const ENV_INTEGRATION = 'inte';
+ const ENV_TESTING = 'test';
+ const ENV_DEVELOPMENT = 'devel';
+
+ const DOMAIN_INSTALL = 'install';
+ const DOMAIN_BACKEND = 'backend';
+ const DOMAIN_FRONTEND = 'frontend';
+ const DOMAIN_WEBSOCKET = 'websocket';
+
+ const SCOPE_GLOBAL = 'global';
+ const SCOPE_WEBSITE = 'website';
+ const SCOPE_GAME = 'game';
+
+ /**
+ *
+ * Enter description here ...
+ * @var ConfigAdapter\Adapter
+ */
+ private $_rootConfig = null;
+ private $_globalConfig = null;
+
+ protected $_websiteList = array();
+ protected $_gameList = array();
+
+ protected $_defaultWebsiteId = 1;
+ protected $_defaultGameId = 1;
+
+ protected $_blockSingletons = array();
+ protected $_modelSingletons = array();
+ protected $_resourceSingletons = array();
+ protected $_helperSingletons = array();
+
+ protected $_frontController = null;
+
+ protected $_connectionManager = null;
+
+ public function __construct($configPath, $domain = self::DOMAIN_FRONTEND, $environment = self::ENV_PRODUCTION)
+ {
+ try {
+ $this->_rootConfig = new ConfigAdapter\PhpArray();
+ $this->_rootConfig->load($configPath . DIRECTORY_SEPARATOR . 'system.php');
+
+ $localConfig = new ConfigAdapter\PhpArray();
+ $localConfig->load($configPath . DIRECTORY_SEPARATOR . 'local.php');
+
+ $this->_rootConfig->merge($localConfig);
+
+ $directoryIterator = new \FilesystemIterator($configPath . DIRECTORY_SEPARATOR . 'modules');
+ foreach ($directoryIterator as $file) {
+ $modulesConfig = new ConfigAdapter\PhpArray();
+ $modulesConfig->load($file->getPathname());
+
+ $this->_rootConfig->merge($modulesConfig);
+ }
+
+ foreach ($this->_rootConfig->getConfig('global/modules') as $moduleName => $moduleConfig) {
+ if (!$moduleConfig->getConfig('active')) {
+ continue;
+ }
+
+ $path = $moduleName . '/config/module.php';
+
+ try {
+ $additionalModuleConfig = new ConfigAdapter\PhpArray();
+ $additionalModuleConfig->load($path);
+
+ $this->_rootConfig->merge($additionalModuleConfig);
+ } catch (CoreException\DataAccessException $e) {
+ Profiler\ErrorProfiler::getSingleton()->addException($e);
+ continue;
+ }
+ }
+
+ if (empty($domain) || !$this->_rootConfig[$domain]) {
+ $domain = self::DOMAIN_FRONTEND;
+ }
+
+ if (empty($environment) || !$this->_rootConfig[$environment]) {
+ $environment = self::ENV_PRODUCTION;
+ }
+
+ $this->_globalConfig = clone $this->_rootConfig['default'];
+
+ $this->appendEnvironmentConfig($this->_globalConfig, 'global')
+ ->appendEnvironmentConfig($this->_globalConfig, $environment)
+ ->appendEnvironmentConfig($this->_globalConfig, $domain);
+ } catch (CoreException\DataAccessException $e) {
+ Profiler\ErrorProfiler::getSingleton()->addException($e);
+ }
+ }
+
+ /**
+ * @return MvcController\Front
+ */
+ public function getFrontController()
+ {
+ if ($this->_frontController === null) {
+ $this->_frontController = new MvcController\Front($this);
+ }
+ return $this->_frontController;
+ }
+
+ /**
+ * @return MvcController\Front
+ */
+ public function getConnectionManager()
+ {
+ if ($this->_connectionManager === null) {
+ $this->_connectionManager = new Database\ConnectionManager($this);
+ }
+ return $this->_connectionManager;
+ }
+
+ /**
+ * @param MvcController\Front $frontController
+ * @return Core\App
+ */
+ public function setFrontController(MvcController\Front $frontController)
+ {
+ $this->_frontController = $frontController;
+
+ return $this;
+ }
+
+ public function appendEnvironmentConfig(Core\Config\Node $config, $environment)
+ {
+ if (isset($this->_rootConfig[$environment])) {
+ $config->merge($this->_rootConfig[$environment]);
+ }
+
+ return $this;
+ }
+
+ public function appendDatabaseConfig(Core\Config\Node $config, $scope = self::SCOPE_GLOBAL, $scopeId = 0)
+ {
+ if (empty($scope)) {
+ $scope = self::SCOPE_GLOBAL;
+ }
+
+ if ($scope !== self::SCOPE_GLOBAL && $scopeId <= 0) {
+ $scope = self::SCOPE_GLOBAL;
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\RuntimeException('Please specify a valid scope ID.'));
+ }
+
+ if ($scope === self::SCOPE_GLOBAL && $scopeId != 0) {
+ $scopeId = 0;
+ }
+
+ $readAdapter = $this->getConnectionManager()
+ ->getConnection('core_read');
+
+ $select = $readAdapter->select()
+ ->column(array('path' => 'config_path', 'value' => 'config_value'))
+ ->from(array('config' => $readAdapter->getTable('core_config')))
+ ;
+ switch ($scope) {
+ case self::SCOPE_GLOBAL:
+ $select->where('game_id', 0)->where('website_id', 0);
+ break;
+ case self::SCOPE_WEBSITE:
+ $select->where('website_id', $scopeId);
+ break;
+ case self::SCOPE_GAME:
+ $select->where('game_id', $scopeId);
+ break;
+ }
+ /** @var Core\Database\Statement\Statement $statement */
+ $statement = $select->prepare();
+
+ $statement->execute();
+ foreach ($statement as $row) {
+ $config->setConfig($row['path'], $row['value']);
+ }
+
+ return $this;
+ }
+
+ public function setDefaultWebsiteId($websiteIdentifier)
+ {
+ $this->_defaultWebsiteId = $websiteIdentifier;
+
+ return $this;
+ }
+
+ public function getDefaultWebsiteId()
+ {
+ return $this->_defaultWebsiteId;
+ }
+
+ /**
+ * @return \Wootook\Core\Model\Website
+ */
+ public function getDefaultWebsite()
+ {
+ return $this->getWebsite($this->_defaultWebsiteId);
+ }
+
+ public function setDefaultGameId($gameIdentifier)
+ {
+ $this->_defaultGameId = $gameIdentifier;
+
+ return $this;
+ }
+
+ public function getDefaultGameId()
+ {
+ return $this->_defaultGameId;
+ }
+
+ public function getDefaultGame()
+ {
+ return $this->getGame($this->_defaultGameId);
+ }
+
+ /**
+ * @param string|int $websiteIdentifier
+ * @return \Wootook\Core\Model\Website
+ */
+ public function getWebsite($websiteIdentifier)
+ {
+ if (!isset($this->_websiteList[$websiteIdentifier])) {
+ /** @var Model\Website $website */
+ //$website = $this->getModel('core', 'website', array($this));
+ $website = new Model\Website($this);
+
+ if (is_numeric($websiteIdentifier)) {
+ $website->load($websiteIdentifier);
+ } else if ($websiteIdentifier !== null) {
+ $website->load($websiteIdentifier, 'code');
+ } else {
+ throw new CoreException\RuntimeException('Website identifier should be specified.');
+ }
+
+ $this->_websiteList[$website->getId()] = $website;
+ $this->_websiteList[$website->getCode()] = $website;
+ }
+
+ return $this->_websiteList[$websiteIdentifier];
+ }
+
+ /**
+ * @param string|int $gameIdentifier
+ * @return \Wootook\Core\Model\Game
+ */
+ public function getGame($gameIdentifier)
+ {
+ if (!isset($this->_gameList[$gameIdentifier])) {
+ /** @var Model\Game $game */
+ //$game = $this->getModel('core', 'game', array($this));
+ $game = new Model\Game($this);
+
+ if (is_numeric($gameIdentifier)) {
+ $game->load($gameIdentifier);
+ } else if ($gameIdentifier !== null) {
+ $game->load($gameIdentifier, 'code');
+ } else {
+ throw new CoreException\RuntimeException('Game identifier should be specified.');
+ }
+
+ $this->_gameList[$game->getId()] = $game;
+ $this->_gameList[$game->getCode()] = $game;
+ }
+
+ return $this->_gameList[$gameIdentifier];
+ }
+
+ public function getGlobalConfig($path = null)
+ {
+ if ($this->_globalConfig === null) {
+ return null;
+ }
+ if ($path !== null) {
+ return $this->_globalConfig->getConfig($path);
+ }
+ return $this->_globalConfig;
+ }
+
+ protected function _resolveClassType(&$namespaces, $module, $class)
+ {
+ $classSuffix = str_replace(' ', '', ucwords(str_replace('-', ' ', $class)));
+ $classSuffix = str_replace(' ', '_', ucwords(str_replace('.', ' ', $classSuffix)));
+
+ if (isset($namespaces[$module])) {
+ foreach ($namespaces[$module] as $namespace => $path) {
+ $className = $namespace . $classSuffix;
+ $fileName = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $classSuffix) . '.php';
+
+ Profiler\ErrorProfiler::getSingleton()->sleep();
+ if (!($fp = @fopen($fileName, 'r', true))) {
+ Profiler\ErrorProfiler::getSingleton()->wakeup();
+ continue;
+ }
+ Profiler\ErrorProfiler::getSingleton()->wakeup();
+ fclose($fp);
+
+ if (!class_exists($className, true)) {
+ continue;
+ }
+
+ return $className;
+ }
+ }
+
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\RuntimeException(sprintf('Class type "%1$s/%2$s" could not be resolved.', $module, $class)));
+ return null;
+ }
+
+ protected function _newInstance($className, Array $constructorParams)
+ {
+ if ($className === null) {
+ return null;
+ }
+
+ if (empty($constructorParams)) {
+ return new $className;
+ } else {
+ $reflection = new ReflectionClass($className);
+ return $reflection->newInstanceArgs($constructorParams);
+ }
+ }
+
+ protected function _parseIdentifier($identifier, &$module, &$class)
+ {
+ $offset = strpos($identifier, '/');
+ if ($offset === false) {
+ $module = $identifier;
+ $class = null;
+
+ return;
+ }
+
+ $module = substr($identifier, 0, $offset);
+ $class = substr($identifier, $offset + 1);
+ }
+
+ public function block($identifier, Array $constructorParams = array())
+ {
+ $this->_parseIdentifier($identifier, $module, $class);
+
+ if ($class === null) {
+ $class = 'view';
+ }
+
+ return $this->getBlock($module, $class, $constructorParams);
+ }
+
+ public function model($identifier, Array $constructorParams = array())
+ {
+ $this->_parseIdentifier($identifier, $module, $class);
+
+ if ($class === null) {
+ $class = 'entity';
+ }
+
+ return $this->getModel($module, $class, $constructorParams);
+ }
+
+ public function resource($identifier, Array $constructorParams = array())
+ {
+ $this->_parseIdentifier($identifier, $module, $class);
+
+ if ($class === null) {
+ $class = 'entity';
+ }
+
+ return $this->getResource($module, $class, $constructorParams);
+ }
+
+ public function helper($identifier, Array $constructorParams = array())
+ {
+ $this->_parseIdentifier($identifier, $module, $class);
+
+ if ($class === null) {
+ $class = 'data';
+ }
+
+ return $this->getResource($module, $class, $constructorParams);
+ }
+
+ public function getBlock($module, $class, Array $constructorParams = array())
+ {
+ $className = $this->_resolveClassType($this->_globalConfig->getConfig('blocks'), $module, $class);
+
+ return $this->_newInstance($className, $constructorParams);
+ }
+
+ public function getModel($module, $class, Array $constructorParams = array())
+ {
+ $className = $this->_resolveClassType($this->_globalConfig->getConfig('models'), $module, $class);
+
+ return $this->_newInstance($className, $constructorParams);
+ }
+
+ public function getResource($module, $class, Array $constructorParams = array())
+ {
+ $className = $this->_resolveClassType($this->_globalConfig->getConfig('resources'), $module, $class);
+
+ return $this->_newInstance($className, $constructorParams);
+ }
+
+ public function getHelper($module, $class, Array $constructorParams = array())
+ {
+ $className = $this->_resolveClassType($this->_globalConfig->getConfig('helpers'), $module, $class);
+
+ return $this->_newInstance($className, $constructorParams);
+ }
+
+ public function getBlockSingleton($module, $class, Array $constructorParams = array())
+ {
+ if (!isset($this->_blockSingletons[$module])) {
+ $this->_blockSingletons[$module] = array();
+ }
+ if (!isset($this->_blockSingletons[$module][$class])) {
+ $this->_blockSingletons[$module][$class] = $this->getBlock($module, $class, $constructorParams);
+ }
+ return $this->_blockSingletons[$module][$class];
+ }
+
+ public function getModelSingleton($module, $class, Array $constructorParams = array())
+ {
+ if (!isset($this->_modelSingletons[$module])) {
+ $this->_modelSingletons[$module] = array();
+ }
+ if (!isset($this->_modelSingletons[$module][$class])) {
+ $this->_modelSingletons[$module][$class] = $this->getModel($module, $class, $constructorParams);
+ }
+ return $this->_modelSingletons[$module][$class];
+ }
+
+ public function getResourceSingleton($module, $class, Array $constructorParams = array())
+ {
+ if (!isset($this->_resourceSingletons[$module])) {
+ $this->_resourceSingletons[$module] = array();
+ }
+ if (!isset($this->_resourceSingletons[$module][$class])) {
+ $this->_resourceSingletons[$module][$class] = $this->getResource($module, $class, $constructorParams);
+ }
+ return $this->_resourceSingletons[$module][$class];
+ }
+
+ public function getHelperSingleton($module, $class, Array $constructorParams = array())
+ {
+ if (!isset($this->_helperSingletons[$module])) {
+ $this->_helperSingletons[$module] = array();
+ }
+ if (!isset($this->_helperSingletons[$module][$class])) {
+ $this->_helperSingletons[$module][$class] = $this->getHelper($module, $class, $constructorParams);
+ }
+ return $this->_helperSingletons[$module][$class];
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Base/BaseObject.php b/src/application/modules/WootookCore/src/Wootook/Core/Base/BaseObject.php
new file mode 100644
index 0000000..db1e7c1
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Base/BaseObject.php
@@ -0,0 +1,68 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Base;
+
+/**
+ *
+ * Enter description here ...
+ * @author Greg
+ *
+ */
+class BaseObject
+ implements \ArrayAccess
+{
+ use Service\App, DataContainer;
+
+ protected function _construct(Array $data = array())
+ {
+ $this->addData($data);
+ }
+
+ public function offsetExists($offset)
+ {
+ return $this->hasData($offset);
+ }
+
+ public function offsetGet($offset)
+ {
+ return $this->getData($offset);
+ }
+
+ public function offsetSet($offset, $data)
+ {
+ return $this->setData($offset, $data);
+ }
+
+ public function offsetUnset($offset)
+ {
+ return $this->unsetData($offset);
+ }
+}
diff --git a/src/application/code/core/Wootook/Object.php b/src/application/modules/WootookCore/src/Wootook/Core/Base/DataContainer.php
similarity index 77%
rename from src/application/code/core/Wootook/Object.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Base/DataContainer.php
index d3271ee..1399ba1 100644
--- a/src/application/code/core/Wootook/Object.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Base/DataContainer.php
@@ -28,22 +28,12 @@
*
*/
-/**
- *
- * Enter description here ...
- * @author Greg
- *
- */
-class Wootook_Object
- implements ArrayAccess
+namespace Wootook\Core\Base;
+
+trait DataContainer
{
protected $_data = array();
- public function __construct(Array $data = array())
- {
- $this->_data = $data;
- }
-
public function getData($key)
{
if ($this->hasData($key)) {
@@ -93,24 +83,4 @@ class Wootook_Object
return $this;
}
-
- public function offsetExists($offset)
- {
- return $this->hasData($offset);
- }
-
- public function offsetGet($offset)
- {
- return $this->getData($offset);
- }
-
- public function offsetSet($offset, $data)
- {
- return $this->setData($offset, $data);
- }
-
- public function offsetUnset($offset)
- {
- return $this->unsetData($offset);
- }
}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Base/Service/App.php b/src/application/modules/WootookCore/src/Wootook/Core/Base/Service/App.php
new file mode 100644
index 0000000..d2c142e
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Base/Service/App.php
@@ -0,0 +1,67 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Base\Service;
+
+use Wootook\Core;
+
+/**
+ *
+ *
+ */
+trait App
+{
+ /**
+ * @var \Wootook\Core\App
+ */
+ protected $_app = null;
+
+ /**
+ * @param \Wootook\Core\App $app
+ * @param null $...
+ */
+ public function __construct(Core\App\App $app, $_ = null)
+ {
+ $this->_app = $app;
+
+ $params = func_get_args();
+ array_shift($params);
+
+ call_user_func_array(array($this, '_construct'), $params);
+ }
+
+ /**
+ * @return \Wootook\Core\App
+ */
+ public function app()
+ {
+ return $this->_app;
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Singleton.php b/src/application/modules/WootookCore/src/Wootook/Core/Base/Singleton.php
similarity index 96%
rename from src/application/code/core/Wootook/Core/Singleton.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Base/Singleton.php
index c136e82..c8a1cf2 100644
--- a/src/application/code/core/Wootook/Core/Singleton.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Base/Singleton.php
@@ -28,13 +28,15 @@
*
*/
+namespace Wootook\Core\Base;
+
/**
*
* Enter description here ...
* @author Greg
*
*/
-interface Wootook_Core_Singleton
+interface Singleton
{
public static function getSingleton();
-}
\ No newline at end of file
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Base/Util/FileSystem.php b/src/application/modules/WootookCore/src/Wootook/Core/Base/Util/FileSystem.php
new file mode 100644
index 0000000..3516202
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Base/Util/FileSystem.php
@@ -0,0 +1,68 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Base\Util;
+
+use Wootook\Core\Profiler;
+
+class FileSystem
+{
+ public function fileExists($fileName)
+ {
+ if ($fileName === null || empty($fileName)) {
+ return false;
+ }
+
+ if (($fp = @fopen($fileName, 'r', true)) === false) {
+ return false;
+ }
+ fclose($fp);
+
+ return true;
+ }
+
+ public function directoryExists($directoryName)
+ {
+ if ($directoryName === null || empty($directoryName)) {
+ return false;
+ }
+
+ return is_dir($directoryName);
+ }
+
+ public function includeFile($fileName)
+ {
+ if ($fileName === null || empty($fileName)) {
+ return null;
+ }
+
+ return include $fileName;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Concat.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Concat.php
new file mode 100644
index 0000000..9eaeae8
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Concat.php
@@ -0,0 +1,46 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block;
+
+use Wootook\Core\Mvc\View;
+
+class Concat
+ extends View\View
+{
+ public function render()
+ {
+ $content = '';
+ foreach ($this->_partials as $partial) {
+ $content .= $partial->render();
+ }
+ return $content;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Deprecated.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Deprecated.php
new file mode 100644
index 0000000..b3f9edb
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Deprecated.php
@@ -0,0 +1,40 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block;
+
+class Deprecated
+ extends Template
+{
+ public function getScriptPath()
+ {
+ return $this->getLayout()->getScriptPath();
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Form.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Form.php
new file mode 100644
index 0000000..d98e023
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Form.php
@@ -0,0 +1,41 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block;
+
+class Form
+ extends Template
+{
+ public function getFormKey()
+ {
+ $session = \Wootook::getSession('security');
+ return $session->getFormKey(true);
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Block/Html/Head.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Head.php
similarity index 86%
rename from src/application/code/core/Wootook/Core/Block/Html/Head.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Head.php
index c404045..9b6312c 100644
--- a/src/application/code/core/Wootook/Core/Block/Html/Head.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Head.php
@@ -1,7 +1,37 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Block_Html_Head
- extends Wootook_Core_Block_Template
+namespace Wootook\Core\Block;
+
+class Head
+ extends Template
{
const TYPE_GLOBAL_CSS = 'global_css';
const TYPE_GLOBAL_JS = 'global_js';
@@ -284,4 +314,4 @@ HTML_EOF;
}
return $render;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Home.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Home.php
new file mode 100644
index 0000000..6634cd7
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Home.php
@@ -0,0 +1,45 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block;
+
+class Home
+ extends Template
+{
+ public function getTitle()
+ {
+ return \Wootook::app()->getDefaultGame()->getConfig('game/home/title');
+ }
+
+ public function getFormattedWelcomeText()
+ {
+ return \Wootook::app()->getDefaultGame()->getConfig('game/home/formatted-welcome-text');
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Block/Html/Navigation/Link.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Link.php
similarity index 79%
rename from src/application/code/core/Wootook/Core/Block/Html/Navigation/Link.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Link.php
index 82a09fa..94c4771 100644
--- a/src/application/code/core/Wootook/Core/Block/Html/Navigation/Link.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Link.php
@@ -1,7 +1,39 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Block_Html_Navigation_Link
- extends Wootook_Core_Block_Template
+namespace Wootook\Core\Block\Html\Navigation;
+
+use Wootook\Core\Block;
+
+class Link
+ extends Block\Template
{
protected $_label = '';
protected $_title = '';
diff --git a/src/application/code/core/Wootook/Core/Block/Html/Navigation.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Menu.php
similarity index 73%
rename from src/application/code/core/Wootook/Core/Block/Html/Navigation.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Menu.php
index efbcd35..7d6ebbf 100644
--- a/src/application/code/core/Wootook/Core/Block/Html/Navigation.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Menu.php
@@ -1,7 +1,40 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Block_Html_Navigation
- extends Wootook_Core_Block_Template
+namespace Wootook\Core\Block\Html\Navigation;
+
+use Wootook\Core\Block,
+ Wootook\Core\Exception as CoreException;
+
+class Menu
+ extends Block\Template
{
public function addLink($name, $label, $title, $uri, Array $params = array(), Array $classes = array(), $template = null, Array $attributes = array())
{
@@ -115,8 +148,8 @@ class Wootook_Core_Block_Html_Navigation
$this->setPartial($name, $child);
}
- if ($child instanceof Wootook_Core_Block_Html_Navigation_Link) {
- throw new Wootook_Core_Exception_RuntimeException('Node is a link. Could not append a child node to a link node.');
+ if ($child instanceof Link) {
+ throw new CoreException\RuntimeException('Node is a link. Could not append a child node to a link node.');
}
if (count($explodedPath) == 0) {
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Node.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Node.php
new file mode 100644
index 0000000..e60a391
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Navigation/Node.php
@@ -0,0 +1,57 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block\Html\Navigation;
+
+class Node
+ extends Menu
+{
+ protected $_title = '';
+
+ public function setTitle($title)
+ {
+ $this->_title = $title;
+
+ return $this;
+ }
+
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+
+ public function getTemplate()
+ {
+ if ($this->_template !== null) {
+ return $this->_template;
+ }
+ return 'page/html/navigation/node.phtml';
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Page.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Page.php
new file mode 100644
index 0000000..0d4135b
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Html/Page.php
@@ -0,0 +1,51 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block\Html;
+
+use Wootook\Core\Block;
+
+class Page
+ extends Block\Template
+{
+ protected $_bodyClasses = array();
+
+ public function getBodyClasses()
+ {
+ return implode(' ', $this->_bodyClasses);
+ }
+
+ public function addBodyClass($class)
+ {
+ $this->_bodyClasses[] = $class;
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Messages.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Messages.php
new file mode 100644
index 0000000..e483a09
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Messages.php
@@ -0,0 +1,77 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block;
+
+class Messages
+ extends Template
+{
+ protected $_storages = array();
+
+ public function prepareMessages($namespace)
+ {
+ $this->_storages[] = $namespace;
+ }
+
+ public function renderGroupedHtml()
+ {
+ $messages = array();
+
+ foreach ($this->_storages as $namespace) {
+ $session = \Wootook::getSession($namespace);
+
+ $messageList = $session->getMessages();
+ if (!is_array($messageList)) {
+ continue;
+ }
+ foreach ($messageList as $messageLevel => $messageList) {
+ if (!isset($messages[$messageLevel])) {
+ $messages[$messageLevel] = $messageList;
+ } else {
+ $messages[$messageLevel] += $messageList;
+ }
+ }
+ }
+
+ rsort($messages, SORT_NUMERIC);
+
+ $output = '
';
+
+ return $output;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Template.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Template.php
new file mode 100644
index 0000000..6e4fe80
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Template.php
@@ -0,0 +1,81 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block;
+
+use Wootook\Core\Profiler,
+ Wootook\Core\Mvc\View,
+ Wootook\Core\Model,
+ Wootook\Core\Exception as CoreException;
+
+class Template
+ extends View\View
+{
+ protected function _getTemplatePath($file)
+ {
+ if ($this->getScriptPath() == '') {
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\RuntimeException("No script path defined in block {$this->getNameInLayout()}."));
+ return null;
+ }
+
+ $pattern = "{$this->getScriptPath()}/%s/%s/scripts/{$file}";
+ if (($layout = $this->getLayout()) !== null) {
+ $package = $this->getLayout()->getPackage();
+ $theme = $this->getLayout()->getTheme();
+
+ if ($package !== Model\Layout::DEFAULT_PACKAGE) {
+ if ($theme !== Model\Layout::DEFAULT_THEME) {
+ $path = sprintf($pattern, $package, $theme);
+ if (\Wootook::fileExists($path)) {
+ return $path;
+ }
+ }
+
+ $path = sprintf($pattern, $package, Model\Layout::DEFAULT_THEME);
+ if (\Wootook::fileExists($path)) {
+ return $path;
+ }
+ }
+ } else {
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\RuntimeException("No layout defined."));
+ }
+
+ $path = sprintf($pattern, Model\Layout::DEFAULT_PACKAGE, Model\Layout::DEFAULT_THEME);
+ if (\Wootook::fileExists($path)) {
+ return $path;
+ }
+
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\RuntimeException("Template '{$file}' could not be found."));
+ return null;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Block/Text.php b/src/application/modules/WootookCore/src/Wootook/Core/Block/Text.php
new file mode 100644
index 0000000..a28e04d
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Block/Text.php
@@ -0,0 +1,60 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Block;
+
+use Wootook\Core\Mvc\View;
+
+class Text
+ extends View\View
+{
+ protected $_content = null;
+
+ public function setContent($content)
+ {
+ $this->_content = $content;
+
+ return $this;
+ }
+
+ public function getContent()
+ {
+ return $this->_content;
+ }
+
+ public function render()
+ {
+ $content = $this->getContent();
+ if (empty($content)) {
+ return null;
+ }
+ return $content;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Bootstrap/Module.php b/src/application/modules/WootookCore/src/Wootook/Core/Bootstrap/Module.php
new file mode 100644
index 0000000..d1f460d
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Bootstrap/Module.php
@@ -0,0 +1,55 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Bootstrap;
+
+use Wootook\Core\Config,
+ Wootook\Core\Base\Service;
+
+class Module
+{
+ use Service\App;
+
+ protected function _construct(Config\Node $rootConfig)
+ {
+ return;
+
+ foreach ($rootConfig->getConfig('global/modules') as $moduleAlias => $moduleConfig) {
+ if ($moduleConfig->getConfig('active') !== true) {
+ continue;
+ }
+ if (($codePool = $moduleConfig->getConfig('code-pool')) === null) {
+ continue;
+ }
+
+
+ }
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Config/Adapter/Adapter.php b/src/application/modules/WootookCore/src/Wootook/Core/Config/Adapter/Adapter.php
new file mode 100644
index 0000000..e688136
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Config/Adapter/Adapter.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Config\Adapter;
+
+use Wootook\Core\Config;
+
+abstract class Adapter
+ extends Config\Node
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Config/Adapter/PhpArray.php b/src/application/modules/WootookCore/src/Wootook/Core/Config/Adapter/PhpArray.php
new file mode 100644
index 0000000..0282447
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Config/Adapter/PhpArray.php
@@ -0,0 +1,72 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Config\Adapter;
+
+use Wootook\Core\Base\Util,
+ Wootook\Core\Exception as CoreException;
+
+class PhpArray
+ extends Adapter
+{
+ protected $_ioHelper = null;
+
+ public function __construct($filename = null)
+ {
+ if ($filename !== null) {
+ $this->load($filename);
+ }
+
+ $this->_ioHelper = new Util\FileSystem();
+ }
+
+ public function load($filename)
+ {
+ if (!$this->_ioHelper->fileExists($filename)) {
+ throw new CoreException\DataAccessException(sprintf('Could not load config file "%s"', $filename));
+ }
+ $data = $this->_ioHelper->includeFile($filename);
+
+ if (!is_array($data)) {
+ throw new CoreException\DataAccessException('Configuration file could not be loaded.');
+ }
+
+ $this->_init($data);
+
+ return $this;
+ }
+
+ public function save($filename)
+ {
+ file_put_contents($filename, '<' . '?p' . 'hp return ' . var_export($this->toArray(), true) . ';');
+
+ return $this;
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Config/Node.php b/src/application/modules/WootookCore/src/Wootook/Core/Config/Node.php
similarity index 75%
rename from src/application/code/core/Wootook/Core/Config/Node.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Config/Node.php
index 309c1cf..007cea1 100644
--- a/src/application/code/core/Wootook/Core/Config/Node.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Config/Node.php
@@ -1,7 +1,39 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Config_Node
- implements ArrayAccess, Iterator, Countable
+namespace Wootook\Core\Config;
+
+use Wootook\Core\Exception as CoreException;
+
+class Node
+ implements \ArrayAccess, \Iterator, \Countable
{
protected $_children = array();
@@ -54,7 +86,7 @@ class Wootook_Core_Config_Node
for ($i = 0; $i < $length; $i++) {
if ($i < ($length - 1)) {
if (!$currentNode->offsetExists($explodedPath[$i])) {
- $newNode = new Wootook_Core_Config_Node(array(), $currentNode);
+ $newNode = new Node(array(), $currentNode);
$currentNode->offsetSet($explodedPath[$i], $newNode);
}
} else if (is_array($value)) {
@@ -67,8 +99,8 @@ class Wootook_Core_Config_Node
$currentNode = $currentNode->offsetGet($explodedPath[$i]);
- if (!$currentNode instanceof Wootook_Core_Config_Node) {
- throw new Wootook_Core_Exception_RuntimeException();
+ if (!$currentNode instanceof Node) {
+ throw new CoreException\RuntimeException();
}
}
@@ -82,8 +114,8 @@ class Wootook_Core_Config_Node
$length = count($explodedPath);
$currentNode = $this;
for ($i = 0; $i < $length; $i++) {
- if (!$currentNode instanceof Wootook_Core_Config_Node) {
- throw new Wootook_Core_Exception_RuntimeException();
+ if (!$currentNode instanceof Node) {
+ throw new CoreException\RuntimeException();
}
if (!$currentNode->offsetExists($explodedPath[$i])) {
return null;
@@ -101,7 +133,7 @@ class Wootook_Core_Config_Node
foreach ($this->_children as $key => $child) {
if ($child instanceof self) {
$result[$key] = $child->toArray();
- } else if ($child instanceof Wootook_Core_Config_Leaf) {
+ } else if ($child instanceof Leaf) {
$result[$key] = $child->getValue();
} else {
$result[$key] = $child;
@@ -215,31 +247,31 @@ class Wootook_Core_Config_Node
}
}
- public function valid()
- {
- return key($this->_children);
- }
-
- public function next()
- {
- next($this->_children);
- }
-
public function current()
{
return current($this->_children);
}
- public function rewind()
- {
- reset($this->_children);
- }
-
public function key()
{
return key($this->_children);
}
+ public function next()
+ {
+ return next($this->_children);
+ }
+
+ public function rewind()
+ {
+ return reset($this->_children);
+ }
+
+ public function valid()
+ {
+ return key($this->_children) !== null;
+ }
+
public function count()
{
return count($this->_children);
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Controller/ErrorController.php b/src/application/modules/WootookCore/src/Wootook/Core/Controller/ErrorController.php
new file mode 100644
index 0000000..17ecba0
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Controller/ErrorController.php
@@ -0,0 +1,43 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Controller;
+
+use Wootook\Core\Mvc\Controller as MvcController;
+
+class ErrorController
+ extends MvcController\Action
+{
+ public function noRouteAction()
+ {
+ $this->loadLayout('no-route');
+ $this->renderLayout();
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Controller/IndexController.php b/src/application/modules/WootookCore/src/Wootook/Core/Controller/IndexController.php
new file mode 100644
index 0000000..4a1993a
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Controller/IndexController.php
@@ -0,0 +1,43 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Controller;
+
+use Wootook\Core\Mvc\Controller as MvcController;
+
+class IndexController
+ extends MvcController\Action
+{
+ public function indexAction()
+ {
+ $this->loadLayout('home');
+ $this->renderLayout();
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Adapter.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Adapter.php
new file mode 100644
index 0000000..09ff943
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Adapter.php
@@ -0,0 +1,281 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Adapter;
+
+use Wootook\Core,
+ Wootook\Core\Database\Orm,
+ Wootook\Core\Database\Sql,
+ Wootook\Core\Database\Statement,
+ Wootook\Core\Event,
+ Wootook\Core\Exception as CoreException;
+
+abstract class Adapter
+{
+ use Event\EventTarget;
+
+ protected $_handler = null;
+
+ protected $_tablePrefix = null;
+
+ protected $_statementClass = null;
+
+ public function setStatementClass($statementClass)
+ {
+ $this->_statementClass = $statementClass;
+
+ return $this;
+ }
+
+ public function getStatementClass()
+ {
+ return $this->_statementClass;
+ }
+
+ public function getDriverHandler()
+ {
+ return $this->_handler;
+ }
+
+ public function getDataMapper()
+ {
+ return new Orm\DataMapper();
+ }
+
+ /**
+ *
+ * @param string $prefix
+ * @return Adapter
+ */
+ public function setTablePrefix($prefix)
+ {
+ $this->_tablePrefix = $prefix;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTablePrefix()
+ {
+ return $this->_tablePrefix;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTable($table)
+ {
+ return $this->getTablePrefix() . $table;
+ }
+
+ /**
+ * @return Sql\Select
+ */
+ public function select()
+ {
+ return new Sql\Select($this);
+ }
+
+ /**
+ * @return Sql\Insert
+ */
+ public function insert()
+ {
+ return new Sql\Insert($this);
+ }
+
+ /**
+ * @return Sql\Update
+ */
+ public function update()
+ {
+ return new Sql\Update($this);
+ }
+
+ /**
+ * @return Sql\Delete
+ */
+ public function delete()
+ {
+ return new Sql\Delete($this);
+ }
+
+ /**
+ * @param string $data
+ * @return string
+ */
+ abstract public function quote($data);
+
+ /**
+ * @param string $identifier
+ * @return string
+ */
+ abstract public function quoteIdentifier($identifier);
+
+ /**
+ * @param string $identifier
+ * @return string
+ */
+ public function quoteInto($string, $values)
+ {
+ $parts = preg_split('#(:[\w_]+|[?])#', $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+
+ $result = '';
+ if (is_array($values)) {
+ $index = 0;
+ foreach ($parts as $part) {
+ if ($part == '?') {
+ $result .= $this->quote($values[$index++]);
+ } else if (!empty($part) && $part[0] == ':') {
+ $key = substr($part, 1);
+
+ if (isset($values[$key])) {
+ $result .= $this->quote($values[$key]);
+ } else if (isset($values[$part])) {
+ $result .= $this->quote($values[$part]);
+ } else {
+ $result .= $part;
+ }
+ } else {
+ $result .= $part;
+ }
+ }
+ } else {
+ foreach ($parts as $part) {
+ if ($part == '?' || $part[0] == ':') {
+ $result .= $this->quote($values);
+ } else {
+ $result .= $part;
+ }
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * @param $sql
+ * @param array|null $params
+ * @param Closure|null $asynchronousCallback
+ * @return \Wootook\Core\Database\Statement\Statement
+ * @throws \Wootook\Core\Exception\Database\StatementError
+ */
+ public function query($sql, Array $params = null, Closure $asynchronousCallback = null)
+ {
+ $statement = $this->prepare($sql, $params);
+
+ if ($asynchronousCallback !== null) {
+ $statement->registerEventListener(Statement\Statement::EVENT_READY, $asynchronousCallback);
+ }
+ if (!$statement->execute(null, $asynchronousCallback !== null)) {
+ $message = sprintf('[SQLSTATE %s] Could not execute query: %s', $statement->errorState(), $statement->errorMessage());
+ throw new CoreException\Database\StatementError($statement, $message);
+ }
+
+ return $statement;
+ }
+
+ /**
+ * @param $sql
+ * @param array|null $params
+ * @param Closure|null $asynchronousCallback
+ * @return bool
+ */
+ public function execute($sql, Array $params = null, Closure $asynchronousCallback = null)
+ {
+ $statement = $this->prepare($sql, $params);
+
+ if ($asynchronousCallback !== null) {
+ $statement->registerEventListener(Statement\Statement::EVENT_READY, $asynchronousCallback);
+ }
+
+ return $statement->execute(null, $asynchronousCallback !== null);
+ }
+
+ /**
+ * @param $sql
+ * @param array|null $params
+ * @return \Wootook\Core\Database\Statement\Statement
+ */
+ public function prepare($sql, Array $params = null)
+ {
+ $statement = new $this->_statementClass($this, $sql);
+
+ if ($params !== null) {
+ foreach ($params as $paramKey => $paramValue) {
+ $statement->bindValue($paramKey, $paramValue, $statement->getParamType($paramValue));
+ }
+ }
+
+ return $statement;
+ }
+
+ /**
+ * @return bool
+ */
+ abstract public function beginTransaction();
+
+ /**
+ * @return bool
+ */
+ abstract public function commit();
+
+ /**
+ * @return bool
+ */
+ abstract public function rollback();
+
+ /**
+ * @return bool
+ */
+ abstract public function lastInsertId();
+
+ /**
+ * @return string
+ */
+ abstract public function errorCode();
+
+ /**
+ * @return string
+ */
+ abstract public function errorMessage();
+
+ /**
+ * @return array
+ */
+ abstract public function errorInfo();
+
+ /**
+ * @return string
+ */
+ abstract public function errorState();
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Mysql.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Mysql.php
new file mode 100644
index 0000000..9596466
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Mysql.php
@@ -0,0 +1,178 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Adapter;
+
+use Wootook\Core\Config,
+ Wootook\Core\Database,
+ Wootook\Core\Database\Statement,
+ Wootook\Core\Database\Sql,
+ Wootook\Core\Exception as CoreException;
+
+class Mysql
+ extends Adapter
+{
+ protected $_statementClass = 'Wootook\\Core\\Database\\Statement\\Mysql';
+
+ /**
+ *
+ * Enter description here ...
+ * @param Config\Node $config
+ * @param array $params
+ */
+ public function __construct(Config\Node $config, Array $options = array())
+ {
+ if (!isset($options[Database\ConnectionManager::ATTR_ERRMODE])) {
+ $options[Database\ConnectionManager::ATTR_ERRMODE] = Database\ConnectionManager::ERRMODE_EXCEPTION;
+ }
+
+ try {
+ $this->_handler = new \mysqli($config->hostname, $config->username, $config->password, $config->database, (int) $config->port, $options);
+ } catch (\mysqli_sql_exception $e) {
+ throw new CoreException\Database\AdapterError($this, $e->getMessage(), null, $e);
+ }
+
+ if ($this->_handler->connect_errno) {
+ throw new CoreException\Database\AdapterError($this, $this->_handler->connect_error, $this->_handler->connect_errno);
+ }
+ }
+
+ /**
+ * (non-PHPdoc)
+ * @see Adapter\Adapter::quoteIdentifier()
+ */
+ public function quoteIdentifier($identifier)
+ {
+ return "`$identifier`";
+ }
+
+ public function quote($data)
+ {
+ $result = $this->_handler->real_escape_string($data);
+
+ if ($this->_handler->errno) {
+ throw new CoreException\Database\AdapterError($this, $this->_handler->connect_error, $this->_handler->connect_errno);
+ }
+
+ return $result;
+ }
+
+ /**
+ * @return bool
+ */
+ public function beginTransaction()
+ {
+ $result = $this->_handler->autocommit(false);
+
+ if ($this->_handler->errno) {
+ throw new CoreException\Database\AdapterError($this, $this->_handler->connect_error, $this->_handler->connect_errno);
+ }
+
+ return $result;
+ }
+
+ /**
+ * @return bool
+ */
+ public function commit()
+ {
+ $result = $this->_handler->commit();
+ $this->_handler->autocommit(true);
+
+ if ($this->_handler->errno) {
+ throw new CoreException\Database\AdapterError($this, $this->_handler->connect_error, $this->_handler->connect_errno);
+ }
+
+ return $result;
+ }
+
+ /**
+ * @return bool
+ */
+ public function rollback()
+ {
+ $result = $this->_handler->rollback();
+ $this->_handler->autocommit(true);
+
+ if ($this->_handler->errno) {
+ throw new CoreException\Database\AdapterError($this, $this->_handler->connect_error, $this->_handler->connect_errno);
+ }
+
+ return $result;
+ }
+
+ /**
+ * @return int
+ */
+ public function lastInsertId()
+ {
+ return $this->_handler->insert_id;
+ }
+
+ /**
+ * @return string
+ */
+ public function errorCode()
+ {
+ return $this->_handler->errno;
+ }
+
+ /**
+ * @return array
+ */
+ public function errorInfo()
+ {
+ return array(
+ $this->_handler->sqlstate,
+ $this->_handler->errno,
+ $this->_handler->error,
+ );
+ }
+
+ /**
+ * @return string
+ */
+ public function errorMessage()
+ {
+ $info = $this->_handler->error;
+
+ return $info[2];
+ }
+
+ /**
+ * @return string
+ */
+ public function errorState()
+ {
+ $info = $this->_handler->sqlstate;
+
+ return $info[0];
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo.php
new file mode 100644
index 0000000..c9bc397
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo.php
@@ -0,0 +1,180 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Adapter;
+
+use Wootook\Core\Config,
+ Wootook\Core\Database,
+ Wootook\Core\Database\Statement,
+ Wootook\Core\Database\Sql,
+ Wootook\Core\Exception as CoreException;
+
+abstract class Pdo
+ extends Adapter
+{
+ /**
+ *
+ * Enter description here ...
+ * @param Config\Node $config
+ * @param array $params
+ */
+ public function __construct(Config\Node $config, Array $options = array())
+ {
+ if (!isset($options[Database\ConnectionManager::ATTR_ERRMODE])) {
+ $options[Database\ConnectionManager::ATTR_ERRMODE] = Database\ConnectionManager::ERRMODE_EXCEPTION;
+ }
+
+ try {
+ $this->_handler = new \PDO($this->_buildDsn($config), $config->username, $config->password, $options);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\AdapterError($this, $e->getMessage(), null, $e);
+ }
+ }
+
+ /**
+ * @abstract
+ * @param \Wootook\Core\Config\Node $config
+ * @return string
+ */
+ abstract protected function _buildDsn(Config\Node $config);
+
+ public function quote($data)
+ {
+ try {
+ return $this->_handler->quote($data);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\AdapterError($this, $e->getMessage(), null, $e);
+ }
+ }
+
+ /**
+ * @return Statement\Statement
+ */
+ public function prepare($sql, Array $params = null)
+ {
+ $statement = new $this->_statementClass($this, $sql);
+
+ if ($params !== null) {
+ foreach ($params as $paramKey => $paramValue) {
+ $statement->bindValue($paramKey, $paramValue, $statement->getParamType($paramValue));
+ }
+ }
+
+ return $statement;
+ }
+
+ /**
+ * @return bool
+ */
+ public function beginTransaction()
+ {
+ try {
+ return $this->_handler->beginTransaction();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\AdapterError($this, $e->getMessage(), null, $e);
+ }
+ return false;
+ }
+
+ /**
+ * @return bool
+ */
+ public function commit()
+ {
+ try {
+ return $this->_handler->commit();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\AdapterError($this, $e->getMessage(), null, $e);
+ }
+ return false;
+ }
+
+ /**
+ * @return bool
+ */
+ public function rollback()
+ {
+ try {
+ return $this->_handler->rollback();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\AdapterError($this, $e->getMessage(), null, $e);
+ }
+ return false;
+ }
+
+ /**
+ * @return int
+ */
+ public function lastInsertId()
+ {
+ try {
+ return $this->_handler->lastInsertId();
+ } catch (\PDOException $e) {
+ throw new CoreException\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];
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo/Mysql.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo/Mysql.php
new file mode 100644
index 0000000..3cc0e0f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo/Mysql.php
@@ -0,0 +1,63 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Adapter\Pdo;
+
+use Wootook\Core\Config,
+ Wootook\Core\Database,
+ Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Statement,
+ Wootook\Core\Database\Sql,
+ Wootook\Core\Exception as CoreException;
+
+class Mysql
+ extends Adapter\Pdo
+{
+ protected $_statementClass = 'Wootook\\Core\\Database\\Statement\\Pdo\\Mysql';
+
+ protected function _buildDsn(Config\Node $config)
+ {
+ $dsn = "mysql:host={$config->hostname};dbname={$config->database}";
+ if (is_numeric($config->port)) {
+ $dsn .= ";port={$config->database}";
+ }
+
+ return $dsn;
+ }
+
+ /**
+ * (non-PHPdoc)
+ * @see Adapter\Adapter::quoteIdentifier()
+ */
+ public function quoteIdentifier($identifier)
+ {
+ return "`$identifier`";
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo/Sqlite.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo/Sqlite.php
new file mode 100644
index 0000000..8a24958
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Adapter/Pdo/Sqlite.php
@@ -0,0 +1,60 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Adapter\Pdo;
+
+use Wootook\Core\Config,
+ Wootook\Core\Database,
+ Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Statement,
+ Wootook\Core\Database\Sql,
+ Wootook\Core\Exception as CoreException;
+
+class Sqlite
+ extends Adapter\Pdo
+{
+ protected $_statementClass = 'Wootook\\Core\\Database\\Statement\\Pdo\\Sqlite';
+
+ protected function _buildDsn(Config\Node $config)
+ {
+ $dsn = "sqlite:{$config->database}";
+
+ return $dsn;
+ }
+
+ /**
+ * (non-PHPdoc)
+ * @see Adapter\Adapter::quoteIdentifier()
+ */
+ public function quoteIdentifier($identifier)
+ {
+ return "\"$identifier\"";
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Database/ConnectionManager.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/ConnectionManager.php
similarity index 65%
rename from src/application/code/core/Wootook/Core/Database/ConnectionManager.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Database/ConnectionManager.php
index 4ba8289..f7af92e 100644
--- a/src/application/code/core/Wootook/Core/Database/ConnectionManager.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/ConnectionManager.php
@@ -1,9 +1,48 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Database_ConnectionManager
- extends Wootook_Core_PluginLoader_PluginLoader
- implements Wootook_Core_Singleton
+namespace Wootook\Core\Database;
+
+use Wootook\Core,
+ Wootook\Core\Base\Service,
+ Wootook\Core\Config,
+ Wootook\Core\Exception as CoreException,
+ Wootook\Core\PluginLoader,
+ Wootook\Core\Profiler;
+
+class ConnectionManager
+ extends PluginLoader\PluginLoader
+ implements Core\Base\Singleton
{
+ use Service\App;
+
const PROFILER = 'profiler';
const CASE_FOLDING = 'case-folding';
const AUTO_QUOTE_IDENTIFIERS = 'auto-quote-identifiers';
@@ -99,20 +138,20 @@ class Wootook_Core_Database_ConnectionManager
protected static $_singleton = null;
- public function __construct()
+ protected function _construct()
{
- $this->registerNamespace('Wootook_Core_Database_Adapter_');
+ $this->registerNamespace('Wootook\\Core\\Database\\Adapter');
}
/**
- * @return Wootook_Core_Database_ConnectionManager
+ * @return ConnectionManager
*/
public static function getSingleton()
{
- if (self::$_singleton === null) {
- self::$_singleton = new self();
- }
- return self::$_singleton;
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
+
+ return \Wootook::app()->getConnectionManager();
}
protected $_defaultOptions = array(
@@ -121,7 +160,7 @@ class Wootook_Core_Database_ConnectionManager
/**
* @param $connectionName
- * @return Wootook_Core_Database_Adapter_Adapter
+ * @return Adapter\Adapter
*/
public function getConnection($connectionName)
{
@@ -134,7 +173,7 @@ class Wootook_Core_Database_ConnectionManager
return $this->_connectionAliases[$connectionName];
}
- $connectionConfig = Wootook::getConfig("resource/database/{$connectionName}");
+ $connectionConfig = \Wootook::app()->getGlobalConfig("resource/database/{$connectionName}");
if ($connectionConfig === null) {
return null;
}
@@ -154,12 +193,12 @@ class Wootook_Core_Database_ConnectionManager
private 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());
+ $params = new Config\Node($params);
+ } else if (!$params instanceof Config\Node) {
+ $params = new Config\Node(array());
}
- if ($options instanceof Wootook_Core_Config_Node) {
+ if ($options instanceof Config\Node) {
$options = $options->toArray();
} else if (!is_array($options)) {
$options = array();
@@ -169,24 +208,28 @@ class Wootook_Core_Database_ConnectionManager
return null;
}
- $event = Wootook::dispatchEvent('database.prepare-options', array(
+ $event = \Wootook::dispatchEvent('database.prepare-options', array(
'name' => $connectionName,
'options' => array_merge($this->_defaultOptions, $options)
));
$options = $event->getData('options');
- $connection = $this->load($engine, false, array($params, $options));
-
+ try {
+ $connection = $this->load($engine, false, array($params, $options));
+ } catch (CoreException\Database\AdapterError $e) {
+ Profiler\ErrorProfiler::getSingleton()->addException($e);
+ return null;
+ }
if (!$connection) {
- throw new Wootook_Core_Exception_Database_AdapterError('Could not find data connection handler.');
+ throw new CoreException\DataAccessException('Could not find data connection handler.');
}
- if (($prefix = Wootook::getConfig("resource/database/{$connectionName}/table_prefix")) !== null) {
+ if (($prefix = \Wootook::app()->getGlobalConfig("resource/database/{$connectionName}/table_prefix")) !== null) {
$connection->setTablePrefix($prefix);
}
- Wootook::dispatchEvent('database.init', array(
+ \Wootook::dispatchEvent('database.init', array(
'name' => $connectionName,
'handler' => $connection
));
@@ -196,7 +239,7 @@ class Wootook_Core_Database_ConnectionManager
protected function _load($className, $useSingleton, Array $constructorParams = array())
{
- $reflection = new ReflectionClass($className);
+ $reflection = new \ReflectionClass($className);
return $reflection->newInstanceArgs($constructorParams);
}
}
diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper.php
similarity index 56%
rename from src/application/code/core/Wootook/Core/Database/Orm/DataMapper.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper.php
index d4dc61f..437426c 100644
--- a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper.php
@@ -1,7 +1,43 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Database_Orm_DataMapper
- extends Wootook_Core_PluginLoader_PluginLoader
+namespace Wootook\Core\Database\Orm;
+
+use Wootook\Core\Config,
+ Wootook\Core\Database,
+ Wootook\Core\Mvc\Model,
+ Wootook\Core\PluginLoader,
+ Wootook\Core\Profiler;
+
+class DataMapper
+ extends PluginLoader\PluginLoader
{
protected $_rules = array();
@@ -9,9 +45,9 @@ class Wootook_Core_Database_Orm_DataMapper
public function __construct($config = array())
{
- $this->registerNamespace('Wootook_Core_Database_Orm_DataMapper_');
+ $this->registerNamespace('Wootook\\Core\\Database\\Orm\\DataMapper');
- if (!is_array($config) || !$config instanceof Wootook_Core_Config_Node) {
+ if (!is_array($config) || !$config instanceof Config\Node) {
return;
}
@@ -53,16 +89,16 @@ class Wootook_Core_Database_Orm_DataMapper
protected function _load($className, $useSingleton, Array $constructorParams = array())
{
- $reflection = new ReflectionClass($className);
- if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) {
+ $reflection = new \ReflectionClass($className);
+ if ($useSingleton && $reflection->implementsInterface('Wootook\\Core\\Base\\Singleton')) {
$method = $reflection->getMethod('getSingleton');
return $method->invoke(null);
}
try {
return $reflection->newInstance($this);
- } catch (ReflectionException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()
+ } catch (\ReflectionException $e) {
+ Profiler\ErrorProfiler::getSingleton()
->addException($e);
return null;
}
@@ -70,11 +106,11 @@ class Wootook_Core_Database_Orm_DataMapper
/**
*
- * @param Wootook_Core_Database_Resource $entity
+ * @param Database\Resource $entity
* @param Array $datas
* @return Array
*/
- public function encode(Wootook_Core_Database_Resource $entity, Array $datas = array())
+ public function encode(Model\Entity $entity, Array $datas = array())
{
$aliasTable = array_flip($this->_alias);
foreach ($entity->getAllDatas() as $aliasedField => $decodedValue) {
@@ -96,11 +132,11 @@ class Wootook_Core_Database_Orm_DataMapper
/**
*
- * @param Wootook_Core_Database_Resource $entity
+ * @param Database\Resource $entity
* @param Array $datas
- * @return Wootook_Core_Database_Resource
+ * @return Database\Resource
*/
- public function decode(Wootook_Core_Database_Resource $entity, Array $datas = array())
+ public function decode(Model\Entity $entity, Array $datas = array())
{
foreach ($datas as $field => $encodedValue) {
if (isset($this->_rules[$field])) {
@@ -112,4 +148,4 @@ class Wootook_Core_Database_Orm_DataMapper
return $entity;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/Config.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/Config.php
new file mode 100644
index 0000000..dbb88ff
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/Config.php
@@ -0,0 +1,47 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Orm\DataMapper;
+
+use Wootook\Core\Config as CoreConfig;
+
+class Config
+ extends FieldMapper
+{
+ public function encode($value)
+ {
+ return parent::encode($value->toArray());
+ }
+
+ public function decode($value)
+ {
+ return new CoreConfig\Node(parent::decode($value));
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/DateTime.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/DateTime.php
new file mode 100644
index 0000000..b8e624f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/DateTime.php
@@ -0,0 +1,70 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Orm\DataMapper;
+
+use Wootook\Core;
+
+class DateTime
+ extends FieldMapper
+{
+ const DATE_FORMAT_MYSQL = 'Y-m-d G:i:s';
+
+ protected $_format = self::DATE_FORMAT_MYSQL;
+
+ public function setFormat($format = null)
+ {
+ if ($format === null) {
+ $this->_format = self::DATE_FORMAT_MYSQL;
+ } else {
+ $this->_format = $format;
+ }
+ return $this;
+ }
+
+ public function getFormat()
+ {
+ return $this->_format;
+ }
+
+ public function encode($value)
+ {
+ if (!$value instanceof Core\DateTime) {
+ $value = new Core\DateTime($value);
+ }
+
+ return $value->toString($this->getFormat());
+ }
+
+ public function decode($value)
+ {
+ return new Core\DateTime($value, $this->getFormat());
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php
new file mode 100644
index 0000000..7399fed
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php
@@ -0,0 +1,47 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Orm\DataMapper;
+
+use Wootook\Core\Database\Orm;
+
+abstract class FieldMapper
+{
+ protected $_mapper = null;
+
+ public function __construct(Orm\DataMapper $mapper = null)
+ {
+ $this->_mapper = $mapper;
+ }
+
+ abstract public function encode($value);
+
+ abstract public function decode($value);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/PhpArray.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/PhpArray.php
new file mode 100644
index 0000000..aa25a02
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/PhpArray.php
@@ -0,0 +1,45 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Orm\DataMapper;
+
+class PhpArray
+ extends FieldMapper
+{
+ public function encode($value)
+ {
+ return serialize($value);
+ }
+
+ public function decode($value)
+ {
+ return unserialize($value);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/PhpObject.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/PhpObject.php
new file mode 100644
index 0000000..8e52740
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Orm/DataMapper/PhpObject.php
@@ -0,0 +1,73 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Orm\DataMapper;
+
+class PhpObject
+ extends FieldMapper
+{
+ protected $_entityClass = null;
+
+ protected $_reflectionClass = null;
+
+ public function setEntityClass($class)
+ {
+ $this->_entityClass = $class;
+
+ return $this;
+ }
+
+ public function getEntityClass()
+ {
+ return $this->_entityClass;
+ }
+
+ protected function _newInstance(Array $args = array())
+ {
+ if ($this->_reflectionClass === null && $this->_entityClass !== null) {
+ $this->_reflectionClass = new ReflectionClass($this->_entityClass);
+ }
+
+ return $this->newInstanceArgs($args);
+ }
+
+ public function encode($value)
+ {
+ return parent::encode($value->getAllDatas());
+ }
+
+ public function decode($value)
+ {
+ $object = $this->_newInstance();
+ $object->addData(parent::decode($value));
+
+ return $object;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/DataMapper.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/DataMapper.php
new file mode 100644
index 0000000..db0e086
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/DataMapper.php
@@ -0,0 +1,61 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Resource;
+
+use Wootook\Core\Database\Orm;
+
+trait DataMapper
+{
+ protected $_dataMapper = null;
+
+ /**
+ *
+ * @return Orm\DataMapper
+ */
+ public function getDataMapper()
+ {
+ if ($this->_dataMapper === null) {
+ $this->_dataMapper = new Orm\DataMapper();
+ }
+ return $this->_dataMapper;
+ }
+
+ /**
+ *
+ * @param Orm\DataMapper $dataMapper
+ */
+ public function setDataMapper(Orm\DataMapper $dataMapper)
+ {
+ $this->_dataMapper = $dataMapper;
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/ReadConnection.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/ReadConnection.php
new file mode 100644
index 0000000..4dfea06
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/ReadConnection.php
@@ -0,0 +1,72 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Resource;
+
+use Wootook\Core,
+ Wootook\Core\Database,
+ Wootook\Core\Database\Adapter as DatabaseAdapter,
+ Wootook\Core\Exception as CoreException;
+
+/**
+ *
+ */
+trait ReadConnection
+{
+ protected $_readConnection = null;
+
+ /**
+ * @return DatabaseAdapter\Adapter
+ */
+ public function getReadConnection()
+ {
+ if ($this->_readConnection === null) {
+ $this->_readConnection = $this->app()->getConnectionManager()
+ ->getConnection('core_read');
+ }
+
+ return $this->_readConnection;
+ }
+
+ public function setReadConnection($connection)
+ {
+ if ($connection instanceof DatabaseAdapter\Adapter) {
+ $this->_readConnection = $connection;
+ } else if (is_string($connection)) {
+ $this->_readConnection = $this->app()->getConnectionManager()
+ ->getConnection($connection);
+ } else {
+ throw new CoreException\RuntimeException(
+ 'First parameter should be either a database connection object or a string identifier.');
+ }
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/WriteConnection.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/WriteConnection.php
new file mode 100644
index 0000000..61b0dc5
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Resource/WriteConnection.php
@@ -0,0 +1,70 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Resource;
+
+use Wootook\Core,
+ Wootook\Core\Database\Adapter as DatabaseAdapter,
+ Wootook\Core\Exception as CoreException;
+
+/**
+ *
+ */
+trait WriteConnection
+{
+ protected $_writeConnection = null;
+
+ /**
+ * @return DatabaseAdapter\Adapter
+ */
+ public function getWriteConnection()
+ {
+ if ($this->_writeConnection === null) {
+ $this->_writeConnection = $this->app()->getConnectionManager()
+ ->getConnection('core_write');
+ }
+ return $this->_writeConnection;
+ }
+
+ public function setWriteConnection($connection)
+ {
+ if ($connection instanceof DatabaseAdapter\Adapter) {
+ $this->_readConnection = $connection;
+ } else if (is_string($connection)) {
+ $this->_readConnection = $this->app()->getConnectionManager()
+ ->getConnection($connection);
+ } else {
+ throw new CoreException\RuntimeException(
+ 'First parameter should be either a database connection object or a string identifier.');
+ }
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/Condition.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/Condition.php
new file mode 100644
index 0000000..cc807d3
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/Condition.php
@@ -0,0 +1,123 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Condition;
+
+use Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Sql\Placeholder,
+ Wootook\Core\Database\Sql\Dml,
+ Wootook\Core\Database\Statement;
+
+abstract class Condition
+{
+ protected $_query = null;
+ protected $_placeholders = array();
+
+ abstract public function render();
+
+ public function __toString()
+ {
+ return (string) $this->render();
+ }
+
+ abstract public function reset();
+
+ public function setQuery(Dml\Dml $query)
+ {
+ $this->_query = $query;
+
+ return $this;
+ }
+
+ public function getQuery()
+ {
+ return $this->_query;
+ }
+
+ public function addPlaceholder(Placeholder\Placeholder $placeholder)
+ {
+ $this->_placeholders[] = $placeholder;
+
+ return $this;
+ }
+
+ public function clearPlaceholders()
+ {
+ $this->_placeholders = array();
+
+ return $this;
+ }
+
+ public function getAllPlaceholders()
+ {
+ return $this->_placeholders;
+ }
+
+ public function beforePrepare(Statement\Statement $statement)
+ {
+ foreach ($this->getAllPlaceholders() as $placeholder) {
+ /** @var \Wootook\Core\Database\Sql\Placeholder\Placeholder $placeholder */
+ $placeholder->beforePrepare($statement);
+ }
+
+ return $this;
+ }
+
+ public function afterPrepare(Statement\Statement $statement)
+ {
+ foreach ($this->getAllPlaceholders() as $placeholder) {
+ /** @var \Wootook\Core\Database\Sql\Placeholder\Placeholder $placeholder */
+ $placeholder->afterPrepare($statement);
+ }
+
+ return $this;
+ }
+
+ public function beforeExecute(Statement\Statement $statement)
+ {
+ foreach ($this->getAllPlaceholders() as $placeholder) {
+ /** @var \Wootook\Core\Database\Sql\Placeholder\Placeholder $placeholder */
+ $placeholder->beforeExecute($statement);
+ }
+
+ return $this;
+ }
+
+ public function afterExecute(Statement\Statement $statement)
+ {
+ foreach ($this->getAllPlaceholders() as $placeholder) {
+ /** @var \Wootook\Core\Database\Sql\Placeholder\Placeholder $placeholder */
+ $placeholder->afterExecute($statement);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/InListOperator.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/InListOperator.php
new file mode 100644
index 0000000..fb289e5
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/InListOperator.php
@@ -0,0 +1,127 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Condition;
+
+use Wootook\Core\Database\Sql\Dml,
+ Wootook\Core\Database\Sql\Placeholder;
+
+
+class InListOperator
+ extends Condition
+{
+ protected $_operator = null;
+ protected $_field = null;
+ protected $_values = array();
+
+ public function __construct(Dml\Dml $query, $operator)
+ {
+ $this->_query = $query;
+ $this->_operator = $operator;
+ }
+
+ protected function _render($rawOperator)
+ {
+ $output = array();
+ foreach ($this->_values as $value) {
+ if ($this->_value instanceof Placeholder\Placeholder) {
+ $output[] = $value;
+ }
+
+ $output[] = $this->getQuery()->quote($value);
+ }
+
+ return $rawOperator . '(' . implode(', ', $output) . ')';
+ }
+
+ public function render()
+ {
+ switch ($this->_operator) {
+ case Dml\Section\WhereAware::OPERATOR_IN:
+ return $this->_render('=');
+
+ case Dml\Section\WhereAware::OPERATOR_NOT_IN:
+ return $this->_render('!=');
+ }
+
+ return '';
+ }
+
+ public function reset()
+ {
+ $this->_operator = null;
+ $this->_field = null;
+ $this->_values = array();
+
+ $this->_clearPlaceholders();
+
+ return $this;
+ }
+
+ public function setOperator($operator)
+ {
+ $this->_operator = $operator;
+
+ return $this;
+ }
+
+ public function getOperator()
+ {
+ return $this->_operator;
+ }
+
+ public function setField($field)
+ {
+ $this->_field = $field;
+
+ return $this;
+ }
+
+ public function getField()
+ {
+ return $this->_field;
+ }
+
+ public function addValue($value)
+ {
+ if ($value instanceof Placeholder\Placeholder) {
+ $this->_addPlaceholder($value);
+ }
+
+ $this->_values[] = $value;
+
+ return $this;
+ }
+
+ public function getAllValues()
+ {
+ return $this->_values;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/LogicalOperator.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/LogicalOperator.php
new file mode 100644
index 0000000..c7f8c15
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/LogicalOperator.php
@@ -0,0 +1,264 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Condition;
+
+use Wootook\Core\Database\Sql\Dml,
+ Wootook\Core\Exception as CoreException;
+
+class LogicalOperator
+ extends Condition
+ implements \ArrayAccess, \Countable, \Iterator
+{
+ /**
+ * @var string|int
+ */
+ protected $_operator = null;
+
+ /**
+ * @var array
+ */
+ protected $_conditions = array();
+
+ /**
+ * @var array
+ */
+ protected $_allowedOperators = array();
+
+ public function __construct(Dml\Dml $query, $operator = null, Array $allowedOperators = array())
+ {
+ $this->_query = $query;
+ $this->_operator = $operator;
+
+ $this->_allowedOperators = array(
+ Dml\Section\WhereAware::OPERATOR_NOT => function(LogicalOperator $conditions) {
+ return '(NOT (' . $conditions[0] . ')';
+ },
+ Dml\Section\WhereAware::OPERATOR_AND => function(LogicalOperator $conditions) {
+ return '(' . implode(') AND (', $conditions->getAllConditions()) . ')';
+ },
+ Dml\Section\WhereAware::OPERATOR_NAND => function(LogicalOperator $conditions) {
+ return '(NOT (' . implode(') AND (', $conditions->getAllConditions()) . '))';
+ },
+ Dml\Section\WhereAware::OPERATOR_OR => function(LogicalOperator $conditions) {
+ return '(' . implode(') OR (', $conditions->getAllConditions()) . ')';
+ },
+ Dml\Section\WhereAware::OPERATOR_NOR => function(LogicalOperator $conditions) {
+ return '(NOT (' . implode(') OR (', $conditions->getAllConditions()) . '))';
+ },
+ Dml\Section\WhereAware::OPERATOR_XOR => function(LogicalOperator $conditions) {
+ return '(' . implode(') XOR (', $conditions->getAllConditions()) . ')';
+ },
+ Dml\Section\WhereAware::OPERATOR_NXOR => function(LogicalOperator $conditions) {
+ return '(NOT (' . implode(') XOR (', $conditions->getAllConditions()) . '))';
+ },
+ );
+
+ foreach ($allowedOperators as $operatorKey => $operator) {
+ if (!$operator instanceof \Closure) {
+ continue;
+ }
+ /** @var \Closure $operator */
+ $this->addAllowedOperator($operatorKey, $operator);
+ }
+ }
+
+ /**
+ * @return LogicalOperator
+ */
+ public function reset()
+ {
+ $this->_operator = null;
+ $this->_conditions = array();
+
+ $this->_clearPlaceholders();
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function render()
+ {
+ if (isset($this->_allowedOperators[$this->_operator])) {
+ return $this->_allowedOperators[$this->_operator]($this);
+ }
+
+ return '';
+ }
+
+ /**
+ * @param string|int $operator
+ * @return LogicalOperator
+ */
+ public function setOperator($operator)
+ {
+ if (!isset($this->_allowedOperators[$operator])) {
+ throw new CoreException\InvalidArgumentException('Inexistent operator');
+ }
+ $this->_operator = $operator;
+
+ return $this;
+ }
+
+ /**
+ * @return string|int
+ */
+ public function getOperator()
+ {
+ return $this->_operator;
+ }
+
+ /**
+ * @param string|int $operator
+ * @param Closure $renderer
+ * @return LogicalOperator
+ */
+ public function addAllowedOperator($operator, \Closure $renderer)
+ {
+ $this->_allowedOperators[$operator] = $renderer;
+
+ return $this;
+ }
+
+ /**
+ * @param string|int $operator
+ * @return LogicalOperator
+ */
+ public function removeAllowedOperator($operator)
+ {
+ $key = array_search($operator, $this->_allowedOperators);
+ if ($key !== null) {
+ unset($this->_allowedOperators[$key]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string|int $operator
+ * @param Closure $renderer
+ * @return \Closure
+ */
+ public function getAllowedOperatorRenderer($operator)
+ {
+ if (!isset($this->_allowedOperators[$operator])) {
+ throw new CoreException\InvalidArgumentException('Inexistent operator');
+ }
+ return $this->_allowedOperators[$operator];
+ }
+
+ /**
+ * @return array
+ */
+ public function getAllAllowedOperators()
+ {
+ return $this->_allowedOperators;
+ }
+
+ /**
+ * @param Condition $condition
+ * @return LogicalOperator
+ */
+ public function addCondition(Condition $condition)
+ {
+ $this->_conditions[] = $condition;
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getAllConditions()
+ {
+ return $this->_conditions;
+ }
+
+ public function count()
+ {
+ return count($this->_conditions);
+ }
+
+ public function current()
+ {
+ return current($this->_conditions);
+ }
+
+ public function key()
+ {
+ return key($this->_conditions);
+ }
+
+ public function valid()
+ {
+ return key($this->_conditions) !== false;
+ }
+
+ public function next()
+ {
+ next($this->_conditions);
+ }
+
+ public function rewind()
+ {
+ reset($this->_conditions);
+ }
+
+ public function offsetExists($offset)
+ {
+ return isset($this->_conditions[$offset]);
+ }
+
+ public function offsetSet($offset, $value)
+ {
+ if (!is_int($offset)) {
+ throw new CoreException\InvalidArgumentException('Offset should be an integer');
+ }
+ $this->_conditions[$offset] = $value;
+ }
+
+ public function offsetGet($offset)
+ {
+ if (!is_int($offset)) {
+ throw new CoreException\InvalidArgumentException('Offset should be an integer');
+ }
+ return $this->_conditions[$offset];
+ }
+
+ public function offsetUnset($offset)
+ {
+ if (!is_int($offset)) {
+ throw new CoreException\InvalidArgumentException('Offset should be an integer');
+ }
+ unset($this->_conditions[$offset]);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/MathOperator.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/MathOperator.php
new file mode 100644
index 0000000..95fe6a6
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/MathOperator.php
@@ -0,0 +1,136 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Condition;
+
+use Wootook\Core\Database\Sql\Dml,
+ Wootook\Core\Database\Sql\Placeholder;
+
+
+class MathOperator
+ extends Condition
+{
+ protected $_operator = null;
+ protected $_field = null;
+ protected $_value = null;
+
+ public function __construct(Dml\Dml $query, $field, $operator, $value)
+ {
+ $this->_query = $query;
+ $this->_field = $field;
+ $this->_operator = $operator;
+ $this->_value = $value;
+ }
+
+ protected function _render($rawOperator)
+ {
+ if ($this->_value instanceof Placeholder\Placeholder) {
+ return "{$this->getQuery()->quoteIdentifier($this->_field)}{$rawOperator}{$this->_value}";
+ }
+
+ return "{$this->getQuery()->quoteIdentifier($this->_field)}{$rawOperator}{$this->getQuery()->quote($this->_value)}";
+ }
+
+ public function render()
+ {
+ switch ($this->_operator) {
+ case Dml\Section\WhereAware::OPERATOR_EQUALS:
+ return $this->_render('=');
+
+ case Dml\Section\WhereAware::OPERATOR_NOT_EQUALS:
+ return $this->_render('!=');
+
+ case Dml\Section\WhereAware::OPERATOR_LOWER:
+ return $this->_render('<');
+
+ case Dml\Section\WhereAware::OPERATOR_GREATER:
+ return $this->_render('>');
+
+ case Dml\Section\WhereAware::OPERATOR_LOWER_EQUALS:
+ return $this->_render('<=');
+
+ case Dml\Section\WhereAware::OPERATOR_GREATER_EQUALS:
+ return $this->_render('>=');
+ }
+
+ return '';
+ }
+
+ public function reset()
+ {
+ $this->_operator = null;
+ $this->_field = null;
+ $this->_value = null;
+
+ $this->_clearPlaceholders();
+
+ return $this;
+ }
+
+ public function setOperator($operator)
+ {
+ $this->_operator = $operator;
+
+ return $this;
+ }
+
+ public function getOperator()
+ {
+ return $this->_operator;
+ }
+
+ public function setField($field)
+ {
+ $this->_field = $field;
+
+ return $this;
+ }
+
+ public function getField()
+ {
+ return $this->_field;
+ }
+
+ public function setValue($value)
+ {
+ if ($value instanceof Placeholder\Placeholder) {
+ $this->_addPlaceholder($value);
+ }
+
+ $this->_value = $value;
+
+ return $this;
+ }
+
+ public function getValue()
+ {
+ return $this->_value;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/Placeholder.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/Placeholder.php
new file mode 100644
index 0000000..58d3ea7
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Condition/Placeholder.php
@@ -0,0 +1,72 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Condition;
+
+use Wootook\Core\Database\Sql\Placeholder as SqlPlaceholder;
+
+class Placeholder
+ extends Condition
+{
+ protected $_placeholder = null;
+
+ public function __construct(SqlPlaceholder\Placeholder $placeholder)
+ {
+ $this->_placeholder = $placeholder;
+
+ $this->_addPlaceholder($placeholder);
+ }
+
+ public function render()
+ {
+ return $this->_placeholder->toString();
+ }
+
+ public function reset()
+ {
+ $this->_placeholder = null;
+
+ $this->_clearPlaceholders();
+
+ return $this;
+ }
+
+ public function setPlaceholder($placeholder)
+ {
+ $this->_placeholder = $placeholder;
+
+ return $this;
+ }
+
+ public function getPlaceholder()
+ {
+ return $this->_placeholder;
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Delete.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Delete.php
similarity index 62%
rename from src/application/code/core/Wootook/Core/Database/Sql/Delete.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Delete.php
index 84d8e37..5302b13 100644
--- a/src/application/code/core/Wootook/Core/Database/Sql/Delete.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Delete.php
@@ -1,7 +1,37 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Database_Sql_Delete
- extends Wootook_Core_Database_Sql_DmlFilterableQuery
+namespace Wootook\Core\Database\Sql\Dml;
+
+class Delete
+ extends DmlQuery
{
const FROM = 'FROM';
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Dml.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Dml.php
new file mode 100644
index 0000000..3e2f22c
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Dml.php
@@ -0,0 +1,63 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml;
+
+use Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Sql\Placeholder,
+ Wootook\Core\Database\Statement;
+
+interface Dml
+{
+ function __construct(Adapter\Adapter $connection, $param = null);
+
+ function render();
+ function toString($part = null);
+
+ function reset($part = null);
+
+ function quote($data);
+ function quoteIdentifier($identifier);
+
+ function setConnection(Adapter\Adapter $connection);
+ function getConnection();
+
+ function beforePrepare(Statement\Statement $statement);
+ function afterPrepare(Statement\Statement $statement);
+
+ function beforeExecute(Statement\Statement $statement);
+ function afterExecute(Statement\Statement $statement);
+
+ function getPart($part);
+ function setPart($part, $value);
+ function getAllParts();
+
+ function addPlaceholder(Placeholder\Placeholder $placeholder);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/DmlQuery.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/DmlQuery.php
new file mode 100644
index 0000000..146be4d
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/DmlQuery.php
@@ -0,0 +1,162 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml;
+
+use Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Sql\Placeholder,
+ Wootook\Core\Database\Statement;
+
+abstract class DmlQuery
+ implements Dml
+{
+ protected $_parts = array();
+
+ protected $_connection = null;
+
+ protected $_placeholders = array();
+
+ public function __construct(Adapter\Adapter $connection, $tableName = null)
+ {
+ $this->setConnection($connection);
+
+ $this->reset();
+ $this->_init($tableName);
+ }
+
+ /**
+ * @return \Wootook\Core\Database\Adapter\Adapter
+ */
+ public function getConnection()
+ {
+ return $this->_connection;
+ }
+
+ public function setConnection(Adapter\Adapter $connection)
+ {
+ $this->_connection = $connection;
+
+ return $this;
+ }
+
+ protected function _init($param = null)
+ {
+ return $this;
+ }
+
+ public function setPart($part, $value)
+ {
+ $this->_parts[$part] = $value;
+
+ return $this;
+ }
+
+ public function getPart($part)
+ {
+ if (isset($this->_parts[$part])) {
+ return $this->_parts[$part];
+ }
+
+ return null;
+ }
+
+ public function getAllParts()
+ {
+ return $this->_parts;
+ }
+
+ public function quote($data)
+ {
+ return $this->getConnection()->quote($data);
+ }
+
+ public function quoteIdentifier($identifier)
+ {
+ return $this->getConnection()->quoteIdentifier($identifier);
+ }
+
+ public function quoteInto($identifier, $values)
+ {
+ return $this->getConnection()->quoteInto($identifier, $values);
+ }
+
+ public function addPlaceholder(Placeholder\Placeholder $placeholder)
+ {
+ $this->_placeholders[] = $placeholder;
+
+ return $this;
+ }
+
+ public function beforePrepare(Statement\Statement $statement)
+ {
+ foreach ($this->_placeholders as $placeholder) {
+ $placeholder->beforePrepare($statement);
+ }
+
+ return $this;
+ }
+
+ public function afterPrepare(Statement\Statement $statement)
+ {
+ foreach ($this->_placeholders as $placeholder) {
+ $placeholder->afterPrepare($statement);
+ }
+
+ return $this;
+ }
+
+ public function beforeExecute(Statement\Statement $statement)
+ {
+ foreach ($this->_placeholders as $placeholder) {
+ $placeholder->beforeExecute($statement);
+ }
+
+ return $this;
+ }
+
+ public function afterExecute(Statement\Statement $statement)
+ {
+ foreach ($this->_placeholders as $placeholder) {
+ $placeholder->afterExecute($statement);
+ }
+
+ return $this;
+ }
+
+ public function prepare()
+ {
+ return $this->getConnection()->prepare($this);
+ }
+
+ public function execute(Array $params = null)
+ {
+ return $this->getConnection()->execute($this, $params);
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Insert.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Insert.php
similarity index 71%
rename from src/application/code/core/Wootook/Core/Database/Sql/Insert.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Insert.php
index cccbcc8..14abfaf 100644
--- a/src/application/code/core/Wootook/Core/Database/Sql/Insert.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Insert.php
@@ -1,7 +1,39 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Database_Sql_Insert
- extends Wootook_Core_Database_Sql_DmlQuery
+namespace Wootook\Core\Database\Sql\Dml;
+
+use Wootook\Core\Database\Sql\Placeholder;
+
+class Insert
+ extends DmlQuery
{
const SET = 'SET';
const INTO = 'INTO';
@@ -40,7 +72,7 @@ class Wootook_Core_Database_Sql_Insert
}
foreach ($column as $field => $value) {
- if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
+ if ($value instanceof Placeholder\Placeholder) {
$this->_placeholders[] = $value;
}
@@ -102,7 +134,7 @@ class Wootook_Core_Database_Sql_Insert
{
$fields = array();
foreach ($this->_parts[self::SET] as $field) {
- if ($field['value'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
+ if ($field['value'] instanceof Placeholder\Placeholder) {
$fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$field['value']->toString()}";
} else {
$fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$this->_connection->quote($field['value'])}";
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Renderer.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Renderer.php
new file mode 100644
index 0000000..c8b6a6d
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Renderer.php
@@ -0,0 +1,44 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql;
+
+use Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Statement;
+
+interface Renderer
+{
+ function __construct(Adapter\Adapter $connection);
+
+ function render(Dml $query);
+
+ function quote($data);
+ function quoteIdentifier($identifier);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Column.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Column.php
new file mode 100644
index 0000000..2326d56
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Column.php
@@ -0,0 +1,72 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+use Wootook\Core\Database\Sql\Dml,
+ Wootook\Core\Database\Sql\Placeholder;
+
+trait Column
+{
+ public function column($column = '*', $table = null)
+ {
+ $parts = $this->getPart(Dml\Section\ColumnAware::COLUMNS);
+ if (is_array($column)) {
+ foreach ($column as $alias => $field) {
+ if (is_int($alias)) {
+ $parts[] = array(
+ 'table' => $table,
+ 'alias' => null,
+ 'field' => $field
+ );
+ } else {
+ $parts[] = array(
+ 'table' => $table,
+ 'alias' => $alias,
+ 'field' => $field
+ );
+ }
+ }
+ } else {
+ if ($column instanceof Placeholder\Placeholder) {
+ $this->_placeholders[] = $column;
+ }
+
+ $parts[] = array(
+ 'table' => $table,
+ 'alias' => null,
+ 'field' => $column
+ );
+ }
+ $this->setPart(Dml\Section\ColumnAware::COLUMNS, $parts);
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/ColumnAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/ColumnAware.php
new file mode 100644
index 0000000..a75f0be
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/ColumnAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+interface ColumnAware
+{
+ const COLUMNS = 'COLUMNS';
+
+ public function column($column = '*', $table = null);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/From.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/From.php
new file mode 100644
index 0000000..414c40f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/From.php
@@ -0,0 +1,61 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+use Wootook\Core\Database\Sql\Dml;
+
+trait From
+{
+ public function from($table, $schema = null)
+ {
+ if (is_array($table)) {
+ $alias = key($table);
+ $table = current($table);
+ } else {
+ $alias = null;
+ }
+
+ $part = $this->getPart(FromAware::FROM);
+ if (!is_array($part)) {
+ $part = array();
+ }
+
+ $part[] = array(
+ 'table' => $table,
+ 'alias' => $alias,
+ 'schema' => $schema
+ );
+
+ $this->setPart(FromAware::FROM, $part);
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/FromAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/FromAware.php
new file mode 100644
index 0000000..1c16e2b
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/FromAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+interface FromAware
+{
+ const FROM = 'FROM';
+
+ public function from($table, $schema = null);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Into.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Into.php
new file mode 100644
index 0000000..7b70980
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Into.php
@@ -0,0 +1,44 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+trait Into
+{
+ public function into($table, $schema = null)
+ {
+ $this->setPart(IntoAware::INTO, array(
+ 'table' => $table,
+ 'schema' => $schema,
+ ));
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/IntoAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/IntoAware.php
new file mode 100644
index 0000000..d0c3d7e
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/IntoAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+interface IntoAware
+{
+ const INTO = 'INTO';
+
+ public function into($table, $schema = null);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Limit.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Limit.php
new file mode 100644
index 0000000..54ed5d7
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Limit.php
@@ -0,0 +1,42 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+trait Limit
+{
+ public function limit($limit, $offset = null)
+ {
+ $this->setPart(LimitAware::LIMIT, intval($limit));
+ $this->setPart(LimitAware::OFFSET, intval($offset));
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/LimitAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/LimitAware.php
new file mode 100644
index 0000000..586d4be
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/LimitAware.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+interface LimitAware
+{
+ const LIMIT = 'LIMIT';
+ const OFFSET = 'OFFSET';
+
+ public function limit($limit, $offset = null);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Column.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Column.php
new file mode 100644
index 0000000..3920de5
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Column.php
@@ -0,0 +1,73 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml,
+ Wootook\Core\Database\Sql\Placeholder;
+
+trait Column
+{
+ public function renderColumn(Dml\Dml $query)
+ {
+ $fields = array();
+ $part = $query->getPart(Dml\Section\ColumnAware::COLUMNS);
+ foreach ($part as $field) {
+ if ($field['field'] instanceof Dml\Dml) {
+ if ($field['alias'] !== null) {
+ $fields[] = "({$field['field']}) AS {$field['alias']}";
+ } else {
+ $fields[] = "({$field['field']})";
+ }
+ } else if ($field['field'] instanceof Placeholder\Placeholder) {
+ 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 '*';
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/ColumnAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/ColumnAware.php
new file mode 100644
index 0000000..dfaf4c2
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/ColumnAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+interface ColumnAware
+{
+ public function renderColumn(Dml\Dml $query);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/From.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/From.php
new file mode 100644
index 0000000..a57f6a1
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/From.php
@@ -0,0 +1,68 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+trait From
+{
+ public function renderFrom(Dml\Dml $query)
+ {
+ $part = $query->getPart(Dml\Section\FromAware::FROM);
+
+ if (!is_array($part)) {
+ return '';
+ }
+
+ $tables = array();
+ foreach ($part as $table) {
+ if ($table['table'] instanceof Dml\Dml) {
+ if ($table['alias'] !== null) {
+ $tables[] = "({$table['table']}) AS {$query->quoteIdentifier($table['alias'])}";
+ } else {
+ $tables[] = "({$table['table']})";
+ }
+ } else if ($table['alias'] !== null) {
+ if ($table['schema'] !== null) {
+ $tables[] = "{$query->quoteIdentifier($table['schema'])}.{$query->quoteIdentifier($table['table'])} AS {$query->quoteIdentifier($table['alias'])}";
+ } else {
+ $tables[] = "{$query->quoteIdentifier($table['table'])} AS {$query->quoteIdentifier($table['alias'])}";
+ }
+ } else if ($table['schema'] !== null) {
+ $tables[] = "{$query->quoteIdentifier($table['schema'])}.{$query->quoteIdentifier($table['table'])}";
+ } else {
+ $tables[] = "{$query->quoteIdentifier($table['table'])}";
+ }
+ }
+
+ return " FROM " . implode(', ', $tables);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/FromAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/FromAware.php
new file mode 100644
index 0000000..52e6ab6
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/FromAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+interface FromAware
+{
+ public function renderFrom(Dml\Dml $query);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Into.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Into.php
new file mode 100644
index 0000000..f5d6cfb
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Into.php
@@ -0,0 +1,48 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+trait Into
+{
+ public function renderInto(Dml\Dml $query)
+ {
+ $part = $query->getPart(Dml\Section\IntoAware::INTO);
+
+
+ if ($part['schema'] !== null) {
+ return "{$query->quoteIdentifier($part['schema'])}.{$query->quoteIdentifier($part['table'])}";
+ }
+
+ return "{$query->quoteIdentifier($part['table'])}";
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/IntoAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/IntoAware.php
new file mode 100644
index 0000000..05be8b2
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/IntoAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+interface IntoAware
+{
+ public function renderLimit(Dml\Dml $query);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Limit.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Limit.php
new file mode 100644
index 0000000..4b7efdd
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Limit.php
@@ -0,0 +1,47 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+trait Limit
+{
+ public function renderLimit(Dml\Dml $query)
+ {
+ if (!($limit = $query->getPart(Dml\Section\LimitAware::LIMIT))) {
+ return '';
+ }
+ if (!($offset = $query->getPart(Dml\Section\LimitAware::OFFSET))) {
+ return sprintf(" LIMIT %d", $limit);
+ }
+ return sprintf(" LIMIT %d,%d", $limit, $offset);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/LimitAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/LimitAware.php
new file mode 100644
index 0000000..b4a4c8d
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/LimitAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+interface LimitAware
+{
+ public function renderLimit(Dml\Dml $query);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Set.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Set.php
new file mode 100644
index 0000000..cc14251
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Set.php
@@ -0,0 +1,60 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml,
+ Wootook\Core\Database\Sql\Placeholder;
+
+trait Set
+{
+ public function renderSet(Dml\Dml $query)
+ {
+ $fields = array();
+ $parts = $query->getPart(Dml\Section\SetAware::SET);
+ if (is_array($parts)) {
+ foreach ($parts as $field) {
+ if ($field['value'] instanceof Placeholder\Placeholder) {
+ $fields[] = "{$query->quoteIdentifier($field['field'])}={$field['value']->toString()}";
+ } else if ($field['value'] === null) {
+ $fields[] = "{$query->quoteIdentifier($field['field'])}=NULL";
+ } else {
+ $fields[] = "{$query->quoteIdentifier($field['field'])}={$query->quote($field['value'])}";
+ }
+ }
+ }
+
+ if (!empty($fields)) {
+ return ' SET ' . implode(', ', $fields);
+ }
+
+ return '';
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/SetAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/SetAware.php
new file mode 100644
index 0000000..f072e75
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/SetAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+interface SetAware
+{
+ public function renderSet(Dml\Dml $query);
+}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/DmlFilterableQuery.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Where.php
similarity index 78%
rename from src/application/code/core/Wootook/Core/Database/Sql/DmlFilterableQuery.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Where.php
index 6ca3730..55e2ee1 100644
--- a/src/application/code/core/Wootook/Core/Database/Sql/DmlFilterableQuery.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/Where.php
@@ -1,31 +1,45 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
- extends Wootook_Core_Database_Sql_DmlQuery
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core,
+ Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Statement,
+ Wootook\Core\Database\Sql\Placeholder;
+
+trait Where
{
- const WHERE = 'WHERE';
- const LIMIT = 'LIMIT';
- const OFFSET = 'OFFSET';
-
- const OPERATOR_AND = 'AND';
- const OPERATOR_OR = 'OR';
- const OPERATOR_XOR = 'XOR';
- const OPERATOR_EQUALS = 'EQ';
- const OPERATOR_NOT_EQUALS = 'NEQ';
- const OPERATOR_LOWER = 'LT';
- const OPERATOR_GREATER = 'GT';
- const OPERATOR_LOWER_EQUALS = 'LTEQ';
- const OPERATOR_GREATER_EQUALS = 'GTEQ';
- const OPERATOR_IS_NULL = 'NULL';
- const OPERATOR_IN = 'IN';
- const OPERATOR_NOT_IN = 'NIN';
- const OPERATOR_FIND_IN_SET = 'FINSET';
- const OPERATOR_NOT_FIND_IN_SET = 'NFINSET';
- const OPERATOR_DATE = 'DATE';
-
public function where($condition, $value = null)
{
- if ($condition instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
+ if ($condition instanceof Placeholder\Placeholder) {
$this->_placeholders[] = $condition;
$this->_parts[self::WHERE][] = $condition;
} else if (is_array($value)) {
@@ -33,7 +47,7 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
if ($where !== null) {
$this->_parts[self::WHERE][] = $where;
}
- } else if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
+ } else if ($value instanceof Placeholder\Placeholder) {
$this->_parts[self::WHERE][] = "{$this->getConnection()->quoteIdentifier($condition)}=" . $value;
} else {
$this->_parts[self::WHERE][] = $this->getConnection()->quoteInto("{$this->getConnection()->quoteIdentifier($condition)}=?", $value);
@@ -42,14 +56,6 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
return $this;
}
- public function limit($limit, $offset = null)
- {
- $this->_parts[self::LIMIT] = intval($limit);
- $this->_parts[self::OFFSET] = intval($offset);
-
- return $this;
- }
-
public function renderWhere()
{
if (count($this->_parts[self::WHERE]) <= 0) {
@@ -59,17 +65,6 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
return " WHERE (" . implode(")\n AND (", $this->_parts[self::WHERE]) . ')';
}
- public function renderLimit()
- {
- if (!$this->_parts[self::LIMIT]) {
- return '';
- }
- if (!$this->_parts[self::OFFSET]) {
- return sprintf(" LIMIT %d", $this->_parts[self::LIMIT]);
- }
- return sprintf(" LIMIT %d,%d", $this->_parts[self::LIMIT], $this->_parts[self::OFFSET]);
- }
-
protected function _translateSqlWhere($field, $operator, $value)
{
if ($value === null) {
@@ -94,7 +89,7 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
return "{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}FALSE";
} else if (is_numeric($value)) {
return sprintf("{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}%d", $value);
- } else if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
+ } else if ($value instanceof Placeholder\Placeholder) {
$this->_placeholders[] = $value;
return sprintf("{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}%s", $adapter->quote($value->toString()));
} else {
@@ -182,7 +177,7 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
case self::OPERATOR_DATE:
$dateValues = array();
if (isset($value['from'])) {
- if ($value['from'] instanceof Wootook_Core_DateTime) {
+ if ($value['from'] instanceof Core\DateTime) {
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($this->getConnection()->getDataMapper()->load('DateTime')->encode($value['from']))}";
} else if (is_string($value['from'])) {
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($value['from'])}";
@@ -191,7 +186,7 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
}
}
if (isset($value['to'])) {
- if ($value['to'] instanceof Wootook_Core_DateTime) {
+ if ($value['to'] instanceof Core\DateTime) {
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($this->getConnection()->getDataMapper()->load('DateTime')->encode($value['to']))}";
} else if (is_string($value['to'])) {
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($value['to'])}";
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/WhereAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/WhereAware.php
new file mode 100644
index 0000000..063a748
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Renderer/WhereAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section\Renderer;
+
+use Wootook\Core\Database\Sql\Dml;
+
+interface WhereAware
+{
+ public function renderWhere(Dml\Dml $query);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Set.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Set.php
new file mode 100644
index 0000000..14d75c9
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Set.php
@@ -0,0 +1,63 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+use Wootook\Core\Database\Sql\Placeholder;
+
+trait Set
+{
+ public function set($column, $value = null)
+ {
+ if (!is_array($column)) {
+ $column = array($column => $value);
+ }
+
+ $parts = $this->getPart(SetAware::SET);
+ if (!is_array($parts)) {
+ $parts = array();
+ }
+
+ foreach ($column as $field => $value) {
+ if ($value instanceof Placeholder\Placeholder) {
+ $this->addPlaceholder($value);
+ }
+
+ $parts[] = array(
+ 'value' => $value,
+ 'field' => $field
+ );
+ }
+
+ $this->setPart(SetAware::SET, $parts);
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/SetAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/SetAware.php
new file mode 100644
index 0000000..28c4996
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/SetAware.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+interface SetAware
+{
+ const SET = 'SET';
+
+ public function set($column, $value = null);
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Where.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Where.php
new file mode 100644
index 0000000..f3bebbb
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/Where.php
@@ -0,0 +1,204 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+use Wootook\Core,
+ Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Statement,
+ Wootook\Core\Database\Sql\Placeholder;
+
+trait Where
+{
+ public function where($condition, $value = null)
+ {
+ if ($condition instanceof Placeholder\Placeholder) {
+ $this->_placeholders[] = $condition;
+ $this->_parts[WhereAware::WHERE][] = $condition;
+ } else if (is_array($value)) {
+ $where = $this->_translateSqlWhere($condition, 'or', $value);
+ if ($where !== null) {
+ $this->_parts[WhereAware::WHERE][] = $where;
+ }
+ } else if ($value instanceof Placeholder\Placeholder) {
+ $this->_parts[WhereAware::WHERE][] = "{$this->getConnection()->quoteIdentifier($condition)}=" . $value;
+ } else {
+ $this->_parts[WhereAware::WHERE][] = $this->getConnection()->quoteInto("{$this->getConnection()->quoteIdentifier($condition)}=?", $value);
+ }
+
+ return $this;
+ }
+
+ public function renderWhere()
+ {
+ if (count($this->_parts[self::WHERE]) <= 0) {
+ return '';
+ }
+
+ return " WHERE (" . implode(")\n AND (", $this->_parts[self::WHERE]) . ')';
+ }
+
+ protected function _translateSqlWhere($field, $operator, $value)
+ {
+ if ($value === null) {
+ return null;
+ }
+ $operator = strtoupper($operator);
+ $adapter = $this->getConnection();
+
+ $basicBinayOperatorList = array(
+ WhereAware::OPERATOR_EQUALS => '=',
+ WhereAware::OPERATOR_NOT_EQUALS => '!=',
+ WhereAware::OPERATOR_LOWER => '<',
+ WhereAware::OPERATOR_GREATER => '>',
+ WhereAware::OPERATOR_LOWER_EQUALS => '<=',
+ WhereAware::OPERATOR_GREATER_EQUALS => '>='
+ );
+
+ if (in_array($operator, $basicBinayOperatorList)) {
+ if ($value === true) {
+ return "{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}TRUE";
+ } else if ($value === false) {
+ return "{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}FALSE";
+ } else if (is_numeric($value)) {
+ return sprintf("{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}%d", $value);
+ } else if ($value instanceof Placeholder\Placeholder) {
+ $this->_placeholders[] = $value;
+ return sprintf("{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}%s", $adapter->quote($value->toString()));
+ } else {
+ return sprintf("{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}%s", $adapter->quote($value));
+ }
+ }
+
+ switch ($operator) {
+ case WhereAware::OPERATOR_IS_NULL:
+ if ($value == false) {
+ return "{$adapter->quoteIdentifier($field)} IS NOT NULL";
+ } else {
+ return "{$adapter->quoteIdentifier($field)} IS NULL";
+ }
+ break;
+
+ case WhereAware::OPERATOR_AND:
+ case WhereAware::OPERATOR_OR:
+ case WhereAware::OPERATOR_XOR:
+ $where = array();
+ foreach ($value as $valueItem) {
+ $subOperator = key($valueItem);
+ $realValue = current($valueItem);
+
+ if (is_array($realValue) && isset($realValue['field'])) {
+ if (!isset($realValue['value'])) {
+ continue;
+ }
+
+ $realField = $realValue['field'];
+ $realValue = $realValue['value'];
+ } else {
+ $realField = $field;
+ }
+
+ if ($realValue === null) {
+ continue;
+ }
+ $actualValue = $this->_translateSqlWhere($realField, $subOperator, $realValue);
+ if ($actualValue !== null) {
+ $where[] = $actualValue;
+ }
+ }
+
+ if (count($where)) {
+ return '((' . implode(') ' . strtoupper($operator) . ' (', $where) . '))';
+ }
+ break;
+
+ case WhereAware::OPERATOR_IN:
+ $valueList = array();
+ foreach ($value as $setValue) {
+ $valueList[] = $adapter->quote($setValue);
+ }
+ $implodedList = implode(',', $valueList);
+ return "{$adapter->quoteIdentifier($field)} IN({$implodedList})";
+ break;
+
+ case WhereAware::OPERATOR_NOT_IN:
+ $valueList = array();
+ foreach ($value as $setValue) {
+ $valueList[] = $adapter->quote($setValue);
+ }
+ $implodedList = implode(',', $valueList);
+ return "{$adapter->quoteIdentifier($field)} NOT IN({$implodedList})";
+ break;
+
+ case WhereAware::OPERATOR_FIND_IN_SET:
+ if (is_array($value)) {
+ $subField = current($value);
+ $subOperator = key($value);
+
+ if (in_array($subOperator, $basicBinayOperatorList)) {
+ return "FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)}){$basicBinayOperatorList[$operator]}{$adapter->quoteIdentifier($subField)}";
+ }
+ } else {
+ return "0 < FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})";
+ }
+ break;
+
+ case WhereAware::OPERATOR_NOT_FIND_IN_SET:
+ return "0 = FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})";
+ break;
+
+ case WhereAware::OPERATOR_DATE:
+ $dateValues = array();
+ if (isset($value['from'])) {
+ if ($value['from'] instanceof Core\DateTime) {
+ $dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($this->getConnection()->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'])) {
+ $dateValues['from'] = "UNIX_TIMESTAMP({$adapter->quoteIdentifier($field)}) >= {$adapter->quote($value['from'])}";
+ }
+ }
+ if (isset($value['to'])) {
+ if ($value['to'] instanceof Core\DateTime) {
+ $dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($this->getConnection()->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'])) {
+ $dateValues['to'] = "UNIX_TIMESTAMP({$adapter->quoteIdentifier($field)}) <= {$adapter->quote($value['to'])}";
+ }
+ }
+
+ return '(' . implode(' AND ', $dateValues) . ')';
+ break;
+ }
+
+ return null;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/WhereAware.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/WhereAware.php
new file mode 100644
index 0000000..a45b415
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Section/WhereAware.php
@@ -0,0 +1,58 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Dml\Section;
+
+interface WhereAware
+{
+ const WHERE = 'WHERE';
+
+ const OPERATOR_NOT = 'NOT';
+ const OPERATOR_AND = 'AND';
+ const OPERATOR_OR = 'OR';
+ const OPERATOR_XOR = 'XOR';
+ const OPERATOR_NAND = 'NAND';
+ const OPERATOR_NOR = 'NOR';
+ const OPERATOR_NXOR = 'NXOR';
+ const OPERATOR_EQUALS = 'EQ';
+ const OPERATOR_NOT_EQUALS = 'NEQ';
+ const OPERATOR_LOWER = 'LT';
+ const OPERATOR_GREATER = 'GT';
+ const OPERATOR_LOWER_EQUALS = 'LTEQ';
+ const OPERATOR_GREATER_EQUALS = 'GTEQ';
+ const OPERATOR_IS_NULL = 'NULL';
+ const OPERATOR_IN = 'IN';
+ const OPERATOR_NOT_IN = 'NIN';
+ const OPERATOR_FIND_IN_SET = 'FINSET';
+ const OPERATOR_NOT_FIND_IN_SET = 'NFINSET';
+ const OPERATOR_DATE = 'DATE';
+
+ public function where($condition, $value = null);
+}
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Select.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Select.php
similarity index 85%
rename from src/application/code/core/Wootook/Core/Database/Sql/Select.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Select.php
index 3c67203..95f36a1 100644
--- a/src/application/code/core/Wootook/Core/Database/Sql/Select.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Select.php
@@ -1,10 +1,44 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Database_Sql_Select
- extends Wootook_Core_Database_Sql_DmlFilterableQuery
+namespace Wootook\Core\Database\Sql\Dml;
+
+use Wootook\Core\Database\Sql\Dml\Section,
+ Wootook\Core\Database\Sql\Placeholder;
+
+class Select
+ extends DmlQuery
{
+ use Section\Where, Section\Limit;
+
const COLUMNS = 'COLUMNS';
- const FROM = 'FROM';
const JOIN = 'JOIN';
const ORDER = 'ORDER';
const UNION = 'UNION';
@@ -68,7 +102,7 @@ class Wootook_Core_Database_Sql_Select
}
}
} else {
- if ($column instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
+ if ($column instanceof Placeholder\Placeholder) {
$this->_placeholders[] = $column;
}
@@ -211,13 +245,13 @@ class Wootook_Core_Database_Sql_Select
{
$fields = array();
foreach ($this->_parts[self::COLUMNS] as $field) {
- if ($field['field'] instanceof Wootook_Core_Database_Sql_Dml) {
+ if ($field['field'] instanceof Dml) {
if ($field['alias'] !== null) {
$fields[] = "({$field['field']}) AS {$field['alias']}";
} else {
$fields[] = "({$field['field']})";
}
- } else if ($field['field'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
+ } else if ($field['field'] instanceof Placeholder\Placeholder) {
if ($field['alias'] !== null) {
$fields[] = "({$field['field']}) AS {$field['alias']}";
} else {
@@ -246,7 +280,7 @@ class Wootook_Core_Database_Sql_Select
{
$tables = array();
foreach ($this->_parts[self::FROM] as $table) {
- if ($table['table'] instanceof Wootook_Core_Database_Sql_Dml) {
+ if ($table['table'] instanceof Dml) {
if ($table['alias'] !== null) {
$tables[] = "({$table['table']}) AS {$this->_connection->quoteIdentifier($table['alias'])}";
} else {
diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Update.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Update.php
similarity index 60%
rename from src/application/code/core/Wootook/Core/Database/Sql/Update.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Update.php
index 5cd83b8..51a297a 100644
--- a/src/application/code/core/Wootook/Core/Database/Sql/Update.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Dml/Update.php
@@ -1,10 +1,43 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Database_Sql_Update
- extends Wootook_Core_Database_Sql_DmlFilterableQuery
+namespace Wootook\Core\Database\Sql\Dml;
+
+use Wootook\Core\Database\Sql\Dml\Section,
+ Wootook\Core\Database\Sql\Placeholder;
+
+class Update
+ extends DmlQuery
+ implements Section\IntoAware, Section\LimitAware, Section\SetAware
{
- const SET = 'SET';
- const INTO = 'INTO';
+ use Section\Set, Section\Into, Section\Where, Section\Limit;
protected function _init($tableName = null)
{
@@ -34,36 +67,6 @@ class Wootook_Core_Database_Sql_Update
return $this;
}
- public function set($column, $value = null)
- {
- if (!is_array($column)) {
- $column = array($column => $value);
- }
-
- foreach ($column as $field => $value) {
- if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
- $this->_placeholders[] = $value;
- }
-
- $this->_parts[self::SET][] = array(
- 'value' => $value,
- 'field' => $field
- );
- }
-
- return $this;
- }
-
- public function into($table, $schema = null)
- {
- $this->_parts[self::INTO] = array(
- 'table' => $table,
- 'schema' => $schema,
- );
-
- return $this;
- }
-
public function __toString()
{
return $this->render();
@@ -91,7 +94,7 @@ class Wootook_Core_Database_Sql_Update
{
$fields = array();
foreach ($this->_parts[self::SET] as $field) {
- if ($field['value'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
+ if ($field['value'] instanceof Placeholder\Placeholder) {
$fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$field['value']->toString()}";
} else {
$fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$this->_connection->quote($field['value'])}";
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Expression.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Expression.php
new file mode 100644
index 0000000..796fc9f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Expression.php
@@ -0,0 +1,62 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Placeholder;
+
+use Wootook\Core\Database\Statement;
+
+class Expression
+ extends Placeholder
+{
+ protected $_expression = null;
+ protected $_params = array();
+
+ public function __construct($expression, Array $params = array())
+ {
+ $this->_expression = (string) $expression;
+ $this->_params = $params;
+ }
+
+ public function __toString()
+ {
+ return $this->_expression;
+ }
+
+ public function beforeExecute(Statement\Statement $statement)
+ {
+ parent::beforeExecute($statement);
+
+ foreach ($this->_params as $paramName => $value) {
+ $statement->bindValue($paramName, $value, $statement->getParamType($value));
+ }
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Param.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Param.php
new file mode 100644
index 0000000..18155c0
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Param.php
@@ -0,0 +1,63 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Placeholder;
+
+use Wootook\Core\Database\Statement;
+
+class Param
+ extends Placeholder
+{
+ protected $_paramType = null;
+ protected $_paramName = null;
+ protected $_value = null;
+
+ public function __construct($paramName, $value, $type = null)
+ {
+ $this->_paramName = $paramName;
+ $this->_paramType = $type;
+ $this->_value = $value;
+ }
+
+ public function __toString()
+ {
+ return ':' . $this->_paramName;
+ }
+
+ public function beforeExecute(Statement\Statement $statement)
+ {
+ parent::beforeExecute($statement);
+
+ $type = $this->_paramType !== null ? $this->_paramType : $statement->getParamType($this->_value);
+ $statement->bindValue($this->_paramName, $this->_value, $type);
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Placeholder.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Placeholder.php
new file mode 100644
index 0000000..188cd03
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Placeholder.php
@@ -0,0 +1,63 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Placeholder;
+
+use Wootook\Core\Database\Statement;
+
+abstract class Placeholder
+{
+ public function toString()
+ {
+ return $this->__toString();
+ }
+
+ abstract public function __toString();
+
+ public function beforePrepare(Statement\Statement $statement)
+ {
+ return $this;
+ }
+
+ public function afterPrepare(Statement\Statement $statement)
+ {
+ return $this;
+ }
+
+ public function beforeExecute(Statement\Statement $statement)
+ {
+ return $this;
+ }
+
+ public function afterExecute(Statement\Statement $statement)
+ {
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Variable.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Variable.php
new file mode 100644
index 0000000..ef1bfdc
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/Placeholder/Variable.php
@@ -0,0 +1,52 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Sql\Placeholder;
+
+use Wootook\Core\Database\Statement;
+
+class Variable
+ extends Placeholder
+{
+ protected $_paramType = null;
+ protected $_paramName = null;
+ protected $_value = null;
+
+ public function __construct($paramName, $type = null)
+ {
+ $this->_paramName = $paramName;
+ $this->_paramType = $type;
+ }
+
+ public function __toString()
+ {
+ return ':' . $this->_paramName;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/QueryBuilder/QueryBuilder.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/QueryBuilder/QueryBuilder.php
new file mode 100644
index 0000000..dbda08e
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Sql/QueryBuilder/QueryBuilder.php
@@ -0,0 +1,8 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Statement;
+
+use Wootook\Core\Database,
+ Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Sql,
+ Wootook\Core\Exception as CoreException;
+
+class Mysql
+ extends Statement
+{
+ /**
+ * @var \mysqli_stmt
+ */
+ protected $_handler = null;
+
+ /**
+ * @var string|Sql\Dml
+ */
+ protected $_query = null;
+
+ protected function _init($query)
+ {
+ $this->_query = $query;
+
+ if ($this->_query instanceof Sql\Dml) {
+ $this->_query->beforePrepare($this);
+ }
+
+ try {
+ $this->_handler = $this->_adapter->getDriverHandler()->stmt_init();
+
+ if (!$this->_handler->prepare($this->_query)) {
+ throw new CoreException\Database\StatementError($this, $this->_handler->error, $this->_handler->errno);
+ }
+ } catch (\mysqli_sql_exception $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ if ($this->_query instanceof Sql\Dml) {
+ $this->_query->afterPrepare($this);
+ }
+
+ $this->dispatchEvent(self::EVENT_INIT);
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param string|int $column
+ * @param mixed $param
+ * @param int $type
+ * @return Statement
+ */
+ public function bindColumn($column, &$param, $type = null)
+ {
+ try {
+ return $this->_handler->bindColumn($column, $param, $type);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), null, $e);
+ }
+ }
+
+ /**
+ *
+ * @param string|int $parameter
+ * @param mixed $variable
+ * @param int $type
+ * @param int $length
+ * @param unknown_type $options
+ * @return Statement
+ */
+ public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
+ {
+ try {
+ return $this->_handler->bindParam($parameter, $variable, $type, $length, $options);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ *
+ * @param string|int $parameter
+ * @param mixed $value
+ * @param int $type
+ * @return Statement\Statement
+ */
+ public function bindValue($parameter, $value, $type = null)
+ {
+ try {
+ return $this->_handler->bindValue($parameter, $value, $type);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ *
+ * @param array $params
+ * @return bool
+ */
+ public function execute(Array $params = null, $asynchronous = false)
+ {
+ if ($this->_query instanceof Sql\Dml) {
+ $this->_query->beforeExecute($this);
+ }
+
+ try {
+ foreach ($params as $paramKey => $paramValue) {
+ $this->_handler->bind_param('', $paramValue);
+ }
+ $result = $this->_handler->execute($params);
+ } catch (\mysqli_sql_exception $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ if ($this->_query instanceof Sql\Dml) {
+ $this->_query->afterExecute($this);
+ }
+
+ $this->dispatchEvent(self::EVENT_READY, array(
+ 'result' => $result
+ ));
+
+ return $result;
+ }
+
+ /**
+ *
+ * @param int $style
+ * @param int $col
+ * @return mixed
+ */
+ public function fetchAll($style = null, $col = null)
+ {
+ try {
+ if ($style !== null) {
+ if ($col !== null) {
+ $result = $this->_handler->fetchAll($style, $col);
+ } else {
+ $result = $this->_handler->fetchAll($style);
+ }
+ } else {
+ $result = $this->_handler->fetchAll($style);
+ }
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ $this->dispatchEvent(self::EVENT_FETCH_ALL, array(
+ 'result' => $result
+ ));
+
+ return $result;
+ }
+
+ /**
+ *
+ * @param int $col
+ * @return mixed
+ */
+ public function fetchColumn($col = 0)
+ {
+ try {
+ $result = $this->_handler->fetchColumn($col);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ $this->dispatchEvent(self::EVENT_FETCH_COL, array(
+ 'result' => $result
+ ));
+
+ return $result;
+ }
+
+ /**
+ *
+ * @return Database\Adapter\Adapter
+ */
+ public function getAdapter()
+ {
+ return $this->_adapter;
+ }
+
+ /**
+ *
+ * @param string $key
+ */
+ public function getAttribute($key)
+ {
+ try {
+ return $this->_handler->getAttribute($key);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return Statement\Statement
+ */
+ public function setAttribute($key, $value)
+ {
+ try {
+ return $this->_handler->setAttribute($key, $value);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @param unknown_type $mode
+ * @return Statement\Statement
+ */
+ public function setFetchMode($mode)
+ {
+ try {
+ $params = func_get_args();
+ return call_user_func_array(array($this->_handler, 'setFetchMode'), $params);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @return int
+ */
+ public function columnCount()
+ {
+ try {
+ return $this->_handler->columnCount();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @return int
+ */
+ public function rowCount()
+ {
+ try {
+ return $this->_handler->rowCount();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @param int $col
+ * @return mixed
+ */
+ public function fetch($style = null, $orientation = Database\ConnectionManager::FETCH_ORI_NEXT, $cursorOffset = 0)
+ {
+ try {
+ $result = $this->_handler->fetch($style, $orientation, $cursorOffset);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ $this->dispatchEvent(self::EVENT_FETCH, array(
+ 'result' => $result,
+ 'style' => $style,
+ 'orientation' => $orientation,
+ 'offset' => $cursorOffset
+ ));
+
+ return $result;
+ }
+
+ /**
+ * @param string $class
+ * @param array $config
+ * @return Wootook\Core\BaseBaseObject
+ */
+ public function fetchObject($class = 'Wootook\\Core\\BaseBaseObject', Array $constructorArgs = array())
+ {
+ try {
+ array_unshift($constructorArgs, $this->app());
+
+ $result = $this->_handler->fetchObject($class, $constructorArgs);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ $this->dispatchEvent(self::EVENT_FETCH, array(
+ 'result' => $result,
+ 'style' => Database\ConnectionManager::FETCH_OBJ,
+ 'orientation' => Database\ConnectionManager::FETCH_ORI_NEXT,
+ 'offset' => 0
+ ));
+
+ return $result;
+ }
+
+ /**
+ * @return bool
+ */
+ public function closeCursor()
+ {
+ try {
+ return $this->_handler->closeCursor();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @return bool
+ */
+ public function nextRowset()
+ {
+ try {
+ return $this->_handler->nextRowset();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @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];
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Statement/Pdo.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Statement/Pdo.php
new file mode 100644
index 0000000..492c409
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Statement/Pdo.php
@@ -0,0 +1,387 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Statement;
+
+use Wootook\Core\Database,
+ Wootook\Core\Database\Adapter,
+ Wootook\Core\Database\Statement,
+ Wootook\Core\Database\Sql,
+ Wootook\Core\Exception as CoreException;
+
+class Pdo
+ extends Statement
+{
+ /**
+ * @var \PDOStatement
+ */
+ protected $_handler = null;
+
+ /**
+ * @var string|Sql\Dml
+ */
+ protected $_query = null;
+
+ protected function _init($query)
+ {
+ $this->_query = $query;
+
+ if ($this->_query instanceof Sql\Dml) {
+ $this->_query->beforePrepare($this);
+ }
+
+ try {
+ $this->_handler = $this->_adapter->getDriverHandler()->prepare($this->_query);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), null, $e);
+ }
+
+ if ($this->_query instanceof Sql\Dml) {
+ $this->_query->afterPrepare($this);
+ }
+
+ $this->dispatchEvent(self::EVENT_INIT);
+
+ return $this;
+ }
+
+ /**
+ *
+ * @param string|int $column
+ * @param mixed $param
+ * @param int $type
+ * @return Statement\Statement
+ */
+ public function bindColumn($column, &$param, $type = null)
+ {
+ try {
+ return $this->_handler->bindColumn($column, $param, $type);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), null, $e);
+ }
+ }
+
+ /**
+ *
+ * @param string|int $parameter
+ * @param mixed $variable
+ * @param int $type
+ * @param int $length
+ * @param unknown_type $options
+ * @return Statement\Statement
+ */
+ public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
+ {
+ try {
+ return $this->_handler->bindParam($parameter, $variable, $type, $length, $options);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ *
+ * @param string|int $parameter
+ * @param mixed $value
+ * @param int $type
+ * @return Statement\Statement
+ */
+ public function bindValue($parameter, $value, $type = null)
+ {
+ try {
+ return $this->_handler->bindValue($parameter, $value, $type);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ *
+ * @param array $params
+ * @return bool
+ */
+ public function execute(Array $params = null, $asynchronous = false)
+ {
+ if ($this->_query instanceof Sql\Dml) {
+ $this->_query->beforeExecute($this);
+ }
+
+ if ($asynchronous === true) {
+ throw new CoreException\Database\StatementError($this, 'Asynchronous calls are not available with this driver.');
+ }
+
+ try {
+ $result = $this->_handler->execute($params);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ if ($this->_query instanceof Sql\Dml) {
+ $this->_query->afterExecute($this);
+ }
+
+ $this->dispatchEvent(self::EVENT_READY, array(
+ 'result' => $result
+ ));
+
+ return $result;
+ }
+
+ /**
+ *
+ * @param int $style
+ * @param int $col
+ * @return mixed
+ */
+ public function fetchAll($style = null, $col = null)
+ {
+ try {
+ if ($style !== null) {
+ if ($col !== null) {
+ $result = $this->_handler->fetchAll($style, $col);
+ } else {
+ $result = $this->_handler->fetchAll($style);
+ }
+ } else {
+ $result = $this->_handler->fetchAll($style);
+ }
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ $this->dispatchEvent(self::EVENT_FETCH_ALL, array(
+ 'result' => $result
+ ));
+
+ return $result;
+ }
+
+ /**
+ *
+ * @param int $col
+ * @return mixed
+ */
+ public function fetchColumn($col = 0)
+ {
+ try {
+ $result = $this->_handler->fetchColumn($col);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ $this->dispatchEvent(self::EVENT_FETCH_COL, array(
+ 'result' => $result
+ ));
+
+ return $result;
+ }
+
+ /**
+ *
+ * @return Database\Adapter\Adapter
+ */
+ public function getAdapter()
+ {
+ return $this->_adapter;
+ }
+
+ /**
+ *
+ * @param string $key
+ */
+ public function getAttribute($key)
+ {
+ try {
+ return $this->_handler->getAttribute($key);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return Statement\Statement
+ */
+ public function setAttribute($key, $value)
+ {
+ try {
+ return $this->_handler->setAttribute($key, $value);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @param unknown_type $mode
+ * @return Statement\Statement
+ */
+ public function setFetchMode($mode)
+ {
+ try {
+ $params = func_get_args();
+ return call_user_func_array(array($this->_handler, 'setFetchMode'), $params);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @return int
+ */
+ public function columnCount()
+ {
+ try {
+ return $this->_handler->columnCount();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @return int
+ */
+ public function rowCount()
+ {
+ try {
+ return $this->_handler->rowCount();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @param int $col
+ * @return mixed
+ */
+ public function fetch($style = null, $orientation = Database\ConnectionManager::FETCH_ORI_NEXT, $cursorOffset = 0)
+ {
+ try {
+ $result = $this->_handler->fetch($style, $orientation, $cursorOffset);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ $this->dispatchEvent(self::EVENT_FETCH, array(
+ 'result' => $result,
+ 'style' => $style,
+ 'orientation' => $orientation,
+ 'offset' => $cursorOffset
+ ));
+
+ return $result;
+ }
+
+ /**
+ * @param string $class
+ * @param array $config
+ * @return Wootook\Core\BaseBaseObject
+ */
+ public function fetchObject($class = 'Wootook\\Core\\BaseBaseObject', Array $constructorArgs = array())
+ {
+ try {
+ array_unshift($constructorArgs, $this->app());
+
+ $result = $this->_handler->fetchObject($class, $constructorArgs);
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+
+ $this->dispatchEvent(self::EVENT_FETCH, array(
+ 'result' => $result,
+ 'style' => Database\ConnectionManager::FETCH_OBJ,
+ 'orientation' => Database\ConnectionManager::FETCH_ORI_NEXT,
+ 'offset' => 0
+ ));
+
+ return $result;
+ }
+
+ /**
+ * @return bool
+ */
+ public function closeCursor()
+ {
+ try {
+ return $this->_handler->closeCursor();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @return bool
+ */
+ public function nextRowset()
+ {
+ try {
+ return $this->_handler->nextRowset();
+ } catch (\PDOException $e) {
+ throw new CoreException\Database\StatementError($this, $e->getMessage(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * @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];
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Database/Statement/Statement.php b/src/application/modules/WootookCore/src/Wootook/Core/Database/Statement/Statement.php
new file mode 100644
index 0000000..150901e
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Database/Statement/Statement.php
@@ -0,0 +1,275 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Database\Statement;
+
+use Wootook\Core\Database,
+ Wootook\Core\Database\Adapter,
+ Wootook\Core\Event,
+ Wootook\Core\Exception as CoreException;
+
+abstract class Statement
+ implements \Iterator
+{
+ use Event\EventTarget;
+
+ const EVENT_INIT = 'init';
+ const EVENT_READY = 'ready';
+ const EVENT_ERROR = 'error';
+ const EVENT_FETCH = 'fetch';
+ const EVENT_FETCH_ALL = 'fetch-all';
+ const EVENT_FETCH_COL = 'fetch-column';
+
+ protected $_adapter = null;
+
+ protected $_currentIndex = 0;
+ protected $_currentRow = null;
+
+ protected $_asynchronousCallbacks = array();
+
+ public function __construct(Adapter\Adapter $adapter, $sql)
+ {
+ $this->_adapter = $adapter;
+
+ $this->_init($sql);
+ }
+
+ abstract protected function _init($sql);
+
+ /**
+ *
+ * @param string|int $column
+ * @param mixed $param
+ * @param int $type
+ * @return Statement
+ */
+ abstract public function bindColumn($column, &$param, $type = null);
+
+ /**
+ *
+ * @param string|int $parameter
+ * @param mixed $variable
+ * @param int $type
+ * @param int $length
+ * @param unknown_type $options
+ * @return Statement
+ */
+ abstract public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null);
+
+ /**
+ *
+ * @param string|int $parameter
+ * @param mixed $value
+ * @param int $type
+ * @return Statement
+ */
+ abstract public function bindValue($parameter, $value, $type = null);
+
+ /**
+ * @abstract
+ * @param array|null $params
+ * @param bool $synchronous
+ * @return bool
+ */
+ abstract public function execute(Array $params = null, $synchronous = false);
+
+ /**
+ * @abstract
+ * @param null $style
+ * @param int $orientation
+ * @param int $cursorOffset
+ * @return mixed
+ */
+ abstract public function fetch($style = null, $orientation = Database\ConnectionManager::FETCH_ORI_NEXT, $cursorOffset = 0);
+
+ /**
+ * @param int $style
+ * @param int $col
+ * @return mixed
+ */
+ abstract public function fetchAll($style = null, $col = null);
+
+ /**
+ * @param int $col
+ * @return mixed
+ */
+ abstract public function fetchColumn($col = 0);
+
+ /**
+ *
+ * @param string $class
+ * @param array $config
+ * @return \Wootook\Core\Base\BaseObject
+ */
+ abstract public function fetchObject($class = 'Wootook\\Core\\Base\\BaseObject', Array $constructorArgs = array());
+
+ /**
+ *
+ * @param string $class
+ * @param array $config
+ * @return \Wootook\Core\Mvc\Model\Entity
+ */
+ public function fetchEntity($class = 'Wootook\\Core\\Mvc\\Model\\Entity', Array $constructorArgs = array())
+ {
+ $reflection = new ReflectionClass($class);
+ $object = $reflection->newInstanceArgs($constructorArgs);
+
+ if (!$object instanceof Wootook\Core\Mvc\Model\Entity) {
+ throw new CoreException\Database\StatementError($this, 'Destination object should be a Wootook\\Core\\Mvc\\Model\\Entity instance.');
+ }
+
+ $data = $this->fetch(Database\ConnectionManager::FETCH_ASSOC);
+ $object->getDataMapper()->decode($object, $data);
+
+ return $object;
+ }
+
+ /**
+ *
+ * @return \Wootook\Core\Database\Adapter\Adapter
+ */
+ abstract public function getAdapter();
+
+ /**
+ * @param mixed $key
+ */
+ abstract public function getAttribute($key);
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @return Statement
+ */
+ abstract public function setAttribute($key, $value);
+
+ /**
+ * @param int $mode
+ * @return Statement
+ */
+ abstract public function setFetchMode($mode);
+
+ /**
+ * @return int
+ */
+ 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
+ */
+ abstract public function rowCount();
+
+ /**
+ * @return bool
+ */
+ abstract public function closeCursor();
+
+ /**
+ * @return bool
+ */
+ abstract public function nextRowset();
+
+ /**
+ * @param mixed $value
+ * @return int|null
+ */
+ public function getParamType($value)
+ {
+ if (is_numeric($value)) {
+ return Database\ConnectionManager::PARAM_INT;
+ } else if (is_bool($value)) {
+ return Database\ConnectionManager::PARAM_BOOL;
+ } else if (is_string($value)) {
+ return Database\ConnectionManager::PARAM_STR;
+ }
+
+ return null;
+ }
+
+ /**
+ * @return null|mixed
+ */
+ public function current()
+ {
+ return $this->_currentRow;
+ }
+
+ /**
+ * @return void
+ */
+ public function next()
+ {
+ $this->_currentRow = $this->fetch();
+ $this->_currentIndex++;
+ }
+
+ /**
+ * @return int
+ */
+ public function key()
+ {
+ return $this->_currentIndex;
+ }
+
+ /**
+ * @return int
+ */
+ public function rewind()
+ {
+ return $this->_currentIndex;
+ }
+
+ /**
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->_currentIndex < $this->rowCount() && $this->_currentIndex >= 0;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateInterval.php b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateInterval.php
new file mode 100644
index 0000000..0a9babb
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateInterval.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\DateTime;
+
+/**
+ * Date interval management class
+ */
+class DateInterval
+ extends \DateInterval
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DatePeriod.php b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DatePeriod.php
new file mode 100644
index 0000000..1b2701c
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DatePeriod.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\DateTime;
+
+/**
+ * Date period management class
+ */
+class DatePeriod
+ extends \DatePeriod
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTime.php b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTime.php
new file mode 100644
index 0000000..db2d3fe
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTime.php
@@ -0,0 +1,226 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\DateTime;
+
+use Wootook\Core\Exception as CoreException;
+
+/**
+ * Date period management class
+ */
+class DateTime
+ extends \DateTime
+{
+ /**
+ * @var Formatter
+ */
+ protected $_formatter = null;
+
+ /**
+ * @param string|int $dateTime
+ * @param null|DateTimeZone $timeZone
+ * @param Formatter $formatter
+ */
+ public function __construct($dateTime = null, DateTimeZone $timeZone = null, Formatter $formatter = null, $useIntlParsing = true)
+ {
+ if ($formatter === null || $useIntlParsing === false) {
+ parent::__construct($dateTime, $timeZone);
+ } else {
+ parent::__construct();
+
+ $this->setTimestamp($formatter->parse($dateTime));
+ }
+
+ $this->_formatter = $formatter;
+ }
+
+ /**
+ * @param Formatter $formatter
+ * @return DateTime
+ */
+ public function setFormatter(Formatter $formatter)
+ {
+ $this->_formatter = $formatter;
+
+ return $this;
+ }
+
+ /**
+ * @return null|Formatter
+ */
+ public function getFormatter()
+ {
+ return $this->_formatter;
+ }
+
+ /**
+ * @param string|int $dateTime
+ * @param Formatter $formatter
+ * @param null|DateTimeZone $timeZone
+ */
+ public function set($dateTime, DateTimeZone $timeZone = null, Formatter $formatter)
+ {
+ if ($formatter === null) {
+ $this->setTimestamp(strtotime($dateTime));
+ } else {
+ $this->setTimestamp($formatter->parse($dateTime));
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param DateTime $dateTime
+ * @return bool
+ */
+ public function isEarlier(\DateTime $dateTime)
+ {
+ return $this < $dateTime;
+ }
+
+ /**
+ * @param DateTime $dateTime
+ * @return bool
+ */
+ public function isLater(\DateTime $dateTime)
+ {
+ return $this > $dateTime;
+ }
+
+ /**
+ * @param DateTime $dateTime
+ * @return bool
+ */
+ public function isToday(\DateTime $today = null)
+ {
+ if ($today === null) {
+ $today = new self(null, $this->getTimezone());
+ } else {
+ $today = clone $today;
+ }
+
+ $today->setTime(0, 0, 0);
+ if ($this->isEarlier($today)) {
+ return false;
+ }
+
+ $today->setTime(23, 59, 59);
+ if ($this->isLater($today)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @param DateTime $dateTime
+ * @return bool
+ */
+ public function isTomorrow(\DateTime $tomorrow = null)
+ {
+ if ($tomorrow === null) {
+ $tomorrow = new self(null, $this->getTimezone());
+ } else {
+ $tomorrow = clone $tomorrow;
+ }
+ $tomorrow->add(new \DateInterval('P1D'));
+
+ $tomorrow->setTime(0, 0, 0);
+ if ($this->isEarlier($tomorrow)) {
+ return false;
+ }
+
+ $tomorrow->setTime(23, 59, 59);
+ if ($this->isLater($tomorrow)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @param DateTime $dateTime
+ * @return bool
+ */
+ public function isYesterday(\DateTime $yesterday = null)
+ {
+ if ($yesterday === null) {
+ $yesterday = new self(null, $this->getTimezone());
+ } else {
+ $yesterday = clone $yesterday;
+ }
+ $yesterday->sub(new \DateInterval('P1D'));
+
+ $yesterday->setTime(0, 0, 0);
+ if ($this->isEarlier($yesterday)) {
+ return false;
+ }
+
+ $yesterday->setTime(23, 59, 59);
+ if ($this->isLater($yesterday)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @param null|Formatter $formatter
+ * @param string $pattern
+ * @return string
+ */
+ public function toString(Formatter $formatter = null, $pattern = null)
+ {
+ if ($formatter === null) {
+ $formatter = $this->_formatter;
+ }
+
+ if ($formatter === null) {
+ return null;
+ }
+
+ if ($pattern !== null) {
+ $formatter = clone $this->_formatter;
+ $formatter->setPattern($pattern);
+ return $formatter->format($this);
+ }
+
+ return $this->_formatter->format($this);
+ }
+
+ /**
+ * @param DateTime $dateTime
+ * @return bool
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/DateTime.php b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTime.php.old
similarity index 83%
rename from src/application/code/core/Wootook/Core/DateTime.php
rename to src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTime.php.old
index 06a6d79..934c6d3 100644
--- a/src/application/code/core/Wootook/Core/DateTime.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTime.php.old
@@ -1,7 +1,40 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+namespace Wootook\Core\DateTime;
-class Wootook_Core_DateTime
+/**
+ * Date and time management class
+ * @todo : refactor to be compatible with \DateTime
+ */
+class DateTime
{
const ISO_8601 = 'c';
@@ -71,16 +104,18 @@ class Wootook_Core_DateTime
protected $_datetime = null;
+ protected $_timezone = null;
+
public static function init($timezone = null, $force = false)
{
static $init = false;
if ($init === false || $force === true) {
if ($timezone === null) {
- //$timezone = Wootook::getConfig('system/date/timezone');
+ //$timezone = \Wootook::app()->getGlobalConfig('system/date/timezone');
}
if ($timezone === null) {
- $timezone = 'GMT';
+ $timezone = 'UTC';
}
date_default_timezone_set($timezone);
@@ -88,7 +123,11 @@ class Wootook_Core_DateTime
}
}
- public function __construct($timestamp = null, $format = null)
+ /**
+ * @param null|string|int $timestamp
+ * @param string $format
+ */
+ public function __construct($timestamp = null, $format = null, $timezone = 'UTC')
{
self::init();
@@ -99,6 +138,8 @@ class Wootook_Core_DateTime
} else {
$this->_datetime = $this->_parse($timestamp, $format);
}
+
+ $this->_timezone = $timezone;
}
public function getIso($useTimezone = false)
@@ -222,18 +263,12 @@ class Wootook_Core_DateTime
protected function _parseShortMonth($match)
{
- if ($key = array_search(strtolower($match), array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'))) {
- return $key + 1;
- }
- return false;
+ return 1 + array_search(strtolower($match), array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'));
}
protected function _parseShortWeekday($match)
{
- if ($key = array_search(strtolower($match), array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'))) {
- return $key;
- }
- return false;
+ return array_search(strtolower($match), array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'));
}
protected function _parseWeekday($match)
@@ -243,10 +278,7 @@ class Wootook_Core_DateTime
protected function _parseMeridiem($match)
{
- if (in_array(strtolower($match), array(self::MERIDIEM_AM, self::MERIDIEM_PM))) {
- return strtolower($match);
- }
- return false;
+ return strtolower($match);
}
protected function _parse($datetime, $format)
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTimeZone.php b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTimeZone.php
new file mode 100644
index 0000000..08b2a7c
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/DateTimeZone.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\DateTime;
+
+/**
+ * Date time zone management class
+ */
+class DateTimeZone
+ extends \DateTimeZone
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DateTime/Formatter.php b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/Formatter.php
new file mode 100644
index 0000000..44b8196
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DateTime/Formatter.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\DateTime;
+
+/**
+ * Date formatter and parser
+ */
+class Formatter
+// extends \IntlDateFormatter
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Config/Config.php b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Config/Config.php
new file mode 100644
index 0000000..198e1f2
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Config/Config.php
@@ -0,0 +1,22 @@
+ $classConfig) {
+ $factory->addClassDefinition($className);
+
+ if ($classConfig->methods instanceof Node) {
+ foreach ($classConfig->methods as $methodName => $methodConfig) {
+ //$classDefinition->
+ }
+ }
+ }
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/ArgumentDefinition.php b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/ArgumentDefinition.php
new file mode 100644
index 0000000..ea033c1
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/ArgumentDefinition.php
@@ -0,0 +1,137 @@
+_methodDefinition = $methodDefinition;
+ $this->_argumentName = $argumentName;
+
+ $this->setReflector($methodDefinition->getArgumentReflector($argumentName));
+
+ if ($registry !== null) {
+ $this->setRegistry($registry);
+ }
+ }
+
+ public function setRegistry(DependencyInjection\Registry $registry)
+ {
+ $this->_registry = $registry;
+
+ return $this;
+ }
+
+ public function getRegistry()
+ {
+ return $this->_registry;
+ }
+
+ public function bindValue($argumentValue)
+ {
+ $this->_value = $argumentValue;
+ $this->_type = self::TYPE_VALUE;
+
+ return $this;
+ }
+
+ public function bindVariable(&$argumentVariable)
+ {
+ $this->_value = &$argumentVariable;
+ $this->_type = self::TYPE_VARIABLE;
+
+ return $this;
+ }
+
+ public function bindRegistryEntry($registryKey)
+ {
+ $this->_value = $registryKey;
+ $this->_type = self::TYPE_REGISTRY;
+
+ return $this;
+ }
+
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ public function getValue()
+ {
+ return $this->_value;
+ }
+
+ public function getReflector()
+ {
+ return $this->_reflector;
+ }
+
+ public function setReflector(\ReflectionParameter $reflector)
+ {
+ $this->_reflector = $reflector;
+
+ return $this;
+ }
+
+ public function compileInto(Array &$compiledArgs)
+ {
+ $position = $this->getReflector()->getPosition();
+
+ if ($this->_type === self::TYPE_VALUE) {
+ $compiledArgs[$position] = $this->_value;
+ } else if ($this->_type === self::TYPE_VARIABLE) {
+ $compiledArgs[$position] = &$this->_value;
+ } else if ($this->_type === self::TYPE_REGISTRY) {
+ if (($registry = $this->getRegistry()) === null) {
+ throw new CoreException\DependencyInjection\RuntimeException('No registry available');
+ }
+
+ $compiledArgs[$position] = $registry->get($this->_value);
+ }
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/ClassDefinition.php b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/ClassDefinition.php
new file mode 100644
index 0000000..d72783d
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/ClassDefinition.php
@@ -0,0 +1,288 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\DependencyInjection\Definition;
+
+use Wootook\Core\Base\Service,
+ Wootook\Core\Config,
+ Wootook\Core\DependencyInjection,
+ Wootook\Core\Exception as CoreException;
+
+/**
+ * Class definition for the DependencyInjection component, used to define a
+ * class's dependencies.
+ *
+ * @package WootookCore
+ * @subpackage DependencyInjection
+ * @author Grégory PLANCHAT
+ * @see http://wootook.org/
+ */
+class ClassDefinition
+{
+ /**
+ * @var string
+ */
+ protected $_className = null;
+
+ /**
+ * @var \ReflectionClass
+ */
+ protected $_reflector = null;
+
+ /**
+ * @var array
+ */
+ protected $_methodDefinitions = array();
+
+ /**
+ * @var null|\Wootook\Core\DependencyInjection\Registry
+ */
+ protected $_registry = null;
+
+ /**
+ * @var string
+ */
+ protected $_methodDefinitionClassName = 'Wootook\\Core\\DependencyInjection\\Definition\\MethodDefinition';
+
+ /**
+ * @param string $className
+ * @param null|string $methodDefinitionHandlerClass
+ */
+ public function __construct($className, DependencyInjection\Registry $registry = null, $methodDefinitionClassName = null)
+ {
+ $this->_className = $className;
+ try {
+ $this->_reflector = new \ReflectionClass($className);
+ } catch (\ReflectionException $e) {
+ throw new CoreException\DependencyInjection\BadMethodCallException($e->getMessage(), $e->getCode(), $e);
+ }
+
+ if ($methodDefinitionClassName !== null) {
+ $this->setMethodDefinitionClassName($methodDefinitionClassName);
+ }
+
+ if ($registry !== null) {
+ $this->setRegistry($registry);
+ }
+ }
+
+ /**
+ * @param \Wootook\Core\DependencyInjection\Registry $registry
+ * @return ClassDefinition
+ */
+ public function setRegistry(DependencyInjection\Registry $registry)
+ {
+ $this->_registry = $registry;
+
+ return $this;
+ }
+
+ /**
+ * @return null|\Wootook\Core\DependencyInjection\Registry
+ */
+ public function getRegistry()
+ {
+ return $this->_registry;
+ }
+
+ /**
+ * @param string $methodName
+ * @return \Wootook\Core\DependencyInjection\Definition\MethodDefinition
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function getMethodDefinition($methodName, $registerInstanceIfNew = false)
+ {
+ if (!is_string($methodName)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Method names only accept string.');
+ }
+
+ if (isset($this->_methodDefinitions[$methodName])) {
+ return $this->_methodDefinitions[$methodName];
+ }
+
+ $definition = $this->initMethodDefinition($methodName);
+ if ($registerInstanceIfNew === true) {
+ $this->registerMethodDefinition($methodName, $definition);
+ }
+ return $definition;
+ }
+
+ /**
+ * @param string $methodName
+ * @return \Wootook\Core\DependencyInjection\Definition\MethodDefinition
+ */
+ public function initMethodDefinition($methodName)
+ {
+ if (!is_string($methodName)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Method names only accept string.');
+ }
+
+ $class = $this->getMethodDefinitionClassName();
+
+ return new $class($this, $methodName, $this->getRegistry());
+ }
+
+ /**
+ * @param $methodName
+ * @param MethodDefinition $methodDefinition
+ * @return ClassDefinition
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function registerMethodDefinition($methodName, MethodDefinition $methodDefinition)
+ {
+ if (!is_string($methodName)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Method names only accept string.');
+ }
+
+ $this->_methodDefinitions[$methodName] = $methodDefinition;
+
+ return $this;
+ }
+
+ /**
+ * @param $methodName
+ * @return ClassDefinition
+ */
+ public function addMethodDefinition($methodName)
+ {
+ $this->registerMethodDefinition($methodName, $this->initMethodDefinition($methodName));
+
+ return $this;
+ }
+
+ /**
+ * @param $methodName
+ * @param MethodDefinition $definition
+ * @return ClassDefinition
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function setMethodDefinition($methodName, MethodDefinition $definition)
+ {
+ if (!is_string($methodName)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Method names only accept string.');
+ }
+
+ $this->_methodDefinitions[$methodName] = $definition;
+
+ return $this;
+ }
+
+ /**
+ * @param $methodDefinitionClassName
+ * @return string
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function setMethodDefinitionClassName($methodDefinitionClassName)
+ {
+ if (!is_string($methodDefinitionClassName)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Class names only accept string.');
+ }
+
+ $this->_methodDefinitionClassName = $methodDefinitionClassName;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMethodDefinitionClassName()
+ {
+ return $this->_methodDefinitionClassName;
+ }
+
+ /**
+ * @return array
+ */
+ public function getAllMethodDefinitions()
+ {
+ return $this->_methodDefinitions;
+ }
+
+ /**
+ * @param array $args
+ * @return object
+ * @throws \Wootook\Core\Exception\DependencyInjection\RuntimeException
+ */
+ public function newInstance(Array $args = array())
+ {
+ try {
+ if ($this->getReflector()->hasMethod('__construct')) {
+ $methodDefinition = $this->getMethodDefinition('__construct');
+
+ return $this->getReflector()->newInstanceArgs($methodDefinition->compileArgs($args));
+ } else {
+ return $this->getReflector()->newInstance();
+ }
+ } catch (\ReflectionException $e) {
+ throw new CoreException\DependencyInjection\RuntimeException('Could not instantiate class : constructor may be non-public.', null, $e);
+ }
+ }
+
+ /**
+ * @return mixed
+ * @throws \Wootook\Core\Exception\DependencyInjection\RuntimeException
+ */
+ public function newInstanceWithoutConstructor()
+ {
+ try {
+ return $this->getReflector()->newInstanceWithoutConstructor();
+ } catch (\ReflectionException $e) {
+ throw new CoreException\DependencyInjection\RuntimeException('Could not instantiate class : may be a PHP-internal class.', null, $e);
+ }
+ }
+
+ /**
+ * @return array
+ */
+ public function reset()
+ {
+ return $this->_methodDefinitions = array();
+ }
+
+ /**
+ * @return null|\ReflectionClass
+ */
+ public function getReflector()
+ {
+ return $this->_reflector;
+ }
+
+ /**
+ * @param \ReflectionClass $reflector
+ * @return ClassDefinition
+ */
+ public function setReflector(\ReflectionClass $reflector)
+ {
+ $this->_reflector = $reflector;
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/MethodDefinition.php b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/MethodDefinition.php
new file mode 100644
index 0000000..6e5720e
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Definition/MethodDefinition.php
@@ -0,0 +1,298 @@
+_classDefinition = $classDefinition;
+
+ $this->_methodName = $methodName;
+
+ try {
+ $this->setReflector($classDefinition->getReflector()->getMethod($methodName));
+ } catch (\ReflectionException $e) {
+ throw new CoreException\DependencyInjection\BadMethodCallException($e->getMessage(), $e->getCode(), $e);
+ }
+
+ if ($argumentDefinitionClassName !== null) {
+ $this->setArgumentDefinitionClassName($argumentDefinitionClassName);
+ }
+
+ if ($registry !== null) {
+ $this->setRegistry($registry);
+ }
+ }
+
+ /**
+ * @param \Wootook\Core\DependencyInjection\Registry $registry
+ * @return MethodDefinition
+ */
+ public function setRegistry(DependencyInjection\Registry $registry)
+ {
+ $this->_registry = $registry;
+
+ return $this;
+ }
+
+ /**
+ * @return null|\Wootook\Core\DependencyInjection\Registry
+ */
+ public function getRegistry()
+ {
+ return $this->_registry;
+ }
+
+ /**
+ * @param int|string $argumentPosition
+ * @return \Wootook\Core\DependencyInjection\Definition\ArgumentDefinition
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function getArgumentDefinition($argumentPosition, $registerInstanceIfNew = false)
+ {
+ if (is_string($argumentPosition) && isset($this->_argumentIndex[$argumentPosition])) {
+ $argumentPosition = $this->_argumentIndex[$argumentPosition];
+ }
+
+ if (!is_int($argumentPosition)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Argument could only be found by position or by name.');
+ }
+
+ if (isset($this->_argumentDefinitions[$argumentPosition])) {
+ return $this->_argumentDefinitions[$argumentPosition];
+ }
+
+ $definition = $this->initArgumentDefinition($argumentPosition);
+ if ($registerInstanceIfNew === true) {
+ $this->registerArgumentDefinition($argumentPosition, $definition);
+ }
+ return $definition;
+ }
+
+ public function initArgumentDefinition($argumentPosition)
+ {
+ if (is_string($argumentPosition) && isset($this->_argumentIndex[$argumentPosition])) {
+ $argumentPosition = $this->_argumentIndex[$argumentPosition];
+ }
+
+ if (!is_int($argumentPosition)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Argument could only be found by position or by name.');
+ }
+
+ $class = $this->getArgumentDefinitionClassName();
+
+ return new $class($this, $argumentPosition, $this->getRegistry());
+ }
+
+ public function registerArgumentDefinition($argumentPosition, ArgumentDefinition $argumentDefinition)
+ {
+ if (is_string($argumentPosition) && isset($this->_argumentIndex[$argumentPosition])) {
+ $argumentName = $argumentPosition;
+ $argumentPosition = $this->_argumentIndex[$argumentPosition];
+ } else if (($reflector = $argumentDefinition->getReflector()) instanceof \ReflectionParameter) {
+ $argumentName = $reflector->getName();
+ } else {
+ $argumentName = null;
+ }
+
+ if (!is_int($argumentPosition)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Argument could only be found by position or by name.');
+ }
+
+ $this->_argumentDefinitions[$argumentPosition] = $argumentDefinition;
+ if ($argumentName !== null) {
+ $this->_argumentIndex[$argumentName] = $argumentPosition;
+ }
+
+ return $this;
+ }
+
+ public function addArgumentDefinition($argumentPosition)
+ {
+ $this->registerArgumentDefinition($argumentPosition, $this->initArgumentDefinition($argumentPosition));
+
+ return $this;
+ }
+
+ public function setArgumentDefinition($argumentPosition, ArgumentDefinition $definition)
+ {
+ if (is_string($argumentPosition) && isset($this->_argumentIndex[$argumentPosition])) {
+ $argumentPosition = $this->_argumentIndex[$argumentPosition];
+ }
+
+ if (!is_int($argumentPosition)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Argument could only be found by position or by name.');
+ }
+
+ $this->_argumentDefinitions[$argumentPosition] = $definition;
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getAllArgumentDefinitions()
+ {
+ return $this->_argumentDefinitions;
+ }
+
+ /**
+ * @return array
+ */
+ public function reset()
+ {
+ $this->_argumentDefinitions = array();
+
+ return $this;
+ }
+
+ public function setArgumentDefinitionClassName($argumentDefinitionClassName)
+ {
+ if (!is_string($argumentDefinitionClassName)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Class names only accept string.');
+ }
+
+ $this->_argumentDefinitionClassName = $argumentDefinitionClassName;
+
+ return $this;
+ }
+
+ public function getArgumentDefinitionClassName()
+ {
+ return $this->_argumentDefinitionClassName;
+ }
+
+ /**
+ * @param string|int $argumentPosition
+ * @param mixed $argumentValue
+ * @return MethodDefinition
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function bindArgumentValue($argumentPosition, $argumentValue)
+ {
+ $this->getArgumentDefinition($argumentPosition, true)->bindValue($argumentValue);
+
+ return $this;
+ }
+
+ /**
+ * @param string|int $argumentPosition
+ * @param mixed $argumentVariable
+ * @return MethodDefinition
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function bindArgumentVariable($argumentPosition, &$argumentVariable)
+ {
+ $this->getArgumentDefinition($argumentPosition, true)->bindVariable($argumentVariable);
+
+ return $this;
+ }
+
+ /**
+ * @param string|int $argumentPosition
+ * @param string $registryKey
+ * @return MethodDefinition
+ * @throws \Wootook\Core\Exception\DependencyInjection\RuntimeException
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function bindArgumentRegistryEntry($argumentPosition, $registryKey)
+ {
+ $this->getArgumentDefinition($argumentPosition, true)->bindRegistryEntry($registryKey);
+
+ return $this;
+ }
+
+ /**
+ * @return \ReflectionMethod
+ */
+ public function getReflector()
+ {
+ return $this->_reflector;
+ }
+
+ /**
+ * @param \ReflectionMethod $reflector
+ * @return MethodDefinition
+ */
+ public function setReflector(\ReflectionMethod $reflector)
+ {
+ $this->_reflector = $reflector;
+
+ foreach ($this->_reflector->getParameters() as $argumentReflector) {
+ $argumentName = $argumentReflector->getName();
+ $argumentPosition = $argumentReflector->getPosition();
+
+ $this->_argumentIndex[$argumentName] = $argumentPosition;
+ $this->_argumentReflectors[$argumentPosition] = $argumentReflector;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param $argumentPosition
+ * @return \ReflectionParameter
+ * @throws \Wootook\Core\Exception\DependencyInjection\InvalidArgumentException
+ */
+ public function getArgumentReflector($argumentPosition)
+ {
+ if (is_string($argumentPosition) && isset($this->_argumentIndex[$argumentPosition])) {
+ $argumentPosition = $this->_argumentIndex[$argumentPosition];
+ }
+
+ if (!is_int($argumentPosition) || !isset($this->_argumentReflectors[$argumentPosition])) {
+ throw new CoreException\DependencyInjection\BadMethodCallException('Argument does not exist.');
+ }
+
+ return $this->_argumentReflectors[$argumentPosition];
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Factory.php b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Factory.php
new file mode 100644
index 0000000..bbff31f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Factory.php
@@ -0,0 +1,133 @@
+setRegistry($registry);
+ }
+
+ if ($classDefinitionClassName !== null) {
+ $this->setClassDefinitionClassName($classDefinitionClassName);
+ }
+ }
+
+ public function setRegistry(Registry $registry)
+ {
+ $this->_registry = $registry;
+
+ return $this;
+ }
+
+ public function getRegistry()
+ {
+ if ($this->_registry === null) {
+ $this->_registry = new Registry($this->app());
+ }
+
+ return $this->_registry;
+ }
+
+ public function getClassDefinition($className, $registerInstanceIfNew = false)
+ {
+ if (!is_string($className)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Class names only accept string.');
+ }
+
+ if (isset($this->_classDefinitions[$className])) {
+ return $this->_classDefinitions[$className];
+ }
+
+ $definition = $this->initClassDefinition($className);
+ if ($registerInstanceIfNew === true) {
+ $this->registerClassDefinition($className, $definition);
+ }
+ return $definition;
+
+ return $this->initClassDefinition($className);
+ }
+
+ public function initClassDefinition($className)
+ {
+ $class = $this->getClassDefinitionClassName();
+
+ return new $class($className);
+ }
+
+ public function registerClassDefinition($className, Definition\ClassDefinition $classDefinition)
+ {
+ if (!is_string($className)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Class names only accept string.');
+ }
+
+ $this->_classDefinitions[$className] = $classDefinition;
+
+ return $this;
+ }
+
+ public function addClassDefinition($className)
+ {
+ $this->registerClassDefinition($className, $this->initClassDefinition($className));
+
+ return $this;
+ }
+
+ public function setClassDefinition($className, Definition\ClassDefinition $definition)
+ {
+ if (!is_string($className)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Class names only accept string.');
+ }
+
+ $this->_classDefinitions[$className] = $definition;
+
+ return $this;
+ }
+
+ public function getAllClassDefinitions()
+ {
+ return $this->_classDefinitions;
+ }
+
+ public function setClassDefinitionClassName($classDefinitionClassName)
+ {
+ if (!is_string($classDefinitionClassName)) {
+ throw new CoreException\DependencyInjection\InvalidArgumentException('Class names only accept string.');
+ }
+
+ $this->_classDefinitionClassName = $classDefinitionClassName;
+
+ return $this;
+ }
+
+ public function getClassDefinitionClassName()
+ {
+ return $this->_classDefinitionClassName;
+ }
+
+ public function reset()
+ {
+ return $this->_classDefinitions = array();
+ }
+
+ public function __invoke($className, Array $additionalArguments = array())
+ {
+ $definition = $this->getClassDefinition($className);
+
+ return $definition->newInstance($additionalArguments);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Registry.php b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Registry.php
new file mode 100644
index 0000000..df4c3fb
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/DependencyInjection/Registry.php
@@ -0,0 +1,60 @@
+_instances = array();
+
+ return $this;
+ }
+
+ public function add($identifier, $value)
+ {
+ if ($this->has($identifier)) {
+ throw new CoreException\RuntimeException('Instance already exists.');
+ }
+ $this->set($identifier, $value);
+ }
+
+ public function set($identifier, $value)
+ {
+ if (isset($this->_instances[$identifier])) {
+ throw new CoreException\BadMethodCallException;
+ }
+ $this->_instances[$identifier] = $value;
+
+ return $this;
+ }
+
+ public function get($identifier)
+ {
+ return $this->_instances[$identifier];
+ }
+
+ public function delete($identifier)
+ {
+ unset($this->_instances[$identifier]);
+
+ return $this;
+ }
+
+ public function has($identifier)
+ {
+ return isset($this->_instances[$identifier]);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Email/Email.php b/src/application/modules/WootookCore/src/Wootook/Core/Email/Email.php
new file mode 100644
index 0000000..df01526
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Email/Email.php
@@ -0,0 +1,104 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Email;
+
+use Wootook\Core,
+ Wootook\Core\Exception as CoreException,
+ Wootook\Core\Email\Transport,
+ Wootook\Core\Email\Part;
+
+/**
+ * Email management class
+ */
+class Email
+{
+ /**
+ * @var Transport\Transport
+ */
+ protected $_transport = null;
+
+ /**
+ * @param null|Transport\Transport $transport
+ */
+ public function __construct(Transport\Transport $transport = null)
+ {
+ if ($transport === null) {
+ $transport = new Transport\Sendmail();
+ }
+ $this->setTransport($transport);
+ }
+
+ /**
+ * @param Transport\Transport $transport
+ */
+ public function setTransport(Transport\Transport $transport)
+ {
+ $this->_transport = $transport;
+ }
+
+ /**
+ * @return Transport\Transport
+ */
+ public function getTransport()
+ {
+ return $this->_transport;
+ }
+
+ /**
+ * @param string|array $to
+ * @param string|array $from
+ * @param string $subject
+ * @param $body
+ * @param array $headers
+ * @return Core\Email
+ * @throws CoreException\RuntimeException
+ */
+ public function send($to, $from, $subject, $body, Array $headers = array())
+ {
+ try {
+ $this->_transport
+ ->addRecipient($to)
+ ->setFrom($from)
+ ->setSubject($subject)
+ ->addPart(new Part\Part($body))
+ ->addHeaders($headers)
+ ->connect()
+ ->send()
+ ;
+ } catch (CoreException\RuntimeException $e) {
+ throw new CoreException\RuntimeException('Could not send mail.', null, $e);
+ }
+
+ $this->_transport->disconnect();
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Email/Part/Part.php b/src/application/modules/WootookCore/src/Wootook/Core/Email/Part/Part.php
new file mode 100644
index 0000000..ea8d79e
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Email/Part/Part.php
@@ -0,0 +1,46 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Email\Part;
+
+class Part
+{
+ protected $_content = null;
+
+ public function __construct($content, $mime = 'text/plain')
+ {
+ $this->_content = $content;
+ }
+
+ public function render()
+ {
+ return $this->_content;
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Email/Transport/Sendmail.php b/src/application/modules/WootookCore/src/Wootook/Core/Email/Transport/Sendmail.php
similarity index 69%
rename from src/application/code/core/Wootook/Core/Email/Transport/Sendmail.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Email/Transport/Sendmail.php
index 165247a..4a7f066 100644
--- a/src/application/code/core/Wootook/Core/Email/Transport/Sendmail.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Email/Transport/Sendmail.php
@@ -1,7 +1,40 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Email_Transport_Sendmail
- implements Wootook_Core_Email_Transport_Transport
+namespace Wootook\Core\Email\Transport;
+
+use Wootook\Core\Email\Part,
+ Wootook\Core\Exception as CoreException;
+
+class Sendmail
+ implements Transport
{
protected static $_defaultHeaders = array();
@@ -89,7 +122,7 @@ class Wootook_Core_Email_Transport_Sendmail
return $this;
}
- public function addPart(Wootook_Core_Email_Part_Part $part)
+ public function addPart(Part\Part $part)
{
$this->_parts[] = $part;
@@ -154,9 +187,9 @@ class Wootook_Core_Email_Transport_Sendmail
$this->addHeader('To', implode(',', $this->_recipients));
if (!mail(implode(',', $this->_recipients), $this->_subject, $content, implode("\r\n", $this->_headers))) {
- throw new Wootook_Core_Exception_RuntimeException('Could not send mail.');
+ throw new CoreException\RuntimeException('Could not send mail.');
}
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Email/Transport/Transport.php b/src/application/modules/WootookCore/src/Wootook/Core/Email/Transport/Transport.php
new file mode 100644
index 0000000..371f40a
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Email/Transport/Transport.php
@@ -0,0 +1,54 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Email\Transport;
+
+use Wootook\Core\Email\Part;
+
+interface Transport
+{
+ public function setFrom($from);
+ public function addRecipient($recipient);
+ public function setSubject($subject);
+ public function addHeader($name, $value);
+ public function addPart(Part\Part $part);
+
+ public function reset();
+ public function clearFrom();
+ public function clearHeaders();
+ public function clearRecipients();
+ public function clearSubject();
+ public function clearParts();
+
+ public function connect();
+ public function disconnect();
+
+ public function send();
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Event/Break.php b/src/application/modules/WootookCore/src/Wootook/Core/Event/Break.php
new file mode 100644
index 0000000..4ca10bb
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Event/Break.php
@@ -0,0 +1,38 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Event;
+
+use Wootook\Core\Exception as CoreException;
+
+class EventBreak
+ extends CoreException\Exception
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Event/Event.php b/src/application/modules/WootookCore/src/Wootook/Core/Event/Event.php
new file mode 100644
index 0000000..3d37596
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Event/Event.php
@@ -0,0 +1,117 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Event;
+
+use Wootook\Core,
+ Wootook\Core\Exception as CoreException;
+
+/**
+ * Event
+ */
+class Event
+ extends Core\Base\BaseObject
+{
+ protected $_propagationStopped = false;
+
+ public function __call($method, $params)
+ {
+ $prefix = substr($method, 0, 3);
+ $dataKey = substr($method, 3);
+
+ $dataKey = str_replace(' ', '', ucwords(str_replace('-', ' ', $dataKey)));
+ $dataKey = str_replace(' ', '_', ucwords(str_replace('.', ' ', $dataKey)));
+
+ switch ($prefix) {
+ case 'get':
+ return $this->getData($dataKey);
+ case 'set':
+ return $this->setData($dataKey, isset($params[0]) ? $params[0] : null);
+ case 'uns':
+ return $this->unsetData($dataKey);
+ case 'has':
+ return $this->hasData($dataKey);
+ }
+
+ throw new CoreException\RuntimeException(sprintf('Method %d does not exist.', $method));
+ }
+
+ public function setType($type)
+ {
+ return $this->setData('type', $type);
+ }
+
+ public function getType()
+ {
+ return $this->getData('type');
+ }
+
+ public function hasType()
+ {
+ return $this->hasData('type');
+ }
+
+ public function unsType()
+ {
+ return $this->unsetData('type');
+ }
+
+ public function setTarget($target)
+ {
+ return $this->setData('target', $target);
+ }
+
+ public function getTarget()
+ {
+ return $this->getData('target');
+ }
+
+ public function hasTarget()
+ {
+ return $this->hasData('target');
+ }
+
+ public function unsTarget()
+ {
+ return $this->unsetData('target');
+ }
+
+ public function stopPropagation()
+ {
+ $this->_propagationStopped = true;
+
+ return $this;
+ }
+
+ public function isPropagationStopped()
+ {
+ return $this->_propagationStopped;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Event/EventTarget.php b/src/application/modules/WootookCore/src/Wootook/Core/Event/EventTarget.php
new file mode 100644
index 0000000..0808e9e
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Event/EventTarget.php
@@ -0,0 +1,94 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Event;
+
+/**
+ * EventTarget
+ */
+trait EventTarget
+{
+ protected $_eventListeners = array();
+
+ /**
+ * @param $type
+ * @param Closure $listener
+ * @return EventTarget
+ */
+ public function registerEventListener($type, Closure $listener)
+ {
+ if (!isset($this->_eventListeners[$type])) {
+ $this->_eventListeners[$type] = array();
+ }
+ $this->_eventListeners[$type][] = $listener;
+
+ return $this;
+ }
+
+ /**
+ * @param $type
+ * @param Closure $listener
+ * @return EventTarget
+ */
+ public function unregisterEventListener($type, Closure $listener)
+ {
+ if (!isset($this->_eventListeners[$type])) {
+ return $this;
+ }
+ $key = array_search($listener, $this->_eventListeners[$type]);
+ unset($this->_eventListeners[$type][$key]);
+
+ return $this;
+ }
+
+ /**
+ * @param $type
+ * @return Event
+ */
+ public function dispatchEvent($type, Array $datas = array())
+ {
+ if (!isset($this->_eventListeners[$type])) {
+ return $this;
+ }
+
+ $event = new Event($datas);
+ $event->setType($type);
+ $event->setTarget($this);
+
+ foreach ($this->_eventListeners[$type] as $eventListener) {
+ $eventListener($event);
+ if ($event->isPropagationStopped()) {
+ break;
+ }
+ }
+
+ return $event;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/BadMethodCallException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/BadMethodCallException.php
new file mode 100644
index 0000000..0dacf2f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/BadMethodCallException.php
@@ -0,0 +1,37 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class BadMethodCallException
+ extends \BadMethodCallException
+ implements CoreException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/CoreException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/CoreException.php
new file mode 100644
index 0000000..ef691e2
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/CoreException.php
@@ -0,0 +1,40 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+use Wootook;
+
+/**
+ * Base exception identifier for the Core module
+ */
+interface CoreException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/DataAccessException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/DataAccessException.php
new file mode 100644
index 0000000..b7fc6da
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/DataAccessException.php
@@ -0,0 +1,36 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class DataAccessException
+ extends RuntimeException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/AdapterError.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/AdapterError.php
new file mode 100644
index 0000000..90e41c7
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/AdapterError.php
@@ -0,0 +1,53 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception\Database;
+
+use Wootook\Core\Database\Adapter,
+ Wootook\Core\Exception as CoreException;
+
+class AdapterError
+ extends CoreException\RuntimeException
+ implements Error
+{
+ protected $_adapter = null;
+
+ public function __construct(Adapter\Adapter $adapter, $message = null, $code = null, $previous = null)
+ {
+ parent::__construct($message, null, $previous);
+
+ $this->_adapter = $adapter;
+ }
+
+ public function getAdapter()
+ {
+ return $this->_adapter;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/Error.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/Error.php
new file mode 100644
index 0000000..c1c30b1
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/Error.php
@@ -0,0 +1,35 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception\Database;
+
+interface Error
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/StatementError.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/StatementError.php
new file mode 100644
index 0000000..7876465
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Database/StatementError.php
@@ -0,0 +1,53 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception\Database;
+
+use Wootook\Core\Database\Statement,
+ Wootook\Core\Exception as CoreException;
+
+class StatementError
+ extends CoreException\RuntimeException
+ implements Error
+{
+ protected $_statement = null;
+
+ public function __construct(Statement\Statement $statement, $message = null, $code = null, $previous = null)
+ {
+ parent::__construct($message, $code, $previous);
+
+ $this->_statement = $statement;
+ }
+
+ public function getStatement()
+ {
+ return $this->_statement;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/BadMethodCallException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/BadMethodCallException.php
new file mode 100644
index 0000000..4b19b85
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/BadMethodCallException.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception\DependencyInjection;
+
+use Wootook\Core\Exception;
+
+class BadMethodCallException
+ extends \BadMethodCallException
+ implements Exception\CoreException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/InvalidArgumentException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/InvalidArgumentException.php
new file mode 100644
index 0000000..d24998d
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/InvalidArgumentException.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception\DependencyInjection;
+
+use Wootook\Core\Exception;
+
+class InvalidArgumentException
+ extends \InvalidArgumentException
+ implements Exception\CoreException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/RuntimeException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/RuntimeException.php
new file mode 100644
index 0000000..1185dad
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/DependencyInjection/RuntimeException.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception\DependencyInjection;
+
+use Wootook\Core\Exception;
+
+class RuntimeException
+ extends \RuntimeException
+ implements Exception\CoreException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/Deprecated.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Deprecated.php
new file mode 100644
index 0000000..138c74e
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Deprecated.php
@@ -0,0 +1,37 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class Deprecated
+ extends RuntimeException
+{
+
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/Exception.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Exception.php
new file mode 100644
index 0000000..1c594e0
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/Exception.php
@@ -0,0 +1,37 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class Exception
+ extends \Exception
+ implements CoreException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/GameError.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/GameError.php
new file mode 100644
index 0000000..6738dc9
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/GameError.php
@@ -0,0 +1,37 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class GameError
+ extends RuntimeException
+{
+
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/InvalidArgumentException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/InvalidArgumentException.php
new file mode 100644
index 0000000..d1d5838
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/InvalidArgumentException.php
@@ -0,0 +1,37 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class InvalidArgumentException
+ extends \InvalidArgumentException
+ implements CoreException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/LayoutException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/LayoutException.php
new file mode 100644
index 0000000..81d9822
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/LayoutException.php
@@ -0,0 +1,36 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class LayoutException
+ extends RuntimeException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/RuntimeException.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/RuntimeException.php
new file mode 100644
index 0000000..4dd710f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/RuntimeException.php
@@ -0,0 +1,37 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class RuntimeException
+ extends \RuntimeException
+ implements CoreException
+{
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Exception/WebsiteError.php b/src/application/modules/WootookCore/src/Wootook/Core/Exception/WebsiteError.php
new file mode 100644
index 0000000..00d4292
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Exception/WebsiteError.php
@@ -0,0 +1,37 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Exception;
+
+class WebsiteError
+ extends RuntimeException
+{
+
+}
diff --git a/src/application/code/core/Wootook/Core/Form/ElementAbstract.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Element/BaseElement.php
similarity index 61%
rename from src/application/code/core/Wootook/Core/Form/ElementAbstract.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Form/Element/BaseElement.php
index f718c34..bf04160 100644
--- a/src/application/code/core/Wootook/Core/Form/ElementAbstract.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Element/BaseElement.php
@@ -1,6 +1,39 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-abstract class Wootook_Core_Form_ElementAbstract
+namespace Wootook\Core\Form\Element;
+
+use Wootook\Core\Form,
+ Wootook\Core\Form\Validator;
+
+abstract class BaseElement
{
protected $_name = null;
protected $_form = null;
@@ -10,7 +43,7 @@ abstract class Wootook_Core_Form_ElementAbstract
protected $_validators = array();
- public function __construct($name, $params = array(), Wootook_Core_Form $form = null)
+ public function __construct($name, $params = array(), Form\Form $form = null)
{
if ($form !== null) {
$this->setForm($form);
@@ -82,7 +115,7 @@ abstract class Wootook_Core_Form_ElementAbstract
return $this;
}
- public function setForm(Wootook_Core_Form $form)
+ public function setForm(Form\Form $form)
{
$this->_form = $form;
@@ -106,7 +139,7 @@ abstract class Wootook_Core_Form_ElementAbstract
return $this;
}
- public function addValidator(Wootook_Core_Form_ValidatorAbstract $validator, $name = null)
+ public function addValidator(Validator\BaseValidator $validator, $name = null)
{
if ($name === null) {
$this->_validators = array();
@@ -142,4 +175,4 @@ abstract class Wootook_Core_Form_ElementAbstract
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Element/Button.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Element/Button.php
new file mode 100644
index 0000000..d573d52
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Element/Button.php
@@ -0,0 +1,40 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Element;
+
+class Button
+ extends BaseElement
+{
+ public function getType()
+ {
+ return 'button';
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Element/Text.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Element/Text.php
new file mode 100644
index 0000000..2df3e25
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Element/Text.php
@@ -0,0 +1,40 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Element;
+
+class Text
+ extends BaseElement
+{
+ public function getType()
+ {
+ return 'text';
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/ElementLoader.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/ElementLoader.php
new file mode 100644
index 0000000..63a7b25
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/ElementLoader.php
@@ -0,0 +1,70 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form;
+
+use Wootook\Core\Profiler,
+ Wootook\Core\PluginLoader;
+
+class ElementLoader
+ extends PluginLoader\PluginLoader
+{
+ protected $_form = null;
+
+ public function __construct(Form $form, Array $namespaces = array())
+ {
+ $this->_form = $form;
+
+ foreach ($namespaces as $namespace => $path) {
+ if (is_int($namespace)) {
+ $this->registerNamespace($path);
+ } else {
+ $this->registerNamespace($namespace, $path);
+ }
+ }
+ }
+
+ protected function _load($className, $useSingleton, Array $constructorParams = array())
+ {
+ $reflection = new \ReflectionClass($className);
+ if ($useSingleton && $reflection->implementsInterface('Wootook\\Core\\Base\\Singleton')) {
+ $method = $reflection->getMethod('getSingleton');
+ return $method->invoke(null);
+ }
+
+ try {
+ return $reflection->newInstance($this->_form);
+ } catch (\ReflectionException $e) {
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException($e);
+ return null;
+ }
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Form.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Form.php
similarity index 65%
rename from src/application/code/core/Wootook/Core/Form.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Form/Form.php
index 75137de..5ee6929 100644
--- a/src/application/code/core/Wootook/Core/Form.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Form.php
@@ -28,49 +28,73 @@
*
*/
+namespace Wootook\Core\Form;
+
+use Wootook\Core\Exception as CoreException,
+ Wootook\Core\Model,
+ Wootook\Core\Form\Element,
+ Wootook\Core\Mvc\Controller\Response,
+ Wootook\Core\Mvc\Controller\Request,
+ Wootook\Core\Profiler;
+
+
/**
*
* Enter description here ...
* @author Greg
*
*/
-class Wootook_Core_Form
+class Form
{
+ /**
+ * Form elements container
+ *
+ * @var array
+ */
protected $_elements = array();
+ /**
+ * current MVC request management instance
+ *
+ * @var Request\Http
+ */
protected $_request = null;
/**
+ * Form element instance loader
*
- * Element class loader
- * @var Wootook_Core_Form_ElementLoader
+ * @var ElementLoader
*/
protected $_elementLoader = null;
/**
+ * Form field validator instance loader
*
- * Validator class loader
- * @var Wootook_Core_Form_ValidatorLoader
+ * @var ValidatorLoader
*/
protected $_validatorLoader = null;
/**
+ * Session storage instance, used for messaging purposes
*
- * Enter description here ...
- * @var Wootook_Core_Model_Session
+ * @var Model\Session
*/
protected $_session = null;
- public function __construct(Wootook_Core_Model_Session $session, Array $elements = array())
+ /**
+ * @param Model\Session $session
+ * @param array $elements
+ */
+ public function __construct(Model\Session $session, Array $elements = array())
{
$this->_session = $session;
- $this->_elementLoader = new Wootook_Core_Form_ElementLoader($this, array(
- 'Wootook_Core_Form_Element_' => 'Wootook/Core/Form/Element'
+ $this->_elementLoader = new ElementLoader($this, array(
+ 'Wootook\\Core\\Form\\Element' => 'Wootook/Core/Form/Element'
));
- $this->_validatorLoader = new Wootook_Core_Form_ValidatorLoader($this, array(
- 'Wootook_Core_Form_Validator_' => 'Wootook/Core/Form/Validator'
+ $this->_validatorLoader = new ValidatorLoader($this, array(
+ 'Wootook\\Core\\Form\\Validator' => 'Wootook/Core/Form/Validator'
));
$this->addElement('__formkey', 'text', array('form_key' => 'formKey'));
@@ -78,7 +102,7 @@ class Wootook_Core_Form
foreach ($elements as $elementName => $elementConfig) {
if (is_string($elementConfig)) {
$this->addElement($elementName, $elementConfig);
- } else if ($elementConfig instanceof Wootook_Core_Form_ElementAbstract) {
+ } else if ($elementConfig instanceof Element\BaseElement) {
$this->addElement($elementName, $elementConfig);
} else {
if (isset($elementConfig['validators'])) {
@@ -90,6 +114,11 @@ class Wootook_Core_Form
}
}
+ /**
+ * Validated the form field values
+ *
+ * @return bool
+ */
public function validate()
{
foreach ($this->_elements as $element) {
@@ -101,23 +130,23 @@ class Wootook_Core_Form
}
/**
+ * Add a field element to the current form
*
- * Enter description here ...
* @param string $name
- * @param string|Wootook_Core_Form_ElementAbstract $type
- * @return Wootook_Core_Form
+ * @param string|Element\BaseElement $type
+ * @return Form
*/
public function addElement($name, $type = 'text', Array $validators = array())
{
- if ($type instanceof Wootook_Core_Form_ElementAbstract) {
+ if ($type instanceof Element\BaseElement) {
$this->_elements[$name] = $type;
$this->_elements[$name]->setForm($this);
} else {
$element = $this->_elementLoader->load($type);
if ($element === null) {
- Wootook_Core_ErrorProfiler::getSingleton()
- ->addException(new Wootook_Core_Exception_RuntimeException(sprintf('Element %1$s (type: %2$s) could not be created.', $name, $type)));
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\RuntimeException(sprintf('Element %1$s (type: %2$s) could not be created.', $name, $type)));
return $this;
}
$element->setForm($this);
@@ -126,14 +155,14 @@ class Wootook_Core_Form
$this->_elements[$name]->setName($name);
foreach ($validators as $validatorName => $validatorType) {
- if ($validatorType instanceof Wootook_Core_Form_ElementAbstract) {
+ if ($validatorType instanceof Element\BaseElement) {
$this->_elements[$name]->addValidator($validatorType, $validatorName);
} else {
$validator = $this->_validatorLoader->load($validatorType);
if ($validator === null) {
- Wootook_Core_ErrorProfiler::getSingleton()
- ->addException(new Wootook_Core_Exception_RuntimeException(sprintf('Validator %1$s (type: %2$s) could not be created.', $validatorName, $validatorType)));
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\RuntimeException(sprintf('Validator %1$s (type: %2$s) could not be created.', $validatorName, $validatorType)));
return $this;
}
$this->_elements[$name]->addValidator($validator, $validatorName);
@@ -144,10 +173,10 @@ class Wootook_Core_Form
}
/**
+ * Returns the form field element instance
*
- * Enter description here ...
* @param string $name
- * @return Wootook_Core_Form_ElementAbstract
+ * @return Element\BaseElement
*/
public function getElement($name)
{
@@ -159,17 +188,22 @@ class Wootook_Core_Form
}
/**
+ * Get the currently used session instance
*
- * Enter description here ...
- * @param string $name
- * @return Wootook_Core_Model_Session
+ * @return Model\Session
*/
public function getSession()
{
return $this->_session;
}
- public function setRequest(Wootook_Core_Mvc_Controller_Request_Http $request)
+ /**
+ * Use a new MVC request handler instance
+ *
+ * @param Request\Http $request
+ * @return Form
+ */
+ public function setRequest(Request\Http $request)
{
$this->_request = $request;
@@ -177,15 +211,20 @@ class Wootook_Core_Form
}
/**
+ * Get the currently used MVC request handler
*
- * Enter description here ...
- * @return Wootook_Core_Mvc_Controller_Request_Http
+ * @return Request\Http
*/
public function getRequest()
{
return $this->_request;
}
+ /**
+ * Return the validated and filtered form data
+ *
+ * @return array
+ */
public function getData()
{
$request = $this->getRequest();
@@ -198,6 +237,11 @@ class Wootook_Core_Form
return $request->getAllQueryData();
}
+ /**
+ * Populates form fields using the data provided.
+ *
+ * @param array $datas
+ */
public function populate(Array $datas = array())
{
$request = $this->getRequest();
@@ -212,4 +256,4 @@ class Wootook_Core_Form
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Alnum.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Alnum.php
new file mode 100644
index 0000000..459dbb7
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Alnum.php
@@ -0,0 +1,53 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form\Element;
+
+class Alnum
+ extends Regex
+{
+ public function __construct()
+ {
+ parent::__construct('#[^[:alnum:]]#');
+ }
+
+ public function validate(Element\BaseElement $element, $data)
+ {
+ if ($this->_validate($element, $data)) {
+ $this->_getSession($element)
+ ->addError('Field "%s" should only contain alphanumeric characters.', $element->getName());
+
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Alpha.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Alpha.php
new file mode 100644
index 0000000..98eb3cf
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Alpha.php
@@ -0,0 +1,53 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form\Element;
+
+class Alpha
+ extends Regex
+{
+ public function __construct()
+ {
+ parent::__construct('#[^[:alpha:]]#');
+ }
+
+ public function validate(Element\BaseElement $element, $data)
+ {
+ if ($this->_validate($element, $data)) {
+ $this->_getSession($element)
+ ->addError('Field "%s" should only contain alphabetic characters.', $element->getName());
+
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/BaseValidator.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/BaseValidator.php
new file mode 100644
index 0000000..3307b02
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/BaseValidator.php
@@ -0,0 +1,48 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form,
+ Wootook\Core\Form\Element;
+
+abstract class BaseValidator
+{
+ abstract public function validate(Element\BaseElement $element, $data);
+
+ protected function _getSession(Element\BaseElement $element)
+ {
+ $form = $element->getForm();
+ if (!$form instanceof Form\Form) {
+ return null;
+ }
+ return $element->getSession();
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Email.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Email.php
new file mode 100644
index 0000000..8e36960
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Email.php
@@ -0,0 +1,53 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form\Element;
+
+class Email
+ extends Regex
+{
+ public function __construct()
+ {
+ parent::__construct('#^[[:alnum:]\._\-]@[[:alnum:]\._\-]\.[a-z]{2,}$#');
+ }
+
+ public function validate(Element\BaseElement $element, $data)
+ {
+ if (!$this->_validate($element, $data)) {
+ $this->_getSession($element)
+ ->addError('Field "%s" should contain an email.', $element->getName());
+
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/FormKey.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/FormKey.php
new file mode 100644
index 0000000..32d54bd
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/FormKey.php
@@ -0,0 +1,52 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form\Element;
+
+class FormKey
+ extends BaseValidator
+{
+ public function validate(Element\BaseElement $element, $data)
+ {
+ $form = $element->getForm();
+ $session = $form->getSession();
+
+ if ($session->getFormKey(false) == $data) {
+ return true;
+ }
+
+ $this->_getSession($field)
+ ->addError('CSRF token failure.', $field->getName());
+
+ return false;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Hex.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Hex.php
new file mode 100644
index 0000000..2009a54
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Hex.php
@@ -0,0 +1,54 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form\Element;
+
+class Hex
+ extends Regex
+{
+
+ public function __construct()
+ {
+ parent::__construct('#(?:0x)?[^0-9a-f]#i');
+ }
+
+ public function validate(Element\BaseElement $element, $data)
+ {
+ if ($this->_validate($element, $data)) {
+ $this->_getSession($element)
+ ->addError('Field "%s" should only contain numeric characters.', $element->getName());
+
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Host.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Host.php
new file mode 100644
index 0000000..f8df82f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Host.php
@@ -0,0 +1,53 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form\Element;
+
+class Host
+ extends Regex
+{
+ public function __construct()
+ {
+ parent::__construct('#^[[:alnum:]\._\-]\.[a-z]{2,}$#');
+ }
+
+ public function validate(Element\BaseElement $element, $data)
+ {
+ if (!$this->_validate($element, $data)) {
+ $this->_getSession($element)
+ ->addError('Field "%s" should contain a host name.', $element->getName());
+
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Numeric.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Numeric.php
new file mode 100644
index 0000000..b3ed15b
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Numeric.php
@@ -0,0 +1,54 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form\Element;
+
+class Numeric
+ extends Regex
+{
+
+ public function __construct()
+ {
+ parent::__construct('#[^[:digit:]]#');
+ }
+
+ public function validate(Element\BaseElement $element, $data)
+ {
+ if ($this->_validate($element, $data)) {
+ $this->_getSession($element)
+ ->addError('Field "%s" should only contain numeric characters.', $element->getName());
+
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Regex.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Regex.php
new file mode 100644
index 0000000..c692ec0
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/Validator/Regex.php
@@ -0,0 +1,60 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form\Validator;
+
+use Wootook\Core\Form\Element;
+
+class Regex
+ extends BaseValidator
+{
+ protected $_expression = null;
+
+ public function __construct($expression)
+ {
+ $this->_expression = $expression;
+ }
+
+ public function validate(Element\BaseElement $element, $data)
+ {
+ if (!$this->_validate($element, $data)) {
+ $this->_getSession($element)
+ ->addError('Field "%s" does not match the validation pattern.', $element->getName());
+
+ return false;
+ }
+ return true;
+ }
+
+ protected function _validate(Element\BaseElement $element, $data)
+ {
+ return preg_match($this->_expression, $data);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Form/ValidatorLoader.php b/src/application/modules/WootookCore/src/Wootook/Core/Form/ValidatorLoader.php
new file mode 100644
index 0000000..8acc4b4
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Form/ValidatorLoader.php
@@ -0,0 +1,70 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Form;
+
+use Wootook\Core\Profiler,
+ Wootook\Core\PluginLoader;
+
+class ValidatorLoader
+ extends PluginLoader\PluginLoader
+{
+ protected $_form = null;
+
+ public function __construct(Form $form, Array $namespaces = array())
+ {
+ $this->_form = $form;
+
+ foreach ($namespaces as $namespace => $path) {
+ if (is_int($namespace)) {
+ $this->registerNamespace($path);
+ } else {
+ $this->registerNamespace($namespace, $path);
+ }
+ }
+ }
+
+ protected function _load($className, $useSingleton, Array $constructorParams = array())
+ {
+ $reflection = new \ReflectionClass($className);
+ if ($useSingleton && $reflection->implementsInterface('Wootook\\Core\\Base\\Singleton')) {
+ $method = $reflection->getMethod('getSingleton');
+ return $method->invoke(null);
+ }
+
+ try {
+ return $reflection->newInstance();
+ } catch (\ReflectionException $e) {
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException($e);
+ return null;
+ }
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/ConfigHandler.php b/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/ConfigHandler.php
new file mode 100644
index 0000000..6fb1cae
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/ConfigHandler.php
@@ -0,0 +1,93 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Helper\Config;
+
+use Wootook\Core\Mvc\Model\Type,
+ Wootook\Core\Mvc\Model\Action;
+
+abstract class ConfigHandler
+ implements \Iterator, \Countable
+{
+ protected $_data = array();
+
+ protected function _initData($filename)
+ {
+ $config = \Wootook::app()->getDefaultGame()->getConfig('engine/storyline');
+
+ if ($config === null) {
+ $config = array(
+ 'universe' => 'default',
+ 'episode' => 'default'
+ );
+ } else {
+ $config = $config->toArray();
+ }
+
+ $path = 'gamedata' . DIRECTORY_SEPARATOR . $config['universe'] . DIRECTORY_SEPARATOR
+ . $config['episode'] . DIRECTORY_SEPARATOR . $filename . '.php';
+
+ foreach (include APPLICATION_PATH . $path as $elementId => $fieldName) {
+ $this->setData($elementId, $fieldName);
+ }
+
+ return $this;
+ }
+
+ public function count()
+ {
+ return count($this->_data);
+ }
+
+ public function current()
+ {
+ return current($this->_data);
+ }
+
+ public function next()
+ {
+ return next($this->_data);
+ }
+
+ public function key()
+ {
+ return key($this->_data);
+ }
+
+ public function valid()
+ {
+ return $this->current() !== false;
+ }
+
+ public function rewind()
+ {
+ reset($this->_data);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/Events.php b/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/Events.php
new file mode 100644
index 0000000..9809eed
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/Events.php
@@ -0,0 +1,71 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Helper\Config;
+
+use Wootook\Core,
+ Wootook\Core\Config;
+
+/**
+ *
+ * Enter description here ...
+ *
+ * @uses Wootook\Core\BaseObject
+ * @uses Legacies_Empire
+ */
+class Events
+ extends ConfigHandler
+ implements Core\Base\Singleton
+{
+ private static $_singleton = null;
+
+ public static function getSingleton()
+ {
+ if (self::$_singleton === null) {
+ self::$_singleton = new self();
+ }
+ return self::$_singleton;
+ }
+
+ public static function registerEvents()
+ {
+ foreach (self::getSingleton() as $event => $listenerList) {
+ foreach ($listenerList as $listener) {
+ \Wootook::registerListener($event, $listener);
+ }
+ }
+ }
+
+ protected function _init()
+ {
+ $this->_initData('events');
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/Modules.php b/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/Modules.php
new file mode 100644
index 0000000..cfad504
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Helper/Config/Modules.php
@@ -0,0 +1,79 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Helper\Config;
+
+use Wootook\Core;
+
+/**
+ *
+ * Enter description here ...
+ *
+ * @uses Wootook\Core\BaseObject
+ * @uses Legacies_Empire
+ */
+class Modules
+ extends ConfigHandler
+ implements Core\Base\Singleton
+{
+ private static $_singleton = null;
+
+ public static function getSingleton()
+ {
+ if (self::$_singleton === null) {
+ self::$_singleton = new self();
+ }
+ return self::$_singleton;
+ }
+
+ protected function _init()
+ {
+ $this->_initData('modules');
+ return $this;
+ }
+
+ protected function _load()
+ {
+ // NOP
+ return $this;
+ }
+
+ protected function _save()
+ {
+ // NOP
+ return $this;
+ }
+
+ protected function _delete()
+ {
+ // NOP
+ return $this;
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Model/Layout.php b/src/application/modules/WootookCore/src/Wootook/Core/Layout/Manager.php
similarity index 84%
rename from src/application/code/core/Wootook/Core/Model/Layout.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Layout/Manager.php
index d15057f..b3a95e0 100644
--- a/src/application/code/core/Wootook/Core/Model/Layout.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Layout/Manager.php
@@ -28,6 +28,19 @@
*
*/
+namespace Wootook\Core\Layout;
+
+use Wootook\Core,
+ Wootook\Core\Base,
+ Wootook\Core\Block,
+ Wootook\Core\Config,
+ Wootook\Core\Exception as CoreException,
+ Wootook\Core\Helper\Config as ConfigHelper,
+ Wootook\Core\Model\Layout,
+ Wootook\Core\Mvc\Model,
+ Wootook\Core\Mvc\View,
+ Wootook\Core\Profiler;
+
/**
* Page layout class utility.
* Builds page structures from flexible layout declaration files, written in a
@@ -36,12 +49,14 @@
* @author Greg
* @since 1.5.0
* @package Wootook
- * @subpackage Wootook_Core
+ * @subpackage WootookCore
* @category layout
*/
-class Wootook_Core_Model_Layout
- extends Wootook_Core_Mvc_Model_Model
+class Manager
+ //extends Core\BaseObject
{
+ use Base\Service\App, Base\DataContainer;
+
const DEFAULT_PACKAGE = 'base';
const DEFAULT_THEME = 'default';
@@ -51,10 +66,10 @@ class Wootook_Core_Model_Layout
/** @var array */
protected $_blocks = array();
- /** @var Wootook_Core_Mvc_View_View */
+ /** @var View\View */
protected $_messageBlock = null;
- /** @var Wootook_Core_Mvc_View_View */
+ /** @var View\View */
protected $_rootView = null;
/** @var string */
@@ -75,7 +90,7 @@ class Wootook_Core_Model_Layout
/** @var array */
protected $_namespaces = array(
'core' => array(
- 'Wootook_Core_Block_' => 'Wootook/Core/Block'
+ 'Wootook\\Core\\Block' => 'Wootook/Core/Block'
)
);
@@ -87,10 +102,10 @@ class Wootook_Core_Model_Layout
* @param string $theme
* @param array $data
*/
- public function __construct($domain = null, $package = null, $theme = null, Array $data = array())
+ protected function _construct($domain = null, $package = null, $theme = null, Array $data = array())
{
if ($domain === null) {
- if (Wootook::getDefaultWebsite()->getId() == 0) {
+ if (\Wootook::app()->getDefaultWebsiteId() == 0) {
$this->_domain = self::DOMAIN_BACKEND;
} else {
$this->_domain = self::DOMAIN_FRONTEND;
@@ -104,13 +119,12 @@ class Wootook_Core_Model_Layout
if ($theme !== null) {
$this->setTheme($theme);
}
-
- parent::__construct($data);
+ $this->addData($data);
}
public function _init()
{
- $modules = Wootook_Core_Helper_Config_Modules::getSingleton();
+ $modules = ConfigHelper\Modules::getSingleton();
foreach ($modules['block'] as $module => $moduleNamespaces) {
foreach ($moduleNamespaces as $namespace => $path) {
@@ -118,8 +132,8 @@ class Wootook_Core_Model_Layout
}
}
- $fileList = Wootook::getGameConfig('layout');
- if ($fileList instanceof Wootook_Core_Config_Node) {
+ $fileList = \Wootook::app()->getDefaultGame()->getConfig('layout');
+ if ($fileList instanceof Config\Node) {
$fileList = $fileList->toArray();
}
if (!is_array($fileList) || empty($fileList)) {
@@ -127,10 +141,10 @@ class Wootook_Core_Model_Layout
}
$this->_data = array();
- $this->setPackage(Wootook::getWebsiteConfig('package'));
- $this->setTheme(Wootook::getGameConfig('theme'));
+ $this->setPackage(\Wootook::app()->getDefaultWebsite()->getConfig('package'));
+ $this->setTheme(\Wootook::app()->getDefaultGame()->getConfig('theme'));
- $parser = new Wootook_Core_Model_Layout_Parser();
+ $parser = new Layout\Parser();
foreach ($fileList as $layoutFile) {
try {
if (preg_match('#\.php$#', $layoutFile)) {
@@ -138,8 +152,8 @@ class Wootook_Core_Model_Layout
} else {
$layoutData = $parser->parse($this->_getLayoutPath($layoutFile), $this->_getLayoutCachePath($layoutFile), 3600);
}
- } catch (Wootook_Core_Exception_LayoutException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
+ } catch (CoreException\LayoutException $e) {
+ Profiler\ErrorProfiler::getSingleton()->addException($e);
continue;
}
@@ -186,10 +200,8 @@ class Wootook_Core_Model_Layout
}
}
- protected function _load()
+ public function load($layoutId)
{
- $layoutId = func_get_arg(0);
-
if (!$this->hasData($layoutId)) {
return $this;
}
@@ -258,7 +270,7 @@ class Wootook_Core_Model_Layout
}
}
- Wootook::dispatchEvent($this->_eventPrefix . '.prepare.before', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.prepare.before', array(
$this->_eventObject => $this
));
@@ -266,19 +278,19 @@ class Wootook_Core_Model_Layout
$block->prepareLayout();
}
- Wootook::dispatchEvent($this->_eventPrefix . '.prepare.after', array(
+ \Wootook::dispatchEvent($this->_eventPrefix . '.prepare.after', array(
$this->_eventObject => $this
));
}
protected function _save()
{
- throw new Wootook_Core_Exception_LayoutException('Save not permitted for the layout manager.');
+ throw new CoreException\LayoutException('Save not permitted for the layout manager.');
}
protected function _delete()
{
- throw new Wootook_Core_Exception_LayoutException('Delete not permitted for the layout manager.');
+ throw new CoreException\LayoutException('Delete not permitted for the layout manager.');
}
protected function _resolveBlockClassType($type)
@@ -303,12 +315,12 @@ class Wootook_Core_Model_Layout
$className = $namespace . $block;
$fileName = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $block) . '.php';
- Wootook_Core_ErrorProfiler::getSingleton()->sleep();
+ Profiler\ErrorProfiler::getSingleton()->sleep();
if (!($fp = @fopen($fileName, 'r', true))) {
- Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
+ Profiler\ErrorProfiler::getSingleton()->wakeup();
continue;
}
- Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
+ Profiler\ErrorProfiler::getSingleton()->wakeup();
fclose($fp);
if (!class_exists($className, true)) {
@@ -319,8 +331,8 @@ class Wootook_Core_Model_Layout
}
}
- Wootook_Core_ErrorProfiler::getSingleton()
- ->addException(new Wootook_Core_Exception_LayoutException(sprintf('Class type "%s" could not be resolved.', $type)));
+ Profiler\ErrorProfiler::getSingleton()
+ ->addException(new CoreException\LayoutException(sprintf('Class type "%s" could not be resolved.', $type)));
return null;
}
@@ -331,7 +343,7 @@ class Wootook_Core_Model_Layout
* @param string $module
* @param string $namespace
* @param string|null $path
- * @return Wootook_Core_Model_Layout
+ * @return Layout
*/
public function registerBlockNamespace($module, $namespace, $path = null)
{
@@ -352,7 +364,7 @@ class Wootook_Core_Model_Layout
* @since 1.5.0
* @param string $module
* @param string $namespace
- * @return Wootook_Core_Model_Layout
+ * @return Layout
*/
public function unregisterBlockNamespace($module, $namespace)
{
@@ -369,7 +381,7 @@ class Wootook_Core_Model_Layout
* @param string $type
* @param string $name
* @param array $config
- * @return Wootook_Core_Mvc_View_View
+ * @return View\View
*/
public function createBlock($type, $name, $config = array())
{
@@ -419,7 +431,7 @@ class Wootook_Core_Model_Layout
}
if (!isset($config['type'])) {
- $instance->$alias = new Wootook_Core_Mvc_View_View($config);
+ $instance->$alias = new View\View($config);
} else {
$child = $this->_createBlock($config['type'], $name, $config);
if ($child !== null) {
@@ -427,8 +439,8 @@ class Wootook_Core_Model_Layout
}
}
}
- } catch (ReflectionException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()
+ } catch (\ReflectionException $e) {
+ Profiler\ErrorProfiler::getSingleton()
->addException($e);
return null;
}
@@ -467,18 +479,18 @@ class Wootook_Core_Model_Layout
$callParamaters[$paramterPosition] = $parameter->getDefaultValue();
//} else if (!$parameter->isOptionnal()) {
} else if ($paramterPosition <= $requiredParameterCount) {
- throw new Wootook_Core_Exception_LayoutException(Wootook::__('Method %s requires parameter %d ($%s) to be defined.',
+ throw new CoreException\LayoutException(\Wootook::__('Method %s requires parameter %d ($%s) to be defined.',
$reflectionMethod->getName(), $paramterPosition + 1, $paramterName));
}
}
$reflectionMethod->invokeArgs($block, $callParamaters);
- } catch (ReflectionException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()
+ } catch (\ReflectionException $e) {
+ Profiler\ErrorProfiler::getSingleton()
->addException($e);
continue;
- } catch (RuntimeException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()
+ } catch (\RuntimeException $e) {
+ Profiler\ErrorProfiler::getSingleton()
->addException($e);
continue;
}
@@ -501,7 +513,7 @@ class Wootook_Core_Model_Layout
*
* @since 1.5.0
* @param string $domain
- * @return Wootook_Core_Model_Layout
+ * @return Layout
*/
public function setDomain($domain)
{
@@ -543,7 +555,7 @@ class Wootook_Core_Model_Layout
public function getScriptPath()
{
- return Wootook::getBasePath('design') . DIRECTORY_SEPARATOR . $this->getDomain();
+ return \Wootook::getBasePath('design') . DIRECTORY_SEPARATOR . $this->getDomain();
}
public function getAllBlocks()
@@ -561,13 +573,13 @@ class Wootook_Core_Model_Layout
public function render()
{
- if (!$this->_rootView instanceof Wootook_Core_Mvc_View_View) {
- throw new Wootook_Core_Exception_LayoutException(Wootook::__('No root view declared.'));
+ if (!$this->_rootView instanceof View\View) {
+ throw new CoreException\LayoutException(\Wootook::__('No root view declared.'));
}
$scriptPath = $this->getScriptPath();
foreach ($this->_blocks as $block) {
- if ($block instanceof Wootook_Core_Block_Template) {
+ if ($block instanceof Block\Template) {
$block->setScriptPath($scriptPath);
}
$block->beforeToHtml();
@@ -601,29 +613,29 @@ class Wootook_Core_Model_Layout
if ($package !== null && $theme !== null) {
$path = sprintf($pattern, $package, $theme);
- if (Wootook::fileExists($path)) {
+ if (\Wootook::fileExists($path)) {
return $path;
}
}
if ($package !== null) {
$path = sprintf($pattern, $package, self::DEFAULT_THEME);
- if (Wootook::fileExists($path)) {
+ if (\Wootook::fileExists($path)) {
return $path;
}
}
$path = sprintf($pattern, self::DEFAULT_PACKAGE, self::DEFAULT_THEME);
- if (Wootook::fileExists($path)) {
+ if (\Wootook::fileExists($path)) {
return $path;
}
- throw new Wootook_Core_Exception_LayoutException(sprintf("Layout file '%s' does not exist.", $file));
+ throw new CoreException\LayoutException(sprintf("Layout file '%s' does not exist.", $file));
}
/**
*
- * @return Wootook_Core_Block_Messages
+ * @return Block\Messages
*/
public function getMessagesBlock()
{
diff --git a/src/application/code/core/Wootook/Core/Model/Layout/Parser.php b/src/application/modules/WootookCore/src/Wootook/Core/Layout/Parser.php
similarity index 63%
rename from src/application/code/core/Wootook/Core/Model/Layout/Parser.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Layout/Parser.php
index 1e07ae8..b0a5bf2 100644
--- a/src/application/code/core/Wootook/Core/Model/Layout/Parser.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Layout/Parser.php
@@ -1,15 +1,47 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Model_Layout_Parser
+namespace Wootook\Core\Model\Layout;
+
+use Wootook\Core\Config;
+
+class Parser
{
/**
*
* Enter description here ...
- * @param unknown_type $filename
+ * @param string $filename
*/
public function parse($filename, $cachePath = null, $cacheLifetime = 86400)
{
- if ($cachePath !== null && Wootook::fileExists($cachePath) && $cacheLifetime > 0 && (time() - filemtime($cachePath) <= $cacheLifetime)) {
+ if ($cachePath !== null && \Wootook::fileExists($cachePath) && $cacheLifetime > 0 && (time() - filemtime($cachePath) <= $cacheLifetime)) {
return include $cachePath;
}
@@ -30,18 +62,18 @@ class Wootook_Core_Model_Layout_Parser
return array();
}
- $result = new Wootook_Core_Config_Adapter_Array();
+ $result = new Config\Adapter\PhpArray();
foreach ($layout->handle as $handle) {
$name = (string) $handle['name'];
if (empty($name)) {
continue;
}
- $handleNode = new Wootook_Core_Config_Node(array(), $result);
+ $handleNode = new Config\Node(array(), $result);
$result->$name = $handleNode;
if (isset($handle->update)) {
- $updateListNode = new Wootook_Core_Config_Node(array(), $handleNode);
+ $updateListNode = new Config\Node(array(), $handleNode);
$handleNode->update = $updateListNode;
foreach ($handle->update as $update) {
@@ -56,7 +88,7 @@ class Wootook_Core_Model_Layout_Parser
}
if (isset($handle->reference)) {
- $referenceListNode = new Wootook_Core_Config_Node(array(), $handleNode);
+ $referenceListNode = new Config\Node(array(), $handleNode);
$handleNode->reference = $referenceListNode;
foreach ($handle->reference as $reference) {
@@ -65,7 +97,7 @@ class Wootook_Core_Model_Layout_Parser
continue;
}
- $referenceNode = new Wootook_Core_Config_Node(array(), $referenceListNode);
+ $referenceNode = new Config\Node(array(), $referenceListNode);
$referenceListNode->$referenceName = $referenceNode;
$this->_parseBlockBody($reference, $referenceNode);
@@ -76,7 +108,7 @@ class Wootook_Core_Model_Layout_Parser
return $result;
}
- protected function _parseBlock(SimpleXMLElement $handle, Wootook_Core_Config_Node $blockNode)
+ protected function _parseBlock(\SimpleXMLElement $handle, Config\Node $blockNode)
{
foreach ($handle->attributes() as $attributeName => $attributeValue) {
$blockNode->$attributeName = (string) $attributeValue;
@@ -85,10 +117,10 @@ class Wootook_Core_Model_Layout_Parser
$this->_parseBlockBody($handle, $blockNode);
}
- protected function _parseBlockBody(SimpleXMLElement $handle, Wootook_Core_Config_Node $blockNode)
+ protected function _parseBlockBody(\SimpleXMLElement $handle, Config\Node $blockNode)
{
if (isset($handle->block)) {
- $childrenNode = new Wootook_Core_Config_Node(array(), $blockNode);
+ $childrenNode = new Config\Node(array(), $blockNode);
$blockNode->children = $childrenNode;
foreach ($handle->block as $block) {
@@ -97,7 +129,7 @@ class Wootook_Core_Model_Layout_Parser
continue;
}
- $childNode = new Wootook_Core_Config_Node(array(), $childrenNode);
+ $childNode = new Config\Node(array(), $childrenNode);
$childrenNode->$blockName = $childNode;
$this->_parseBlock($block, $childNode);
@@ -105,7 +137,7 @@ class Wootook_Core_Model_Layout_Parser
}
if (isset($handle->action)) {
- $actionListNode = new Wootook_Core_Config_Node(array(), $blockNode);
+ $actionListNode = new Config\Node(array(), $blockNode);
$blockNode->actions = $actionListNode;
foreach ($handle->action as $action) {
@@ -114,7 +146,7 @@ class Wootook_Core_Model_Layout_Parser
continue;
}
- $actionNode = new Wootook_Core_Config_Node(array(
+ $actionNode = new Config\Node(array(
'method' => $methodName,
'params' => array()
), $actionListNode);
@@ -134,7 +166,7 @@ class Wootook_Core_Model_Layout_Parser
if (isset($param->const) && isset($param->const['name']) && defined((string) $param->const['name'])) {
$paramsNode->$paramName = constant((string) $param->const['name']);
} else {
- $paramArrayNode = new Wootook_Core_Config_Node(array(), $paramsNode);
+ $paramArrayNode = new Config\Node(array(), $paramsNode);
$paramsNode->$paramName = $paramArrayNode;
$this->_parseArrayParam($param, $paramArrayNode);
@@ -148,11 +180,11 @@ class Wootook_Core_Model_Layout_Parser
}
}
- protected function _parseArrayParam(SimpleXMLElement $element, Wootook_Core_Config_Node $parentNode)
+ protected function _parseArrayParam(\SimpleXMLElement $element, Config\Node $parentNode)
{
foreach ($element->children() as $child) {
if (count($child)) {
- $childNode = new Wootook_Core_Config_Node(array(), $parentNode);
+ $childNode = new Config\Node(array(), $parentNode);
$parentNode->{$child->getName()} = $childNode;
$this->_parseArrayParam($child, $childNode);
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Model/Config.php b/src/application/modules/WootookCore/src/Wootook/Core/Model/Config.php
new file mode 100644
index 0000000..81d2095
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Model/Config.php
@@ -0,0 +1,93 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Model;
+
+use Wootook\Core\Mvc\Model;
+
+/**
+ *
+ * Enter description here ...
+ *
+ * @uses Wootook\Core\BaseObject
+ * @uses Legacies_Empire
+ */
+class Config
+ extends Model\SubTable
+{
+ protected $_eventPrefix = 'core.config';
+ protected $_eventObject = 'config';
+
+ protected function _init()
+ {
+ $this->_tableName = 'core_config';
+ $this->_idFieldNames = array('config_path', 'website_id', 'game_id');
+ }
+
+ public function setWebsiteId($websiteId)
+ {
+ return $this->setData('website_id', $websiteId);
+ }
+
+ public function getWebsiteId()
+ {
+ return $this->getData('website_id');
+ }
+
+ public function setGameId($gameId)
+ {
+ return $this->setData('game_id', $gameId);
+ }
+
+ public function getGameId()
+ {
+ return $this->getData('game_id');
+ }
+
+ public function setPath($path)
+ {
+ return $this->setData('config_path', $path);
+ }
+
+ public function getPath()
+ {
+ return $this->getData('config_path');
+ }
+
+ public function setValue($value)
+ {
+ return $this->setData('config_value', $value);
+ }
+
+ public function getValue()
+ {
+ return $this->getData('config_value');
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Model/Game.php b/src/application/modules/WootookCore/src/Wootook/Core/Model/Game.php
new file mode 100644
index 0000000..4453274
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Model/Game.php
@@ -0,0 +1,139 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Model;
+
+use Wootook\Core,
+ Wootook\Core\Mvc\Model,
+ Wootook\Core\Mvc\Model\Type;
+
+/**
+ *
+ * Enter description here ...
+ *
+ * @uses Wootook\Core\BaseObject
+ * @uses Legacies_Empire
+ */
+class Game
+ extends Model\Entity
+{
+ use Type\Full;
+
+ const DEFAULT_CODE = 'default';
+
+ protected $_website = null;
+
+ protected function _construct(Array $data = array())
+ {
+ $this->_eventPrefix = 'core.game';
+ $this->_eventObject = 'game';
+
+ parent::_construct($data);
+
+ $this->_tableName = 'core_game';
+ $this->_idFieldName = 'game_id';
+ }
+
+ public function getWebsiteId()
+ {
+ return $this->getData('website_id');
+ }
+
+ public function setWebsiteId($websiteId)
+ {
+ $this->_website = $this->app()->getWebsite($websiteId);
+ return $this->setData('website_id', $websiteId);
+ }
+
+ /**
+ * @return Website
+ */
+ public function getWebsite()
+ {
+ if ($this->_website === null) {
+ $this->_website = $this->app()->getWebsite($this->getWebsiteId());
+ }
+
+ return $this->_website;
+ }
+
+ /**
+ * @param Website $website
+ * @return Game
+ */
+ public function setWebsite(Website $website)
+ {
+ $this->_website = $website;
+ $this->setWebsiteId($website->getId());
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->getData('code');
+ }
+
+ /**
+ * @param string $code
+ * @return Game
+ */
+ public function setCode($code)
+ {
+ return $this->setData('code', $code);
+ }
+
+ /**
+ * @return Core\Config\Node
+ */
+ public function getConfig($path = null)
+ {
+ if ($this->_config === null) {
+ $this->_config = clone $this->getWebsite()->getConfig();
+
+ $this->app()->appendEnvironmentConfig($this->_config, $this->getCode());
+ $this->app()->appendDatabaseConfig($this->_config, Core\App\App::SCOPE_GAME, $this->getId());
+ }
+
+ if ($path !== null) {
+ return $this->_config->getConfig($path);
+ }
+
+ return $this->_config;
+ }
+
+ public function getBaseUrl()
+ {
+ return $this->getConfig('web/url/base');
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Model/Image/Png.php b/src/application/modules/WootookCore/src/Wootook/Core/Model/Image/Png.php
similarity index 79%
rename from src/application/code/core/Wootook/Core/Model/Image/Png.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Model/Image/Png.php
index 0b3f5f9..1d4303a 100644
--- a/src/application/code/core/Wootook/Core/Model/Image/Png.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Model/Image/Png.php
@@ -1,4 +1,34 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Model\Image;
/**
*
@@ -6,7 +36,7 @@
* @author Greg
*
*/
-class Wootook_Core_Model_Image_Png
+class Png
{
private $_format = NULL;
private $_mime = NULL;
@@ -191,4 +221,4 @@ class Wootook_Core_Model_Image_Png
return $imageData;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Core/Model/Session.php b/src/application/modules/WootookCore/src/Wootook/Core/Model/Session.php
similarity index 76%
rename from src/application/code/core/Wootook/Core/Model/Session.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Model/Session.php
index 2306f03..a378f28 100644
--- a/src/application/code/core/Wootook/Core/Model/Session.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Model/Session.php
@@ -1,15 +1,49 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Model;
+
+use Wootook\Core,
+ Wootook\Core\Base;
/**
*
* Enter description here ...
*
- * @uses Wootook_Object
+ * @uses Wootook\Core\BaseObject
* @uses Legacies_Empire
*/
-class Wootook_Core_Model_Session
- extends Wootook_Object
+class Session
{
+ use Base\Service\App, Base\DataContainer;
+
const CRIT = 0x80;
const ERR = 0x40;
const WARN = 0x20;
@@ -51,7 +85,7 @@ class Wootook_Core_Model_Session
session_destroy();
}
- public function __construct($namespace)
+ public function _construct($namespace)
{
if (session_id() == '') {
session_set_cookie_params($this->getCookieLifetime(), $this->getCookiePath(), $this->getCookieDomain(), false, true);
@@ -80,7 +114,7 @@ class Wootook_Core_Model_Session
public function getCookieLifetime()
{
- $lifetime = Wootook::getWebsiteConfig(self::COOKIE_LIFETIME_CONFIG_KEY);
+ $lifetime = \Wootook::app()->getDefaultWebsite()->getConfig(self::COOKIE_LIFETIME_CONFIG_KEY);
if (!is_numeric($lifetime) || $lifetime <= 0) {
return 900;
}
@@ -90,7 +124,7 @@ class Wootook_Core_Model_Session
public function getCookieDomain()
{
- $domain = Wootook::getWebsiteConfig(self::COOKIE_DOMAIN_CONFIG_KEY);
+ $domain = \Wootook::app()->getDefaultWebsite()->getConfig(self::COOKIE_DOMAIN_CONFIG_KEY);
if ($domain === null) {
return $_SERVER['SERVER_NAME'];
}
@@ -99,7 +133,7 @@ class Wootook_Core_Model_Session
public function getCookiePath()
{
- $path = Wootook::getWebsiteConfig(self::COOKIE_PATH_CONFIG_KEY);
+ $path = \Wootook::app()->getDefaultWebsite()->getConfig(self::COOKIE_PATH_CONFIG_KEY);
if ($path === null) {
return '/';
}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Model/Translator.php b/src/application/modules/WootookCore/src/Wootook/Core/Model/Translator.php
new file mode 100644
index 0000000..3e2bf53
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Model/Translator.php
@@ -0,0 +1,67 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Model;
+
+class Translator
+{
+ protected $_translations = array();
+
+ public function __construct($path, $locale)
+ {
+ $fileList = glob($path . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . '*.csv');
+ foreach ($fileList as $file) {
+ $fp = fopen($file, 'r');
+ while (!feof($fp)) {
+ $line = fgetcsv($fp);
+ if (count($line) >= 2) {
+ $this->_translations[$line[0]] = $line[1];
+ }
+ }
+ }
+ }
+
+ public function translate($message, $_ = null)
+ {
+ $args = func_get_args();
+ array_shift($args);
+
+ return $this->translateArgs($message, $args);
+ }
+
+ public function translateArgs($message, Array $args = array())
+ {
+ if (isset($this->_translations[$message])) {
+ $message = $this->_translations[$message];
+ }
+
+ return vsprintf($message, $args);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Model/Website.php b/src/application/modules/WootookCore/src/Wootook/Core/Model/Website.php
new file mode 100644
index 0000000..3a1552f
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Model/Website.php
@@ -0,0 +1,96 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Model;
+
+use Wootook\Core,
+ Wootook\Core\Mvc\Model,
+ Wootook\Core\Mvc\Model\Type;
+
+/**
+ *
+ * Enter description here ...
+ *
+ * @uses Wootook\Core\BaseObject
+ * @uses Legacies_Empire
+ */
+class Website
+ extends Model\Entity
+{
+ use Type\Full;
+
+ const DEFAULT_CODE = 'default';
+
+ protected $_config = null;
+
+ protected function _construct(Array $data = array())
+ {
+ $this->_eventPrefix = 'core.website';
+ $this->_eventObject = 'website';
+
+ parent::_construct($data);
+
+ $this->_tableName = 'core_website';
+ $this->_idFieldName = 'website_id';
+ }
+
+ public function getCode()
+ {
+ return $this->getData('code');
+ }
+
+ public function setCode($code)
+ {
+ return $this->setData('code', $code);
+ }
+
+ /**
+ * @return Core\Config\Node
+ */
+ public function getConfig($path = null)
+ {
+ if ($this->_config === null) {
+ $this->_config = clone $this->app()->getGlobalConfig();
+
+ $this->app()->appendEnvironmentConfig($this->_config, $this->getCode());
+ $this->app()->appendDatabaseConfig($this->_config, Core\App\App::SCOPE_WEBSITE, $this->getId());
+ }
+
+ if ($path !== null) {
+ return $this->_config->getConfig($path);
+ }
+ return $this->_config;
+ }
+
+ public function getBaseUrl()
+ {
+ return $this->getConfig('web/url/base');
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Action.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Action.php
similarity index 57%
rename from src/application/code/core/Wootook/Core/Mvc/Controller/Action.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Action.php
index e6230ba..3a530c3 100644
--- a/src/application/code/core/Wootook/Core/Mvc/Controller/Action.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Action.php
@@ -1,14 +1,54 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-abstract class Wootook_Core_Mvc_Controller_Action
+namespace Wootook\Core\Mvc\Controller;
+
+use Wootook\Core,
+ Wootook\Core\Exception as CoreException,
+ Wootook\Core\Layout,
+ Wootook\Core\Model,
+ Wootook\Core\Profiler;
+
+abstract class Action
{
+ protected $_app = null;
+
private $_request = null;
private $_response = null;
private $_layout = null;
- public function __construct(Wootook_Core_Mvc_Controller_Request_Http $request, Wootook_Core_Mvc_Controller_Response_Http $response)
+ public function __construct(Core\App\App $app, Request\Request $request, Response\Response $response)
{
+ $this->_app = $app;
+
$this->setRequest($request);
$this->setResponse($response);
}
@@ -17,6 +57,11 @@ abstract class Wootook_Core_Mvc_Controller_Action
{
}
+ public function app()
+ {
+ return $this->_app;
+ }
+
public function preDispatch()
{
}
@@ -25,14 +70,14 @@ abstract class Wootook_Core_Mvc_Controller_Action
{
}
- public function setRequest(Wootook_Core_Mvc_Controller_Request_Http $request)
+ public function setRequest(Request\Request $request)
{
$this->_request = $request;
return $this;
}
- public function setResponse(Wootook_Core_Mvc_Controller_Response_Http $response)
+ public function setResponse(Response\Response $response)
{
$this->_response = $response;
@@ -41,7 +86,7 @@ abstract class Wootook_Core_Mvc_Controller_Action
/**
*
- * @return Wootook_Core_Mvc_Controller_Request_Http
+ * @return Request\Request
*/
public function getRequest()
{
@@ -50,7 +95,7 @@ abstract class Wootook_Core_Mvc_Controller_Action
/**
*
- * @return Wootook_Core_Mvc_Controller_Response_Http
+ * @return Response\Response
*/
public function getResponse()
{
@@ -71,7 +116,7 @@ abstract class Wootook_Core_Mvc_Controller_Action
$this->getResponse()->setIsDispatched(false);
}
- protected function _redirect($uri, Array $params = array(), $code = Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_FOUND)
+ protected function _redirect($uri, Array $params = array(), $code = Response\Response::REDIRECT_FOUND)
{
$parts = explode('/', $uri);
$partsCount = count($parts);
@@ -87,14 +132,14 @@ abstract class Wootook_Core_Mvc_Controller_Action
$uri = implode('/', array_slice($parts, 0, 3));
$this->getResponse()
- ->setRedirect(Wootook::getUrl($uri, $params), $code);
+ ->setRedirect(\Wootook::getUrl($uri, $params), $code);
- Wootook_Core_ErrorProfiler::unregister(true);
+ Profiler\ErrorProfiler::unregister(true);
return $this;
}
- protected function _redirectUrl($url, $code = Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_FOUND)
+ protected function _redirectUrl($url, $code = Response\Response::REDIRECT_FOUND)
{
$this->getResponse()->setRedirect($url, $code);
@@ -128,12 +173,12 @@ abstract class Wootook_Core_Mvc_Controller_Action
protected function _initLayout()
{
- return new Wootook_Core_Model_Layout(Wootook_Core_Model_Layout::DOMAIN_FRONTEND);
+ return new Layout\Manager($this->app(), Layout\Manager::DOMAIN_FRONTEND);
}
/**
*
- * @return Wootook_Core_Model_Layout
+ * @return Layout\Manager
*/
public function getLayout()
{
@@ -144,8 +189,8 @@ abstract class Wootook_Core_Mvc_Controller_Action
{
try {
$content = $this->getLayout()->render();
- } catch (Wootook_Core_Exception_LayoutException $e) {
- Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
+ } catch (CoreException\LayoutException $e) {
+ Profiler\ErrorProfiler::getSingleton()->addException($e);
return $this;
}
$this->getResponse()->setBody($content);
diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Front.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Front.php
similarity index 62%
rename from src/application/code/core/Wootook/Core/Mvc/Controller/Front.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Front.php
index 6c6b20f..a95ce7d 100644
--- a/src/application/code/core/Wootook/Core/Mvc/Controller/Front.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Front.php
@@ -1,7 +1,41 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Mvc_Controller_Front
+namespace Wootook\Core\Mvc\Controller;
+
+use Wootook\Core\Base\Service;
+
+class Front
{
+ use Service\App;
+
const ROUTE_DEFAULT = 'default';
const ROUTE_ERROR = 'error';
@@ -10,8 +44,7 @@ class Wootook_Core_Mvc_Controller_Front
self::ROUTE_ERROR => array(
'modules' => array(
'core' => array(
- 'class' => 'Wootook_Core_Controller_',
- 'path' => 'Wootook/Core/Controller'
+ 100 => 'Wootook\\Core\\Controller'
)
),
'defaults' => array(
@@ -34,11 +67,50 @@ class Wootook_Core_Mvc_Controller_Front
protected $_request = null;
protected $_response = null;
- public function __construct(Wootook_Core_Mvc_Controller_Request_Request $request,
- Wootook_Core_Mvc_Controller_Response_Response $response)
+ protected function _construct(Request\Request $request = null, Response\Response $response = null)
+ {
+ if ($request !== null) {
+ $this->setRequest($request);
+ }
+ if ($response !== null) {
+ $this->setResponse($response);
+ }
+ }
+
+ /**
+ * @return Request\Request
+ */
+ public function getRequest()
+ {
+ if ($this->_request === null) {
+ $this->_request = new Request\Http($this->app());
+ }
+ return $this->_request;
+ }
+
+ public function setRequest(Request\Request $request)
{
$this->_request = $request;
+
+ return $this;
+ }
+
+ /**
+ * @return Response\Response
+ */
+ public function getResponse()
+ {
+ if ($this->_response === null) {
+ $this->_response = new Response\Http($this->app());
+ }
+ return $this->_response;
+ }
+
+ public function setResponse(Response\Response $response)
+ {
$this->_response = $response;
+
+ return $this;
}
protected function _setNoRouteAction(&$route, &$moduleKey, &$controllerKey, &$actionKey)
@@ -64,14 +136,7 @@ class Wootook_Core_Mvc_Controller_Front
protected function _camelizeClass($string)
{
$string = strtolower($string);
- $string = str_replace(' ', '_', ucwords(str_replace('.', ' ', $string)));
- return str_replace(' ', '', ucwords(str_replace('-', ' ', $string)));
- }
-
- protected function _camelizePath($string)
- {
- $string = strtolower($string);
- $string = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('.', ' ', $string)));
+ $string = str_replace(' ', '\\', ucwords(str_replace('.', ' ', $string)));
return str_replace(' ', '', ucwords(str_replace('-', ' ', $string)));
}
@@ -88,21 +153,8 @@ class Wootook_Core_Mvc_Controller_Front
if (!isset($this->_routes[$route]['modules'][$module])) {
return null;
}
- $modulePrefix = $this->_routes[$route]['modules'][$module]['class'];
- return $modulePrefix . $this->_camelizeClass($controllerKey) . 'Controller';
- }
-
- protected function _getControllerFilename($route, $module, $controllerKey)
- {
- if (!isset($this->_routes[$route])) {
- return null;
- }
- if (!isset($this->_routes[$route]['modules'][$module])) {
- return null;
- }
- $modulePath = $this->_routes[$route]['modules'][$module]['path'];
-
- return $modulePath . DIRECTORY_SEPARATOR . $this->_camelizePath($controllerKey) . 'Controller.php';
+ $modulePrefix = current($this->_routes[$route]['modules'][$module]);
+ return $modulePrefix . '\\' . $this->_camelizeClass($controllerKey) . 'Controller';
}
protected function _getActionMethod($actionKey)
@@ -112,14 +164,14 @@ class Wootook_Core_Mvc_Controller_Front
protected function _forward($action, $controller = null, $module = null)
{
- $this->_request->setActionName($action);
+ $this->getRequest()->setActionName($action);
if ($controller !== null) {
- $this->_request->setControllerName($controller);
+ $this->getRequest()->setControllerName($controller);
if ($module != null) {
- $this->_request->setModuleName($module);
+ $this->getRequest()->setModuleName($module);
}
}
- $this->_response->setIsDispatched(false);
+ $this->getResponse()->setIsDispatched(false);
}
public function dispatch($route = null)
@@ -134,7 +186,7 @@ class Wootook_Core_Mvc_Controller_Front
$loop = 0;
while ($loop++ < 100) {
- $moduleKey = $this->_request->getModuleName();
+ $moduleKey = $this->getRequest()->getModuleName();
if (empty($moduleKey)) {
$this->_forward(
$this->_routes[$route]['defaults']['action'],
@@ -154,19 +206,14 @@ class Wootook_Core_Mvc_Controller_Front
continue;
}
- $controllerKey = $this->_request->getControllerName();
+ $controllerKey = $this->getRequest()->getControllerName();
if (empty($controllerKey)) {
$controllerKey = $this->_routes[$route]['defaults']['controller'];
}
$controllerClass = $this->_getControllerClass($route, $moduleKey, $controllerKey);
- $controllerPath = $this->_getControllerFilename($route, $moduleKey, $controllerKey);
- if (!class_exists($controllerClass, false) && Wootook::fileExists($controllerPath)) {
- include_once $controllerPath;
- }
-
- if (!class_exists($controllerClass, false)) {
+ if (!class_exists($controllerClass, true)) {
$this->_forward(
$this->_routes[self::ROUTE_ERROR]['defaults']['action'],
$this->_routes[self::ROUTE_ERROR]['defaults']['controller'],
@@ -176,7 +223,7 @@ class Wootook_Core_Mvc_Controller_Front
continue;
}
- $actionKey = $this->_request->getActionName();
+ $actionKey = $this->getRequest()->getActionName();
if (empty($actionKey)) {
$actionKey = $this->_routes[$route]['defaults']['action'];
}
@@ -192,30 +239,30 @@ class Wootook_Core_Mvc_Controller_Front
continue;
}
- $controller = new $controllerClass($this->_request, $this->_response);
+ $controller = new $controllerClass($this->app(), $this->getRequest(), $this->getResponse());
$controller->init();
- $this->_response->setIsDispatched();
+ $this->getResponse()->setIsDispatched();
$this->preDispatch();
$controller->preDispatch();
- if (!$this->_response->isDispatched()) {
+ if (!$this->getResponse()->isDispatched()) {
continue;
}
- if ($this->_response->isRedirect()) {
+ if ($this->getResponse()->isRedirect()) {
break;
}
$controller->$actionMethod();
- if (!$this->_response->isDispatched()) {
+ if (!$this->getResponse()->isDispatched()) {
continue;
}
$controller->postDispatch();
$this->postDispatch();
- if ($this->_response->isDispatched() || $this->_response->isRedirect()) {
+ if ($this->getResponse()->isDispatched() || $this->getResponse()->isRedirect()) {
break;
}
}
@@ -225,7 +272,7 @@ class Wootook_Core_Mvc_Controller_Front
public function send()
{
- $this->_response->render();
+ $this->getResponse()->render();
}
public function addModule($frontName, $namespace, $path)
@@ -251,9 +298,9 @@ class Wootook_Core_Mvc_Controller_Front
public function preDispatch()
{
- Wootook::dispatchEvent('core.mvc.controller.front.pre-dispatch', array(
- 'request' => $this->_request,
- 'response' => $this->_response
+ \Wootook::dispatchEvent('core.mvc.controller.front.pre-dispatch', array(
+ 'request' => $this->getRequest(),
+ 'response' => $this->getResponse()
));
return $this;
@@ -261,9 +308,9 @@ class Wootook_Core_Mvc_Controller_Front
public function postDispatch()
{
- Wootook::dispatchEvent('core.mvc.controller.front.post-dispatch', array(
- 'request' => $this->_request,
- 'response' => $this->_response
+ \Wootook::dispatchEvent('core.mvc.controller.front.post-dispatch', array(
+ 'request' => $this->getRequest(),
+ 'response' => $this->getResponse()
));
return $this;
diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Http.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Request/Http.php
similarity index 86%
rename from src/application/code/core/Wootook/Core/Mvc/Controller/Request/Http.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Request/Http.php
index 3780a37..71b0f63 100644
--- a/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Http.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Request/Http.php
@@ -1,7 +1,37 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Mvc_Controller_Request_Http
- extends Wootook_Core_Mvc_Controller_Request_Request
+namespace Wootook\Core\Mvc\Controller\Request;
+
+class Http
+ extends Request
{
protected $_baseUrl = null;
@@ -15,11 +45,11 @@ class Wootook_Core_Mvc_Controller_Request_Http
protected $_serverVars = array();
protected $_postFiles = array();
- public function __construct(Array $options = array())
+ protected function _construct(Array $options = array())
{
- parent::__construct($options);
+ parent::_construct($options);
- $this->_baseUrl = Wootook::getBaseUrl('link');
+ $this->_baseUrl = \Wootook::getBaseUrl('link');
if ($this->_baseUrl === null) {
$this->_baseUrl = 'http://' . $this->getServer('HTTP_HOST') . $this->getServer('REQUEST_URI');
}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Request/Request.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Request/Request.php
new file mode 100644
index 0000000..3eb24ca
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Request/Request.php
@@ -0,0 +1,67 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Controller\Request;
+
+use Wootook\Core;
+
+abstract class Request
+ extends Core\Base\BaseObject
+{
+ protected function _construct(Array $data = array())
+ {
+ $this->init();
+
+ parent::_construct($data);
+ }
+
+ public function setParam($key, $value)
+ {
+ return $this->setData($key, $value);
+ }
+
+ public function getParam($key, $default = null)
+ {
+ if ($this->hasData($key)) {
+ return $this->getData($key);
+ }
+ return $default;
+ }
+
+ abstract public function init();
+
+ abstract public function getModuleName();
+ abstract public function getControllerName();
+ abstract public function getActionName();
+
+ abstract public function setModuleName($name);
+ abstract public function setControllerName($name);
+ abstract public function setActionName($name);
+}
diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Response/Http.php
similarity index 75%
rename from src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Response/Http.php
index 3025249..74fbd71 100644
--- a/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Response/Http.php
@@ -1,7 +1,39 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-class Wootook_Core_Mvc_Controller_Response_Http
- extends Wootook_Core_Mvc_Controller_Response_Response
+namespace Wootook\Core\Mvc\Controller\Response;
+
+use Wootook\Core;
+
+class Http
+ extends Response
{
const STATUS_OK = 200;
@@ -127,7 +159,7 @@ class Wootook_Core_Mvc_Controller_Response_Http
public function setRawCookie($name, $value, $lifetime = null, $path = null, $domain = null)
{
- $date = new Wootook_Core_DateTime();
+ $date = new Core\DateTime();
$date->add($lifetime);
setcookie($name, $value, $date->getTimestamp(), $path, $domain);
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Response/Response.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Response/Response.php
new file mode 100644
index 0000000..1afa0af
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Controller/Response/Response.php
@@ -0,0 +1,53 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Controller\Response;
+
+use Wootook\Core;
+
+abstract class Response
+ extends Core\Base\BaseObject
+{
+ protected $_isDispatched = false;
+
+ public function setIsDispatched($dispatched = true)
+ {
+ $this->_isDispatched = $dispatched;
+
+ return $this;
+ }
+
+ public function isDispatched()
+ {
+ return $this->_isDispatched;
+ }
+
+ abstract public function render($send = true);
+}
diff --git a/src/application/code/core/Wootook/Core/Event.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Deletable.php
similarity index 92%
rename from src/application/code/core/Wootook/Core/Event.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Deletable.php
index 42b4de7..123eea7 100644
--- a/src/application/code/core/Wootook/Core/Event.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Deletable.php
@@ -28,13 +28,12 @@
*
*/
+namespace Wootook\Core\Mvc\Model\Action;
+
/**
- *
- * Enter description here ...
- * @author Greg
*
*/
-class Wootook_Core_Event
- extends Wootook_Object
+interface Deletable
{
-}
\ No newline at end of file
+ public function save();
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Delete.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Delete.php
new file mode 100644
index 0000000..76c577d
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Delete.php
@@ -0,0 +1,75 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Model\Action;
+
+use Wootook\Core\Exception as CoreException;
+
+/**
+ *
+ */
+trait Delete
+{
+ public function delete()
+ {
+ try {
+ $this->_beforeDelete();
+ $this->_delete();
+ $this->_afterDelete();
+ } catch (\PDOException $e) {
+ throw new CoreException\DataAccessException('Could not delete entity: ' . $e->getMessage(), 0);
+ }
+ return $this;
+ }
+
+ abstract protected function _delete();
+
+ protected function _beforeDelete()
+ {
+ \Wootook::dispatchEvent('model.before-delete', array('model' => $this));
+
+ if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
+ \Wootook::dispatchEvent($this->_eventPrefix . '.before-delete', array($this->_eventObject => $this));
+ }
+
+ return $this;
+ }
+
+ protected function _afterDelete()
+ {
+ \Wootook::dispatchEvent('model.after-delete', array('model' => $this));
+
+ if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
+ \Wootook::dispatchEvent($this->_eventPrefix . '.after-delete', array($this->_eventObject => $this));
+ }
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Load.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Load.php
new file mode 100644
index 0000000..1d39b9b
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Load.php
@@ -0,0 +1,77 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Model\Action;
+
+use Wootook\Core\Exception as CoreException;
+
+/**
+ *
+ */
+trait Load
+{
+ public function load($entityId, $field = null, $_ = null)
+ {
+ try {
+ $this->_beforeLoad();
+ $this->_load($entityId, $field);
+ $this->_afterLoad();
+
+ $this->_setOriginalData($this->_data);
+ } catch (\PDOException $e) {
+ throw new CoreException\DataAccessException('Could not load data: ' . $e->getMessage(), 0, $e);
+ }
+ return $this;
+ }
+
+ abstract protected function _load();
+
+ protected function _beforeLoad()
+ {
+ \Wootook::dispatchEvent('model.before-load', array('model' => $this));
+
+ if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
+ \Wootook::dispatchEvent($this->_eventPrefix . '.before-load', array($this->_eventObject => $this));
+ }
+
+ return $this;
+ }
+
+ protected function _afterLoad()
+ {
+ \Wootook::dispatchEvent('model.after-load', array('model' => $this));
+
+ if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
+ \Wootook::dispatchEvent($this->_eventPrefix . '.after-load', array($this->_eventObject => $this));
+ }
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Loadable.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Loadable.php
new file mode 100644
index 0000000..d809788
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Loadable.php
@@ -0,0 +1,39 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Model\Action;
+
+/**
+ *
+ */
+interface Loadable
+{
+ public function load($entityId, $field = null, $_ = null);
+}
diff --git a/src/application/code/core/Wootook/Core/Exception.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Savable.php
similarity index 91%
rename from src/application/code/core/Wootook/Core/Exception.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Savable.php
index 7a9030d..d933687 100644
--- a/src/application/code/core/Wootook/Core/Exception.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Savable.php
@@ -28,10 +28,12 @@
*
*/
+namespace Wootook\Core\Mvc\Model\Action;
+
/**
- *
- * Enter description here ...
- * @author Greg
*
*/
-interface Wootook_Core_Exception extends Wootook_Exception {}
\ No newline at end of file
+interface Savable
+{
+ public function save();
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Save.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Save.php
new file mode 100644
index 0000000..9089e37
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Action/Save.php
@@ -0,0 +1,77 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Model\Action;
+
+use Wootook\Core\Exception as CoreException;
+
+/**
+ *
+ */
+trait Save
+{
+ public function save()
+ {
+ try {
+ $this->_beforeSave();
+ $this->_save();
+ $this->_afterSave();
+
+ $this->_setOriginalData($this->_data);
+ } catch (PDOException $e) {
+ throw new CoreException\DataAccessException('Could not save data: ' . $e->getMessage(), 0);
+ }
+ return $this;
+ }
+
+ abstract protected function _save();
+
+ protected function _beforeSave()
+ {
+ \Wootook::dispatchEvent('model.before-save', array('model' => $this));
+
+ if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
+ \Wootook::dispatchEvent($this->_eventPrefix . '.before-save', array($this->_eventObject => $this));
+ }
+
+ return $this;
+ }
+
+ protected function _afterSave()
+ {
+ \Wootook::dispatchEvent('model.after-save', array('model' => $this));
+
+ if ($this->_eventPrefix !== null && $this->_eventObject !== null) {
+ \Wootook::dispatchEvent($this->_eventPrefix . '.after-save', array($this->_eventObject => $this));
+ }
+
+ return $this;
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Entity.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Entity.php
new file mode 100644
index 0000000..dc4891b
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Entity.php
@@ -0,0 +1,193 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Model;
+
+use Wootook\Core,
+ Wootook\Core\Database,
+ Wootook\Core\Database\Sql,
+ Wootook\Core\Exception as CoreException;
+
+abstract class Entity
+ extends Core\Base\BaseObject
+ implements EntityInterface
+{
+ protected $_tableName = null;
+
+ protected $_idFieldName = null;
+
+ public function setIdFieldName($fieldName)
+ {
+ $this->_idFieldName = $fieldName;
+
+ return $this;
+ }
+
+ public function getIdFieldName()
+ {
+ return $this->_idFieldName;
+ }
+
+ public function setId($id)
+ {
+ $this->setData($this->getIdFieldName(), $id);
+
+ return $this;
+ }
+
+ public function getId()
+ {
+ return $this->getData($this->getIdFieldName());
+ }
+
+ protected function _load()
+ {
+ $id = func_get_arg(0);
+
+ $idFieldName = null;
+ if (func_num_args() >= 2) {
+ $idFieldName = func_get_arg(1);
+ }
+ if ($idFieldName === null) {
+ $idFieldName = $this->getIdFieldName();
+ }
+
+ $database = $this->getReadConnection();
+ if ($database === null) {
+ throw new CoreException\DataAccessException('Could not load data: no read connection configured.');
+ }
+
+ $select = $database->select()
+ ->from(array('main_table' => $database->getTable($this->getTableName())))
+ ->where($idFieldName, new Sql\Placeholder\Param('id', $id))
+ ->limit(1);
+
+ $statement = $select->prepare();
+ $statement->execute(array(
+ 'id' => $id
+ ));
+
+ $datas = $statement->fetch(Database\ConnectionManager::FETCH_ASSOC);
+ if (!is_array($datas) || empty($datas)) {
+ throw new CoreException\DataAccessException('Could not load data: this id could not be found.');
+ }
+ $realId = $datas[$this->getIdFieldName()];
+ unset($datas[$this->getIdFieldName()]);
+
+ $this->_data = array();
+ $this->getDataMapper()->decode($this, $datas);
+ $this->setId($realId);
+
+ return $this;
+ }
+
+ protected function _save()
+ {
+ $adapter = $this->getWriteConnection();
+
+ if ($adapter === null) {
+ throw new CoreException\DataAccessException('Could not save data: no write connection configured.');
+ }
+
+ if ($this->getId() !== null) {
+ $update = $adapter->update()
+ ->into($adapter->getTable($this->getTableName()))
+ ->where(new Sql\Placeholder\Expression("{$adapter->quoteIdentifier($this->getIdFieldName())}=:id", array('id' => $this->getId())));
+
+ foreach ($this->getDataMapper()->encode($this, $this->getChangedDatas()) as $field => $value) {
+ $update->set($field, new Sql\Placeholder\Param($field, $value));
+ }
+ try {
+ $statement = $update->prepare();
+ $statement->execute();
+ } catch (CoreException\Database\AdapterError $e) {
+ throw new CoreException\DataAccessException('Could not save data: ' . $e->getMessage(), null, $e);
+ } catch (CoreException\Database\StatementError $e) {
+ throw new CoreException\DataAccessException('Could not save data: ' . $e->getMessage(), null, $e);
+ }
+ } else {
+ $insert = $adapter->insert()
+ ->into($adapter->getTable($this->getTableName()));
+
+ foreach ($this->getDataMapper()->encode($this, $this->getAllDatas()) as $field => $value) {
+ $insert->set($field, new Sql\Placeholder\Param($field, $value));
+ }
+ try {
+ $statement = $insert->prepare();
+ $statement->execute();
+
+ $id = $adapter->lastInsertId($adapter->getTable($this->getTableName()));
+ $this->setId($id);
+ } catch (CoreException\Database\AdapterError $e) {
+ throw new CoreException\DataAccessException('Could not save data: ' . $e->getMessage(), null, $e);
+ } catch (CoreException\Database\StatementError $e) {
+ throw new CoreException\DataAccessException('Could not save data: ' . $e->getMessage(), null, $e);
+ }
+ }
+
+ return $this;
+ }
+
+ protected function _delete()
+ {
+ $adapter = $this->getWriteConnection();
+ if ($adapter === null) {
+ throw new CoreException\DataAccessException('Could not delete data: no write connection configured.');
+ }
+ $delete = $adapter
+ ->delete()
+ ->from($adapter->getTable($this->getTableName()))
+ ->where($this->getIdFieldName(), $this->getId())
+ ->limit(1);
+
+ try {
+ $statement = $adapter->prepare($delete);
+ $statement->execute();
+ } catch (CoreException\Database\AdapterError $e) {
+ throw new CoreException\DataAccessException('Could not delete data: ' . $e->getMessage(), null, $e);
+ } catch (CoreException\Database\StatementError $e) {
+ throw new CoreException\DataAccessException('Could not delete data: ' . $e->getMessage(), null, $e);
+ }
+
+ return $this;
+ }
+
+ public function setTableName($tableName)
+ {
+ $this->_tableName = $tableName;
+
+ return $this;
+ }
+
+ public function getTableName()
+ {
+ return $this->_tableName;
+ }
+}
diff --git a/src/application/code/core/Wootook/Core/Mvc/Model/EntityInterface.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/EntityInterface.php
similarity index 96%
rename from src/application/code/core/Wootook/Core/Mvc/Model/EntityInterface.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/EntityInterface.php
index e512a5d..da60043 100644
--- a/src/application/code/core/Wootook/Core/Mvc/Model/EntityInterface.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/EntityInterface.php
@@ -28,13 +28,15 @@
*
*/
+namespace Wootook\Core\Mvc\Model;
+
/**
*
* Enter description here ...
* @author Greg
*
*/
-interface Wootook_Core_Mvc_Model_EntityInterface
+interface EntityInterface
{
public function getId();
public function setId($id);
diff --git a/src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/SubTable.php
similarity index 67%
rename from src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/SubTable.php
index 791d481..faa3cc5 100644
--- a/src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/SubTable.php
@@ -1,13 +1,44 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+namespace Wootook\Core\Mvc\Model;
+
+use Wootook\Core,
+ Wootook\Core\Database,
+ Wootook\Core\Exception as CoreException;
/**
*
- * @uses Wootook_Object
- * @uses Legacies_Empire
- * @uses Wootook_Player_Model_Entity
+ * @uses Wootook\Core\BaseObject
*/
-abstract class Wootook_Core_Mvc_Model_Entity_SubTable
- extends Wootook_Core_Database_Resource
+abstract class SubTable
+ extends Core\Base\BaseObject
{
private $_isLoaded = false;
protected $_idFieldNames = array();
@@ -81,7 +112,7 @@ SQL_EOF;
$datas = $statement->fetch(PDO::FETCH_ASSOC);
if (!is_array($datas) || empty($datas)) {
- throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id combination could not be found.');
+ throw new CoreException\DataAccessException('Could not load data: this id combination could not be found.');
}
$this->_data = array();
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Base.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Base.php
new file mode 100644
index 0000000..631bae3
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Base.php
@@ -0,0 +1,96 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Model\Type;
+
+use Wootook\Core,
+ Wootook\Core\Database\Resource,
+ Wootook\Core\Exception as CoreException;
+
+/**
+ * Base model implementation, should be consumed by a Wootook\Core\BaseObject derived class
+ */
+trait Base
+{
+ protected $_originalData = array();
+
+ protected $_eventPrefix = null;
+ protected $_eventObject = null;
+
+ public function _construct(Array $data = array())
+ {
+ parent::_construct($data);
+
+ $this->_init();
+ $this->_setOriginalData();
+ }
+
+ protected function _init()
+ {
+ }
+
+ protected function _setOriginalData()
+ {
+ $this->_originalData = $this->_data;
+ }
+
+ public function getChangedDatas()
+ {
+ return array_diff_assoc($this->_data, $this->_originalData);
+ }
+
+ public function hasChangedDatas()
+ {
+ if (count($this->getChangedDatas()) > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ public function __set($key, $value)
+ {
+ return $this->setData($key, $value);
+ }
+
+ public function __get($key)
+ {
+ return $this->getData($key);
+ }
+
+ public function __unset($key)
+ {
+ return $this->unsetData($key);
+ }
+
+ public function __isset($key)
+ {
+ return $this->hasData($key);
+ }
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Full.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Full.php
new file mode 100644
index 0000000..ef18229
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Full.php
@@ -0,0 +1,46 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Model\Type;
+
+use Wootook\Core,
+ Wootook\Core\Database\Resource,
+ Wootook\Core\Mvc\Model\Action;
+
+/**
+ *
+ * Enter description here ...
+ * @author Greg
+ *
+ */
+trait Full
+{
+ use Base, Action\Load, Action\Save, Action\Delete, Resource\ReadConnection, Resource\WriteConnection, Resource\DataMapper;
+}
diff --git a/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Readonly.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Readonly.php
new file mode 100644
index 0000000..c210162
--- /dev/null
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/Model/Type/Readonly.php
@@ -0,0 +1,46 @@
+
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
+
+namespace Wootook\Core\Mvc\Model\Type;
+
+use Wootook\Core,
+ Wootook\Core\Mvc\Model\Action,
+ Wootook\Core\Exception as CoreException;
+
+/**
+ *
+ * Enter description here ...
+ * @author Greg
+ *
+ */
+trait Readonly
+{
+ use Base, Action\Load;
+}
diff --git a/src/application/code/core/Wootook/Core/Mvc/View/View.php b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/View/View.php
similarity index 85%
rename from src/application/code/core/Wootook/Core/Mvc/View/View.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Mvc/View/View.php
index 4847061..b95b941 100644
--- a/src/application/code/core/Wootook/Core/Mvc/View/View.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Mvc/View/View.php
@@ -28,14 +28,20 @@
*
*/
+namespace Wootook\Core\Mvc\View;
+
+use Wootook\Core,
+ Wootook\Core\Model;
+use Wootook_Player_Model_Session;
+
/**
*
* Enter description here ...
* @author Greg
*
*/
-class Wootook_Core_Mvc_View_View
- extends Wootook_Object
+class View
+ extends Core\Base\BaseObject
{
protected $_template = null;
protected $_partials = array();
@@ -44,14 +50,14 @@ class Wootook_Core_Mvc_View_View
protected $_scriptPath = null;
- public function __construct(Array $data = array())
+ public function _construct(Array $data = array())
{
if (isset($data['template'])) {
$this->_template = $data['template'];
unset($data['template']);
}
- parent::__construct($data);
+ parent::_construct($data);
}
protected function _prepareRender()
@@ -95,8 +101,8 @@ class Wootook_Core_Mvc_View_View
if ($format === null) {
$format = 'H:i:s';
}
- if (!$dateTime instanceof Wootook_Core_DateTime) {
- $dateTime = new Wootook_Core_DateTime($dateTime);
+ if (!$dateTime instanceof Core\DateTime) {
+ $dateTime = new Core\DateTime($dateTime);
}
return $dateTime->toString($format);
}
@@ -116,7 +122,7 @@ class Wootook_Core_Mvc_View_View
$args = func_get_args();
array_shift($args);
- return Wootook::translate(Wootook::getDefaultLocale(), $message, $args);
+ return \Wootook::translate(\Wootook::getDefaultLocale(), $message, $args);
}
public function translate($message, $_ = null)
@@ -124,7 +130,7 @@ class Wootook_Core_Mvc_View_View
$args = func_get_args();
array_shift($args);
- return Wootook::translate(Wootook::getLocale(), $message, $args);
+ return \Wootook::translate(\Wootook::getLocale(), $message, $args);
}
public function renderScript($file)
@@ -179,18 +185,19 @@ class Wootook_Core_Mvc_View_View
public function getUrl($uri, Array $params = array())
{
- return Wootook::getUrl($uri, $params);
+ return \Wootook::getUrl($uri, $params);
}
public function getStaticUrl($uri, Array $params = array())
{
- return Wootook::getStaticUrl($uri, $params);
+ return \Wootook::getStaticUrl($uri, $params);
}
public function getSkinUrl($uri, Array $params = array(), $theme = null, $package = null)
{
- if (Wootook::$isInstalled) {
- $player = Wootook_Player_Model_Session::getSingleton()->getPlayer();
+ if (\Wootook::$isInstalled) {
+ // FIXME: External dependency should not exist
+ $player = \Wootook\Player\Model\Session::getSingleton()->getPlayer();
if ($player !== null && $player->getId()) {
$theme = $player->getSkinPath();
}
@@ -199,19 +206,19 @@ class Wootook_Core_Mvc_View_View
$theme = $this->getLayout()->getTheme();
}
if ($theme === null || empty($theme)) {
- $theme = Wootook_Core_Model_Layout::DEFAULT_THEME;
+ $theme = Model\Layout::DEFAULT_THEME;
}
if ($package === null || empty($package)) {
$package = $this->getLayout()->getPackage();
}
if ($package === null || empty($package)) {
- $package = Wootook_Core_Model_Layout::DEFAULT_PACKAGE;
+ $package = Model\Layout::DEFAULT_PACKAGE;
}
$domain = $this->getLayout()->getDomain();
- $baseUrl = Wootook::getBaseUrl('skin');
- $basePath = Wootook::getBasePath('skin');
+ $baseUrl = \Wootook::getBaseUrl('skin');
+ $basePath = \Wootook::getBasePath('skin');
$pathPattern = $basePath . "{$domain}/%s/%s/{$uri}";
$urlPattern = $baseUrl . "{$domain}/%s/%s/{$uri}";
@@ -226,14 +233,14 @@ class Wootook_Core_Mvc_View_View
$urlPattern .= '?' . implode('&', $serializedParams);
}
- if (Wootook::fileExists(sprintf($pathPattern, $package, $theme))) {
+ if (\Wootook::fileExists(sprintf($pathPattern, $package, $theme))) {
return sprintf($urlPattern, $package, $theme);
}
- if (Wootook::fileExists(sprintf($pathPattern, $package, Wootook_Core_Model_Layout::DEFAULT_THEME))) {
- return sprintf($urlPattern, $package, Wootook_Core_Model_Layout::DEFAULT_THEME);
+ if (\Wootook::fileExists(sprintf($pathPattern, $package, Model\Layout::DEFAULT_THEME))) {
+ return sprintf($urlPattern, $package, Model\Layout::DEFAULT_THEME);
}
- return sprintf($urlPattern, Wootook_Core_Model_Layout::DEFAULT_PACKAGE, Wootook_Core_Model_Layout::DEFAULT_THEME);
+ return sprintf($urlPattern, Model\Layout::DEFAULT_PACKAGE, Model\Layout::DEFAULT_THEME);
}
public function setPartial($name, $content)
@@ -305,7 +312,7 @@ class Wootook_Core_Mvc_View_View
/**
*
- * @return Wootook_Core_Model_Layout
+ * @return Model\Layout
*/
public function getLayout()
{
diff --git a/src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php b/src/application/modules/WootookCore/src/Wootook/Core/PluginLoader/PluginLoader.php
similarity index 53%
rename from src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php
rename to src/application/modules/WootookCore/src/Wootook/Core/PluginLoader/PluginLoader.php
index eaaff7a..3d86696 100644
--- a/src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/PluginLoader/PluginLoader.php
@@ -1,6 +1,36 @@
+ * 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 .
+ *
+ * --> 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.
+ *
+ */
-abstract class Wootook_Core_PluginLoader_PluginLoader
+namespace Wootook\Core\PluginLoader;
+
+abstract class PluginLoader
{
protected $_pluginInstances = array();
protected $_namespaces = array();
@@ -11,17 +41,13 @@ abstract class Wootook_Core_PluginLoader_PluginLoader
return $this->_pluginInstances[$pluginName];
}
- $pluginName = str_replace(' ', '_', ucwords(str_replace('.', ' ', $pluginName)));
+ $pluginName = str_replace(' ', '\\', ucwords(str_replace('.', ' ', $pluginName)));
$pluginName = str_replace(' ', '', ucwords(str_replace('-', ' ', $pluginName)));
foreach ($this->_namespaces as $namespace => $path) {
- $className = $namespace . $pluginName;
+ $className = $namespace . '\\' . $pluginName;
$fileName = $path . DIRECTORY_SEPARATOR .
- str_replace('_', DIRECTORY_SEPARATOR, $pluginName) . '.php';
-
- if (!Wootook::fileExists($fileName)) {
- continue;
- }
+ str_replace('\\', DIRECTORY_SEPARATOR, $pluginName) . '.php';
if (!class_exists($className, true)) {
continue;
@@ -36,7 +62,7 @@ abstract class Wootook_Core_PluginLoader_PluginLoader
public function registerNamespace($namespace, $path = null)
{
if ($path === null) {
- $path = str_replace('_', DIRECTORY_SEPARATOR, $namespace);
+ $path = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
}
$this->_namespaces[$namespace] = $path;
@@ -77,4 +103,4 @@ abstract class Wootook_Core_PluginLoader_PluginLoader
return $this;
}
-}
\ No newline at end of file
+}
diff --git a/src/application/code/core/Wootook/Core/ErrorProfiler.php b/src/application/modules/WootookCore/src/Wootook/Core/Profiler/ErrorProfiler.php
similarity index 70%
rename from src/application/code/core/Wootook/Core/ErrorProfiler.php
rename to src/application/modules/WootookCore/src/Wootook/Core/Profiler/ErrorProfiler.php
index a957b62..276e4f7 100644
--- a/src/application/code/core/Wootook/Core/ErrorProfiler.php
+++ b/src/application/modules/WootookCore/src/Wootook/Core/Profiler/ErrorProfiler.php
@@ -28,13 +28,15 @@
*
*/
+namespace Wootook\Core\Profiler;
+
+use Wootook\Core\Config,
+ Wootook\Core\Exception as CoreException;
+
/**
- *
- * Enter description here ...
- * @author Greg
- *
+ * Error profiler, displays details about PHP core errors and uncaught exceptions.
*/
-class Wootook_Core_ErrorProfiler
+class ErrorProfiler
{
private static $_singleton = null;
@@ -48,11 +50,11 @@ class Wootook_Core_ErrorProfiler
private $_listen = true;
- private $_mute = true;
+ private $_mute = false;
/**
*
- * @return Wootook_Core_ErrorProfiler
+ * @return ErrorProfiler
*/
public static function getSingleton()
{
@@ -62,6 +64,14 @@ class Wootook_Core_ErrorProfiler
return self::$_singleton;
}
+ /**
+ * @param $errno
+ * @param $errstr
+ * @param null $errfile
+ * @param null $errline
+ * @param array $errcontext
+ * @return bool
+ */
public function errorManager($errno, $errstr, $errfile = null, $errline = null, Array $errcontext = array())
{
if (!$this->_listen) {
@@ -71,59 +81,59 @@ class Wootook_Core_ErrorProfiler
$trace = debug_backtrace();
switch ($errno) {
- case E_RECOVERABLE_ERROR:
- case E_USER_ERROR:
- case E_ERROR:
- $this->_errors[] = array(
- 'time' => explode(' ', microtime()),
- 'code' => $errno,
- 'message' => $errstr,
- 'file' => $errfile,
- 'line' => $errline,
- 'context' => $errcontext,
- 'trace' => $trace
+ case E_RECOVERABLE_ERROR:
+ case E_USER_ERROR:
+ case E_ERROR:
+ $this->_errors[] = array(
+ 'time' => explode(' ', microtime()),
+ 'code' => $errno,
+ 'message' => $errstr,
+ 'file' => $errfile,
+ 'line' => $errline,
+ 'context' => $errcontext,
+ 'trace' => $trace
);
break;
- case E_USER_WARNING:
- case E_WARNING:
- $this->_warnings[] = array(
- 'time' => explode(' ', microtime()),
- 'code' => $errno,
- 'message' => $errstr,
- 'file' => $errfile,
- 'line' => $errline,
- 'context' => $errcontext,
- 'trace' => $trace
+ case E_USER_WARNING:
+ case E_WARNING:
+ $this->_warnings[] = array(
+ 'time' => explode(' ', microtime()),
+ 'code' => $errno,
+ 'message' => $errstr,
+ 'file' => $errfile,
+ 'line' => $errline,
+ 'context' => $errcontext,
+ 'trace' => $trace
);
break;
- case E_USER_NOTICE:
- case E_NOTICE:
- $this->_notices[] = array(
- 'time' => explode(' ', microtime()),
- 'code' => $errno,
- 'message' => $errstr,
- 'file' => $errfile,
- 'line' => $errline,
- 'context' => $errcontext,
- 'trace' => $trace
+ case E_USER_NOTICE:
+ case E_NOTICE:
+ $this->_notices[] = array(
+ 'time' => explode(' ', microtime()),
+ 'code' => $errno,
+ 'message' => $errstr,
+ 'file' => $errfile,
+ 'line' => $errline,
+ 'context' => $errcontext,
+ 'trace' => $trace
);
break;
- default:
- if (!isset($this->_otherErrors[$errno])) {
- $this->_otherErrors[$errno] = array();
- }
+ default:
+ if (!isset($this->_otherErrors[$errno])) {
+ $this->_otherErrors[$errno] = array();
+ }
- $this->_otherErrors[$errno][] = array(
- 'time' => explode(' ', microtime()),
- 'code' => $errno,
- 'message' => $errstr,
- 'file' => $errfile,
- 'line' => $errline,
- 'context' => $errcontext,
- 'trace' => $trace
+ $this->_otherErrors[$errno][] = array(
+ 'time' => explode(' ', microtime()),
+ 'code' => $errno,
+ 'message' => $errstr,
+ 'file' => $errfile,
+ 'line' => $errline,
+ 'context' => $errcontext,
+ 'trace' => $trace
);
break;
}
@@ -131,19 +141,36 @@ class Wootook_Core_ErrorProfiler
return true;
}
- public function addException($exception)
+ /**
+ * Add a caught exception to the error profiler
+ *
+ * @param \Exception $exception
+ * @return void
+ */
+ public function addException(\Exception $exception)
{
$this->_exceptions[] = $exception;
}
- public function exceptionManager($exception)
+ /**
+ * Exception manager, fallback function for uncaught exceptions
+ *
+ * @param \Exception $exception
+ * @return void
+ */
+ public function exceptionManager(\Exception $exception)
{
if (!$this->_listen) {
return;
}
- $this->_exceptions[] = new Wootook_Core_Exception_Exception('Uncaught Exception: ' . $exception->getMessage(), null, $exception);
+ $this->_exceptions[] = new CoreException\Exception('Uncaught Exception: ' . $exception->getMessage(), null, $exception);
}
+ /**
+ * @param $id
+ * @param $error
+ * @return string
+ */
protected function _renderError($id, $error)
{
$types = array(
@@ -162,7 +189,7 @@ class Wootook_Core_ErrorProfiler
0x1000 => 'E_RECOVERABLE_ERROR',
0x2000 => 'E_DEPRECATED',
0x4000 => 'E_USER_DEPRECATED',
- );
+ );
if (isset($error['code']) && isset($types[$error['code']])) {
$code = $types[$error['code']];
@@ -171,10 +198,10 @@ class Wootook_Core_ErrorProfiler
}
$date = date('Y-m-d H:i:s', (int) $error['time'][1]);
- $microsec = (int) ($error['time'][0] * 1000000);
+ $microSec = (int) ($error['time'][0] * 1000000);
return <<';
foreach ($config as $key => $value) {
$output .= sprintf('