Skip to content
Snippets Groups Projects
Verified Commit 1a0bd14c authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3491515 by quietone, akulsaxena: Fix...

Issue #3491515 by quietone, akulsaxena: Fix Drupal.Commenting.FunctionComment.Missing in views plugins, pt 2
parent 95579a70
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,9 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$
$this->setItemsPerPage(0);
}
/**
* {@inheritdoc}
*/
public function summaryTitle() {
if (!empty($this->options['offset'])) {
return $this->t('All items, skip @skip', ['@skip' => $this->options['offset']]);
......@@ -38,6 +41,9 @@ public function summaryTitle() {
return $this->t('All items');
}
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['offset'] = ['default' => 0];
......@@ -59,26 +65,44 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
];
}
/**
* {@inheritdoc}
*/
public function usePager() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function useCountQuery() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getItemsPerPage() {
return 0;
}
/**
* {@inheritdoc}
*/
public function executeCountQuery(&$count_query) {
// If we are displaying all items, never count. But we can update the count in post_execute.
}
/**
* {@inheritdoc}
*/
public function postExecute(&$result) {
$this->total_items = count($result);
}
/**
* {@inheritdoc}
*/
public function query() {
// The only query modifications we might do are offsets.
if (!empty($this->options['offset'])) {
......
......@@ -252,20 +252,38 @@ public function hasMoreRecords() {
&& $this->total_items > (intval($this->current_page) + 1) * $this->getItemsPerPage();
}
/**
* Allows the exposed form to be altered.
*/
public function exposedFormAlter(&$form, FormStateInterface $form_state) {}
/**
* Allows the exposed form to be validated.
*/
public function exposedFormValidate(&$form, FormStateInterface $form_state) {}
/**
* Handles submission of the exposed form.
*/
public function exposedFormSubmit(&$form, FormStateInterface $form_state, &$exclude) {}
/**
* Indicates whether this pager uses exposed filters.
*/
public function usesExposed() {
return FALSE;
}
/**
* Returns whether the items per page is exposed.
*/
protected function itemsPerPageExposed() {
return FALSE;
}
/**
* Returns whether the offset is exposed.
*/
protected function isOffsetExposed() {
return FALSE;
}
......
......@@ -19,6 +19,9 @@
)]
class Some extends PagerPluginBase {
/**
* {@inheritdoc}
*/
public function summaryTitle() {
if (!empty($this->options['offset'])) {
return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', ['@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']]);
......@@ -26,6 +29,9 @@ public function summaryTitle() {
return $this->formatPlural($this->options['items_per_page'], '@count item', '@count items', ['@count' => $this->options['items_per_page']]);
}
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['items_per_page'] = ['default' => 10];
......@@ -57,14 +63,23 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
];
}
/**
* {@inheritdoc}
*/
public function usePager() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function useCountQuery() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function query() {
$this->view->query->setLimit($this->options['items_per_page']);
$this->view->query->setOffset($this->options['offset']);
......
......@@ -62,6 +62,9 @@ public static function create(ContainerInterface $container, array $configuratio
);
}
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['items_per_page'] = ['default' => 10];
......@@ -232,6 +235,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
];
}
/**
* {@inheritdoc}
*/
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
// Only accept integer values.
$error = FALSE;
......@@ -265,6 +271,9 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) {
}
}
/**
* {@inheritdoc}
*/
public function query() {
if ($this->itemsPerPageExposed()) {
$query = $this->view->getRequest()->query;
......@@ -313,6 +322,9 @@ public function setCurrentPage($number = NULL) {
$this->current_page = max(0, $this->pagerParameters->findPage($this->options['id']));
}
/**
* Gets the total number of pages.
*/
public function getPagerTotal() {
if ($items_per_page = intval($this->getItemsPerPage())) {
return ceil($this->total_items / $items_per_page);
......@@ -347,18 +359,30 @@ public function updatePageInfo() {
}
}
/**
* {@inheritdoc}
*/
public function usesExposed() {
return $this->itemsPerPageExposed() || $this->isOffsetExposed();
}
/**
* {@inheritdoc}
*/
protected function itemsPerPageExposed() {
return !empty($this->options['expose']['items_per_page']);
}
/**
* {@inheritdoc}
*/
protected function isOffsetExposed() {
return !empty($this->options['expose']['offset']);
}
/**
* {@inheritdoc}
*/
public function exposedFormAlter(&$form, FormStateInterface $form_state) {
if ($this->itemsPerPageExposed()) {
$options = explode(',', $this->options['expose']['items_per_page_options']);
......@@ -390,6 +414,9 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) {
}
}
/**
* {@inheritdoc}
*/
public function exposedFormValidate(&$form, FormStateInterface $form_state) {
if (!$form_state->isValueEmpty('offset') && trim($form_state->getValue('offset'))) {
if (!is_numeric($form_state->getValue('offset')) || $form_state->getValue('offset') < 0) {
......
......@@ -20,6 +20,9 @@
)]
class DefaultSummary extends StylePluginBase {
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
......@@ -31,12 +34,18 @@ protected function defineOptions() {
return $options;
}
/**
* {@inheritdoc}
*/
public function query() {
if (!empty($this->options['override'])) {
$this->view->setItemsPerPage(intval($this->options['items_per_page']));
}
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['base_path'] = [
'#type' => 'textfield',
......@@ -71,6 +80,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
];
}
/**
* {@inheritdoc}
*/
public function render() {
$rows = [];
foreach ($this->view->result as $row) {
......
......@@ -37,6 +37,9 @@ class Rss extends StylePluginBase {
*/
protected $usesRowPlugin = TRUE;
/**
* Attaches the RSS icon and feed link to the view.
*/
public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
$url_options = [];
$input = $this->view->getExposedInput();
......@@ -63,6 +66,9 @@ public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
];
}
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
......@@ -71,6 +77,9 @@ protected function defineOptions() {
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
......@@ -108,6 +117,9 @@ public function getDescription() {
return $description;
}
/**
* {@inheritdoc}
*/
public function render() {
$rows = [];
......
......@@ -64,6 +64,9 @@ class Table extends StylePluginBase implements CacheableDependencyInterface {
*/
public $order;
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
......@@ -413,10 +416,16 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
];
}
/**
* {@inheritdoc}
*/
public function evenEmpty() {
return parent::evenEmpty() || !empty($this->options['empty_table']);
}
/**
* {@inheritdoc}
*/
public function wizardSubmit(&$form, FormStateInterface $form_state, WizardInterface $wizard, &$display_options, $display_type) {
// If any of the displays use the table style, make sure that the fields
// always have a labels by unsetting the override.
......
......@@ -20,6 +20,9 @@
)]
class UnformattedSummary extends DefaultSummary {
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['inline'] = ['default' => FALSE];
......@@ -27,6 +30,9 @@ protected function defineOptions() {
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['inline'] = [
......
......@@ -78,6 +78,8 @@
<include-pattern>core/modules/*/Plugin/views/display/*</include-pattern>
<include-pattern>core/modules/*/Plugin/views/exposed_form/*</include-pattern>
<include-pattern>core/modules/*/Plugin/views/field/*</include-pattern>
<include-pattern>core/modules/*/Plugin/views/pager/*</include-pattern>
<include-pattern>core/modules/*/Plugin/views/style/*</include-pattern>
<include-pattern>*/Database/*</include-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment