当前位置: 首页>>代码示例>>PHP>>正文


PHP FileHelper::get_value_json方法代码示例

本文整理汇总了PHP中FileHelper::get_value_json方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::get_value_json方法的具体用法?PHP FileHelper::get_value_json怎么用?PHP FileHelper::get_value_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileHelper的用法示例。


在下文中一共展示了FileHelper::get_value_json方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: previewData

 public static function previewData($post)
 {
     /**** new ****/
     if (isset($post['infoCreateData']) && isset($post['idCollection']) && isset($post['subFile']) && isset($post['nameFile'])) {
         $pathSubFile = '../../modules/cityData/filesImportData/' . $post['nameFile'] . '/' . $post['subFile'];
         $arrayCSV = new SplFileObject($pathSubFile, 'r');
         $arrayCSV->setFlags(SplFileObject::READ_CSV);
         $arrayCSV->setCsvControl(',', '"', '"');
         $i = 0;
         while (!$arrayCSV->eof() && $i == 0) {
             $arrayHeadCSV = $arrayCSV->fgetcsv();
             $i++;
         }
         $i = 0;
         // On parcourt les lignes du CSV
         foreach ($arrayCSV as $keyCSV => $lineCSV) {
             // On rejet la premier lignes qui correspond a l'en-tete, et les lignes qui seraient null
             if ($i > 0 && $lineCSV[0] != null) {
                 if ($i % 500 == 0) {
                     set_time_limit(30);
                 }
                 foreach ($post['infoCreateData'] as $key => $objetInfoData) {
                     //$objetInfoData->idHeadCSV;
                     //$objetInfoData->valueLinkCollection;
                     $valueData = $lineCSV[$objetInfoData['idHeadCSV']];
                     //var_dump($valueData);
                     if (!empty($valueData)) {
                         $paramsInfoCollection = array("_id" => new MongoId($post['idCollection']));
                         $fieldsInfoCollection = array("mappingFields." . $objetInfoData['valueLinkCollection']);
                         $infoCollection = ImportData::getMicroFormats($paramsInfoCollection);
                         //var_dump($infoCollection) ;
                         $mappingTypeData = explode(".", $post['idCollection'] . ".mappingFields." . $objetInfoData['valueLinkCollection']);
                         $typeData = FileHelper::get_value_json($infoCollection, $mappingTypeData);
                         /*var_dump($mappingTypeData) ; 
                           
                            var_dump($typeData) ; */
                         $mapping = explode(".", $objetInfoData['valueLinkCollection']);
                         if (isset($jsonData[$mapping[0]])) {
                             if (count($mapping) > 1) {
                                 $newmap = array_splice($mapping, 1);
                                 $jsonData[$mapping[0]] = FileHelper::create_json_with_father($newmap, $valueData, $jsonData[$mapping[0]], $typeData);
                             } else {
                                 $jsonData[$mapping[0]] = $valueData;
                             }
                         } else {
                             if (count($mapping) > 1) {
                                 $newmap = array_splice($mapping, 1);
                                 $jsonData[$mapping[0]] = FileHelper::create_json($newmap, $valueData, $typeData);
                             } else {
                                 $jsonData[$mapping[0]] = $valueData;
                             }
                         }
                     }
                 }
                 $newOrganization = Organization::newOrganizationFromImportData($jsonData);
                 //var_dump($newOrganization);
                 try {
                     $arrayJson[] = Organization::getAndCheckOrganization($newOrganization);
                 } catch (CTKException $e) {
                     $newOrganization["msgError"] = $e->getMessage();
                     $arrayJsonError[] = $newOrganization;
                 }
                 //var_dump($arrayJson);
             }
             $i++;
         }
         if (!isset($arrayJson)) {
             $arrayJson = [];
         }
         if (!isset($arrayJsonError)) {
             $arrayJsonError = [];
         }
         $params = array("result" => true, "jsonImport" => json_encode($arrayJson), "jsonError" => json_encode($arrayJsonError));
     } else {
         $params = array("result" => false);
     }
     return $params;
 }
开发者ID:Koulio,项目名称:pixelhumain,代码行数:78,代码来源:ImportData.php

示例2: get_value_json

 /**
  * 
  *
  * 
  *
  * @access	public
  * @param	array	mapping
  * @param	string	
  * @return	array
  */
 public static function get_value_json($json, $map)
 {
     if (isset($json[$map[0]])) {
         if (count($map) == 1) {
             $value = $json[$map[0]];
         } else {
             $newmap = array_splice($map, 1);
             $value = FileHelper::get_value_json($json[$map[0]], $newmap);
         }
     } else {
         $num = intval($map[0]);
         if (is_int($num)) {
             if (count($map) == 1) {
                 $value = $json[0];
             } else {
                 $newmap = array_splice($map, 1);
                 $value = FileHelper::get_value_json($json[0], $newmap);
             }
         } else {
             $value = null;
         }
     }
     return $value;
 }
