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 54cfd404f5688c34973cf724da716560d570418b (commit)
via 5c14ee23e5ff2e25431c54de7d5240e38a5fd13b (commit)
via 8c2b2d6a033b9b3d5ea7fce1c11eddbe2245d587 (commit)
via a2ed372be6d8f94c0c601184ee672d49424ce944 (commit)
via 7d29d2e026a07adb3c078ae20b3e89d107ba1f83 (commit)
via 8e06a19ef7ba963ad8b01500f58f48cc0bd84791 (commit)
from f194b28a3e20242addcc86b22dec7a1b59d37cef (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 54cfd404f5688c34973cf724da716560d570418b
Author: Ivan Borzenkov <iva...@li...>
Date: Mon Dec 13 18:45:14 2010 +0300
Тесты для шаблонизаторов
diff --git a/tests/app/060_view_assigns.phpt b/tests/app/060_view_assigns.phpt
new file mode 100644
index 0000000..47f355c
--- /dev/null
+++ b/tests/app/060_view_assigns.phpt
@@ -0,0 +1,52 @@
+--TEST--
+QFW: assigns in view
+--FILE--
+<?php
+require dirname(__FILE__).'/init.php';
+
+QFW::$router->route('assigns');
+
+--EXPECT--
+1
+array1
+array2
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+------------------------------------------
+1
+array1
+array2
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+local1
+------------------------------------------
+1
+array1
+array2
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+local2
+local3
+------------------------------------------
+1
+array1
+array2
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+------------------------------------------
diff --git a/tests/testapp/default/controllers/AssignsController.php b/tests/testapp/default/controllers/AssignsController.php
new file mode 100644
index 0000000..4c197ee
--- /dev/null
+++ b/tests/testapp/default/controllers/AssignsController.php
@@ -0,0 +1,20 @@
+<?php
+
+class AssignsController
+{
+
+ public function indexAction()
+ {
+ QFW::$view->mainTemplate = '';
+ QFW::$view->assign('var', 1);
+ QFW::$view->assign(array('array1' => 'array1', 'array2' => 'array2'));
+ QFW::$view->append('append', 1);
+ QFW::$view->append('append', 2);
+ echo QFW::$view->fetch('assigns.php');
+ echo QFW::$view->fetch('assigns.php', array('local1' => 'local1'));
+ echo QFW::$view->fetch('assigns.php', array('local2' => 'local2', 'local3' => 'local3'));
+ echo QFW::$view->fetch('assigns.php');
+ }
+
+}
+
diff --git a/tests/testapp/default/templates/assigns.php b/tests/testapp/default/templates/assigns.php
new file mode 100644
index 0000000..23139ac
--- /dev/null
+++ b/tests/testapp/default/templates/assigns.php
@@ -0,0 +1,8 @@
+<?php echo $var."\n" ?>
+<?php echo $array1."\n" ?>
+<?php echo $array2."\n" ?>
+<?php var_dump($append) ?>
+<?php if (isset($local1)) echo $local1."\n" ?>
+<?php if (isset($local2)) echo $local2."\n" ?>
+<?php if (isset($local3)) echo $local3."\n" ?>
+------------------------------------------
commit 5c14ee23e5ff2e25431c54de7d5240e38a5fd13b
Author: Ivan Borzenkov <iva...@li...>
Date: Mon Dec 13 18:44:49 2010 +0300
Локальные переменные и append в шаблонизаторах
diff --git a/QFW/Templater/PlainView.php b/QFW/Templater/PlainView.php
index 7892ad4..037780d 100644
--- a/QFW/Templater/PlainView.php
+++ b/QFW/Templater/PlainView.php
@@ -69,9 +69,10 @@ class PlainView_Delegate
class Templater_PlainView extends Templater
{
- public function fetch($tmpl)
+ public function fetch($tmpl, $vars=array())
{
extract($this->_vars, EXTR_OVERWRITE);
+ extract($vars, EXTR_OVERWRITE);
$P=&$this->P;
ob_start();
include($this->_tmplPath . '/' . $tmpl);
diff --git a/QFW/Templater/Proxy.php b/QFW/Templater/Proxy.php
index d804b78..1e8a641 100644
--- a/QFW/Templater/Proxy.php
+++ b/QFW/Templater/Proxy.php
@@ -52,7 +52,7 @@ class Templater_Proxy extends Templater
parent::delete($spec);
}
- public function fetch($name)
+ public function fetch($name, $vars=array())
{
$key=substr($name,strrpos($name,'.')+1);
$T = isset(QFW::$config['templater']['exts'][$key]) ?
@@ -75,7 +75,7 @@ class Templater_Proxy extends Templater
$this->syncronize($this->templates[$T]['c']);
$this->templates[$T]['s']=true;
}
- return $this->templates[$T]['c']->fetch($name);
+ return $this->templates[$T]['c']->fetch($name, $vars);
}
/**
diff --git a/QFW/Templater/Smarty.php b/QFW/Templater/Smarty.php
index b0ae22c..7a85aad 100644
--- a/QFW/Templater/Smarty.php
+++ b/QFW/Templater/Smarty.php
@@ -111,9 +111,18 @@ class Templater_Smarty extends Templater
return $this->getEngine()->get_template_vars($var);
}
- public function fetch($name)
+ public function fetch($name, $vars=array())
{
- return $this->getEngine()->fetch($name);
+ if (!$vars)
+ return $this->getEngine()->fetch($name);
+ //если есть локальные переменные - сохраняем старые
+ //Smarty не поддерживает локальные переменные
+ $old = $this->getEngine()->get_template_vars();
+ $this->getEngine()->assign($vars);
+ $data = $this->getEngine()->fetch($name);
+ $this->getEngine()->clear_all_assign();
+ $this->getEngine()->assign($old);
+ return $data;
}
/**
diff --git a/QFW/Templater/Templater.php b/QFW/Templater/Templater.php
index a512db6..1ff31ce 100644
--- a/QFW/Templater/Templater.php
+++ b/QFW/Templater/Templater.php
@@ -46,6 +46,20 @@ abstract class Templater
}
/**
+ * Добавлеет в массив в шаблонизаторе новое значение
+ *
+ * @param string $name имя массива
+ * @param mixed $value значение
+ */
+ public function append($name, $value)
+ {
+ if (empty($this->_vars[$name]))
+ $this->_vars[$name] = array();
+ $this->_vars[$name][] = $value;
+ return $this;
+ }
+
+ /**
* Удаляет указанную переменную из шаблона
*
* @param string|array имя переменной или массив имен
@@ -124,12 +138,12 @@ abstract class Templater
/**
* Синоним fetch
*/
- public function render($tmpl)
+ public function render($tmpl, $vars=array())
{
- return $this->fetch($tmpl);
+ return $this->fetch($tmpl, $vars);
}
- abstract public function fetch($tmpl);
+ abstract public function fetch($tmpl, $vars=array());
/**
* Генерирует полный вывод, обрабатывает фильтрами
diff --git a/QFW/Templater/Twig.php b/QFW/Templater/Twig.php
index 8dad408..619e246 100644
--- a/QFW/Templater/Twig.php
+++ b/QFW/Templater/Twig.php
@@ -62,11 +62,11 @@ class Templater_Twig extends Templater
return true;
}
- public function fetch($name)
+ public function fetch($name, $vars=array())
{
$template = $this->getEngine()->loadTemplate($name);
$this->assign('P', $this->P);
- return $template->render($this->_vars);
+ return $template->render($vars + $this->_vars);
}
/**
commit 8c2b2d6a033b9b3d5ea7fce1c11eddbe2245d587
Author: Ivan Borzenkov <iva...@li...>
Date: Mon Dec 13 13:14:52 2010 +0300
Фильтр для чекбокса
diff --git a/lib/Modules/Scaffold/Fields.php b/lib/Modules/Scaffold/Fields.php
index 93d1d4a..09fb737 100644
--- a/lib/Modules/Scaffold/Fields.php
+++ b/lib/Modules/Scaffold/Fields.php
@@ -417,6 +417,35 @@ class Scaffold_Checkbox extends Scaffold_Field
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>';
+ }
+
}
/**
commit a2ed372be6d8f94c0c601184ee672d49424ce944
Author: Ivan Borzenkov <iva...@li...>
Date: Fri Dec 10 20:55:04 2010 +0300
Постим туда-же, с параметрами
diff --git a/lib/Modules/Scaffold/scaffold/edit.php b/lib/Modules/Scaffold/scaffold/edit.php
index cd4e9d4..163183f 100644
--- a/lib/Modules/Scaffold/scaffold/edit.php
+++ b/lib/Modules/Scaffold/scaffold/edit.php
@@ -1,6 +1,6 @@
<?php require dirname(__FILE__).'/info.php' ?>
<?php echo $this->block(Url::C('preForm'), $id); ?>
-<form action="<?php echo Url::C('edit/'.$id) ?>" class="scaffoldEdit"
+<form class="scaffoldEdit"
method="post" id="form_<?php echo $table ?>" enctype="multipart/form-data">
<?php echo $this->block(Url::C('preEdit'), $id); ?>
<dl>
commit 7d29d2e026a07adb3c078ae20b3e89d107ba1f83
Author: Ivan Borzenkov <iva...@li...>
Date: Fri Dec 10 20:38:57 2010 +0300
Загрузка файлов - фикс
diff --git a/lib/Modules/Scaffold/Fields.php b/lib/Modules/Scaffold/Fields.php
index ca02e33..93d1d4a 100644
--- a/lib/Modules/Scaffold/Fields.php
+++ b/lib/Modules/Scaffold/Fields.php
@@ -526,9 +526,8 @@ class Scaffold_File extends Scaffold_Field
$info = pathinfo($this->postField($id, 'name'));
if (empty($info['extension']))
return '';
- if ($id == -1)
- $id = time();
- $new_name = $this->genFunc ? call_user_func($this->genFunc, $this->name, $id, '.'.$info['extension']) : $this->name.'_'.$id.'.'.$info['extension'];
+ $p = $id == -1 ? time() : $id;
+ $new_name = $this->genFunc ? call_user_func($this->genFunc, $this->name, $id, '.'.$info['extension']) : $this->name.'_'.$p.'.'.$info['extension'];
move_uploaded_file($this->postField($id, 'tmp_name'), $this->path.'/'.$new_name);
return $new_name;
}
commit 8e06a19ef7ba963ad8b01500f58f48cc0bd84791
Author: Ivan Borzenkov <iva...@li...>
Date: Fri Dec 10 18:53:42 2010 +0300
Правка загрузки файлов
diff --git a/lib/Modules/Scaffold/Fields.php b/lib/Modules/Scaffold/Fields.php
index e7bdae3..ca02e33 100644
--- a/lib/Modules/Scaffold/Fields.php
+++ b/lib/Modules/Scaffold/Fields.php
@@ -265,6 +265,8 @@ class Scaffold_Foreign extends Scaffold_Field
public function editor($id, $value)
{
+ if (isset($_POST['data'][$id][$this->name]))
+ $value = $_POST['data'][$id][$this->name];
return $this->selectBuild($id, $this->lookup, $value, $this->isnull);
}
@@ -391,6 +393,8 @@ class Scaffold_Enum extends Scaffold_Field
public function editor($id, $value)
{
+ if (isset($_POST['data'][$id][$this->name]))
+ $value = $_POST['data'][$id][$this->name];
return $this->selectBuild($id, $this->items, $value, false);
}
@@ -590,12 +594,8 @@ class Scaffold_Image extends Scaffold_File
public function proccess($id, $value, $old)
{
//если запись удалили
- if ($value === false)
- {
- if (is_file($this->path.'/'.$old))
- unlink($this->path.'/'.$old);
- return '';
- }
+ if ($value === false && is_file($this->path.'/'.$old))
+ unlink($this->path.'/'.$old);
//оставляем старое значение
if ($this->postField($id, 'error') == 4 && !$value)
return $old ? $old : '';
@@ -607,9 +607,8 @@ class Scaffold_Image extends Scaffold_File
return '';
//генерим новое имя
$ext = $this->getImgType($this->postField($id, 'tmp_name'));
- if ($id == -1)
- $id = time();
- $new_name = $this->genFunc ? call_user_func($this->genFunc, $this->name, $id, $ext) : $this->name.'_'.$id.$ext;
+ $p = $id == -1 ? time() : $id;
+ $new_name = $this->genFunc ? call_user_func($this->genFunc, $this->name, $id, $ext) : $this->name.'_'.$p.$ext;
move_uploaded_file($this->postField($id, 'tmp_name'), $this->path.'/'.$new_name);
return $new_name;
}
-----------------------------------------------------------------------
Summary of changes:
QFW/Templater/PlainView.php | 3 +-
QFW/Templater/Proxy.php | 4 +-
QFW/Templater/Smarty.php | 13 ++++-
QFW/Templater/Templater.php | 20 ++++++-
QFW/Templater/Twig.php | 4 +-
lib/Modules/Scaffold/Fields.php | 51 +++++++++++++++-----
lib/Modules/Scaffold/scaffold/edit.php | 2 +-
tests/app/060_view_assigns.phpt | 52 ++++++++++++++++++++
.../default/controllers/AssignsController.php | 20 ++++++++
tests/testapp/default/templates/assigns.php | 8 +++
10 files changed, 154 insertions(+), 23 deletions(-)
create mode 100644 tests/app/060_view_assigns.phpt
create mode 100644 tests/testapp/default/controllers/AssignsController.php
create mode 100644 tests/testapp/default/templates/assigns.php
hooks/post-receive
--
quickfw
|