Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

tslib_jsmenu Class Reference

Inherits tslib_menu.

List of all members.

Public Member Functions

 generate ()
 Dummy.
 writeMenu ()
 Creates the HTML (mixture of a <form> and a JavaScript section) for the JavaScript menu (basically an array of selector boxes with onchange handlers).
 generate_level ($levels, $count, $pid, $menuItemArray='', $MP_array=array())
 Generates a number of lines of JavaScript code for a menu level.


Member Function Documentation

tslib_jsmenu::generate  ) 
 

Dummy.

Should do nothing, because we don't use the result-array here!

Returns:
void

Definition at line 2530 of file class.tslib_menu.php.

02530                         {
02531    }

tslib_jsmenu::generate_level levels,
count,
pid,
menuItemArray = '',
MP_array = array()
 

Generates a number of lines of JavaScript code for a menu level.

Calls itself recursively for additional levels.

Parameters:
integer Number of levels to generate
integer Current level being generated - and if this number is less than $levels it will call itself recursively with $count incremented
integer Page id of the starting point.
array $this->menuArr passed along
array Previous MP vars
Returns:
string JavaScript code lines. private

Definition at line 2599 of file class.tslib_menu.php.

02599                                                                                     {
02600       $levelConf = $this->mconf[$count.'.'];
02601 
02602          // Translate PID to a mount page, if any:
02603       $mount_info = $this->sys_page->getMountPointInfo($pid);
02604       if (is_array($mount_info)) {
02605          $MP_array[] = $mount_info['MPvar'];
02606          $pid = $mount_info['mount_pid'];
02607       }
02608 
02609          // Set "&MP=" var:
02610       $MP_var = implode(',',$MP_array);
02611       $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : '';
02612 
02613          // UIDs to ban:
02614       $banUidArray=array();
02615       if (trim($this->conf['excludeUidList']))  {
02616          $banUidArray = t3lib_div::intExplode(',', $this->conf['excludeUidList']);
02617       }
02618 
02619          // Initializing variables:
02620       $var = $this->JSVarName;
02621       $menuName = $this->JSMenuName;
02622       $parent = $count==1 ? 0 : $var.($count-1);
02623       $prev=0;
02624       $c=0;
02625 
02626       $menuItems = is_array($menuItemArray) ? $menuItemArray : $this->sys_page->getMenu($pid);
02627       foreach($menuItems as $uid => $data)   {
02628          $spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype'])?1:0);      // if item is a spacer, $spacer is set
02629          if ($this->mconf['SPC'] || !$spacer)   {  // If the spacer-function is not enabled, spacers will not enter the $menuArr
02630             if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype']) && !$data['nav_hide'] && !t3lib_div::inArray($banUidArray,$uid)) {     // Page may not be 'not_in_menu' or 'Backend User Section' + not in banned uid's
02631                if ($count<$levels)  {
02632                   $addLines = $this->generate_level($levels,$count+1,$data['uid'],'',$MP_array);
02633                } else {
02634                   $addLines = '';
02635                }
02636                $title=rawurlencode($data['title']);
02637                $url='';
02638                $target='';
02639                if ((!$addLines && !$levelConf['noLink']) || $levelConf['alwaysLink']) {
02640                   $LD = $this->tmpl->linkData($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']);
02641                   $url = rawurlencode($LD['totalURL']);
02642                   $target = rawurlencode($LD['target']);
02643                }
02644                $codeLines.="\n".$var.$count."=".$menuName.".add(".$parent.",".$prev.",0,'".$title."','".$GLOBALS['TSFE']->baseUrlWrap($url)."','".$target."');";
02645                   // If the active one should be chosen...
02646                $active = ($levelConf['showActive'] && $data['uid'] == $this->tmpl->rootLine[$count]['uid']);
02647                   // If the first item should be shown
02648                $first = (!$c && $levelConf['showFirst']);
02649                   // do it...
02650                if ($active || $first)  {
02651                   if ($count==1) {
02652                      $codeLines.="\n".$menuName.".openID = ".$var.$count.";";
02653                   } else {
02654                      $codeLines.="\n".$menuName.".entry[".$parent."].openID = ".$var.$count.";";
02655                   }
02656                }
02657                   // Add submenu...
02658                $codeLines.=$addLines;
02659 
02660                $prev=$var.$count;
02661                $c++;
02662             }
02663          }
02664       }
02665       if ($this->mconf['firstLabelGeneral'] && !$levelConf['firstLabel'])  {
02666          $levelConf['firstLabel'] = $this->mconf['firstLabelGeneral'];
02667    }
02668       if ($levelConf['firstLabel'] && $codeLines)  {
02669          $codeLines.="\n".$menuName.".defTopTitle[".$count."] = unescape('".rawurlencode($levelConf['firstLabel'])."');";
02670 }
02671       return $codeLines;
02672    }

