You've already forked joomla_test
first commit
This commit is contained in:
346
modules/mod_roknavmenu/lib/renderers/RokNavMenu1XRenderer.php
Normal file
346
modules/mod_roknavmenu/lib/renderers/RokNavMenu1XRenderer.php
Normal file
@ -0,0 +1,346 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokNavMenu1XRenderer.php 9687 2013-04-24 20:37:47Z 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 RokNavMenu1XRenderer implements RokMenuRenderer {
|
||||
protected $provider;
|
||||
protected $args;
|
||||
|
||||
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) {
|
||||
$menu_data = $provider->getMenuTree();
|
||||
if (!empty($menu_data) && $menu_data !== false) {
|
||||
$menu = $this->convertNodes($menu_data);
|
||||
|
||||
$menu_params = new JRegistry();
|
||||
$menu_params->loadArray($this->args);
|
||||
|
||||
$menu = $this->getFormattedMenu($menu, $menu_params);
|
||||
$this->layout_path = $this->getLayoutPath($menu_params);
|
||||
$this->menu = &$menu;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderHeader() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderMenu() {
|
||||
$menu =& $this->menu;
|
||||
require($this->layout_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function renderFooter() {
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function convertNodes(RokMenuNodeTree $menu) {
|
||||
|
||||
$top = new RokNavMenuTree();
|
||||
$top->_params = $this->convertArgsToParams();
|
||||
|
||||
$subnodes = array();
|
||||
// convert the nodes to an array of old school node types
|
||||
$itr = new RecursiveIteratorIterator($menu, RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($itr as $tmp) {
|
||||
$node = new RokNavMenuNode();
|
||||
$node->id = $tmp->getId();
|
||||
$node->parent = $tmp->getParent();
|
||||
$node->title = $tmp->getTitle();
|
||||
$node->access = $tmp->getAccess();
|
||||
$node->link = $tmp->getLink();
|
||||
$node->level = $tmp->getLevel();
|
||||
$node->image = $tmp->getImage();
|
||||
$node->alias = $tmp->isAlias();
|
||||
$node->nav = $tmp->getTarget();
|
||||
$node->access = $tmp->getAccess();
|
||||
switch ($tmp->getTarget()) {
|
||||
case 'newnotool':
|
||||
$node->displayType = 2;
|
||||
break;
|
||||
case 'new':
|
||||
$node->displayType = 1;
|
||||
break;
|
||||
default:
|
||||
$node->displayType = 0;
|
||||
break;
|
||||
}
|
||||
$node->setParameters($tmp->getParams());
|
||||
$node->type = $tmp->getType();
|
||||
//$node->order = $item->ordering;
|
||||
|
||||
foreach(explode(" ",$tmp->getListItemClasses()) as $class){
|
||||
$node->addListItemClass($class);
|
||||
}
|
||||
foreach(explode(" ",$tmp->getSpanClasses()) as $class){
|
||||
$node->addSpanClass($class);
|
||||
}
|
||||
foreach(explode(" ",$tmp->getLinkClasses()) as $class){
|
||||
$node->addLinkClass($class);
|
||||
}
|
||||
foreach($tmp->getLinkAttribsArray() as $name => $attrib){
|
||||
$node->addLinkAttrib($name, $attrib);
|
||||
}
|
||||
foreach($tmp->getLinkAdditionsArray() as $name => $value){
|
||||
$node->addLinkAddition($name, $value);
|
||||
}
|
||||
|
||||
if ($node->parent == RokNavMenu::TOP_LEVEL_PARENT_ID){
|
||||
$node->_parentRef = $top;
|
||||
$top->_children[$node->id] = $node;
|
||||
|
||||
}
|
||||
else {
|
||||
foreach ($subnodes as $subnode){
|
||||
if ($node->parent == $subnode->id){
|
||||
$subnode->addChild($node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$subnodes[] = $node;
|
||||
}
|
||||
return $top;
|
||||
}
|
||||
|
||||
protected function convertArgsToParams() {
|
||||
$params = new JRegistry();
|
||||
$params->loadArray($this->args);
|
||||
return $params;
|
||||
}
|
||||
|
||||
|
||||
public function getThemePath(&$params) {
|
||||
$default_module_theme_dir = JPath::clean('/modules/mod_roknavmenu/themes');
|
||||
$basic_theme = $default_module_theme_dir . '/default';
|
||||
$theme = $params->get('theme', $basic_theme);
|
||||
// Set the theme to the old school default theme if it exists
|
||||
if ($params->get('default_formatter', false)) {
|
||||
$theme = $default_module_theme_dir . '/' . $params->get('default_formatter', 'default');
|
||||
}
|
||||
return $theme;
|
||||
}
|
||||
|
||||
public function getFormatterPath(&$params) {
|
||||
$app = JFactory::getApplication();
|
||||
$theme = $this->getThemePath($params);
|
||||
|
||||
// Get the formatters path
|
||||
$formatter_path = JPath::clean(JPATH_ROOT . $params->get('theme', $theme) . "/formatter.php");
|
||||
|
||||
$template_default_formatter_path = JPath::clean(JPATH_ROOT . '/templates/' . $app->getTemplate() . '/html/mod_roknavmenu/formatter.php');
|
||||
if (JFile::exists($template_default_formatter_path)) {
|
||||
$formatter_path = $template_default_formatter_path;
|
||||
}
|
||||
|
||||
$template_formatter_path = JPath::clean(JPATH_ROOT . '/templates/' . $app->getTemplate() . '/html/mod_roknavmenu/themes/' . $theme . '/formatter.php');
|
||||
if (JFile::exists($template_formatter_path)) {
|
||||
$formatter_path = $template_formatter_path;
|
||||
}
|
||||
|
||||
//see if the backwards compat custom_formatter is set.
|
||||
$template_formatter = $params->get('custom_formatter', "default");
|
||||
$template_named_formatter_path = JPath::clean(JPATH_ROOT . '/templates/' . $app->getTemplate() . '/html/mod_roknavmenu/formatters/' . $template_formatter . '.php');
|
||||
if (JFile::exists($template_named_formatter_path)) {
|
||||
$formatter_path = $template_named_formatter_path;
|
||||
}
|
||||
return $formatter_path;
|
||||
}
|
||||
|
||||
public function getLayoutPath(&$params) {
|
||||
$app = JFactory::getApplication();
|
||||
$theme = $this->getThemePath($params);
|
||||
|
||||
// Get the layout path
|
||||
$layout_path = JPath::clean(JPATH_ROOT . $theme . "/layout.php");
|
||||
|
||||
$joomla_layout_path = JModuleHelper::getLayoutPath('mod_roknavmenu');
|
||||
if (JFile::exists($joomla_layout_path)) {
|
||||
$layout_path = $joomla_layout_path;
|
||||
}
|
||||
|
||||
$template_layout_path = JPath::clean(JPATH_ROOT . '/templates/' . $app->getTemplate() . '/html/mod_roknavmenu/themes/' . $theme . '/layout.php');
|
||||
if (JFile::exists($template_layout_path)) {
|
||||
$layout_path = $template_layout_path;
|
||||
}
|
||||
|
||||
//see if the backwards compat custom_formatter is set.
|
||||
if ($params->get('custom_layout', false)) {
|
||||
$template_layout = $params->get('custom_layout', "default");
|
||||
$template_named_layput_path = JPath::clean(JPATH_ROOT . '/templates/' . $app->getTemplate() . '/html/mod_roknavmenu/layouts/' . $template_layout . '.php');
|
||||
if (JFile::exists($template_named_layput_path)) {
|
||||
$layout_path = $template_named_layput_path;
|
||||
}
|
||||
}
|
||||
return $layout_path;
|
||||
}
|
||||
|
||||
protected function getFormattedMenu($menu, &$params) {
|
||||
$app = JFactory::getApplication();
|
||||
// get the base menu data structure
|
||||
|
||||
// Run the basic formatter
|
||||
$this->formatMenu($menu);
|
||||
|
||||
$default_module_theme_dir = JPath::clean('/modules/mod_roknavmenu/themes');
|
||||
|
||||
$theme = $this->getThemePath($params);
|
||||
|
||||
$theme_name = basename($params->get('theme', $theme));
|
||||
|
||||
$formatter_path = $this->getFormatterPath($params);
|
||||
|
||||
//load the formatter
|
||||
require_once ($formatter_path);
|
||||
|
||||
$theme_type = 'Template';
|
||||
// Find if this is a Default or Template theme
|
||||
if (dirname(JPath::clean($params->get('theme', $theme))) == $default_module_theme_dir) {
|
||||
$theme_type = 'Default';
|
||||
}
|
||||
|
||||
// run the formatter class
|
||||
$theme_formatter_class = 'RokNavMenuFormatter' . str_replace('-', '', $theme_type . $theme_name);
|
||||
if (class_exists($theme_formatter_class)) {
|
||||
$formatter = new $theme_formatter_class();
|
||||
$formatter->format_tree($menu);
|
||||
}
|
||||
else if (class_exists('RokNavMenuFormatter')) {
|
||||
$formatter = new RokNavMenuFormatter();
|
||||
$formatter->format_tree($menu);
|
||||
}
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the basic common formatting to all menu nodes
|
||||
*/
|
||||
protected function formatMenu(&$menu) {
|
||||
|
||||
|
||||
//set the active tree branch
|
||||
$site = new JSite();
|
||||
$joomlamenu = $site->getMenu();
|
||||
$active = $joomlamenu->getActive();
|
||||
if (isset($active) && isset($active->tree) && count($active->tree)) {
|
||||
reset($active->tree);
|
||||
while (list($key, $value) = each($active->tree)) {
|
||||
$active_node =& $active->tree[$key];
|
||||
$active_child =& $menu->findChild($active_node);
|
||||
if ($active_child !== false) {
|
||||
$active_child->addListItemClass('active');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set the current node
|
||||
if (isset($active)) {
|
||||
$current_child =& $menu->findChild($active->id);
|
||||
if ($current_child !== false && !$current_child->menualias) {
|
||||
$current_child->css_id = 'current';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Limit the levels of the tree is called for By limitLevels
|
||||
if ($menu->getParameter('limit_levels')) {
|
||||
$start = $menu->getParameter('startLevel');
|
||||
$end = $menu->getParameter('endLevel');
|
||||
|
||||
//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 (isset($active) && isset($active->tree) && count($active->tree)) {
|
||||
reset($active->tree);
|
||||
while (list($key, $value) = each($active->tree)) {
|
||||
$active_child = $menu->findChild($active->tree[$key]);
|
||||
if ($active_child != null && $active_child !== false) {
|
||||
if ($active_child->level == $start - 1) {
|
||||
$menu->resetTop($active_child->id);
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$menu->_children = array();
|
||||
}
|
||||
}
|
||||
//remove lower then the defined end level
|
||||
$menu->removeLevel($end);
|
||||
}
|
||||
|
||||
// Remove the child nodes that were not needed to display unless showAllChildren is set
|
||||
$showAllChildren = $menu->getParameter('showAllChildren');
|
||||
if (!$showAllChildren) {
|
||||
if ($menu->hasChildren()) {
|
||||
reset($menu->_children);
|
||||
while (list($key, $value) = each($menu->_children)) {
|
||||
$toplevel =& $menu->_children[$key];
|
||||
if (isset($active) && isset($active->tree) && in_array($toplevel->id, $active->tree) !== false) {
|
||||
$last_active =& $menu->findChild($active->tree[count($active->tree) - 1]);
|
||||
if ($last_active !== false) {
|
||||
$toplevel->removeIfNotInTree($active->tree, $last_active->id);
|
||||
//$toplevel->removeLevel($last_active->level+1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$toplevel->removeLevel($toplevel->level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function _getJSVersion() {
|
||||
if (version_compare(JVERSION, '1.5', '>=') && version_compare(JVERSION, '1.6', '<')) {
|
||||
if (JPluginHelper::isEnabled('system', 'mtupgrade')) {
|
||||
return "-mt1.2";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokNavMenu2XRenderer.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 RokNavMenu2XRenderer extends RokMenuDefaultRenderer
|
||||
{
|
||||
public function renderHeader(){
|
||||
parent::renderHeader();
|
||||
$doc = JFactory::getDocument();
|
||||
|
||||
foreach($this->layout->getScriptFiles() as $script){
|
||||
$doc->addScript($script['relative']);
|
||||
}
|
||||
|
||||
foreach($this->layout->getStyleFiles() as $style){
|
||||
$doc->addStyleSheet($style['relative']);
|
||||
}
|
||||
$doc->addScriptDeclaration($this->layout->getInlineScript());
|
||||
$doc->addStyleDeclaration($this->layout->getInlineStyle());
|
||||
}
|
||||
}
|
554
modules/mod_roknavmenu/lib/renderers/RokNavMenuTree.php
Normal file
554
modules/mod_roknavmenu/lib/renderers/RokNavMenuTree.php
Normal file
@ -0,0 +1,554 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokNavMenuTree.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
|
||||
*/
|
||||
// no direct access
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.base.tree');
|
||||
//require_once (dirname(__FILE__).'/RokNavMenuNode.php');
|
||||
|
||||
|
||||
/**
|
||||
* Base Class for menu tree nodes
|
||||
*/
|
||||
|
||||
class RokMenuTreeBase {
|
||||
|
||||
|
||||
/**
|
||||
* Base ID for the menu as ultimate parent
|
||||
*/
|
||||
var $id = 0;
|
||||
var $parent = 0;
|
||||
var $_parentRef = null;
|
||||
var $level = -1;
|
||||
var $access = 2;
|
||||
|
||||
var $_check_access_level = null;
|
||||
|
||||
var $_children = array();
|
||||
|
||||
function __construct($params = null)
|
||||
{
|
||||
$this->_params = &$params;
|
||||
}
|
||||
/**
|
||||
* Menu parameters
|
||||
*/
|
||||
var $_params = null;
|
||||
|
||||
function addChild(&$node) {
|
||||
if (!$node->isAccessable()){
|
||||
return true;
|
||||
}
|
||||
if ( $this->id == $node->parent) {
|
||||
$node->_parentRef = $this;
|
||||
$this->_children[$node->id] = $node;
|
||||
return true;
|
||||
}
|
||||
else if ($this->hasChildren()) {
|
||||
reset($this->_children);
|
||||
while (list($key, $value) = each($this->_children)) {
|
||||
$child =& $this->_children[$key];
|
||||
if ($child->addChild($node)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function hasChildren()
|
||||
{
|
||||
return count($this->_children);
|
||||
}
|
||||
|
||||
function &getChildren()
|
||||
{
|
||||
return $this->_children;
|
||||
}
|
||||
|
||||
function setParameters($params) {
|
||||
$this->_params = is_object($params) ? $params : new JRegistry($params);
|
||||
}
|
||||
|
||||
function getParameter($param) {
|
||||
if (null == $param || null == $this->_params) {
|
||||
return null;
|
||||
}
|
||||
return $this->_params->get($param);
|
||||
}
|
||||
|
||||
function &findChild($node_id) {
|
||||
if (array_key_exists($node_id, $this->_children)) {
|
||||
return $this->_children[$node_id];
|
||||
}
|
||||
else if ($this->hasChildren()) {
|
||||
reset($this->_children);
|
||||
while (list($key, $value) = each($this->_children)) {
|
||||
$child =& $this->_children[$key];
|
||||
$wanted_node = $child->findChild($node_id);
|
||||
if ($wanted_node !== false) {
|
||||
return $wanted_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret = false;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function removeChild($node_id) {
|
||||
if (array_key_exists($node_id, $this->_children)) {
|
||||
unset($this->_children[$node_id]);
|
||||
return true;
|
||||
}
|
||||
else if ($this->hasChildren()) {
|
||||
reset($this->_children);
|
||||
while (list($key, $value) = each($this->_children)) {
|
||||
$child =& $this->_children[$key];
|
||||
$ret = $child->removeChild($node_id);
|
||||
if ($ret === true) {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeLevel($end) {
|
||||
if ( $this->level == $end ) {
|
||||
$this->_children = array();
|
||||
}
|
||||
else if ($this->level < $end) {
|
||||
if ($this->hasChildren()) {
|
||||
reset($this->_children);
|
||||
while (list($key, $value) = each($this->_children)) {
|
||||
$child =& $this->_children[$key];
|
||||
$child->removeLevel($end);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeIfNotInTree(&$active_tree, $last_active) {
|
||||
if (!empty($active_tree)) {
|
||||
|
||||
if (in_array((int)$this->id, $active_tree) && $last_active == $this->id) {
|
||||
// i am the last node in the active tree
|
||||
if ($this->hasChildren()) {
|
||||
reset($this->_children);
|
||||
while (list($key, $value) = each($this->_children)) {
|
||||
$child =& $this->_children[$key];
|
||||
$child->_children = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (in_array((int)$this->id, $active_tree)) {
|
||||
// i am in the active tree but not the last node
|
||||
if ($this->hasChildren()) {
|
||||
reset($this->_children);
|
||||
while (list($key, $value) = each($this->_children)) {
|
||||
$child =& $this->_children[$key];
|
||||
$child->removeIfNotInTree($active_tree, $last_active);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// i am not in the active tree
|
||||
$this->_children = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isAccessable(){
|
||||
$user =JFactory::getUser();
|
||||
$view_levels = $user->getAuthorisedViewLevels();
|
||||
if (null == $this->access ) {
|
||||
return null;
|
||||
}
|
||||
else if (in_array($this->access,$view_levels)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getParent() {
|
||||
return $this->_parentRef;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rok Nav Menu Tree Class.
|
||||
*/
|
||||
class RokNavMenuTree extends RokMenuTreeBase
|
||||
{
|
||||
// const MENUPARAM_MENU_IMAGES = "menu_images";
|
||||
// const MENUPARAM_LIMIT_LEVELS = "limit_levels";
|
||||
// const MENUPARAM_START_LEVEL = "startLevel";
|
||||
// const MENUPARAM_END_LEVEL = "endLevel";
|
||||
// const MENUPARAM_SHOW_ALL_CHILDREN = "showAllChildren";
|
||||
// const MENUPARAM_TAG_ID = "tag_id";
|
||||
// const MENUPARAM_CLASS_SUFFIX = "class_sfx";
|
||||
// const MENUPARAM_MENU_IMAGES_LINK = "menu_images_link";
|
||||
// const MENUPARAM_MAX_DEPTH = "maxdepth";
|
||||
|
||||
|
||||
|
||||
function addNode(&$params, $item)
|
||||
{
|
||||
// Get menu item data
|
||||
|
||||
$node = $this->_getItemData($params, $item);
|
||||
$node->_check_access_level = $params->get('check_access_level',null);
|
||||
if ($node !== false) {
|
||||
return $this->addChild($node);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function resetTop($top_node_id) {
|
||||
$new_top_node = $this->findChild($top_node_id);
|
||||
if ($new_top_node !== false)
|
||||
{
|
||||
$this->id = $new_top_node->id;
|
||||
$this->_children = $new_top_node->getChildren();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function _getSecureUrl($url, $secure) {
|
||||
if ($secure == -1) {
|
||||
$url = str_replace('https://', 'http://', $url);
|
||||
} elseif ($secure == 1) {
|
||||
$url = str_replace('http://', 'https://', $url);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
function _getItemData(&$params, $item)
|
||||
{
|
||||
//Create the new Node
|
||||
$node = new RokNavMenuNode();
|
||||
|
||||
$tmp = null;
|
||||
// Menu Link is a special type that is a link to another item
|
||||
if ($item->type == 'menulink')
|
||||
{
|
||||
$site = new JSite();
|
||||
$menu = $site->getMenu();
|
||||
if ($newItem = $menu->getItem($item->query['Itemid'])) {
|
||||
$tmp = clone($newItem);
|
||||
$tmp->name = addslashes(htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8'));
|
||||
$tmp->mid = $item->id;
|
||||
$tmp->parent = $item->parent;
|
||||
$tmp->params = $item->params;
|
||||
$tmp->url = null;
|
||||
$tmp->nav = 'current';
|
||||
$tmp->menualias = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($item->type != 'menulink' || ($item->type == 'menulink' && $tmp == null)){
|
||||
$tmp = clone($item);
|
||||
$tmp->name = addslashes(htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8'));
|
||||
$tmp->mid = $tmp->id;
|
||||
$tmp->url = null;
|
||||
$tmp->nav = 'current';
|
||||
$tmp->menualias = false;
|
||||
}
|
||||
|
||||
|
||||
$iParams = new JRegistry($tmp->params);
|
||||
|
||||
if ($params->get('menu_images') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
|
||||
$image = JURI::base(true).'/images/stories/'.$iParams->get('menu_image');
|
||||
if($tmp->ionly){
|
||||
$tmp->name = null;
|
||||
}
|
||||
} else {
|
||||
$image = null;
|
||||
}
|
||||
|
||||
|
||||
switch ($tmp->type)
|
||||
{
|
||||
case 'separator':
|
||||
$tmp->outtype = 'separator';
|
||||
break;
|
||||
case 'url':
|
||||
if ((strpos($tmp->link, 'index.php?') === 0) && (strpos($tmp->link, 'Itemid=') === false)) {
|
||||
$tmp->url = $tmp->link.'&Itemid='.$tmp->id;
|
||||
} else {
|
||||
$tmp->url = $tmp->link;
|
||||
}
|
||||
$tmp->outtype = 'menuitem';
|
||||
break;
|
||||
default :
|
||||
$router = JSite::getRouter();
|
||||
$tmp->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$tmp->id : $tmp->link.'&Itemid='.$tmp->id;
|
||||
$tmp->outtype = 'menuitem';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($tmp->url != null)
|
||||
{
|
||||
// set the target based on menu item options
|
||||
switch ($tmp->browserNav)
|
||||
{
|
||||
case 0:
|
||||
$tmp->nav = 'current';
|
||||
break;
|
||||
case 1:
|
||||
$tmp->nav = 'new';
|
||||
break;
|
||||
case 2:
|
||||
$tmp->url = str_replace('index.php', 'index2.php', $tmp->url);
|
||||
$tmp->nav = 'newnotool';
|
||||
break;
|
||||
default:
|
||||
$tmp->nav = 'current';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Get the final URL
|
||||
if ($tmp->home == 1) {// Set Home Links to the Base
|
||||
$tmp->url = str_replace(array($tmp->route.'/', $tmp->route), '', JRoute::_( $tmp->url ));
|
||||
}
|
||||
|
||||
if ($tmp->type != 'separator' && $tmp->type != 'url') {
|
||||
$iSecure = $iParams->get('secure', 0);
|
||||
|
||||
if ($this->_params->get('url_type','relative') == 'full') {
|
||||
$url = JRoute::_($tmp->url, true, $iSecure);
|
||||
$base = (!preg_match("/^http/",$tmp->url))?rtrim(JURI::base(false), '/'):'';
|
||||
$routed = $base.$url;
|
||||
$secure = RokNavMenuTree::_getSecureUrl($routed,$iSecure);
|
||||
$tmp->url =$secure;
|
||||
} else {
|
||||
$tmp->url = JRoute::_($tmp->url, true, $iSecure);
|
||||
}
|
||||
}
|
||||
else if($tmp->type == 'url') {
|
||||
$tmp->url = str_replace('&', '&', $tmp->url);
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$node->id = $tmp->mid;
|
||||
$node->parent = $tmp->parent;
|
||||
$node->title = $tmp->name;
|
||||
$node->access = $tmp->access;
|
||||
$node->link = $tmp->url;
|
||||
$node->level = $item->sublevel;
|
||||
$node->image = $image;
|
||||
$node->alias = $tmp->alias;
|
||||
$node->nav = $tmp->nav;
|
||||
$node->displayType = $tmp->browserNav;
|
||||
|
||||
|
||||
$node->setParameters($tmp->params);
|
||||
$node->type = $tmp->outtype;
|
||||
$node->order = $item->ordering;
|
||||
$node->addListItemClass("item" . $node->id);
|
||||
$node->addSpanClass($tmp->outtype);
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* RokNavMenuNode
|
||||
*/
|
||||
class RokNavMenuNode extends RokMenuTreeBase
|
||||
{
|
||||
// const TYPE_MENU_LINK = "menulink";
|
||||
// const TYPE_SEPARATOR = "separator";
|
||||
// const TYPE_MENU_ITEM = "menuitem";
|
||||
// const TYPE_URL = "url";
|
||||
//
|
||||
// const TARGET_CURRENT = "current";
|
||||
// const TARGET_NEW = "new";
|
||||
// const TARGET_NEW_NO_TOOLBAR = "newnotool";
|
||||
//
|
||||
// const CLASS_PARENT = "parent";
|
||||
// const CLASS_ACTIVE = "active";
|
||||
// const ID_CURRENT = "current";
|
||||
|
||||
|
||||
var $title = null;
|
||||
var $link = null;
|
||||
|
||||
var $image = null;
|
||||
var $alias = null;
|
||||
var $type = null;
|
||||
var $target = null;
|
||||
var $order = null;
|
||||
var $nav = null;
|
||||
var $displayType = null;
|
||||
var $menualias = false;
|
||||
|
||||
|
||||
var $_link_additions = array();
|
||||
var $_link_attribs = array();
|
||||
var $_li_classes = array();
|
||||
var $_a_classes = array();
|
||||
var $_span_classes = array();
|
||||
var $css_id = null;
|
||||
|
||||
|
||||
function hasLink() {
|
||||
return (isset($this->link));
|
||||
}
|
||||
|
||||
function getLink() {
|
||||
$outlink = $this->link;
|
||||
$outlink .= $this->getLinkAdditions(!strpos($this->link, '?'));
|
||||
return $outlink;
|
||||
}
|
||||
|
||||
function addLinkAddition($name ,$value) {
|
||||
$this->_link_additions[$name] = $value;
|
||||
}
|
||||
|
||||
function getLinkAdditions($starting_query = false, $starting_seperator = false){
|
||||
$link_additions = " ";
|
||||
reset($this->_link_additions);
|
||||
$i = 0;
|
||||
while (list($key, $value) = each($this->_link_additions)) {
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function hasLinkAdditions(){
|
||||
return count($this->_link_additions);
|
||||
}
|
||||
|
||||
function addLinkAttrib($name, $value) {
|
||||
$this->_link_attribs[$name] = $value;
|
||||
}
|
||||
|
||||
function getLinkAttribs(){
|
||||
$link_attribs = " ";
|
||||
reset($this->_link_attribs);
|
||||
while (list($key, $value) = each($this->_link_attribs)) {
|
||||
$link_attribs .= $key . "='" .$value . "' ";
|
||||
}
|
||||
return rtrim(ltrim($link_attribs));
|
||||
}
|
||||
|
||||
function hasLinkAttribs(){
|
||||
return count($this->_link_attribs);
|
||||
}
|
||||
|
||||
function getListItemClasses() {
|
||||
$html_classes = " ";
|
||||
reset($this->_li_classes);
|
||||
while (list($key, $value) = each($this->_li_classes)) {
|
||||
$class =& $this->_li_classes[$key];
|
||||
$html_classes .= $class. " ";
|
||||
}
|
||||
return rtrim(ltrim($html_classes));
|
||||
}
|
||||
|
||||
function addListItemClass($class) {
|
||||
$this->_li_classes[] = $class;
|
||||
}
|
||||
|
||||
function hasListItemClasses(){
|
||||
return count($this->_li_classes);
|
||||
}
|
||||
|
||||
|
||||
function getLinkClasses() {
|
||||
$html_classes = " ";
|
||||
reset($this->_a_classes);
|
||||
while (list($key, $value) = each($this->_a_classes)) {
|
||||
$class =& $this->_a_classes[$key];
|
||||
$html_classes .= $class. " ";
|
||||
}
|
||||
return rtrim(ltrim($html_classes));
|
||||
}
|
||||
|
||||
function addLinkClass($class) {
|
||||
$this->_a_classes[] = $class;
|
||||
}
|
||||
|
||||
function hasLinkClasses(){
|
||||
return count($this->_a_classes);
|
||||
}
|
||||
|
||||
function getSpanClasses() {
|
||||
$html_classes = " ";
|
||||
reset($this->_span_classes);
|
||||
while (list($key, $value) = each($this->_span_classes)) {
|
||||
$class =& $this->_span_classes[$key];
|
||||
$html_classes .= $class. " ";
|
||||
}
|
||||
return rtrim(ltrim($html_classes));
|
||||
}
|
||||
|
||||
function addSpanClass($class) {
|
||||
$this->_span_classes[] = $class;
|
||||
}
|
||||
function hasSpanClasses(){
|
||||
return count($this->_span_classes);
|
||||
}
|
||||
|
||||
function addChild(&$node) {
|
||||
if($node->isAccessable()) {
|
||||
|
||||
//$ret = parent::addChild($node);
|
||||
$ret = false;
|
||||
|
||||
if (!$node->isAccessable()){
|
||||
$ret = true;
|
||||
}
|
||||
if ( $this->id == $node->parent) {
|
||||
$node->_parentRef = &$this;
|
||||
$this->_children[$node->id] = $node;
|
||||
$ret = true;
|
||||
}
|
||||
else if ($this->hasChildren()) {
|
||||
reset($this->_children);
|
||||
while (list($key, $value) = each($this->_children)) {
|
||||
$child =& $this->_children[$key];
|
||||
if ($child->addChild($node)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($ret === true) {
|
||||
if (!array_search('parent', $this->_li_classes)) {
|
||||
$this->addListItemClass('parent');
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return true; // item is not accessable so return true to remove from the stack
|
||||
}
|
||||
}
|
||||
|
10
modules/mod_roknavmenu/lib/renderers/includes.php
Normal file
10
modules/mod_roknavmenu/lib/renderers/includes.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?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__) . '/RokNavMenu2XRenderer.php');
|
||||
require_once(dirname(__FILE__) . '/RokNavMenu1XRenderer.php');
|
||||
require_once(dirname(__FILE__) . '/RokNavMenuTree.php');
|
1
modules/mod_roknavmenu/lib/renderers/index.html
Normal file
1
modules/mod_roknavmenu/lib/renderers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
Reference in New Issue
Block a user