/**
  * Add one or more lines to an existing language file.
  *
  * @param string $filename   The name of the file to update.
  *                           entries to update/add and the values to set them to.
  * @param string $language   The language of the file to update.
  * @param array  $new_values An array of key/value pairs containing the language
  * @param string $domain     The domain where the language is located.
  *
  * @return bool True on successful update, else false.
  */
 function addLanguageLine($filename, $language = 'english', $domain = 'main', $new_values = array())
 {
     $original_values = load_lang_file($filename, $language);
     foreach ($new_values as $key => $val) {
         $original_values[$key] = $val;
     }
     return save_lang_file($filename, $language, $domain, $original_values, FALSE, TRUE);
 }
Esempio n. 2
0
 /**
  * Add one or more lines to an existing language file
  *
  * @param string $filename The name of the file to update
  * @param array $line     An array of key/value pairs containing the language entries to update/add and the values to set them to
  * @param string $language The language of the file to update
  *
  * @return bool    true on successful update, else false
  */
 function addLanguageLine($filename, $line, $language = 'english')
 {
     $orig = load_lang_file($filename, $language);
     foreach ($line as $key => $val) {
         $orig[$key] = $val;
     }
     return save_lang_file($filename, $language, $orig, false, true);
 }
Esempio n. 3
0
 private function _saveLanguage()
 {
     if ($this->validateForm() === TRUE) {
         $save_type = !is_numeric($this->input->get('id')) ? $this->lang->line('text_added') : $this->lang->line('text_updated');
         if ($language_id = $this->Languages_model->saveLanguage($this->input->get('id'), $this->input->post())) {
             $this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Language ' . $save_type));
             if ($save_type === 'added' and $this->input->post('clone_language') === '1') {
                 if (!clone_language($this->input->post('idiom'), $this->input->post('language_to_clone'))) {
                     $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $this->lang->line('text_cloned')));
                 }
             }
             if ($save_type === 'updated' and $this->input->get('file')) {
                 if (!save_lang_file($this->input->get('file'), $this->input->post('idiom'), $this->input->get('location'), $this->input->post('lang'))) {
                     $this->alert->set('warning', sprintf($this->lang->line('alert_warning_file'), $save_type));
                 }
             }
         } else {
             $this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $save_type));
         }
         return $language_id;
     }
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
 /**
  * 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;
 }