tslib_jsmenu::writeMenu  ) 
 

Creates the HTML (mixture of a <form> and a JavaScript section) for the JavaScript menu (basically an array of selector boxes with onchange handlers).

Returns:
string The HTML code for the menu

Definition at line 2538 of file class.tslib_menu.php.

02538                         {
02539       if ($this->id) {
02540             // Making levels:
02541          $levels = t3lib_div::intInRange($this->mconf['levels'],1,5);
02542          $this->levels = $levels;
02543          $this->JSVarName='eid';
02544          $this->JSMenuName= $this->mconf['menuName'] ? $this->mconf['menuName'] : 'JSmenu';
02545 
02546          $JScode="\n var ".$this->JSMenuName." = new JSmenu(".$levels.",'".$this->JSMenuName."Form');";
02547 
02548          for ($a=1;$a<=$levels;$a++)   {
02549             $JScode.="\n var ".$this->JSVarName.$a."=0;";
02550          }
02551          $JScode.= $this->generate_level($levels,1,$this->id,$this->menuArr,$this->MP_array)."\n";
02552 
02553          $GLOBALS['TSFE']->additionalHeaderData['JSMenuCode']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.menu.js"></script>';
02554          $GLOBALS['TSFE']->JSCode.=$JScode;
02555 
02556             // Printing:
02557          $allFormCode="";
02558          for ($a=1;$a<=$this->levels;$a++)   {
02559             $formCode='';
02560             $levelConf = $this->mconf[$a.'.'];
02561             $length = $levelConf['width'] ? $levelConf['width'] : 14;
02562             $lenghtStr='';
02563             for ($b=0;$b<$length;$b++) {
02564                $lenghtStr.='_';
02565             }
02566             $height = $levelConf['elements'] ? $levelConf['elements'] : 5;
02567 
02568             $formCode.= '<select name="selector'.$a.'" onchange="'.$this->JSMenuName.'.act('.$a.');"'.($levelConf['additionalParams']?' '.$levelConf['additionalParams']:'').'>';
02569             for ($b=0;$b<$height;$b++) {
02570                $formCode.= '<option value="0">';
02571                if ($b==0)  {
02572                   $formCode.= $lenghtStr;
02573                }
02574                $formCode.='</option>';
02575             }
02576             $formCode.= '</select>';
02577             $allFormCode.=$this->tmpl->wrap($formCode,$levelConf['wrap']);
02578          }
02579          $formCode = $this->tmpl->wrap($allFormCode,$this->mconf['wrap']);
02580 
02581          $formCode= '<form action="" method="post" style="margin: 0 0 0 0;" name="'.$this->JSMenuName.'Form">'.$formCode.'</form>';
02582          $formCode.='<script type="text/javascript"> /*<![CDATA[*/ '.$this->JSMenuName.'.writeOut(1,'.$this->JSMenuName.'.openID,1); /*]]>*/ </script>';
02583          return $this->tmpl->wrap($formCode,$this->mconf['wrapAfterTags']);
02584       }
02585    }


The documentation for this class was generated from the following file:
Generated on Sun Oct 3 01:07:41 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913