Documentation TYPO3 par Ameos

class.t3lib_topmenubase.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00047 class t3lib_topmenubase {
00048 
00049         function menuItems($menuItems)  {
00050                 $output = '';
00051                 
00052                         // Traverse items:
00053                 foreach($menuItems as $item)    {
00054                         
00055                                 // Divider has no other options:
00056                         if ($item['title']=='--div--')  {
00057                                 $output.= '<div class="menuLayerItem_divider" onmouseover="menuOpenSub(this);"></div>';
00058                         } else {
00059                         
00060                                 $itemCode = '';
00061                                 $onClick = '';
00062                         
00063                                         // Render subitems if any:
00064                                 if (is_array($item['subitems']))        {
00065                                         $itemCode.= $this->menuLayer($item['subitems'],$item['id']);
00066                                 }
00067                         
00068                                         // Render state icon if any:
00069                                 switch ($item['state']) {
00070                                         case 'checked';
00071                                                 $itemCode.= '<img src="gfx/x_state_checked.png" width="16" class="menulayerItemIcon">';
00072                                         break;
00073                                         default:
00074                                         $itemCode.= '<img src="gfx/clear.gif" width="16" class="menulayerItemIcon">';
00075                                         break;
00076                                 }
00077                         
00078                                         // Render icon if any:
00079                                 if ($item['icon'])      {
00080                                         if (is_array($item['icon']))    {
00081                                                 $itemCode.= '<img '.t3lib_iconWorks::skinImg('',$item['icon'][0],$item['icon'][1]).' class="menulayerItemIcon" alt="" />';
00082                                         } else {
00083                                                 $itemCode.= $item['icon'];
00084                                         }
00085                                 }
00086                         
00087                                         // Title:
00088                                 $itemCode.= htmlspecialchars($item['title']).'&nbsp;&nbsp;';
00089                         
00090                                         // if subitems, show arrow pointing right:
00091                                 $itemCode.= is_array($item['subitems']) ? '<img src="gfx/x_thereismore.png" class="menulayerItemIcon" style="padding-left:40px;">' : ''; 
00092                         
00093                                         // Set onclick handlers:
00094                                 $onClick.= $item['xurl'] ? "if (Event.element(event)==this){openUrlInWindow('".$item['xurl']."','aWindow');}" : '';
00095                                 $onClick.= $item['url'] ? "if (Event.element(event)==this){content.document.location='".$item['url']."';}" : '';
00096                                 $onClick.= $item['onclick'] ? $item['onclick'] : $item['onclick'];
00097                 
00098                                         // Wrap it all up:
00099                                 $output.= '<div '.($item['id'] ? 'id="'.htmlspecialchars($item['id']).'"' : '').'class="menuLayerItem" onmouseover="menuOpenSub(this);"'.($onClick ? ' onclick="'.htmlspecialchars($onClick).'"' : '').'>'.$itemCode.'</div>';
00100                                 $output.= $item['html'];
00101                         }
00102                 }
00103 
00104                 return $output;
00105         }
00109         function menuLayer($menuItems,$baseid='')       {
00110                 $output = $this->menuItems($menuItems);
00111                         
00112                         // Encapsulate in menu layer:
00113                 return $this->simpleLayer($output,$baseid?$baseid.'-layer':'');
00114         }
00115         
00116         function simpleLayer($output,$id='',$class='menulayer') {
00117                 return '<div class="'.$class.'" style="display: none;"'.($id?' id="'.htmlspecialchars($id).'"':'').'>'.$output.'</div>';
00118         }
00119         
00120         function menuItemLayer($id,$content,$onclick='')        {
00121                 return '<div id="'.$id.'" class="menuItems menu-normal" style="float: left;" onclick="menuToggleState(\''.$id.'\');'.$onclick.'" onmouseover="menuMouseOver(\''.$id.'\');" onmouseout="menuMouseOut(\''.$id.'\');">'.$content.'</div>';
00122         }
00123         function menuItemObject($id,$functionContent)   {
00124                 return '
00125                 <script>
00126                         menuItemObjects[\''.$id.'\'] = {
00127                                 '.$functionContent.'
00128                         }               
00129                 </script>               
00130                 ';
00131         }
00132 }
00133 
00134 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6