$vars */ private function fillTpl(string $name, array $vars): string { return (string)$this->f->str_replace(array_keys($vars), array_values($vars), $this->tpl($name)); } /** * Build the shared rows-per-page selector without changing a saved size. * All three tables persist one preference, including valid sizes selected * through an API or an older screen's preset list. * * @param int|string $currentPerPage */ public function buildPerpageOptions($currentPerPage): string { $optionTpl = $this->tpl('viewRedirectsTablePerpageOption.html'); $current = filter_var($currentPerPage, FILTER_VALIDATE_INT, array('options' => array( 'min_range' => ABJ404_OPTION_MIN_PERPAGE, 'max_range' => ABJ404_OPTION_MAX_PERPAGE, ))); $current = is_int($current) ? $current : ABJ404_OPTION_DEFAULT_PERPAGE; $choices = array_values(array_unique(array(10, 25, 50, 100, 200, 250, $current))); sort($choices, SORT_NUMERIC); $html = ''; foreach ($choices as $opt) { $selected = ($current === $opt) ? ' selected' : ''; $html .= $this->f->str_replace( array('{value}', '{selected_attr}'), array((string)$opt, $selected), $optionTpl ) . "\n"; } return $html; } /** Build a bulk-action button (the type that posts to the bulk form). */ public function buildBulkButton(string $value, string $label): string { return $this->f->str_replace( array('{value}', '{label}'), array(esc_attr($value), $label), $this->tpl('viewRedirectsTableBulkButton.html') ) . "\n"; } /** * Build the i18n string for the pagination "Refresh available" pill * data-* attr. The pill is the only background-refresh surface: the table * always renders live from the denorm read, so there is no "refreshing / * data refreshed" progress toast (and no started/finished strings). * * @return array{available:string} */ public function paginationRefreshStrings(): array { $available = __('Refresh available', '404-solution'); return array('available' => $available); } /** Build the Confidence-filter