public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Languages'), 'icon' => 'icon-globe'), 'input' => array(array('type' => 'hidden', 'name' => 'ps_version'), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true), array('type' => 'text', 'label' => $this->l('ISO code'), 'name' => 'iso_code', 'required' => true, 'maxlength' => 2, 'hint' => $this->l('Two-letter ISO code (e.g. FR, EN, DE).')), array('type' => 'text', 'label' => $this->l('Language code'), 'name' => 'language_code', 'required' => true, 'maxlength' => 5, 'hint' => $this->l('IETF language tag (e.g. en-US, pt-BR).')), array('type' => 'text', 'label' => $this->l('Date format'), 'name' => 'date_format_lite', 'required' => true, 'hint' => sprintf($this->l('Short date format (e.g., %s).'), 'Y-m-d')), array('type' => 'text', 'label' => $this->l('Date format (full)'), 'name' => 'date_format_full', 'required' => true, 'hint' => sprintf($this->l('Full date format (e.g., %s).'), 'Y-m-d H:i:s')), array('type' => 'file', 'label' => $this->l('Flag'), 'name' => 'flag', 'required' => true, 'hint' => $this->l('Upload the country flag from your computer.')), array('type' => 'file', 'label' => $this->l('"No-picture" image'), 'name' => 'no_picture', 'hint' => $this->l('Image is displayed when "no picture is found".')), array('type' => 'switch', 'label' => $this->l('Is RTL language'), 'name' => 'is_rtl', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'is_rtl_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => array($this->l('Enable if this language is read from right to left.') . ' ' . $this->l('(Experimental: your theme must be compliant with RTL languages).'))), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Activate this language.')), array('type' => 'special', 'name' => 'resultCheckLangPack', 'text' => $this->l('Check to see if a language pack is available for this ISO code.'), 'img' => 'ajax-loader.gif')));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso');
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     if ($obj->id && !$obj->checkFiles()) {
         $this->fields_form['new'] = array('legend' => array('title' => $this->l('Warning'), 'image' => '../img/admin/warning.gif'), 'list_files' => array(array('label' => $this->l('Translation files'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'tr', true)), array('label' => $this->l('Theme files'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'theme', true)), array('label' => $this->l('Mail files'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'mail', true))));
     }
     $this->fields_value = array('ps_version' => _PS_VERSION_);
     return parent::renderForm();
 }
 public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Languages'), 'image' => '../img/admin/world.gif'), 'input' => array(array('type' => 'hidden', 'name' => 'ps_version'), array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 32, 'maxlength' => 32, 'required' => true), array('type' => 'text', 'label' => $this->l('ISO code:'), 'name' => 'iso_code', 'required' => true, 'size' => 2, 'maxlength' => 2, 'desc' => $this->l('2-letter ISO code (e.g. fr, en, de)')), array('type' => 'text', 'label' => $this->l('Language code:'), 'name' => 'language_code', 'required' => true, 'size' => 2, 'maxlength' => 5, 'desc' => $this->l('Full language code (e.g. en-us, pt-br)')), array('type' => 'text', 'label' => $this->l('Date format:'), 'name' => 'date_format_lite', 'required' => true, 'size' => 15, 'desc' => $this->l('Short date format (e.g. Y-m-d, d/m/Y)')), array('type' => 'text', 'label' => $this->l('Date format (full):'), 'name' => 'date_format_full', 'required' => true, 'size' => 25, 'desc' => $this->l('Full date format (e.g., Y-m-d H:i:s, d/m/Y H:i)')), array('type' => 'file', 'label' => $this->l('Flag:'), 'name' => 'flag', 'required' => true, 'desc' => $this->l('Upload country flag from your computer')), array('type' => 'file', 'label' => $this->l('"No-picture" image:'), 'name' => 'no-picture', 'desc' => $this->l('Image displayed when "no picture found"')), array('type' => 'radio', 'label' => $this->l('Is RTL language:'), 'name' => 'is_rtl', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'is_rtl_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Enable if this language is read from right to left') . ' ' . $this->l('(Experimental: your theme must be compliant with RTL languages)')), array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Allow or disallow this language to be selected by the customer')), array('type' => 'special', 'name' => 'resultCheckLangPack', 'text' => $this->l('Check if a language pack is available for this ISO code...'), 'img' => 'ajax-loader.gif')));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     $this->fields_form['submit'] = array('title' => $this->l('   Save   '), 'class' => 'button');
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     if ($obj->id && !$obj->checkFiles()) {
         $this->fields_form['new'] = array('legend' => array('title' => $this->l('Warning'), 'image' => '../img/admin/warning.gif'), 'list_files' => array(array('label' => $this->l('Translation files:'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'tr', true)), array('label' => $this->l('Theme files:'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'theme', true)), array('label' => $this->l('Mail files:'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'mail', true))));
     }
     $this->fields_value = array('ps_version' => _PS_VERSION_);
     $this->addJS(_PS_JS_DIR_ . 'checkLangPack.js');
     return parent::renderForm();
 }
 public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Languages'), 'image' => '../img/admin/world.gif'), 'input' => array(array('type' => 'hidden', 'name' => 'ps_version'), array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 32, 'maxlength' => 32, 'required' => true), array('type' => 'text', 'label' => $this->l('ISO code:'), 'name' => 'iso_code', 'required' => true, 'size' => 2, 'maxlength' => 2, 'desc' => $this->l('Two-letter ISO code (e.g. FR, EN, DE)')), array('type' => 'text', 'label' => $this->l('Language code:'), 'name' => 'language_code', 'required' => true, 'size' => 2, 'maxlength' => 5, 'desc' => $this->l('IETF language tag (e.g. en-US, pt-BR).') . ' ' . sprintf('<a href="http://en.wikipedia.org/wiki/IETF_language_tag" target="_blank">%s <img src="../img/admin/external_link.png" class="icon-top" /></a>', $this->l('IETF on Wikipedia'))), array('type' => 'text', 'label' => $this->l('Date format:'), 'name' => 'date_format_lite', 'required' => true, 'size' => 15, 'desc' => sprintf($this->l('Short date format (e.g., %s)'), '<a href="http://php.net/date" target="_blank">Y-m-d</a>')), array('type' => 'text', 'label' => $this->l('Date format (full):'), 'name' => 'date_format_full', 'required' => true, 'size' => 25, 'desc' => sprintf($this->l('Full date format (e.g., %s)'), '<a href="http://php.net/date" target="_blank">Y-m-d H:i:s</a>')), array('type' => 'file', 'label' => $this->l('Flag:'), 'name' => 'flag', 'required' => true, 'desc' => $this->l('Upload the country flag from your computer')), array('type' => 'file', 'label' => $this->l('"No-picture" image:'), 'name' => 'no-picture', 'desc' => $this->l('Image is displayed when "no picture is found"')), array('type' => 'radio', 'label' => $this->l('Is RTL language:'), 'name' => 'is_rtl', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'is_rtl_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Enable if this language is read from right to left') . ' ' . $this->l('(Experimental: your theme must be compliant with RTL languages)')), array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Activate this language')), array('type' => 'special', 'name' => 'resultCheckLangPack', 'text' => $this->l('Check to see if a language pack is available for this ISO code.'), 'img' => 'ajax-loader.gif')));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save   '), 'class' => 'button');
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     if ($obj->id && !$obj->checkFiles()) {
         $this->fields_form['new'] = array('legend' => array('title' => $this->l('Warning'), 'image' => '../img/admin/warning.gif'), 'list_files' => array(array('label' => $this->l('Translation files:'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'tr', true)), array('label' => $this->l('Theme files:'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'theme', true)), array('label' => $this->l('Mail files:'), 'files' => Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'mail', true))));
     }
     $this->fields_value = array('ps_version' => _PS_VERSION_);
     $this->addJS(_PS_JS_DIR_ . 'checkLangPack.js');
     return parent::renderForm();
 }
 public function submitExportLang()
 {
     global $currentIndex;
     $lang = strtolower(Tools::getValue('iso_code'));
     $theme = strval(Tools::getValue('theme'));
     if ($lang and $theme) {
         $items = array_flip(Language::getFilesList($lang, $theme, false, false, false, false, true));
         $gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_ . '/export/' . $lang . '.gzip', true);
         if ($gz->createModify($items, NULL, _PS_ROOT_DIR_)) {
         }
         Tools::redirect('translations/export/' . $lang . '.gzip');
         $this->_errors[] = Tools::displayError('An error occurred while creating archive.');
     }
     $this->_errors[] = Tools::displayError('Please choose a language and theme.');
 }
 public function delete()
 {
     if (!$this->hasMultishopEntries() || Shop::getContext() == Shop::CONTEXT_ALL) {
         if (empty($this->iso_code)) {
             $this->iso_code = Language::getIsoById($this->id);
         }
         // Database translations deletion
         $result = Db::getInstance()->executeS('SHOW TABLES FROM `' . _DB_NAME_ . '`');
         foreach ($result as $row) {
             if (isset($row['Tables_in_' . _DB_NAME_]) && !empty($row['Tables_in_' . _DB_NAME_]) && preg_match('/' . preg_quote(_DB_PREFIX_) . '_lang/', $row['Tables_in_' . _DB_NAME_])) {
                 if (!Db::getInstance()->execute('DELETE FROM `' . $row['Tables_in_' . _DB_NAME_] . '` WHERE `id_lang` = ' . (int) $this->id)) {
                     return false;
                 }
             }
         }
         // Delete tags
         Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'tag WHERE id_lang = ' . (int) $this->id);
         // Delete search words
         Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'search_word WHERE id_lang = ' . (int) $this->id);
         // Files deletion
         foreach (Language::getFilesList($this->iso_code, _THEME_NAME_, false, false, false, true, true) as $key => $file) {
             if (file_exists($key)) {
                 unlink($key);
             }
         }
         $modList = scandir(_PS_MODULE_DIR_);
         foreach ($modList as $mod) {
             Language::recurseDeleteDir(_PS_MODULE_DIR_ . $mod . '/mails/' . $this->iso_code);
             $files = @scandir(_PS_MODULE_DIR_ . $mod . '/mails/');
             if (count($files) <= 2) {
                 Language::recurseDeleteDir(_PS_MODULE_DIR_ . $mod . '/mails/');
             }
             if (file_exists(_PS_MODULE_DIR_ . $mod . '/' . $this->iso_code . '.php')) {
                 unlink(_PS_MODULE_DIR_ . $mod . '/' . $this->iso_code . '.php');
                 $files = @scandir(_PS_MODULE_DIR_ . $mod);
                 if (count($files) <= 2) {
                     Language::recurseDeleteDir(_PS_MODULE_DIR_ . $mod);
                 }
             }
         }
         if (file_exists(_PS_MAIL_DIR_ . $this->iso_code)) {
             Language::recurseDeleteDir(_PS_MAIL_DIR_ . $this->iso_code);
         }
         if (file_exists(_PS_TRANSLATIONS_DIR_ . $this->iso_code)) {
             Language::recurseDeleteDir(_PS_TRANSLATIONS_DIR_ . $this->iso_code);
         }
         $images = array('.jpg', '-default-' . ImageType::getFormatedName('thickbox') . '.jpg', '-default-' . ImageType::getFormatedName('home') . '.jpg', '-default-' . ImageType::getFormatedName('large') . '.jpg', '-default-' . ImageType::getFormatedName('medium') . '.jpg', '-default-' . ImageType::getFormatedName('small') . '.jpg');
         $images_directories = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
         foreach ($images_directories as $image_directory) {
             foreach ($images as $image) {
                 if (file_exists($image_directory . $this->iso_code . $image)) {
                     unlink($image_directory . $this->iso_code . $image);
                 }
                 if (file_exists(_PS_ROOT_DIR_ . '/img/l/' . $this->id . '.jpg')) {
                     unlink(_PS_ROOT_DIR_ . '/img/l/' . $this->id . '.jpg');
                 }
             }
         }
     }
     if (!parent::delete()) {
         return false;
     }
     return true;
 }
