Currency.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Manage currency block
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\CurrencySymbol\Block\Adminhtml\System;
  12. /**
  13. * @api
  14. * @since 100.0.2
  15. */
  16. class Currency extends \Magento\Backend\Block\Template
  17. {
  18. /**
  19. * @var string
  20. */
  21. protected $_template = 'Magento_CurrencySymbol::system/currency/rates.phtml';
  22. /**
  23. * Prepare layout
  24. *
  25. * @return \Magento\Framework\View\Element\AbstractBlock
  26. */
  27. protected function _prepareLayout()
  28. {
  29. $this->getToolbar()->addChild(
  30. 'save_button',
  31. \Magento\Backend\Block\Widget\Button::class,
  32. [
  33. 'label' => __('Save Currency Rates'),
  34. 'class' => 'save primary save-currency-rates',
  35. 'data_attribute' => [
  36. 'mage-init' => ['button' => ['event' => 'save', 'target' => '#rate-form']],
  37. ]
  38. ]
  39. );
  40. $onClick = "setLocation('" . $this->getUrl('adminhtml/system_config/edit/section/currency') . "')";
  41. $this->getToolbar()->addChild(
  42. 'options_button',
  43. \Magento\Backend\Block\Widget\Button::class,
  44. ['label' => __('Options'), 'onclick' => $onClick]
  45. );
  46. $this->getToolbar()->addChild(
  47. 'reset_button',
  48. \Magento\Backend\Block\Widget\Button::class,
  49. ['label' => __('Reset'), 'onclick' => 'document.location.reload()', 'class' => 'reset']
  50. );
  51. $this->addChild(
  52. 'import_button',
  53. \Magento\Backend\Block\Widget\Button::class,
  54. ['label' => __('Import'), 'class' => 'add', 'type' => 'submit']
  55. );
  56. $this->addChild('rates_matrix', \Magento\CurrencySymbol\Block\Adminhtml\System\Currency\Rate\Matrix::class);
  57. $this->addChild(
  58. 'import_services',
  59. \Magento\CurrencySymbol\Block\Adminhtml\System\Currency\Rate\Services::class
  60. );
  61. return parent::_prepareLayout();
  62. }
  63. /**
  64. * Get header
  65. *
  66. * @return \Magento\Framework\Phrase
  67. * @codeCoverageIgnore
  68. */
  69. public function getHeader()
  70. {
  71. return __('Manage Currency Rates');
  72. }
  73. /**
  74. * Get save button html
  75. *
  76. * @return string
  77. * @codeCoverageIgnore
  78. */
  79. public function getSaveButtonHtml()
  80. {
  81. return $this->getChildHtml('save_button');
  82. }
  83. /**
  84. * Get reset button html
  85. *
  86. * @return string
  87. * @codeCoverageIgnore
  88. */
  89. public function getResetButtonHtml()
  90. {
  91. return $this->getChildHtml('reset_button');
  92. }
  93. /**
  94. * Get import button html
  95. *
  96. * @return string
  97. * @codeCoverageIgnore
  98. */
  99. public function getImportButtonHtml()
  100. {
  101. return $this->getChildHtml('import_button');
  102. }
  103. /**
  104. * Get services html
  105. *
  106. * @return string
  107. * @codeCoverageIgnore
  108. */
  109. public function getServicesHtml()
  110. {
  111. return $this->getChildHtml('import_services');
  112. }
  113. /**
  114. * Get rates matrix html
  115. *
  116. * @return string
  117. * @codeCoverageIgnore
  118. */
  119. public function getRatesMatrixHtml()
  120. {
  121. return $this->getChildHtml('rates_matrix');
  122. }
  123. /**
  124. * Get import form action url
  125. *
  126. * @return string
  127. * @codeCoverageIgnore
  128. */
  129. public function getImportFormAction()
  130. {
  131. return $this->getUrl('adminhtml/*/fetchRates');
  132. }
  133. }