1 | <?php |
||
13 | abstract class admin_main |
||
14 | { |
||
15 | /** @var object \phpbb\config\config */ |
||
16 | protected $config; |
||
17 | /** @var object Symfony\Component\DependencyInjection\ContainerInterface */ |
||
18 | protected $container; |
||
19 | /** @var string */ |
||
20 | protected $id_prefix_name; |
||
21 | /** @var string */ |
||
22 | protected $lang_key_prefix; |
||
23 | /** @var \phpbb\log\log */ |
||
24 | protected $log; |
||
25 | /** @var string */ |
||
26 | protected $module_name; |
||
27 | /** @var bool */ |
||
28 | protected $preview; |
||
29 | /** @var \phpbb\request\request */ |
||
30 | protected $request; |
||
31 | /** @var bool */ |
||
32 | protected $submit; |
||
33 | /** @var \phpbb\template\template */ |
||
34 | protected $template; |
||
35 | /** @var string */ |
||
36 | protected $u_action; |
||
37 | /** @var \phpbb\user */ |
||
38 | protected $user; |
||
39 | |||
40 | /** |
||
41 | * Constructor |
||
42 | * |
||
43 | * @param string $lang_key_prefix Prefix for the messages thrown by exceptions |
||
44 | * @param string $id_prefix_name Prefix name for identifier in the URL |
||
45 | * @param string $module_name Name of the module currently used |
||
46 | * |
||
47 | * @access public |
||
48 | */ |
||
49 | public function __construct($module_name, $lang_key_prefix, $id_prefix_name) |
||
55 | |||
56 | /** |
||
57 | * Parse data to the entity |
||
58 | * |
||
59 | * @param \skouat\ppde\entity\main $entity The entity object |
||
60 | * @param string $run_before_insert Name of the function to call before SQL INSERT |
||
61 | * |
||
62 | * @return string $log_action |
||
63 | * @access public |
||
64 | */ |
||
65 | public function add_edit_data(\skouat\ppde\entity\main $entity, $run_before_insert = '') |
||
88 | |||
89 | /** |
||
90 | * Set data in the $entity object. |
||
91 | * Use call_user_func_array() to call $entity function |
||
92 | * |
||
93 | * @param \skouat\ppde\entity\main $entity The entity object |
||
94 | * @param array $data_ary |
||
95 | * |
||
96 | * @access public |
||
97 | */ |
||
98 | public function set_entity_data(\skouat\ppde\entity\main $entity, $data_ary) |
||
107 | |||
108 | /** |
||
109 | * Set page url |
||
110 | * |
||
111 | * @param string $u_action Custom form action |
||
112 | * |
||
113 | * @return void |
||
114 | * @access public |
||
115 | */ |
||
116 | public function set_page_url($u_action) |
||
120 | |||
121 | /** |
||
122 | * @param array $errors |
||
123 | * |
||
124 | * @return bool |
||
125 | * @access protected |
||
126 | */ |
||
127 | protected function can_submit_data(array $errors) |
||
131 | |||
132 | /** |
||
133 | * Trigger error message if data already exists |
||
134 | * |
||
135 | * @param \skouat\ppde\entity\main $entity The entity object |
||
136 | * |
||
137 | * @access protected |
||
138 | */ |
||
139 | protected function trigger_error_data_already_exists(\skouat\ppde\entity\main $entity) |
||
150 | |||
151 | /** |
||
152 | * @param \skouat\ppde\entity\main $entity The entity object |
||
153 | * |
||
154 | * @return bool |
||
155 | * @access protected |
||
156 | */ |
||
157 | protected function is_added_data_exists($entity) |
||
161 | |||
162 | /** |
||
163 | * Check some settings before submitting data |
||
164 | * |
||
165 | * @param \skouat\ppde\entity\main $entity The entity object |
||
166 | * @param string $field_name Name of the entity function to call |
||
167 | * @param string|int $value_cmp Default value to compare with the call_user_func() return value |
||
168 | * @param bool $submit_or_preview Form submit or preview status |
||
169 | * |
||
170 | * @return array $errors |
||
171 | * @access protected |
||
172 | */ |
||
173 | protected function is_empty_data(\skouat\ppde\entity\main $entity, $field_name, $value_cmp, $submit_or_preview = false) |
||
184 | |||
185 | /** |
||
186 | * Check if form is valid or not |
||
187 | * |
||
188 | * @param string $form_name |
||
189 | * @param bool $submit_or_preview |
||
190 | * |
||
191 | * @return array |
||
192 | * @access protected |
||
193 | */ |
||
194 | protected function is_invalid_form($form_name, $submit_or_preview = false) |
||
198 | |||
199 | /** |
||
200 | * Get result of submit and preview expression |
||
201 | * |
||
202 | * @param bool $submit |
||
203 | * @param bool $preview |
||
204 | * |
||
205 | * @return bool |
||
206 | * @access protected |
||
207 | */ |
||
208 | protected function submit_or_preview($submit = false, $preview = false) |
||
212 | |||
213 | /** |
||
214 | * Show user a result message if AJAX was used |
||
215 | * |
||
216 | * @param string $message Text message to show to the user |
||
217 | * |
||
218 | * @return void |
||
219 | * @access protected |
||
220 | */ |
||
221 | protected function ajax_delete_result_message($message = '') |
||
235 | |||
236 | /** |
||
237 | * Return the entity ContainerInterface used by the ACP module in use |
||
238 | * |
||
239 | * @return object |
||
240 | * @access protected |
||
241 | */ |
||
242 | protected function get_container_entity() |
||
246 | |||
247 | /** |
||
248 | * Set u_action output vars for display in the template |
||
249 | * |
||
250 | * @return void |
||
251 | * @access protected |
||
252 | */ |
||
253 | protected function u_action_assign_template_vars() |
||
259 | |||
260 | /** |
||
261 | * Set error output vars for display in the template |
||
262 | * |
||
263 | * @param array $errors |
||
264 | * |
||
265 | * @return void |
||
266 | * @access protected |
||
267 | */ |
||
268 | protected function s_error_assign_template_vars($errors) |
||
275 | |||
276 | /** |
||
277 | * Check if a config value is true |
||
278 | * |
||
279 | * @param mixed $config Config value |
||
280 | * @param string $type (see settype()) |
||
281 | * @param mixed $default |
||
282 | * |
||
283 | * @return mixed |
||
284 | * @access protected |
||
285 | */ |
||
286 | protected function check_config($config, $type = 'boolean', $default = '') |
||
294 | /** |
||
295 | * Check if settings is required |
||
296 | * |
||
297 | * @param $settings |
||
298 | * @param $depend_on |
||
299 | * |
||
300 | * @return mixed |
||
301 | * @access protected |
||
302 | */ |
||
303 | protected function required_settings($settings, $depend_on) |
||
312 | |||
313 | /** |
||
314 | * Check if a settings depend on another. |
||
315 | * |
||
316 | * @param $config_name |
||
317 | * |
||
318 | * @return bool |
||
319 | * @access protected |
||
320 | */ |
||
321 | protected function depend_on($config_name) |
||
325 | } |
||
326 |