/** * Retrieve all files for a language, zip them, and send the zip file to the * browser for immediate download * * @param string $language The language for which to retrieve the files * @param bool $includeCore Include the core language files * @param bool $includeCustom Include the custom module language files * * @return mixed false on error or void */ public function do_export($language = null, $includeCore = false, $includeCustom = false) { if (empty($language)) { $this->error = 'No language file chosen.'; return false; } $all_lang_files = list_lang_files($language); if (!count($all_lang_files)) { $this->error = 'No files found to archive.'; return false; } // Make the zip file $this->load->library('zip'); foreach ($all_lang_files as $key => $file) { if (is_numeric($key) && $includeCore) { $content = load_lang_file($file, $language); $this->zip->add_data($file, save_lang_file($file, $language, $content, true)); } elseif ($key == 'core' && $includeCore || $key == 'custom' && $includeCustom) { foreach ($file as $f) { $content = load_lang_file($f, $language); $this->zip->add_data($f, save_lang_file($f, $language, $content, true)); } } } $this->zip->download("bonfire_{$language}_files.zip"); die; }
public function _valid_idiom($str) { $lang_files = list_lang_files($str); if (empty($lang_files['admin']) and empty($lang_files['main']) and empty($lang_files['module'])) { $this->form_validation->set_message('_valid_idiom', $this->lang->line('error_invalid_idiom')); return FALSE; } else { // else validation is not successful return TRUE; } }
/** * Retrieve all files for a language, zip them and send the zip file * to the browser for immediate download * * @access public * * @return void */ public function do_export($language = NULL, $include_core = FALSE, $include_custom = FALSE) { if (empty($language)) { $this->error = 'No language file chosen.'; return FALSE; } $all_lang_files = list_lang_files($language); if (!count($all_lang_files)) { $this->error = 'No files found to archive.'; return FALSE; } // Make the zip file $this->load->library('zip'); foreach ($all_lang_files as $key => $file) { if (is_numeric($key) && $include_core) { $content = load_lang_file($file, $language); $this->zip->add_data($file, save_lang_file($file, $language, $content, TRUE)); } else { if ($key == 'core' && $include_core) { foreach ($file as $f) { $content = load_lang_file($f, $language); $this->zip->add_data($f, save_lang_file($f, $language, $content, TRUE)); } } else { if ($key == 'custom' && $include_custom) { foreach ($file as $f) { $content = load_lang_file($f, $language); $this->zip->add_data($f, save_lang_file($f, $language, $content, TRUE)); } } } } } //end foreach $this->zip->download('bonfire_' . $language . '_files.zip'); die; }