Compare commits

...
Sign in to create a new pull request.
Author SHA1 Message Date
Gregory PLANCHAT
af103cce2c Updated DependencyInjection component's API
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-19 19:23:30 +02:00
Gregory PLANCHAT
2bed707ecd Updated DependencyInjection component's API
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-17 23:27:44 +02:00
Gregory PLANCHAT
07f18f5e76 Updated PHPUnit config
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-17 20:19:20 +02:00
Gregory PLANCHAT
8e8b4b3513 Updated DependencyInjection component
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-17 20:10:13 +02:00
Gregory PLANCHAT
6b393762d9 Fixed class call in unit tests
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-12 19:55:44 +02:00
Gregory PLANCHAT
7a9b3e9196 Updated Travis CI integration
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-12 11:08:33 +02:00
Gregory PLANCHAT
a8dff3d6d7 Updated integration to Travis-CI
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-12 10:42:02 +02:00
Gregory PLANCHAT
7a55d6e026 Added Dependency Injection configurator
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-12 03:28:28 +02:00
Gregory PLANCHAT
d75265a8fe Updated code base & unit tests of WootookCore module
Added a Dependency Injection
Started to refactor the Database\Sql\Dml component

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2012-07-12 02:37:05 +02:00
457 changed files with 19085 additions and 6498 deletions

6
.travis.yml Normal file
View file

@ -0,0 +1,6 @@
language: php
php:
- 5.4
script: sh build/build.sh

146
build.xml
View file

@ -1,146 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="name-of-project" default="build">
<target name="build"
depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpdoc,phpunit,phpcb"/>
<target name="build-parallel"
depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
<target name="tools-parallel"
description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd-ci"/>
</sequential>
<antcall target="phpcpd"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc"/>
<antcall target="phpdoc"/>
</parallel>
</target>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/code-browser"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
</target>
<target name="prepare" depends="clean"
description="Prepare for build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/code-browser"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/pdepend"/>
</target>
<target name="lint">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/src">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="pdepend"
description="Calculate software metrics using PHP_Depend">
<exec executable="pdepend">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpmd"
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpmd">
<arg path="${basedir}/src" />
<arg value="text" />
<arg value="${basedir}/build/phpmd.xml" />
</exec>
</target>
<target name="phpmd-ci"
description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg path="${basedir}/src" />
<arg value="xml" />
<arg value="${basedir}/build/phpmd.xml" />
<arg value="--reportfile" />
<arg value="${basedir}/build/logs/pmd.xml" />
</exec>
</target>
<target name="phpcs"
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="phpcs">
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpcs-ci"
description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=${basedir}/build/phpcs.xml" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd" />
<arg value="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/src" />
</exec>
</target>
<target name="phpdoc"
description="Generate API documentation using PHPDocumentor">
<exec executable="phpdoc">
<arg value="--directory" />
<arg path="${basedir}/src" />
<arg value="--target" />
<arg path="${basedir}/build/api" />
</exec>
</target>
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true"/>
</target>
<target name="phpcb"
description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log" />
<arg path="${basedir}/build/logs" />
<arg value="--source" />
<arg path="${basedir}/src" />
<arg value="--output" />
<arg path="${basedir}/build/code-browser" />
</exec>
</target>
</project>

13
build/build.sh Normal file
View file

@ -0,0 +1,13 @@
echo " * Wootook unit testing"
MODULES_DIR="`pwd`/src/application/modules"
for file in `find $MODULES_DIR -mindepth 1 -maxdepth 1 -type d`
do
echo " * Running `basename ${file}` module tests (Unit tests)"
phpunit --strict --colors --configuration ${file}/test/phpunit.xml ${file}/test/php/WootookUnit
#echo " * Running `basename ${file}` module tests (Integration tests)"
#phpunit --strict --colors --configuration ${file}/test/phpunit.xml ${file}/test/php/WootookUnit
done

View file

@ -16,3 +16,6 @@ SetEnv DEPRECATION On
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
# OVH.com
SetEnv PHP_VER 5_4

View file