示例#6
0
 public function delete()
 {
     if (!$this->hasMultishopEntries()) {
         if (empty($this->iso_code)) {
             $this->iso_code = Language::getIsoById($this->id);
         }
         // Database translations deletion
         $result = Db::getInstance()->executeS('SHOW TABLES FROM `' . _DB_NAME_ . '`');
         foreach ($result as $row) {
             if (isset($row['Tables_in_' . _DB_NAME_]) && !empty($row['Tables_in_' . _DB_NAME_]) && preg_match('/_lang/', $row['Tables_in_' . _DB_NAME_])) {
                 if (!Db::getInstance()->execute('DELETE FROM `' . $row['Tables_in_' . _DB_NAME_] . '` WHERE `id_lang` = ' . (int) $this->id)) {
                     return false;
                 }
             }
         }
         // Delete tags
         Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'tag WHERE id_lang = ' . (int) $this->id);
         // Delete search words
         Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'search_word WHERE id_lang = ' . (int) $this->id);
         // Files deletion
         foreach (Language::getFilesList($this->iso_code, _THEME_NAME_, false, false, false, true, true) as $key => $file) {
             if (file_exists($key)) {
                 unlink($key);
             }
         }
         $modList = scandir(_PS_MODULE_DIR_);
         foreach ($modList as $mod) {
             Language::recurseDeleteDir(_PS_MODULE_DIR_ . $mod . '/mails/' . $this->iso_code);
             $files = @scandir(_PS_MODULE_DIR_ . $mod . '/mails/');
             if (count($files) <= 2) {
                 Language::recurseDeleteDir(_PS_MODULE_DIR_ . $mod . '/mails/');
             }
             if (file_exists(_PS_MODULE_DIR_ . $mod . '/' . $this->iso_code . '.php')) {
                 unlink(_PS_MODULE_DIR_ . $mod . '/' . $this->iso_code . '.php');
                 $files = @scandir(_PS_MODULE_DIR_ . $mod);
                 if (count($files) <= 2) {
                     Language::recurseDeleteDir(_PS_MODULE_DIR_ . $mod);
                 }
             }
         }
         if (file_exists(_PS_MAIL_DIR_ . $this->iso_code)) {
             Language::recurseDeleteDir(_PS_MAIL_DIR_ . $this->iso_code);
         }
         if (file_exists(_PS_TRANSLATIONS_DIR_ . $this->iso_code)) {
             Language::recurseDeleteDir(_PS_TRANSLATIONS_DIR_ . $this->iso_code);
         }
     }
     if (!parent::delete()) {
         return false;
     }
     if (!$this->hasMultishopEntries()) {
         // delete images
         $files_copy = array('/en.jpg', '/en-default-thickbox_default.jpg', '/en-default-home_default.jpg', '/en-default-large_default.jpg', '/en-default-medium_default.jpg', '/en-default-small_default.jpg');
         $tos = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
         foreach ($tos as $to) {
             foreach ($files_copy as $file) {
                 $name = str_replace('/en', '' . $this->iso_code, $file);
                 if (file_exists($to . $name)) {
                     unlink($to . $name);
                 }
                 if (file_exists(dirname(__FILE__) . '/../img/l/' . $this->id . '.jpg')) {
                     unlink(dirname(__FILE__) . '/../img/l/' . $this->id . '.jpg');
                 }
             }
         }
     }
     return Tools::generateHtaccess();
 }
 public function submitExportLang()
 {
     if ($this->lang_selected->iso_code && $this->theme_selected) {
         $this->exportTabs();
         $items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true));
         $gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_ . '/export/' . $this->lang_selected->iso_code . '.gzip', true);
         $file_name = Tools::getCurrentUrlProtocolPrefix() . Tools::getShopDomain() . __PS_BASE_URI__ . 'translations/export/' . $this->lang_selected->iso_code . '.gzip';
         if ($gz->createModify($items, null, _PS_ROOT_DIR_)) {
         }
         ob_start();
         header('Pragma: public');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Cache-Control: public');
         header('Content-Description: File Transfer');
         header('Content-type: application/octet-stream');
         header('Content-Disposition: attachment; filename="' . $this->lang_selected->iso_code . '.gzip' . '"');
         header('Content-Transfer-Encoding: binary');
         ob_end_flush();
         @readfile($file_name);
         exit;
         $this->errors[] = Tools::displayError('An error occurred while creating archive.');
     }
     $this->errors[] = Tools::displayError('Please choose a language and a theme.');
 }
    public function displayForm($isMainTab = true)
    {
        global $currentIndex;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        echo '
		<script type="text/javascript">
		var langPackOk = "<img src=\\"' . _PS_IMG_ . 'admin/information.png\\" alt=\\"\\" /> ' . $this->l('A language pack is available for this ISO (name is') . '";
		var langPackVersion = "' . $this->l('The compatible Prestashop version for this language and your system is: ') . '";
		var langPackInfo = "' . $this->l('After creating the language, you can import the content of the language pack, which you can download above under "Tools - Translations"') . '";
		var noLangPack = "<img src=\\"' . _PS_IMG_ . 'admin/information.png\\" alt=\\"\\" /> ' . $this->l('No language pack available on prestashop.com for this ISO code') . '";
		var download = "' . $this->l('Download') . '";
		</script>
		<script type="text/javascript" src="' . _PS_JS_DIR_ . 'checkLangPack.js"></script>
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/world.gif" />' . $this->l('Languages') . '</legend>
				<input type="hidden" value="' . _PS_VERSION_ . '" name="ps_version" id="ps_version" />
				<label>' . $this->l('Name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="8" maxlength="32" name="name" value="' . htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('ISO code:') . ' </label>
				<div class="margin-form">
					<input type="text" size="4" maxlength="2" name="iso_code" id="iso_code" value="' . htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="checkLangPack();" /> <sup>*</sup>
					<p>' . $this->l('2-letter ISO code (e.g., fr, en, de)') . '</p>
				</div>
				<label>' . $this->l('Language code:') . ' </label>
				<div class="margin-form">
					<input type="text" size="10" maxlength="5" name="language_code" id="language_code" value="' . htmlentities($this->getFieldValue($obj, 'language_code'), ENT_COMPAT, 'UTF-8') . '"/> <sup>*</sup>
					<p>' . $this->l('Full language code (e.g., en-us, pt-br)') . '</p>
				</div>
				<label>' . $this->l('Flag:') . ' </label>
				<div class="margin-form">
					<input type="file" name="flag" /> <sup>*</sup>
					<p>' . $this->l('Upload country flag from your computer') . '</p>
				</div>
				<label>' . $this->l('"No-picture" image:') . ' </label>
				<div class="margin-form">
					<input type="file" name="no-picture" /> <sup>*</sup>
					<p>' . $this->l('Image displayed when "no picture found"') . '</p>
				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . ((!$this->getFieldValue($obj, 'active') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Allow or disallow this language to be selected by the customer') . '</p>
				</div>
				<p id="resultCheckLangPack"><img src="' . _PS_IMG_ . 'admin/ajax-loader.gif" alt="" /> ' . $this->l('Check if a language pack is available for this ISO code...') . '</p>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
        if ($obj->id and !$obj->checkFiles()) {
            echo '
			<br /><br />
			<fieldset style="width:572px;"><legend><img src="../img/admin/warning.gif" />' . $this->l('Warning') . '</legend>
					<p>' . $this->l('This language is NOT complete and cannot be used in the Front or Back Office because some files are missing.') . '</p>
					<br />
					<label>' . $this->l('Translations files:') . ' </label>
					<div class="margin-form" style="margin-top:4px;">';
            $files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'tr', true);
            $this->displayFilesList($files);
            echo '
					</div><br style="clear:both;" />
					<label>' . $this->l('Theme files:') . ' </label>
					<div class="margin-form" style="margin-top:4px;">';
            $files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'theme', true);
            $this->displayFilesList($files);
            echo '
					</div><br style="clear:both;" />
					<label>' . $this->l('Mail files:') . ' </label>
					<div class="margin-form" style="margin-top:4px;">';
            $files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'mail', true);
            $this->displayFilesList($files);
            echo '
					</div>
					<br />
					<div class="small">' . $this->l('Missing files are marked in red') . '</div>
			</fieldset>';
        }
    }
 public function submitExportLang()
 {
     if ($this->lang_selected->iso_code && $this->theme_selected) {
         $this->exportTabs();
         $items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true));
         $file_name = _PS_TRANSLATIONS_DIR_ . '/export/' . $this->lang_selected->iso_code . '.gzip';
         $gz = new \Archive_Tar($file_name, true);
         if ($gz->createModify($items, null, _PS_ROOT_DIR_)) {
             ob_start();
             header('Pragma: public');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Cache-Control: public');
             header('Content-Description: File Transfer');
             header('Content-type: application/octet-stream');
             header('Content-Disposition: attachment; filename="' . $this->lang_selected->iso_code . '.gzip' . '"');
             header('Content-Transfer-Encoding: binary');
             ob_end_flush();
             readfile($file_name);
             @unlink($file_name);
             exit;
         }
         $this->errors[] = $this->trans('An error occurred while creating archive.', array(), 'Admin.International.Notification');
     }
     $this->errors[] = $this->trans('Please select a language and a theme.', array(), 'Admin.International.Notification');
 }
    public function displayForm()
    {
        global $currentIndex;
        $obj = $this->loadObject(true);
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data" class="width3">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/world.gif" />' . $this->l('Languages') . '</legend>
				<label>' . $this->l('Name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="8" maxlength="32" name="name" value="' . htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('ISO code:') . ' </label>
				<div class="margin-form">
					<input type="text" size="4" maxlength="2" name="iso_code" value="' . htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					<p>' . $this->l('2-letter ISO code (e.g., fr, en, de)') . '</p>
				</div>
				<label>' . $this->l('Flag:') . ' </label>
				<div class="margin-form">
					<input type="file" name="flag" /> <sup>*</sup>
					<p>' . $this->l('Upload country flag from your computer') . '</p>
				</div>
				<label>' . $this->l('"No-picture" image:') . ' </label>
				<div class="margin-form">
					<input type="file" name="no-picture" /> <sup>*</sup>
					<p>' . $this->l('Image displayed when "no picture found"') . '</p>
				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . ((!$this->getFieldValue($obj, 'active') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Allow or disallow this language to be selected by the customer') . '</p>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
        if ($obj->id and !$obj->checkFiles()) {
            echo '
			<br /><br />
			<fieldset style="width:572px;"><legend><img src="../img/admin/warning.gif" />' . $this->l('Warning') . '</legend>
					<p>' . $this->l('This language is NOT complete and cannot be used in the Front or Back Office because some files are missing.') . '</p>
					<br />
					<label>' . $this->l('Translations files:') . ' </label>
					<div class="margin-form" style="margin-top:4px;">';
            $files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'tr', true);
            $this->displayFilesList($files);
            echo '
					</div><br style="clear:both;" />
					<label>' . $this->l('Theme files:') . ' </label>
					<div class="margin-form" style="margin-top:4px;">';
            $files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'theme', true);
            $this->displayFilesList($files);
            echo '
					</div><br style="clear:both;" />
					<label>' . $this->l('Mail files:') . ' </label>
					<div class="margin-form" style="margin-top:4px;">';
            $files = Language::getFilesList($obj->iso_code, _THEME_NAME_, false, false, 'mail', true);
            $this->displayFilesList($files);
            echo '
					</div>
					<br />
					<div class="small">' . $this->l('Missing files are marked in red') . '</div>
			</fieldset>';
        }
    }
 public function submitExportLang()
 {
     if ($this->lang_selected->iso_code && $this->theme_selected) {
         $this->exportTabs();
         $items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true));
         $gz = new Archive_Tar(_PS_TRANSLATIONS_DIR_ . '/export/' . $this->lang_selected->iso_code . '.gzip', true);
         $file_name = Tools::getCurrentUrlProtocolPrefix() . Tools::getShopDomain() . __PS_BASE_URI__ . 'translations/export/' . $this->lang_selected->iso_code . '.gzip';
         if ($gz->createModify($items, null, _PS_ROOT_DIR_)) {
         }
         Tools::redirectLink($file_name);
         $this->errors[] = Tools::displayError('An error occurred while creating archive.');
     }
     $this->errors[] = Tools::displayError('Please choose a language and a theme.');
 }