1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
stepper.php
См. документацию.
1
<?php
2
namespace
Bitrix\Translate\Controller;
3
4
use Bitrix\Main;
5
use Bitrix\Translate;
6
12
trait
Stepper
13
{
14
protected
?
string
$processToken;
15
16
protected
bool
$isNewProcess
=
true
;
17
18
protected
bool
$isProcessCompleted
=
false
;
19
20
protected
int
$processedItems
= 0;
21
22
protected
int
$totalItems
= 0;
23
24
protected
?
Translate\Controller\Timer
$timer
=
null
;
25
26
33
protected
function
onBeforeRun()
34
{
35
if
($this instanceof
IProcessParameters
)
36
{
37
$this->
keepField
([
38
'processedItems'
,
39
'totalItems'
,
40
]);
41
43
$this->processToken = $this->getController()->getRequest()->get(
'PROCESS_TOKEN'
);
44
45
$progressData = $this->
getProgressParameters
();
46
if
(\
count
($progressData) > 0)
47
{
48
$this->isNewProcess = (empty($progressData[
'processToken'
]) || $progressData[
'processToken'
] !== $this->processToken);
49
if
(!$this->isNewProcess)
50
{
51
// restore state
52
$this->
restoreProgressParameters
();
53
}
54
}
55
56
$this->
keepField
(
'processToken'
);
57
}
58
59
if
(empty($this->processToken))
60
{
61
$this->
addError
(
new
Main
\
Error
(
'Process token is not specified.'
));
62
}
63
64
return \count($this->
getErrors
()) === 0;
65
}
66
75
protected
function
performStep
(
$action
,
array
$params
= [])
76
{
77
if
($this->isNewProcess)
78
{
79
$this->processedItems = 0;
80
$this->totalItems = 0;
81
82
if
($this instanceof
IProcessParameters
)
83
{
84
$this->
saveProgressParameters
();
85
}
86
}
87
88
$this->
startTimer
();
89
90
if
(
$action
instanceof \Closure)
91
{
92
$result
=
$action
->call($this,
$params
);
93
}
94
elseif
(\is_callable(
$action
))
95
{
96
$result
= \call_user_func(
$action
,
$params
);
97
}
98
elseif
(\is_string(
$action
) && \is_callable([$this,
$action
]))
99
{
100
$result
= \call_user_func([$this,
$action
],
$params
);
101
}
102
else
103
{
104
$this->
addError
(
new
Main
\
Error
(
'Wrong action parameter!'
));
105
}
106
107
if
($this->
hasErrors
())
108
{
109
$result
[
'STATUS'
] =
Translate\Controller\STATUS_COMPLETED
;
110
}
111
elseif
($this->
hasProcessCompleted
())
112
{
113
$result
[
'STATUS'
] =
Translate\Controller\STATUS_COMPLETED
;
114
}
115
else
116
{
117
$result
[
'STATUS'
] =
Translate\Controller\STATUS_PROGRESS
;
118
}
119
120
if
($this instanceof
IProcessParameters
)
121
{
122
// Save progress
123
$this->
saveProgressParameters
();
124
}
125
126
return
$result
;
127
}
128
136
public
function
declareAccomplishment
(
bool
$flag =
true
): void
137
{
138
$this->isProcessCompleted = $flag;
139
}
140
146
public
function
hasProcessCompleted
(): bool
147
{
148
return
$this->isProcessCompleted;
149
}
150
151
156
public
function
hasErrors
(): bool
157
{
159
if
($this->errorCollection instanceof
Main
\
ErrorCollection
)
160
{
161
return
$this->errorCollection->isEmpty() !==
true
;
162
}
163
164
return
false
;
165
}
166
172
public
function
instanceTimer
():
Translate
\
Controller
\
Timer
173
{
174
if
($this->timer ===
null
)
175
{
176
$this->timer =
new
Translate\Controller\Timer
();
177
}
178
179
return
$this->timer;
180
}
181
189
public
function
startTimer
(): void
190
{
191
$this->
instanceTimer
()->startTimer((
int
)\
START_EXEC_TIME
);
192
}
193
201
public
function
hasTimeLimitReached
(): bool
202
{
203
return
$this->
instanceTimer
()->hasTimeLimitReached();
204
}
205
}
Bitrix\Main\ErrorCollection
Определения
errorcollection.php:14
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Translate\Controller\Timer
Определения
timer.php:11
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
Bitrix\Translate\Controller\IProcessParameters
Определения
iprocessparameters.php:9
START_EXEC_TIME
const START_EXEC_TIME
Определения
start.php:12
Bitrix\Main\Controller
Определения
agreement.php:2
Bitrix\Main
Bitrix\Main\getErrors
getErrors()
Определения
errorableimplementation.php:34
Bitrix\Main\hasErrors
hasErrors()
Определения
errorableimplementation.php:17
Bitrix\Translate\Controller\$isProcessCompleted
bool $isProcessCompleted
Определения
stepper.php:18
Bitrix\Translate\Controller\startTimer
startTimer()
Определения
stepper.php:189
Bitrix\Translate\Controller\restoreProgressParameters
restoreProgressParameters()
Определения
processparams.php:72
Bitrix\Translate\Controller\STATUS_COMPLETED
const STATUS_COMPLETED
Определения
controller.php:6
Bitrix\Translate\Controller\getProgressParameters
getProgressParameters()
Определения
processparams.php:127
Bitrix\Translate\Controller\instanceTimer
instanceTimer()
Определения
stepper.php:172
Bitrix\Translate\Controller\$isNewProcess
bool $isNewProcess
Определения
stepper.php:16
Bitrix\Translate\Controller\$timer
Translate Controller Timer $timer
Определения
stepper.php:24
Bitrix\Translate\Controller\hasProcessCompleted
hasProcessCompleted()
Определения
stepper.php:146
Bitrix\Translate\Controller\$processedItems
int $processedItems
Определения
stepper.php:20
Bitrix\Translate\Controller\$totalItems
int $totalItems
Определения
stepper.php:22
Bitrix\Translate\Controller\hasTimeLimitReached
hasTimeLimitReached()
Определения
stepper.php:201
Bitrix\Translate\Controller\performStep
performStep($action, array $params=[])
Определения
stepper.php:75
Bitrix\Translate\Controller\declareAccomplishment
declareAccomplishment(bool $flag=true)
Определения
stepper.php:136
Bitrix\Translate\Controller\Stepper
trait Stepper
Определения
stepper.php:13
Bitrix\Translate\Controller\saveProgressParameters
saveProgressParameters()
Определения
processparams.php:97
Bitrix\Translate\Controller\keepField
keepField($fieldName)
Определения
processparams.php:53
Bitrix\Translate\Controller\STATUS_PROGRESS
const STATUS_PROGRESS
Определения
controller.php:7
Bitrix\Translate
Определения
autoload.php:3
Bitrix\Translate\addError
addError(Main\Error $error)
Определения
error.php:22
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
count
</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."%"
Определения
waybill.php:936
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$action
$action
Определения
file_dialog.php:21
bitrix
modules
translate
lib
controller
stepper.php
Создано системой
1.14.0