PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/components/bitrix/sale.bsm.site.master/wizard/updatesystemstep.php

https://gitlab.com/alexprowars/bitrix
PHP | 210 lines | 157 code | 25 blank | 28 comment | 8 complexity | 6fa0c48b8e5e601b6d5d1bad185b2036 MD5 | raw file
  1. <?php
  2. namespace Bitrix\Sale\BsmSiteMaster\Steps;
  3. use Bitrix\Main\Localization\Loc;
  4. Loc::loadMessages(__FILE__);
  5. /**
  6. * Class UpdateSystemStep
  7. * @package Bitrix\Sale\BsmSiteMaster\Steps
  8. */
  9. class UpdateSystemStep extends \CWizardStep
  10. {
  11. private $currentStepName = __CLASS__;
  12. /** @var \SaleBsmSiteMaster */
  13. private $component = null;
  14. /**
  15. * Prepare next/prev buttons
  16. *
  17. * @throws \ReflectionException
  18. */
  19. private function prepareButtons()
  20. {
  21. $steps = $this->component->getSteps($this->currentStepName);
  22. $shortClassName = (new \ReflectionClass($this))->getShortName();
  23. if (isset($steps["NEXT_STEP"]))
  24. {
  25. $this->SetNextStep($steps["NEXT_STEP"]);
  26. $this->SetNextCaption(Loc::getMessage("SALE_BSM_WIZARD_".mb_strtoupper($shortClassName)."_NEXT"));
  27. }
  28. if (isset($steps["PREV_STEP"]))
  29. {
  30. $this->SetPrevStep($steps["PREV_STEP"]);
  31. $this->SetPrevCaption(Loc::getMessage("SALE_BSM_WIZARD_".mb_strtoupper($shortClassName)."_PREV"));
  32. }
  33. }
  34. /**
  35. * Initialization step id and title
  36. *
  37. * @throws \ReflectionException
  38. */
  39. public function initStep()
  40. {
  41. $this->component = $this->GetWizard()->GetVar("component");
  42. $this->SetStepID($this->currentStepName);
  43. $this->SetTitle(Loc::getMessage("SALE_BSM_WIZARD_UPDATESYSTEMSTEP_TITLE"));
  44. $this->prepareButtons();
  45. }
  46. /**
  47. * @return bool
  48. */
  49. public function showStep()
  50. {
  51. $this->installModulesHtml();
  52. $modules = $this->GetWizard()->GetVar("not_exist_modules");
  53. $isMarketPlace = false;
  54. $isUpdateSystem = false;
  55. foreach (array_keys($modules) as $module)
  56. {
  57. if (mb_strpos($module, ".") !== false)
  58. {
  59. $isMarketPlace = true;
  60. }
  61. else
  62. {
  63. $isUpdateSystem = true;
  64. }
  65. }
  66. ob_start();
  67. ?>
  68. <div class="adm-bsm-site-master-paragraph-wrapper">
  69. <?php if ($isMarketPlace && $isUpdateSystem):?>
  70. <div class="adm-bsm-site-master-paragraph"><?=Loc::getMessage("SALE_BSM_WIZARD_UPDATESYSTEMSTEP_ALL_DESCR", [
  71. "#MARKET_PLACE_LINK#" => "/bitrix/admin/update_system_market.php?module=bitrix.eshop&lang=".LANGUAGE_ID,
  72. "#UPDATE_SYSTEM_LINK#" => "/bitrix/admin/update_system.php?lang=".LANGUAGE_ID,
  73. ])?>
  74. </div>
  75. <?php elseif ($isMarketPlace):?>
  76. <div class="adm-bsm-site-master-paragraph"><?=Loc::getMessage("SALE_BSM_WIZARD_UPDATESYSTEMSTEP_MARKET_PLACE_DESCR", [
  77. "#MARKET_PLACE_LINK#" => "/bitrix/admin/update_system_market.php?module=bitrix.eshop&lang=".LANGUAGE_ID,
  78. ])?>
  79. </div>
  80. <?php elseif ($isUpdateSystem):?>
  81. <div class="adm-bsm-site-master-paragraph"><?=Loc::getMessage("SALE_BSM_WIZARD_UPDATESYSTEMSTEP_UPDATE_SYSTEM_DESCR", [
  82. "#UPDATE_SYSTEM_LINK#" => "/bitrix/admin/update_system.php?lang=".LANGUAGE_ID,
  83. ])?>
  84. </div>
  85. <?php endif;?>
  86. <div class="adm-bsm-site-master-paragraph"><?=Loc::getMessage("SALE_BSM_WIZARD_UPDATESYSTEMSTEP_CONTINUE_DESCR")?></div>
  87. </div>
  88. <?
  89. $content = ob_get_contents();
  90. ob_end_clean();
  91. $this->content .= $content;
  92. return true;
  93. }
  94. /**
  95. * Prepare html content with modules to be installed
  96. */
  97. private function installModulesHtml()
  98. {
  99. $modules = $this->GetWizard()->GetVar("not_exist_modules");
  100. $rows = [];
  101. foreach ($modules as $module)
  102. {
  103. $rows[]["data"] = [
  104. "MODULE" => $module["name"],
  105. ];
  106. };
  107. /** @noinspection PhpVariableNamingConventionInspection */
  108. global $APPLICATION;
  109. ob_start();
  110. $APPLICATION->IncludeComponent('bitrix:main.ui.grid', '', [
  111. 'GRID_ID' => 'module_load_list',
  112. 'COLUMNS' => [
  113. [
  114. 'id' => 'MODULE',
  115. 'name' => Loc::getMessage("SALE_BSM_WIZARD_UPDATESYSTEMSTEP_DESCR1"),
  116. 'sort' => 'MODULE',
  117. 'default' => true,
  118. 'resizeable' => false,
  119. ],
  120. ],
  121. 'ROWS' => $rows,
  122. 'SHOW_ROW_CHECKBOXES' => false,
  123. 'AJAX_MODE' => 'N',
  124. 'AJAX_OPTION_JUMP' => 'N',
  125. 'SHOW_CHECK_ALL_CHECKBOXES' => false,
  126. 'SHOW_ROW_ACTIONS_MENU' => false,
  127. 'SHOW_GRID_SETTINGS_MENU' => false,
  128. 'SHOW_NAVIGATION_PANEL' => false,
  129. 'SHOW_PAGINATION' => false,
  130. 'SHOW_SELECTED_COUNTER' => false,
  131. 'SHOW_TOTAL_COUNTER' => false,
  132. 'SHOW_PAGESIZE' => false,
  133. 'SHOW_ACTION_PANEL' => false,
  134. 'ACTION_PANEL' => [],
  135. 'ALLOW_COLUMNS_SORT' => false,
  136. 'ALLOW_COLUMNS_RESIZE' => false,
  137. 'ALLOW_HORIZONTAL_SCROLL' => false,
  138. 'ALLOW_SORT' => false,
  139. 'ALLOW_PIN_HEADER' => false,
  140. 'AJAX_OPTION_HISTORY' => 'N'
  141. ]);
  142. $content = ob_get_contents();
  143. ob_end_clean();
  144. $this->content .= $content;
  145. }
  146. /**
  147. * @return array
  148. */
  149. public function showButtons()
  150. {
  151. ob_start();
  152. if ($this->GetNextStepID() !== null)
  153. {
  154. ?>
  155. <input type="hidden" name="<?=$this->GetWizard()->nextStepHiddenID?>" value="<?=$this->GetNextStepID()?>">
  156. <button type="submit" class="ui-btn ui-btn-primary" name="<?=$this->GetWizard()->nextButtonID?>">
  157. <?=$this->GetNextCaption()?>
  158. </button>
  159. <?
  160. }
  161. $content = ob_get_contents();
  162. ob_end_clean();
  163. return [
  164. "CONTENT" => $content,
  165. "NEED_WRAPPER" => true,
  166. "CENTER" => true,
  167. ];
  168. }
  169. /**
  170. * @return bool
  171. */
  172. public function onPostForm()
  173. {
  174. $wizard =& $this->GetWizard();
  175. if ($wizard->IsPrevButtonClick())
  176. {
  177. return false;
  178. }
  179. if (in_array($this->currentStepName, $this->component->arResult["WIZARD_STEPS"]))
  180. {
  181. $this->GetWizard()->SetCurrentStep($this->currentStepName);
  182. }
  183. return true;
  184. }
  185. }