// Merge -> revision 8952

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8957 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-10-03 09:14:01 +00:00
parent f1e265fad4
commit ef17d0b7da
44 changed files with 622 additions and 366 deletions
+27 -9
View File
@@ -24,6 +24,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if(!defined('_PS_ADMIN_DIR_'))
define('_PS_ADMIN_DIR_', _PS_ADMIN_DIR_);
if(!defined('_PS_USE_SQL_SLAVE_'))
@@ -480,10 +481,11 @@ $this->standalone = true;
else
{
// echo '<img src="'.$originalCore.'" /> '.
$this->nextParams['msg'] = ($testOrigCore?$this->l('Core files are ok'):sprintf($this->l('%s core files have been modified'), sizeof($changedFileList)));
$this->nextParams['msg'] = ($testOrigCore?$this->l('Core files are ok'):sprintf($this->l('%1$s core files have been modified (%2$s total)'), count($changedFileList['core']), count(array_merge($changedFileList['core'], $changedFileList['mail'], $changedFileList['translation']))));
}
$this->nextParams['result'] = $changedFileList;
}
public function ajaxProcessUpgradeNow()
{
$this->nextDesc = $this->l('Starting upgrade ...');
@@ -1727,6 +1729,9 @@ echo '</script>';
#dbResultCheck{ padding-left:20px;}
#checkPrestaShopFilesVersion{margin-bottom:20px;}
#changedList ul{list-style-type:circle}
.changedFileList {margin-left:20px; padding-left:5px;}
.changedNotice li{color:lightgrey;}
.changedImportant li{color:red;font-weight:bold}
</style>';
$this->displayWarning($this->l('This function is experimental. It\'s highly recommended to make a backup of your files and database before starting the upgrade process.'));
@@ -1870,7 +1875,7 @@ function handleXMLResult(xmlRet, previousParams)
switch(previousParams.upgradeDbStep)
{
case 0: // getVersionFromDb
result = "ok";
resGlobal.result = "ok";
break;
case 1: // getVersionFromDb
result = resGlobal.result;
@@ -2134,6 +2139,19 @@ function handleError(res)
}
';
// ajax to check md5 files
$js .= 'function addModifiedFileList(title, fileList, css_class)
{
subList = $("<ul class=\"changedFileList "+css_class+"\"></ul>");
$(fileList).each(function(k,v){
$(subList).append("<li>"+v+"</li>");
});
$("#changedList").append("<h3><a class=\"toggleSublist\">"+title+"</a></h3>");
$("#changedList").append(subList);
$("#cchangedList").append("<br/>");
}';
$js.= '$(document).ready(function(){
$.ajax({
type:"POST",
@@ -2155,16 +2173,15 @@ $js.= '$(document).ready(function(){
$("#checkPrestaShopFilesVersion").prepend("<img src=\"../img/admin/warning.gif\" /> ");
else
{
$("#checkPrestaShopFilesVersion").prepend(answer.status);
$("#checkPrestaShopFilesVersion").prepend("<img src=\"../img/admin/warning.gif\" /> ");
$("#checkPrestaShopFilesVersion").append("<a id=\"toggleChangedList\" class=\"button\" href=\"\">'.$this->l('See or hide the list').'</a><br/>");
$("#checkPrestaShopFilesVersion").append("<div id=\"changedList\" style=\"display:none \">");
$("#changedList").html("<ul>");
$(answer.result).each(function(k,v){
$("#changedList ul").append("<li>"+v+"</li>");
});
$("#checkPrestaShopFilesVersion").append("<div id=\"changedList\" style=\"display:none \"><br/>");
addModifiedFileList("'.$this->l('Core files').'", answer.result.core, "changedImportant");
addModifiedFileList("'.$this->l('Mail files').'", answer.result.mail, "changedNotice");
addModifiedFileList("'.$this->l('Translation files').'", answer.result.translation, "changedNotice");
$("#toggleChangedList").bind("click",function(e){e.preventDefault();$("#changedList").toggle();});
$(".toggleSublist").live("click",function(e){e.preventDefault();$(this).parent().next().toggle();});
}
}
,
@@ -2183,6 +2200,7 @@ $("#toggleChangedList").bind("click",function(e){e.preventDefault();$("#changedL
});';
return $js;
}
private function _cleanUp($path)
{
// as we need theses files for restore operation, we can't remove them.
+35 -12
View File
@@ -165,18 +165,37 @@ class UpgraderCore
}
return $this->changed_files;
}
/** populate $this->changed_files with $path
* in sub arrays mail, translation and core items
* @param string $path filepath to add, relative to _PS_ROOT_DIR_
*/
protected function addChangedFile($path)
{
$this->version_is_modified = true;
$this->changed_files[] = $path;
//array_unique($this->changed_files);
if (strpos($path, 'mails/') !== false)
$this->changed_files['mail'][] = $path;
else if (
strpos($path, '/en.php') !== false
|| strpos($path, '/fr.php') !== false
|| strpos($path, '/es.php') !== false
|| strpos($path, '/it.php') !== false
|| strpos($path, '/de.php') !== false
|| strpos($path, 'translations/') !== false
)
$this->changed_files['translation'][] = $path;
else
$this->changed_files['core'][] = $path;
}
/** populate $this->missing_files with $path
* @param string $path filepath to add, relative to _PS_ROOT_DIR_
*/
protected function addMissingFile($path)
{
$this->version_is_modified = true;
$this->missing_files[] = $path;
//array_unique($this->missingFile);
}
protected function browseXmlAndCompare($node, &$current_path = array(), $level = 1)
@@ -190,18 +209,22 @@ class UpgraderCore
}
else if (is_object($child) && $child->getName() == 'md5file')
{
$path = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR;
// We will store only relative path.
// absolute path is only used for file_exists and compare
$relative_path = '';
for ($i = 1; $i < $level; $i++)
$path .= $current_path[$i].'/';
$path .= (string)$child['name'];
$path = str_replace('ps_root_dir',_PS_ROOT_DIR_,$path);
$relative_path .= $current_path[$i].'/';
$relative_path .= (string)$child['name'];
$fullpath = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR . $relative_path;
$fullpath = str_replace('ps_root_dir', _PS_ROOT_DIR_, $fullpath);
// replace default admin dir by current one
$path = str_replace(_PS_ROOT_DIR_.'/admin', _PS_ADMIN_DIR_, $path);
if(!file_exists($path))
$this->addMissingFile($path);
else if (!$this->compareChecksum($path, (string)$child))
$this->addChangedFile($path);
$fullpath = str_replace(_PS_ROOT_DIR_.'/admin', _PS_ADMIN_DIR_, $fullpath);
if (!file_exists($fullpath))
$this->addMissingFile($relative_path);
else if (!$this->compareChecksum($fullpath, (string)$child))
$this->addChangedFile($relative_path);
// else, file is original (and ok)
}
}
+42 -17
View File
@@ -1,8 +1,33 @@
<?php
/*
* 2007-2011 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 license@prestashop.com 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 <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class Autoupgrade extends Module
{
function __construct()
public function __construct()
{
$this->name = 'autoupgrade';
$this->tab = 'administration';
@@ -25,15 +50,16 @@ class Autoupgrade extends Module
$this->description = $this->l('Provides an automated method to upgrade your shop to the last PrestaShop version');
}
function install()
public function install()
{
$res = true;
// before adding AdminSelfUpgrade, we should remove AdminUpgrade
$idTab = Tab::getIdFromClassName('AdminUpgrade');
$idTab = Tab::getIdFromClassName('AdminUpgrade');
if ($idTab)
{
if ($idTab)
{
$tab = new Tab($idTab);
$res &= $tab->delete();
}
@@ -46,17 +72,17 @@ class Autoupgrade extends Module
$tab->class_name = 'AdminSelfUpgrade';
$tab->module = 'autoupgrade';
$tab->id_parent = 9;
$tab->name = array_fill(1,sizeof(Language::getLanguages(false)), 'Upgrade');
$tab->name = array_fill(1, sizeof(Language::getLanguages(false)), 'Upgrade');
$res &= $tab->save();
}
else
$tab = new Tab($idTab);
Configuration::updateValue('PS_AUTOUPDATE_MODULE_IDTAB',$tab->id);
Configuration::updateValue('PS_AUTOUPDATE_MODULE_IDTAB',$tab->id);
$autoupgradeDir = _PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'autoupgrade';
if(!file_exists($autoupgradeDir))
if (!file_exists($autoupgradeDir))
$res &= @mkdir($autoupgradeDir);
if(file_exists($autoupgradeDir.DIRECTORY_SEPARATOR.'ajax-upgradetab.php'))
if (file_exists($autoupgradeDir.DIRECTORY_SEPARATOR.'ajax-upgradetab.php'))
$res &= unlink($autoupgradeDir.DIRECTORY_SEPARATOR.'ajax-upgradetab.php');
if (!defined('_PS_MODULE_DIR_'))
{
@@ -67,36 +93,35 @@ class Autoupgrade extends Module
$res &= copy(_PS_MODULE_DIR_.'autoupgrade/logo.gif',_PS_ROOT_DIR_. DIRECTORY_SEPARATOR . 'img/t/AdminSelfUpgrade.gif');
if (!$res
OR !Tab::getIdFromClassName('AdminSelfUpgrade')
OR !parent::install()
|| !Tab::getIdFromClassName('AdminSelfUpgrade')
|| !parent::install()
)
return false;
return true;
}
public function uninstall()
{
$idtab = Configuration::get('PS_AUTOUPDATE_MODULE_IDTAB');
$tab = new Tab($idtab,1);
$res = $tab->delete();
if(file_exists(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'tabs'.'AdminUpgrade.php'))
if (file_exists(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'tabs'.'AdminUpgrade.php'))
{
// Should we create the correct AdminUpgrade tab (not the module)
if($idOldTab = Tab::getIdFromClassName('AdminUpgrade'))
{
$tab = new Tab($idOldTab);
$res &= $tab->delete();
}
}
$res &= unlink(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'tabs'.'AdminUpgrade.php');
}
if (file_exists(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'autoupgrade'.DIRECTORY_SEPARATOR.'ajax-upgradetab.php'))
$res &= @unlink(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'autoupgrade'.DIRECTORY_SEPARATOR.'ajax-upgradetab.php');
if (!$res OR !parent::uninstall())
if (!$res || !parent::uninstall())
return false;
return true;
}
}
}