class Mini in Pagerer 8
Same name and namespace in other branches
- 8.2 src/Plugin/pagerer/Mini.php \Drupal\pagerer\Plugin\pagerer\Mini
Pager style to display current page/item in a direct entry textbox.
Examples:
page 9 out of 955, display 'pages': ----------------------------------------------------------- << < Page 9 of 955 > >> -----------------------------------------------------------
page 9 out of 955, total items = 47731, limit = 50, display = 'items': ----------------------------------------------------------- << < Item 401 of 47731 > >> -----------------------------------------------------------
Plugin annotation
@PagererStyle(
id = "mini",
title = @Translation("Display current page/item"),
short_title = @Translation("Mini"),
help = @Translation("Pager style to display current page/item in a direct entry textbox."),
style_type = "base"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\pagerer\Plugin\pagerer\PagererStyleBase implements ContainerFactoryPluginInterface, PluginFormInterface, PagererStyleInterface
- class \Drupal\pagerer\Plugin\pagerer\Mini
- class \Drupal\pagerer\Plugin\pagerer\PagererStyleBase implements ContainerFactoryPluginInterface, PluginFormInterface, PagererStyleInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Mini
File
- src/
Plugin/ pagerer/ Mini.php, line 30
Namespace
Drupal\pagerer\Plugin\pagererView source
class Mini extends PagererStyleBase {
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$config = parent::buildConfigurationForm($form, $form_state);
// Reset pager display mode options specifically for mini.
unset($config['display_container']['display_mode']['#options']['normal']);
$config['display_container']['display_mode']['#options']['none'] = $this
->t('Not displayed.');
$config['display_container']['display_mode']['#options']['widget'] = $this
->t('Input box. Users can enter directly a page/item number to go to.');
// Remove 'item_ranges' display option.
unset($config['display']['#options']['item_ranges']);
$config['display']['#description'] = $this
->t("Select whether to display pages or items.");
// No need for separators in mini.
unset($config['separators_container']);
// Add widget resizing option specific for mini.
$config['plugin'] = [
'#type' => 'details',
'#title' => $this
->t("Input box"),
'#description' => $this
->t("Input box options."),
];
$config['plugin']['widget_resize'] = [
'#type' => 'checkbox',
'#title' => $this
->t("Automatic width adjustment"),
'#default_value' => $this->configuration['widget_resize'],
'#description' => $this
->t("If set, the input box width will be adjusted dynamically based on the total number of pages/items. When unset, CSS styling will prevail."),
];
$options = [
'no',
'yes',
'auto',
];
$options = array_combine($options, $options);
$config['plugin']['widget_button'] = [
'#type' => 'select',
'#title' => $this
->t("Trigger button"),
'#options' => $options,
'#default_value' => $this->configuration['widget_button'],
'#description' => $this
->t("Select whether to add a clickable navigation button to the input box. Options are 'no' (page relocation will only occur by pressing the 'return' key on the keyboard), 'yes' (button is shown, and styled via CSS), 'auto' (button height is automatically resized to match the input box height)."),
'#required' => TRUE,
];
return $config;
}
/**
* Return the pager render array.
*
* @return array
* render array.
*/
protected function buildPagerItems() {
// Return immediately if configuration is not set to display the page
// widget.
if ($this
->getOption('display_mode') != 'widget') {
return [];
}
// Prepares state.
$state_settings = [
'widgetResize' => $this
->getOption('widget_resize'),
'widgetButton' => $this
->getOption('widget_button'),
];
$pagerer_widget_id = $this
->prepareJsState($state_settings);
// Entry textbox.
return [
[
'widget' => [
'#theme' => 'pagerer_mini',
'#id' => $pagerer_widget_id,
'#title' => $this
->getDisplayTag('widget_title'),
'#value' => $state_settings['value'],
'#min' => 1,
'#max' => $this
->getOption('display') == 'pages' ? $state_settings['total'] : $state_settings['totalItems'],
'#step' => $state_settings['interval'],
'#button' => $this
->getOption('widget_button') === 'no' ? FALSE : TRUE,
'#attached' => [
'drupalSettings' => [
'pagerer' => [
'state' => [
$pagerer_widget_id => $state_settings,
],
],
],
],
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
Mini:: |
public | function |
Form constructor. Overrides PagererStyleBase:: |
|
Mini:: |
protected | function | Return the pager render array. | |
PagererStyleBase:: |
protected | property | The config factory. | |
PagererStyleBase:: |
protected | property | The Pagerer pager object. | |
PagererStyleBase:: |
protected | property | The PagererPreset object being configured. | |
PagererStyleBase:: |
protected | property | The PagererPreset pane being configured. | |
PagererStyleBase:: |
protected | property | Query parameters as requested by the theme call. | |
PagererStyleBase:: |
protected | property | The config type plugins manager. | |
PagererStyleBase:: |
protected | function | Render a 'no pages to display' text. | 1 |
PagererStyleBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
PagererStyleBase:: |
protected | function | Returns a translated textual element for pages/items/item ranges. | |
PagererStyleBase:: |
protected | function | Gets a link/button item to first/previous/next/last link. | |
PagererStyleBase:: |
protected | function | Returns a configuration element. | |
PagererStyleBase:: |
protected | function | Gets a 'page' item in the pager. | |
PagererStyleBase:: |
protected | function | Returns a translated textual element from the configuration. | |
PagererStyleBase:: |
protected | function | Prepares input parameters for a JS enabled pager widget. | |
PagererStyleBase:: |
public | function |
Prepares to render the pager. Overrides PagererStyleInterface:: |
|
PagererStyleBase:: |
public | function | Sets the current PagererPreset and pane being configured. | |
PagererStyleBase:: |
public | function |
Sets the Pagerer pager to be rendered. Overrides PagererStyleInterface:: |
|
PagererStyleBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
PagererStyleBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
PagererStyleBase:: |
public | function |
Constructs a \Drupal\pagerer\Plugin\pagerer\PagererStyleBase object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |