PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/controllers/admin/AdminPaymentController.php

https://gitlab.com/goolic/PrestaShop
PHP | 126 lines | 86 code | 16 blank | 24 comment | 16 complexity | 455f7b75f162ab5f12da04b25eef4a8a 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. class AdminPaymentControllerCore extends AdminController
  27. {
  28. public $payment_modules = array();
  29. public function __construct()
  30. {
  31. $this->bootstrap = true;
  32. parent::__construct();
  33. }
  34. public function initToolbarTitle()
  35. {
  36. $this->toolbar_title = array_unique($this->breadcrumbs);
  37. }
  38. public function initPageHeaderToolbar()
  39. {
  40. parent::initPageHeaderToolbar();
  41. $this->page_header_toolbar_btn = array();
  42. }
  43. public function postProcess()
  44. {
  45. if (Tools::getValue('action') == 'GetModuleQuickView' && Tools::getValue('ajax') == '1') {
  46. $this->ajaxProcessGetModuleQuickView();
  47. }
  48. if ($this->action) {
  49. $this->saveRestrictions($this->action);
  50. }
  51. }
  52. public function initContent()
  53. {
  54. $this->display = 'view';
  55. return parent::initContent();
  56. }
  57. public function setMedia()
  58. {
  59. parent::setMedia();
  60. $this->addJqueryPlugin('fancybox');
  61. }
  62. public function renderView()
  63. {
  64. $this->toolbar_title = $this->l('Payment');
  65. unset($this->toolbar_btn['back']);
  66. $shop_context = (!Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP);
  67. if (!$shop_context) {
  68. $this->tpl_view_vars = array('shop_context' => $shop_context);
  69. return parent::renderView();
  70. }
  71. $this->tpl_view_vars = array(
  72. 'modules_list' => $this->renderModulesList('back-office,AdminPayment,index'),
  73. 'ps_base_uri' => __PS_BASE_URI__,
  74. 'url_submit' => self::$currentIndex.'&token='.$this->token,
  75. 'shop_context' => $shop_context
  76. );
  77. return parent::renderView();
  78. }
  79. public function renderModulesList($tracking_source = false)
  80. {
  81. if ($this->getModulesList($this->filter_modules_list, $tracking_source)) {
  82. $active_list = array();
  83. foreach ($this->modules_list as $key => $module) {
  84. if (in_array($module->name, $this->list_partners_modules)) {
  85. $this->modules_list[$key]->type = 'addonsPartner';
  86. }
  87. if (isset($module->description_full) && trim($module->description_full) != '') {
  88. $module->show_quick_view = true;
  89. }
  90. if ($module->active) {
  91. $active_list[] = $module;
  92. } else {
  93. $unactive_list[] = $module;
  94. }
  95. }
  96. $helper = new Helper();
  97. $fetch = '';
  98. if (isset($active_list)) {
  99. $this->context->smarty->assign('panel_title', $this->l('Active payment'));
  100. $fetch = $helper->renderModulesList($active_list);
  101. }
  102. $this->context->smarty->assign(array(
  103. 'panel_title' => $this->l('Recommended payment gateways'),
  104. 'view_all' => true
  105. ));
  106. $fetch .= $helper->renderModulesList($unactive_list);
  107. return $fetch;
  108. }
  109. }
  110. }