Ejemplo n.º 1
0
 private function serialiseTheArrayKey($arr, $myName, &$headingRow, &$dataRow)
 {
     $ret = "";
     foreach ($arr as $k => $val) {
         $ret = $myName;
         $dk = ArrayBuilder::getDummyKey();
         if ($k != $dk) {
             $ret .= "_" . $k;
         }
         if (is_array($val)) {
             $this->serialiseTheArrayKey($val, $ret, $headingRow, $dataRow);
         } else {
             $headingRow[$ret] = true;
             $dataRow[$ret] = $val;
         }
     }
 }
Ejemplo n.º 2
0
 public static function convertFileToArray($file, $inputFormat)
 {
     $ret = array();
     //always return array no undefine notices will be generated then..
     if (ArrayBuilder::verifyFileAndExtension($file)) {
         $fileExtension = "";
         if (isset($inputFormat) && !empty($inputFormat)) {
             $fileExtension = $inputFormat;
         } else {
             $fileName = basename($file);
             $fileExtension = substr($fileName, strrpos($fileName, ".") + 1);
         }
         switch (strtolower($fileExtension)) {
             case "csv":
                 $ret = ArrayBuilder::convertCSVToArray($file);
                 break;
             case "js":
                 $ret = ArrayBuilder::convertJSONToArray($file);
                 break;
             case "xml":
                 $ret = ArrayBuilder::convertXMLToArray($file);
                 break;
             default:
                 print "We don't support yet {$fileExtension}.";
                 exit;
         }
     } else {
         $allSuppFile = SupportedFileType::getAllSupportedType();
         if (count($allSuppFile) > 0) {
             $str = implode(",", $allSuppFile);
             print "Supported files are: {$str}";
             exit;
         }
     }
     return $ret;
 }
Ejemplo n.º 3
0
 public function setParams($params)
 {
     return parent::setParams(json_decode($params, true));
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     $this->dummyKey = ArrayBuilder::getDummyKey();
 }
Ejemplo n.º 5
0
 private function convertFileToArray()
 {
     $this->arrayOfElements = ArrayBuilder::convertFileToArray($this->file, $this->inputFormat);
 }