Summary | Array operation on non-array throws warnings - fix available |
Queue | Horde Base |
Queue Version | Git master |
Type | Bug |
State | Resolved |
Priority | 1. Low |
Owners | mrubinsk (at) horde (dot) org |
Requester | torben (at) dannhauer (dot) info |
Created | 02/16/2017 (3075 days ago) |
Due | |
Updated | 02/25/2017 (3066 days ago) |
Assigned | 02/25/2017 (3066 days ago) |
Resolved | 02/25/2017 (3066 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | Yes |
State ⇒ Resolved
items are rendered. I've added the ability back to specify a specific
"container" for custom items and have updated the instructions on the
menu.php.dist files to reflect this. Note that these currently only
work in traditional view, not dynamic view.
State ⇒ Assigned
some Horde 5 refactoring...
The menu items are displayed, but the separator is not displayed.
commit a3f3b09028a91e2cb6e98196497eb3c1b01f6462
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date: Fri Feb 24 12:28:50 2017 -0500
Bug: 14581Allow a string containing 'separator' to be passed as well.framework/Core/lib/Horde/Menu.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
http://github.com/horde/horde/commit/a3f3b09028a91e2cb6e98196497eb3c1b01f6462
the method in question to accept either an array or a string
containing the value "separator".
Thanks,
Torben
way seperators are defined, or we allow arrays and strings and need to
adapt the code down the road to accept it.
What is your recommended solution?
Thanks,
Torben
State ⇒ Assigned
Assigned to Michael Rubinsky
the phpdoc of the method that is called to add the menu entry requires
a string. I guess it makes the most sense to allow an array or a
string containing 'separator' seeing how these instructions are out in
the wild...
I'm on the road, will post the content later.
Thanks,
Torben
<?php
/*
* This file lets you extend Wicked's menu with your own items.
*
* To add a new menu item, simply add a new entry to the $_menu array.
* Valid attributes for a new menu item are:
*
* 'url' The URL value for the menu item.
* 'text' The text to accompany the menu item.
*
* These attributes are optional:
*
* 'icon' The filename of an icon to use for the menu item.
* 'icon_path' The path to the icon if it doesn't exist in the graphics/
* directory.
* 'target' The "target" of the link (e.g. '_top', '_blank').
* 'onclick' Any JavaScript to execute on the "onclick" event.
*
* Here's an example entry:
*
* $_menu[] = array(
* 'url' => 'http://www.example.com/',
* 'text' => 'Example, Inc.',
* 'icon' => 'example.gif',
* 'icon_path' => 'http://www.example.com/images/',
* 'target' => '_blank',
* 'onclick' => ''
* );
*
* You can also add a "separator" (a spacer) between menu items. To add a
* separator, simply add a new string to the $_menu array set to the text
* 'separator'. It should look like this:
*
* $_menu[] = 'separator';
*/
$_menu = array();
/* Add your custom entries below this line. */
$_menu[] = 'separator';
$_menu[] = array(
'url' => '<URL1>',
'text' => 'Desc 1',
'icon' => '',
'icon_path' => '',
'target' => '',
'onclick' => ''
);
$_menu[] = array(
'url' => '<URL 2>',
'text' => 'Desc 2',
'icon' => '',
'icon_path' => '',
'target' => '',
'onclick' => ''
);
$_menu[] = array(
'url' => '<URL 3>',
'text' => 'Desc 3',
'icon' => '',
'icon_path' => '',
'target' => '',
'onclick' => ''
);
I'm on the road, will post the content later.
Thanks,
Torben
State ⇒ Feedback
Considering the phpdoc for the method indicates that $item IS an
array, we need to find out where this is being called from with an
invalid parameter and fix it there.
Priority ⇒ 1. Low
State ⇒ Unconfirmed
Patch ⇒ Yes
Milestone ⇒
Summary ⇒ Array operation on non-array throws warnings - fix available
Type ⇒ Bug
Queue ⇒ Horde Base
/home/torben/horde/framework/Core/lib/Horde/Menu.php : line 71
performs array operations on (potential non-arrays). This throws
warnings caused in multiple lines of the functions and pollutes the
error log.
The suggest solution is to convert $item to an array before working
with array operations on it.
The function should be like this:
-----
/**
* Add an item to the menu array.
*
* @param array $item The item to add. Valid keys:
* <pre>
* 'class' - (string) CSS classname.
* 'icon' - (string) Filename of the image icon.
* 'icon_path' - (string) Non-default directory path for icon.
* 'onclick' - (string) Onclick javascript.
* 'target' - (string) HREF target parameter.
* 'text' - (string) Label.
* 'url' - (string) Hyperlink.
* </pre>
*
* @return integer The id (NOT guaranteed to be an array index) of the
* item just added to the menu.
*/
public function addArray($item)
{
$item = array($item);
if (!isset($item['url'])) {
$item['url'] = new Horde_Url();
} elseif (!($item['url'] instanceof Horde_Url)) {
$item['url'] = new Horde_Url($item['url']);
}
$this->_menu[] = array_merge(array(
'class' => null,
'icon' => '',
'icon_path' => null,
'onclick' => null,
'target' => '',
'text' => ''
), $item);
}