Access Keys not working - Joomla! Forum - community, help and support
hi
im refering
http://docs.joomla.org/adding_access_keys
ive setup admin part works part displays html code doesnt?
but have noticed link above code different 1.5.11
this have, doesnt output access key section?
helpep.php
thanks help
im refering
http://docs.joomla.org/adding_access_keys
ive setup admin part works part displays html code doesnt?
but have noticed link above code different 1.5.11
this have, doesnt output access key section?
helpep.php
code: select all
<?php
/**
* @version $id: helper.php 11799 2009-05-06 02:15:50z ian $
* @package joomla
* @copyright copyright (c) 2005 - 2008 open source matters. rights reserved.
* @license gnu/gpl, see license.php
* joomla! free software. version may have been modified pursuant
* gnu general public license, , distributed includes or
* derivative of works licensed under gnu general public license or
* other free or open source software licenses.
* see copyright.php copyright notices , details.
*/
// no direct access
defined('_jexec') or die('restricted access');
jimport('joomla.base.tree');
jimport('joomla.utilities.simplexml');
/**
* mod_mainmenu helper class
*
* @static
* @package joomla
* @subpackage menus
* @since 1.5
*/
class modmainmenuhelper
{
function buildxml(&$params)
{
$menu = new jmenutree($params);
$items = &jsite::getmenu();
// menu items
$rows = $items->getitems('menutype', $params->get('menutype'));
$maxdepth = $params->get('maxdepth',10);
// build menu tree root down (orphan proof - child might have lower id parent)
$user =& jfactory::getuser();
$ids = array();
$ids[0] = true;
$last = null;
$unresolved = array();
// pop first item until array empty if there item
if ( is_array($rows)) {
while (count($rows) && !is_null($row = array_shift($rows)))
{
if (array_key_exists($row->parent, $ids)) {
$row->ionly = $params->get('menu_images_link');
$menu->addnode($params, $row);
// record loaded parents
$ids[$row->id] = true;
} else {
// no parent yet push item of list
// sam: if key isn't in list , dont _add_ infinite, check unresolved queue
if(!array_key_exists($row->id, $unresolved) || $unresolved[$row->id] < $maxdepth) {
array_push($rows, $row);
// let max $maxdepth passes
// todo: put time check in loop in case close php timeout
if(!isset($unresolved[$row->id])) $unresolved[$row->id] = 1;
else $unresolved[$row->id]++;
}
}
}
}
return $menu->toxml();
}
function &getxml($type, &$params, $decorator)
{
static $xmls;
if (!isset($xmls[$type])) {
$cache =& jfactory::getcache('mod_mainmenu');
$string = $cache->call(array('modmainmenuhelper', 'buildxml'), $params);
$xmls[$type] = $string;
}
// document
$xml = jfactory::getxmlparser('simple');
$xml->loadstring($xmls[$type]);
$doc = &$xml->document;
$menu = &jsite::getmenu();
$active = $menu->getactive();
$start = $params->get('startlevel');
$end = $params->get('endlevel');
$schild = $params->get('showallchildren');
$path = array();
// subtree
if ($start)
{
$found = false;
$root = true;
if(!isset($active)){
$doc = false;
}
else{
$path = $active->tree;
for ($i=0,$n=count($path);$i<$n;$i++)
{
foreach ($doc->children() $child)
{
if ($child->attributes('id') == $path[$i]) {
$doc = &$child->ul[0];
$root = false;
break;
}
}
if ($i == $start-1) {
$found = true;
break;
}
}
if ((!is_a($doc, 'jsimplexmlelement')) || (!$found) || ($root)) {
$doc = false;
}
}
}
if ($doc && is_callable($decorator)) {
$doc->map($decorator, array('end'=>$end, 'children'=>$schild));
}
return $doc;
}
function render(&$params, $callback)
{
switch ( $params->get( 'menu_style', 'list' ) )
{
case 'list_flat' :
// include legacy library file
require_once(dirname(__file__).ds.'legacy.php');
mosshowhfmenu($params, 1);
break;
case 'horiz_flat' :
// include legacy library file
require_once(dirname(__file__).ds.'legacy.php');
mosshowhfmenu($params, 0);
break;
case 'vert_indent' :
// include legacy library file
require_once(dirname(__file__).ds.'legacy.php');
mosshowvimenu($params);
break;
default :
// include new menu class
$xml = modmainmenuhelper::getxml($params->get('menutype'), $params, $callback);
if ($xml) {
$class = $params->get('class_sfx');
$xml->addattribute('class', 'menu'.$class);
if ($tagid = $params->get('tag_id')) {
$xml->addattribute('id', $tagid);
}
$result = jfilteroutput::ampreplace($xml->tostring((bool)$params->get('show_whitespace')));
$result = str_replace(array('<ul/>', '<ul />'), '', $result);
echo $result;
}
break;
}
}
}
/**
* main menu tree class.
*
* @package joomla
* @subpackage menus
* @since 1.5
*/
class jmenutree extends jtree
{
/**
* node/id hash handling node additions tree.
*/
var $_nodehash = array();
/**
* menu parameters
*/
var $_params = null;
/**
* menu parameters
*/
var $_buffer = null;
function __construct(&$params)
{
$this->_params =& $params;
$this->_root = new jmenunode(0, 'root');
$this->_nodehash[0] =& $this->_root;
$this->_current =& $this->_root;
}
function addnode(&$params, $item)
{
// menu item data
$data = $this->_getitemdata($params, $item);
// create node , add it
$node = new jmenunode($item->id, $item->name, $item->access, $data);
if (isset($item->mid)) {
$nid = $item->mid;
} else {
$nid = $item->id;
}
$this->_nodehash[$nid] =& $node;
$this->_current =& $this->_nodehash[$item->parent];
if ($item->type == 'menulink' && !empty($item->query['itemid'])) {
$node->mid = $item->query['itemid'];
}
if ($this->_current) {
$this->addchild($node, true);
} else {
// sanity check
jerror::raiseerror( 500, 'orphan error. not find parent item '.$item->id );
}
}
function toxml()
{
// initialize variables
$this->_current =& $this->_root;
// recurse through children if exist
while ($this->_current->haschildren())
{
$this->_buffer .= '<ul>';
foreach ($this->_current->getchildren() $child)
{
$this->_current = & $child;
$this->_getlevelxml(0);
}
$this->_buffer .= '</ul>';
}
if($this->_buffer == '') { $this->_buffer = '<ul />'; }
return $this->_buffer;
}
function _getlevelxml($depth)
{
$depth++;
// start item
$rel = (!empty($this->_current->mid)) ? ' rel="'.$this->_current->mid.'"' : '';
$this->_buffer .= '<li access="'.$this->_current->access.'" level="'.$depth.'" id="'.$this->_current->id.'"'.$rel.'>';
// append item data
$this->_buffer .= $this->_current->link;
// recurse through item's children if exist
while ($this->_current->haschildren())
{
$this->_buffer .= '<ul>';
foreach ($this->_current->getchildren() $child)
{
$this->_current = & $child;
$this->_getlevelxml($depth);
}
$this->_buffer .= '</ul>';
}
// finish item
$this->_buffer .= '</li>';
}
function _getitemdata(&$params, $item)
{
$data = null;
// menu link special type link item
if ($item->type == 'menulink')
{
$menu = &jsite::getmenu();
if ($newitem = $menu->getitem($item->query['itemid'])) {
$tmp = clone($newitem);
$tmp->name = '<span><![cdata['.$item->name.']]></span>';
$tmp->mid = $item->id;
$tmp->parent = $item->parent;
} else {
return false;
}
} else {
$tmp = clone($item);
$tmp->name = '<span><![cdata['.$item->name.']]></span>';
}
$iparams = new jparameter($tmp->params);
if ($params->get('menu_images') && $iparams->get('menu_image') && $iparams->get('menu_image') != -1) {
switch ($params->get('menu_images_align', 0)){
case 0 :
$imgalign='align="left"';
break;
case 1 :
$imgalign='align="right"';
break;
default :
$imgalign='';
break;
}
$image = '<img src="'.juri::base(true).'/images/stories/'.$iparams->get('menu_image').'" '.$imgalign.' alt="'.$item->alias.'" />';
if($tmp->ionly){
$tmp->name = null;
}
} else {
$image = null;
}
// access key hack - part 1
$accesskey = $iparams->get('accesskey');
$tmp->accesskey = $accesskey;
switch ($tmp->type)
{
case 'separator' :
return '<span class="separator">'.$image.$tmp->name.'</span>';
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;
}
break;
default :
$router = jsite::getrouter();
$tmp->url = $router->getmode() == jrouter_mode_sef ? 'index.php?itemid='.$tmp->id : $tmp->link.'&itemid='.$tmp->id;
break;
}
// print link if exists
if ($tmp->url != null)
{
// handle ssl links
$isecure = $iparams->def('secure', 0);
if ($tmp->home == 1) {
$tmp->url = juri::base();
} elseif (strcasecmp(substr($tmp->url, 0, 4), 'http') && (strpos($tmp->link, 'index.php?') !== false)) {
$tmp->url = jroute::_($tmp->url, true, $isecure);
} else {
$tmp->url = str_replace('&', '&', $tmp->url);
}
switch ($tmp->browsernav)
{
default:
case 0:
// _top
$data = '<a href="'.$tmp->url.'">'.$image.$tmp->name.'</a>';
break;
case 1:
// access key hack - part 2
if ($tmp->accesskey)
$data = '<a href="'.$tmp->url.'" accesskey="'.$tmp->accesskey.'">'.$image.$tmp->name.'</a>';
else
$data = '<a href="'.$tmp->url.'" >'.$image.$tmp->name.'</a>';
// _blank
$data = '<a href="'.$tmp->url.'" target="_blank">'.$image.$tmp->name.'</a>';
break;
case 2:
// window.open
$attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,'.$this->_params->get('window_open');
// hrm...this bit dickey
$link = str_replace('index.php', 'index2.php', $tmp->url);
$data = '<a href="'.$link.'" onclick="window.open(this.href,\'targetwindow\',\''.$attribs.'\');return false;">'.$image.$tmp->name.'</a>';
break;
}
} else {
$data = '<a>'.$image.$tmp->name.'</a>';
}
return $data;
}
}
/**
* main menu tree node class.
*
* @package joomla
* @subpackage menus
* @since 1.5
*/
class jmenunode extends jnode
{
/**
* node title
*/
var $title = null;
/**
* node link
*/
var $link = null;
/**
* css class node
*/
var $class = null;
function __construct($id, $title, $access = null, $link = null, $class = null)
{
$this->id = $id;
$this->title = $title;
$this->access = $access;
$this->link = $link;
$this->class = $class;
}
}
thanks help
Comments
Post a Comment