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, scaffold has been created
at fd5fdcb2c6b50a75b6df227436a06df228305331 (commit)
- Log -----------------------------------------------------------------
commit fd5fdcb2c6b50a75b6df227436a06df228305331
Author: Ivan Borzenkov <iva...@li...>
Date: Tue Mar 1 15:39:35 2011 +0300
Правка phpdoc
diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/lib/Modules/Scaffold/ScaffoldController.php
index 5385bf4..3f29b5f 100644
--- a/lib/Modules/Scaffold/ScaffoldController.php
+++ b/lib/Modules/Scaffold/ScaffoldController.php
@@ -1031,8 +1031,8 @@ abstract class ScaffoldController extends Controller
$infoClass->typeParams = $match[2];
}
+ /** @var Scaffold_Field $C */
$C = new $class();
- /** @var $C Scaffold_Field */
$C->init($infoClass);
return $C;
}
commit cb736b71f6fba1eb5a3f4a7eee27143c106a14f6
Author: Ivan Borzenkov <iva...@li...>
Date: Mon Feb 28 14:48:02 2011 +0300
Отделил инициализацию от конструктора
diff --git a/lib/Modules/Scaffold/Fields.php b/lib/Modules/Scaffold/Fields.php
index b58ed6f..8fca13f 100644
--- a/lib/Modules/Scaffold/Fields.php
+++ b/lib/Modules/Scaffold/Fields.php
@@ -59,12 +59,16 @@ class Scaffold_Field_Info
class Scaffold_Field extends Scaffold_Field_Info
{
+ public function __construct()
+ {
+ }
+
/**
- * Создает полноценное поле из данных о пользователе
+ * Инициализирует данные из таблицы
*
* @param Scaffold_Field_Info $info Информация о поле
*/
- public function __construct($info)
+ public function init($info)
{
$vars = get_class_vars('Scaffold_Field_Info');
foreach ($vars as $k=>$v)
@@ -266,12 +270,10 @@ class Scaffold_Foreign extends Scaffold_Field
/** @var bool Может ли быть нулевое значение */
protected $isnull;
- public function __construct($info, $where = DBSIMPLE_SKIP)
+ public function init($info)
{
- if (!empty($info->typeParams))
- $where = $info->typeParams;
$this->isnull = $info->foreign['null'];
- parent::__construct($info);
+ parent::init($info);
$this->lookup = QFW::$db->selectCol('SELECT ?# AS ARRAY_KEY_1, ?# FROM ?# {WHERE ?s}',
$info->foreign['key'], $info->foreign['field'], $info->foreign['table'], $where);
}
@@ -302,9 +304,9 @@ abstract class Scaffold_UserInput extends Scaffold_Field
/** @var integer До скольки обрезать */
private $trim;
- public function __construct($info)
+ public function init($info)
{
- parent::__construct($info);
+ parent::init($info);
$this->trim = isset($info->typeParams['trim']) ? $info->typeParams['trim'] : 80;
}
@@ -328,9 +330,9 @@ class Scaffold_Text extends Scaffold_UserInput
/** @var integer Сколько колонок */
private $cols;
- public function __construct($info)
+ public function init($info)
{
- parent::__construct($info);
+ parent::init($info);
$this->rows = isset($info->typeParams['rows']) ? $info->typeParams['rows'] : 10;
$this->cols = isset($info->typeParams['cols']) ? $info->typeParams['cols'] : 80;
}
@@ -367,13 +369,18 @@ class Scaffold_Varchar extends Scaffold_Field
/** @var integer размер поля в базе */
private $size;
- public function __construct($info, $size = 100)
+ public function __construct($size = false)
{
- if (!empty($info->typeParams) && is_numeric($info->typeParams))
- $size = $info->typeParams;
- parent::__construct($info);
$this->size = $size;
}
+
+ public function init($info)
+ {
+ parent::init($info);
+ if (!$this->size)
+ if (!empty($info->typeParams) && is_numeric($info->typeParams))
+ $this->size = $info->typeParams;
+ }
public function validator($id, $value)
{
@@ -397,11 +404,15 @@ class Scaffold_Enum extends Scaffold_Field
/** @var array что в перечислении */
private $items;
- public function __construct($info, $items)
+ public function __construct($items = '')
{
- parent::__construct($info);
- $items = str_getcsv($items, ',', "'");
- $this->items = array_combine($items, $items);
+ $this->items = str_getcsv($items, ',', "'");
+ }
+
+ public function init($info)
+ {
+ parent::init($info);
+ $this->items = array_combine($info->typeParams, $this->items);
}
public function editor($id, $value)
@@ -421,9 +432,13 @@ class Scaffold_Enum extends Scaffold_Field
class Scaffold_Datetime extends Scaffold_Field
{
- public function __construct($info)
+ public function __construct()
+ {
+ }
+
+ public function init($info)
{
- parent::__construct($info);
+ parent::init($info);
if ($this->default == 'CURRENT_TIMESTAMP')
$this->default = date('Y-m-d H:i:s');
}
@@ -465,9 +480,9 @@ class Scaffold_File extends Scaffold_Field
*
* @param Scaffold_Field_Info $info Информация о поле
*/
- public function __construct($info)
+ public function init($info)
{
- parent::__construct($info);
+ parent::init($info);
$this->label = false;
if (empty ($info->typeParams['path']))
throw new Exception('Не указана директория для фалов', 1);
@@ -556,11 +571,11 @@ class Scaffold_File extends Scaffold_Field
class Scaffold_Image extends Scaffold_File
{
- public function __construct($info)
+ public function init($info)
{
if (empty($info->typeParams['accept']))
$info->typeParams['accept'] = 'image/*';
- parent::__construct($info);
+ parent::init($info);
}
public function display($id, $value)
diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/lib/Modules/Scaffold/ScaffoldController.php
index 02c633a..5385bf4 100644
--- a/lib/Modules/Scaffold/ScaffoldController.php
+++ b/lib/Modules/Scaffold/ScaffoldController.php
@@ -1013,22 +1013,28 @@ abstract class ScaffoldController extends Controller
$infoClass->tableObject = &$this;
$infoClass->primaryKey = $this->primaryKey;
+ $class = 'Scaffold_Field';
+ $match = array();
if ($infoClass->type)
{
$class = 'Scaffold_'.ucfirst($infoClass->type);
- return new $class($infoClass);
}
//определяем по типам и прочей известной информации
- if ($infoClass->foreign)
- return new Scaffold_Foreign($infoClass);
+ elseif ($infoClass->foreign)
+ $class = 'Scaffold_Foreign';
- $match = array();
- if (preg_match('#(.*?)(?:\((.+?)\)|$)#', $fieldInfo['Type'], $match))
- if (class_exists($class = 'Scaffold_'.ucfirst($match[1])))
- return new $class($infoClass, isset($match[2]) ? $match[2] : false );
+ elseif (preg_match('#(.*?)(?:\((.+?)\)|$)#', $fieldInfo['Type'], $match))
+ if (class_exists($cl = 'Scaffold_'.ucfirst($match[1])))
+ {
+ $class = $cl;
+ $infoClass->typeParams = $match[2];
+ }
- return new Scaffold_Field($infoClass);
+ $C = new $class();
+ /** @var $C Scaffold_Field */
+ $C->init($infoClass);
+ return $C;
}
private function endTest()
commit e6df258035a4aa7a13094740a761e127a6398042
Author: Ivan Borzenkov <iva...@li...>
Date: Mon Feb 28 14:18:39 2011 +0300
notice old
diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/lib/Modules/Scaffold/ScaffoldController.php
index 3e0b38f..02c633a 100644
--- a/lib/Modules/Scaffold/ScaffoldController.php
+++ b/lib/Modules/Scaffold/ScaffoldController.php
@@ -488,6 +488,7 @@ abstract class ScaffoldController extends Controller
//Обработка результата редактирования
foreach($alldata as $id => $data)
{
+ $old = $this->getOldVars($id);
self::setCurRow($old);
foreach ($data as $k=>$v)
{
commit 8cfa3b5fc77c3f0c31b952c3038b40eb63011e45
Author: Ivan Borzenkov <iva...@li...>
Date: Mon Feb 28 13:45:26 2011 +0300
Автолоад для скафолдинга
diff --git a/lib/Modules/Scaffold/Fields.php b/lib/Modules/Scaffold/Fields.php
index 5d978d8..b58ed6f 100644
--- a/lib/Modules/Scaffold/Fields.php
+++ b/lib/Modules/Scaffold/Fields.php
@@ -415,52 +415,6 @@ class Scaffold_Enum extends Scaffold_Field
//Классы для других типов полей, указываемых пользователем
-class Scaffold_Checkbox extends Scaffold_Field
-{
-
- public function display($id, $value)
- {
- return $value ? 'Да' : 'Нет';
- }
-
- public function editor($id, $value)
- {
- return '<input type="hidden" name="'.$this->editName($id).'" value="0" />
- <input type="checkbox" name="'.$this->editName($id).'" value="1" label="'.$this->title.'"
- default="'.($value?'checked':'').'" />';
- }
-
- /**
- * Часть условия WHERE для данного фильтра
- *
- * @param mixed $session сохраненное в сессии значение
- * @return DbSimple_SubQuery часть запроса к базе данных
- */
- public function filterWhere($session)
- {
- if ($session == 0)
- return QFW::$db->subquery('');
- return QFW::$db->subquery('?# LIKE ?',
- array($this->table=>$this->name), $session==1 ? '1' : '0');
- }
-
- /**
- * Формирует поле ввода для фильтра
- *
- * @param mixed $session сохраненные в сесии данные
- * @return string часть формы для фильтра
- */
- public function filterForm($session)
- {
- return '<fieldset>'.$this->title.':
- <label><input type="radio" name="filter['.$this->name.']" value=""'.($session==0 ? ' checked': '').'> любой</label>
- <label><input type="radio" name="filter['.$this->name.']" value="1"'.($session==1 ? ' checked': '').'> установлен</label>
- <label><input type="radio" name="filter['.$this->name.']" value="-1"'.($session==-1 ? ' checked': '').'> сброшен</label>
- </fieldset>';
- }
-
-}
-
/**
* Дата и время
*/
diff --git a/lib/Modules/Scaffold/ScaffoldController.php b/lib/Modules/Scaffold/ScaffoldController.php
index f10a049..3e0b38f 100644
--- a/lib/Modules/Scaffold/ScaffoldController.php
+++ b/lib/Modules/Scaffold/ScaffoldController.php
@@ -1037,4 +1037,22 @@ abstract class ScaffoldController extends Controller
}
}
-?>
+
+/**
+ * Autoload для скафолда - классы полей в fields
+ *
+ * @param string $class имя класса
+ * @return bool загрузилось
+ */
+function ScaffoldAutoload($class)
+{
+ if (strpos($class, 'Scaffold_') === 0)
+ {
+ $class = str_replace('Scaffold_','fields/', $class);
+ require dirname(__FILE__).'/'.$class.'.php';
+ return true;
+ }
+ return false;
+}
+
+spl_autoload_register('ScaffoldAutoload');
diff --git a/lib/Modules/Scaffold/fields/Checkbox.php b/lib/Modules/Scaffold/fields/Checkbox.php
new file mode 100644
index 0000000..f0fcb2f
--- /dev/null
+++ b/lib/Modules/Scaffold/fields/Checkbox.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Поле с типом checkbox
+ */
+class Scaffold_Checkbox extends Scaffold_Field
+{
+
+ public function display($id, $value)
+ {
+ return $value ? 'Да' : 'Нет';
+ }
+
+ public function editor($id, $value)
+ {
+ return '<input type="hidden" name="'.$this->editName($id).'" value="0" />
+ <input type="checkbox" name="'.$this->editName($id).'" value="1" label="'.$this->title.'"
+ default="'.($value?'checked':'').'" />';
+ }
+
+ /**
+ * Часть условия WHERE для данного фильтра
+ *
+ * @param mixed $session сохраненное в сессии значение
+ * @return DbSimple_SubQuery часть запроса к базе данных
+ */
+ public function filterWhere($session)
+ {
+ if ($session == 0)
+ return QFW::$db->subquery('');
+ return QFW::$db->subquery('?# LIKE ?',
+ array($this->table=>$this->name), $session==1 ? '1' : '0');
+ }
+
+ /**
+ * Формирует поле ввода для фильтра
+ *
+ * @param mixed $session сохраненные в сесии данные
+ * @return string часть формы для фильтра
+ */
+ public function filterForm($session)
+ {
+ return '<fieldset>'.$this->title.':
+ <label><input type="radio" name="filter['.$this->name.']" value=""'.($session==0 ? ' checked': '').'> любой</label>
+ <label><input type="radio" name="filter['.$this->name.']" value="1"'.($session==1 ? ' checked': '').'> установлен</label>
+ <label><input type="radio" name="filter['.$this->name.']" value="-1"'.($session==-1 ? ' checked': '').'> сброшен</label>
+ </fieldset>';
+ }
+
+}
-----------------------------------------------------------------------
hooks/post-receive
--
quickfw
|