/config/smartyadmin.config.inc.php

https://gitlab.com/staging06/myproject · PHP · 86 lines · 43 code · 10 blank · 33 comment · 12 complexity · 92cb26aaccfa0b102795a01683fb1bab MD5 · raw file

  1. <?php
  2. /*
  3. * 2007-2015 PrestaShop
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@prestashop.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
  18. * versions in the future. If you wish to customize PrestaShop for your
  19. * needs please refer to http://www.prestashop.com for more information.
  20. *
  21. * @author PrestaShop SA <contact@prestashop.com>
  22. * @copyright 2007-2015 PrestaShop SA
  23. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  24. * International Registered Trademark & Property of PrestaShop SA
  25. */
  26. global $smarty;
  27. $smarty->debugging = false;
  28. $smarty->debugging_ctrl = 'NONE';
  29. // Let user choose to force compilation
  30. $smarty->force_compile = (Configuration::get('PS_SMARTY_FORCE_COMPILE') == _PS_SMARTY_FORCE_COMPILE_) ? true : false;
  31. // But force compile_check since the performance impact is small and it is better for debugging
  32. $smarty->compile_check = true;
  33. function smartyTranslate($params, &$smarty)
  34. {
  35. $htmlentities = !isset($params['js']);
  36. $pdf = isset($params['pdf']);
  37. $addslashes = (isset($params['slashes']) || isset($params['js']));
  38. $sprintf = isset($params['sprintf']) ? $params['sprintf'] : null;
  39. if ($pdf) {
  40. return Translate::smartyPostProcessTranslation(Translate::getPdfTranslation($params['s'], $sprintf), $params);
  41. }
  42. $filename = ((!isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template)) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath());
  43. // If the template is part of a module
  44. if (!empty($params['mod'])) {
  45. return Translate::smartyPostProcessTranslation(Translate::getModuleTranslation($params['mod'], $params['s'], basename($filename, '.tpl'), $sprintf, isset($params['js'])), $params);
  46. }
  47. // If the tpl is at the root of the template folder
  48. if (dirname($filename) == '.') {
  49. $class = 'index';
  50. }
  51. // If the tpl is used by a Helper
  52. if (strpos($filename, 'helpers') === 0) {
  53. $class = 'Helper';
  54. }
  55. // If the tpl is used by a Controller
  56. else {
  57. if (!empty(Context::getContext()->override_controller_name_for_translations)) {
  58. $class = Context::getContext()->override_controller_name_for_translations;
  59. } elseif (isset(Context::getContext()->controller)) {
  60. $class_name = get_class(Context::getContext()->controller);
  61. $class = substr($class_name, 0, strpos(Tools::strtolower($class_name), 'controller'));
  62. } else {
  63. // Split by \ and / to get the folder tree for the file
  64. $folder_tree = preg_split('#[/\\\]#', $filename);
  65. $key = array_search('controllers', $folder_tree);
  66. // If there was a match, construct the class name using the child folder name
  67. // Eg. xxx/controllers/customers/xxx => AdminCustomers
  68. if ($key !== false) {
  69. $class = 'Admin'.Tools::toCamelCase($folder_tree[$key + 1], true);
  70. } elseif (isset($folder_tree[0])) {
  71. $class = 'Admin'.Tools::toCamelCase($folder_tree[0], true);
  72. }
  73. }
  74. }
  75. return Translate::smartyPostProcessTranslation(Translate::getAdminTranslation($params['s'], $class, $addslashes, $htmlentities, $sprintf), $params);
  76. }