@@ -12,6 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | class Tree extends \Object |
| 14 | 14 | { |
| 15 | + /** |
|
| 16 | + * @param \Closure $hrefFunc |
|
| 17 | + */ |
|
| 15 | 18 | public static function ul($objectRoot, $maxDeep = 0, $hrefFunc = null) |
| 16 | 19 | { |
| 17 | 20 | $count = 0; |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Tree |
|
| 4 | - * |
|
| 5 | - * @author Alexey Krupskiy <[email protected]> |
|
| 6 | - * @link http://inji.ru/ |
|
| 7 | - * @copyright 2015 Alexey Krupskiy |
|
| 8 | - * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
|
| 9 | - */ |
|
| 3 | + * Tree |
|
| 4 | + * |
|
| 5 | + * @author Alexey Krupskiy <[email protected]> |
|
| 6 | + * @link http://inji.ru/ |
|
| 7 | + * @copyright 2015 Alexey Krupskiy |
|
| 8 | + * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | namespace Ui; |
| 12 | 12 | |
@@ -23,17 +23,17 @@ discard block |
||
| 23 | 23 | ?> |
| 24 | 24 | <ul class="treeview" data-col='tree_path'> |
| 25 | 25 | <?php |
| 26 | - if (is_string($objectRoot)) { |
|
| 27 | - $items = $objectRoot::getList(['where' => ['parent_id', 0]]); |
|
| 28 | - } else { |
|
| 29 | - $class = get_class($objectRoot); |
|
| 30 | - $items = $class::getList(['where' => ['parent_id', $objectRoot->pk()]]); |
|
| 31 | - } |
|
| 32 | - $count += count($items); |
|
| 33 | - foreach ($items as $objectChild) { |
|
| 34 | - $count+=static::showLi($objectChild, 1, $maxDeep, $hrefFunc); |
|
| 35 | - } |
|
| 36 | - ?> |
|
| 26 | + if (is_string($objectRoot)) { |
|
| 27 | + $items = $objectRoot::getList(['where' => ['parent_id', 0]]); |
|
| 28 | + } else { |
|
| 29 | + $class = get_class($objectRoot); |
|
| 30 | + $items = $class::getList(['where' => ['parent_id', $objectRoot->pk()]]); |
|
| 31 | + } |
|
| 32 | + $count += count($items); |
|
| 33 | + foreach ($items as $objectChild) { |
|
| 34 | + $count+=static::showLi($objectChild, 1, $maxDeep, $hrefFunc); |
|
| 35 | + } |
|
| 36 | + ?> |
|
| 37 | 37 | </ul> |
| 38 | 38 | <?php |
| 39 | 39 | return $count; |
@@ -17,30 +17,30 @@ discard block |
||
| 17 | 17 | ?> |
| 18 | 18 | <div class="filter"> |
| 19 | 19 | <?php |
| 20 | - switch ($option->type) { |
|
| 21 | - case 'radio': |
|
| 20 | + switch ($option->type) { |
|
| 21 | + case 'radio': |
|
| 22 | 22 | foreach ($option->items as $item) { |
| 23 | - $this->widget('Ui\Form/' . $option->type, [ |
|
| 24 | - 'label' => $item->name, |
|
| 25 | - 'name' => "filters[options][{$option->id}]", |
|
| 26 | - !empty($_GET['filters']['options'][$option->id]) && $_GET['filters']['options'][$option->id] == $item->id ? 'checked' : false, |
|
| 27 | - 'options' => [ |
|
| 28 | - 'value' => $item->id, |
|
| 29 | - ] |
|
| 30 | - ]); |
|
| 31 | - } |
|
| 32 | - break; |
|
| 33 | - default: |
|
| 23 | + $this->widget('Ui\Form/' . $option->type, [ |
|
| 24 | + 'label' => $item->name, |
|
| 25 | + 'name' => "filters[options][{$option->id}]", |
|
| 26 | + !empty($_GET['filters']['options'][$option->id]) && $_GET['filters']['options'][$option->id] == $item->id ? 'checked' : false, |
|
| 27 | + 'options' => [ |
|
| 28 | + 'value' => $item->id, |
|
| 29 | + ] |
|
| 30 | + ]); |
|
| 31 | + } |
|
| 32 | + break; |
|
| 33 | + default: |
|
| 34 | 34 | $this->widget('Ui\Form/' . $option->type, [ |
| 35 | - 'label' => $option->name, |
|
| 36 | - 'name' => "filters[options][{$option->id}]", |
|
| 37 | - 'options' => [ |
|
| 38 | - 'value' => !empty($_GET['filters']['options'][$option->id]) ? $_GET['filters']['options'][$option->id] : '', |
|
| 39 | - ] |
|
| 40 | - ]); |
|
| 41 | - } |
|
| 42 | - foreach ($option->items as $item) { |
|
| 43 | - ?> |
|
| 35 | + 'label' => $option->name, |
|
| 36 | + 'name' => "filters[options][{$option->id}]", |
|
| 37 | + 'options' => [ |
|
| 38 | + 'value' => !empty($_GET['filters']['options'][$option->id]) ? $_GET['filters']['options'][$option->id] : '', |
|
| 39 | + ] |
|
| 40 | + ]); |
|
| 41 | + } |
|
| 42 | + foreach ($option->items as $item) { |
|
| 43 | + ?> |
|
| 44 | 44 | <div class="radio"> |
| 45 | 45 | <label> |
| 46 | 46 | <input type="radio" name = 'filters[options][<?= $option->id; ?>]' value ="<?= $item->id; ?>" <?= !empty($_GET['filters']['options'][$option->id]) && $_GET['filters']['options'][$option->id] == $item->id ? 'checked' : ''; ?>> |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | </label> |
| 49 | 49 | </div> |
| 50 | 50 | <?php |
| 51 | - } |
|
| 52 | - ?> |
|
| 51 | + } |
|
| 52 | + ?> |
|
| 53 | 53 | </div> |
| 54 | 54 | <?php |
| 55 | 55 | } |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <div class="ecommerce-sidebar-categorys"> |
| 2 | 2 | <?php |
| 3 | - $tree = new Ui\Tree(); |
|
| 4 | - $tree->ul('\Ecommerce\Category', 0, function($categoryItem) use($category) { |
|
| 5 | - if ($category->id == $categoryItem->id) { |
|
| 6 | - $class = 'active'; |
|
| 7 | - } else { |
|
| 8 | - $class = ''; |
|
| 9 | - } |
|
| 10 | - return [ |
|
| 11 | - 'class' => $class, |
|
| 12 | - 'text' => "<a {$class} href = '/ecommerce/itemList/{$categoryItem->id}'>{$categoryItem->name}</a>" |
|
| 13 | - ]; |
|
| 14 | - }); |
|
| 15 | - ?> |
|
| 3 | + $tree = new Ui\Tree(); |
|
| 4 | + $tree->ul('\Ecommerce\Category', 0, function($categoryItem) use($category) { |
|
| 5 | + if ($category->id == $categoryItem->id) { |
|
| 6 | + $class = 'active'; |
|
| 7 | + } else { |
|
| 8 | + $class = ''; |
|
| 9 | + } |
|
| 10 | + return [ |
|
| 11 | + 'class' => $class, |
|
| 12 | + 'text' => "<a {$class} href = '/ecommerce/itemList/{$categoryItem->id}'>{$categoryItem->name}</a>" |
|
| 13 | + ]; |
|
| 14 | + }); |
|
| 15 | + ?> |
|
| 16 | 16 | </div> |
| 17 | 17 | \ No newline at end of file |