This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "quickfw".
The branch, master has been updated
via 3ae7582099befdcbdedc899114b5118d2f75152c (commit)
via b9af15c502a2c25823279e44a6985d3bb975ae3d (commit)
via fb11dca4dd186f1d866454197cb6f2292b5e7ad9 (commit)
via a0b0a5d092c70e2a1b40b3cb144748798bba8eea (commit)
via ec7604792b02897382fda8c1857f279a4a62bd5e (commit)
from 35cb8d420b9cdea86df7d2df3ac955fb77434847 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3ae7582099befdcbdedc899114b5118d2f75152c
Author: Ivan Borzenkov <iva...@li...>
Date: Sun May 23 19:48:05 2010 +0400
Функция order для установки порядка полей
diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php
index 8cf29d8..3d84e3e 100644
--- a/lib/Modules/Scafold/ScafoldController.php
+++ b/lib/Modules/Scafold/ScafoldController.php
@@ -42,6 +42,8 @@ abstract class ScafoldController extends Controller
private $methods;
/** @var boolean Флаг окончания настройки */
private $setup = false;
+ /** @var array Порядок сортировки */
+ private $order = array();
/**
* Получает данные о полях
@@ -105,6 +107,11 @@ abstract class ScafoldController extends Controller
if (get_class($field) == 'Scafold_Field_Info')
unset($this->fields[$k]);
+ //порядок сортировки полей
+ foreach($this->order as $k=>$v)
+ if (!isset($this->fields[$v]))
+ unset($this->order[$k]);
+
//Общая информация о таблице
QFW::$view->assign(array(
'methods' => $this->methods,
@@ -163,7 +170,7 @@ abstract class ScafoldController extends Controller
$foreign = $this->getForeign();
$data = QFW::$db->select('SELECT ?# ?s FROM ?# ?s
WHERE ?s ?s '.$this->where.' LIMIT ?d, ?d',
- array($this->table=>'*'),
+ array($this->table=>array_merge($this->order, array('*'))),
$foreign['field'], $this->table, $foreign['join'],
$filter['where'], $parentWhere,
$page*$this->pageSize, $this->pageSize);
@@ -251,11 +258,15 @@ abstract class ScafoldController extends Controller
{
//получение дефолтовых значений для новой записи
$data = array();
+ foreach($this->order as $f)
+ $data[$f] = $this->fields[$f]->def();
foreach ($this->fields as $f=>$info)
- $data[$f] = $info->def();
+ if (!isset($data[$f]))
+ $data[$f] = $info->def();
}
else
- $data = QFW::$db->selectRow('SELECT * FROM ?# WHERE ?#=?',
+ $data = QFW::$db->selectRow('SELECT ?# FROM ?# WHERE ?#=?',
+ array($this->table=>array_merge($this->order, array('*'))),
$this->table, $this->primaryKey, $id);
$state = new TemplaterState(QFW::$view);
@@ -323,6 +334,21 @@ abstract class ScafoldController extends Controller
////////////////////////////////////////////////////////////
/**
+ * Скрывает при выводе и редактировании указанные колонки
+ *
+ * <br><br> Вызывается только в конструкторе
+ *
+ * @param array $fieldList массив с именами полей
+ * @return ScafoldController
+ */
+ protected function order($fieldList)
+ {
+ $this->endTest();
+ $this->order = $fieldList;
+ return $this;
+ }
+
+ /**
* Устанавливает таблицу как подчиненную
*
* <br><br> Вызывается только в конструкторе
commit b9af15c502a2c25823279e44a6985d3bb975ae3d
Author: Ivan Borzenkov <iva...@li...>
Date: Sun May 23 19:10:53 2010 +0400
Исправлена ошибка с фильтром - не работал
diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php
index e85747c..8cf29d8 100644
--- a/lib/Modules/Scafold/ScafoldController.php
+++ b/lib/Modules/Scafold/ScafoldController.php
@@ -308,12 +308,12 @@ abstract class ScafoldController extends Controller
$this->session();
if (!empty($_POST['clear']))
{
- $_SESSION['scafold']['filter'] = array();
+ $_SESSION['scafold'][$this->table]['filter'] = array();
QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true);
}
if (empty($_POST['filter']) || empty($_POST['apply']))
QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true);
- $_SESSION['scafold']['filter'] = $_POST['filter'];
+ $_SESSION['scafold'][$this->table]['filter'] = $_POST['filter'];
QFW::$router->redirect('/'.$this->ControllerUrl.'/index', true);
}
commit fb11dca4dd186f1d866454197cb6f2292b5e7ad9
Author: Ivan Borzenkov <iva...@li...>
Date: Sun May 23 18:56:53 2010 +0400
В varchar можно передавать размер
diff --git a/lib/Modules/Scafold/Fields.php b/lib/Modules/Scafold/Fields.php
index 533c810..4bb373e 100644
--- a/lib/Modules/Scafold/Fields.php
+++ b/lib/Modules/Scafold/Fields.php
@@ -296,8 +296,10 @@ class Scafold_Varchar extends Scafold_Field
/** @var integer размер поля в базе */
private $size;
- public function __construct($info, $size)
+ public function __construct($info, $size = 100)
{
+ if (!empty($info->typeParams) && is_numeric($info->typeParams))
+ $size = $info->typeParams;
parent::__construct($info);
$this->size = $size;
}
diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php
index e6402cd..e85747c 100644
--- a/lib/Modules/Scafold/ScafoldController.php
+++ b/lib/Modules/Scafold/ScafoldController.php
@@ -81,7 +81,6 @@ abstract class ScafoldController extends Controller
'Null' => 'NO',
'Default' => null,
'Extra' => '',
-
);
$f[$field[0]] = $this->getFieldClass($c, $info);
}
commit a0b0a5d092c70e2a1b40b3cb144748798bba8eea
Author: Ivan Borzenkov <iva...@li...>
Date: Sun May 23 16:45:43 2010 +0400
Скафолдинг - работа с sqlite
diff --git a/lib/Modules/Scafold/ScafoldController.php b/lib/Modules/Scafold/ScafoldController.php
index 703174b..e6402cd 100644
--- a/lib/Modules/Scafold/ScafoldController.php
+++ b/lib/Modules/Scafold/ScafoldController.php
@@ -44,6 +44,52 @@ abstract class ScafoldController extends Controller
private $setup = false;
/**
+ * Получает данные о полях
+ *
+ * @return array Данные
+ */
+ private function fields()
+ {
+ $f = array();
+ $shema = QFW::$db->getShema();
+ if ($shema == 'Mypdo' || $shema == 'Mysql')
+ { //Mysql
+ $fields = QFW::$db->select('SHOW FIELDS IN ?#', $this->table);
+ foreach($fields as $field)
+ {
+ $c = $this->getInfoClass($field['Field']);
+ $c->primaryKey = $field['Key'] == 'PRI';
+ $f[$field['Field']] = $this->getFieldClass($c, $field);
+ }
+ }
+ else if ($shema == 'Litepdo' || $shema == 'Sqlite')
+ { //Sqlite
+ $sql = QFW::$db->selectCell('SELECT sql FROM sqlite_master
+ WHERE type=? AND name=?', 'table', str_replace('?_',
+ QFW::$db->setIdentPrefix(null), $this->table));
+ //выделяем то что в скобках
+ $sql = substr($sql, strpos($sql, '(')+1, -1);
+ $fields = explode(',', $sql);
+ foreach($fields as $field)
+ {
+ $field = explode(' ', trim($field), 2);
+ $c = $this->getInfoClass($field[0]);
+ $c->primaryKey = strpos($field[1], 'PRIMARY KEY') !== false;
+ $info = array(
+ 'Field' => $field[0],
+ 'Type' => $field[1],
+ 'Null' => 'NO',
+ 'Default' => null,
+ 'Extra' => '',
+
+ );
+ $f[$field[0]] = $this->getFieldClass($c, $info);
+ }
+ }
+ return $f;
+ }
+
+ /**
* Конструктор вызывать только после настройки таблицы
*/
public function __construct()
@@ -55,14 +101,7 @@ abstract class ScafoldController extends Controller
$this->methods = array_flip(get_class_methods($this));
//Получаем данные о полях
- $fields = QFW::$db->select('SHOW FIELDS IN ?#', $this->table);
- foreach($fields as $field)
- {
- $c = $this->getInfoClass($field['Field']);
- $c->primaryKey = $field['Key'] == 'PRI';
- $this->fields[$field['Field']] =
- $this->getFieldClass($c, $field);
- }
+ $this->fields = $this->fields();
foreach($this->fields as $k=>$field)
if (get_class($field) == 'Scafold_Field_Info')
unset($this->fields[$k]);
commit ec7604792b02897382fda8c1857f279a4a62bd5e
Author: Ivan Borzenkov <iva...@li...>
Date: Sun May 23 16:45:13 2010 +0400
Dbsimple - получение информации о типе базы
diff --git a/lib/DbSimple/Connect.php b/lib/DbSimple/Connect.php
index e474467..f74bee8 100644
--- a/lib/DbSimple/Connect.php
+++ b/lib/DbSimple/Connect.php
@@ -34,7 +34,12 @@ define('DBSIMPLE_PARENT_KEY', 'PARENT_KEY'); // forrest-based resultset support
*/
class DbSimple_Connect
{
- protected $DbSimple, $DSN;
+ /** @var DbSimple_Generic_Database База данных */
+ protected $DbSimple;
+ /** @var string DSN подключения */
+ protected $DSN;
+ /** @var string Тип базы данных */
+ protected $shema;
/**
* Конструктор только запоминает переданный DSN
@@ -44,8 +49,9 @@ class DbSimple_Connect
*/
public function __construct($dsn)
{
- $this->DbSimple = null;
- $this->DSN = $dsn;
+ $this->DbSimple = null;
+ $this->DSN = $dsn;
+ $this->shema = ucfirst(substr($dsn, 0, strpos($dsn, ':')));
}
/**
@@ -61,6 +67,16 @@ class DbSimple_Connect
}
/**
+ * Возвращает тип базы данных
+ *
+ * @return string имя типа БД
+ */
+ public function getShema()
+ {
+ return $this->shema;
+ }
+
+ /**
* Коннект при первом запросе к базе данных
*/
public function __call($method, $params)
@@ -91,10 +107,11 @@ class DbSimple_Connect
$parsed = $this->parseDSN($dsn);
if (!$parsed)
$this->errorHandler('Ошибка разбора строки DSN',$dsn);
- if (!isset($parsed['scheme']) || !is_file(dirname(__FILE__).'/'.ucfirst($parsed['scheme']).'.php'))
+ $this->shema = ucfirst($parsed['scheme']);
+ if (!isset($parsed['scheme']) || !is_file(dirname(__FILE__).'/'.$this->shema.'.php'))
$this->errorHandler('Невозможно загрузить драйвер базы данных',$parsed);
- require_once dirname(__FILE__).'/'.ucfirst($parsed['scheme']).'.php';
- $class = 'DbSimple_'.ucfirst($parsed['scheme']);
+ require_once dirname(__FILE__).'/'.$this->shema.'.php';
+ $class = 'DbSimple_'.$this->shema;
$this->DbSimple = new $class($parsed);
if (isset($parsed['prefix']))
$this->DbSimple->setIdentPrefix($parsed['prefix']);
-----------------------------------------------------------------------
Summary of changes:
lib/DbSimple/Connect.php | 29 +++++++--
lib/Modules/Scafold/Fields.php | 4 +-
lib/Modules/Scafold/ScafoldController.php | 90 ++++++++++++++++++++++++----
3 files changed, 103 insertions(+), 20 deletions(-)
hooks/post-receive
--
quickfw
|