Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 42 additions & 22 deletions classes/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManagerBuilder;
use PrestaShop\PrestaShop\Core\Cldr\Repository as cldrRepository;
use PrestaShop\PrestaShop\Core\Localization\RTL\StylesheetGenerator;

class LanguageCore extends ObjectModel
{
Expand Down Expand Up @@ -185,7 +186,7 @@ public function add($autodate = true, $nullValues = false, $only_add = false)
if (!parent::add($autodate, $nullValues)) {
return false;
}

if ($this->is_rtl) {
self::installRtlStylesheets(true, false, null, null, (defined('PS_INSTALLATION_IN_PROGRESS') ? true : false));
}
Expand All @@ -199,17 +200,17 @@ public function add($autodate = true, $nullValues = false, $only_add = false)

return true;
}

public function update($nullValues = false)
{
if (!parent::update($nullValues)) {
return false;
}

if ($this->is_rtl) {
self::installRtlStylesheets(true, false);
}

return true;
}

Expand Down Expand Up @@ -1335,37 +1336,56 @@ public static function updateMultilangFromClass($table, $className, $lang)
}
}
}

/**
* Language::installRtlStylesheets()
* @param bool $bo_theme
* @param bool $fo_theme
* @param null $theme_name
* @param null $iso
*
* @param bool $boTheme
* @param bool $foTheme
* @param string|null $themeName
* @param string|null $iso
* @param bool $install
* @param null $path
* @param string|null $path
*
* @throws \PrestaShop\PrestaShop\Core\Localization\RTL\Exception\GenerationException
* @throws Exception
*/
public static function installRtlStylesheets($bo_theme = false, $fo_theme = false, $theme_name = null, $iso = null, $install = false, $path = null)
public static function installRtlStylesheets($boTheme = false, $foTheme = false, $themeName = null, $iso = null, $install = false, $path = null)
{
$admin_dir = ($install) ? _PS_ROOT_DIR_.'/admin/' : _PS_ADMIN_DIR_.'/';
$front_dir = _PS_ROOT_DIR_.'/themes/';
if ($iso) {
$lang_pack = Language::getLangDetails($iso);
$lang_pack = static::getLangDetails($iso);
if (!$lang_pack['is_rtl']) {
return;
}
}

if ($bo_theme) {
\RTLGenerator::generate($admin_dir.'themes');

$generator = new StylesheetGenerator();

// generate stylesheets for BO themes
if ($boTheme) {
if (defined('_PS_ADMIN_DIR_')) {
$adminDir = _PS_ADMIN_DIR_;
} else {
$adminDir = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'admin';
$adminDir = (is_dir($adminDir)) ? $adminDir : ($adminDir.'-dev');
}

if (!is_dir($adminDir)) {
throw new Exception("Cannot generate BO themes: \"$adminDir\" is not a directory");
}

$generator->generateInDirectory($adminDir.DIRECTORY_SEPARATOR.'themes');
}

if ($fo_theme) {
\RTLGenerator::generate($front_dir.($theme_name?$theme_name:'classic'));

// generate stylesheets for BO themes
if ($foTheme) {
$frontDir = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR;

$generator->generateInDirectory($frontDir.($themeName?$themeName:'classic'));
}

if ($path && is_dir($path)) {
\RTLGenerator::generate($path);
$generator->generateInDirectory($path);
}
}
}
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"phpoffice/phpexcel": "~1.8",
"guzzlehttp/guzzle": "~5.0",
"csa/guzzle-bundle": "~1.3",
"ipresta/localize-fixture": "~v1.0",
"paragonie/random_compat": "^1.4|^2.0",
"prestashop/smarty": "dev-master",
"prestashop/blockreassurance": "^3",
Expand Down Expand Up @@ -97,8 +96,15 @@
"beberlei/DoctrineExtensions": "^1.0",
"composer/ca-bundle": "^1.0",
"nikic/php-parser": "^2.1",
"prestashop/decimal": "^1.0.0"
"prestashop/decimal": "^1.0.0",
"cssjanus/cssjanus": "dev-patch-1"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/prestashop/php-cssjanus"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please describe what is the reason of that fork?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long story short -- it doesn't handle some CSS files. You can learn more here: https://github.com/cssjanus/php-cssjanus/pull/13

The idea is to come back to the original library if/when the maintainer decides to merge that PR.

}
],
"require-dev": {
"phpunit/phpunit": "~4.5",
"symfony/phpunit-bridge": "~3.1.3",
Expand Down
79 changes: 47 additions & 32 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/Core/Localization/RTL/Exception/GenerationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* 2007-2018 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:
* https://opensource.org/licenses/OSL-3.0
* 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-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

namespace PrestaShop\PrestaShop\Core\Localization\RTL\Exception;

class GenerationException extends \Exception
{
}
Loading