Skip to content

Commit

Permalink
//added methode to write default content in index.php file && added c…
Browse files Browse the repository at this point in the history
…heck in translation pack import
  • Loading branch information
vAugagneur committed Dec 28, 2012
1 parent a354697 commit aae9aa8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
41 changes: 41 additions & 0 deletions classes/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,47 @@ public static function generateHtaccess($path = null, $rewrite_settings = null,

return true;
}

public static function getDefaultIndexContent()
{
return '<?php
/*
* 2007-'.date('Y').' PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-'.date('Y').' PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;
';

}

/**
* jsonDecode convert json string to php array / object
Expand Down
9 changes: 8 additions & 1 deletion controllers/admin/AdminTranslationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,10 @@ public function submitImportLang()
{
foreach ($files_list as $file2check)
{
//don't validate index.php, will be overwrite when extract in translation directory
if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php')
continue;
if (preg_match('@^[0-9a-z-_/\\\\]+\.php$@i', $file2check['filename']))
{
if (!AdminTranslationsController::checkTranslationFile(file_get_contents($sandbox.$file2check['filename'])))
Expand All @@ -655,7 +659,6 @@ public function submitImportLang()
elseif (!preg_match('@^[0-9a-z-_/\\\\]+\.(html|tpl|txt)$@i', $file2check['filename']))
$this->errors[] = sprintf(Tools::displayError('Unidentified file found: %s'), $file2check['filename']);
}
}
Tools::deleteDirectory($sandbox, true);
Expand All @@ -664,6 +667,10 @@ public function submitImportLang()
if ($gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
{
foreach ($files_list as $file2check)
if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_.'../'.$file2check['filename'], Tools::getDefaultIndexContent()))
continue;
AdminTranslationsController::checkAndAddMailsFiles($iso_code, $files_list);
$this->checkAndAddThemesFiles($files_list, $themes_selected);
$tab_errors = AdminTranslationsController::addNewTabs($iso_code, $files_list);
Expand Down

0 comments on commit aae9aa8

Please sign in to comment.