Beispiel #1
0
 /**
  * Sort Objects by position
  * @param array $collection
  * @return Collection
  */
 public function sortPosition($collection)
 {
     if (!empty($collection)) {
         $i = 0;
         foreach ($collection as $coll) {
             $position = $coll->getPosition();
             if (empty($position)) {
                 $coll->setPosition(count($collection) - $i);
             }
             $i++;
         }
     }
     return zbase_collection($collection)->sortByDesc(function ($itm) {
         return $itm->getPosition();
     })->toArray();
 }
Beispiel #2
0
/**
 * Return contents for a certain module and widget
 *
 * @param string $module The module that is asking for content
 * @param string $widget The widget that is asking for content
 * @param string $section The current section [default: front] front|back
 * @param boolean $adminView IF for admin [default: false]
 * @param string $key key to search
 * @param array $contents Some contents
 * @return array
 */
function zbase_module_widget_contents($module, $widget, $section = 'front', $adminView = false, $key = null, $contents = [])
{
    $modules = zbase()->modules();
    foreach ($modules as $mod) {
        $widgetContent = $mod->widgetContents($widget, $module, $section, $adminView, $key);
        if (!empty($widgetContent)) {
            foreach ($widgetContent as $index => $content) {
                $contents[] = $content;
            }
        }
    }
    if (!empty($contents)) {
        return zbase_collection($contents)->sortByDesc(function ($itm) {
            return !empty($itm['position']) ? $itm['position'] : 0;
        })->toArray();
    }
}
<!-- BEGIN NOTIFICATION DROPDOWN -->
<?php 
$modules = zbase()->modules();
$notifications = [];
foreach ($modules as $module) {
    $notifications = array_merge($notifications, $module->getNotifications());
}
if (!empty($notifications)) {
    $notifications = zbase_collection($notifications)->sortByDesc(function ($itm) {
        return $itm->getOrder();
    })->toArray();
    foreach ($notifications as $notification) {
        echo $notification;
    }
}
?>
<!-- END NOTIFICATION DROPDOWN -->
Beispiel #4
0
					<li class="classic-menu-dropdown">
						<a href="/home">
							Home
							<span class="selected">
							</span>
						</a>
					</li>
					<?php 
    $modules = zbase()->modules();
    $navs = [];
    foreach ($modules as $module) {
        if ($module->hasNavigation(zbase_section())) {
            $navs[] = $module;
        }
    }
    $navs = zbase_collection($navs)->sortByDesc(function ($itm) {
        return $itm->getNavigationOrder();
    })->toArray();
    if (!empty($navs)) {
        foreach ($navs as $navigation) {
            echo $navigation->getNavigation(zbase_section());
        }
    }
    ?>
				</ul>
			</div>
		<?php 
}
?>

Beispiel #5
0
 /**
  * Prepare
  * return void
  */
 protected function _pre()
 {
     $this->_tabs = $this->sortPosition($this->_tabs);
     if (empty($this->_hasActiveTab) && !empty($this->_tabs)) {
         zbase_collection($this->_tabs)->first()->setActive(true);
     }
     parent::_pre();
 }
Beispiel #6
0
}
$script = ['jQuery(\'#' . $uiId . 'TreeView\').jstree(' . zbase_collection($pluginOptions)->toJson() . ')'];
$script[] = 'on(\'changed.jstree\', nodeCategoryJstreeOnClicked)';
zbase_view_script_add($uiId . 'TreeView', implode('.', $script) . ';', true);
$dataConfig = [];
$dataConfig['url'] = zbase_url_from_route('admin.node_' . $entity::$nodeNamePrefix . '_category', ['action' => 'ACTION', 'id' => 'ID']);
$dataConfig['node'] = str_replace('-', '_', $treeOptions['nodeWidgetId']);
$dataConfig['infopane'] = '#' . $uiId . 'TreeViewInfoPane';
?>

<div class="col-md-12">
	<div class="col-md-3 col-xs-12">
		<div class="slimScrollDiv" id="<?php 
echo $uiId;
?>
TreeView" data-id="<?php 
echo $uiId;
?>
" data-config='<?php 
echo zbase_collection($dataConfig)->toJson();
?>
'></div>
	</div>
	<div class="col-md-9 col-xs-12">
		<div id="<?php 
echo $uiId;
?>
TreeViewInfoPane"></div>
	</div>
</div>
Beispiel #7
0
 /**
  * Retrive all View Elements of a certain $type
  *
  * @param string $type
  * @return array
  */
 public function all($type, $group = null)
 {
     if ($this->_hasKey($type)) {
         $typeName = zbase_string_camel_case($type);
         if (!empty($group)) {
             if ($type == self::NAVIGATION) {
                 return zbase_collection($this->{$typeName}[$group])->sortBy(function ($view) {
                     if ($view instanceof Interfaces\PositionInterface) {
                         return $view->position();
                     }
                 })->all();
             }
         }
         return zbase_collection($this->{$typeName})->sortByDesc(function ($view) {
             if ($view instanceof Interfaces\PositionInterface) {
                 return $view->position();
             }
         })->all();
     }
 }