You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: AbstractJoomlaRokMenuFormatter.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
|
||||
*/
|
||||
abstract class AbstractJoomlaRokMenuFormatter extends AbstractRokMenuFormatter {
|
||||
protected function _format_subnodes(&$node) {
|
||||
parent::_format_subnodes($node);
|
||||
//See if the the roknavmenudisplay plugins want to play
|
||||
JPluginHelper::importPlugin('roknavmenu');
|
||||
$dispatcher =JDispatcher::getInstance();
|
||||
$dispatcher->trigger('onRokNavMenuModifyLink', array (&$node, &$this->args));
|
||||
}
|
||||
}
|
60
modules/mod_roknavmenu/lib/BaseRokNavMenuFormatter.php
Normal file
60
modules/mod_roknavmenu/lib/BaseRokNavMenuFormatter.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: BaseRokNavMenuFormatter.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');
|
||||
|
||||
//require_once (dirname(__FILE__).'/RokNavMenuTree.php');
|
||||
|
||||
/*
|
||||
* Created on Jan 16, 2009
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
class BaseRokNavMenuFormatter {
|
||||
function format_tree(&$nav_menu_tree) {
|
||||
if ($nav_menu_tree->hasChildren()){
|
||||
reset($nav_menu_tree->_children);
|
||||
while (list($key, $value) = each($nav_menu_tree->_children)) {
|
||||
$child_node =& $nav_menu_tree->_children[$key];
|
||||
$menu_params =& $nav_menu_tree->_params;
|
||||
$this->format_subnodes($child_node, $menu_params);
|
||||
}
|
||||
}
|
||||
}
|
||||
function format(&$node,$menu_params){
|
||||
|
||||
}
|
||||
function format_subnodes(&$node, &$menu_params) {
|
||||
|
||||
$this->default_format($node, $menu_params);
|
||||
$this->format($node, $menu_params);
|
||||
if ($node->hasChildren()){
|
||||
reset($node->_children);
|
||||
while (list($key, $value) = each($node->_children)) {
|
||||
$child_node =& $node->_children[$key];
|
||||
$this->format_subnodes($child_node, $menu_params);
|
||||
}
|
||||
}
|
||||
}
|
||||
function default_format(&$node, &$menu_params) {
|
||||
// Set up basic nav for target type
|
||||
if ($node->nav == 'new') {
|
||||
$node->target = "_blank";
|
||||
}
|
||||
else if ($node->nav == 'newnotool'){
|
||||
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,'.$node->getParameter('window_open');
|
||||
$node->onclick = 'window.open(this.href,\'targetWindow\',\''.$attribs.'\');return false;';
|
||||
}
|
||||
|
||||
//See if the the roknavmenudisplay plugins want to play
|
||||
JPluginHelper::importPlugin('roknavmenu');
|
||||
$dispatcher =JDispatcher::getInstance();
|
||||
$dispatcher->trigger('onRokNavMenuModifyLink', array (&$node, &$menu_params));
|
||||
}
|
||||
}
|
23
modules/mod_roknavmenu/lib/BaseRokNavMenuTemplateParams.php
Normal file
23
modules/mod_roknavmenu/lib/BaseRokNavMenuTemplateParams.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: BaseRokNavMenuTemplateParams.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');
|
||||
|
||||
//require_once (dirname(__FILE__).'/RokNavMenuTree.php');
|
||||
|
||||
/*
|
||||
* Created on Jan 16, 2009
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - PHPeclipse - PHP - Code Templates
|
||||
*/
|
||||
class BaseRokNavMenuTemplateParams {
|
||||
function getTemplateParams($basename, $base_control_name, &$params){
|
||||
return "";
|
||||
}
|
||||
}
|
225
modules/mod_roknavmenu/lib/RokNavMenu.php
Normal file
225
modules/mod_roknavmenu/lib/RokNavMenu.php
Normal file
@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokNavMenu.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__) . "/librokmenu/includes.php");
|
||||
require_once(dirname(__FILE__) . "/helper.php");
|
||||
|
||||
if (!class_exists('RokNavMenu'))
|
||||
{
|
||||
class RokNavMenu extends RokMenu
|
||||
{
|
||||
const TOP_LEVEL_PARENT_ID = 1;
|
||||
static $themes = array();
|
||||
static $current_template;
|
||||
static $catalogs_loaded = false;
|
||||
|
||||
public function __construct($args)
|
||||
{
|
||||
self::loadCatalogs();
|
||||
parent::__construct($args);
|
||||
}
|
||||
|
||||
protected function getProvider()
|
||||
{
|
||||
require_once(dirname(__FILE__) . '/providers/RokMenuProviderJoomla16.php');
|
||||
return new RokMenuProviderJoomla16($this->args);
|
||||
}
|
||||
|
||||
protected function getRenderer()
|
||||
{
|
||||
// if its a registered theme its a 2x theme
|
||||
if (array_key_exists('theme', $this->args) && array_key_exists($this->args['theme'], self::$themes))
|
||||
{
|
||||
$themeinfo = self::$themes[$this->args['theme']];
|
||||
$themeclass = $themeinfo['class'];
|
||||
|
||||
$renderer = new RokNavMenu2XRenderer();
|
||||
|
||||
$theme = new $themeclass();
|
||||
$renderer->setTheme($theme);
|
||||
}
|
||||
else
|
||||
{
|
||||
// its a 1x theme
|
||||
$renderer = new RokNavMenu1XRenderer();
|
||||
}
|
||||
return $renderer;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$this->renderHeader();
|
||||
return $this->renderMenu();
|
||||
}
|
||||
|
||||
public static function registerTheme($path, $name, $fullname, $themeClass)
|
||||
{
|
||||
$theme = array('name' => $name, 'fullname' => $fullname, 'path' => $path, 'class' => $themeClass);
|
||||
self::$themes[$name] = $theme;
|
||||
}
|
||||
|
||||
public static function loadCatalogs()
|
||||
{
|
||||
if (!self::$catalogs_loaded) {
|
||||
// load the module themes catalog
|
||||
require_once(JPATH_ROOT . '/modules/mod_roknavmenu/themes/catalog.php');
|
||||
|
||||
foreach (self::getTemplates() as $template) {
|
||||
$template_theme_catalog = JPATH_ROOT . '/templates/' . $template . "/html/mod_roknavmenu/themes/catalog.php";
|
||||
if (JFile::exists($template_theme_catalog)) {
|
||||
//load the templates themes
|
||||
include_once($template_theme_catalog);
|
||||
}
|
||||
}
|
||||
self::$catalogs_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected static function getTemplates()
|
||||
{
|
||||
$Itemid = JFactory::getApplication()->input->getInt('Itemid');
|
||||
$templates = null;
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
if(!is_null($Itemid)){
|
||||
// Load specific style if one is assigned
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('ts.template');
|
||||
$query->from('#__template_styles AS ts');
|
||||
$query->join('INNER','#__menu AS m ON ts.id=m.template_style_id');
|
||||
$query->where('m.id = '.$Itemid);
|
||||
$query->where('m.template_style_id != 0');
|
||||
|
||||
$db->setQuery($query);
|
||||
$templates = $db->loadColumn();
|
||||
}
|
||||
|
||||
if ($templates){
|
||||
return $templates;
|
||||
}
|
||||
|
||||
// Load styles normally if no specific style is assigned
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('template');
|
||||
$query->from('#__template_styles');
|
||||
$query->where('home = 1');
|
||||
$query->where('client_id = 0');
|
||||
|
||||
$db->setQuery($query);
|
||||
$templates = $db->loadColumn();
|
||||
return $templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load published modules
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &loadModules()
|
||||
{
|
||||
static $clean;
|
||||
|
||||
if (isset($clean)) {
|
||||
return $clean;
|
||||
}
|
||||
|
||||
$Itemid = JFactory::getApplication()->input->getInt('Itemid');
|
||||
$app = JFactory::getApplication();
|
||||
$user = JFactory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$lang = JFactory::getLanguage()->getTag();
|
||||
$clientId = (int) $app->getClientId();
|
||||
|
||||
$cache = JFactory::getCache ('com_modules', '');
|
||||
$cacheid = md5(serialize(array($Itemid, $groups, $clientId, $lang)));
|
||||
|
||||
if (!($clean = $cache->get($cacheid))) {
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('id, title, module, position, content, showtitle, params, mm.menuid');
|
||||
$query->from('#__modules AS m');
|
||||
$query->join('LEFT','#__modules_menu AS mm ON mm.moduleid = m.id');
|
||||
$query->where('m.published = 1');
|
||||
|
||||
$date = JFactory::getDate();
|
||||
$now = $date->toSql();
|
||||
$nullDate = $db->getNullDate();
|
||||
$query->where('(m.publish_up = '.$db->Quote($nullDate).' OR m.publish_up <= '.$db->Quote($now).')');
|
||||
$query->where('(m.publish_down = '.$db->Quote($nullDate).' OR m.publish_down >= '.$db->Quote($now).')');
|
||||
|
||||
$query->where('m.access IN ('.$groups.')');
|
||||
$query->where('m.client_id = '. $clientId);
|
||||
$query->where('(mm.menuid = '. (int) $Itemid .' OR mm.menuid <= 0)');
|
||||
|
||||
// Filter by language
|
||||
if ($app->isSite() && $app->getLanguageFilter()) {
|
||||
$query->where('m.language IN (' . $db->Quote($lang) . ',' . $db->Quote('*') . ')');
|
||||
}
|
||||
|
||||
$query->order('position, ordering');
|
||||
|
||||
// Set the query
|
||||
$db->setQuery($query);
|
||||
$modules = $db->loadObjectList();
|
||||
$clean = array();
|
||||
|
||||
if($db->getErrorNum()){
|
||||
JError::raiseWarning(500, JText::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD', $db->getErrorMsg()));
|
||||
return $clean;
|
||||
}
|
||||
|
||||
// Apply negative selections and eliminate duplicates
|
||||
$negId = $Itemid ? -(int)$Itemid : false;
|
||||
$dupes = array();
|
||||
for ($i = 0, $n = count($modules); $i < $n; $i++)
|
||||
{
|
||||
$module = &$modules[$i];
|
||||
|
||||
// The module is excluded if there is an explicit prohibition, or if
|
||||
// the Itemid is missing or zero and the module is in exclude mode.
|
||||
$negHit = ($negId === (int) $module->menuid)
|
||||
|| (!$negId && (int)$module->menuid < 0);
|
||||
|
||||
if (isset($dupes[$module->id]))
|
||||
{
|
||||
// If this item has been excluded, keep the duplicate flag set,
|
||||
// but remove any item from the cleaned array.
|
||||
if ($negHit) {
|
||||
unset($clean[$module->id]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$dupes[$module->id] = true;
|
||||
|
||||
// Only accept modules without explicit exclusions.
|
||||
if (!$negHit)
|
||||
{
|
||||
//determine if this is a custom module
|
||||
$file = $module->module;
|
||||
$custom = substr($file, 0, 4) == 'mod_' ? 0 : 1;
|
||||
$module->user = $custom;
|
||||
// Custom module name is given by the title field, otherwise strip off "com_"
|
||||
$module->name = $custom ? $module->title : substr($file, 4);
|
||||
$module->style = null;
|
||||
$module->position = strtolower($module->position);
|
||||
$clean[$module->id] = $module;
|
||||
}
|
||||
}
|
||||
unset($dupes);
|
||||
// Return to simple indexing that matches the query order.
|
||||
$clean = array_values($clean);
|
||||
|
||||
$cache->store($clean, $cacheid);
|
||||
}
|
||||
|
||||
return $clean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
205
modules/mod_roknavmenu/lib/RokNavMenuEvents.php
Normal file
205
modules/mod_roknavmenu/lib/RokNavMenuEvents.php
Normal file
@ -0,0 +1,205 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokNavMenuEvents.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
|
||||
*/
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.plugin.plugin');
|
||||
jimport('joomla.filesystem.file');
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
/**
|
||||
*/
|
||||
class RokNavMenuEvents extends JPlugin
|
||||
{
|
||||
|
||||
public function onContentPrepareForm($form, $data)
|
||||
{
|
||||
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
if (!$app->isAdmin()) return;
|
||||
|
||||
$option = JFactory::getApplication()->input->get('option');
|
||||
$layout = JFactory::getApplication()->input->get('layout');
|
||||
$task = JFactory::getApplication()->input->get('task');
|
||||
$id = JFactory::getApplication()->input->getInt('id');
|
||||
|
||||
|
||||
$module = $this->getModuleType($data);
|
||||
|
||||
|
||||
if (in_array($option, array('com_modules', 'com_advancedmodules')) && $layout == 'edit' && $module == 'mod_roknavmenu')
|
||||
{
|
||||
|
||||
require_once(JPATH_ROOT . '/modules/mod_roknavmenu/lib/RokNavMenu.php');
|
||||
require_once(JPATH_ROOT . '/modules/mod_roknavmenu/lib/RokSubfieldForm.php');
|
||||
JForm::addFieldPath(JPATH_ROOT . '/modules/mod_roknavmenu/fields');
|
||||
// Load 2x Catalog Themes
|
||||
RokNavMenu::loadCatalogs();
|
||||
// Load 1x Themes
|
||||
$this->registerOldThemes();
|
||||
|
||||
foreach (RokNavMenu::$themes as $theme_name => $theme_info)
|
||||
{
|
||||
$params_file = $theme_info['path'] . "/parameters.xml";
|
||||
if (JFile::exists($params_file))
|
||||
{
|
||||
$form->loadFile($params_file, false);
|
||||
}
|
||||
|
||||
$fields_folder = $theme_info['path'] . "/fields";
|
||||
if (JFolder::exists($fields_folder))
|
||||
{
|
||||
JForm::addFieldPath($fields_folder);
|
||||
}
|
||||
|
||||
$language_path = $theme_info['path'] . "/language";
|
||||
if (JFolder::exists($language_path)){
|
||||
$language =JFactory::getLanguage();
|
||||
$language->load($theme_name ,$theme_info['path'], $language->getTag(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$subfieldform = RokSubfieldForm::getInstanceFromForm($form);
|
||||
|
||||
if (!empty($data) && isset($data->params)) $subfieldform->setOriginalParams($data->params);
|
||||
|
||||
if ($task == 'save' || $task == 'apply')
|
||||
{
|
||||
$subfieldform->makeSubfieldsVisable();
|
||||
}
|
||||
}
|
||||
else if ($option == 'com_menus' && $layout == 'edit'){
|
||||
JForm::addFieldPath(JPATH_ROOT . '/modules/mod_roknavmenu/fields');
|
||||
// Load 2x Catalog Themes
|
||||
require_once(JPATH_ROOT . "/modules/mod_roknavmenu/lib/RokNavMenu.php");
|
||||
RokNavMenu::loadCatalogs();
|
||||
// Load 1x Themes
|
||||
$this->registerOldThemes();
|
||||
foreach (RokNavMenu::$themes as $theme_name => $theme_info)
|
||||
{
|
||||
$item_file = $theme_info['path'] . "/item.xml";
|
||||
if (JFile::exists($item_file))
|
||||
{
|
||||
$form->loadFile($item_file, true);
|
||||
}
|
||||
|
||||
$fields_folder = $theme_info['path'] . "/fields";
|
||||
if (JFolder::exists($fields_folder))
|
||||
{
|
||||
JForm::addFieldPath($fields_folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function registerOldThemes()
|
||||
{
|
||||
$filter = '.';
|
||||
$exclude = array('.svn', 'CVS','.DS_Store','__MACOSX');
|
||||
|
||||
// path to directory
|
||||
$template_themes_path = '/templates/'.$this->_getFrontSideTemplate().'/html/mod_roknavmenu/themes';
|
||||
$template_themes_full_path = JPath::clean(JPATH_ROOT.$template_themes_path);
|
||||
|
||||
$module_themes_path = '/modules/mod_roknavmenu/themes';
|
||||
$module_themes_full_path = JPath::clean(JPATH_ROOT.$module_themes_path);
|
||||
|
||||
|
||||
/** Get the Template Themes parameters **/
|
||||
if (JFolder::exists($template_themes_full_path) && !JFile::exists($template_themes_full_path."/catalog.php")) {
|
||||
$folders = JFolder::folders($template_themes_full_path, $filter);
|
||||
if ( is_array($folders) )
|
||||
{
|
||||
while (list($key, $val) = each($folders)) {
|
||||
$folder =& $folders[$key];
|
||||
if ($exclude)
|
||||
{
|
||||
if (preg_match( chr( 1 ) . $exclude . chr( 1 ), $folder ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$theme_full_path = $template_themes_full_path.'/'.$folder;
|
||||
|
||||
$fullname = 'Template theme - '.$folder;
|
||||
$class = 'RokNavMenuFormatterTemplate'.str_replace('-', '', $folder);
|
||||
$name = $folder;
|
||||
|
||||
RokNavMenu::registerTheme($theme_full_path, $name, $fullname, $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Get the Default Themes parameters **/
|
||||
if (JFolder::exists($module_themes_full_path) && !JFile::exists($module_themes_full_path."/catalog.php")) {
|
||||
$folders = JFolder::folders($module_themes_full_path, $filter);
|
||||
if ( is_array($folders) )
|
||||
{
|
||||
while (list($key, $val) = each($folders)) {
|
||||
$folder =& $folders[$key];
|
||||
if ($exclude)
|
||||
{
|
||||
if (preg_match( chr( 1 ) . $exclude . chr( 1 ), $folder ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$theme_full_path = $module_themes_full_path.'/'.$folder;
|
||||
|
||||
$fullname = 'Template theme - '.$folder;
|
||||
$class = 'RokNavMenuFormatterTemplate'.str_replace('-', '', $folder);
|
||||
$name = $folder;
|
||||
|
||||
RokNavMenu::registerTheme($theme_full_path, $name, $fullname, $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function _getFrontSideTemplate() {
|
||||
if (empty($this->_front_side_template)) {
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
// Get the current default template
|
||||
$query->select('template');
|
||||
$query->from('#__template_styles');
|
||||
$query->where('client_id = 0 AND home = 1');
|
||||
$db->setQuery((string)$query);
|
||||
$defaultemplate = $db->loadResult();
|
||||
$this->_front_side_template = $defaultemplate;
|
||||
}
|
||||
return $this->_front_side_template;
|
||||
}
|
||||
|
||||
|
||||
protected function getModuleType(&$data)
|
||||
{
|
||||
if (is_array($data) && isset($data['module']))
|
||||
{
|
||||
return $data['module'];
|
||||
}
|
||||
elseif (is_array($data) && empty($data))
|
||||
{
|
||||
$form = JRequest::getVar('jform');
|
||||
if (is_array($form) && array_key_exists('module',$form))
|
||||
{
|
||||
return $form['module'];
|
||||
}
|
||||
}
|
||||
if (is_object($data) && method_exists( $data , 'get'))
|
||||
{
|
||||
return $data->get('module');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
182
modules/mod_roknavmenu/lib/RokSubfieldForm.php
Normal file
182
modules/mod_roknavmenu/lib/RokSubfieldForm.php
Normal file
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokSubfieldForm.php 10623 2013-05-23 23:37:15Z steph $
|
||||
* @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(!class_exists('RokSubfieldForm')){
|
||||
class RokSubfieldForm extends JForm
|
||||
{
|
||||
static $instances = array();
|
||||
|
||||
protected $original_params;
|
||||
|
||||
public static function getInstanceFromForm(JForm $form)
|
||||
{
|
||||
if (!array_key_exists($form->getName(), self::$instances))
|
||||
{
|
||||
self::$instances[$form->getName()] = new RokSubfieldForm($form);
|
||||
}
|
||||
self::$instances[$form->getName()]->updateDataParams();
|
||||
return self::$instances[$form->getName()];
|
||||
}
|
||||
|
||||
public function __construct(JForm &$form)
|
||||
{
|
||||
$form_vars = get_object_vars($form);
|
||||
foreach ($form_vars as $form_var_name => $form_var_value)
|
||||
{
|
||||
$this->$form_var_name = $form_var_value;
|
||||
}
|
||||
}
|
||||
|
||||
public function makeSubfieldsVisable(){
|
||||
$subs = $this->xml->xpath('//subfields/fieldset/field');
|
||||
foreach($subs as $sub){
|
||||
$field =& $this->xml->config[0]->fields->fieldset[0]->addChild('field');
|
||||
foreach($sub->attributes() as $aname=>$aval){
|
||||
$field->addAttribute($aname,$aval);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of <field /> elements from the form XML document which are
|
||||
* in a specified fieldset by name.
|
||||
*
|
||||
* @param string $name The name of the fieldset.
|
||||
*
|
||||
* @return mixed Boolean false on error or array of JXMLElement objects.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function & findFieldsBySubFieldset($subtype, $name)
|
||||
{
|
||||
// Initialise variables.
|
||||
$false = false;
|
||||
|
||||
// Make sure there is a valid JForm XML document.
|
||||
$version = new JVersion();
|
||||
if (!($this->xml instanceof SimpleXMLElement) && (version_compare($version->getShortVersion(), '3.0', '>='))) {
|
||||
return false;
|
||||
} elseif (!($this->xml instanceof JXMLElement) && (version_compare($version->getShortVersion(), '3.0', '<'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get an array of <field /> elements that are underneath a <fieldset /> element
|
||||
* with the appropriate name attribute, and also any <field /> elements with
|
||||
* the appropriate fieldset attribute.
|
||||
*/
|
||||
$fields = $this->xml->xpath('//subfields[@name="'.$subtype.'"]/fieldset[@name="'.$name.'"]/field');
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to get an array of JFormField objects in a given fieldset by name. If no name is
|
||||
* given then all fields are returned.
|
||||
*
|
||||
* @param string $set The optional name of the fieldset.
|
||||
*
|
||||
* @return array The array of JFormField objects in the fieldset.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getSubFieldset($subtype, $set, $group="params")
|
||||
{
|
||||
// Initialise variables.
|
||||
$fields = array();
|
||||
|
||||
$elements = $this->findFieldsBySubFieldset($subtype, $set);
|
||||
|
||||
// If no field elements were found return empty.
|
||||
if (empty($elements)) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
// Build the result array from the found field elements.
|
||||
foreach ($elements as $element)
|
||||
{
|
||||
// If the field is successfully loaded add it to the result array.
|
||||
if ($field = $this->loadField($element, $group)) {
|
||||
$fields[$field->id] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function setOriginalParams($original_params)
|
||||
{
|
||||
$this->original_params = $original_params;
|
||||
}
|
||||
|
||||
public function getOriginalParams()
|
||||
{
|
||||
return $this->original_params;
|
||||
}
|
||||
|
||||
public function updateDataParams()
|
||||
{
|
||||
if (isset($this->original_params) && (is_array($this->original_params))){
|
||||
foreach($this->original_params as $param_name => $param_value){
|
||||
$this->data->set('params.'.$param_name, $param_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of fieldset objects optionally filtered over a given field group.
|
||||
*
|
||||
* @param string $group The dot-separated form group path on which to filter the fieldsets.
|
||||
*
|
||||
* @return array The array of fieldset objects.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getSubFieldsets($subfield_type)
|
||||
{
|
||||
// Initialise variables.
|
||||
$fieldsets = array();
|
||||
$sets = array();
|
||||
|
||||
// Make sure there is a valid JForm XML document.
|
||||
$version = new JVersion();
|
||||
if (!($this->xml instanceof SimpleXMLElement) && (version_compare($version->getShortVersion(), '3.0', '>='))) {
|
||||
return $fieldsets;
|
||||
} elseif (!($this->xml instanceof JXMLElement) && (version_compare($version->getShortVersion(), '3.0', '<'))) {
|
||||
return $fieldsets;
|
||||
}
|
||||
|
||||
// Get an array of <fieldset /> elements and fieldset attributes.
|
||||
$sets = $this->xml->xpath('//subfields[@name="'.$subfield_type.'"]/fieldset');
|
||||
|
||||
// If no fieldsets are found return empty.
|
||||
if (empty($sets)) {
|
||||
return $fieldsets;
|
||||
}
|
||||
|
||||
// Process each found fieldset.
|
||||
foreach ($sets as $set)
|
||||
{
|
||||
// Only create it if it doesn't already exist.
|
||||
if (empty($fieldsets[(string) $set['name']])) {
|
||||
|
||||
// Build the fieldset object.
|
||||
$fieldset = (object) array('name' => '', 'label' => '', 'description' => '');
|
||||
foreach ($set->attributes() as $name => $value)
|
||||
{
|
||||
$fieldset->$name = (string) $value;
|
||||
}
|
||||
|
||||
// Add the fieldset object to the list.
|
||||
$fieldsets[$fieldset->name] = $fieldset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $fieldsets;
|
||||
}
|
||||
}
|
||||
}
|
196
modules/mod_roknavmenu/lib/common/RokBrowserCheck.php
Normal file
196
modules/mod_roknavmenu/lib/common/RokBrowserCheck.php
Normal file
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokBrowserCheck.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 (!class_exists('RokBrowserCheck')) {
|
||||
|
||||
class RokBrowserCheck {
|
||||
var $_ua;
|
||||
|
||||
var $name;
|
||||
var $version;
|
||||
var $shortversion;
|
||||
var $platform;
|
||||
var $engine;
|
||||
var $_checks = array();
|
||||
|
||||
function __construct() {
|
||||
$this->_ua = $_SERVER['HTTP_USER_AGENT'];
|
||||
$this->_checkPlatform();
|
||||
$this->_checkBrowser();
|
||||
$this->_checkEngine();
|
||||
|
||||
// add short version
|
||||
if ($this->version != 'unknown') $this->shortversion = substr($this->version, 0, strpos($this->version, '.'));
|
||||
else $this->shortversion = 'unknown';
|
||||
|
||||
$this->_createChecks();
|
||||
}
|
||||
|
||||
function _checkPlatform() {
|
||||
if (preg_match("/iPhone/", $this->_ua) || preg_match("/iPod/", $this->_ua)) {
|
||||
$this->platform = "iphone";
|
||||
}
|
||||
elseif (preg_match("/iPad/", $this->_ua)) {
|
||||
$this->platform = "ipad";
|
||||
}
|
||||
elseif (preg_match("/Android/", $this->_ua)) {
|
||||
$this->platform = "android";
|
||||
}
|
||||
elseif (preg_match("/Mobile/i", $this->_ua)) {
|
||||
$this->platform = "mobile";
|
||||
}
|
||||
elseif (preg_match("/win/i", $this->_ua)) {
|
||||
$this->platform = "win";
|
||||
}
|
||||
elseif (preg_match("/mac/i", $this->_ua)) {
|
||||
$this->platform = "mac";
|
||||
}
|
||||
elseif (preg_match("/linux/i", $this->_ua)) {
|
||||
$this->platform = "linux";
|
||||
} else {
|
||||
$this->platform = "unknown";
|
||||
}
|
||||
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
function _checkEngine() {
|
||||
switch ($this->name) {
|
||||
case 'ie':
|
||||
$this->engine = 'trident';
|
||||
break;
|
||||
case 'firefox':
|
||||
$this->engine = 'gecko';
|
||||
break;
|
||||
case 'android':
|
||||
case 'ipad':
|
||||
case 'iphone':
|
||||
case 'chrome':
|
||||
case 'safari':
|
||||
$this->engine = 'webkit';
|
||||
break;
|
||||
case 'opera':
|
||||
$this->engine = 'presto';
|
||||
break;
|
||||
default:
|
||||
$this->engine = 'unknown';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function _checkBrowser() {
|
||||
// IE
|
||||
if (preg_match('/msie/i', $this->_ua) && !preg_match('/opera/i', $this->_ua)) {
|
||||
$result = explode(' ', stristr(str_replace(';', ' ', $this->_ua), 'msie'));
|
||||
$this->name = 'ie';
|
||||
$this->version = $result[1];
|
||||
}
|
||||
// Firefox
|
||||
elseif (preg_match('/Firefox/', $this->_ua)) {
|
||||
$result = explode('/', stristr($this->_ua, 'Firefox'));
|
||||
$version = explode(' ', $result[1]);
|
||||
$this->name = 'firefox';
|
||||
$this->version = $version[0];
|
||||
}
|
||||
// Chrome
|
||||
elseif (preg_match('/Chrome/', $this->_ua)) {
|
||||
$result = explode('/', stristr($this->_ua, 'Chrome'));
|
||||
$version = explode(' ', $result[1]);
|
||||
$this->name = 'chrome';
|
||||
$this->version = $version[0];
|
||||
}
|
||||
//Safari
|
||||
elseif (preg_match('/Safari/', $this->_ua) && !preg_match('/iPhone/', $this->_ua) && !preg_match('/iPod/', $this->_ua) && !preg_match('/iPad/', $this->_ua)) {
|
||||
$result = explode('/', stristr($this->_ua, 'Version'));
|
||||
$this->name = 'safari';
|
||||
if (isset ($result[1])) {
|
||||
$version = explode(' ', $result[1]);
|
||||
$this->version = $version[0];
|
||||
} else {
|
||||
$this->version = 'unknown';
|
||||
}
|
||||
}
|
||||
// Opera
|
||||
elseif (preg_match('/opera/i', $this->_ua)) {
|
||||
$result = stristr($this->_ua, 'opera');
|
||||
|
||||
if (preg_match('/\//', $result)) {
|
||||
$result = explode('/', $result);
|
||||
$version = explode(' ', $result[1]);
|
||||
$this->name = 'opera';
|
||||
$this->version = $version[0];
|
||||
} else {
|
||||
$version = explode(' ', stristr($result, 'opera'));
|
||||
$this->name = 'opera';
|
||||
$this->version = $version[1];
|
||||
}
|
||||
}
|
||||
// iPhone/iPod
|
||||
elseif (preg_match('/iPhone/', $this->_ua) || preg_match('/iPod/', $this->_ua)) {
|
||||
$result = explode('/', stristr($this->_ua, 'Version'));
|
||||
$this->name = 'iphone';
|
||||
if (isset ($result[1])) {
|
||||
$version = explode(' ', $result[1]);
|
||||
$this->version = $version[0];
|
||||
} else {
|
||||
$this->version = 'unknown';
|
||||
}
|
||||
}
|
||||
// iPad
|
||||
elseif (preg_match('/iPad/', $this->_ua)) {
|
||||
$result = explode('/', stristr($this->_ua, 'Version'));
|
||||
$this->name = 'ipad';
|
||||
if (isset ($result[1])) {
|
||||
$version = explode(' ', $result[1]);
|
||||
$this->version = $version[0];
|
||||
} else {
|
||||
$this->version = 'unknown';
|
||||
}
|
||||
}
|
||||
// Android
|
||||
elseif (preg_match('/Android/', $this->_ua)) {
|
||||
$result = explode('/', stristr($this->_ua, 'Version'));
|
||||
$this->name = 'android';
|
||||
if (isset ($result[1])) {
|
||||
$version = explode(' ', $result[1]);
|
||||
$this->version = $version[0];
|
||||
} else {
|
||||
$this->version = "unknown";
|
||||
}
|
||||
} else {
|
||||
$this->name = "unknown";
|
||||
$this->version = "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
function _createChecks() {
|
||||
$this->_checks = array(
|
||||
$this->name, // browser check
|
||||
$this->platform, // platform check
|
||||
$this->engine, // render engine
|
||||
$this->name . '-' . $this->platform, // browser + platform check
|
||||
$this->name . $this->shortversion, // short browser version check
|
||||
$this->name . $this->version, // longbrowser version check
|
||||
$this->name . $this->shortversion . '-' . $this->platform, // short browser version + platform check
|
||||
$this->name . $this->version . '-' . $this->platform // longbrowser version + platform check
|
||||
);
|
||||
}
|
||||
|
||||
function getChecks($file, $keep_path = false) {
|
||||
$checkfiles = array();
|
||||
$ext = substr($file, strrpos($file, '.'));
|
||||
$path = ($keep_path) ? dirname($file) . '/' : '';
|
||||
$filename = basename($file, $ext);
|
||||
$checkfiles[] = $path . $filename . $ext;
|
||||
foreach ($this->_checks as $suffix) {
|
||||
$checkfiles[] = $path . $filename . '-' . $suffix . $ext;
|
||||
}
|
||||
return $checkfiles;
|
||||
}
|
||||
}
|
||||
}
|
9
modules/mod_roknavmenu/lib/common/includes.php
Normal file
9
modules/mod_roknavmenu/lib/common/includes.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?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__) . '/RokBrowserCheck.php');
|
1
modules/mod_roknavmenu/lib/common/index.html
Normal file
1
modules/mod_roknavmenu/lib/common/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
33
modules/mod_roknavmenu/lib/helper.php
Normal file
33
modules/mod_roknavmenu/lib/helper.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: helper.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');
|
||||
|
||||
|
||||
/**
|
||||
* mod_roknavmenu Helper class
|
||||
*
|
||||
* @static
|
||||
* @package Joomla
|
||||
* @subpackage Menus
|
||||
* @since 1.5
|
||||
*/
|
||||
class modRokNavMenuHelper
|
||||
{
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
}
|
13
modules/mod_roknavmenu/lib/includes.php
Normal file
13
modules/mod_roknavmenu/lib/includes.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?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__) . '/common/includes.php');
|
||||
require_once(dirname(__FILE__) . '/librokmenu/includes.php');
|
||||
require_once(dirname(__FILE__) . '/providers/includes.php');
|
||||
require_once(dirname(__FILE__) . '/renderers/includes.php');
|
||||
require_once(dirname(__FILE__) . '/RokNavMenu.php');
|
||||
require_once(dirname(__FILE__) . '/AbstractJoomlaRokMenuFormatter.php');
|
1
modules/mod_roknavmenu/lib/index.html
Normal file
1
modules/mod_roknavmenu/lib/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -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>
|
1
modules/mod_roknavmenu/lib/parameters/index.html
Normal file
1
modules/mod_roknavmenu/lib/parameters/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
51
modules/mod_roknavmenu/lib/parameters/templateinclude.php
Normal file
51
modules/mod_roknavmenu/lib/parameters/templateinclude.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: templateinclude.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
|
||||
*/
|
||||
defined('_JEXEC') or die();
|
||||
require_once (dirname(__FILE__).'/../BaseRokNavMenuTemplateParams.php');
|
||||
|
||||
class JElementTemplateInclude extends JElement
|
||||
{
|
||||
function fetchElement($name, $value, &$node, $control_name)
|
||||
{
|
||||
global $mainframe;
|
||||
$html = "";
|
||||
$values = array();
|
||||
|
||||
// get the current from side tem
|
||||
|
||||
//Run the template formatter if its there if not run the default formatter
|
||||
$tPath = JPATH_ROOT.'/templates/'.$this->_getFrontSideTemplate().'/html/mod_roknavmenu/parameters.php';
|
||||
if (file_exists($tPath)) {
|
||||
|
||||
// get all the params for the module
|
||||
$all_params = $this->_parent;
|
||||
require_once ($tPath);
|
||||
$template_params = new RokNavMenuTemplateParams();
|
||||
$html .= $template_params->getTemplateParams($name, $control_name, $all_params);
|
||||
}
|
||||
|
||||
if (strlen($html) == 0) {
|
||||
$html = JText::_("ROKNAVMENU.MSG.NO_TEMPLATE_CONFIG");
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function _getFrontSideTemplate() {
|
||||
$db =JFactory::getDBO();
|
||||
// Get the current default template
|
||||
$query = ' SELECT template '
|
||||
.' FROM #__template_styles '
|
||||
.' WHERE client_id = 0 '
|
||||
.' AND home = 1 ';
|
||||
$db->setQuery($query);
|
||||
$defaultemplate = $db->loadResult();
|
||||
return $defaultemplate;
|
||||
}
|
||||
|
||||
}
|
||||
|
161
modules/mod_roknavmenu/lib/parameters/themelist.php
Normal file
161
modules/mod_roknavmenu/lib/parameters/themelist.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: themelist.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
|
||||
*/
|
||||
// Check to ensure this file is within the rest of the framework
|
||||
defined('JPATH_BASE') or die();
|
||||
|
||||
/**
|
||||
* Renders a file list from a directory in the current templates directory
|
||||
*/
|
||||
|
||||
class JElementThemelist extends JElement
|
||||
{
|
||||
/**
|
||||
* Element name
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
var $_name = 'TemplateFilelist';
|
||||
|
||||
var $_front_side_template;
|
||||
|
||||
function fetchElement($name, $value, &$node, $control_name)
|
||||
{
|
||||
jimport( 'joomla.filesystem.folder' );
|
||||
jimport( 'joomla.filesystem.file' );
|
||||
|
||||
$filter = $node->attributes('filter');
|
||||
$exclude = $node->attributes('exclude');
|
||||
|
||||
$options = array ();
|
||||
|
||||
|
||||
// Load 2x Catalog Themes
|
||||
require_once(dirname(__FILE__) . "/../RokNavMenu.php");
|
||||
RokNavMenu::setFrontSideTemplate();
|
||||
RokNavMenu::loadCatalogs();
|
||||
|
||||
|
||||
|
||||
foreach(RokNavMenu::$themes as $theme_name => $theme_info){
|
||||
$options[] = JHtml::_('select.option', $theme_name, $theme_info['fullname']);
|
||||
}
|
||||
|
||||
// path to directory
|
||||
$template_themes_path = '/templates/'.$this->_getFrontSideTemplate().'/html/mod_roknavmenu/themes';
|
||||
$template_themes_full_path = JPath::clean(JPATH_ROOT.$template_themes_path);
|
||||
$template_theme_text = JText::_("Template theme");
|
||||
|
||||
$module_themes_path = '/modules/mod_roknavmenu/themes';
|
||||
$module_themes_full_path = JPath::clean(JPATH_ROOT.$module_themes_path);
|
||||
$module_theme_text = JText::_("Default theme");
|
||||
|
||||
/**
|
||||
* check for old school formatter and layout
|
||||
*/
|
||||
if ($this->_getOldFormatter() || $this->_getOldLayout()) {
|
||||
return JText::sprintf("ROKNAVMENU.MSG.USING_OLD_FORMATTERS_AND_LAYOUTS", ($this->_getOldFormatter())? '<br/>'.$this->_getOldFormatter():'', ($this->_getOldLayout())?'<br/>'.$this->_getOldLayout():'');
|
||||
}
|
||||
|
||||
if (!$node->attributes('hide_none'))
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '-1', '- '.JText::_('Do not use').' -');
|
||||
}
|
||||
|
||||
if (!$node->attributes('hide_default'))
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '', '- '.JText::_('Use default').' -');
|
||||
}
|
||||
|
||||
/** Get the Template Themes **/
|
||||
if (JFolder::exists($template_themes_full_path) && !JFile::exists($template_themes_full_path."/catalog.php") ) {
|
||||
$folders = JFolder::folders($template_themes_full_path, $filter);
|
||||
if ( is_array($folders) )
|
||||
{
|
||||
reset($folders);
|
||||
while (list($key, $val) = each($folders)) {
|
||||
$folder =& $folders[$key];
|
||||
if ($exclude)
|
||||
{
|
||||
if (preg_match( chr( 1 ) . $exclude . chr( 1 ), $folder ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$options[] = JHtml::_('select.option', $template_themes_path.'/'.$folder, $template_theme_text." - ".$folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Get the Default Themes **/
|
||||
if (JFolder::exists($module_themes_full_path) && !JFile::exists($module_themes_full_path."/catalog.php")) {
|
||||
$folders = JFolder::folders($module_themes_full_path, $filter);
|
||||
if ( is_array($folders) )
|
||||
{
|
||||
reset($folders);
|
||||
while (list($key, $val) = each($folders)) {
|
||||
$folder =& $folders[$key];
|
||||
if ($exclude)
|
||||
{
|
||||
if (preg_match( chr( 1 ) . $exclude . chr( 1 ), $folder ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$options[] = JHtml::_('select.option', $module_themes_path.'/'.$folder, $module_theme_text. " - ". $folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
return JHtml::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'value', 'text', $value, "param$name");
|
||||
|
||||
}
|
||||
|
||||
function _getFrontSideTemplate() {
|
||||
if (empty($this->_front_side_template)) {
|
||||
$db =JFactory::getDBO();
|
||||
// Get the current default template
|
||||
$query = ' SELECT template '
|
||||
.' FROM #__template_styles '
|
||||
.' WHERE client_id = 0 '
|
||||
.' AND home = 1 ';
|
||||
$db->setQuery($query);
|
||||
$defaultemplate = $db->loadResult();
|
||||
$this->_front_side_template = $defaultemplate;
|
||||
}
|
||||
return $this->_front_side_template;
|
||||
}
|
||||
|
||||
function _getOldFormatter() {
|
||||
$paths = array(
|
||||
JPath::clean('/templates/'.$this->_getFrontSideTemplate().'/html/mod_roknavmenu/formatters/default.php'),
|
||||
JPath::clean('/templates/'.$this->_getFrontSideTemplate().'/html/mod_roknavmenu/formatter.php'),
|
||||
JPath::clean('/modules/mod_roknavmenu/formatters/default.php')
|
||||
);
|
||||
|
||||
for ($i = 0; $i < count($paths); $i++){
|
||||
if (JFile::exists(JPATH_ROOT.$paths[$i])){
|
||||
return $paths[$i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function _getOldLayout() {
|
||||
$paths = array(
|
||||
JPath::clean('/templates/'.$this->_getFrontSideTemplate().'/html/mod_roknavmenu/layouts/default.php'),
|
||||
JPath::clean('/templates/'.$this->_getFrontSideTemplate().'/html/mod_roknavmenu/default.php'),
|
||||
JPath::clean('/modules/mod_roknavmenu/tmpl/default.php')
|
||||
);
|
||||
|
||||
for ($i = 0; $i < count($paths); $i++){
|
||||
if (JFile::exists(JPATH_ROOT.$paths[$i])){
|
||||
return $paths[$i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
194
modules/mod_roknavmenu/lib/parameters/themeparameters.php
Normal file
194
modules/mod_roknavmenu/lib/parameters/themeparameters.php
Normal file
@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: themeparameters.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
|
||||
*/
|
||||
// Check to ensure this file is within the rest of the framework
|
||||
defined('JPATH_BASE') or die();
|
||||
|
||||
/**
|
||||
* Renders a file list from a directory in the current templates directory
|
||||
*/
|
||||
|
||||
class JElementThemeParameters extends JElement
|
||||
{
|
||||
/**
|
||||
* Element name
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
var $_name = 'TemplateFilelist';
|
||||
|
||||
var $_front_side_template;
|
||||
|
||||
function fetchElement($name, $value, &$node, $control_name)
|
||||
{
|
||||
jimport( 'joomla.filesystem.folder' );
|
||||
jimport( 'joomla.filesystem.file' );
|
||||
$doc =JFactory::getDocument();
|
||||
$lang = JFactory::getLanguage();
|
||||
|
||||
$parameter_sets = array();
|
||||
|
||||
$filter = $node->attributes('filter');
|
||||
$exclude = $node->attributes('exclude');
|
||||
|
||||
|
||||
// Load 2x Catalog Themes
|
||||
require_once(dirname(__FILE__) . "/../RokNavMenu.php");
|
||||
RokNavMenu::setFrontSideTemplate();
|
||||
RokNavMenu::loadCatalogs();
|
||||
|
||||
|
||||
|
||||
foreach(RokNavMenu::$themes as $theme_name => $theme_info){
|
||||
$lang_file_path = JPath::clean($theme_info['path'].'/language/'.$lang->_lang.'.ini');
|
||||
$this->loadLangFile($lang_file_path, $theme_info['fullname']);
|
||||
|
||||
$parms_file_path = JPath::clean($theme_info['path'].'/parameters.xml');
|
||||
if (JFile::exists($parms_file_path)) {
|
||||
$parameters = new JForm( $this->_parent->_raw, JPath::clean($parms_file_path));
|
||||
$parameter_sets[$theme_name] = $parameters->getParams();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// path to directory
|
||||
$template_themes_path = '/templates/'.$this->_getFrontSideTemplate().'/html/mod_roknavmenu/themes';
|
||||
$template_themes_full_path = JPath::clean(JPATH_ROOT.$template_themes_path);
|
||||
$template_theme_text = JText::_("Template theme");
|
||||
|
||||
$module_themes_path = '/modules/mod_roknavmenu/themes';
|
||||
$module_themes_full_path = JPath::clean(JPATH_ROOT.$module_themes_path);
|
||||
$module_theme_text = JText::_("Default theme");
|
||||
|
||||
$module_js_path = JURI::root(true).'/modules/mod_roknavmenu/lib/js';
|
||||
$doc->addScript($module_js_path."/switcher".$this->_getJSVersion().".js");
|
||||
$doc->addScriptDeclaration("window.addEvent('domready', function() {new NavMenuSwitcher('paramtheme');});");
|
||||
|
||||
|
||||
/** Get the Template Themes parameters **/
|
||||
if (JFolder::exists($template_themes_full_path) && !JFile::exists($template_themes_full_path."/catalog.php")) {
|
||||
$folders = JFolder::folders($template_themes_full_path, $filter);
|
||||
if ( is_array($folders) )
|
||||
{
|
||||
reset($folders);
|
||||
while (list($key, $val) = each($folders)) {
|
||||
$folder =& $folders[$key];
|
||||
if ($exclude)
|
||||
{
|
||||
if (preg_match( chr( 1 ) . $exclude . chr( 1 ), $folder ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$theme_path = $template_themes_path.'/'.$folder;
|
||||
|
||||
$langfile = JPath::clean(JPATH_ROOT.$theme_path.'/language/'.$lang->_lang.'.ini');
|
||||
if (JFile::exists($langfile)) {
|
||||
$lang->_load($langfile,'roknavmenu_theme_template_'.$folder);
|
||||
}
|
||||
|
||||
$param_file_path = $theme_path.'/parameters.xml';
|
||||
if (JFile::exists(JPath::clean(JPATH_ROOT.$param_file_path))) {
|
||||
|
||||
$parameters = new JForm( $this->_parent->_raw, JPath::clean(JPATH_ROOT.$param_file_path));
|
||||
$parameter_sets[$theme_path] = $parameters->getParams();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Get the Default Themes parameters **/
|
||||
if (JFolder::exists($module_themes_full_path) && !JFile::exists($module_themes_full_path."/catalog.php")) {
|
||||
$folders = JFolder::folders($module_themes_full_path, $filter);
|
||||
if ( is_array($folders) )
|
||||
{
|
||||
reset($folders);
|
||||
while (list($key, $val) = each($folders)) {
|
||||
$folder =& $folders[$key];
|
||||
if ($exclude)
|
||||
{
|
||||
if (preg_match( chr( 1 ) . $exclude . chr( 1 ), $folder ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$theme_path = $module_themes_path.'/'.$folder;
|
||||
|
||||
$langfile = JPath::clean(JPATH_ROOT.$theme_path.'/language/'.$lang->_lang.'.ini');
|
||||
if (JFile::exists($langfile)) {
|
||||
$lang->_load($langfile,'roknavmenu_theme_module_'.$folder);
|
||||
}
|
||||
|
||||
$param_file_path = $theme_path.'/parameters.xml';
|
||||
|
||||
$parameter_sets[$theme_path] = array();
|
||||
if (JFile::exists(JPath::clean(JPATH_ROOT.$param_file_path))) {
|
||||
$parameters = new JForm( $this->_parent->_raw, JPath::clean(JPATH_ROOT.$param_file_path));
|
||||
$parameter_sets[$theme_path] = $parameters->getParams();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$parameter_renders = array();
|
||||
reset($parameter_sets);
|
||||
|
||||
$html = '';
|
||||
// render a parameter set
|
||||
while(list($key, $val) = each($parameter_sets)) {
|
||||
$params =& $parameter_sets[$key];
|
||||
$cls = basename($key);
|
||||
if (empty($params)){
|
||||
$html .= '<p class="'.$cls.'"><span>' . JText::_('ROKNAVMENU.MSG.NO_THEME_OPTIONS_AVAILABLE') . ' </span></p>';
|
||||
}
|
||||
else {
|
||||
//render an individual parameter
|
||||
for ($i=0; $i < count($params); $i++) {
|
||||
$param =& $params[$i];
|
||||
$html .= '<p class="'.$cls.'"><span>'.$param[0].':</span>' .$param[1] . '</p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function loadLangFile($langfile, $info){
|
||||
$lang = JFactory::getLanguage();
|
||||
if (JFile::exists($langfile)) {
|
||||
$lang->_load($langfile,$info);
|
||||
}
|
||||
}
|
||||
|
||||
function _getFrontSideTemplate() {
|
||||
if (empty($this->_front_side_template)) {
|
||||
$db =JFactory::getDBO();
|
||||
// Get the current default template
|
||||
$query = ' SELECT template '
|
||||
.' FROM #__template_styles '
|
||||
.' WHERE client_id = 0 '
|
||||
.' AND home = 1 ';
|
||||
$db->setQuery($query);
|
||||
$defaultemplate = $db->loadResult();
|
||||
$this->_front_side_template = $defaultemplate;
|
||||
}
|
||||
return $this->_front_side_template;
|
||||
}
|
||||
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
}
|
128
modules/mod_roknavmenu/lib/providers/JoomlaRokMenuNode.php
Normal file
128
modules/mod_roknavmenu/lib/providers/JoomlaRokMenuNode.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: JoomlaRokMenuNode.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 (!class_exists('JoomlaRokMenuNode')) {
|
||||
class JoomlaRokMenuNode extends RokMenuNode {
|
||||
protected $image;
|
||||
protected $alias = false;
|
||||
protected $access = 0;
|
||||
protected $params = '';
|
||||
protected $type = 'menuitem';
|
||||
protected $menuId = null;
|
||||
|
||||
/**
|
||||
* Gets the image
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getImage() {
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image
|
||||
* @access public
|
||||
* @param string $image
|
||||
*/
|
||||
public function setImage($image) {
|
||||
$this->image = $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasImage(){
|
||||
return isset($this->image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the alias
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function isAlias() {
|
||||
return $this->alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alias
|
||||
* @access public
|
||||
* @param boolean $alias
|
||||
*/
|
||||
public function setAlias($alias) {
|
||||
$this->alias = $alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the access
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getAccess() {
|
||||
return $this->access;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the access
|
||||
* @access public
|
||||
* @param string $access
|
||||
*/
|
||||
public function setAccess($access) {
|
||||
$this->access = $access;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the params
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getParams() {
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the params
|
||||
* @access public
|
||||
* @param string $params
|
||||
*/
|
||||
public function setParams($params) {
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type
|
||||
* @access public
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType($type) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $menuId
|
||||
*/
|
||||
public function setMenuId($menuId){
|
||||
$this->menuId = $menuId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getMenuId(){
|
||||
return $this->menuId;
|
||||
}
|
||||
}
|
||||
}
|
159
modules/mod_roknavmenu/lib/providers/RokMenuProviderJoomla.php
Normal file
159
modules/mod_roknavmenu/lib/providers/RokMenuProviderJoomla.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuProviderJoomla.php 8586 2013-03-20 14:15:35Z steph $
|
||||
* @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__) . '/JoomlaRokMenuNode.php');
|
||||
if (!class_exists('RokMenuProviderJoomla')) {
|
||||
class RokMenuProviderJoomla extends AbstractRokMenuProvider {
|
||||
|
||||
protected function getMenuItems() {
|
||||
//Cache this basd on access level
|
||||
$conf =JFactory::getConfig();
|
||||
if ($conf->get('caching') && $this->args["cache"]) {
|
||||
$user =JFactory::getUser();
|
||||
$cache =JFactory::getCache('mod_roknavmenu');
|
||||
$cache->setCaching(true);
|
||||
$args = array($this->args);
|
||||
$checksum = md5(implode(',',$this->args));
|
||||
$menuitems = $cache->get(array($this, 'getFullMenuItems'), $args, 'mod_roknavmenu-'.$user->get('aid', 0).'-'.$checksum);
|
||||
}
|
||||
else {
|
||||
$menuitems = $this->getFullMenuItems($this->args);
|
||||
}
|
||||
|
||||
$site = new JSite();
|
||||
$jmenu = $site->getMenu();
|
||||
$active = $jmenu->getActive();
|
||||
|
||||
|
||||
if (is_object($active)){
|
||||
if (array_key_exists($active->id, $menuitems)){
|
||||
$this->current_node = $active->id;
|
||||
}
|
||||
}
|
||||
|
||||
$this->populateActiveBranch($menuitems);
|
||||
|
||||
return $menuitems;
|
||||
}
|
||||
|
||||
public function getFullMenuItems($args){
|
||||
$site = new JSite();
|
||||
$menu = $site->getMenu();
|
||||
// Get Menu Items
|
||||
$rows = $menu->getItems('menutype', $args['menutype']);
|
||||
|
||||
$outputNodes = array();
|
||||
if(is_array($rows) && count($rows) > 0){
|
||||
foreach ($rows as $item) {
|
||||
//Create the new Node
|
||||
$node = new JoomlaRokMenuNode();
|
||||
|
||||
$node->setId($item->id);
|
||||
$node->setParent($item->parent);
|
||||
$node->setTitle(addslashes(htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8')));
|
||||
$node->setParams($item->params);
|
||||
$node->setLink($item->link);
|
||||
|
||||
// Menu Link is a special type that is a link to another item
|
||||
if ($item->type == 'menulink' && $newItem = $menu->getItem($item->query['Itemid'])) {
|
||||
$node->setAlias(true);
|
||||
$node->setLink($newItem->link);
|
||||
}
|
||||
|
||||
// Get the icon image associated with the item
|
||||
$iParams = (is_object($item->params)) ? $item->params : new JRegisry($item->params);
|
||||
if ($args['menu_images'] && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
|
||||
$node->setImage(JURI::base(true) . '/images/stories/' . $iParams->get('menu_image'));
|
||||
if ($args['menu_images_link']) {
|
||||
$node->setLink(null);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($item->type)
|
||||
{
|
||||
case 'separator':
|
||||
$node->setType('separator');
|
||||
break;
|
||||
case 'url':
|
||||
if ((strpos($node->getLink(), 'index.php?') === 0) && (strpos($node->getLink(), 'Itemid=') === false)) {
|
||||
$node->setLink($node->getLink() . '&Itemid=' . $node->getId());
|
||||
}
|
||||
$node->setType('menuitem');
|
||||
break;
|
||||
default :
|
||||
$router = JSite::getRouter();
|
||||
if ($node->isAlias() && $newItem){
|
||||
$menu_id = $item->query['Itemid'];
|
||||
}
|
||||
else {
|
||||
$menu_id = $node->getId();
|
||||
}
|
||||
$link = ($router->getMode() == JROUTER_MODE_SEF)? 'index.php?Itemid=' . $menu_id : $node->getLink() . '&Itemid=' . $menu_id;
|
||||
$node->setLink($link);
|
||||
$node->setType('menuitem');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($node->getLink() != null) {
|
||||
// set the target based on menu item options
|
||||
switch ($item->browserNav)
|
||||
{
|
||||
case 1:
|
||||
$node->setTarget('_blank');
|
||||
break;
|
||||
case 2:
|
||||
//$node->setLink(str_replace('index.php', 'index2.php', $node->getLink()));
|
||||
//$node->setTarget('newnotool');
|
||||
$value = addslashes(htmlspecialchars("window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false;", ENT_QUOTES, 'UTF-8'));
|
||||
$node->addLinkAttrib('onclick', $value);
|
||||
break;
|
||||
default:
|
||||
//$node->setTarget('current');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Get the final URL
|
||||
if ($item->home == 1) { // Set Home Links to the Base
|
||||
$node->setLink(JURI::base());
|
||||
}
|
||||
|
||||
if ($item->type != 'separator' && $item->type != 'url') {
|
||||
$iSecure = $iParams->get('secure', 0);
|
||||
if (array_key_exists('url_type',$args) && $args['url_type'] == 'full') {
|
||||
$url = JRoute::_($node->getLink(), true, $iSecure);
|
||||
$base = (!preg_match("/^http/", $node->getLink())) ? rtrim(JURI::base(false).'/') : '';
|
||||
$routed = $base . $url;
|
||||
$secure = RokNavMenuTree::_getSecureUrl($routed, $iSecure);
|
||||
$node->setLink($secure);
|
||||
} else {
|
||||
$node->setLink(JRoute::_($node->getLink(), true, $iSecure));
|
||||
}
|
||||
}
|
||||
else if ($item->type == 'url') {
|
||||
$node->setLink(str_replace('&', '&', $node->getLink()));
|
||||
}
|
||||
}
|
||||
|
||||
$node->addListItemClass("item" . $node->getId());
|
||||
$node->setAccess($item->access);
|
||||
$node->addSpanClass($node->getType());
|
||||
|
||||
$user =JFactory::getUser();
|
||||
|
||||
|
||||
if (($node->getAccess() <= $user->get('aid', 0))||((isset($args['check_access_level'][0]) && $args['check_access_level'][0]==1))){
|
||||
// Add node to output list
|
||||
$outputNodes[$node->getId()] = $node;
|
||||
}
|
||||
}
|
||||
return $outputNodes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
314
modules/mod_roknavmenu/lib/providers/RokMenuProviderJoomla16.php
Normal file
314
modules/mod_roknavmenu/lib/providers/RokMenuProviderJoomla16.php
Normal file
@ -0,0 +1,314 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: RokMenuProviderJoomla16.php 9104 2013-04-04 02:26:54Z steph $
|
||||
* @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__) . '/JoomlaRokMenuNode.php');
|
||||
|
||||
if (!class_exists('RokMenuProviderJoomla16')) {
|
||||
|
||||
|
||||
class RokMenuProviderJoomla16 extends AbstractRokMenuProvider
|
||||
{
|
||||
|
||||
const ROOT_ID = 1;
|
||||
|
||||
protected function getMenuItems()
|
||||
{
|
||||
//Cache this basd on access level
|
||||
$conf = JFactory::getConfig();
|
||||
if ($conf->get('caching') && $this->args["cache"]) {
|
||||
$user = JFactory::getUser();
|
||||
$cache = JFactory::getCache('mod_roknavmenu');
|
||||
$cache->setCaching(true);
|
||||
$args = array($this->args);
|
||||
$checksum = md5(implode(',', $this->args));
|
||||
$menuitems = $cache->get(array(
|
||||
$this, 'getFullMenuItems'
|
||||
), $args, 'mod_roknavmenu-' . $user->get('aid', 0) . '-' . $checksum);
|
||||
} else {
|
||||
$menuitems = $this->getFullMenuItems($this->args);
|
||||
}
|
||||
|
||||
|
||||
/* Set the active to the current run since its not saved with the cache */
|
||||
$app = JFactory::getApplication();
|
||||
$jmenu = $app->getMenu();
|
||||
$active = $jmenu->getActive();
|
||||
|
||||
if (is_object($active)) {
|
||||
if (array_key_exists($active->id, $menuitems)) {
|
||||
$this->current_node = $active->id;
|
||||
}
|
||||
}
|
||||
|
||||
$this->populateActiveBranch($menuitems);
|
||||
return $menuitems;
|
||||
}
|
||||
|
||||
public function getFullMenuItems($args)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
|
||||
$attributes = array('menutype');
|
||||
$values = array($args['menutype']);
|
||||
|
||||
//public level menu items
|
||||
if (isset($args['check_access_level']) && $args['check_access_level']==0) {
|
||||
$attributes[] = 'access';
|
||||
$values[] = array(1);
|
||||
}
|
||||
|
||||
//registered level menu items
|
||||
elseif (isset($args['check_access_level']) && $args['check_access_level']==1) {
|
||||
$attributes[] = 'access';
|
||||
$values[] = array(1,2);
|
||||
}
|
||||
|
||||
//user level menu items
|
||||
else {
|
||||
$attributes[] = 'access';
|
||||
$values[] = JFactory::getUser()->getAuthorisedViewLevels();
|
||||
}
|
||||
|
||||
// Get Menu Items
|
||||
$rows = $menu->getItems($attributes, $values);
|
||||
|
||||
$outputNodes = array();
|
||||
|
||||
if (is_array($rows) && count($rows) > 0) {
|
||||
foreach ($rows as $item) {
|
||||
//Create the new Node
|
||||
$node = new JoomlaRokMenuNode();
|
||||
|
||||
$node->setId($item->id);
|
||||
$node->setParent($item->parent_id);
|
||||
$node->setTitle(addslashes(htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8')));
|
||||
$node->setParams($item->params);
|
||||
$node->setLink($item->link);
|
||||
|
||||
// Menu Link is a special type that is a link to another item
|
||||
if ($item->type == 'alias' && $newItem = $menu->getItem($item->params->get('aliasoptions'))) {
|
||||
$node->setAlias(true);
|
||||
$node->setLink($newItem->link);
|
||||
}
|
||||
|
||||
// Get the icon image associated with the item
|
||||
$iParams = (is_object($item->params)) ? $item->params : new JRegisry($item->params);
|
||||
if ($args['menu_images'] && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
|
||||
$node->setImage(JURI::base(true) . '/images/stories/' . $iParams->get('menu_image'));
|
||||
if ($args['menu_images_link']) {
|
||||
$node->setLink(null);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($item->type) {
|
||||
case 'separator':
|
||||
$node->setType('separator');
|
||||
break;
|
||||
case 'url':
|
||||
if ((strpos($node->getLink(), 'index.php?') === 0) && (strpos($node->getLink(), 'Itemid=') === false)) {
|
||||
$node->setLink($node->getLink() . '&Itemid=' . $node->getId());
|
||||
} elseif (!empty($item->link) && ($item->link != null)) {
|
||||
$node->setLink($item->link);
|
||||
}
|
||||
$node->setType('menuitem');
|
||||
break;
|
||||
default :
|
||||
$router = JSite::getRouter();
|
||||
if ($node->isAlias() && $newItem) {
|
||||
$menu_id = $item->params->get('aliasoptions');
|
||||
$node->setMenuId($menu_id);
|
||||
//for aliased items formatter.php doesn't cover
|
||||
if ($node->getMenuId() == $this->current_node) {
|
||||
//taken back out because it caused all the aliased menu items on RT demos to highlight
|
||||
//$node->addListItemClass('active');
|
||||
//$node->setCssId('current');
|
||||
}
|
||||
} else {
|
||||
$menu_id = $node->getId();
|
||||
$node->setMenuId($menu_id);
|
||||
}
|
||||
$link = ($router->getMode() == JROUTER_MODE_SEF) ? 'index.php?Itemid=' . $menu_id : $node->getLink() . '&Itemid=' . $menu_id;
|
||||
$node->setLink($link);
|
||||
$node->setType('menuitem');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($node->getLink() != null) {
|
||||
// set the target based on menu item options
|
||||
switch ($item->browserNav) {
|
||||
case 1:
|
||||
$node->setTarget('_blank');
|
||||
break;
|
||||
case 2:
|
||||
//$node->setLink(str_replace('index.php', 'index2.php', $node->getLink()));
|
||||
//$node->setTarget('newnotool');
|
||||
$value = addslashes(htmlspecialchars("window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false;", ENT_QUOTES, 'UTF-8'));
|
||||
$node->addLinkAttrib('onclick', $value);
|
||||
break;
|
||||
default:
|
||||
//$node->setTarget('current');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Get the final URL
|
||||
if ($item->home == 1) { // Set Home Links to the Base
|
||||
//removed because it breaks SEF extensions
|
||||
//$node->setLink(JRoute::_(JURI::base()));
|
||||
}
|
||||
|
||||
if ($item->type != 'separator' && $item->type != 'url') {
|
||||
$iSecure = $iParams->get('secure', 0);
|
||||
if (array_key_exists('url_type', $args) && $args['url_type'] == 'full') {
|
||||
$url = JRoute::_($node->getLink(), true, $iSecure);
|
||||
$base = (!preg_match("/^http/", $node->getLink())) ? rtrim(JURI::base(false) . '/') : '';
|
||||
$routed = $base . $url;
|
||||
$secure = RokNavMenuTree::_getSecureUrl($routed, $iSecure);
|
||||
$node->setLink($secure);
|
||||
} else {
|
||||
$node->setLink(JRoute::_($node->getLink(), true, $iSecure));
|
||||
}
|
||||
} else if ($item->type == 'url') {
|
||||
$node->setLink(str_replace('&', '&', $node->getLink()));
|
||||
}
|
||||
}
|
||||
$node->addListItemClass("item" . $node->getId());
|
||||
$node->setAccess($item->access);
|
||||
$node->addSpanClass($node->getType());
|
||||
|
||||
// Add node to output list
|
||||
$outputNodes[$node->getId()] = $node;
|
||||
}
|
||||
}
|
||||
return $outputNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $nodeList
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function populateActiveBranch($nodeList)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return RokMenuNodeTree
|
||||
*/
|
||||
public function getRealMenuTree()
|
||||
{
|
||||
$menuitems = $this->getFullMenuItems($this->args);
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$jmenu = $app->getMenu();
|
||||
$active = $jmenu->getActive();
|
||||
if (is_object($active)) {
|
||||
if (array_key_exists($active->id, $menuitems)) {
|
||||
$this->current_node = $active->id;
|
||||
}
|
||||
}
|
||||
//$this->populateActiveBranch($menuitems);
|
||||
|
||||
$menu = $this->createJoomlaMenuTree($menuitems, $this->args['maxdepth']);
|
||||
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the menu item nodes and puts them into a tree structure
|
||||
*
|
||||
* @param $nodes
|
||||
* @param $maxdepth
|
||||
*
|
||||
* @return bool|RokMenuNodeTree
|
||||
*/
|
||||
protected function createJoomlaMenuTree(&$nodes, $maxdepth)
|
||||
{
|
||||
$menu = new RokMenuNodeTree(self::ROOT_ID);
|
||||
// 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 (!$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()]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $menu;
|
||||
}
|
||||
|
||||
public function getMenuTree()
|
||||
{
|
||||
if (null == $this->menu) {
|
||||
//Cache this basd on access level
|
||||
$conf = JFactory::getConfig();
|
||||
if ($conf->get('caching',0) && isset($this->args["module_cache"]) && $this->args["module_cache"]) {
|
||||
$user = JFactory::getUser();
|
||||
$cache = JFactory::getCache('mod_roknavmenu');
|
||||
$cache->setCaching(true);
|
||||
$args = array($this->args);
|
||||
$checksum = md5(implode(',', $this->args));
|
||||
$this->menu = $cache->get(array(
|
||||
$this, 'getRealMenuTree'
|
||||
), $args, 'mod_roknavmenu-' . $user->get('aid', 0) . '-' . $checksum);
|
||||
} else {
|
||||
$this->menu = $this->getRealMenuTree();
|
||||
}
|
||||
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$jmenu = $app->getMenu();
|
||||
$active = $jmenu->getActive();
|
||||
if (is_object($active)) {
|
||||
if ($this->menu->findNode($active->id)) {
|
||||
$this->current_node = $active->id;
|
||||
}
|
||||
}
|
||||
$this->active_branch = $this->findActiveBranch($this->menu, $this->current_node);
|
||||
}
|
||||
return $this->menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current active based on the current_node
|
||||
*
|
||||
* @param RokMenuNodeTree $menu
|
||||
* @param $active_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function findActiveBranch(RokMenuNodeTree $menu, $active_id)
|
||||
{
|
||||
$active_branch = array();
|
||||
/** @var $current JoomlaRokMenuNode */
|
||||
$current = $menu->findNode($active_id);
|
||||
if ($current) {
|
||||
do {
|
||||
$active_branch[$current->getId()] = $current;
|
||||
if ($current->getParent() == self::ROOT_ID) break;
|
||||
} while ($current = $current->getParentRef());
|
||||
$active_branch = array_reverse($active_branch, true);
|
||||
}
|
||||
return $active_branch;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
10
modules/mod_roknavmenu/lib/providers/includes.php
Normal file
10
modules/mod_roknavmenu/lib/providers/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__) . '/JoomlaRokMenuNode.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuProviderJoomla.php');
|
||||
require_once(dirname(__FILE__) . '/RokMenuProviderJoomla16.php');
|
1
modules/mod_roknavmenu/lib/providers/index.html
Normal file
1
modules/mod_roknavmenu/lib/providers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
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