News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1203651824:v:use_geshi-1:v:type-php

Started by Guest, Feb 22, 2008, 03:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Guest

function template_create_list_menu($list_menu, $direction = 'top')
{
   global $context, $settings;

   /**
      // This is use if you want your generic lists to have tabs.
      $cur_list['list_menu'] = array(
         // This is the style to use.  Tabs or Buttons (Text 1 | Text 2).
         // By default tabs are selected if not set.
         // The main difference between tabs and buttons is that tabs get highlighted if selected.
         // If style is set to buttons and use tabs is diabled then we change the style to old styled tabs.
         'style' => 'tabs',
         // The posisiton of the tabs/buttons.  Left or Right.  By default is set to left.
         'position' => 'left',
         // This is used by the old styled menu.  We *need* to know the total number of columns to span.
         'columns' => 0,
         // This gives you the option to show tabs only at the top, bottom or both.
         // By default they are just shown at the top.
         'show_on' => 'top',
         // Links.  This is the core of the array.  It has all the info that we need.
         'links' => array(
            'name' => array(
               // This will tell use were to go when they click it.
               'href' => $scripturl . '?action=theaction',
               // The name that you want to appear for the link.
               'label' => $txt['name'],
               // If we use tabs instead of buttons we highlight the current tab.
               // Must use conditions to determine if its selected or not.
               'is_selected' => isset($_REQUEST['name']),
            ),
         ),
      );
   */

   // Are we using right-to-left orientation?
   $first = $context['right_to_left'] ? 'last' : 'first';
   $last = $context['right_to_left'] ? 'first' : 'last';

   // Tabs take preference over buttons in certain cases.
   if (empty($settings['use_tabs']) && $list_menu['style'] == 'button')
      $list_menu['style'] = 'tabs';

   if (!isset($list_menu['style']) || isset($list_menu['style']) && $list_menu['style'] == 'tabs')
   {
      if (!empty($settings['use_tabs']))
      {
         echo '
      <table cellpadding="0" cellspacing="0" border="0" style="margin-', $list_menu['position'], ': 10px; width: 100%;">
         <tr>', $list_menu['position'] == 'right' ? '
            <td>&nbsp;</td>' : '', '
            <td align="', $list_menu['position'], '">
               <table cellspacing="0" cellpadding="0">
                  <tr>
                     <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $first, '">&nbsp;</td>';

         foreach ($list_menu['links'] as $link)
         {
            if ($link['is_selected'])
               echo '
                     <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $first, '">&nbsp;</td>
                     <td valign="top" class="', $direction == 'top' ? 'mirrortab' : 'maintab', '_active_back">
                        <a href="', $link['href'], '">', $link['label'], '</a>
                     </td>
                     <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $last, '">&nbsp;</td>';
            else
               echo '
                     <td valign="top" class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back">
                        <a href="', $link['href'], '">', $link['label'], '</a>
                     </td>';
         }

         echo '
                     <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $last, '">&nbsp;</td>
                  </tr>
               </table>
            </td>', $list_menu['position'] == 'left' ? '
            <td>&nbsp;</td>' : '', '
         </tr>
      </table>';
      }
      else
      {
         echo '
         <tr class="titlebg">
            <td colspan="', $context['colspan'], '">';

         $links = array();
         foreach ($list_menu['links'] as $link)
            $links[] = ($link['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.gif" alt="&gt;" /> ' : '') . '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';

         echo '
            ', implode(' | ', $links), '
            </td>
         </tr>';
      }
   }
   elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons')
   {
      $links = array();
      foreach ($list_menu['links'] as $link)
         $links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';

      echo '
      <table cellpadding="0" cellspacing="0" border="0" style="margin-', $list_menu['position'], ': 10px; width: 100%;">
         <tr>', $list_menu['position'] == 'right' ? '
            <td>&nbsp;</td>' : '', '
            <td align="', $list_menu['position'], '">
               <table cellspacing="0" cellpadding="0">
                  <tr>
                     <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_' , $first , '">&nbsp;</td>
                     <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back">', implode(' &nbsp;|&nbsp; ', $links) , '</td>
                     <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_' , $last , '">&nbsp;</td>
                  </tr>
               </table>
            </td>', $list_menu['position'] == 'left' ? '
            <td>&nbsp;</td>' : '', '
         </tr>
      </table>';
   }
}