/** * Create the report * @return Response */ public function store() { $input = Input::all(); $file = Input::file('file'); $filename = $file->getClientOriginalName(); $file->move(temp_path(), $filename); $filename = str_replace('.ZIP', '.zip', $filename); $unzipSuccess = Unzip(temp_path() . "/{$filename}", temp_path()); $contents = file_get_contents(temp_path() . "/report_generator.json"); $report_info = json_decode($contents, true); $input = array('name' => $report_info['name'], 'author' => $report_info['author'], 'version' => $report_info['version'], 'website' => $report_info['website'], 'modules' => json_encode($report_info['modules']), 'show_calendars' => $report_info['show_calendars']); if ($report_generator = ReportGenerator::where('name', '=', $input['name'])->first()) { $report_generator->update($input); } else { $report_generator = ReportGenerator::create($input); } return Redirect::to("{$this->link_type}/report-generators")->with('success_message', trans('success_messages.report_generator_install')); }
public function installLanguageFile($file) { $filename = $this->uploadLanguageFile($file); $filename = str_replace('.ZIP', '.zip', $filename); $canonical = str_replace('.zip', '', $filename); $temp_import_path = temp_path() . '/translations_import/' . $canonical . '/'; if (File::exists($temp_import_path)) { File::deleteDirectory($temp_import_path); } $unzipSuccess = Unzip("{$this->temp_path}{$filename}", $temp_import_path); if (!$unzipSuccess) { throw new Exception("The language file {$filename} couldn\\'t be extracted."); } if (!File::exists("{$temp_import_path}language.json")) { throw new Exception('language.json doesn\'t exist in the language file'); } $language_config = json_decode(file_get_contents("{$temp_import_path}/language.json"), true); $language_dir = $this->language_path . $language_config['code']; File::copyDirectory($temp_import_path . 'lang', $language_dir); // Import the translations from file to database $this->translation_manager->importTranslations(); return $language_config; }