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 68b2ec429e005a1e7a58d28e5ba33852be511f19 (commit)
from 665668c2e8458e82d493f7eecae0102b3573ff82 (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 68b2ec429e005a1e7a58d28e5ba33852be511f19
Author: Ivan Borzenkov <iva...@li...>
Date: Sun Oct 10 14:49:34 2010 +0400
Динамическое меню - хелпер и пример
diff --git a/application/default/controllers/IndexController.php b/application/default/controllers/IndexController.php
index f087d4a..1d672b6 100644
--- a/application/default/controllers/IndexController.php
+++ b/application/default/controllers/IndexController.php
@@ -16,6 +16,11 @@ class IndexController extends QuickFW_Auth
return QFW::$view->fetch('b.html');
}
+ public function dinmenuAction()
+ {
+ return QFW::$view->fetch('dinmenu.html');
+ }
+
public function testBlock()
{
echo 2;
diff --git a/application/default/templates/dinmenu.html b/application/default/templates/dinmenu.html
new file mode 100644
index 0000000..579fa33
--- /dev/null
+++ b/application/default/templates/dinmenu.html
@@ -0,0 +1,117 @@
+<style>
+ul#ttt ul, ul#ttt li {
+ margin:-1px;
+ padding:1px;
+}
+ul#ttt li {display:inline-block; position:relative; border:1px solid red;}
+ul#ttt li a {display:block; width:200px}
+ul#ttt li ul {
+position:absolute;
+top:25px;
+left:10px;
+}
+ul#ttt li ul li {
+display:block; position:relative;
+}
+ul#ttt li ul {display:none}
+ul#ttt li:hover > ul {display:block}
+ul#ttt li ul li ul {
+position:absolute;
+top:0px;
+left:95%;
+}
+
+</style>
+
+<?php echo $this->block('helper.nav.menuTree', array(
+ array(
+ 'title' => 'afgdfgdfggf',
+ 'url' => Url::A(),
+ ),
+ array(
+ 'title' => 'asdffgdfgdfgdf',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'askj',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ ),
+ ),
+ ),
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ ),
+ ),
+ ),
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'title' => 'asdfgsdf',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ ),
+ ),
+ ),
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ ),
+ ),
+ ),
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ 'childNodes' => array(
+ array(
+ 'title' => 'afhgfgjgf',
+ 'url' => Url::A(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'title' => 'asdf',
+ 'url' => Url::A(),
+ ),
+ ),
+ ),
+ array(
+ 'title' => 'a',
+ 'url' => Url::A(),
+ ),
+), 'ttt');?>
diff --git a/application/default/templates/index.html b/application/default/templates/index.html
index 5a2aa47..9ab50b9 100644
--- a/application/default/templates/index.html
+++ b/application/default/templates/index.html
@@ -4,4 +4,7 @@
<li><a href="<?php echo Url::M('doc') ?>">Документация</a>
<p><small>Для генерации нужен установленный a2x, xetex и вообще только unix - с виндой трахайтесь как хотите</small></p>
</li>
+ <li><a href="<?php echo Url::C('dinmenu') ?>">Динамическое меню</a>
+ <p><small>Пример вложенного динамического меню с помощью хелпера на CSS3</small></p>
+ </li>
</ul>
diff --git a/application/helper/controllers/NavController.php b/application/helper/controllers/NavController.php
index 7b0c95f..884c070 100644
--- a/application/helper/controllers/NavController.php
+++ b/application/helper/controllers/NavController.php
@@ -28,16 +28,71 @@ class NavController
}
/**
+ * Древоводное меню на вложенными списками
+ *
+ * @param array $items Массив элементов:
+ * <br>каждый элемент - array(
+ * <br> 'title' => Заголовок,
+ * <br> 'url' => адрес(Url|строка|false),
+ * <br> 'childNodes' => вложенный массив аналогичной структуры,
+ * <br>)
+ * <br>остальные элементы игнорируются
+ * @param string $id id для элемента ul - для оформления
+ * @param Url $cur текущий адресс
+ * @return string Сформированное меню
+ */
+ public function menuTreeBlock($items, $id='', $cur=false)
+ {
+ if (count($items) == 0)
+ return '';
+ if ($cur == false)
+ $cur = QFW::$router->RequestUri;
+ $result = '<ul'.($id?' id="'.$id.'"':'').'>';
+ $result.=$this->menuTreeNodes($items, $cur);
+ $result.= '</ul>';
+ return $result;
+ }
+
+ /**
+ * Рекурсивная функция формирования меню
+ *
+ * @param array $items Массив элементов - аналогичен menuTreeBlock
+ * @param Url $cur текущий адресс
+ * @return string Сформированное подменю
+ */
+ private function menuTreeNodes($items, $cur)
+ {
+ $result = '';
+ foreach ($items as $v)
+ {
+ $result.='<li>';
+ if ($v === false)
+ $result.=$v['title'];
+ else
+ {
+ if ($v['url'] instanceof Url)
+ $self = $cur == $v['url']->intern();
+ else
+ $self = $cur == $v['url'];
+ $result.= $self ? '<b>'.$v['title'].'</b>' : '<a href="'.$v['url'].'">'.$v['title'].'</a>';
+ }
+ if (isset($v['childNodes']))
+ $result.='<ul>'.$this->menuTreeNodes($v['childNodes'], $cur).'</ul>';
+ $result.="</li>\n";
+ }
+ return $result;
+ }
+
+ /**
* Вывод меню списком с подсветкой текущего элемента
*
* @param array $items Массив элементов:
* <br>ключ - заголовок, значение Url|false
* @param string $id id для элемента ul - для оформления
* @param Url $cur текущий адресс
- * @param boolean $delDef Применять к ссылкам функцию QFW::$router->delDef
* @return string Сформированное меню
*/
- public function menuNewBlock($items, $id='', $cur=false)
+ public function menuBlock($items, $id='', $cur=false)
{
if (count($items) == 0)
return '';
@@ -73,7 +128,7 @@ class NavController
* @param boolean $delDef Применять к ссылкам функцию QFW::$router->delDef
* @return string Сформированное меню
*/
- public function menuBlock($items, $id='', $cur=false, $delDef = true)
+ public function menuOldBlock($items, $id='', $cur=false, $delDef = true)
{
if (count($items) == 0)
return '';
-----------------------------------------------------------------------
Summary of changes:
.../default/controllers/IndexController.php | 5 +
application/default/templates/dinmenu.html | 117 ++++++++++++++++++++
application/default/templates/index.html | 3 +
application/helper/controllers/NavController.php | 61 ++++++++++-
4 files changed, 183 insertions(+), 3 deletions(-)
create mode 100644 application/default/templates/dinmenu.html
hooks/post-receive
--
quickfw
|