@ -30,7 +30,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
require_once dirname(__FILE__) .'/application/bc.php';
$mode = Wootook::getRequest()->getPost('mode');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
includeLang('admin');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN))) {
includeLang('admin/Queries');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
include(ROOT_PATH . 'includes/functions/BuildFlyingFleetTable.'.PHPEXT);

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
includeLang('admin');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();

View file

@ -32,7 +32,7 @@ define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin/addmoon');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN))) {
doquery("UPDATE {{table}} SET `banaday` =` banaday` - '1' WHERE `banaday` != '0';",'users');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
includeLang('admin');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
includeLang('changelog');
$template = gettemplate('changelog_table');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
includeLang('admin');
$parse = $lang;

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
includeLang('credit');
$parse = $lang;

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($CurrentUser['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
$PageTpl = gettemplate( "admin/deletuser" );

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
includeLang('admin');
$parse = $lang;

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
includeLang('leftmenu');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
includeLang('admin/changepass');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
includeLang('admin/md5enc');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin/messagelist');

View file

@ -32,7 +32,7 @@ define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
if (!empty($_POST)) {

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('overview');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
includeLang('admin/multi');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
includeLang('admin');

View file

@ -32,7 +32,7 @@ define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
function DisplayGameSettingsPage($CurrentUser) {

View file

@ -32,7 +32,7 @@ define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
include(ROOT_PATH . 'admin/statfunctions.' . PHPEXT);

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin');

View file

@ -31,7 +31,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
require_once dirname(dirname(__FILE__)) .'/application/bc.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {

View file

@ -30,7 +30,7 @@
define('INSTALL' , false);
define('INSIDE' , true);
require_once dirname(__FILE__) .'/application/bootstrap.php';
require_once dirname(__FILE__) .'/application/bc.php';
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
$db = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection(Wootook_Core_Database_ConnectionManager::DEFAULT_CONNECTION_NAME);

View file

@ -30,7 +30,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
require_once dirname(__FILE__) .'/application/bc.php';
$readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read');
$writeAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_write');

View file

@ -30,7 +30,7 @@
define('INSIDE' , true);
define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
require_once dirname(__FILE__) .'/application/bc.php';
$actions = $_GET['action'];

103
src/application/bc.php Normal file
View file

@ -0,0 +1,103 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
require_once __DIR__ . '/bc.php';
if (defined('IN_ADMIN')) {
Wootook::app()->setDefaultWebsiteId(0);
Wootook::app()->setDefaultGameId(0);
}
include ROOT_PATH . 'includes/constants.php';
if (!Wootook::$isInstalled) {
Wootook::app()->getFrontController()
->getResponse()
->setRedirect(Wootook::getStaticUrl('install/'), Wootook\Core\Mvc\Controller\Response\Http::REDIRECT_TEMPORARY)
->sendHeaders();
exit(0);
}
$lang = array();
define('DEFAULT_LANG', 'fr');
include(ROOT_PATH . 'includes/functions.' . PHPEXT);
include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT);
include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT);
include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg');
include(ROOT_PATH . 'includes/vars.' . PHPEXT);
include(ROOT_PATH . 'includes/strings.' . PHPEXT);
$user = Wootook\Player\Model\Session::getSingleton()->getPlayer();
if (!defined('DISABLE_IDENTITY_CHECK')) {
if ($user === null || !$user->getId()) {
Wootook::getResponse()
->setRedirect(Wootook::getUrl('player/account/login'))
->sendHeaders();
exit(0);
}
if (!Wootook::getGameConfig('game/general/active') && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) {
$layout = new Wootook\Core\Layout\Manager(Wootook\Core\Layout\Manager::DOMAIN_FRONTEND);
$layout->load('message');
$block = $layout->getBlock('message');
$block['title'] = Wootook::__('Game is disabled.');
$block['message'] = Wootook::getGameConfig('game/general/closing-message');
echo $layout->render();
exit(0);
}
}
includeLang('system');
includeLang('tech');
if (($user !== null && $user->getId())) {
if (isset($_GET['cp']) && !empty($_GET['cp'])) {
$user->updateCurrentPlanet((int) $_GET['cp']);
}
$planet = $user->getCurrentPlanet();
foreach ($user->getPlanetCollection() as $userPlanet) {
FlyingFleetHandler($userPlanet); // TODO: implement logic into a refactored model
}
/*
* Update planet resources and constructions
*/
Wootook::dispatchEvent('planet.update', array(
'planet' => $planet
));
$planet->save();
}

View file

@ -28,6 +28,9 @@
*
*/
define('DEBUG', true);
define('DEPRECATION', true);
if (!defined('PHP_VERSION_ID')) {
$version = explode('.',PHP_VERSION);
define('PHP_VERSION_ID', (((int)$version[0]) * 10000 + ((int)$version[1]) * 100 + ((int)$version[2])));
@ -67,97 +70,12 @@ defined('PHPEXT') || define('PHPEXT', 'php');
defined('VERSION') || define('VERSION', '1.5.0-beta2');
set_include_path(implode(PATH_SEPARATOR, array(
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'libraries',
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'local',
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'community',
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'core',
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'modules',
get_include_path()
)));
function __autoload($class) {
include_once str_replace('_', '/', $class) . '.php';
}
include APPLICATION_PATH . 'code' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'Wootook.php';
include 'WootookCore' . DIRECTORY_SEPARATOR . 'autoload_register.php';
if (defined('IN_ADMIN')) {
$website = new Wootook_Core_Model_Website();
$website->setId(0)->setData('code', 'admin');
Wootook::addWebsite($website);
Wootook::setDefaultWebsite($website);
$game = new Wootook_Core_Model_Game();
$game->setId(0)->setData('code', 'admin')->setData('website_id', $website->getId());
Wootook::addGame($game);
Wootook::setDefaultGame($game);
}
include ROOT_PATH . 'includes/constants.php';
if (defined('DEBUG')) {
Wootook_Core_ErrorProfiler::register();
}
Wootook_Core_Helper_Config_Events::registerEvents();
if (!Wootook::$isInstalled) {
Wootook::getResponse()
->setRedirect(Wootook::getStaticUrl('install/'), Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_TEMPORARY)
->sendHeaders();
exit(0);
}
$lang = array();
define('DEFAULT_LANG', 'fr');
include(ROOT_PATH . 'includes/functions.' . PHPEXT);
include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT);
include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT);
include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg');
include(ROOT_PATH . 'includes/vars.' . PHPEXT);
include(ROOT_PATH . 'includes/strings.' . PHPEXT);
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
if (!defined('DISABLE_IDENTITY_CHECK')) {
if ($user === null || !$user->getId()) {
Wootook::getResponse()
->setRedirect(Wootook::getUrl('player/account/login'))
->sendHeaders();
exit(0);
}
//var_dump(Wootook::getGameConfig('game/general/active'));
if (!Wootook::getGameConfig('game/general/active')/* && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))*/) {
$layout = new Wootook_Core_Model_Layout(Wootook_Core_Model_Layout::DOMAIN_FRONTEND);
$layout->load('message');
$block = $layout->getBlock('message');
$block['title'] = Wootook::__('Game is disabled.');
$block['message'] = Wootook::getGameConfig('game/general/closing-message');
echo $layout->render();
exit(0);
}
}
includeLang('system');
includeLang('tech');
if (($user !== null && $user->getId())) {
if (isset($_GET['cp']) && !empty($_GET['cp'])) {
$user->updateCurrentPlanet((int) $_GET['cp']);
}
$planet = $user->getCurrentPlanet();
foreach ($user->getPlanetCollection() as $userPlanet) {
FlyingFleetHandler($userPlanet); // TODO: implement logic into a refactored model
}
/*
* Update planet resources and constructions
*/
Wootook::dispatchEvent('planet.update', array(
'planet' => $planet
));
$planet->save();
}
Wootook\Core\Profiler\ErrorProfiler::register();
Wootook\Core\Helper\Config\Events::registerEvents();

View file

@ -63,7 +63,7 @@ class Legacies_Empire_Block_Planet_ResearchLab_Item
$resourceConfig = array();
foreach ($resources as $resourceId => $resourceValue) {
$resourceConfig[$resourceId] = new Wootook_Object(array(
$resourceConfig[$resourceId] = new Wootook\Core\BaseObject(array(
'resource_id' => $resourceId,
'value' => $resourceValue
));

View file

@ -74,7 +74,7 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item
$resourceConfig = array();
foreach ($resources as $resourceId => $resourceValue) {
$resourceConfig[$resourceId] = new Wootook_Object(array(
$resourceConfig[$resourceId] = new Wootook\Core\BaseObject(array(
'resource_id' => $resourceId,
'value' => $resourceValue
));

View file

@ -68,7 +68,7 @@ class Legacies_Empire_Block_Planet_Shipyard_Item
$resourceConfig = array();
foreach ($resources as $resourceId => $resourceValue) {
$resourceConfig[$resourceId] = new Wootook_Object(array(
$resourceConfig[$resourceId] = new Wootook\Core\BaseObject(array(
'resource_id' => $resourceId,
'value' => $resourceValue
));

View file

@ -74,7 +74,7 @@ class Legacies_Empire_Block_Planet_Shipyard_Queue_Item
$resourceConfig = array();
foreach ($resources as $resourceId => $resourceValue) {
$resourceConfig[$resourceId] = new Wootook_Object(array(
$resourceConfig[$resourceId] = new Wootook\Core\BaseObject(array(
'resource_id' => $resourceId,
'value' => $resourceValue
));

View file

@ -54,7 +54,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
{
$this->_unserializeQueue($this->_currentPlanet->getData(self::FIELD_SERIALIZED));
$this->_maxLength = Wootook::getGameConfig('engine/core/lab_queue_size');
$this->_maxLength = Wootook::app()->getDefaultGame()->getConfig('engine/core/lab_queue_size');
}
/**
@ -144,7 +144,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab_Builder
$partialLevelTime = Math::mul($firstLevelTime, Math::pow($prices[$technologyId][Legacies_Empire::RESOURCE_MULTIPLIER], $level));
$levelTime = Math::sub($partialLevelTime, $firstLevelTime);
$speedFactor = Wootook::getGameConfig('game/speed/general');
$speedFactor = Wootook::app()->getDefaultGame()->getConfig('game/speed/general');
if ($speedFactor == null) {
$speedFactor = 1;
}

View file

@ -207,7 +207,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
Math::setPrecision(50);
$buildingTime = Math::mul($prices[$shipId][Legacies_Empire::BASE_BUILDING_TIME], intval($qty));
$speedFactor = Wootook::getGameConfig('game/speed/general') / 1000;
$speedFactor = Wootook::app()->getDefaultGame()->getConfig('game/speed/general') / 1000;
$baseTime = Math::mul(Math::div($buildingTime, 5000), Math::mul($speedFactor, $this->getSpeedEnhancement()));
Math::setPrecision();

View file

@ -28,6 +28,9 @@
*
*/
use Wootook\Core\Exception as CoreException,
Wootook\Core\Profiler;
/**
* Bootstrap class, used to access main and global functionalities
*
@ -50,20 +53,6 @@ class Wootook
*/
private static $_translators = array();
/**
* HTTP request management object
*
* @var Legacies_Core_Controller_Request_Http
*/
private static $_request = null;
/**
* HTTP response management object
*
* @var Legacies_Core_Controller_Response
*/
private static $_response = null;
/**
* The current timestamp
*
@ -78,34 +67,6 @@ class Wootook
*/
private static $_defaultLocale = 'fr_FR';
/**
*
* Enter description here ...
* @var Wootook_Core_Helper_Config_ConfigHandler
*/
private static $_config = null;
/**
*
* Enter description here ...
* @var Wootook_Core_Helper_Config_ConfigHandler
*/
private static $_globalConfig = null;
/**
*
* Enter description here ...
* @var array
*/
private static $_websiteConfigs = array();
/**
*
* Enter description here ...
* @var array
*/
private static $_gameConfigs = array();
/**
*
* Enter description here ...
@ -113,16 +74,10 @@ class Wootook
*/
private static $_ignoreDatabaseConfig = false;
private static $_defaultWebsite = null;
private static $_defaultGame = null;
private static $_websitesById = array();
private static $_websitesByCode = array();
private static $_gamesById = array();
private static $_gamesByCode = array();
public static $isInstalled = true;
protected static $_app = array();
/**
* Registers an event listener to be called later in the application.
*
@ -165,7 +120,7 @@ class Wootook
*/
public static function dispatchEvent($event, $params)
{
$eventObject = new Wootook_Core_Event($params);
$eventObject = new Wootook\Core\Event\Event(self::app(), $params);
if (!isset(self::$_listeners[$event])) {
return $eventObject;
@ -182,17 +137,17 @@ class Wootook
*
* Enter description here ...
* @param unknown_type $namespace
* @return Wootook_Core_Model_Session
* @return Wootook\Core\Model\Session
*/
public static function getSession($namespace)
{
return Wootook_Core_Model_Session::factory($namespace);
return Wootook\Core\Model\Session::factory($namespace);
}
/**
* @static
* @param string|null $locale
* @return Wootook_Core_Model_Translator
* @return Wootook\Core\Model\Translator
*/
public static function getTranslator($locale = null)
{
@ -202,7 +157,7 @@ class Wootook
if (!isset($translator[$locale])) {
$path = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'locale';
$translator[$locale] = new Wootook_Core_Model_Translator($path, $locale);
$translator[$locale] = new Wootook\Core\Model\Translator($path, $locale);
}
return $translator[$locale];
}
@ -222,7 +177,7 @@ class Wootook
public static function getLocale()
{
$availableLocales = self::getWebsiteConfig('locales');
$availableLocales = self::app()->getDefaultWebsite()->getConfig('locales');
if ($availableLocales !== null) {
return self::getPreferredLocale($availableLocales->toArray());
}
@ -248,14 +203,17 @@ class Wootook
return self::getDefaultLocale();
}
$userLocale = Wootook_Player_Model_Session::getSingleton()->getData('locale');
// FIXME: Dependency should not exist
/*
$userLocale = Wootook\Player\Model\Session::getSingleton()->getData('locale');
if ($userLocale !== null && in_array($userLocale, $availableLocales)) {
return $userLocale;
}
*/
$locales = array();
if (($accept = self::getRequest()->getServer('HTTP_ACCEPT_LANGUAGE')) !== null) {
if (($accept = self::app()->getFrontController()->getRequest()->getServer('HTTP_ACCEPT_LANGUAGE')) !== null) {
// break up string into pieces (languages and q factors)
preg_match_all('/([a-z]{1,8}(?:-([a-z]{1,8}))?)\s*(?:;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $accept, $matches);
@ -287,437 +245,247 @@ class Wootook
}
}
Wootook_Player_Model_Session::getSingleton()->setData('locale', $preferredLocale);
// FIXME: Dependency should not exist
//Wootook\Player\Model\Session::getSingleton()->setData('locale', $preferredLocale);
return $preferredLocale;
}
/**
* @static
* @return Wootook_Core_DateTime
* @return Wootook\Core\DateTime
*/
public static function now()
{
if (self::$_now === null) {
self::$_now = time();
}
return new Wootook_Core_DateTime(self::$_now);
}
/**
* @return Wootook_Core_Mvc_Controller_Request_Http
*/
public static function getRequest()
{
if (self::$_request === null) {
self::$_request = new Wootook_Core_Mvc_Controller_Request_Http();
}
return self::$_request;
}
public static function setRequest($request)
{
self::$_request = $request;
}
/**
* @return Wootook_Core_Mvc_Controller_Response_Http
*/
public static function getResponse()
{
if (self::$_response === null) {
self::$_response = new Wootook_Core_Mvc_Controller_Response_Http();
}
return self::$_response;
}
public static function setResponse($response)
{
self::$_response = $response;
}
public static function loadConfig($filename = null)
{
self::$_websiteConfigs = array();
self::$_gameConfigs = array();
self::$_config = new Wootook_Core_Config_Adapter_Array();
try {
self::$_config->load(APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'system.php');
if ($filename === null) {
$filename = APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'local.php';
}
if (is_string($filename)) {
if (!self::$isInstalled) {
throw new Wootook_Core_Exception_DataAccessException();
}
$localConfig = new Wootook_Core_Config_Adapter_Array($filename);
self::$_config->merge($localConfig);
} else if (is_array($filename)) {
$localConfig = new Wootook_Core_Config_Node($filename);
self::$_config->merge($localConfig);
} else if ($filename instanceof Wootook_Core_Config_Node) {
self::$_config->merge($filename);
} else {
throw new Wootook_Core_Exception_DataAccessException();
}
} catch (Wootook_Core_Exception_DataAccessException $e) {
self::$_globalConfig = new Wootook_Core_Config_Node(array(), self::$_config);
self::$_ignoreDatabaseConfig = true;
return self::$_config;
}
self::$_globalConfig = clone self::$_config['default'];
if (isset(self::$_config['global'])) {
self::$_globalConfig->merge(self::$_config['global']);
}
self::_appendDatabaseConfig(self::$_globalConfig);
return self::$_config;
}
private static function _appendDatabaseConfig(Wootook_Core_Config_Node $config, $type = 'global', $model = null)
{
if (self::$_ignoreDatabaseConfig || !self::$isInstalled) {
return $config;
}
try {
$adapter = Wootook_Core_Database_ConnectionManager::getSingleton()
->getConnection('core_read');
} catch (Wootook_Core_Exception_Database_AdapterError $e) {
// This may also occur when the pdo_sqlite driver isn't loaded
self::$isInstalled = false;
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
return $config;
}
$select = $adapter->select($adapter->getTable('core_config'));
switch ($type) {
case 'website':
$select->where(new Wootook_Core_Database_Sql_Placeholder_Expression('website_id = :website_id', array('website_id' => $model->getId())));
break;
case 'game':
$select->where(new Wootook_Core_Database_Sql_Placeholder_Expression('game_id = :game_id', array('game_id' => $model->getId())));
break;
default:
$select->where('website_id', 0);
$select->where('game_id', 0);
break;
}
$statement = $select->prepare();
$statement->execute();
foreach ($statement as $row) {
$config->setConfig($row['config_path'], $row['config_value']);
}
return $config;
}
public static function getWebsite($websiteId)
{
if (is_numeric($websiteId)) {
if (isset(self::$_websitesById[$websiteId])) {
return self::$_websitesById[$websiteId];
}
$website = new Wootook_Core_Model_Website();
try {
$website->load($websiteId);
$websiteCode = $website->getData('code');
self::$_websitesById[$websiteId] = $website;
self::$_websitesByCode[$websiteCode] = $website;
} catch (Wootook_Core_Exception_DataAccessException $e) {
throw new Wootook_Core_Exception_WebsiteError('Could not load website entity.', null, $e);
}
return $website;
} else {
if (isset(self::$_websitesByCode[$websiteId])) {
return self::$_websitesByCode[$websiteId];
}
$website = new Wootook_Core_Model_Website();
try {
$website->load($websiteId, 'code');
$websiteId = $website->getId();
$websiteCode = $website->getData('code');
self::$_websitesById[$websiteId] = $website;
self::$_websitesByCode[$websiteCode] = $website;
} catch (Wootook_Core_Exception_DataAccessException $e) {
throw new Wootook_Core_Exception_WebsiteError('Could not load website entity.', null, $e);
}
return $website;
}
}
public static function getGame($gameId)
{
if (is_numeric($gameId)) {
if (isset(self::$_gamesById[$gameId])) {
return self::$_gamesById[$gameId];
}
$game = new Wootook_Core_Model_Game();
try {
$game->load($gameId);
$gameCode = $game->getData('code');
self::$_gamesById[$gameId] = $game;
self::$_gamesByCode[$gameCode] = $game;
} catch (Wootook_Core_Exception_DataAccessException $e) {
throw new Wootook_Core_Exception_GameError('Could not load game entity.', null, $e);
}
return $game;
} else {
if (isset(self::$_gamesByCode[$gameId])) {
return self::$_gamesByCode[$gameId];
}
$game = new Wootook_Core_Model_Game();
try {
$game->load($gameId, 'code');
$gameId = $game->getId();
$gameCode = $game->getData('code');
self::$_gamesById[$gameId] = $game;
self::$_gamesByCode[$gameCode] = $game;
} catch (Wootook_Core_Exception_DataAccessException $e) {
throw new Wootook_Core_Exception_GameError('Could not load game entity.', null, $e);
}
return $game;
}
}
public static function addWebsite(Wootook_Core_Model_Website $website)
{
$websiteId = $website->getId();
$websiteKey = $website->getData('code');
self::$_websitesById[$websiteId] = $website;
self::$_websitesByCode[$websiteKey] = $website;
}
public static function addGame(Wootook_Core_Model_Game $game)
{
$gameId = $game->getId();
$gameKey = $game->getData('code');
self::$_gamesById[$gameId] = $game;
self::$_gamesByCode[$gameKey] = $game;
}
public static function setDefaultWebsite(Wootook_Core_Model_Website $website)
{
self::$_defaultWebsite = $website;
}
public static function getDefaultWebsite()
{
if (self::$_defaultWebsite === null) {
self::$_defaultWebsite = new Wootook_Core_Model_Website();
self::$_defaultWebsite->setId(1)->setData('code', Wootook_Core_Model_Website::DEFAULT_CODE);
}
return self::$_defaultWebsite;
}
public static function getDefaultGame()
{
if (self::$_defaultGame === null) {
self::$_defaultGame = new Wootook_Core_Model_Game();
self::$_defaultGame->setId(1)->setData('code', Wootook_Core_Model_Game::DEFAULT_CODE);
}
return self::$_defaultGame;
}
public static function setDefaultGame(Wootook_Core_Model_Game $game)
{
self::$_defaultGame = $game;
}
private static function _initWebsiteConfig($websiteId)
{
if (self::$_config === null) {
self::loadConfig();
}
if (!self::$isInstalled) {
if (isset(self::$_config['default'])) {
self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE] = clone self::$_config['default'];
} else {
self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE] = new Wootook_Core_Config_Node(array(), self::$_config);
}
if (isset(self::$_config['install'])) {
self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE]->merge(self::$_config['install']);
}
return self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE];
}
try {
$website = self::getWebsite($websiteId);
} catch (Wootook_Core_Exception_WebsiteError $e) {
self::$isInstalled = false;
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
$website = new Wootook_Core_Model_Website();
$website->setId(0)->setData('code', 'install');
self::addWebsite($website);
self::setDefaultWebsite($website);
} catch (Wootook_Core_Exception_RuntimeException $e) {
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
return null;
}
$websiteKey = $website->getData('code');
$websiteId = $website->getId();
if (!isset(self::$_websiteConfigs[$websiteKey])) {
self::$_websiteConfigs[$websiteKey] = clone self::$_config['default'];
if ($websiteId != 0 && isset(self::$_config['frontend'])) {
self::$_websiteConfigs[$websiteKey]->merge(self::$_config['frontend']);
} else if ($websiteId == 0 && isset(self::$_config['backend'])) {
self::$_websiteConfigs[$websiteKey]->merge(self::$_config['backend']);
}
$websiteConfig = self::$_config->getConfig("website/{$websiteKey}");
if ($websiteConfig !== null) {
self::$_websiteConfigs[$websiteKey]->merge($websiteConfig);
}
self::_appendDatabaseConfig(self::$_websiteConfigs[$websiteKey], 'website', $website);
}
return self::$_websiteConfigs[$websiteKey];
}
private static function _initGameConfig($gameId)
{
if (self::$_config === null) {
self::loadConfig();
}
if (!self::$isInstalled) {
if (isset(self::$_config['default'])) {
self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE] = clone self::$_config['default'];
} else {
self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE] = new Wootook_Core_Config_Node(array(), self::$_config);
}
if (isset(self::$_config['install'])) {
self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE]->merge(self::$_config['install']);
}
return self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE];
}
try {
$game = self::getGame($gameId);
} catch (Wootook_Core_Exception_GameError $e) {
self::$isInstalled = false;
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
$game = new Wootook_Core_Model_Game();
$game->setId(0)->setData('code', 'install')->setData('website_id', self::getDefaultWebsite()->getId());
self::addGame($game);
self::setDefaultGame($game);
} catch (Wootook_Core_Exception_RuntimeException $e) {
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
return null;
}
$gameKey = $game->getData('code');
$gameId = $game->getId();
$websiteId = $game->getData('website_id');
if (!isset(self::$_gameConfigs[$gameKey])) {
$websiteConfig = self::_initWebsiteConfig($websiteId);
if ($websiteConfig === null) {
return null;
}
self::$_gameConfigs[$gameKey] = clone $websiteConfig;
$gameConfig = self::$_config->getConfig("game/{$gameKey}");
if ($gameConfig !== null) {
self::$_gameConfigs[$gameKey]->merge($gameConfig);
}
self::_appendDatabaseConfig(self::$_gameConfigs[$gameKey], 'game', $game);
}
return self::$_gameConfigs[$gameKey];
}
public static function getConfig($path = null)
{
if (self::$_config === null) {
self::loadConfig();
}
if ($path !== null) {
return self::$_globalConfig->getConfig($path);
}
return self::$_globalConfig;
return new Wootook\Core\DateTime(self::$_now);
}
/**
* @static
* @return Wootook\Core\App
*/
public static function app($domain = Wootook\Core\App::DOMAIN_FRONTEND, $environment = Wootook\Core\App::ENV_PRODUCTION)
{
if (!isset(self::$_app[$environment])) {
self::$_app[$environment] = array();
}
if (!isset(self::$_app[$environment][$domain])) {
$configPath = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'configs';
self::$_app[$environment][$domain] = new Wootook\Core\App($configPath, $domain, $environment);
}
return self::$_app[$environment][$domain];
}
/**
* @deprecated
* @return Wootook\Core\Mvc\Controller\Request\Request
*/
public static function getRequest()
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
return self::app()->getFrontController()->getRequest();
}
/**
* @static
* @deprecated
* @param Wootook\Core\Mvc\Controller\Request\Request $request
*/
public static function setRequest(Wootook\Core\Mvc\Controller\Request\Request $request)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
self::app()->getFrontController()->setRequest($request);
}
/**
* @deprecated
* @return Wootook\Core\Mvc\Controller\Response\Response
*/
public static function getResponse()
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
return self::app()->getFrontController()->getResponse();
}
/**
* @static
* @deprecated
* @param Wootook\Core\Mvc\Controller\Response\Response $response
*/
public static function setResponse(Wootook\Core\Mvc\Controller\Response\Response $response)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
self::app()->getFrontController()->setResponse($response);
}
/**
* @static
* @deprecated
* @param null $filename
* @return null|Wootook_Core_Helper_Config_ConfigHandler
* @throws CoreException\DataAccessException
*/
public static function loadConfig($filename = null)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
return self::app()->getGlobalConfig();
}
/**
* @static
* @deprecated
* @param $websiteId
* @return mixed
*/
public static function getWebsite($websiteId)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
return self::app()->getWebsite($websiteId);
}
/**
* @static
* @deprecated
* @param $gameId
* @return Wootook_Core_Model_Game
* @throws CoreException\GameError
*/
public static function getGame($gameId)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
return self::app()->getGame($gameId);
}
/**
* @static
* @deprecated
* @param Wootook_Core_Model_Website $website
*/
public static function addWebsite(Wootook_Core_Model_Website $website)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
}
/**
* @static
* @deprecated
* @param Wootook_Core_Model_Game $game
*/
public static function addGame(Wootook_Core_Model_Game $game)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
}
/**
* @static
* @deprecated
* @param Wootook_Core_Model_Website $website
*/
public static function setDefaultWebsite(Wootook_Core_Model_Website $website)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
self::app()->setDefaultWebsiteId($website->getId());
}
/**
* @static
* @deprecated
* @param Wootook_Core_Model_Game $game
*/
public static function setDefaultGame(Wootook_Core_Model_Game $game)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
self::app()->setDefaultGameId($game->getId());
}
/**
* @static
* @deprecated
* @return mixed
*/
public static function getDefaultWebsite()
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
return self::app()->getDefaultWebsite();
}
/**
* @static
* @deprecated
* @return mixed
*/
public static function getDefaultGame()
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
return self::app()->getDefaultGame();
}
/**
* @static
* @deprecated
* @param null $path
* @return null|Wootook_Core_Config_Adapter_Array
*/
public static function getConfig($path = null)
{
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
return self::app()->getGlobalConfig($path);
}
/**
* @static
* @deprecated
* @param null $path
* @param null $gameKey
* @return Wootook_Core_Config_Node
*/
public static function getWebsiteConfig($path = null, $websiteKey = null)
{
if (self::$_config === null) {
self::loadConfig();
}
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
if ($websiteKey === null) {
//$websiteKey = Wootook_Core_Model_Website::DEFAULT_CODE;
$websiteKey = self::getDefaultWebsite()->getData('code');
$websiteKey = self::app()->getDefaultWebsiteId();
}
$config = self::_initWebsiteConfig($websiteKey);
if ($config === null) {
return null;
}
if ($path !== null) {
return $config->getConfig($path);
}
return $config;
return self::app()->getWebsite($websiteKey)->getConfig($path);
}
/**
* @static
* @deprecated
* @param null $path
* @param null $gameKey
* @return Wootook_Core_Config_Node
*/
public static function getGameConfig($path = null, $gameKey = null)
{
if (self::$_config === null) {
self::loadConfig();
}
Profiler\ErrorProfiler::getSingleton()
->addException(new CoreException\RuntimeException('Method ' . __METHOD__ . ' is deprecated.'));
if ($gameKey === null) {
//$gameKey = Wootook_Core_Model_Game::DEFAULT_CODE;
$gameKey = self::getDefaultGame()->getData('code');
$gameKey = self::app()->getDefaultGameId();
}
$config = self::_initGameConfig($gameKey);
if ($config === null) {
return null;
}
if ($path !== null) {
return $config->getConfig($path);
}
return $config;
return self::app()->getGame($gameKey)->getConfig($path);
}
public static function setConfig($path, $value, $websiteId = null, $gameId = null)
@ -756,7 +524,7 @@ class Wootook
public static function getBaseUrl($domain = 'base')
{
$urlConfig = self::getGameConfig('web/url');
$urlConfig = self::app()->getDefaultGame()->getConfig('web/url');
if (!$urlConfig instanceof Wootook_Core_Config_Node) {
return null;
}
@ -768,7 +536,7 @@ class Wootook
public static function getBasePath($domain = 'base')
{
$pathConfig = self::getGameConfig('system/path');
$pathConfig = self::app()->getDefaultGame()->getConfig('system/path');
if (!$pathConfig instanceof Wootook_Core_Config_Node) {
return null;
}
@ -831,13 +599,13 @@ class Wootook
return false;
}
Wootook_Core_ErrorProfiler::getSingleton()->sleep();
Profiler\ErrorProfiler::getSingleton()->sleep();
if (($fp = @fopen($path, 'r', true)) === false) {
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
Profiler\ErrorProfiler::getSingleton()->wakeup();
return false;
}
fclose($fp);
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
Profiler\ErrorProfiler::getSingleton()->wakeup();
return true;
}
}

