You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: AbstractRokMenuFormatter.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuFormatter.php');
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class AbstractRokMenuFormatter implements RokMenuFormatter
|
||||
{
|
||||
protected $active_branch = array();
|
||||
protected $args = array();
|
||||
protected $current_node = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(&$args)
|
||||
{
|
||||
$this->args =& $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $current_node
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrentNodeId($current_node)
|
||||
{
|
||||
$this->current_node = $current_node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $active_branch
|
||||
* @return void
|
||||
*/
|
||||
public function setActiveBranch(array $active_branch)
|
||||
{
|
||||
$this->active_branch = $active_branch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $menu
|
||||
* @return void
|
||||
*/
|
||||
public function format_tree(&$menu)
|
||||
{
|
||||
if (!empty($menu) && $menu !== false)
|
||||
{
|
||||
$this->_default_format_menu($menu);
|
||||
$this->format_menu($menu);
|
||||
|
||||
$nodeIterator = new RecursiveIteratorIterator($menu, RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($nodeIterator as $node)
|
||||
{
|
||||
$this->_format_subnodes($node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $node
|
||||
* @return void
|
||||
*/
|
||||
protected function _format_subnodes(&$node)
|
||||
{
|
||||
if ($node->getId() == $this->current_node)
|
||||
{
|
||||
$node->setCssId('current');
|
||||
}
|
||||
if (array_key_exists($node->getId(), $this->active_branch))
|
||||
{
|
||||
$node->addListItemClass('active');
|
||||
}
|
||||
$this->format_subnode($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $menu
|
||||
* @return void
|
||||
*/
|
||||
protected function _default_format_menu(&$menu)
|
||||
{
|
||||
// Limit the levels of the tree is called for By limitLevels
|
||||
$start = $this->args['startLevel'];
|
||||
$end = $this->args['endLevel'];
|
||||
|
||||
if ($this->args['limit_levels'])
|
||||
{
|
||||
//Limit to the active path if the start is more the level 0
|
||||
if ($start > 0)
|
||||
{
|
||||
$found = false;
|
||||
// get active path and find the start level that matches
|
||||
if (count($this->active_branch))
|
||||
{
|
||||
foreach ($this->active_branch as $active_child)
|
||||
{
|
||||
if ($active_child->getLevel() == $start - 1)
|
||||
{
|
||||
$menu->resetTop($active_child->getId());
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$found)
|
||||
{
|
||||
$menu->setChildren(array());
|
||||
}
|
||||
}
|
||||
//remove lower then the defined end level
|
||||
$menu->removeLevel($end);
|
||||
}
|
||||
|
||||
$always_show_menu = false;
|
||||
if (!array_key_exists('showAllChildren', $this->args) && $start==0)
|
||||
{
|
||||
$always_show_menu = true;
|
||||
}
|
||||
elseif (array_key_exists('showAllChildren', $this->args))
|
||||
{
|
||||
$always_show_menu = $this->args['showAllChildren'];
|
||||
}
|
||||
|
||||
if (!$always_show_menu)
|
||||
{
|
||||
if ($menu->hasChildren())
|
||||
{
|
||||
if (count($this->active_branch) == 0 || empty($this->active_branch))
|
||||
{
|
||||
$menu->removeLevel($start);
|
||||
}
|
||||
else
|
||||
{
|
||||
$active = array_keys($this->active_branch);
|
||||
foreach ($menu->getChildren() as $toplevel)
|
||||
{
|
||||
if (array_key_exists($toplevel->getId(), $this->active_branch) !== false)
|
||||
{
|
||||
end($active);
|
||||
$menu->removeIfNotInTree($active, current($active));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count($this->active_branch) > 0)
|
||||
$menu->removeLevelFromNonActive($this->active_branch, end($this->active_branch)->getLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $menu
|
||||
* @return void
|
||||
*/
|
||||
public function format_menu(&$menu)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
115
modules/mod_roknavmenu/lib/librokmenu/AbstractRokMenuLayout.php
Normal file
115
modules/mod_roknavmenu/lib/librokmenu/AbstractRokMenuLayout.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: AbstractRokMenuLayout.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuLayout.php');
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class AbstractRokMenuLayout implements RokMenuLayout
|
||||
{
|
||||
protected $args = array();
|
||||
protected $scripts = array();
|
||||
protected $inlineScript = '';
|
||||
protected $styles = array();
|
||||
protected $inlineStyle = '';
|
||||
protected $browser;
|
||||
protected $staged = false;
|
||||
|
||||
public function __construct(&$args)
|
||||
{
|
||||
$this->args =& $args;
|
||||
$this->browser = new RokBrowserCheck();
|
||||
}
|
||||
|
||||
public function doStageHeader()
|
||||
{
|
||||
if ($this->staged) return;
|
||||
$this->stageHeader();
|
||||
$this->staged = true;
|
||||
}
|
||||
|
||||
public function getInlineScript()
|
||||
{
|
||||
return $this->inlineScript;
|
||||
}
|
||||
|
||||
public function getInlineStyle()
|
||||
{
|
||||
return $this->inlineStyle;
|
||||
}
|
||||
|
||||
public function getStyleFiles()
|
||||
{
|
||||
return $this->styles;
|
||||
}
|
||||
|
||||
public function getScriptFiles()
|
||||
{
|
||||
return $this->scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqeues a script file after doing the browser specific check.
|
||||
* @param $scriptFile the script file relative to the themes root dir
|
||||
* @return void
|
||||
*/
|
||||
protected function addScript($scriptFile, $prefix = 'rokmenu_')
|
||||
{
|
||||
$full_path = $this->args['theme_path'] . '/' . dirname($scriptFile) . '/';
|
||||
$relative_path = $this->args['theme_rel_path'] . '/' . dirname($scriptFile) . '/';
|
||||
$url_path = $this->args['theme_url'] . '/' . dirname($scriptFile) . '/';
|
||||
|
||||
$file_checks = array_reverse($this->browser->getChecks($scriptFile));
|
||||
foreach ($file_checks as $file_check) {
|
||||
if (file_exists($full_path . $file_check) && is_readable($full_path . $file_check)) {
|
||||
$this->scripts[$prefix . $file_check] = array(
|
||||
'full' => $full_path . $file_check,
|
||||
'relative' => $relative_path . $file_check,
|
||||
'url' => $url_path . $file_check
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a css style file and any browser specific versions of it
|
||||
* @param $styleFile the css style file relative to the themes root dir
|
||||
* @return void
|
||||
*/
|
||||
protected function addStyle($styleFile, $prefix = 'rokmenu_')
|
||||
{
|
||||
$full_path = $this->args['theme_path'] . '/' . dirname($styleFile) . '/';
|
||||
$relative_path = $this->args['theme_rel_path'] . '/' . dirname($styleFile) . '/';
|
||||
$url_path = $this->args['theme_url'] . '/' . dirname($styleFile) . '/';
|
||||
|
||||
$file_checks = $this->browser->getChecks($styleFile);
|
||||
foreach ($file_checks as $file_check) {
|
||||
if (file_exists($full_path . $file_check) && is_readable($full_path . $file_check)) {
|
||||
$this->styles[$prefix . $file_check] = array(
|
||||
'full' => $full_path . $file_check,
|
||||
'relative' => $relative_path . $file_check,
|
||||
'url' => $url_path . $file_check
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function appendInlineStyle($inlineStyle)
|
||||
{
|
||||
$this->inlineStyle .= $inlineStyle;
|
||||
}
|
||||
|
||||
protected function appendInlineScript($inlineScript)
|
||||
{
|
||||
$this->inlineScript .= $inlineScript;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: AbstractRokMenuProvider.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuProvider.php');
|
||||
|
||||
|
||||
/**
|
||||
* The base class for all data providers for menus
|
||||
*/
|
||||
abstract class AbstractRokMenuProvider implements RokMenuProvider
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $args = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $active_branch = array();
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $current_node = 0;
|
||||
|
||||
/**
|
||||
* @var RokMenuNodeTree
|
||||
*/
|
||||
protected $menu;
|
||||
|
||||
/**
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(&$args)
|
||||
{
|
||||
$this->args =& $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getActiveBranch()
|
||||
{
|
||||
return $this->active_branch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrentNodeId()
|
||||
{
|
||||
return $this->current_node;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return RokMenuNodeTree
|
||||
*/
|
||||
public function getMenuTree()
|
||||
{
|
||||
if (null == $this->menu) {
|
||||
$this->menu = new RokMenuNodeTree();
|
||||
$this->populateMenuTree();
|
||||
}
|
||||
return $this->menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function populateMenuTree()
|
||||
{
|
||||
$nodes = $this->getMenuItems();
|
||||
$this->createMenuTree($nodes, $this->args['maxdepth']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the menu item nodes and puts them into a tree structure
|
||||
* @param $nodes
|
||||
* @param $maxdepth
|
||||
* @return bool|RokMenuNodeTree
|
||||
*/
|
||||
protected function createMenuTree(&$nodes, $maxdepth)
|
||||
{
|
||||
// TODO: move maxdepth to higher processing level?
|
||||
if (!empty($nodes)) {
|
||||
// Build Menu Tree root down (orphan proof - child might have lower id than parent)
|
||||
$ids = array();
|
||||
$ids[0] = true;
|
||||
$unresolved = array();
|
||||
|
||||
// pop the first item until the array is empty if there is any item
|
||||
if (is_array($nodes)) {
|
||||
while (count($nodes) && !is_null($node = array_shift($nodes)))
|
||||
{
|
||||
if (!$this->menu->addNode($node)) {
|
||||
if (!array_key_exists($node->getId(), $unresolved) || $unresolved[$node->getId()] < $maxdepth) {
|
||||
array_push($nodes, $node);
|
||||
if (!isset($unresolved[$node->getId()])) $unresolved[$node->getId()] = 1;
|
||||
else $unresolved[$node->getId()]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $nodeList
|
||||
* @return void
|
||||
*/
|
||||
protected function populateActiveBranch($nodeList)
|
||||
{
|
||||
// setup children array to find parents and children
|
||||
$children = array();
|
||||
$list = array();
|
||||
foreach ($nodeList as $node) {
|
||||
|
||||
$thisref = &$children[$node->getId()];
|
||||
$thisref['parent_id'] = $node->getParent();
|
||||
if ($node->getParent() == 0) {
|
||||
$list[$node->getId()] = &$thisref;
|
||||
} else {
|
||||
$children[$node->getParent()]['children'][] = $node->getId();
|
||||
}
|
||||
}
|
||||
// Find active branch
|
||||
if ($this->current_node != 0) {
|
||||
if (array_key_exists($this->current_node, $nodeList)) {
|
||||
|
||||
$parent_id = $children[$this->current_node]['parent_id'];
|
||||
while ($parent_id != 0) {
|
||||
$this->active_branch[$parent_id] = $nodeList[$parent_id];
|
||||
$parent_id = $children[$parent_id]['parent_id'];
|
||||
}
|
||||
$this->active_branch = array_reverse($this->active_branch, true);
|
||||
$this->active_branch[$this->current_node] = $nodeList[$this->current_node];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This platform specific function should be implemented to get the menu nodes and return them in a RokMenuNodeTree.
|
||||
* @abstract
|
||||
* @return array of RokMenuNode objects
|
||||
*/
|
||||
protected abstract function getMenuItems();
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: AbstractRokMenuTheme.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuTheme.php');
|
||||
|
||||
if (!class_exists('AbstractRokMenuTheme')) {
|
||||
|
||||
abstract class AbstractRokMenuTheme implements RokMenuTheme {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaults = array();
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaults() {
|
||||
return $this->defaults;
|
||||
}
|
||||
}
|
||||
}
|
124
modules/mod_roknavmenu/lib/librokmenu/RokMenu.php
Normal file
124
modules/mod_roknavmenu/lib/librokmenu/RokMenu.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenu.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuNodeTree.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuNode.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuNodeBase.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuFormatter.php');
|
||||
require_once(dirname(__FILE__) . '/AbstractRokMenuFormatter.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuLayout.php');
|
||||
require_once(dirname(__FILE__) . '/AbstractRokMenuLayout.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuProvider.php');
|
||||
require_once(dirname(__FILE__) . '/AbstractRokMenuProvider.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuTheme.php');
|
||||
require_once(dirname(__FILE__) . '/AbstractRokMenuTheme.php');
|
||||
|
||||
if (!class_exists('RokMenu')) {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class RokMenu {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $args = array();
|
||||
|
||||
/**
|
||||
* @var RokMenuProvider
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var RokMenuRenderer
|
||||
*/
|
||||
protected $renderer;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected static $menu_defaults = array(
|
||||
'limit_levels' => 0,
|
||||
'startLevel' => 0,
|
||||
'endLevel' => 0,
|
||||
'showAllChildren' => 1,
|
||||
'maxdepth' => 10
|
||||
);
|
||||
|
||||
/**
|
||||
* @param RokMenuRenderer $renderer
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($args) {
|
||||
$this->args = $args;
|
||||
|
||||
$this->renderer = $this->getRenderer();
|
||||
// get defaults for theme
|
||||
$renderer_defaults = $this->renderer->getDefaults();
|
||||
// merge theme defaults with class defaults theme defaults overrding
|
||||
$defaults = array_merge(self::$menu_defaults, $renderer_defaults);
|
||||
// merge defaults into passed args passed args overriding
|
||||
$this->args = array_merge($defaults, $args);
|
||||
|
||||
$this->renderer->setArgs($this->args);
|
||||
|
||||
$this->provider = $this->getProvider();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return array
|
||||
*/
|
||||
public static function getDefaults() {
|
||||
return self::$menu_defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->renderer->initialize($this->provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderMenu() {
|
||||
$output = $this->renderer->renderMenu();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderHeader() {
|
||||
$output = $this->renderer->renderHeader();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderFooter() {
|
||||
$output = $this->renderer->renderFooter();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return RokMenuProvider
|
||||
*/
|
||||
protected abstract function getProvider();
|
||||
|
||||
protected abstract function getRenderer();
|
||||
}
|
||||
}
|
||||
|
114
modules/mod_roknavmenu/lib/librokmenu/RokMenuDefaultRenderer.php
Normal file
114
modules/mod_roknavmenu/lib/librokmenu/RokMenuDefaultRenderer.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuDefaultRenderer.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class RokMenuDefaultRenderer implements RokMenuRenderer {
|
||||
protected $provider;
|
||||
protected $args;
|
||||
protected $theme;
|
||||
|
||||
/**
|
||||
* @var RokMenuFooter
|
||||
*/
|
||||
protected $formatter;
|
||||
|
||||
/**
|
||||
* @var RokMenuLayout
|
||||
*/
|
||||
protected $layout;
|
||||
|
||||
/**
|
||||
* @var RokMenuNodeTree
|
||||
*/
|
||||
protected $menu;
|
||||
|
||||
/**
|
||||
* @param RokMenuProvider $provider
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function setArgs(array &$args){
|
||||
$this->args =& $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaults() {
|
||||
if (!isset($this->theme)) {
|
||||
return array();
|
||||
}
|
||||
return $this->theme->getDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(RokMenuProvider $provider) {
|
||||
$this->formatter = $this->theme->getFormatter($this->args);
|
||||
$this->layout = $this->theme->getLayout($this->args);
|
||||
$menu = $provider->getMenuTree();
|
||||
$menu = $this->preProcessMenu($menu);
|
||||
if (!empty($menu) && $menu !== false) {
|
||||
$this->formatter->setActiveBranch($provider->getActiveBranch());
|
||||
$this->formatter->setCurrentNodeId($provider->getCurrentNodeId());
|
||||
$this->formatter->format_tree($menu);
|
||||
$this->menu = &$menu;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is run once the menu nodes are retrieved but before the formatter is run in order to give extending classes
|
||||
* a change to process the nodes in the menu.
|
||||
* @param RokMenuNodeTree $menu
|
||||
* @return RokMenuNodeTree
|
||||
*/
|
||||
protected function preProcessMenu(RokMenuNodeTree &$menu){
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderHeader() {
|
||||
$this->layout->doStageHeader();
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderMenu() {
|
||||
return $this->layout->renderMenu($this->menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderFooter() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RokMenuTheme $theme
|
||||
* @return void
|
||||
*/
|
||||
public function setTheme(RokMenuTheme $theme) {
|
||||
$this->theme = $theme;
|
||||
}
|
||||
}
|
56
modules/mod_roknavmenu/lib/librokmenu/RokMenuFormatter.php
Normal file
56
modules/mod_roknavmenu/lib/librokmenu/RokMenuFormatter.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuFormatter.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
if (!interface_exists('RokMenuFormatter')) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
interface RokMenuFormatter {
|
||||
/**
|
||||
* @abstract
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(&$args);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param $menu
|
||||
* @return void
|
||||
*/
|
||||
public function format_tree(&$menu);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param RokMenuNodeTree $menu
|
||||
* @return void
|
||||
*/
|
||||
public function format_menu(&$menu);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param RokMenuNode $node
|
||||
* @return void
|
||||
*/
|
||||
public function format_subnode(&$node);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param array $active_branch
|
||||
* @return void
|
||||
*/
|
||||
public function setActiveBranch(array $active_branch);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param int $current_node
|
||||
* @return void
|
||||
*/
|
||||
public function setCurrentNodeId($current_node);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuGreaterThenLevelFilter.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
class RokMenuGreaterThenLevelFilter extends RecursiveFilterIterator {
|
||||
protected $level;
|
||||
|
||||
public function __construct(RecursiveIterator $recursiveIter, $end) {
|
||||
$this->level = $end;
|
||||
parent::__construct($recursiveIter);
|
||||
}
|
||||
public function accept() {
|
||||
return $this->hasChildren() || $this->current()->getLevel() > $this->level;
|
||||
}
|
||||
|
||||
public function getChildren() {
|
||||
return new self($this->getInnerIterator()->getChildren(), $this->level);
|
||||
}
|
||||
}
|
13
modules/mod_roknavmenu/lib/librokmenu/RokMenuHeader.php
Normal file
13
modules/mod_roknavmenu/lib/librokmenu/RokMenuHeader.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuHeader.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
if (!interface_exists('RokMenuHeader')) {
|
||||
interface RokMenuHeader {
|
||||
|
||||
}
|
||||
}
|
23
modules/mod_roknavmenu/lib/librokmenu/RokMenuIdFilter.php
Normal file
23
modules/mod_roknavmenu/lib/librokmenu/RokMenuIdFilter.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuIdFilter.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
class RokMenuIdFilter extends RecursiveFilterIterator {
|
||||
protected $id;
|
||||
|
||||
public function __construct(RecursiveIterator $recursiveIter, $id) {
|
||||
$this->id = $id;
|
||||
parent::__construct($recursiveIter);
|
||||
}
|
||||
public function accept() {
|
||||
return $this->hasChildren() || $this->current()->getId() == $this->id;
|
||||
}
|
||||
|
||||
public function getChildren() {
|
||||
return new self($this->getInnerIterator()->getChildren(), $this->id);
|
||||
}
|
||||
}
|
54
modules/mod_roknavmenu/lib/librokmenu/RokMenuIterator.php
Normal file
54
modules/mod_roknavmenu/lib/librokmenu/RokMenuIterator.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuIterator.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
|
||||
class RokMenuIterator implements RecursiveIterator
|
||||
{
|
||||
protected $ar;
|
||||
|
||||
public function __construct(RokMenuNodeBase $menuNode)
|
||||
{
|
||||
$this->ar = $menuNode->getChildren();
|
||||
}
|
||||
|
||||
public function rewind()
|
||||
{
|
||||
reset($this->ar);
|
||||
}
|
||||
|
||||
public function valid()
|
||||
{
|
||||
return !is_null(key($this->ar));
|
||||
}
|
||||
|
||||
public function key()
|
||||
{
|
||||
return key($this->ar);
|
||||
}
|
||||
|
||||
public function next()
|
||||
{
|
||||
next($this->ar);
|
||||
}
|
||||
|
||||
public function current()
|
||||
{
|
||||
return current($this->ar);
|
||||
}
|
||||
|
||||
public function hasChildren()
|
||||
{
|
||||
$current = current($this->ar);
|
||||
return $current->hasChildren();
|
||||
}
|
||||
|
||||
public function getChildren()
|
||||
{
|
||||
return new RokMenuIterator($this->current());
|
||||
}
|
||||
}
|
67
modules/mod_roknavmenu/lib/librokmenu/RokMenuLayout.php
Normal file
67
modules/mod_roknavmenu/lib/librokmenu/RokMenuLayout.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuLayout.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
if (!interface_exists('RokMenuLayout')) {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
interface RokMenuLayout
|
||||
{
|
||||
/**
|
||||
* @abstract
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(&$args);
|
||||
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param $menu
|
||||
* @return void
|
||||
*/
|
||||
public function renderMenu(&$menu);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return void
|
||||
*/
|
||||
public function getScriptFiles();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return void
|
||||
*/
|
||||
public function getStyleFiles();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return void
|
||||
*/
|
||||
public function getInlineStyle();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return void
|
||||
*/
|
||||
public function getInlineScript();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return void
|
||||
*/
|
||||
public function doStageHeader();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return void
|
||||
*/
|
||||
public function stageHeader();
|
||||
}
|
||||
}
|
274
modules/mod_roknavmenu/lib/librokmenu/RokMenuNode.php
Normal file
274
modules/mod_roknavmenu/lib/librokmenu/RokMenuNode.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuNode.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuNodeBase.php');
|
||||
|
||||
|
||||
if (!class_exists('RokMenuNode')) {
|
||||
|
||||
/**
|
||||
* RokMenuNode
|
||||
*/
|
||||
class RokMenuNode extends RokMenuNodeBase
|
||||
{
|
||||
const PARENT_CSS_CLASS = "parent";
|
||||
|
||||
protected $title = null;
|
||||
protected $link = null;
|
||||
protected $cssId = null;
|
||||
protected $target = null;
|
||||
|
||||
protected $attributes = array();
|
||||
|
||||
protected $_link_additions = array();
|
||||
protected $_link_attribs = array();
|
||||
|
||||
protected $_li_classes = array();
|
||||
protected $_a_classes = array();
|
||||
protected $_span_classes = array();
|
||||
|
||||
/**
|
||||
* Gets the title
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title
|
||||
* @access public
|
||||
* @param string $title
|
||||
*/
|
||||
function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function setLink($link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
public function hasLink()
|
||||
{
|
||||
return (isset($this->link));
|
||||
}
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
$outlink = $this->link;
|
||||
$outlink .= $this->getLinkAdditions(!strpos($this->link, '?'));
|
||||
return $outlink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the css_id
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getCssId()
|
||||
{
|
||||
return $this->cssId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the css_id
|
||||
* @access public
|
||||
* @param string $cssId
|
||||
*/
|
||||
public function setCssId($cssId)
|
||||
{
|
||||
$this->cssId = $cssId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCssId(){
|
||||
return isset($this->cssId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target
|
||||
* @access public
|
||||
* @return string the target
|
||||
*/
|
||||
public function getTarget()
|
||||
{
|
||||
return $this->target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target
|
||||
* @access public
|
||||
* @param string the target $target
|
||||
*/
|
||||
public function setTarget($target)
|
||||
{
|
||||
$this->target = $target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTarget()
|
||||
{
|
||||
return isset($this->target);
|
||||
}
|
||||
|
||||
public function addAttribute($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
|
||||
public function getAttribute($key)
|
||||
{
|
||||
if (array_key_exists($key, $this->attributes))
|
||||
return $this->attributes[$key];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAttribute($key){
|
||||
return array_key_exists($key, $this->attributes);
|
||||
}
|
||||
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
public function addLinkAddition($name, $value)
|
||||
{
|
||||
$this->_link_additions[$name] = $value;
|
||||
}
|
||||
|
||||
public function getLinkAdditions($starting_query = false, $starting_seperator = false)
|
||||
{
|
||||
$link_additions = " ";
|
||||
reset($this->_link_additions);
|
||||
$i = 0;
|
||||
foreach ($this->_link_additions as $key => $value) {
|
||||
$link_additions .= (($i == 0) && $starting_query) ? '?' : '';
|
||||
$link_additions .= (($i == 0) && !$starting_query) ? '&' : '';
|
||||
$link_additions .= ($i > 0) ? '&' : '';
|
||||
$link_additions .= $key . '=' . $value;
|
||||
$i++;
|
||||
}
|
||||
return rtrim(ltrim($link_additions));
|
||||
}
|
||||
|
||||
public function getLinkAdditionsArray()
|
||||
{
|
||||
return $this->_link_additions;
|
||||
}
|
||||
|
||||
public function hasLinkAdditions()
|
||||
{
|
||||
return (count($this->_link_additions) > 0) ? true : false;
|
||||
}
|
||||
|
||||
public function addLinkAttrib($name, $value)
|
||||
{
|
||||
$this->_link_attribs[$name] = $value;
|
||||
}
|
||||
|
||||
public function getLinkAttribs()
|
||||
{
|
||||
$link_attribs = " ";
|
||||
foreach ($this->_link_attribs as $key => $value) {
|
||||
$link_attribs .= $key . "='" . $value . "' ";
|
||||
}
|
||||
return rtrim(ltrim($link_attribs));
|
||||
}
|
||||
|
||||
public function getLinkAttribsArray()
|
||||
{
|
||||
return $this->_link_attribs;
|
||||
}
|
||||
|
||||
public function hasLinkAttribs()
|
||||
{
|
||||
return (count($this->_link_attribs) > 0) ? true : false;
|
||||
}
|
||||
|
||||
public function getListItemClasses()
|
||||
{
|
||||
return implode(" ", $this->_li_classes);
|
||||
}
|
||||
|
||||
public function addListItemClass($class)
|
||||
{
|
||||
if (!in_array($class, $this->_li_classes))
|
||||
$this->_li_classes[] = $class;
|
||||
}
|
||||
|
||||
public function hasListItemClasses()
|
||||
{
|
||||
return (count($this->_li_classes) > 0) ? true : false;
|
||||
}
|
||||
|
||||
public function setListItemClasses($classes = array()){
|
||||
$this->_li_classes = $classes;
|
||||
}
|
||||
|
||||
public function getLinkClasses()
|
||||
{
|
||||
return implode(" ", $this->_a_classes);
|
||||
}
|
||||
|
||||
public function addLinkClass($class)
|
||||
{
|
||||
if (!in_array($class, $this->_a_classes))
|
||||
$this->_a_classes[] = $class;
|
||||
}
|
||||
|
||||
public function hasLinkClasses()
|
||||
{
|
||||
return (count($this->_a_classes) > 0) ? true : false;
|
||||
}
|
||||
|
||||
public function setLinkClasses($classes = array()){
|
||||
$this->_a_classes = $classes;
|
||||
}
|
||||
|
||||
public function getSpanClasses()
|
||||
{
|
||||
return implode(" ", $this->_span_classes);
|
||||
}
|
||||
|
||||
public function addSpanClass($class)
|
||||
{
|
||||
if (!in_array($class, $this->_span_classes))
|
||||
$this->_span_classes[] = $class;
|
||||
}
|
||||
|
||||
public function hasSpanClasses()
|
||||
{
|
||||
return (count($this->_span_classes) > 0) ? true : false;
|
||||
}
|
||||
|
||||
public function setSpanClasses($classes = array()){
|
||||
$this->_span_classes = $classes;
|
||||
}
|
||||
|
||||
|
||||
public function addChild(RokMenuNodeBase &$node)
|
||||
{
|
||||
parent::addChild($node);
|
||||
$this->addListItemClass(self::PARENT_CSS_CLASS);
|
||||
}
|
||||
}
|
||||
}
|
179
modules/mod_roknavmenu/lib/librokmenu/RokMenuNodeBase.php
Normal file
179
modules/mod_roknavmenu/lib/librokmenu/RokMenuNodeBase.php
Normal file
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuNodeBase.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuIterator.php');
|
||||
|
||||
if (!class_exists('RokMenuNodeBase')) {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class RokMenuNodeBase implements IteratorAggregate {
|
||||
|
||||
function getIterator() {
|
||||
return new RokMenuIterator($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $id = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $parent = 0;
|
||||
|
||||
/**
|
||||
* @var RokMenuNodeBase
|
||||
*/
|
||||
protected $parentRef = null;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $level = -1;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $children = array();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the id
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id
|
||||
* @access public
|
||||
* @param integer $id
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
public function getLevel() {
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level
|
||||
* @access public
|
||||
* @param integer $level
|
||||
*/
|
||||
public function setLevel($level) {
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the parent
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent
|
||||
* @access public
|
||||
* @param integer $parent
|
||||
*/
|
||||
public function setParent($parent) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RokMenuNodeBase
|
||||
*/
|
||||
public function getParentRef() {
|
||||
return $this->parentRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RokmenuNodeBase $parentRef
|
||||
* @return void
|
||||
*/
|
||||
public function setParentRef(RokmenuNodeBase & $parentRef) {
|
||||
$this->parentRef = &$parentRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $children
|
||||
* @return void
|
||||
*/
|
||||
public function setChildren(array $children) {
|
||||
$this->children = $children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RokMenuNodeBase $node
|
||||
* @return void
|
||||
*/
|
||||
public function addChild(RokMenuNodeBase &$node) {
|
||||
if (null == $this->children) {
|
||||
$this->children = array();
|
||||
}
|
||||
$node->setParentRef($this);
|
||||
$node->setLevel($this->getLevel()+1);
|
||||
$this->children[$node->getId()] = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasChildren() {
|
||||
return !empty($this->children);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function &getChildren() {
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $node_id
|
||||
* @return bool
|
||||
*/
|
||||
public function removeChild($node_id) {
|
||||
if (array_key_exists($node_id, $this->children)) {
|
||||
unset($this->children[$node_id]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $menuId
|
||||
*/
|
||||
public function setMenuId($menuId){
|
||||
$this->menuId = $menuId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getMenuId(){
|
||||
return $this->menuId;
|
||||
}
|
||||
}
|
||||
}
|
167
modules/mod_roknavmenu/lib/librokmenu/RokMenuNodeTree.php
Normal file
167
modules/mod_roknavmenu/lib/librokmenu/RokMenuNodeTree.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuNodeTree.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuNodeBase.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuNode.php');
|
||||
|
||||
if (!class_exists('RokMenuNodeTree')) {
|
||||
/**
|
||||
* Rok Nav Menu Tree Class.
|
||||
*/
|
||||
class RokMenuNodeTree extends RokMenuNodeBase
|
||||
{
|
||||
|
||||
|
||||
protected $rootid;
|
||||
|
||||
public function __construct($rootid = 0){
|
||||
$this->rootid = $rootid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $top_node_id
|
||||
* @return bool
|
||||
*/
|
||||
public function resetTop($top_node_id)
|
||||
{
|
||||
$new_top = $this->findNode($top_node_id);
|
||||
if (!$new_top) return false;
|
||||
$this->children = $new_top->getChildren();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RokMenuNodeBase $node
|
||||
* @return bool
|
||||
*/
|
||||
public function addNode(RokMenuNodeBase &$node)
|
||||
{
|
||||
if ($node->getParent() == $this->rootid) {
|
||||
$this->addChild($node);
|
||||
$node->setLevel(0);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$iterator = $this->getIterator();
|
||||
$childrenIterator = new RecursiveIteratorIterator(new RokMenuIdFilter($iterator, $node->getParent()), RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($childrenIterator as $child) {
|
||||
if ($child->getId() == $node->getParent()) {
|
||||
$child->addChild($node);
|
||||
$node->setLevel($childrenIterator->getDepth() + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function findNode($id)
|
||||
{
|
||||
$iterator = $this->getIterator();
|
||||
$childrenIterator = new RecursiveIteratorIterator(new RokMenuIdFilter($iterator, $id), RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($childrenIterator as $child) {
|
||||
if ($child->getId() == $id) {
|
||||
$childref = &$child;
|
||||
return $childref;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $nodeId
|
||||
* @return bool
|
||||
*/
|
||||
public function removeNode($nodeId)
|
||||
{
|
||||
$iterator = $this->getIterator();
|
||||
$childrenIterator = new RecursiveIteratorIterator(new RokMenuIdFilter($iterator, $nodeId), RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($childrenIterator as $child) {
|
||||
if ($child->getId() == $nodeId) {
|
||||
$parent = $child->getParentRef();
|
||||
$parent->removeChild($nodeId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $end
|
||||
* @return void
|
||||
*/
|
||||
public function removeLevel($end)
|
||||
{
|
||||
$toRemove = array();
|
||||
$iterator = $this->getIterator();
|
||||
$childrenIterator = new RecursiveIteratorIterator(new RokMenuGreaterThenLevelFilter($iterator, $end), RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($childrenIterator as $child) {
|
||||
if ($child->getLevel() > $end) {
|
||||
$toRemove[] = $child->getId();
|
||||
}
|
||||
}
|
||||
foreach ($toRemove as $remove_id) {
|
||||
$this->removeNode($remove_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $end
|
||||
* @return void
|
||||
*/
|
||||
public function removeLevelFromNonActive($active_tree, $end)
|
||||
{
|
||||
$toRemove = array();
|
||||
$iterator = $this->getIterator();
|
||||
$childrenIterator = new RecursiveIteratorIterator(new RokMenuNotOnActiveTreeFilter($iterator,$active_tree,$end), RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
foreach ($childrenIterator as $child) {
|
||||
if ($child->getLevel() > $end+1) {
|
||||
$toRemove[] = $child->getId();
|
||||
}
|
||||
}
|
||||
foreach ($toRemove as $remove_id) {
|
||||
$this->removeNode($remove_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $active_tree the array of active RokNavMenu items
|
||||
* @param int $last_active the id of the last active item in the tree
|
||||
* @return void
|
||||
*/
|
||||
public function removeIfNotInTree(&$active_tree, $last_active)
|
||||
{
|
||||
if (!empty($active_tree)) {
|
||||
$toRemove = array();
|
||||
$childrenIterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($childrenIterator as $child) {
|
||||
if (!in_array($child->getId(), $active_tree) && $last_active == $child->getId()) {
|
||||
// i am the last node in the active tree dont show my childs but not my grandchildren
|
||||
foreach ($child as $subchild) {
|
||||
$toRemove = array_merge($toRemove, array_keys($subchild->getChildren()));
|
||||
}
|
||||
}
|
||||
else if (!in_array($child->getId(), $active_tree) && $child->getParent() != $last_active) {
|
||||
// I am not in the active tree and not a child of the last node in the active tree so dont show my children
|
||||
$toRemove = array_merge($toRemove, array_keys($child->getChildren()));
|
||||
}
|
||||
}
|
||||
foreach ($toRemove as $remove_id) {
|
||||
$this->removeNode($remove_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuNotOnActiveTreeFilter.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
class RokMenuNotOnActiveTreeFilter extends RecursiveFilterIterator {
|
||||
protected $active_tree = array();
|
||||
protected $level;
|
||||
|
||||
public function __construct(RecursiveIterator $recursiveIter, $active_tree, $end) {
|
||||
$this->level = $end;
|
||||
$this->active_tree = $active_tree;
|
||||
parent::__construct($recursiveIter);
|
||||
}
|
||||
public function accept() {
|
||||
|
||||
$array_keys = array_keys($this->active_tree);
|
||||
$key = end($array_keys);
|
||||
|
||||
if (!array_key_exists($this->current()->getId(),$this->active_tree) && $this->current()->getParent() == $key){
|
||||
$this->active_tree[$this->current()->getId()] = $this->current();
|
||||
}
|
||||
if (array_key_exists($this->current()->getId(),$this->active_tree) && $this->current()->getLevel() > $this->level+1){
|
||||
return true;
|
||||
}
|
||||
else if (!array_key_exists($this->current()->getId(),$this->active_tree) && $this->current()->getLevel() > $this->level){
|
||||
return true;
|
||||
}
|
||||
else if ($this->hasChildren()){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getChildren() {
|
||||
return new self($this->getInnerIterator()->getChildren(), $this->active_tree, $this->level);
|
||||
}
|
||||
}
|
40
modules/mod_roknavmenu/lib/librokmenu/RokMenuProvider.php
Normal file
40
modules/mod_roknavmenu/lib/librokmenu/RokMenuProvider.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuProvider.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
if (!interface_exists('RokMenuProvider')) {
|
||||
|
||||
/**
|
||||
* The base class for all data providers for menus
|
||||
*/
|
||||
interface RokMenuProvider {
|
||||
/**
|
||||
* Gets an array of RokMenuNodes for that represent the menu items. This should be a non hierarchical array.
|
||||
* @abstract
|
||||
* @return array of RokMenuNode objects
|
||||
*/
|
||||
function getActiveBranch();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return int
|
||||
*/
|
||||
function getCurrentNodeId();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return RokMenuNodeTree
|
||||
*/
|
||||
function getMenuTree();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
function __construct(&$args);
|
||||
}
|
||||
}
|
58
modules/mod_roknavmenu/lib/librokmenu/RokMenuRenderer.php
Normal file
58
modules/mod_roknavmenu/lib/librokmenu/RokMenuRenderer.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuRenderer.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
if (!interface_exists('RokMenuRenderer')) {
|
||||
|
||||
/**
|
||||
* The base class for all data providers for menus
|
||||
*/
|
||||
interface RokMenuRenderer {
|
||||
/**
|
||||
* @abstract
|
||||
* @return void
|
||||
*/
|
||||
public function __construct();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param $args
|
||||
* @return void
|
||||
*/
|
||||
public function setArgs(array &$args);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(RokMenuProvider $provider);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return string
|
||||
*/
|
||||
public function renderHeader();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return string
|
||||
*/
|
||||
public function renderMenu();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return string
|
||||
*/
|
||||
public function renderFooter();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaults();
|
||||
|
||||
}
|
||||
}
|
36
modules/mod_roknavmenu/lib/librokmenu/RokMenuTheme.php
Normal file
36
modules/mod_roknavmenu/lib/librokmenu/RokMenuTheme.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuTheme.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
if (!interface_exists('RokMenuTheme')) {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
interface RokMenuTheme {
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaults();
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param $args array
|
||||
* @return RokMenuFormatter
|
||||
*/
|
||||
public function getFormatter($args);
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param $args
|
||||
* @return RokMenuLayout
|
||||
*/
|
||||
public function getLayout($args);
|
||||
|
||||
}
|
||||
}
|
32
modules/mod_roknavmenu/lib/librokmenu/includes.php
Normal file
32
modules/mod_roknavmenu/lib/librokmenu/includes.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: includes.php 4585 2012-10-27 01:44:54Z btowles $
|
||||
* @author RocketTheme http://www.rockettheme.com
|
||||
* @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
|
||||
*/
|
||||
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuNodeBase.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuIterator.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuIdFilter.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuGreaterThenLevelFilter.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuNotOnActiveTreeFilter.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuNode.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuNodeTree.php');
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuFormatter.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuLayout.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuProvider.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuTheme.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuRenderer.php');
|
||||
|
||||
|
||||
require_once(dirname(__FILE__) . '/AbstractRokMenuFormatter.php');
|
||||
require_once(dirname(__FILE__) . '/AbstractRokMenuLayout.php');
|
||||
require_once(dirname(__FILE__) . '/AbstractRokMenuProvider.php');
|
||||
require_once(dirname(__FILE__) . '/AbstractRokMenuTheme.php');
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenuDefaultRenderer.php');
|
||||
|
||||
require_once(dirname(__FILE__) . '/RokMenu.php');
|
1
modules/mod_roknavmenu/lib/librokmenu/index.html
Normal file
1
modules/mod_roknavmenu/lib/librokmenu/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
Reference in New Issue
Block a user