Location: PHPKode > scripts > Flexible Menu Maker > flexible-menu-maker/FlexMenuMaker.Class.php
<?php
/**
 * Class Menu - Menu Maker class.
 * The Flexible Menu Maker Class By Menu Array
 * 
 * Author: Seyyed Mehdi Safavy
 * hide@address.com
 * @version 1.0
 * eCreate, Oct 2007
 */

 class Menu
 {
   // this parameters should be set before show method   //  
   var $dir;  
   var $align;
   var $width;
   var $ItemAlign;
   var $menu_id;// if menu has javascript control
   var $menu_type;
   var $tag;
   //                                                    //
   var $Ar_align = Array (
    1 => "right",
    2 => "left",
    3 => "center"
   );
   
   
   /**
    * Show the Menu on The Page By Pre Settings.
    *
    * @param Array menu_items
    */
   function show($menu_items)
   {
       
        if ($this->width >0) $with=$this->width;else $with="50%";//if we have assigned width
        $align=$this->Ar_align[$this->align];// for unicode menu's
        $dir=$this->dir;
		$with=$this->width;

        echo"<TABLE width='$with'  cellspacing=0 collspaning=0 align='$align' dir='$dir'>";

        if ($this->menu_type==1)
        {//type Vertical
        	 $item=Array();
             foreach ($menu_items as $item)
             {
               $name =$item[Name] ;
               $title=$item[Title];
               $link=$item[Link];
               $tag=$item[Tag] ;
               $target=$item[Target];
               $m_id= $this->menu_id;
               $algn= $this->ItemAlign;               
               $syntax=strpos("$link","?");  // if specified link has GET elements              
               if ($target==1) $target="href='$link'";else $target="href='$link' target=#";
               //The TAG item contains other properties or javascript to this menu item.
               echo" 
                     <TR style='cursor:hand'>
                        <TD TITLE='$title'  id='MenuTD_$m_id' $tag style='text-align:$algn' valign=middle>
                         <a $target> $name </a>
                        </TD>
                     </TR>
                     ";
           }

        }else  if ($this->menu_type==2) {//type horizantal

           $item=Array();	
           echo "<TR style='cursor:hand'>";
           foreach ($menu_items as $item)
           {
               $name =$item[Name] ;
               $title=$item[Title];
               $link=$item[Link];
               $tag=$item[Tag] ;
               $target=$item[Target];
               $m_id= $this->menu_id;
               $algn= $this->ItemAlign;               
               $syntax=strpos("$link","?");  // if specified link has GET elements             
               if ($target==1) $target="href='$link'";else $target="href='$link' target=#";  
               //The Tag item contains other properties or javascript to this menu item.

               echo" 
                        <TD TITLE='$title'  id='MenuTD_$m_id'  $tag style='text-align:$algn' >
                          <a $target> $name </a>
                        </TD>
                     ";
           }
         echo" </TR>   ";
        }else{//type
           echo "<center> select menu type first!. (menuobject->menu_type)";
        }//type
        echo"
          </TABLE>";

   }

 } #End Class

?>
Return current item: Flexible Menu Maker