View file

@ -1,155 +0,0 @@
<?php
class Wootook_Core_App
{
/**
*
* Enter description here ...
* @var Wootook_Core_Config_Adapter_Adapter
*/
private $_globalConfig = null;
public function __construct($websiteCode, $gameCode)
{
$this->_globalConfig = Wootook::getConfig();
}
protected function _resolveClassType(&$namespaces, $module, $class)
{
$class = str_replace(' ', '', ucwords(str_replace('-', ' ', $class)));
$class = str_replace(' ', '_', ucwords(str_replace('.', ' ', $class)));
if (isset($namespaces[$module])) {
foreach ($namespaces[$module] as $namespace => $path) {
$className = $namespace . $class;
$fileName = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
Wootook_Core_ErrorProfiler::getSingleton()->sleep();
if (!($fp = @fopen($fileName, 'r', true))) {
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
continue;
}
Wootook_Core_ErrorProfiler::getSingleton()->wakeup();
fclose($fp);
if (!class_exists($className, true)) {
continue;
}
return $className;
}
}
Wootook_Core_ErrorProfiler::getSingleton()
->addException(new Wootook_Core_Exception_LayoutException(sprintf('Class type "%s" could not be resolved.', $type)));
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($type, 0, $offset);
$class = substr($type, $offset + 1);
}
public function block($identifier)
{
$this->_parseIdentifier($identifier, $module, $class);
return $this->getBlock($module, $class);
}
public function model($identifier)
{
$this->_parseIdentifier($identifier, $module, $class);
return $this->getModel($module, $class);
}
public function resource($identifier)
{
$this->_parseIdentifier($identifier, $module, $class);
return $this->getResource($module, $class);
}
public function helper($identifier)
{
$this->_parseIdentifier($identifier, $module, $class);
if ($class === null) {
$class = 'data';
}
return $this->getResource($module, $class);
}
public function getBlock($module, $class, Array $constructorParams = array())
{
$className = $this->_resolveClassType($this->_globalConfig->blocks, $module, $class);
return $this->_newInstance($className, $constructorParams);
}
public function getModel($module, $class, Array $constructorParams = array())
{
$className = $this->_resolveClassType($this->_globalConfig->models, $module, $class);
return $this->_newInstance($className, $constructorParams);
}
public function getResource($module, $class, Array $constructorParams = array())
{
$className = $this->_resolveClassType($this->_globalConfig->resources, $module, $class);
return $this->_newInstance($className, $constructorParams);
}
public function getHelper($module, $class, Array $constructorParams = array())
{
$className = $this->_resolveClassType($this->_globalConfig->helpers, $module, $class);
return $this->_newInstance($className, $constructorParams);
}
public function getBlockSingleton($module, $class, Array $constructorParams = array())
{
}
public function getModelSingleton($module, $class, Array $constructorParams = array())
{
}
public function getResourceSingleton($module, $class, Array $constructorParams = array())
{
}
public function getHelperSingleton($module, $class, Array $constructorParams = array())
{
}
}

