Ejemplo n.º 1
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);
 }
 /**
  * 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);
 }
Ejemplo n.º 3
0
 public function edit()
 {
     $language_info = $this->Languages_model->getLanguage((int) $this->input->get('id'));
     if ($language_info) {
         $language_id = $language_info['language_id'];
         $data['_action'] = current_url();
     } else {
         $language_id = 0;
         $data['_action'] = site_url('languages/edit');
     }
     if ($this->input->post() and $language_id = $this->_saveLanguage()) {
         if ($this->input->post('save_close') === '1') {
             redirect('languages');
         } else {
             if (is_numeric($this->input->get('id'))) {
                 redirect("languages/edit?id={$language_id}&location={$this->input->get('location')}&file={$this->input->get('file')}");
             }
         }
         redirect('languages/edit?id=' . $language_id);
     }
     if ($language_id === '11') {
         $this->alert->set('info', $this->lang->line('alert_caution_edit'));
     }
     $title = isset($language_info['name']) ? $language_info['name'] : $this->lang->line('text_new');
     $this->template->setTitle(sprintf($this->lang->line('text_edit_heading'), $title));
     $this->template->setHeading(sprintf($this->lang->line('text_edit_heading'), $title));
     $this->template->setButton($this->lang->line('button_save'), array('class' => 'btn btn-primary', 'onclick' => '$(\'#edit-form\').submit();'));
     $this->template->setButton($this->lang->line('button_save_close'), array('class' => 'btn btn-default', 'onclick' => 'saveClose();'));
     $this->template->setButton($this->lang->line('button_icon_back'), array('class' => 'btn btn-default', 'href' => site_url('languages')));
     $data['language_id'] = $language_info['language_id'];
     $data['name'] = $language_info['name'];
     $data['code'] = $language_info['code'];
     $data['idiom'] = $language_info['idiom'];
     $data['can_delete'] = $language_info['can_delete'];
     $data['status'] = $language_info['status'];
     $data['no_photo'] = $this->Image_tool_model->resize('data/flags/no_flag.png');
     if ($this->input->post('image')) {
         $data['image']['path'] = $this->Image_tool_model->resize($this->input->post('image'));
         $data['image']['name'] = basename($this->input->post('image'));
         $data['image']['input'] = $this->input->post('image');
     } else {
         if (!empty($language_info['image'])) {
             $data['image']['path'] = $this->Image_tool_model->resize($language_info['image']);
             $data['image']['name'] = basename($language_info['image']);
             $data['image']['input'] = $language_info['image'];
         } else {
             $data['image']['path'] = $this->Image_tool_model->resize('data/flags/no_flag.png');
             $data['image']['name'] = 'no_flag.png';
             $data['image']['input'] = 'data/flags/no_flag.png';
         }
     }
     $data['close_edit_link'] = site_url('languages/edit?id=' . $language_id);
     $data['lang_file'] = $this->input->get('file');
     $data['lang_location'] = $this->input->get('location');
     $data['lang_files'] = array();
     $data['lang_file_values'] = array();
     if (!empty($language_info['idiom']) and $lang_files = list_lang_files($language_info['idiom'])) {
         foreach ($lang_files as $location => $files) {
             if (!empty($files)) {
                 foreach ($files as $file) {
                     $data['lang_files'][$location][] = array('name' => $file, 'edit' => site_url('languages/edit?id=' . $language_id . '&location=' . $location . '&file=' . $file));
                 }
             }
         }
         if (!empty($data['lang_file'])) {
             if ($lang_file_values = load_lang_file($this->input->get('file'), $language_info['idiom'], $this->input->get('location'))) {
                 foreach ($lang_file_values as $key => $value) {
                     $data['lang_file_values'][$key] = $value;
                 }
             }
         }
     }
     $data['languages'] = array();
     $results = $this->Languages_model->getLanguages();
     foreach ($results as $result) {
         $data['languages'][] = array('idiom' => $result['idiom'], 'name' => $result['name']);
     }
     $this->template->render('languages_edit', $data);
 }
Ejemplo n.º 4
0
 */
$GLOBALS['current_smf_version'] = '1.0pre';
$GLOBALS['db_script_version'] = '2-0';
$GLOBALS['required_php_version'] = '5.3.1';
global $installurl, $incontext, $databases, $txt;
$incontext = array();
// Don't have PHP support, do you?
// ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
// Database info.
$databases = array('mysql' => array('name' => 'MySQL', 'version' => '4.1.0', 'version_check' => 'return min(mysql_get_server_info(), mysql_get_client_info());', 'supported' => function_exists('mysql_connect'), 'default_user' => 'mysql.default_user', 'default_password' => 'mysql.default_password', 'default_host' => 'mysql.default_host', 'default_port' => 'mysql.default_port', 'utf8_support' => true, 'utf8_version' => '4.1.0', 'utf8_version_check' => 'return mysql_get_server_info();', 'utf8_default' => true, 'utf8_required' => true, 'alter_support' => true, 'validate_prefix' => create_function('&$value', '
			$value = preg_replace(\'~[^A-Za-z0-9_\\$]~\', \'\', $value);
			return true;
		')));
// Initialize everything and load the language files.
initialize_inputs();
load_lang_file();
// This is what we are.
$installurl = $_SERVER['PHP_SELF'];
// All the steps in detail.
// Number,Name,Function,Progress Weight.
$incontext['steps'] = array(0 => array(1, $txt['install_step_welcome'], 'Welcome', 0), 1 => array(2, $txt['install_step_writable'], 'CheckFilesWritable', 10), 2 => array(3, $txt['install_step_databaseset'], 'DatabaseSettings', 15), 3 => array(4, $txt['install_step_forum'], 'ForumSettings', 40), 4 => array(5, $txt['install_step_databasechange'], 'DatabasePopulation', 15), 5 => array(6, $txt['install_step_admin'], 'AdminAccount', 20), 6 => array(7, $txt['install_step_delete'], 'DeleteInstall', 0));
// Default title...
$incontext['page_title'] = $txt['smf_installer'];
// What step are we on?
$incontext['current_step'] = isset($_GET['step']) ? (int) $_GET['step'] : 0;
// Loop through all the steps doing each one as required.
$incontext['overall_percent'] = 0;
foreach ($incontext['steps'] as $num => $step) {
    if ($num >= $incontext['current_step']) {
        // The current weight of this step in terms of overall progress.
        $incontext['step_weight'] = $step[3];
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
function collect_translations($language)
{
    /*
    We collect all translation strings by first loading the default (English) 
    and then the language file itself.
    
    This way, we'll be sure to have all language strings (as the English one 
    is assumed to be complete at all times) while any gaps in the language X 
    file are filled by those English ones.
    */
    // English indexes are our 'master base':
    $lang_entries = load_lang_file('en');
    $i18n = load_lang_file($language);
    // now ONLY override entries which EXIST in 'en'; anything else is superfluous/outdated in the language file anyway and will corrupt our index-counting later on
    foreach ($i18n as $key => $value) {
        if (!empty($value) && array_key_exists($key, $lang_entries)) {
            // override value now!
            $lang_entries[$key] = $value;
        }
    }
    return $lang_entries;
}
Ejemplo n.º 7
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;
 }