PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/components/bitrix/sale.crm.site.master/wizard/defaultsitestep.php

https://gitlab.com/alexprowars/bitrix
PHP | 160 lines | 111 code | 22 blank | 27 comment | 9 complexity | 4413bf0914453c2187e29fb995aae88b MD5 | raw file
  1. <?php
  2. namespace Bitrix\Sale\CrmSiteMaster\Steps;
  3. if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true)
  4. {
  5. die();
  6. }
  7. use Bitrix\Main\Localization\Loc;
  8. Loc::loadMessages(__FILE__);
  9. /**
  10. * Class DefaultSiteStep
  11. * Step of check default site
  12. *
  13. * @package Bitrix\Sale\CrmSiteMaster\Steps
  14. */
  15. class DefaultSiteStep extends \CWizardStep
  16. {
  17. private $currentStepName = __CLASS__;
  18. /** @var \SaleCrmSiteMaster */
  19. private $component = null;
  20. /**
  21. * Check step errors
  22. */
  23. private function setStepErrors()
  24. {
  25. $errors = $this->component->getWizardStepErrors($this->currentStepName);
  26. if ($errors)
  27. {
  28. foreach ($errors as $error)
  29. {
  30. $this->SetError($error);
  31. }
  32. }
  33. }
  34. /**
  35. * Prepare next/prev buttons
  36. */
  37. private function prepareButtons()
  38. {
  39. $steps = $this->component->getSteps($this->currentStepName);
  40. $shortClassName = (new \ReflectionClass($this))->getShortName();
  41. if (isset($steps["NEXT_STEP"]))
  42. {
  43. $this->SetNextStep($steps["NEXT_STEP"]);
  44. $this->SetNextCaption(Loc::getMessage("SALE_CSM_WIZARD_".mb_strtoupper($shortClassName)."_NEXT"));
  45. }
  46. if (isset($steps["PREV_STEP"]))
  47. {
  48. $this->SetPrevStep($steps["PREV_STEP"]);
  49. $this->SetPrevCaption(Loc::getMessage("SALE_CSM_WIZARD_".mb_strtoupper($shortClassName)."_PREV"));
  50. }
  51. }
  52. /**
  53. * Initialization step id and title
  54. */
  55. public function initStep()
  56. {
  57. $this->component = $this->GetWizard()->GetVar("component");
  58. $this->SetStepID($this->currentStepName);
  59. $this->SetTitle(Loc::getMessage("SALE_CSM_WIZARD_DEFAULTSITESTEP_TITLE"));
  60. $this->prepareButtons();
  61. $this->setStepErrors();
  62. }
  63. /**
  64. * Show step content
  65. *
  66. * @return bool
  67. */
  68. public function showStep()
  69. {
  70. ob_start();
  71. $error = $this->GetWizard()->GetVar("default_site_error");
  72. ?>
  73. <div class="ui-alert ui-alert-danger ui-alert-icon-danger">
  74. <span class="ui-alert-message"><?= $error ?></span>
  75. </div>
  76. <div class="ui-alert ui-alert-warning ui-alert-icon-warning">
  77. <span class="ui-alert-message"><?= Loc::getMessage("SALE_CSM_WIZARD_DEFAULTSITESTEP_INFO") ?></span>
  78. </div>
  79. <div class="adm-crm-site-master-paragraph">
  80. <?=Loc::getMessage("SALE_CSM_WIZARD_DEFAULTSITESTEP_SITE_LINK", [
  81. "#LANG#" => LANGUAGE_ID
  82. ])?>
  83. </div>
  84. <?php
  85. $content = ob_get_contents();
  86. ob_end_clean();
  87. $this->content = $content;
  88. return true;
  89. }
  90. /**
  91. * @return bool
  92. */
  93. public function onPostForm()
  94. {
  95. $wizard =& $this->GetWizard();
  96. if ($wizard->IsPrevButtonClick())
  97. {
  98. return false;
  99. }
  100. if (in_array($this->currentStepName, $this->component->arResult["WIZARD_STEPS"]))
  101. {
  102. $this->GetWizard()->SetCurrentStep($this->currentStepName);
  103. }
  104. return true;
  105. }
  106. /**
  107. * @return array
  108. */
  109. public function showButtons()
  110. {
  111. ob_start();
  112. if ($this->GetPrevStepID() !== null)
  113. {
  114. ?>
  115. <input type="hidden" name="<?=$this->GetWizard()->prevStepHiddenID?>" value="<?=$this->GetPrevStepID()?>">
  116. <button type="submit" class="ui-btn ui-btn-primary" name="<?=$this->GetWizard()->prevButtonID?>">
  117. <?=$this->GetPrevCaption()?>
  118. </button>
  119. <?
  120. }
  121. if ($this->GetNextStepID() !== null)
  122. {
  123. ?>
  124. <input type="hidden" name="<?=$this->GetWizard()->nextStepHiddenID?>" value="<?=$this->GetNextStepID()?>">
  125. <button type="submit" class="ui-btn ui-btn-primary" name="<?=$this->GetWizard()->nextButtonID?>">
  126. <?=$this->GetNextCaption()?>
  127. </button>
  128. <?
  129. }
  130. $content = ob_get_contents();
  131. ob_end_clean();
  132. return [
  133. "CONTENT" => $content,
  134. "NEED_WRAPPER" => true,
  135. "CENTER" => true,
  136. ];
  137. }
  138. }