PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://gitlab.com/alexprowars/bitrix
PHP | 185 lines | 129 code | 25 blank | 31 comment | 8 complexity | db78b5a0548cb3dcf3dda3661f6d638d 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,
  8. Bitrix\Main\Application,
  9. Bitrix\Main\Localization\Loc;
  10. Loc::loadMessages(__FILE__);
  11. /**
  12. * Class ActivationKeyStep
  13. * @package Bitrix\Sale\CrmSiteMaster\Steps
  14. */
  15. class ActivationKeyStep extends \CWizardStep
  16. {
  17. /** @var Main\Request */
  18. private $request;
  19. private $currentStepName = __CLASS__;
  20. /** @var \SaleCrmSiteMaster */
  21. private $component = null;
  22. /**
  23. * Check step errors
  24. */
  25. private function setStepErrors()
  26. {
  27. $errors = $this->component->getWizardStepErrors($this->currentStepName);
  28. if ($errors)
  29. {
  30. foreach ($errors as $error)
  31. {
  32. $this->SetError($error);
  33. }
  34. }
  35. }
  36. /**
  37. * Prepare next/prev buttons
  38. *
  39. * @throws \ReflectionException
  40. */
  41. private function prepareButtons()
  42. {
  43. $steps = $this->component->getSteps($this->currentStepName);
  44. $shortClassName = (new \ReflectionClass($this))->getShortName();
  45. if (isset($steps["NEXT_STEP"]))
  46. {
  47. $this->SetNextStep($steps["NEXT_STEP"]);
  48. $this->SetNextCaption(Loc::getMessage("SALE_CSM_WIZARD_".mb_strtoupper($shortClassName)."_NEXT"));
  49. }
  50. if (isset($steps["PREV_STEP"]))
  51. {
  52. $this->SetPrevStep($steps["PREV_STEP"]);
  53. $this->SetPrevCaption(Loc::getMessage("SALE_CSM_WIZARD_".mb_strtoupper($shortClassName)."_PREV"));
  54. }
  55. }
  56. /**
  57. * Initialization step id, title and next/prev step
  58. *
  59. * @throws Main\SystemException
  60. * @throws \ReflectionException
  61. */
  62. public function initStep()
  63. {
  64. $this->component = $this->GetWizard()->GetVar("component");
  65. $this->SetStepID($this->currentStepName);
  66. $this->SetTitle(Loc::getMessage("SALE_CSM_WIZARD_ACTIVATIONKEYSTEP_TITLE"));
  67. $this->request = Application::getInstance()->getContext()->getRequest();
  68. $this->prepareButtons();
  69. $this->setStepErrors();
  70. }
  71. /**
  72. * Show step content
  73. *
  74. * @return bool
  75. */
  76. public function showStep()
  77. {
  78. ob_start();
  79. ?>
  80. <div class="adm-crm-site-master-paragraph" style="text-align: center;">
  81. <?=Loc::getMessage("SALE_CSM_WIZARD_ACTIVATIONKEYSTEP_CONTENT")?>
  82. </div>
  83. <div class="adm-crm-site-master-separator" style="height: 50px;"></div>
  84. <div class="adm-crm-site-master-check-key">
  85. <div class="adm-crm-site-master-check-key-column" id="check_key">
  86. <div class="ui-ctl ui-ctl-textbox ui-ctl-active">
  87. <input type="text" class="ui-ctl-element" style="text-transform: uppercase" id="id_key" name="KEY">
  88. </div>
  89. </div>
  90. <div class="adm-crm-site-master-check-key-column">
  91. <button class="ui-btn ui-btn-primary" id="id_key_btn">
  92. <?=Loc::getMessage("SALE_CSM_WIZARD_ACTIVATIONKEYSTEP_CHECK_BUTTON")?>
  93. </button>
  94. </div>
  95. </div>
  96. <div class="adm-crm-site-master-separator" style="height: 50px;"></div>
  97. <div class="adm-crm-site-master-separator" style="height: 120px;"></div>
  98. <div class="adm-crm-site-master-buy-key-container">
  99. <div class="adm-crm-site-master-buy-key-block">
  100. <div class="adm-crm-site-master-buy-key-icon">
  101. <svg width="22px" height="21px" viewBox="0 0 22 21" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  102. <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
  103. <g id="02" transform="translate(0, -57)" fill="#2FC6F6">
  104. <path d="M10.4437866,77.8875732 C4.67584254,77.8875732 0,73.2117307 0,67.4437866 C0,61.6758425 4.67584254,57 10.4437866,57 C16.2117307,57 20.8875732,61.6758425 20.8875732,67.4437866 C20.8875732,73.2117307 16.2117307,77.8875732 10.4437866,77.8875732 Z M9.88552794,66.6580286 L5.01511171,71.5031935 L6.31782462,72.7992378 L6.99843744,72.1227772 L8.30151898,73.4188215 L9.79382688,71.9350616 L8.49025385,70.6390173 L11.1896785,67.9541707 C12.4755576,68.6683944 14.1304896,68.4850173 15.2233947,67.3980143 C16.5428185,66.0851049 16.5428185,63.956928 15.2233947,62.6451185 C13.904831,61.333309 11.7646072,61.3328202 10.4451833,62.6451185 C9.35227822,63.7321826 9.16747534,65.3786049 9.88552794,66.6580286 Z M14.3550792,66.5339114 C13.5165852,67.367425 12.1529513,67.367425 11.3144327,66.5339114 C10.4759142,65.6999457 10.4759142,64.3431871 11.3144327,63.509197 C12.1524352,62.6756834 13.5165607,62.6756834 14.3550792,63.509197 C15.1935977,64.3431627 15.1935977,65.7003979 14.3550792,66.5339114 Z" id="Combined-Shape"></path>
  105. </g>
  106. </g>
  107. </svg>
  108. </div>
  109. <?php
  110. $priceLink = "https://www.bitrix24.ru/prices/self-hosted.php";
  111. if ($this->component->getLanguageId() === "ua")
  112. {
  113. $priceLink = "https://www.bitrix24.ua/prices/self-hosted.php";
  114. }
  115. ?>
  116. <div class="adm-crm-site-master-buy-key-link">
  117. <a href="<?=$priceLink?>" target="_blank"><?=Loc::getMessage("SALE_CSM_WIZARD_ACTIVATIONKEYSTEP_BUY_LINK")?></a>
  118. </div>
  119. </div>
  120. </div>
  121. <?php
  122. $content = ob_get_contents();
  123. ob_end_clean();
  124. $this->content = $content;
  125. return true;
  126. }
  127. /**
  128. * @return array
  129. */
  130. public function showButtons()
  131. {
  132. ob_start();
  133. if ($this->GetNextStepID() !== null)
  134. {
  135. ?>
  136. <input type="hidden" name="<?=$this->GetWizard()->nextStepHiddenID?>" value="<?=$this->GetNextStepID()?>">
  137. <input type="hidden" name="<?=$this->GetWizard()->nextButtonID?>" value="<?=$this->GetNextCaption()?>">
  138. <?php
  139. }
  140. $content = ob_get_contents();
  141. ob_end_clean();
  142. return [
  143. "CONTENT" => $content,
  144. "NEED_WRAPPER" => false,
  145. "CENTER" => true,
  146. ];
  147. }
  148. /**
  149. * @return bool
  150. */
  151. public function onPostForm()
  152. {
  153. $wizard =& $this->GetWizard();
  154. if ($wizard->IsPrevButtonClick())
  155. {
  156. return false;
  157. }
  158. return true;
  159. }
  160. }