Dwstree.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Admin customer left menu
  8. */
  9. namespace Magento\Config\Block\System\Config;
  10. class Dwstree extends \Magento\Backend\Block\Widget\Tabs
  11. {
  12. /**
  13. * @return void
  14. */
  15. protected function _construct()
  16. {
  17. parent::_construct();
  18. $this->setId('system_config_dwstree');
  19. $this->setDestElementId('system_config_form');
  20. }
  21. /**
  22. * @return $this
  23. */
  24. public function initTabs()
  25. {
  26. $section = $this->getRequest()->getParam('section');
  27. $curWebsite = $this->getRequest()->getParam('website');
  28. $curStore = $this->getRequest()->getParam('store');
  29. $this->addTab(
  30. 'default',
  31. [
  32. 'label' => __('Default Config'),
  33. 'url' => $this->getUrl('*/*/*', ['section' => $section]),
  34. 'class' => 'default'
  35. ]
  36. );
  37. /** @var $website \Magento\Store\Model\Website */
  38. foreach ($this->_storeManager->getWebsites(true) as $website) {
  39. $wCode = $website->getCode();
  40. $wName = $website->getName();
  41. $wUrl = $this->getUrl('*/*/*', ['section' => $section, 'website' => $wCode]);
  42. $this->addTab('website_' . $wCode, ['label' => $wName, 'url' => $wUrl, 'class' => 'website']);
  43. if ($curWebsite === $wCode) {
  44. if ($curStore) {
  45. $this->_addBreadcrumb($wName, '', $wUrl);
  46. } else {
  47. $this->_addBreadcrumb($wName);
  48. }
  49. }
  50. /** @var $store \Magento\Store\Model\Store */
  51. foreach ($website->getStores() as $store) {
  52. $sCode = $store->getCode();
  53. $sName = $store->getName();
  54. $this->addTab(
  55. 'store_' . $sCode,
  56. [
  57. 'label' => $sName,
  58. 'url' => $this->getUrl(
  59. '*/*/*',
  60. ['section' => $section, 'website' => $wCode, 'store' => $sCode]
  61. ),
  62. 'class' => 'store'
  63. ]
  64. );
  65. if ($curStore === $sCode) {
  66. $this->_addBreadcrumb($sName);
  67. }
  68. }
  69. }
  70. if ($curStore) {
  71. $this->setActiveTab('store_' . $curStore);
  72. } elseif ($curWebsite) {
  73. $this->setActiveTab('website_' . $curWebsite);
  74. } else {
  75. $this->setActiveTab('default');
  76. }
  77. return $this;
  78. }
  79. }