public static function build($value)
 {
     /*DocumentBuilder*/
     $builder = new DocumentBuilder();
     if (DataUtils::valueIsMethod($value)) {
         return $builder->buildOnMethod($value);
     } else {
         if (DataUtils::valueIsLink($value)) {
             return $builder->buildOnURLTemplate($value);
         } else {
             if (DataUtils::valueIsFile($value)) {
                 return $builder->buildOnFileTemplate($value);
             } else {
                 return $builder->buildOnString($value);
             }
         }
     }
 }
 protected function generateFromArray($array)
 {
     if ($array == null) {
         $array = $this->dataProvider;
     }
     parent::generateFromArray($array);
     if (count($this->dataProviderList) == 0) {
         throw new Exception("DataProvider is empty");
     } else {
         if ($this->dataProviderList[0][DataUtils::$METHOD_WORD] != null) {
             if (DataUtils::valueIsMethod($this->dataProviderList[0][DataUtils::$METHOD_WORD])) {
                 $this->generateFromString($this->dataProviderList[0][DataUtils::$METHOD_WORD]);
             } else {
                 $this->generateFromString(DataUtils::$METHOD_CODE + $this->dataProviderList[0][DataUtils::$METHOD_WORD]);
             }
         } else {
             foreach ($this->dataProviderList as $key => $val) {
                 if (DataUtils::valueIsMethod($val)) {
                     $this->generateFromString($val);
                 }
             }
         }
     }
 }
 /**
  * Generate data provider array (dataProviderList) based on Object array
  * 
  * @param array income Object array each member of it could be 
  * 				HashMap, Object or Object[]
  * @throws DocumentException
  */
 protected function generateFromArray($array)
 {
     if (count($array) == 1) {
         foreach ($array as $val) {
             if (DataUtils::valueIsMethod($val)) {
                 $this->generateFromString($val);
                 return;
             }
             break;
         }
     }
     $this->dataProviderList = array();
     for ($i = 0; $i < count($array); $i++) {
         $item = array();
         $this->populateRow($item, $array[$i]);
         $this->dataProviderList[] = $item;
     }
 }
Beispiel #4
0
 protected function generateFromArray($array)
 {
     parent::generateFromArray($array);
     if (count($this->dataProviderList) == 0) {
         throw new DocumentBuildException("DataProvider is empty");
     } else {
         if ($this->dataProviderList[0][DataUtils::$METHOD_WORD] != null) {
             $this->columns = null;
             if (DataUtils::valueIsMethod($this->dataProviderList[0][DataUtils::$METHOD_WORD])) {
                 $this->generateFromString($this->dataProviderList[0][DataUtils::$METHOD_WORD]);
             } else {
                 $this->generateFromString(DataUtils::$METHOD_CODE . $this->dataProviderList[0][DataUtils::$METHOD_WORD]);
             }
             return;
         } else {
             if (count($this->dataProviderList[0]) == 1) {
                 foreach ($this->dataProviderList[0] as $itemValue) {
                     if (DataUtils::valueIsMethod($itemValue)) {
                         $this->generateFromString($itemValue);
                         return;
                     }
                 }
             }
         }
     }
     if ($this->columns == null || count($this->columns) == 0) {
         $this->columns = array();
         //new DataGridColumn[colnames.length];
         foreach ($this->dataProviderList[0] as $key => $value) {
             /*DataGridColumn*/
             $col = new DataGridColumn();
             $col->dataField = $key;
             $col->width = $this->getColumnWidth($col);
             $this->columns[] = $col;
         }
     }
 }