示例#1
0
 private function _renderMenuItems($pid = 0)
 {
     global $_CONF, $_TABLES, $_USER, $_BLOCK_TEMPLATE;
     foreach ($this->_menuitems as $menuitem) {
         if ($this->_multiLangMode) {
             $label = $this->getMenuLabel($menuitem['id']);
         } else {
             $label = $menuitem['label'];
         }
         $target = $menuitem['type'] == 2 ? 'target=newWindow;' . $this->_targetFeatures : '';
         $menuitemImage = trim($menuitem['image']);
         if ($menuitemImage != '') {
             // Check and see if the full url is entered
             if (strpos($menuitemImage, 'http') === false) {
                 $menuitemImage = $_CONF['site_url'] . '/nexmenu/menuimages/' . $menuitemImage;
             }
         }
         if ($i == $this->_menuitemCount) {
             $lastitem = true;
         } else {
             $lastitem = false;
         }
         // Check and see if this item is a submenu
         if ($menuitem['type'] == 3) {
             // Type Submenu
             $url = str_replace('[siteurl]', $_CONF['site_url'], $menuitem['url']);
             $url = str_replace('[siteadminurl]', $_CONF['site_admin_url'], $url);
             if ($this->_type == 'header') {
                 $menuitemimagecss = 'headermenuitemimage';
             } else {
                 $menuitemimagecss = 'blocksubmenuitemimage';
             }
             $t = new Template($_CONF['path_layout'] . 'nexmenu/procssmenu');
             if ($pid == 0) {
                 if ($this->_type == 'header') {
                     $t->set_file('menu', 'headersubmenu.thtml');
                 } else {
                     $t->set_file('menu', 'submenu.thtml');
                 }
                 $t->set_var('menuitem_url', $url);
                 if ($menuitemImage != '') {
                     $image = '<img src="' . $menuitemImage . '" border="0">&nbsp;';
                     $label = "{$image}<span id=\"{$menuitemimagecss}\">{$label}</span>";
                     $t->set_var('menuitem_label', $label);
                 } else {
                     $t->set_var('menuitem_label', $label);
                 }
                 if ($pid == 0) {
                     $t->set_var('imgclass', 'drop');
                 } else {
                     $t->set_var('imgclass', 'fly');
                 }
                 if ($i == $this->_menuitemCount) {
                     $t->set_var('lastitemclass', 'class="enclose"');
                 }
             } else {
                 $t->set_file('menu', 'flysubmenu.thtml');
                 $t->set_var('menuitem_url', $url);
                 $t->set_var('menuitem_label', $label);
             }
             parent::initMenuItems($menuitem['id']);
             $t->set_var('submenu_items', $this->_renderMenuItems($menuitem['id']));
             $t->parse('output', 'menu');
             $retval .= $t->finish($t->get_var('output'));
         } elseif ($menuitem['type'] == 4) {
             // Core Menu
             switch ($menuitem['url']) {
                 case "adminmenu":
                     if ($_USER['uid'] > 1) {
                         $_BLOCK_TEMPLATE['admin_block'] = 'nexmenu/procssmenu/blank.thtml,nexmenu/procssmenu/blank.thtml';
                         $_BLOCK_TEMPLATE['adminoption'] = 'nexmenu/procssmenu/menuitem.thtml,nexmenu/procssmenu/menuitem_on.thtml';
                         $plugin_options .= PLG_getAdminOptions();
                         $nrows = count($plugin_options);
                         if (SEC_isModerator() or $nrows > 0 or SEC_hasrights('story.edit,block.edit,topic.edit,link.edit,event.edit,poll.edit,user.edit,plugin.edit,user.mail', 'OR')) {
                             $retval .= COM_adminMenu();
                         }
                     }
                     break;
                 case "usermenu":
                     if ($_USER['uid'] > 1) {
                         $_BLOCK_TEMPLATE['user_block'] = 'nexmenu/procssmenu/blank.thtml,nexmenu/procssmenu/blank.thtml';
                         $_BLOCK_TEMPLATE['useroption'] = 'nexmenu/procssmenu/menuitem.thtml,nexmenu/procssmenu/menuitem_on.thtml';
                         $retval .= COM_userMenu();
                     }
                     break;
                 case "topicmenu":
                     $_BLOCK_TEMPLATE['topicoption'] = 'nexmenu/procssmenu/menuitem2.thtml,nexmenu/procssmenu/menuitem2_on.thtml';
                     $retval .= COM_showTopics('', " sortnum < '{$CONF_NEXMENU['restricted_topics']}'");
                     break;
                 case "linksmenu":
                     if ($this->_linksPlugin) {
                         $retval .= nexmenu_showlinks($pid, $this->_type, 'site', $numcategories, 0, $lastitem);
                     }
                     break;
                 case "spmenu":
                     if ($this->_staticpagesPlugin) {
                         if ($CONF_NEXMENU['sp_labelonly']) {
                             $sql = "SELECT sp_id,sp_title,sp_label FROM {$_TABLES['staticpage']} WHERE sp_onmenu=1 ";
                             $sql .= COM_getPermSql('AND');
                             $sql .= 'ORDER BY sp_title';
                             $spquery = DB_query($sql);
                         } else {
                             $sql = "SELECT sp_id,sp_title,sp_label FROM {$_TABLES['staticpage']} ";
                             $sql .= COM_getPermSql('WHERE');
                             $sql .= 'ORDER BY sp_title';
                             $spquery = DB_query($sql);
                         }
                         while (list($id, $title, $sp_label) = DB_fetchArray($spquery)) {
                             if (trim($sp_label) == '') {
                                 $label = $title;
                             } else {
                                 $label = $sp_label;
                             }
                             $url = "{$_CONF['site_url']}/staticpages/index.php?page={$id}";
                             $retval .= "<li><a href=\"{$url}\" {$target}>{$label}</a></li>" . LB;
                         }
                     }
                     break;
                 case "pluginmenu":
                     $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
                     $nrows = DB_numRows($result);
                     $menu = array();
                     for ($i = 1; $i <= $nrows; $i++) {
                         $A = DB_fetchArray($result);
                         $function = 'plugin_getmenuitems_' . $A['pi_name'];
                         if (function_exists($function)) {
                             $menuitems = $function();
                             if (is_array($menuitems) and count($menuitems) > 0) {
                                 foreach ($menuitems as $plugin_label => $plugin_link) {
                                     if ($pid == 0) {
                                         $retval .= "<li class=\"top\"><a class=\"top_link\" href=\"{$plugin_link}\" {$target}><span>{$plugin_label}</span></a></li>" . LB;
                                     } else {
                                         $retval .= "<li><a href=\"{$plugin_link}\" {$target}><span>{$plugin_label}</span></a></li>" . LB;
                                     }
                                 }
                             }
                         }
                     }
                     break;
                 case "headermenu":
                     $t = new Template($_CONF['path_layout'] . 'nexmenu/procssmenu');
                     $t->set_file(array('menu' => 'siteheader_menuitems.thtml', 'menuitem' => 'headermenu_item.thtml', 'menuitem_last' => 'headermenu_item.thtml'));
                     $plugin_menu = PLG_getMenuItems();
                     COM_renderMenu($t, $plugin_menu);
                     $t->parse('output', 'menu');
                     $retval .= $t->finish($t->get_var('output'));
                     break;
             }
             // End of menutype == 4  (Core Menu)
         } elseif ($menuitem['type'] == 5) {
             if (function_exists($menuitem['url'])) {
                 /* Pass the type of menu to custom php function */
                 $retval .= $menuitem['url']($this->_type);
             }
         } else {
             $url = str_replace('[siteurl]', $_CONF['site_url'], $menuitem['url']);
             $url = str_replace('[siteadminurl]', $_CONF['site_admin_url'], $url);
             // what's our current URL?
             $thisUrl = COM_getCurrentURL();
             if ($menuitemImage != '') {
                 if ($this->_type == 'header') {
                     $menuitemimagecss = 'headermenuitemimage';
                 } else {
                     $menuitemimagecss = 'blockmenuitemimage';
                 }
                 $image = '<img src="' . $menuitemImage . '" border="0">&nbsp;';
                 if ($i == 1 and $pid > 0) {
                     $retval .= "<li><a href=\"{$url}\" {$target} class=\"enclose\">{$image}<span id=\"{$menuitemimagecss}\">{$label}</span></a></li>" . LB;
                 } elseif ($i == $menurows and $pid == 0) {
                     $retval .= "<li><a href=\"{$url}\" {$target} class=\"enclose\">{$image}<span id=\"{$menuitemimagecss}\">{$label}</span></a></li>" . LB;
                 } elseif ($url == $thisUrl) {
                     $retval .= "<li id=\"menuitem_current\"><a href=\"{$url}\" {$target}>{$image}<span id=\"{$menuitemimagecss}\">{$label}</span></a></li>" . LB;
                 } else {
                     $retval .= "<li><a href=\"{$url}\" {$target}>{$image}<span id=\"{$menuitemimagecss}\">{$label}</span></a></li>" . LB;
                 }
             } else {
                 if ($pid == 0) {
                     $retval .= "<li class=\"top\"><a class=\"top_link\" href=\"{$url}\" {$target}><span>{$label}</span></a></li>" . LB;
                 } else {
                     $retval .= "<li><a href=\"{$url}\" {$target}><span>{$label}</span></a></li>" . LB;
                 }
             }
         }
         $i++;
     }
     // Restore Template Setting
     $_BLOCK_TEMPLATE = $this->_currentBlockTemplate;
     return $retval;
 }
