Skip to content
Snippets Groups Projects
Commit f443a771 authored by Jeroen Tubex's avatar Jeroen Tubex Committed by Carsten Logemann
Browse files

Issue #3112908 by JeroenT, C_Logemann, wrd: Adjustments to "Broken Links" view

parent 694d31fe
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@ dependencies:
config:
- system.menu.admin
module:
- dynamic_entity_reference
- linkchecker
- user
id: broken_links_report
......@@ -14,7 +13,6 @@ description: ''
tag: ''
base_table: linkchecker_link
base_field: lid
core: 8.x
display:
default:
display_plugin: default
......@@ -48,23 +46,26 @@ display:
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: mini
type: full
options:
items_per_page: 50
offset: 0
id: 0
total_pages: null
tags:
previous: ‹‹
next: ››
first: '« First'
last: 'Last »'
expose:
items_per_page: false
items_per_page: true
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options: '10, 25, 50, 100'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ‹‹
next: ››
quantity: 9
style:
type: table
options:
......@@ -169,15 +170,15 @@ display:
row:
type: fields
fields:
url:
id: url
entity_field:
id: entity_field
table: linkchecker_link
field: url
field: entity_field
relationship: none
group_type: group
admin_label: ''
label: URL
exclude: false
label: 'Entity field'
exclude: true
alter:
alter_text: false
text: ''
......@@ -218,8 +219,9 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: uri_link
settings: { }
type: string
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
......@@ -231,17 +233,17 @@ display:
separator: ', '
field_api_classes: false
entity_type: linkcheckerlink
entity_field: url
entity_field: entity_field
plugin_id: field
last_check:
id: last_check
entity_langcode:
id: entity_langcode
table: linkchecker_link
field: last_check
field: entity_langcode
relationship: none
group_type: group
admin_label: ''
label: 'Last checked'
exclude: false
label: 'Entity language'
exclude: true
alter:
alter_text: false
text: ''
......@@ -282,11 +284,10 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: timestamp
type: language
settings:
date_format: medium
custom_date_format: ''
timezone: ''
link_to_entity: false
native_language: true
group_column: value
group_columns: { }
group_rows: true
......@@ -298,17 +299,17 @@ display:
separator: ', '
field_api_classes: false
entity_type: linkcheckerlink
entity_field: last_check
entity_field: entity_langcode
plugin_id: field
method:
id: method
linkcheckerlink_page_entity_label:
id: linkcheckerlink_page_entity_label
table: linkchecker_link
field: method
field: linkcheckerlink_page_entity_label
relationship: none
group_type: group
admin_label: ''
label: Method
exclude: false
label: ''
exclude: true
alter:
alter_text: false
text: ''
......@@ -340,7 +341,7 @@ display:
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
......@@ -348,31 +349,17 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
link_to_entity: 1
entity_type: linkcheckerlink
entity_field: method
plugin_id: field
code:
id: code
plugin_id: linkcheckerlink_page_entity_label
url:
id: url
table: linkchecker_link
field: code
field: url
relationship: none
group_type: group
admin_label: ''
label: 'Status code'
label: URL
exclude: false
alter:
alter_text: false
......@@ -414,10 +401,8 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
settings:
thousand_separator: ''
prefix_suffix: true
type: uri_link
settings: { }
group_column: value
group_columns: { }
group_rows: true
......@@ -429,16 +414,16 @@ display:
separator: ', '
field_api_classes: false
entity_type: linkcheckerlink
entity_field: code
entity_field: url
plugin_id: field
error:
id: error
last_check:
id: last_check
table: linkchecker_link
field: error
field: last_check
relationship: none
group_type: group
admin_label: ''
label: Error
label: 'Last checked'
exclude: false
alter:
alter_text: false
......@@ -470,7 +455,7 @@ display:
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_class: nowrap
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
......@@ -480,8 +465,11 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: basic_string
settings: { }
type: timestamp
settings:
date_format: medium
custom_date_format: ''
timezone: ''
group_column: value
group_columns: { }
group_rows: true
......@@ -493,16 +481,16 @@ display:
separator: ', '
field_api_classes: false
entity_type: linkcheckerlink
entity_field: error
entity_field: last_check
plugin_id: field
fail_count:
id: fail_count
method:
id: method
table: linkchecker_link
field: fail_count
field: method
relationship: none
group_type: group
admin_label: ''
label: 'Fail count'
label: Method
exclude: false
alter:
alter_text: false
......@@ -544,10 +532,9 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: number_integer
type: string
settings:
thousand_separator: ''
prefix_suffix: true
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
......@@ -559,16 +546,16 @@ display:
separator: ', '
field_api_classes: false
entity_type: linkcheckerlink
entity_field: fail_count
entity_field: method
plugin_id: field
entity_id__target_id:
id: entity_id__target_id
code:
id: code
table: linkchecker_link
field: entity_id__target_id
field: code
relationship: none
group_type: group
admin_label: ''
label: 'Entity id'
label: 'Status code'
exclude: false
alter:
alter_text: false
......@@ -600,7 +587,7 @@ display:
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_class: nowrap
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
......@@ -609,11 +596,12 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: dynamic_entity_reference_label
click_sort_column: value
type: number_integer
settings:
link: true
group_column: ''
thousand_separator: ''
prefix_suffix: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
......@@ -624,16 +612,16 @@ display:
separator: ', '
field_api_classes: false
entity_type: linkcheckerlink
entity_field: entity_id
entity_field: code
plugin_id: field
entity_field:
id: entity_field
error:
id: error
table: linkchecker_link
field: entity_field
field: error
relationship: none
group_type: group
admin_label: ''
label: 'Entity field'
label: Error
exclude: false
alter:
alter_text: false
......@@ -675,9 +663,8 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
type: basic_string
settings: { }
group_column: value
group_columns: { }
group_rows: true
......@@ -689,16 +676,16 @@ display:
separator: ', '
field_api_classes: false
entity_type: linkcheckerlink
entity_field: entity_field
entity_field: error
plugin_id: field
entity_langcode:
id: entity_langcode
fail_count:
id: fail_count
table: linkchecker_link
field: entity_langcode
field: fail_count
relationship: none
group_type: group
admin_label: ''
label: 'Entity language'
label: 'Fail count'
exclude: false
alter:
alter_text: false
......@@ -730,7 +717,7 @@ display:
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_class: nowrap
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
......@@ -740,10 +727,10 @@ display:
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: language
type: number_integer
settings:
link_to_entity: false
native_language: true
thousand_separator: ''
prefix_suffix: true
group_column: value
group_columns: { }
group_rows: true
......@@ -755,8 +742,57 @@ display:
separator: ', '
field_api_classes: false
entity_type: linkcheckerlink
entity_field: entity_langcode
entity_field: fail_count
plugin_id: field
nothing:
id: nothing
table: views
field: nothing
relationship: none
group_type: group
admin_label: ''
label: 'Found here'
exclude: false
alter:
alter_text: true
text: "<b>Entity:</b> {{ linkcheckerlink_page_entity_label }}<br />\r\n<b>Field:</b> {{ entity_field }}<br />\r\n<b>Language:</b> {{ entity_langcode }}"
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: false
plugin_id: custom
status:
id: status
table: linkchecker_link
......@@ -764,7 +800,7 @@ display:
relationship: none
group_type: group
admin_label: ''
label: 'Check link status'
label: 'Test link'
exclude: false
alter:
alter_text: false
......@@ -796,7 +832,7 @@ display:
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_class: nowrap
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
......@@ -825,16 +861,13 @@ display:
entity_field: status
plugin_id: field
operations:
id: operations
table: linkchecker_link
field: operations
id: operations
entity_type: null
entity_field: null
plugin_id: entity_operations
relationship: none
group_type: group
admin_label: ''
label: 'Operations links'
label: Operations
exclude: false
alter:
alter_text: false
......@@ -876,6 +909,9 @@ display:
empty_zero: false
hide_alter_empty: true
destination: false
entity_type: null
entity_field: null
plugin_id: entity_operations
filters:
url:
id: url
......@@ -903,6 +939,8 @@ display:
anonymous: '0'
administrator: '0'
placeholder: ''
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
......@@ -918,6 +956,87 @@ display:
entity_type: linkcheckerlink
entity_field: url
plugin_id: string
code_1:
id: code_1
table: linkchecker_link
field: code
relationship: none
group_type: group
admin_label: ''
operator: '='
value:
min: ''
max: ''
value: ''
group: 1
exposed: true
expose:
operator_id: code_1_op
label: 'Status code'
description: null
use_operator: false
operator: code_1_op
operator_limit_selection: false
operator_list: { }
identifier: code_1
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
placeholder: null
min_placeholder: null
max_placeholder: null
is_grouped: true
group_info:
label: Result
description: ''
identifier: result
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items:
1:
title: Failed
operator: 'not between'
value:
value: ''
min: '200'
max: '299'
2:
title: 'Success (2xx)'
operator: between
value:
value: ''
min: '200'
max: '299'
3:
title: 'Redirect (3xx)'
operator: between
value:
value: ''
min: '300'
max: '399'
4:
title: 'Client error (4xx)'
operator: between
value:
value: ''
min: '400'
max: '499'
5:
title: 'Server error (5xx)'
operator: between
value:
value: ''
min: '500'
max: '599'
entity_type: linkcheckerlink
entity_field: code
plugin_id: numeric
code:
id: code
table: linkchecker_link
......@@ -949,6 +1068,8 @@ display:
placeholder: ''
min_placeholder: ''
max_placeholder: ''
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
......@@ -990,6 +1111,8 @@ display:
anonymous: '0'
administrator: '0'
reduce: false
operator_limit_selection: false
operator_list: { }
is_grouped: false
group_info:
label: ''
......@@ -1008,7 +1131,17 @@ display:
sorts: { }
title: 'Broken links report'
header: { }
footer: { }
footer:
result:
id: result
table: views
field: result
relationship: none
group_type: group
admin_label: ''
empty: false
content: 'Displaying @start - @end of @total'
plugin_id: result
empty: { }
relationships: { }
arguments: { }
......
......@@ -5,6 +5,7 @@
* Installation file for Link Checker module.
*/
use Drupal\Core\Config\FileStorage;
use Drupal\user\Entity\User;
use Drupal\Core\Entity\EntityTypeInterface;
......@@ -48,3 +49,12 @@ function linkchecker_schema() {
return $schema;
}
/**
* Added new functionality to broken links view.
*/
function linkchecker_update_8001() {
$config_path = drupal_get_path('module', 'linkchecker') . '/config/optional';
$config_source = new FileStorage($config_path);
\Drupal::service('config.installer')->installOptionalConfig($config_source);
}
......@@ -69,7 +69,7 @@ function linkchecker_watchdog_log($type, $message, $variables = [], $severity =
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function linkchecker_form_field_config_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
function linkchecker_form_field_config_form_alter(&$form, FormStateInterface $form_state, $form_id) {
/** @var \Drupal\field\FieldConfigInterface $fieldConfig */
$fieldConfig = $form_state->getFormObject()->getEntity();
......@@ -192,3 +192,21 @@ function linkchecker_entity_delete(EntityInterface $entity) {
\Drupal::service('linkchecker.clean_up')->cleanUpForEntity($entity);
}
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function linkchecker_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form['#id'] == 'views-exposed-form-broken-links-report-page-1') {
$form['result']['#states'] = [
'enabled' => [
':input[name="code"]' => ['value' => ''],
],
];
$form['code']['#states'] = [
'enabled' => [
'select[name="result"]' => ['value' => 'All'],
],
];
}
}
<?php
/**
* @file
* Contains Views integration for the linkchecker module.
*/
/**
* Implements hook_views_data().
*/
function linkchecker_views_data_alter(array &$data) {
$data['linkchecker_link']['linkcheckerlink_page_entity_label'] = [
'field' => [
'title' => t('Page entity label'),
'help' => t('The label of the entity that is related to the file.'),
'id' => 'linkcheckerlink_page_entity_label',
],
];
}
<?php
namespace Drupal\linkchecker\Plugin\views\field;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Drupal\Core\Form\FormStateInterface;
use Drupal\linkchecker\LinkCheckerLinkInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Field handler that builds the page entity label for the linkchecker_link.
*
* @ingroup views_field_handlers
*
* @ViewsField("linkcheckerlink_page_entity_label")
*/
class LinkcheckerLinkPageEntityLabel extends FieldPluginBase {
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['link_to_entity'] = ['default' => FALSE];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['link_to_entity'] = [
'#title' => $this->t('Link to entity'),
'#description' => $this->t('Make entity label a link to entity page.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_entity']),
];
parent::buildOptionsForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function query() {
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$linkchecker_link = $this->getEntity($values);
if (!$linkchecker_link instanceof LinkCheckerLinkInterface) {
return '';
}
if (!$linkchecker_link->hasField('entity_id')) {
return '';
}
if ($linkchecker_link->get('entity_id')->isEmpty()) {
return '';
}
$linked_entity = $linkchecker_link->get('entity_id')->entity;
if (!$linked_entity instanceof EntityInterface) {
return '';
}
if ($linked_entity->getEntityTypeId() === 'paragraph' && $linked_entity->getParentEntity() !== NULL) {
$linked_entity = $linked_entity->getParentEntity();
}
if (!empty($this->options['link_to_entity'])) {
try {
$this->options['alter']['url'] = $linked_entity->toUrl();
$this->options['alter']['make_link'] = TRUE;
}
catch (UndefinedLinkTemplateException $e) {
$this->options['alter']['make_link'] = FALSE;
}
catch (EntityMalformedException $e) {
$this->options['alter']['make_link'] = FALSE;
}
}
return $this->sanitizeValue($linked_entity->label());
}
}
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