3namespace Bitrix\Sale\Discount\Preset;
5use Bitrix\Main\HttpRequest;
6use Bitrix\Main\Security\Sign\Signer;
7use Bitrix\Main\Type\Dictionary;
8use Bitrix\Main\Web\Json;
12 private const STATE_NAME_VAR =
'__state';
13 private const CHAIN_NAME_VAR =
'__chain';
14 private const STATE_SIGNER_SALT =
'discount.preset.state';
26 $this->setDefaultValues();
30 private function setDefaultValues(): void
32 if (empty($this[self::CHAIN_NAME_VAR]))
34 $this[self::CHAIN_NAME_VAR] =
array();
38 private function initSigner(): void
40 $this->signer =
new Signer();
43 private function sign(
string $data): string
45 return $this->signer->sign(
$data, self::STATE_SIGNER_SALT);
52 $signedData = $this->signer->unsign(
$data, self::STATE_SIGNER_SALT);
56 die(
'Bad signature.');
62 public function set(
$name, $value =
null)
64 parent::set(
$name, $value);
66 $this->setDefaultValues();
75 $this[
$name] = $value;
89 $value = parent::get(
$name);
116 return $state->set(
$data ?: []);
121 $prevState = self::createFromEncodedData(
$request->getPost(self::STATE_NAME_VAR));
129 unset($prevState[
$name]);
145 $chain = $this[self::CHAIN_NAME_VAR];
146 $lastStep = end($chain);
148 if ($lastStep != $step)
151 $this[self::CHAIN_NAME_VAR] = $chain;
159 $chain = $this[self::CHAIN_NAME_VAR];
160 $step = array_pop($chain);
162 $this[self::CHAIN_NAME_VAR] = $chain;
169 $steps = $this->getStepChain();
174 private function getStepChain():
array
176 return $this->
get(self::CHAIN_NAME_VAR, []);
190 $value = $this->sign(base64_encode(
$data));
192 return '<input type="hidden" name="' . self::STATE_NAME_VAR .
'" value="' . $value .
'">';
202 $toArray = parent::toArray();
207 $toArray[
'__next_step'],
215 $countPrevSteps =
count($this->getStepChain());
217 return $countPrevSteps + 1;
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
static createFromEncodedData($data)
static createFromRequest(HttpRequest $request)
__construct(array $values=null)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"