View file

@ -1,14 +0,0 @@
<?php
class Wootook_Core_Block_Concat
extends Wootook_Core_Mvc_View_View
{
public function render()
{
$content = '';
foreach ($this->_partials as $partial) {
$content .= $partial->render();
}
return $content;
}
}

View file

@ -1,10 +0,0 @@
<?php
class Wootook_Core_Block_Deprecated
extends Wootook_Core_Block_Template
{
public function getScriptPath()
{
return $this->getLayout()->getScriptPath();
}
}

View file

@ -1,11 +0,0 @@
<?php
class Wootook_Core_Block_Html_Form
extends Wootook_Core_Block_Template
{
public function getFormKey()
{
$session = Wootook::getSession('security');
return $session->getFormKey(true);
}
}

View file

@ -1,22 +0,0 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: Greg
* Date: 24/03/12
* Time: 10:51
* To change this template use File | Settings | File Templates.
*/
class Wootook_Core_Block_Html_Home
extends Wootook_Core_Block_Template
{
public function getTitle()
{
return Wootook::getGameConfig('game/home/title');
}
public function getFormatedWelcomeText()
{
return Wootook::getGameConfig('game/home/formated-welcome-text');
}
}

View file

@ -1,27 +0,0 @@
<?php
class Wootook_Core_Block_Html_Navigation_Node
extends Wootook_Core_Block_Html_Navigation
{
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';
}
}

