container = $phpbb_container; $this->language = $this->container->get('language'); /** @var \phpbbstudio\aps\controller\acp_controller $controller */ $controller = $this->container->get('phpbbstudio.aps.controller.acp'); /** @var \phpbbstudio\aps\core\functions $functions */ $functions = $this->container->get('phpbbstudio.aps.functions'); // Set the page title and template $this->tpl_name = 'aps_' . $mode; $this->page_title = $this->language->lang('ACP_APS_POINTS') . ' • ' . $this->language->lang('ACP_APS_MODE_' . utf8_strtoupper($mode), $functions->get_name()); // Make the custom form action available in the controller and handle the mode $controller->set_page_url($this->u_action)->{$mode}(); } /** * Build configuration template for custom points actions. * * @param string $action The custom points action * @param bool $ajax The AJAX request indicator * @return string The configuration template * @access public */ public function set_action($action, $ajax = true) { return ''; } /** * Build configuration template for the points separator. * * @param string $value The config value * @return string The HTML formatted select options * @access public */ public function build_separator_select($value) { $space = htmlspecialchars(' '); $narrow = htmlspecialchars(' '); $separators = [ ',' => 'ACP_APS_SEPARATOR_COMMA', '.' => 'ACP_APS_SEPARATOR_PERIOD', '-' => 'ACP_APS_SEPARATOR_DASH', '_' => 'ACP_APS_SEPARATOR_UNDERSCORE', $space => 'ACP_APS_SEPARATOR_SPACE', $narrow => 'ACP_APS_SEPARATOR_SPACE_NARROW', ]; return build_select($separators, $value); } /** * Build configuration template for the points icon image. * * @param string $value The config value * @param string $key The config key * @return string The configuration template * @access public */ public function build_icon_image_select($value, $key = '') { $directory = $this->container->getParameter('core.root_path') . '/images'; $files = array_diff(scandir($directory), ['.', '..']); $images = array_filter($files, function($file) use ($directory) { $file = "{$directory}/{$file}"; return is_file($file) && filesize($file) && preg_match('#\.gif|jpg|jpeg|png|svg$#i', $file); }); $select = ''; return $select; } /** * Build configuration template for the points icon position. * * @param string $value The config value * @param string $key The config key * @return string The configuration template * @access public */ public function build_position_radio($value, $key = '') { return $this->build_radio($value, $key, [ 0 => 'ACP_APS_POINTS_ICON_POSITION_LEFT', 1 => 'ACP_APS_POINTS_ICON_POSITION_RIGHT', ]); } /** * Build configuration template for the points decimals. * * @param string $value The config value * @return string The configuration template * @access public */ public function build_decimal_select($value) { $options = ''; for ($i = 0; $i <= 2; $i++) { $options .= ''; } return $options; } public function build_ignore_criteria_radio($value, $key = '') { return $this->build_radio($value, $key, array_map(function($constant) { return 'ACP_APS_IGNORE_' . utf8_strtoupper($constant); }, array_flip($this->container->getParameter('phpbbstudio.aps.constants')['ignore']))); } protected function build_radio($value, $key, $options) { $html = ''; $s_id = false; foreach ($options as $val => $title) { $check = $value === $val ? ' checked' : ''; $id = $s_id ? ' id="' . $key . '"' : ''; $html .= ''; $s_id = true; } return $html; } }