Download project

This commit is contained in:
Roman Pyrih
2024-11-20 09:09:44 +01:00
parent 547a138d6a
commit 5ff041757f
40737 changed files with 7766183 additions and 0 deletions

View File

@@ -0,0 +1,152 @@
<?php
/**
* 2007-2016 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-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\TranslationToolsBundle\Translation\Helper;
class DomainHelper
{
/**
* @param string $localPath
*
* @return string
*/
public static function getCrowdinPath($localPath)
{
$segments = explode(DIRECTORY_SEPARATOR, $localPath);
$directorySegments = array_slice($segments, 0, 2);
if (count($directorySegments) !== count($segments)) {
return implode(DIRECTORY_SEPARATOR, $directorySegments) . DIRECTORY_SEPARATOR . implode('.', array_slice($segments, 2));
}
return implode(DIRECTORY_SEPARATOR, $directorySegments);
}
/**
* @param string $domain
*
* @return string
*/
public static function getExportPath($domain)
{
return str_replace('.', DIRECTORY_SEPARATOR, $domain);
}
/**
* @param string $exportPath
*
* @return string
*/
public static function getDomain($exportPath)
{
return str_replace(DIRECTORY_SEPARATOR, '.', $exportPath);
}
/**
* Builds a module domain name for the legacy system
*
* @param string $moduleName Name of the module (eg. ps_themecusto)
* @param string $sourceFileName Filename where the wording was found (eg. someFile.tpl)
*
* @return string The domain name (eg. Modules.Psthemecusto.somefile)
*/
public static function buildModuleDomainFromLegacySource($moduleName, $sourceFileName)
{
$transformedModuleName = self::buildModuleDomainNameComponent($moduleName);
if (empty($sourceFileName)) {
$source = self::transformDomainComponent($moduleName);
} else {
$source = strtolower(basename($sourceFileName, '.tpl'));
// sourced from https://github.com/PrestaShop/PrestaShop/blob/1.6.1.x/classes/Translate.php#L174-L178
if ('controller' == substr($source, -10, 10)) {
$source = substr($source, 0, -10);
}
$source = ucfirst($source);
}
$domain = 'Modules.' . $transformedModuleName . '.' . $source;
return $domain;
}
/**
* Returns the base domain for the provided module name
*
* @param string $moduleName
* @param bool $withDots True to use separating dots
*
* @return string
*/
public static function buildModuleBaseDomain($moduleName, $withDots = false)
{
$domain = 'Modules';
if ($withDots) {
$domain .= '.';
}
$domain .= self::buildModuleDomainNameComponent($moduleName);
return $domain;
}
/**
* Transforms the module name to use in a domain
*
* @param string $moduleName
*
* @return string
*/
private static function buildModuleDomainNameComponent($moduleName)
{
if ('ps_' === substr($moduleName, 0, 3)) {
$moduleName = substr($moduleName, 3);
}
return self::transformDomainComponent($moduleName);
}
/**
* Formats a domain component by removing unwanted characters
*
* @param string $component
*
* @return string
*/
private static function transformDomainComponent($component)
{
return ucfirst(
strtr(
strtolower($component),
['_' => '']
)
);
}
}

View File