View file

@ -1,19 +0,0 @@
<?php
class Wootook_Core_Block_Html_Page
extends Wootook_Core_Block_Template
{
protected $_bodyClasses = array();
public function getBodyClasses()
{
return implode(' ', $this->_bodyClasses);
}
public function addBodyClass($class)
{
$this->_bodyClasses[] = $class;
return $this;
}
}

View file

@ -1,47 +0,0 @@
<?php
class Wootook_Core_Block_Messages
extends Wootook_Core_Block_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 = '<div class="messages">';
foreach ($messages as $messageLevel => $messageList) {
$output .= "<ul class=\"{$messageLevel}\">";
foreach ($messageList as $message) {
$output .= "<li>{$message}</li>";
}
$output .= '</ul>';
}
$output .= '</div>';
return $output;
}
}

View file

@ -1,46 +0,0 @@
<?php
class Wootook_Core_Block_Template
extends Wootook_Core_Mvc_View_View
{
protected function _getTemplatePath($file)
{
if ($this->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;
}
}

View file

@ -1,28 +0,0 @@
<?php
class Wootook_Core_Block_Text
extends Wootook_Core_Mvc_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;
}
}

View file

@ -1,6 +0,0 @@
<?php
abstract class Wootook_Core_Config_Adapter_Adapter
extends Wootook_Core_Config_Node
{
}

