Переделка для composer autoload
This commit is contained in:
parent
ad69746347
commit
b5641db607
100 changed files with 14 additions and 325 deletions
|
|
@ -7,5 +7,9 @@
|
|||
"email": "phedor@edu.yar.ru"
|
||||
}
|
||||
],
|
||||
"require": {}
|
||||
"require": {
|
||||
"psr-0": {
|
||||
"": "src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
<?php
|
||||
foreach (glob(dirname(__FILE__) . "/*.php") as $file)
|
||||
require_once $file;
|
||||
?>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Простой класс(Factory) для работы с базами данных
|
||||
*/
|
||||
class Database
|
||||
{
|
||||
static function getConnection (array $dsn)
|
||||
{
|
||||
require_once "core/drivers/database." . strtolower($dsn['phptype']) . ".php";
|
||||
$name = "Database_" . strtoupper($dsn['phptype']);
|
||||
$database = new $name();
|
||||
$database->connect($dsn);
|
||||
return $database;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/drivers/db.php';
|
||||
|
||||
/**
|
||||
* Простой класс для работы с базами данных
|
||||
*/
|
||||
class Database_MYSQL extends DB implements IDatabase
|
||||
{
|
||||
public function connect(array $dsn)
|
||||
{
|
||||
$db = @mysql_pconnect($dsn['hostspec'], $dsn['username'], $dsn['password'])
|
||||
or die("Unable connect to database!");
|
||||
|
||||
mysql_select_db($dsn['database']);
|
||||
return ($this->db = $db);
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
return mysql_close($this->db);
|
||||
}
|
||||
|
||||
public function query($query)
|
||||
{
|
||||
$res = mysql_query($this->db, $query)
|
||||
or die("Error: wrong SQL query #$query#");
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function fetchAllArray($query)
|
||||
{
|
||||
$res = $this->query($query);
|
||||
|
||||
while ($row = mysql_fetch_array ($res))
|
||||
$rows[] = $row;
|
||||
mysql_free_result($res);
|
||||
return ($rows) ? $rows : array();
|
||||
}
|
||||
|
||||
public function fetchOneArray($query)
|
||||
{
|
||||
$res = $this->query($query);
|
||||
$row = mysql_fetch_array($res);
|
||||
mysql_free_result($res);
|
||||
return ($row) ? $row : array();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/drivers/db.php';
|
||||
|
||||
/**
|
||||
* Простой класс для работы с базами данных
|
||||
*/
|
||||
class Database_ODBC extends DB implements IDatabase
|
||||
{
|
||||
public function connect(array $dsn)
|
||||
{
|
||||
$db = @odbc_connect($dsn['database'], $dsn['username'], $dsn['password'])
|
||||
or die("Unable connect to database!");
|
||||
return ($this->db = $db);
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
return odbc_close($this->db);
|
||||
}
|
||||
|
||||
public function query($query)
|
||||
{
|
||||
$res = odbc_exec($this->db, $query)
|
||||
or die("Error: wrong SQL query #$query#");
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function fetchAllArray($query)
|
||||
{
|
||||
$res = $this->query($query);
|
||||
$to = odbc_num_fields($res);
|
||||
while (odbc_fetch_row($res)) {
|
||||
for ($i = 1; $i <= $to; $i++) {
|
||||
$row [odbc_field_name($res, $i)] = trim(odbc_result($res, $i));
|
||||
}
|
||||
$rows[] = $row;
|
||||
}
|
||||
return ($rows)? $rows : array();
|
||||
}
|
||||
|
||||
public function fetchOneArray($query)
|
||||
{
|
||||
$res = $this->query($query);
|
||||
if (!odbc_fetch_row($res)) return array ();
|
||||
$to = odbc_num_fields($res);
|
||||
for ($i = 1; $i <= $to; $i++) {
|
||||
$row [odbc_field_name($res, $i)] = trim(odbc_result($res, $i));
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/drivers/db.php';
|
||||
|
||||
/**
|
||||
* Простой класс для работы с базами данных
|
||||
*/
|
||||
class Database_PGSQL extends DB implements IDatabase
|
||||
{
|
||||
public function connect(array $dsn)
|
||||
{
|
||||
if (isset($dsn['port'])) {
|
||||
$port = "port={$dsn['port']}";
|
||||
} else {
|
||||
$port = "port=5432";
|
||||
}
|
||||
$str = "host={$dsn['hostspec']} $port dbname={$dsn['database']} user={$dsn['username']} password={$dsn['password']}";
|
||||
$db = @pg_connect($str)
|
||||
or die("Unable connect to database!");
|
||||
|
||||
return ($this->db = $db);
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
return pg_close($this->db);
|
||||
}
|
||||
|
||||
public function query($query)
|
||||
{
|
||||
$res = pg_query($this->db, $query)
|
||||
or die("Error: wrong SQL query #$query#");
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function fetchAllArray($query, $type = PGSQL_ASSOC)
|
||||
{
|
||||
$res = $this->query($query);
|
||||
|
||||
$rows = array();
|
||||
while ($row = pg_fetch_array($res, NULL, $type)) {
|
||||
$rows[] = $this->clean($row);
|
||||
}
|
||||
pg_free_result($res);
|
||||
return ($rows) ? $rows : array();
|
||||
}
|
||||
|
||||
public function affectedRows()
|
||||
{
|
||||
return pg_affected_rows($this->db);
|
||||
}
|
||||
|
||||
private function clean($row)
|
||||
{
|
||||
foreach ($row as $key => $value) {
|
||||
$row[$key] = trim($value);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function fetchOneArray($query, $type = PGSQL_ASSOC)
|
||||
{
|
||||
$res = $this->query($query);
|
||||
$row = pg_fetch_array($res, NULL, $type);
|
||||
pg_free_result($res);
|
||||
return ($row) ? $this->clean($row) : array();
|
||||
}
|
||||
|
||||
function getNextId($seq)
|
||||
{
|
||||
$result = $this->fetchOneArray("SELECT nextval('$seq')");
|
||||
return $result['nextval'];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Интерфейс драйвера класса баз данных
|
||||
*/
|
||||
interface IDatabase
|
||||
{
|
||||
public function connect(array $dsn);
|
||||
public function close();
|
||||
public function query($query);
|
||||
public function fetchAllArray($query);
|
||||
public function fetchOneArray($query);
|
||||
}
|
||||
|
||||
abstract class DB implements IDatabase
|
||||
{
|
||||
const limit = 1024;
|
||||
protected $db;
|
||||
|
||||
public static function quote($x)
|
||||
{
|
||||
return "'" . $x . "'";
|
||||
}
|
||||
|
||||
private static function assign_quote($x, $y)
|
||||
{
|
||||
return $x . "='" . $y . "'";
|
||||
}
|
||||
|
||||
function insert($table, array $values)
|
||||
{
|
||||
return $this->query("INSERT INTO $table (" . implode(",", array_keys($values))
|
||||
. ") VALUES (" . implode(",", array_map(array('self', 'quote'), array_values($values))) . ")");
|
||||
}
|
||||
|
||||
function update($table, array $values, $cond)
|
||||
{
|
||||
return $this->query("UPDATE $table SET " . implode(",",
|
||||
array_map(array('self', 'assign_quote'), array_keys($values), array_values($values))) . " WHERE $cond");
|
||||
}
|
||||
|
||||
function check_text($text)
|
||||
{
|
||||
if(strlen($text) > self::limit) $text = substr($text, 0, self::limit);
|
||||
$text = htmlspecialchars(trim($text));
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/collection.php';
|
||||
|
||||
class SafeCollection extends Collection
|
||||
{
|
||||
protected function _clean()
|
||||
{
|
||||
if(get_magic_quotes_gpc()) {
|
||||
$this->data = $this->_stripSlashes($this->data);
|
||||
}
|
||||
$this->data = $this->data;
|
||||
}
|
||||
|
||||
function import(array $data)
|
||||
{
|
||||
parent::import($data);
|
||||
$this->_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip slashes code from php.net website.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return array
|
||||
*/
|
||||
protected function _stripSlashes($value)
|
||||
{
|
||||
if(is_array($value)) {
|
||||
return array_map(array($this,'_stripSlashes'), $value);
|
||||
} else {
|
||||
return stripslashes($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ class Adapter
|
|||
public function get($name)
|
||||
{
|
||||
if (is_array ($this->adaptee)) {
|
||||
return $this->adaptee [$name];
|
||||
return $this->adaptee[$name];
|
||||
} else {
|
||||
return $this->adaptee->$name;
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
// HttpConncectionRequest
|
||||
class HttpConnection
|
||||
class Connection_HttpConnection
|
||||
{
|
||||
const POST = "POST";
|
||||
const GET = "GET";
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* Обрабатывает HTTP ответ
|
||||
*/
|
||||
class HttpConnectionResponse
|
||||
class Connection_HttpConnectionResponse
|
||||
{
|
||||
private $offset;
|
||||
private $param = array ();
|
||||
|
|
@ -3,16 +3,6 @@
|
|||
*
|
||||
* @package Core
|
||||
*/
|
||||
require_once 'core/json.php';
|
||||
require_once 'core/form/form.php';
|
||||
require_once 'core/controller/controller.php';
|
||||
|
||||
require_once 'core/widgets/pagemenu.php';
|
||||
require_once 'core/widgets/menu.php';
|
||||
require_once 'core/widgets/search.php';
|
||||
require_once 'core/widgets/setup.php';
|
||||
require_once 'core/widgets/listtable.php';
|
||||
|
||||
/**
|
||||
* Переименовать контроллер !! (StubController, CrudController, PageController, BaseController) ModelController
|
||||
* Возможно нужен еще класс с мета действиями как для actionIndex <= metaActionIndex либо с классам для этих действий
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/path.php';
|
||||
|
||||
class FileNotFountException extends Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -9,7 +7,7 @@ class FileNotFountException extends Exception
|
|||
/**
|
||||
* Класс компонента
|
||||
*/
|
||||
class Component
|
||||
class Controller_Component
|
||||
{
|
||||
static $_uid = 1;
|
||||
public $uid; // UID компонента создается при создании страницы, вставки компонента, или это статическое свойство
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/path.php';
|
||||
require_once 'core/mapper/factory.php';
|
||||
require_once 'core/functions.php';
|
||||
|
||||
|
||||
|
|
@ -17,7 +15,7 @@ function forceUrl($name)
|
|||
* Контроллер страниц
|
||||
* @package core
|
||||
*/
|
||||
class Controller
|
||||
class Controller_Controller
|
||||
{
|
||||
|
||||
const TEMPLATE_EXTENSION = ".html"; // Расширение для шаблонов
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/settings.php';
|
||||
|
||||
class Installer
|
||||
class Controller_Installer
|
||||
{
|
||||
protected $db;
|
||||
protected $installPath;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class State
|
||||
class Controller_State
|
||||
{
|
||||
public $action = '';
|
||||
public $states = array();
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* Попытка реализовать фильтр для запросов
|
||||
*/
|
||||
class Filter
|
||||
class Filter_Filter
|
||||
{
|
||||
public $processor;
|
||||
public function __construct($processor)
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
// В класс авторизации передавать обьект для управления пользователем
|
||||
// Вынести в отдельный файл
|
||||
class LoginFilter extends Filter
|
||||
class Filter_LoginFilter extends Filter_Filter
|
||||
{
|
||||
const SESSION_BROWSER_SIGN_SECRET = '@w3dsju45Msk#';
|
||||
const SESSION_BROWSER_SIGN_KEYNAME = 'session.app.browser.sign';
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/safecollection.php';
|
||||
require_once 'core/session.php';
|
||||
|
||||
/**
|
||||
* Неверный запрос
|
||||
*/
|
||||
|
|
@ -101,5 +101,3 @@ class Password extends Primitive
|
|||
return $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
* http://www.patternsforphp.com/wiki/Singleton
|
||||
* http://www.phppatterns.com/docs/design/the_registry?s=registry
|
||||
*/
|
||||
require_once 'core/settings.php';
|
||||
|
||||
class Registry extends Settings
|
||||
{
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/collection.php';
|
||||
|
||||
/**
|
||||
* Класс реестра
|
||||
* Реестр организован как ассоциативный многомерный массив
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/path.php';
|
||||
require_once 'creole/util/sql/SQLStatementExtractor.php';
|
||||
|
||||
/**
|
||||
* Обработка файлов для установки
|
||||
*/
|
||||
|
|
@ -55,5 +52,3 @@ class Setup
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -96,5 +96,3 @@ class Spell
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue