public static function compareRecords($newContents, $oldContents) { $recordUpdates = array(); foreach ($newContents as $fieldName => $fieldValue) { if (@$oldContents->{$fieldName} != $fieldValue) { $recordUpdates[$fieldName] = array('api' => $fieldName, 'lbl' => KTranslate::custom('fieldNames', $fieldName), 'old' => @$oldContents->{$fieldName}, 'new' => $fieldValue); } } if (isset($newContents->english)) { $name = $newContents->english; } else { if (isset($newContents->api_name)) { $name = $newContents->api_name; } else { if (isset($newContents->api_title)) { $name = $newContents->api_title; } else { $name = "NONAME[" . @$newContents->api_id . "]"; } } } return array('id' => @$newContents->api_id, 'name' => $name, 'changes' => $recordUpdates); }
public static function parseStype($date, $masterData) { $_summary = array(); foreach ($masterData as &$record) { // add to summary $_summary[$record->api_id] = array('id' => $record->api_id, 'JP' => $record->api_name, 'EN' => KTranslate::t($record->api_name), 'code' => KTranslate::custom('shipTypeCode', $record->api_name)); // create record file file_put_contents('data/master/' . $date . '/stype/' . $record->api_id . '.json', json_encode($record)); } // save _summary file file_put_contents('data/master/' . $date . '/stype/_summary.json', json_encode($_summary)); }