View file

@ -1,35 +0,0 @@
<?php
class Wootook_Core_Config_Adapter_Array
extends Wootook_Core_Config_Adapter_Adapter
{
public function __construct($filename = null)
{
if ($filename !== null) {
$this->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;
}
}

View file

@ -1,11 +0,0 @@
<?php
class Wootook_Core_Controller_ErrorController
extends Wootook_Core_Mvc_Controller_Action
{
public function noRouteAction()
{
$this->loadLayout('no-route');
$this->renderLayout();
}
}

View file

@ -1,11 +0,0 @@
<?php
class Wootook_Core_Controller_IndexController
extends Wootook_Core_Mvc_Controller_Action
{
public function indexAction()
{
$this->loadLayout('home');
$this->renderLayout();
}
}

View file

@ -1,199 +0,0 @@
<?php
abstract class Wootook_Core_Database_Adapter_Adapter
{
protected $_handler = null;
protected $_tablePrefix = null;
public function getDriverHandler()
{
return $this->_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();
}

View file

@ -1,170 +0,0 @@
<?php
class Wootook_Core_Database_Adapter_Pdo_Mysql
extends Wootook_Core_Database_Adapter_Adapter
{
/**
*
* Enter description here ...
* @param Wootook_Core_Config_Node $config
* @param array $params
*/
public function __construct(Wootook_Core_Config_Node $config, Array $options = array())
{
$dsn = "mysql:host={$config->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];
}
}

View file

@ -1,15 +0,0 @@
<?php
class Wootook_Core_Database_Orm_DataMapper_Array
extends Wootook_Core_Database_Orm_DataMapper_FieldMapper
{
public function encode($value)
{
return serialize($value);
}
public function decode($value)
{
return unserialize($value);
}
}

View file

@ -1,15 +0,0 @@
<?php
class Wootook_Core_Database_Orm_DataMapper_Config
extends Wootook_Core_Database_Orm_DataMapper_FieldMapper
{
public function encode($value)
{
return parent::encode($value->toArray());
}
public function decode($value)
{
return new Wootook_Core_Config_Node(parent::decode($value));
}
}

View file

@ -1,38 +0,0 @@
<?php
class Wootook_Core_Database_Orm_DataMapper_DateTime
extends Wootook_Core_Database_Orm_DataMapper_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 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());
}
}