开发者ID:Koulio,项目名称:pixelhumain,代码行数:34,代码来源:FileHelper.php

示例3: get_value_json

 /**
  * create_json
  *
  * 
  *
  * @access	public
  * @param	array	mapping
  * @param	string	
  * @return	array
  */
 public static function get_value_json($json, $map)
 {
     if (count($map) == 1) {
         $value = $json[$map[0]];
     } else {
         $newmap = array_splice($map, 1);
         $value = FileHelper::get_value_json($json[$map[0]], $newmap);
     }
     return $value;
 }
开发者ID:acorbi,项目名称:pixelhumain,代码行数:20,代码来源:FileHelper.php

示例4: createMappingWithJSON

 public static function createMappingWithJSON($post)
 {
     $json_array = json_decode($post['json_origine'], true);
     $jsonMapping["src"] = $post['source'];
     //json mapping
     if ($post['chooseSelected'] == "new") {
         $jsonMapping["date_create"] = date("d/m/y");
     } else {
         $oneMapping = PHDB::findOne(City::COLLECTION_IMPORTHISTORY, array("_id" => new MongoId($post['mappingSelected'])));
         $jsonMapping["date_create"] = $oneMapping["date_create"];
         // $jsonmapping["lastImportId"] = $oneMapping['lastImportId'];
     }
     $jsonMapping["date_update"] = date("d/m/y");
     $jsonMapping["url"] = $post['url'];
     $jsonMapping["nameFile"] = $post['nameFile'];
     $jsonMapping["lien"] = $post['lien'];
     foreach ($post['tabmapping'] as $key => $value) {
         if ($value != '') {
             $jsonfilsFields[$post['tabidmapping'][$key]] = $value;
         }
     }
     $jsonMapping["fields"] = $jsonfilsFields;
     $idLien = $post['lien'];
     $cheminLien = explode(".", $idLien);
     //var_dump($cheminLien);
     $valueIdLien = FileHelper::get_value_json($json_array, $cheminLien);
     //var_dump($valueIdLien);
     $res = PHDB::findOne(City::COLLECTION, array("insee" => $valueIdLien));
     $inc_import = 0;
     $inc_rejet = 0;
     if ($res != null) {
         $commune["insee"] = $valueIdLien;
         foreach ($jsonMapping['fields'] as $key => $value) {
             $map = explode(".", $value);
             $cheminJson = explode(".", $key);
             $value_json = FileHelper::get_value_json($json_array, $cheminJson);
             if (!isset($commune[$map[0]])) {
                 if (count($map) > 1) {
                     $newmap = array_splice($map, 1);
                     $commune[$map[0]] = FileHelper::create_json($newmap, $value_json);
                 } else {
                     $commune[$map[0]] = $value_json;
                 }
             } else {
                 if (count($map) > 1) {
                     $newmap = array_splice($map, 1);
                     $commune[$map[0]] = FileHelper::create_json_with_father($newmap, $value_json, $commune[$map[0]]);
                 } else {
                     $commune[$map[0]] = $value_json;
                 }
             }
         }
     } else {
         foreach ($jsonMapping['fields'] as $key => $value) {
             $map = explode(".", $value);
             $cheminJson = explode(".", $key);
             if (!isset($rejet[$valueIdLien])) {
                 if (count($map) > 1) {
                     $newmap = array_splice($map, 1);
                     $rejet[$map[0]] = FileHelper::create_json_with_father($newmap, $value_json);
                 } else {
                     $rejet[$map[0]] = $value_json;
                 }
             } else {
                 if (count($map) > 1) {
                     $newmap = array_splice($map, 1);
                     $rejet[$map[0]] = FileHelper::create_json_with_father($newmap, $value_json, $rejet[$map[0]]);
                 } else {
                     $rejet[$map[0]] = $value_json;
                 }
             }
         }
     }
     if (isset($commune)) {
         $jsonimport = $commune;
     } else {
         $jsonimport = [];
         $arrayCsvImport = [];
     }
     if (isset($rejet)) {
         $jsonrejet = $rejet;
     } else {
         $jsonrejet = [];
         $arrayCsvRejet = [];
     }
     $params = array('result' => true, 'jsonmapping' => FileHelper::indent_json(json_encode($jsonMapping)), "jsonimport" => FileHelper::indent_json(json_encode($jsonimport)), "jsonrejet" => FileHelper::indent_json(json_encode($jsonrejet)), "lien" => $post['lien']);
     return $params;
 }
开发者ID:acorbi,项目名称:pixelhumain,代码行数:88,代码来源:ImportData.php


注:本文中的FileHelper::get_value_json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。