Subversion Repositories PHPX

Compare Revisions

Last modification

Regard whitespace Rev 51 → Rev 52

/trunk/Db/MySQLDB.php
2,8 → 2,6
 
namespace PointedEars\PHPX\Db;
 
require_once __DIR__ . '/Database.php';
 
class MySQLDB extends Database
{
/**
/trunk/Db/Database.php
3,7 → 3,6
namespace PointedEars\PHPX\Db;
 
require_once __DIR__ . '/../global.inc';
require_once __DIR__ . '/../AbstractModel.php';
 
/**
* Generic database model class using PDO (PHP Data Objects)
/trunk/Db/Mapper.php
2,9 → 2,6
 
namespace PointedEars\PHPX\Db;
 
require_once __DIR__ . '/../AbstractModel.php';
require_once __DIR__ . '/Table.php';
 
/**
* Generic abstract database mapper class
*
/trunk/Db/Table.php
2,9 → 2,6
 
namespace PointedEars\PHPX\Db;
 
require_once __DIR__ . '/../Application.php';
require_once __DIR__ . '/../AbstractModel.php';
 
use \PointedEars\PHPX\Application;
 
/**
/trunk/Model.php
1,6 → 1,6
<?php
 
require_once __DIR__ . '/AbstractModel.php';
namespace PointedEars\PHPX;
 
/**
* Abstract model class for Object-Relational Mapping
10,7 → 10,7
*
* @author Thomas Lahn
*/
abstract class Model extends AbstractModel
abstract class Model extends \PointedEars\PHPX\AbstractModel
{
/**
* The <code>Table</code> for instances of this model
69,11 → 69,11
else
{
$table = new $value();
if (!($table instanceof Table))
if (!($table instanceof Db\Table))
{
throw new \InvalidArgumentException(
'Expected Table instance or string for table name, saw '
. (\get_class($value) || \gettype($value))
'Parameter does not specify a subclass of \\PointedEars\\PHPX\\Table: '
. $value
);
}
 
125,7 → 125,7
public function find ()
{
$result = $this->persistentTable->find(
$this->{$this->__persistentId});
$this->{$this->_persistentId});
if ($result)
{
return $this->map($result);
/trunk/Application.php
2,9 → 2,21
 
namespace PointedEars\PHPX;
 
require_once __DIR__ . '/AbstractModel.php';
require_once __DIR__ . '/Registry.php';
function autoload ($class)
{
if (\strpos($class, '..'))
{
throw new \InvalidArgumentException(
'Refusing to load unsafe class ' . $class);
}
 
require_once \preg_replace('#\\\#', '/',
\preg_replace('#^' . \preg_quote(__NAMESPACE__) .'#', __DIR__, $class)
) . '.php';
}
 
\spl_autoload_register(__NAMESPACE__ . '\\autoload');
 
/**
* Basic application class
*
77,20 → 89,20
public function __get($name)
{
/* Support for Object-Relational Mappers */
if (strpos($name, 'persistent') === 0)
if (\strpos($name, 'persistent') === 0)
{
$class = get_class($this);
$class = \get_class($this);
return $class::${$name};
}
 
$method = 'get' . ucfirst($name);
$method = 'get' . \ucfirst($name);
 
if (method_exists($this, $method))
if (\method_exists($this, $method))
{
return $this->$method();
}
 
if (property_exists($this, "_$name"))
if (\property_exists($this, "_$name"))
{
return $this->{"_$name"};
}
107,14 → 119,14
*/
public function __set($name, $value)
{
$method = 'set' . ucfirst($name);
$method = 'set' . \ucfirst($name);
 
if (method_exists($this, $method))
if (\method_exists($this, $method))
{
return $this->$method($value);
}
 
if (property_exists($this, "_$name"))
if (\property_exists($this, "_$name"))
{
$this->{"_$name"} = $value;
return $this->{"_$name"};
137,7 → 149,7
$controller = $this->_defaultController;
}
 
$controller = ucfirst($controller);
$controller = \ucfirst($controller);
 
$controller = $controller . 'Controller';
require_once "{$this->_controllerPath}/{$controller}.php";
148,7 → 160,7
 
protected function startSession()
{
session_start();
\session_start();
}
 
/**
248,7 → 260,7
{
/* Server/PHP too old, compute URI */
$url = self::getParam('REQUEST_URI', $_SERVER);
if (preg_match('/^[^?]+/', $url, $matches) > 0)
if (\preg_match('/^[^?]+/', $url, $matches) > 0)
{
$url = $matches[0];
}
258,7 → 270,7
$url = self::getParam('SCRIPT_NAME', $_SERVER);
if ($url === null)
{
throw new Exception(
throw new \Exception(
'None of $_SERVER["SCRIPT_URL"], $_SERVER["URL"],'
. ' $_SERVER["REQUEST_URI"], or $_SERVER["SCRIPT_NAME"]'
. ' is available, cannot continue.');
283,7 → 295,7
if ($script_uri === null)
{
/* Server/PHP too old, compute URI */
if (preg_match('/^[^?]+/',
if (\preg_match('/^[^?]+/',
self::getParam('REQUEST_URI', $_SERVER), $matches) > 0)
{
$query_prefix = $matches[0];
302,7 → 314,7
. $query_prefix;
}
 
header('Location: ' . $script_uri
\header('Location: ' . $script_uri
. ($query ? (substr($query, 0, 1) === '?' ? '' : '?') . $query : ''));
}
}
}
/trunk/View.php
2,9 → 2,6
 
namespace PointedEars\PHPX;
 
require_once __DIR__ . '/Application.php';
require_once __DIR__ . '/AbstractModel.php';
 
/**
* A general view handled by a controller according to the MVC pattern
*
/trunk/Controller.php
2,9 → 2,6
 
namespace PointedEars\PHPX;
 
require_once __DIR__ . '/Application.php';
require_once __DIR__ . '/View.php';
 
/**
* A general controller that can handle views according to
* the MVC pattern
/trunk/AbstractModel.php
8,8 → 8,8
interface ILocalizable
{
/**
* Localizes this model. The actual implementation is left to the model class
* implementing this interface.
* Localizes this model. The actual implementation is left to
* the model class implementing this interface.
*/
function localize();
}
48,11 → 48,11
public function __get($name)
{
/* Support for Object-Relational Mappers */
if (strpos($name, 'persistent') === 0)
{
$class = get_class($this);
return $class::${$name};
}
// if (strpos($name, 'persistent') === 0)
// {
// $class = get_class($this);
// return $class::${$name};
// }
 
$method = 'get' . ucfirst($name);