View file

@ -1,15 +0,0 @@
<?php
abstract class Wootook_Core_Database_Orm_DataMapper_FieldMapper
{
protected $_mapper = null;
public function __construct(Wootook_Core_Database_Orm_DataMapper $mapper = null)
{
$this->_mapper = $mapper;
}
abstract public function encode($value);
abstract public function decode($value);
}

View file

@ -1,43 +0,0 @@
<?php
class Wootook_Core_Database_Orm_DataMapper_Object
extends Wootook_Core_Database_Orm_DataMapper_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;
}
}

View file

@ -1,89 +0,0 @@
<?php
abstract class Wootook_Core_Database_Resource
extends Wootook_Core_Mvc_Model_Model
{
protected $_readConnection = null;
protected $_writeConnection = null;
protected $_tableName = null;
protected $_dataMapper = null;
/**
*
* @return Wootook_Core_Database_Orm_DataMapper
*/
public function getDataMapper()
{
if ($this->_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;
}
}

View file

@ -1,24 +0,0 @@
<?php
interface Wootook_Core_Database_Sql_Dml
{
function __construct(Wootook_Core_Database_Adapter_Adapter $connection, $param = null);
function render();
function toString($part = null);
function getPart($part = null);
function reset($part = null);
function quote($data);
function quoteIdentifier($identifier);
function setConnection(Wootook_Core_Database_Adapter_Adapter $connection);
function getConnection();
function beforePrepare(Wootook_Core_Database_Statement_Statement $statement);
function afterPrepare(Wootook_Core_Database_Statement_Statement $statement);
function beforeExecute(Wootook_Core_Database_Statement_Statement $statement);
function afterExecute(Wootook_Core_Database_Statement_Statement $statement);
}

View file

@ -1,107 +0,0 @@
<?php
abstract class Wootook_Core_Database_Sql_DmlQuery
implements Wootook_Core_Database_Sql_Dml
{
protected $_parts = array();
protected $_connection = null;
protected $_placeholders = array();
public function __construct(Wootook_Core_Database_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(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);
}
}

View file

@ -1,6 +0,0 @@
<?php
class Wootook_Core_Database_Sql_Mysql_Select
extends Wootook_Core_Database_Sql_Select
{
}

View file

@ -1,30 +0,0 @@
<?php
class Wootook_Core_Database_Sql_Placeholder_Expression
extends Wootook_Core_Database_Sql_Placeholder_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(Wootook_Core_Database_Statement_Statement $statement)
{
parent::beforeExecute($statement);
foreach ($this->_params as $paramName => $value) {
$statement->bindValue($paramName, $value, $statement->getParamType($value));
}
return $this;
}
}

View file

@ -1,31 +0,0 @@
<?php
class Wootook_Core_Database_Sql_Placeholder_Param
extends Wootook_Core_Database_Sql_Placeholder_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(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;
}
}

View file

@ -1,31 +0,0 @@
<?php
abstract class Wootook_Core_Database_Sql_Placeholder_Placeholder
{
public function toString()
{
return $this->__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;
}
}

View file

@ -1,20 +0,0 @@
<?php
class Wootook_Core_Database_Sql_Placeholder_Variable
extends Wootook_Core_Database_Sql_Placeholder_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;
}
}

View file

@ -1,321 +0,0 @@
<?php
class Wootook_Core_Database_Statement_Pdo_Mysql
extends Wootook_Core_Database_Statement_Statement
{
/**
* @var PDOStatement
*/
protected $_handler = null;
protected $_query = null;
protected function _init($query)
{
$this->_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];
}
}

View file

