• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List

E:/E/GEAMP/www/openbiz/openbiz/bin/easy/EasyFormTree.php

00001 <?PHP
00026 class EasyFormTree extends EasyForm
00027 {
00028        public $m_TitleField;
00029        public $m_RootSearchRule;
00030     public $m_TreeDepth;
00031     
00032        protected function readMetadata(&$xmlArr)
00033     {
00034         parent::readMetaData($xmlArr);
00035         $this->m_TitleField = isset($xmlArr["EASYFORM"]["ATTRIBUTES"]["TITLEFIELD"]) ? $xmlArr["EASYFORM"]["ATTRIBUTES"]["TITLEFIELD"] : "title";
00036         $this->m_RootSearchRule = isset($xmlArr["EASYFORM"]["ATTRIBUTES"]["ROOTSEARCHRULE"]) ? $xmlArr["EASYFORM"]["ATTRIBUTES"]["ROOTSEARCHRULE"] : null;
00037         $this->m_TreeDepth = isset($xmlArr["EASYFORM"]["ATTRIBUTES"]["TREEDEPTH"]) ? $xmlArr["EASYFORM"]["ATTRIBUTES"]["TREEDEPTH"] : 10;
00038     }
00039     
00040    public function fetchDataSet()
00041     {
00042         
00043         $dataObj = $this->getDataObj();
00044         if (!$dataObj) return null;
00045         
00046         QueryStringParam::setBindValues($this->m_SearchRuleBindValues);
00047 
00048         if ($this->m_RefreshData)
00049             $dataObj->resetRules();
00050         else
00051             $dataObj->clearSearchRule();
00052 
00053         if ($this->m_FixSearchRule)
00054         {
00055             if ($this->m_SearchRule)
00056                 $searchRule = $this->m_SearchRule . " AND " . $this->m_FixSearchRule;
00057             else
00058                 $searchRule = $this->m_FixSearchRule;
00059         }
00060         else
00061             $searchRule = $this->m_SearchRule;
00062 
00063         $dataObj->setSearchRule($searchRule);
00064         if($this->m_StartItem>1)
00065         {
00066             $dataObj->setLimit($this->m_Range, $this->m_StartItem);
00067         }
00068         else
00069         {
00070             $dataObj->setLimit($this->m_Range, ($this->m_CurrentPage-1)*$this->m_Range);
00071         }
00072         //$resultRecords = $dataObj->fetch();
00073         
00074         $resultRecordTree = $dataObj->fetchTree($this->m_RootSearchRule,$this->m_TreeDepth);
00075         if(is_array($resultRecordTree)){
00076                foreach ($resultRecordTree as $resultRecordTreeNode){
00077                      $this->tree2array($resultRecordTreeNode, $resultRecords);
00078                }
00079         }
00080         $this->m_TotalRecords = $dataObj->count();
00081         if ($this->m_Range && $this->m_Range > 0)
00082             $this->m_TotalPages = ceil($this->m_TotalRecords/$this->m_Range);
00083         $selectedIndex = 0;
00084         $this->getDataObj()->setActiveRecord($resultRecords[$selectedIndex]);
00085 
00086         QueryStringParam::ReSet();
00087 
00088         return $resultRecords;
00089     }    
00090     
00091     private function tree2array($tree,&$array,$level=0){
00092        if(!is_array($array)){
00093               $array=array();
00094        }
00095        
00096        $treeNodeArray = array(
00097               "Level" => $level,
00098               "Id" => $tree->m_Id,
00099               "PId" => $tree->m_PId,
00100        );
00101        foreach ($tree->m_Record as $key=>$value){
00102               $treeNodeArray[$key] = $value;            
00103        }
00104        $treeNodeArray[$this->m_TitleField] = "+ ".str_repeat("- - - -", $level)." ".$treeNodeArray[$this->m_TitleField];
00105        
00106        array_push($array, $treeNodeArray);
00107        $level++;   
00108        if(is_array($tree->m_ChildNodes)){               
00109               foreach($tree->m_ChildNodes as $treeNode){                     
00110                      $this->tree2array($treeNode, $array, $level);                                              
00111               }             
00112        }
00113        return $array;
00114     }
00115 }
00116 ?>

Generated on Thu Apr 19 2012 17:09:13 for openbiz by  doxygen 1.7.2