Skip to content

Commit

Permalink
Merge pull request #182 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Deploying 4.4.0 of autoupgrade
  • Loading branch information
Quetzacoalt91 authored Oct 18, 2018
2 parents 184904b + b9a047c commit 4db3726
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 24 deletions.
23 changes: 16 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ This module is compatible with all PrestaShop 1.6 & 1.7.
# Prerequisites

* PrestaShop 1.6 or 1.7
* PHP 5.6+
* PHP 5.6+

# Installation
For older PHP versions, see previous releases of the module [(ex. v1.6.8)](https://github.com/PrestaShop/autoupgrade/releases/tag/v1.6.8).
Note they are unsupported and we strongly recommend you to upgrade your PHP version.

You must have [composer][4] installed on your computer. Then, execute:
# Installation

```
$ composer install
```
All versions can be found in the [releases list](https://github.com/PrestaShop/autoupgrade/releases).
Zip archives can be directly uploaded on your module page.

# Running an upgrade on PrestaShop

Expand All @@ -42,7 +42,16 @@ $ php cli-upgrade.php --dir=admin-dev --channel=major

PrestaShop modules are open-source extensions to the PrestaShop e-commerce solution. Everyone is welcome and even encouraged to contribute with their own improvements.

### Requirements
To contribute on this project, start by cloning the repository.
You must have [composer][4] installed on your computer. Run the following command:

```
$ composer install
```

Your module will be available with development libraries.

### GitHub Requirements

Contributors **must** follow the following rules:

Expand Down
2 changes: 1 addition & 1 deletion autoupgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct()
$this->name = 'autoupgrade';
$this->tab = 'administration';
$this->author = 'PrestaShop';
$this->version = '4.2.0';
$this->version = '4.4.0';
$this->need_instance = 1;

$this->bootstrap = true;
Expand Down
2 changes: 1 addition & 1 deletion classes/UpgradePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private function _getJsErrorMsgs()
5 => $translator->trans('Cannot create settings file, if /app/config/parameters.php exists, please give the public write permissions to this file, else please create a file named parameters.php in config directory.', array(), $translationDomain),
6 => $translator->trans('Cannot write settings file, please create a file named settings.inc.php in the "config" directory.', array(), $translationDomain),
7 => $translator->trans('Impossible to upload the file!', array(), $translationDomain),
8 => $translator->trans('Data integrity is not valided. Hack attempt?', array(), $translationDomain),
8 => $translator->trans('Data integrity is not valid. Hack attempt?', array(), $translationDomain),
9 => $translator->trans('Impossible to read the content of a MySQL content file.', array(), $translationDomain),
10 => $translator->trans('Cannot access a MySQL content file.', array(), $translationDomain),
11 => $translator->trans('Error while inserting data in the database:', array(), $translationDomain),
Expand Down
2 changes: 1 addition & 1 deletion classes/UpgradeTools/CoreUpgrader/CoreUpgrader16.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function writeNewSettings()

$writer = new SettingsFileWriter($this->container->getTranslator());
$writer->writeSettingsFile(SETTINGS_FILE, $datas);
$this->logger->debug($this->container->getTranslator()->trans('Settings file updated'));
$this->logger->debug($this->container->getTranslator()->trans('Settings file updated', array(), 'Modules.Autoupgrade.Admin'));
}

protected function initConstants()
Expand Down
4 changes: 2 additions & 2 deletions classes/UpgradeTools/SettingsFileWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function migrateSettingsFile(LoggerInterface $logger)
public function writeSettingsFile($filePath, $data)
{
if (!is_writable($filePath)) {
throw new UpgradeException($this->translator->trans('Error when opening settings.inc.php file in write mode'));
throw new UpgradeException($this->translator->trans('Error when opening settings.inc.php file in write mode', array(), 'Modules.Autoupgrade.Admin'));
}

// Create backup file
Expand All @@ -68,7 +68,7 @@ public function writeSettingsFile($filePath, $data)
fwrite($fd, '<?php' . PHP_EOL);
foreach ($data as $name => $value) {
if (false === fwrite($fd, "define('$name', '{$this->checkString($value)}');" . PHP_EOL)) {
throw new UpgradeException($this->translator->trans('Error when generating new settings.inc.php file.'));
throw new UpgradeException($this->translator->trans('Error when generating new settings.inc.php file.', array(), 'Modules.Autoupgrade.Admin'));
}
}
fclose($fd);
Expand Down
19 changes: 14 additions & 5 deletions classes/UpgradeTools/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,26 @@ public function __construct($caller)
$this->caller = $caller;
}

public function trans($id, array $parameters = array(), $domain = null, $locale = null)
/**
* Translate a string to the current language
*
* This methods has the same signature as the 1.7 trans method, but only relies
* on the module translation files.
*
* @param string $id Original text
* @param array $parameters Parameters to apply
* @param string $domain Unused
* @param string $locale Unused
*
* @return string Translated string with parameters applied
*/
public function trans($id, array $parameters = array(), $domain = 'Modules.Autoupgrade.Admin', $locale = null)
{
// If PrestaShop core is not instancied properly, do not try to translate
if (!method_exists('\Context', 'getContext') || null === \Context::getContext()->language) {
return $this->applyParameters($id, $parameters);
}

if (method_exists('\Context', 'getTranslator')) {
return \Context::getContext()->getTranslator()->trans($id, $parameters, $domain, $locale);
}

if (method_exists('\Translate', 'getModuleTranslation')) {
$translated = \Translate::getModuleTranslation('autoupgrade', $id, $this->caller, null);
if (!count($parameters)) {
Expand Down
4 changes: 2 additions & 2 deletions classes/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
class Upgrader
{
const DEFAULT_CHECK_VERSION_DELAY_HOURS = 12;
const DEFAULT_CHANNEL = 'major';
const DEFAULT_CHANNEL = 'minor';
const DEFAULT_FILENAME = 'prestashop.zip';
// @todo channel handling :)

public $addons_api = 'api.addons.prestashop.com';
public $rss_channel_link = 'https://api.prestashop.com/xml/channel.xml';
public $rss_md5file_link_dir = 'https://api.prestashop.com/xml/md5/';
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>autoupgrade</name>
<displayName><![CDATA[1-Click Upgrade]]></displayName>
<version><![CDATA[4.2.0]]></version>
<version><![CDATA[4.4.0]]></version>
<description><![CDATA[Provides an automated method to upgrade your shop to the latest version of PrestaShop.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
3 changes: 1 addition & 2 deletions views/templates/block/channelInfo.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<div id="channel-infos" ><br>
{% if upgradeInfo.branch is not empty %}
<div style="clear:both">
Expand All @@ -16,7 +15,7 @@
<div class="all-infos">
{% if upgradeInfo.version_name is not empty %}
<div style="clear:both;">
<label class="label-small">{{ 'Name:'|trans }}</label>
<label class="label-small">{{ 'Name:'|trans({}, 'Admin.Global') }}</label>
<span class="name">{{ upgradeInfo.version_name }}</span>
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion views/templates/block/checklist.twig
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<tr>
<td>
{% if isPrestaShopReady %}
{{ 'PrestaShop requirements are satisfied. '|trans }}
{{ 'PrestaShop requirements are satisfied.'|trans }}
{% else %}
{{ 'PrestaShop requirements are not satisfied. [1]See details[/1] or [2]ignore[/2].'|trans({
'[1]': '<a href="' ~ informationsLink ~'">',
Expand Down
1 change: 0 additions & 1 deletion views/templates/block/upgradeButtonBlock.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<div class="bootstrap" id="upgradeButtonBlock">
<div class="panel">
<div class="panel-heading">
Expand Down

0 comments on commit 4db3726

Please sign in to comment.