Source for file extmenu.php
Documentation is available at extmenu.php
* Zikula Application Framework
* @copyright (c) 2001, Zikula Development Team
* @link http://www.zikula.org
* @version $Id: extmenu.php 24342 2008-06-06 12:03:14Z markwest $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @package Zikula_System_Modules
* @author Frank Schummertz [landseer]
* @author The Zikula Development Team
* get information on block
* @author The Zikula Development Team
* @return array The block information
return array('text_type' => 'Extended Menu',
'text_type_long' => 'Extended Menu block',
'allow_multiple' => true,
'admin_tableless' => true);
* @author The Zikula Development Team
* @param array $blockinfo a blockinfo structure
* @return output the rendered bock
if (!Securityutil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_READ)) {
$pnRender->cache_id = $blockinfo['bid']. ':'. pnUserGetVar('uid');
// Break out options from our content field
if (empty($vars['template'])) {
$vars['template'] = 'blocks_block_extmenu.htm';
if (empty($vars['stylesheet'])) {
$vars['stylesheet'] = 'extmenu.css';
// check out if the contents are cached.
if ($pnRender->is_cached($vars['template'])) {
// Populate block info and pass to theme
$blockinfo['content'] = $pnRender->fetch($vars['template']);
// create default block variables
if (!isset ($vars['blocktitles'])) {
$vars['blocktitles'] = array();
if (!isset ($vars['links'])) {
$vars['links'] = array();
if (!isset ($vars['stylesheet'])) {
$vars['stylesheet'] = '';
if (!isset ($vars['menuid'])) {
// get language and default to eng
// block title: copy the ml blocktitle to the original block title
$blockinfo['title'] = $vars['blocktitles'][$thislang];
if (!empty($vars['links'][$thislang])) {
foreach ($vars['links'][$thislang] as $linkid => $link) {
// check for multiple options in image
if (!empty($vars['displaymodules'])) {
// Separate from current content, if any
if (count($menuitems) > 0) {
$menuitems[] = array('name' => ' ',
$menuitems[] = array('name' => $mod['displayname'],
'title' => $mod['description'],
$menuitems[] = array('name' => $mod['displayname'],
'title' => $mod['description'],
// check for any empty result set
$pnRender->assign('menuitems', $menuitems);
$pnRender->assign('blockinfo', $blockinfo);
$pnRender->assign('currenturi', $currenturi);
$pnRender->assign('access_edit', Securityutil::checkPermission('ExtendedMenublock::', $blockinfo['bid'] . '::', ACCESS_EDIT));
$blockinfo['content'] = $pnRender->fetch($vars['template']);
// add the stylesheet to the header
// pass the block array back to the theme for display
* do a simple check .. to see if the current URL is the menu item
* Prepare a menu item url
* @param url menu item url
// allow a simple portable way to link to the home page of the site
if ($url == '{homepage}') {
} elseif (!empty($url)) {
switch ($url[0]) // Used to allow support for linking to modules with the use of bracket
case '[': // old style module link
$url = pnConfigGetVar('entrypoint', 'index.php') . '?name='. $url[0]. (isset ($url[1]) ? '&file='. $url[1]: '');
case '{': // new module link
// url[0] should be the module name
if (isset ($url[0]) && !empty($url[0])) {
// url[1] can be a function or function¶m=value
if (isset ($url[1]) && !empty($url[1])) {
if (count($urlparts) > 0) {
foreach ($urlparts as $urlpart) {
$params[trim($part[0])] = trim($part[1]);
// addon: url[2] can be the type parameter, default 'user'
$type = (isset ($url[2]) && !empty($url[2])) ? $url[2] : 'user';
$url = pnModURL($modname, $type, $func, $params);
* @author The Zikula Development Team
* @param array $blockinfo a blockinfo structure
* @return output the bock form
// Break out options from our content field
$blockinfo['content'] = '';
if (empty($vars['displaymodules'])) {
$vars['displaymodules'] = 0;
if (empty($vars['template'])) {
$vars['template'] = 'blocks_block_extmenu.htm';
// Create output object - this object will store all of our output so that
// we can return it easily when required
// create default block variables
if (!isset ($vars['blocktitles'])) {
$vars['blocktitles'] = array();
if (!isset ($vars['links'])) {
$vars['links'] = array();
if (!isset ($vars['stylesheet'])) {
$vars['stylesheet'] = '';
if (!isset ($vars['menuid'])) {
// check if the users wants to add a new link via the "Add current url" link in the block
// or if we come from the normal "edit this block" link
// set a marker for redirection later on
foreach($languages as $singlelanguage) {
} elseif (isset ($fromblock)) {
// add new languages to the blocktitles and link arrays
// we need to know which language has the most links, this language will be the "master"
// for new languages to be added. this ensures that all links for the new language
foreach($languages as $lang) {
if(count($link_master) < count($vars['links'][$lang])) {
$link_master = $vars['links'][$lang];
foreach($languages as $lang) {
// create an empty blocktitle string
$vars['blocktitles'][$lang] = '';
$vars['links'][$lang] = $link_master;
// menuitems are sorted by language per default for easier
// access when showing them (which is more often necessary than
// editing them), but for editing them we need them sorted by id
foreach ($vars['links'] as $lang => $langlinks) {
// langlinks now contains an array of links for a certain language
foreach ($langlinks as $linkid => $link) {
$link['errors'] = array();
$menuitems[$linkid][$lang] = $link;
$pnRender->assign($vars);
$pnRender->assign('languages', $languages);
$pnRender->assign('userlanguage', $userlanguage);
$pnRender->assign('redirect', $redirect);
$pnRender->assign('menuitems', $menuitems);
$pnRender->assign('blockinfo', $blockinfo);
return $pnRender->fetch('blocks_block_extmenu_modify.htm');
* @author The Zikula Development Team
* @param array $blockinfo a blockinfo structure
* @return $blockinfo the modified blockinfo structure
if (empty($vars['displaymodules'])) {
$vars['displaymodules'] = 0;
if (empty($vars['template'])) {
$vars['template'] = 'blocks_block_extmenu.htm';
if (empty($vars['stylesheet'])) {
$vars['stylesheet'] = 'extmenu.css';
// fake some data we will implement later
// rebuild the arrays: we need one entry per link
foreach($linkids as $linkid) {
foreach($languages as $lang) {
$linkarray[$lang][] = array('name' => $linkname[$linkid][$lang],
'url' => $linkurl[$linkid][$lang],
'title' => $linktitle[$linkid][$lang],
'image' => $linkimage[$linkid][$lang],
'active' => $linkactive[$linkid][$lang]
$vars['links'] = $linkarray;
$vars['blockversion'] = 1;
$pnRender->clear_all_cache();
if (!empty($link['image'])) {
$link['imagedata'] = false;
|