示例#2
0
 private function _milonicMenuJavascript()
 {
     global $_CONF, $_TABLES, $_USER, $_BLOCK_TEMPLATE;
     $current_BLOCK_TEMPLATE = $_BLOCK_TEMPLATE;
     $pquery = DB_query("SELECT DISTINCT id,location FROM {$_TABLES['nexmenu']} WHERE menutype=3 and is_enabled=1");
     while (list($pid, $location) = DB_fetchArray($pquery)) {
         $retval .= LB . 'with(milonic=new menuname("nexmenu' . $pid . '")) {';
         if ($location == 'block') {
             $retval .= 'style=' . $this->_blockSubmenuStyle . ';';
         } else {
             $retval .= 'style=' . $this->_headerSubmenuStyle . ';';
         }
         $sql = "SELECT id,location, menutype,label,url,image,grp_access FROM {$_TABLES['nexmenu']} ";
         $sql .= "WHERE pid='{$pid}' AND is_enabled=1 ORDER BY menuorder";
         $query = DB_query($sql);
         while (list($id, $location, $menutype, $label, $url, $menuitemImage, $grp_id) = DB_fetchArray($query)) {
             $grp_name = DB_getItem($_TABLES['groups'], "grp_name", "grp_id='{$grp_id}'");
             $target = $menutype == 2 ? 'target=_new;' : '';
             if ($menuitemImage != '') {
                 // Check and see if the full url is entered
                 if (strpos($menuitemImage, 'http') === false) {
                     $menuitemImage = $_CONF['site_url'] . '/nexmenu/menuimages/' . $menuitemImage;
                 }
             }
             if (SEC_inGroup($grp_name)) {
                 $menudata = '';
                 if ($menutype == 3) {
                     if ($menuitemImage != '') {
                         $menudata = 'aI("image=' . $menuitemImage . ';text=' . $label . ';showmenu=nexmenu' . $id . ';");';
                     } else {
                         $menudata = 'aI("text=' . $label . ';showmenu=nexmenu' . $id . ';");';
                     }
                 } elseif ($menutype == 4) {
                     switch ($url) {
                         case "adminmenu":
                             if ($_USER['uid'] > 1) {
                                 $_BLOCK_TEMPLATE['admin_block'] = 'nexmenu/milonicmenu/blockheader-blank.thtml,nexmenu/milonicmenu/blockfooter-blank.thtml';
                                 $_BLOCK_TEMPLATE['adminoption'] = 'nexmenu/milonicmenu/option.thtml,nexmenu/milonicmenu/option_off.thtml';
                                 $menudata = COM_adminMenu();
                             }
                             break;
                         case "usermenu":
                             if ($_USER['uid'] > 1) {
                                 $_BLOCK_TEMPLATE['user_block'] = 'nexmenu/milonicmenu/blockheader-blank.thtml,nexmenu/milonicmenu/blockfooter-blank.thtml';
                                 $_BLOCK_TEMPLATE['useroption'] = 'nexmenu/milonicmenu/option.thtml,nexmenu/milonicmenu/option_off.thtml';
                                 $menudata = COM_userMenu();
                             }
                             break;
                         case "topicmenu":
                             $_BLOCK_TEMPLATE['topicoption'] = 'nexmenu/milonicmenu/option.thtml,nexmenu/milonicmenu/option_off.thtml';
                             $menudata = COM_showTopics('', " sortnum < '50'");
                             break;
                         case "linksmenu":
                             if ($this->_linksPlugin) {
                                 $menudata .= $this->_milonicLinksPluginSiteLinks();
                             }
                             break;
                         case "spmenu":
                             if ($CONF_NEXMENU['sp_labelonly']) {
                                 $spquery = DB_query("SELECT sp_id,sp_title FROM {$_TABLES['staticpage']} WHERE sp_onmenu=1 ORDER BY sp_title");
                             } else {
                                 $spquery = DB_query("SELECT sp_id,sp_title FROM {$_TABLES['staticpage']} ORDER BY sp_title");
                             }
                             while (list($id, $title) = DB_fetchArray($spquery)) {
                                 $menudata .= 'aI("text=' . $title . ';url=' . $_CONF['site_url'] . '/staticpages/index.php?page=' . $id . ';");';
                             }
                             break;
                         case "pluginmenu":
                             $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
                             $nrows = DB_numRows($result);
                             $menu = array();
                             for ($i = 1; $i <= $nrows; $i++) {
                                 $A = DB_fetchArray($result);
                                 $function = 'plugin_getmenuitems_' . $A['pi_name'];
                                 if (function_exists($function)) {
                                     $menuitems = $function();
                                     foreach ($menuitems as $plugin_label => $plugin_link) {
                                         $menudata .= 'aI("text=' . $plugin_label . ';' . $target . 'url=' . $plugin_link . ';");';
                                     }
                                 }
                             }
                             break;
                     }
                     // End of Case
                 } elseif ($menutype == 5) {
                     if (function_exists($url)) {
                         $menudata = $url();
                     }
                 } else {
                     $url = str_replace('[siteurl]', $_CONF['site_url'], $url);
                     $url = str_replace('[siteadminurl]', $_CONF['site_admin_url'], $url);
                     if ($menuitemImage != '') {
                         $menudata = 'aI("image=' . $menuitemImage . ';text=' . $label . ';url=' . $url . ';' . $target . ';");';
                     } else {
                         $menudata = 'aI("text=' . $label . ';url=' . $url . ';' . $target . ';");';
                     }
                 }
                 if ($menudata != '') {
                     $retval .= $menudata;
                 }
             }
         }
         // End of While
         $retval .= '}';
     }
     /* GL MENU API */
     /* Check if any plugins have included a custom Menu function to generate any needed javascript for submenus */
     $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
     $nrows = DB_numRows($result);
     for ($i = 1; $i <= $nrows; $i++) {
         $A = DB_fetchArray($result);
         $function = 'plugin_nexmenuCreateMenus_' . $A['pi_name'];
         if (function_exists($function)) {
             $jscode = $function();
             $retval .= $jscode;
         }
     }
     if ($this->_linksPlugin) {
         $retval .= $this->_milonicSubLinkMenuCode('site');
     }
     $_BLOCK_TEMPLATE = $current_BLOCK_TEMPLATE;
     return $retval;
 }
