[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/t3lib/ -> class.t3lib_topmenubase.php (source)

   1  <?php
   2  /***************************************************************
   3  *  Copyright notice
   4  *
   5  *  (c) 2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6  *  All rights reserved
   7  *
   8  *  This script is part of the TYPO3 project. The TYPO3 project is
   9  *  free software; you can redistribute it and/or modify
  10  *  it under the terms of the GNU General Public License as published by
  11  *  the Free Software Foundation; either version 2 of the License, or
  12  *  (at your option) any later version.
  13  *
  14  *  The GNU General Public License can be found at
  15  *  http://www.gnu.org/copyleft/gpl.html.
  16  *  A copy is found in the textfile GPL.txt and important notices to the license
  17  *  from the author is found in LICENSE.txt distributed with these scripts.
  18  *
  19  *
  20  *  This script is distributed in the hope that it will be useful,
  21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23  *  GNU General Public License for more details.
  24  *
  25  *  This copyright notice MUST APPEAR in all copies of the script!
  26  ***************************************************************/
  27  /**
  28   * Base class for scripts delivering content to the top menu bar/icon panel.
  29   *
  30   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  31   */
  32  /**
  33   * [CLASS/FUNCTION INDEX of SCRIPT]
  34   *
  35   */
  36  
  37  
  38  
  39  
  40  /**
  41   * Base class for scripts delivering content to the top menu bar/icon panel.
  42   *
  43   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  44   * @package TYPO3
  45   * @subpackage core
  46   */
  47  class t3lib_topmenubase {
  48  
  49  	function menuItems($menuItems)    {
  50          $output = '';
  51          
  52              // Traverse items:
  53          foreach($menuItems as $item)    {
  54              
  55                  // Divider has no other options:
  56              if ($item['title']=='--div--')    {
  57                  $output.= '<div class="menuLayerItem_divider" onmouseover="menuOpenSub(this);"></div>';
  58              } else {
  59              
  60                  $itemCode = '';
  61                  $onClick = '';
  62              
  63                      // Render subitems if any:
  64                  if (is_array($item['subitems']))    {
  65                      $itemCode.= $this->menuLayer($item['subitems'],$item['id']);
  66                  }
  67              
  68                      // Render state icon if any:
  69                  switch ($item['state'])    {
  70                      case 'checked';
  71                          $itemCode.= '<img src="gfx/x_state_checked.png" width="16" class="menulayerItemIcon">';
  72                      break;
  73                      default:
  74                      $itemCode.= '<img src="gfx/clear.gif" width="16" class="menulayerItemIcon">';
  75                      break;
  76                  }
  77              
  78                      // Render icon if any:
  79                  if ($item['icon'])    {
  80                      if (is_array($item['icon']))    {
  81                          $itemCode.= '<img '.t3lib_iconWorks::skinImg('',$item['icon'][0],$item['icon'][1]).' class="menulayerItemIcon" alt="" />';
  82                      } else {
  83                          $itemCode.= $item['icon'];
  84                      }
  85                  }
  86              
  87                      // Title:
  88                  $itemCode.= htmlspecialchars($item['title']).'&nbsp;&nbsp;';
  89              
  90                      // if subitems, show arrow pointing right:
  91                  $itemCode.= is_array($item['subitems']) ? '<img src="gfx/x_thereismore.png" class="menulayerItemIcon" style="padding-left:40px;">' : ''; 
  92              
  93                      // Set onclick handlers:
  94                  $onClick.= $item['xurl'] ? "if (Event.element(event)==this){openUrlInWindow('".$item['xurl']."','aWindow');}" : '';
  95                  $onClick.= $item['url'] ? "if (Event.element(event)==this){content.document.location='".$item['url']."';}" : '';
  96                  $onClick.= $item['onclick'] ? $item['onclick'] : $item['onclick'];
  97          
  98                      // Wrap it all up:
  99                  $output.= '<div '.($item['id'] ? 'id="'.htmlspecialchars($item['id']).'"' : '').'class="menuLayerItem" onmouseover="menuOpenSub(this);"'.($onClick ? ' onclick="'.htmlspecialchars($onClick).'"' : '').'>'.$itemCode.'</div>';
 100                  $output.= $item['html'];
 101              }
 102          }
 103  
 104          return $output;
 105      }
 106      /**
 107       *
 108       */
 109  	function menuLayer($menuItems,$baseid='')    {
 110          $output = $this->menuItems($menuItems);
 111              
 112              // Encapsulate in menu layer:
 113          return $this->simpleLayer($output,$baseid?$baseid.'-layer':'');
 114      }
 115      
 116  	function simpleLayer($output,$id='',$class='menulayer')    {
 117          return '<div class="'.$class.'" style="display: none;"'.($id?' id="'.htmlspecialchars($id).'"':'').'>'.$output.'</div>';
 118      }
 119      
 120  	function menuItemLayer($id,$content,$onclick='')    {
 121          return '<div id="'.$id.'" class="menuItems menu-normal" style="float: left;" onclick="menuToggleState(\''.$id.'\');'.$onclick.'" onmouseover="menuMouseOver(\''.$id.'\');" onmouseout="menuMouseOut(\''.$id.'\');">'.$content.'</div>';
 122      }
 123  	function menuItemObject($id,$functionContent)    {
 124          return '
 125          <script>
 126              menuItemObjects[\''.$id.'\'] = {
 127                  '.$functionContent.'
 128              }        
 129          </script>        
 130          ';
 131      }
 132  }
 133  
 134  ?>


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics