1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Gorlum 12.02.2017 8:51 |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Pages; |
7
|
|
|
|
8
|
|
|
use \SN; |
|
|
|
|
9
|
|
|
use Player\userOptions; |
10
|
|
|
|
11
|
|
|
class PageTutorial extends PageAjax { |
12
|
|
|
|
13
|
|
|
protected $allowedActions = array( |
14
|
|
|
'ajax' => true, |
15
|
|
|
'ajaxNext' => true, |
16
|
|
|
'ajaxPrev' => true, |
17
|
|
|
'ajaxFinish' => true, |
18
|
|
|
); |
19
|
|
|
|
20
|
|
|
protected $id = 1; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var \Player\userOptions $userOptions |
24
|
|
|
*/ |
25
|
|
|
protected $userOptions; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @inheritdoc |
29
|
|
|
*/ |
30
|
|
|
public function loadParams() { |
31
|
|
|
$this->id = sys_get_param_id('id', 1); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function ajaxRender($method = 'getById') { |
35
|
|
|
/** |
36
|
|
|
* @var \TextEntity $text |
37
|
|
|
*/ |
38
|
|
|
$text = SN::$gc->textModel->$method($this->id); |
39
|
|
|
$result = $text->toArrayParsedBBC(HTML_ENCODE_MULTILINE_JS); |
40
|
|
|
if (!$text->isEmpty()) { |
41
|
|
|
SN::$user_options[PLAYER_OPTION_TUTORIAL_CURRENT] = $text->id; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return array( |
45
|
|
|
'tutorial' => $result, |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return array |
51
|
|
|
*/ |
52
|
|
|
protected function block2ValueList() { |
53
|
|
|
$result = array(); |
54
|
|
|
|
55
|
|
|
$text = SN::$gc->textModel->getById($this->id); |
56
|
|
|
$array = $text->toArrayParsedBBC(HTML_ENCODE_MULTILINE_JS); |
57
|
|
|
foreach ($array as $key => $value) { |
58
|
|
|
$result[] = array( |
59
|
|
|
'KEY' => $key, |
60
|
|
|
'VALUE' => $value, |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return $result; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
protected function isBlockEnabled() { |
71
|
|
|
if ($this->userOptions[PLAYER_OPTION_TUTORIAL_DISABLED]) { |
72
|
|
|
return false; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
if (SN::$gc->textModel->getById($this->userOptions[PLAYER_OPTION_TUTORIAL_CURRENT])->isEmpty()) { |
76
|
|
|
return false; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
// Checking if there is new tutorial appears after user finished old one |
80
|
|
|
if ($this->userOptions[PLAYER_OPTION_TUTORIAL_FINISHED]) { |
81
|
|
|
$next = SN::$gc->textModel->next($this->userOptions[PLAYER_OPTION_TUTORIAL_CURRENT]); |
82
|
|
|
if (!$next->isEmpty()) { |
83
|
|
|
$this->userOptions[PLAYER_OPTION_TUTORIAL_FINISHED] = 0; |
84
|
|
|
} else { |
85
|
|
|
return false; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
return true; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
// Page Actions ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
93
|
|
|
/** |
94
|
|
|
* Action 'ajax' |
95
|
|
|
* |
96
|
|
|
* @return array |
97
|
|
|
*/ |
98
|
|
|
public function ajax() { |
99
|
|
|
return $this->ajaxRender('getById'); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Returns ajax-ready next element in chain |
104
|
|
|
* |
105
|
|
|
* @return array |
106
|
|
|
*/ |
107
|
|
|
public function ajaxNext() { |
108
|
|
|
return $this->ajaxRender('next'); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Returns ajax-ready prev element in chain |
113
|
|
|
* |
114
|
|
|
* @return array |
115
|
|
|
*/ |
116
|
|
|
public function ajaxPrev() { |
117
|
|
|
return $this->ajaxRender('prev'); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Finishes current tutorial |
122
|
|
|
*/ |
123
|
|
|
public function ajaxFinish() { |
124
|
|
|
SN::$user_options[PLAYER_OPTION_TUTORIAL_FINISHED] = 1; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
// Renderers +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
128
|
|
|
/** |
129
|
|
|
* @param \template $template |
130
|
|
|
* |
131
|
|
|
* @return bool - should tutorial block be included |
132
|
|
|
*/ |
133
|
|
|
public static function renderNavBar($template) { |
134
|
|
|
$block = new self(); |
135
|
|
|
|
136
|
|
|
if ($result = $block |
137
|
|
|
->setUserOptions(SN::$user_options) |
138
|
|
|
->setId(SN::$user_options[PLAYER_OPTION_TUTORIAL_CURRENT]) |
139
|
|
|
->isBlockEnabled() |
140
|
|
|
) { |
141
|
|
|
$template->assign_recursive(array( |
142
|
|
|
'.' => array( |
143
|
|
|
'tutorial' => $block->block2ValueList()) |
144
|
|
|
)); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
// $template->assign_var('PLAYER_OPTION_TUTORIAL_WINDOWED', SN::$user_options[PLAYER_OPTION_TUTORIAL_WINDOWED]); |
148
|
|
|
|
149
|
|
|
return $result; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
// Getters/Setters +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
153
|
|
|
/** |
154
|
|
|
* @param int|string $id |
155
|
|
|
* |
156
|
|
|
* @return $this |
157
|
|
|
*/ |
158
|
|
|
public function setId($id) { |
159
|
|
|
$this->id = $id; |
160
|
|
|
|
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param \Player\userOptions $userOptions |
166
|
|
|
* |
167
|
|
|
* @return $this |
168
|
|
|
*/ |
169
|
|
|
public function setUserOptions($userOptions) { |
170
|
|
|
$this->userOptions = $userOptions; |
171
|
|
|
|
172
|
|
|
return $this; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
} |
176
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths