Location: PHPKode > projects > phpAWE > phpAWE.0.4.beta.demo-page/awe/classes/TaweNavigationBar.php
<?php

class TaweNavigationBar extends TaweBaseItem {

protected $aweNavigationTempOpt = array (0, 1, 2, 3, "distinct_first" => 2 , "distinct_last" => 3);

    public function view($dataSource, $parameters, $currentAddress, $template, $templateOpt) {
    
        global $tempItemFirstSufix;
        global $tempItemLastSufix;
        
        $templateOpt = optionsToTable($templateOpt,$this->aweNavigationTempOpt);
        
        $itemsData = $this->call($dataSource, $parameters);

        $last = start_value;
        for ($t=0;$t<sizeof($itemsData);$t++) {

              if ($t==0 && $templateOpt[$this->aweNavigationTempOpt["distinct_first"]])
                {$extra .= $tempItemFirstSufix;}; 
              if (($t+1)==sizeof($itemsData) && $templateOpt[$this->aweNavigationTempOpt["distinct_last"]])
                {$extra .= $tempItemLastSufix;};
 
              if (strcmp($last,$extra)) {
                 
                 $itemTemplate = file_get_contents(getItemTemplate($this->moduleName, $template, $extra)); 
                 $last =$extra; $extra="";
                 };
              
        $content .= $this->makeListItem($itemsData[$t], $itemTemplate);
        }
        
        if (sizeof($itemsData))
        $result = $this->makeListForm($content, file_get_contents(getFormTemplate($this->moduleName,$template,$inactive)));

        return $result;        

    }
    
    protected function makeListItem($dataLine, $itemTemplate) {
        global $templateAreola;
     
        $result = massReplace($dataLine, $itemTemplate, $templateAreola);

        return $result;
    }

    
    public function getData($currentAddress, $components, $includeMain = true) {
    global $addressTemplateString;
    global $addressBase;
        
      if (is_array($components))
      for ($i=0, $j=0; $i <sizeof($components); $i++, $j++) {
        if (is_a($components[$i], TawePageTree)) {
        
            if ($includeMain) {
              $tmp = $components[$i]->getItem(0);
              if (is_array($tmp)) {
              $navItem[$j] = $tmp[0];
              $navItem[$j][$addressTemplateString] = $addressBase;
              $j++;  
              }
            } 
            
            $selected = $components[$i]->itemSelected($currentAddress);
        
            $path = $components[$i]->getPredecessors($selected);
                for ($k=0; $k<sizeof($path); $k++) {
                  $tmp = $components[$i]->getItem($path[$k]);
                  $navItem[$j] = $tmp[0];
                  $navItem[$j][$addressTemplateString] =  $addressBase.$components[$i]->makeAddress($path[$k]);
                  $j++;
                }
                
            $tmp = $components[$i]->getItem($selected);
            if (is_array($tmp)) {
                $navItem[$j] = $tmp[0];
                $navItem[$j][$addressTemplateString] =  $addressBase.$components[$i]->makeAddress($selected);
            }
            else $j--;
            
            }
        else {
              $tmp = $components[$i]->getItem($components[$i]->itemSelected($currentAddress));
              if (is_array($tmp)) {
                $navItem[$j] = $tmp[0];
                $navItem[$j][$addressTemplateString] =  $addressBase.$components[$i]->makeAddress($components[$i]->itemSelected($currentAddress));
              }
              else $j--;
        }

      }
    return $navItem;
    
    }    

    
    
}
Return current item: phpAWE