@@ -0,0 +1,161 @@
<?php
/**
* 2007-2016 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-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
namespace PrestaShop\TranslationToolsBundle\Translation\Helper;
class LegacyHelper
{
/**
* @param string $inputFilename NB: Remove the working directory (eg: controllers/foo|themes/bar)
*
* @return array|null
*/
public static function getOutputInfo($inputFilename)
{
switch (1) {
case preg_match('#controllers/admin#', $inputFilename):
case preg_match('#override/controllers/admin#', $inputFilename):
case preg_match('#classes/helper#', $inputFilename):
return [
'file' => 'translations/[locale]/admin.php',
'var' => '_LANGADM',
'generateKey' => function ($string) use ($inputFilename) {
return self::getKeyPrefix($inputFilename) . self::getKey($string);
},
];
case preg_match('#^themes/([A-Za-z0-9_]+).+\.tpl$#', $inputFilename, $matches):
case preg_match('#^themes/([A-Za-z0-9_]+)(?!modules/)[a-zA-Z0-9/-]+(?!_ss\d|\d)\.tpl$#', $inputFilename, $matches):
return [
'file' => 'themes/' . $matches[1] . '/lang/[locale].php',
'var' => '_LANG',
'generateKey' => function ($string) use ($inputFilename) {
return pathinfo(basename($inputFilename), PATHINFO_FILENAME) . '_' . self::getKey($string);
},
];
// when we get a simple theme
case preg_match('#themes/([A-Za-z0-9_-]+).+\.tpl$#', $inputFilename, $matches):
return [
'file' => '/lang/[locale].php',
'var' => '_LANG',
'generateKey' => function ($string) use ($inputFilename) {
return pathinfo(basename($inputFilename), PATHINFO_FILENAME) . '_' . self::getKey($string);
},
];
case preg_match('#override/classes/pdf/(?!index)\w+\.php$#', $inputFilename):
case preg_match('#classes/pdf/(?!index)\w+\.php$#', $inputFilename):
return [
'file' => 'translations/[locale]/pdf.php',
'var' => '_LANGPDF',
'generateKey' => function ($string) {
return 'PDF' . self::getKey($string);
},
];
case preg_match('#(?:/|^)modules/([A-Za-z0-9_]+)/#', $inputFilename, $matches):
return [
'file' => 'modules/' . $matches[1] . '/translations/[locale].php',
'var' => '_MODULE',
'generateKey' => function ($string) use ($inputFilename, $matches) {
return '<{' . $matches[1] . '}prestashop>' . pathinfo(basename($inputFilename), PATHINFO_FILENAME) . '_' . self::getKey($string);
},
];
case preg_match('#^mails/#', $inputFilename):
return [
'file' => 'mails/[locale]/lang.php',
'var' => '_LANGMAIL',
'generateKey' => function ($string) {
return $string;
},
];
case preg_match('/fields_catalogue.php$/', $inputFilename):
return [
'file' => 'translations/[locale]/fields.php',
'var' => '_FIELDS',
'generateKey' => function ($string, $domain) {
return $domain . '_' . md5($string);
},
];
case preg_match('#controllers/admin/([A-Za-z]+)Controller.php$#', $inputFilename):
return [
'file' => 'translations/[locale]/tabs.php',
'var' => '_TABS',
'generateKey' => function () use ($inputFilename) {
return self::getKeyPrefix($inputFilename);
},
];
// case !preg_match('#tools/|cache/|\.tpl\.php$|[a-z]{2}\.php$#', $inputFilename) && preg_match('/\.php$/', $inputFilename):
// return [
// 'file' => 'translations/[locale]/errors.php',
// 'var' => '_ERRORS',
// 'generateKey' => function ($string) {
// return self::getKey($string);
// },
// ];
}
}
/**
* @param string $string
*
* @return string
*/
public static function getKey($string)
{
return md5(preg_replace("/\\\*'/", "\'", $string));
}
/**
* @param string $file
*
* @return string|null
*/
public static function getKeyPrefix($file)
{
$fileName = basename($file);
switch (${false} = true) {
case $fileName === 'AdminController.php':
return 'AdminController';
case $fileName === 'PaymentModule.php':
return 'PaymentModule';
case strpos($file, 'Helper') !== false:
return 'Helper';
case strpos($file, 'Controller.php') !== false:
return basename(substr($file, 0, -14));
}
}
}

View File

@@ -0,0 +1,45 @@
<?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 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-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\TranslationToolsBundle\Translation\Helper\Smarty;
/**
* Stub to support "module" as a resource in smarty files
*/
class SmartyResourceModule extends \Smarty_Resource_Custom
{
/**
* Fetch a template.
*
* @param string $name template name
* @param string $source template source
* @param int $mtime template modification timestamp (epoch)
*/
protected function fetch($name, &$source, &$mtime)
{
return;
}
}

View File

@@ -0,0 +1,45 @@
<?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 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-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\TranslationToolsBundle\Translation\Helper\Smarty;
/**
* Stub to support "parent" as a resource in smarty files
*/
class SmartyResourceParent extends \Smarty_Resource_Custom
{
/**
* Fetch a template.
*
* @param string $name template name
* @param string $source template source
* @param int $mtime template modification timestamp (epoch)
*/
protected function fetch($name, &$source, &$mtime)
{
return;
}
}