@ -1,215 +0,0 @@
<?php
abstract class Wootook_Core_Database_Statement_Statement
implements Iterator
{
protected $_adapter = null;
protected $_currentIndex = 0;
protected $_currentRow = null;
public function __construct(Wootook_Core_Database_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 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;
}
}

View file

@ -1,51 +0,0 @@
<?php
class Wootook_Core_Email
{
/**
* @var Wootook_Core_Email_Transport_Transport
*/
protected $_transport = null;
public function __construct(Wootook_Core_Email_Transport_Transport $transport = null)
{
if ($transport === null) {
$transport = new Wootook_Core_Email_Transport_Sendmail();
}
$this->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;
}
}

View file

@ -1,16 +0,0 @@
<?php
class Wootook_Core_Email_Part_Part
{
protected $_content = null;
public function __construct($content, $mime = 'text/plain')
{
$this->_content = $content;
}
public function render()
{
return $this->_content;
}
}

View file

@ -1,22 +0,0 @@
<?php
interface Wootook_Core_Email_Transport_Transport
{
public function setFrom($from);
public function addRecipient($recipient);
public function setSubject($subject);
public function addHeader($name, $value);
public function addPart(Wootook_Core_Email_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();
}

View file

@ -1,7 +0,0 @@
<?php
class Wootook_Core_Event_Break
extends Exception
implements Wootook_Core_Exception
{
}

View file

@ -1,6 +0,0 @@
<?php
class Wootook_Core_Exception_DataAccessException
extends Wootook_Core_Exception_RuntimeException
{
}

View file

@ -1,20 +0,0 @@
<?php
class Wootook_Core_Exception_Database_AdapterError
extends Wootook_Core_Exception_RuntimeException
implements Wootook_Core_Exception_Database_Error
{
protected $_adapter = null;
public function __construct(Wootook_Core_Database_Adapter_Adapter $adapter, $message = null, $code = null, $previous = null)
{
parent::__construct($message, null, $previous);
$this->_adapter = $adapter;
}
public function getAdapter()
{
return $this->_adapter;
}
}

View file

@ -1,5 +0,0 @@
<?php
interface Wootook_Core_Exception_Database_Error
{
}

View file

@ -1,20 +0,0 @@
<?php
class Wootook_Core_Exception_Database_StatementError
extends Wootook_Core_Exception_RuntimeException
implements Wootook_Core_Exception_Database_Error
{
protected $_statement = null;
public function __construct(Wootook_Core_Database_Statement_Statement $statement, $message = null, $code = null, $previous = null)
{
parent::__construct($message, $code, $previous);
$this->_statement = $statement;
}
public function getStatement()
{
return $this->_statement;
}
}

View file

@ -1,7 +0,0 @@
<?php
class Wootook_Core_Exception_Deprecated
extends Wootook_Core_Exception_RuntimeException
{
}

View file

@ -1,25 +0,0 @@
<?php
class Wootook_Core_Exception_Exception
extends Exception
implements Wootook_Core_Exception
{
protected $_previous = null;
public function __construct($message = null, $code = null, $previous = null)
{
if (PHP_VERSION_ID >= 50300) {
parent::__construct($message, $code, $previous);
} else {
parent::__construct($message, $code);
$this->_previous = $previous;
}
}
public function __call($method, $params)
{
if (strtolower($method) == 'getprevious') {
return $this->_previous;
}
}
}

View file

@ -1,7 +0,0 @@
<?php
class Wootook_Core_Exception_GameError
extends Wootook_Core_Exception_RuntimeException
{
}

View file

@ -1,6 +0,0 @@
<?php
class Wootook_Core_Exception_LayoutException
extends Wootook_Core_Exception_RuntimeException
{
}

View file

@ -1,32 +0,0 @@
<?php
class Wootook_Core_Exception_RuntimeException
extends RuntimeException
implements Wootook_Core_Exception
{
protected $_previous = null;
public function __construct($message = null, $code = null, $previous = null)
{
if (PHP_VERSION_ID >= 50300) {
parent::__construct($message, $code, $previous);
} else {
parent::__construct($message, $code);
$this->_previous = $previous;
}
}
public function __call($method, $params)
{
if (strtolower($method) == 'getprevious') {
return $this->_previous;
}
}
public function __toString()
{
return <<<STRING_EOF
STRING_EOF;
}
}

View file

@ -1,7 +0,0 @@
<?php
class Wootook_Core_Exception_WebsiteError
extends Wootook_Core_Exception_RuntimeException
{
}

View file

@ -1,11 +0,0 @@
<?php
class Wootook_Core_Form_Element_Button
extends Wootook_Core_Form_ElementAbstract
{
public function getType()
{
return 'button';
}
}

View file

@ -1,11 +0,0 @@
<?php
class Wootook_Core_Form_Element_Text
extends Wootook_Core_Form_ElementAbstract
{
public function getType()
{
return 'text';
}
}

View file

@ -1,37 +0,0 @@
<?php
class Wootook_Core_Form_ElementLoader
extends Wootook_Core_PluginLoader_PluginLoader
{
protected $_form = null;
public function __construct(Wootook_Core_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_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;
}
}
}

View file

@ -1,21 +0,0 @@
<?php
class Wootook_Core_Form_Validator_Alnum
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#[^[:alnum:]]#');
}
public function validate(Wootook_Core_Form_ElementAbstract $element, $data)
{
if ($this->_validate($element, $data)) {
$this->_getSession($element)
->addError('Field "%s" should only contain alphanumeric characters.', $element->getName());
return false;
}
return true;
}
}

View file

@ -1,21 +0,0 @@
<?php
class Wootook_Core_Form_Validator_Alnum
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#[^[:alpha:]]#');
}
public function validate(Wootook_Core_Form_ElementAbstract $element, $data)
{
if ($this->_validate($element, $data)) {
$this->_getSession($element)
->addError('Field "%s" should only contain alphabetic characters.', $element->getName());
return false;
}
return true;
}
}

View file

@ -1,21 +0,0 @@
<?php
class Wootook_Core_Form_Validator_Email
extends Wootook_Core_Form_Validator_Regex
{
public function __construct()
{
parent::__construct('#^[[:alnum:]\._\-]@[[:alnum:]\._\-]\.[a-z]{2,}$#');
}
public function validate(Wootook_Core_Form_ElementAbstract $element, $data)
{
if (!$this->_validate($element, $data)) {
$this->_getSession($element)
->addError('Field "%s" should contain an email.', $element->getName());
return false;
}
return true;
}
}

View file

@ -1,20 +0,0 @@
<?php
class Wootook_Core_Form_Validator_FormKey
extends Wootook_Core_Form_ValidatorAbstract
{
public function validate(Wootook_Core_Form_ElementAbstract $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;
}
}

Some files were not shown because too many files have changed in this diff Show more