示例#3
0
/**
* Shows a single Geeklog block
*
* This shows a single block and is typically called from
* COM_showBlocks OR from plugin code
*
* @param        string      $name       Logical name of block (not same as title) -- 'user_block', 'admin_block', 'section_block', 'whats_new_block'.
* @param        string      $help       Help file location
* @param        string      $title      Title shown in block header
* @param        string      $position   Side, 'left', 'right' or empty.
* @see function COM_showBlocks
* @return   string  HTML Formated block
*
*/
function COM_showBlock($name, $help = '', $title = '', $position = '')
{
    global $_CONF, $topic, $_TABLES, $_USER;
    $retval = '';
    if (!isset($_USER['noboxes'])) {
        if (!COM_isAnonUser()) {
            $_USER['noboxes'] = DB_getItem($_TABLES['userindex'], 'noboxes', "uid = {$_USER['uid']}");
        } else {
            $_USER['noboxes'] = 0;
        }
    }
    switch ($name) {
        case 'user_block':
            $retval .= COM_userMenu($help, $title, $position);
            break;
        case 'admin_block':
            $retval .= COM_adminMenu($help, $title, $position);
            break;
        case 'section_block':
            $retval .= COM_startBlock($title, $help, COM_getBlockTemplate($name, 'header', $position)) . COM_showTopics($topic) . COM_endBlock(COM_getBlockTemplate($name, 'footer', $position));
            break;
        case 'whats_new_block':
            if (!$_USER['noboxes']) {
                $retval .= COM_whatsNewBlock($help, $title, $position);
            }
            break;
    }
    return $retval;
}
示例#4
0
         $menudata = 'aI("text=' . $label . ';showmenu=nexmenu' . $id . ';");';
     }
 } elseif ($menutype == 4) {
     switch ($url) {
         case "adminmenu":
             if ($_USER['uid'] > 1) {
                 $_BLOCK_TEMPLATE['admin_block'] = 'nexmenu/milonicmenu/blockheader-blank.thtml,nexmenu/milonicmenu/blockfooter-blank.thtml';
                 $_BLOCK_TEMPLATE['adminoption'] = 'nexmenu/milonicmenu/option.thtml,nexmenu/milonicmenu/option_off.thtml';
                 $menudata = COM_adminMenu();
             }
             break;
         case "usermenu":
             if ($_USER['uid'] > 1) {
                 $_BLOCK_TEMPLATE['user_block'] = 'nexmenu/milonicmenu/blockheader-blank.thtml,nexmenu/milonicmenu/blockfooter-blank.thtml';
                 $_BLOCK_TEMPLATE['useroption'] = 'nexmenu/milonicmenu/option.thtml,nexmenu/milonicmenu/option_off.thtml';
                 $menudata = COM_userMenu();
             }
             break;
         case "topicmenu":
             $_BLOCK_TEMPLATE['topicoption'] = 'nexmenu/milonicmenu/option.thtml,nexmenu/milonicmenu/option_off.thtml';
             $menudata = COM_showTopics('', " sortnum < '50'");
             break;
         case "linksmenu":
             $qcategories = DB_query("SELECT DISTINCT category FROM {$_TABLES['links']}");
             while (list($category) = DB_fetchArray($qcategories)) {
                 if (DB_count($_TABLES['links'], "category", $category) > 0) {
                     $menudata .= 'aI("text=' . $category . ';showmenu=links-' . $category . ';url=' . $_CONF['site_url'] . '/links/index.php?category=' . urlencode($category) . ';");';
                 } else {
                     $menudata .= 'aI("text=' . $category . ';url=' . $_CONF['site_url'] . '/links/index.php?category=' . urlencode($category) . ';");';
                 }
             }