Loading core/modules/node/src/Plugin/views/row/Rss.php +0 −9 Original line number Diff line number Diff line Loading @@ -119,15 +119,6 @@ public function render($row) { if (!empty($node->rss_namespaces)) { $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $node->rss_namespaces); } elseif (function_exists('rdf_get_namespaces')) { // Merge RDF namespaces in the XML namespaces in case they are used // further in the RSS content. $xml_rdf_namespaces = []; foreach (rdf_get_namespaces() as $prefix => $uri) { $xml_rdf_namespaces['xmlns:' . $prefix] = $uri; } $this->view->style_plugin->namespaces += $xml_rdf_namespaces; } $item = new \stdClass(); if ($display_mode != 'title') { Loading core/modules/rdf/rdf.module +18 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\Core\Url; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Template\Attribute; use Drupal\node\NodeInterface; use Drupal\rdf\Entity\RdfMapping; /** Loading Loading @@ -228,6 +229,23 @@ function rdf_entity_prepare_view($entity_type, array $entities, array $displays) } } /** * Implements hook_ENTITY_TYPE_build_defaults_alter(). */ function rdf_node_build_defaults_alter(array &$build, NodeInterface $node) { // Ensure that RSS views define the RDF namespaces. // @see \Drupal\node\Plugin\views\row\Rss::render() if (!isset($node->rss_namespaces)) { $node->rss_namespaces = []; } foreach (rdf_get_namespaces() as $prefix => $uri) { if ($prefix === 'dc') { continue; } $node->rss_namespaces["xmlns:$prefix"] = $uri; } } /** * Implements hook_ENTITY_TYPE_storage_load() for comment entities. */ Loading core/modules/rdf/tests/rdf_test_namespaces/config/optional/views.view.rdf_rss_test.yml 0 → 100644 +191 −0 Original line number Diff line number Diff line langcode: en status: true dependencies: module: - node id: rdf_rss_test label: RDF RSS Test module: views description: '' tag: '' base_table: node_field_data base_field: nid display: default: id: default display_title: Default display_plugin: default position: 0 display_options: fields: title: id: title table: node_field_data field: title relationship: none group_type: group admin_label: '' entity_type: node entity_field: title plugin_id: field label: '' exclude: false alter: alter_text: false make_link: false absolute: false word_boundary: false ellipsis: false strip_tags: false trim: false 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: true click_sort_column: value type: string settings: link_to_entity: true 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 pager: type: mini options: offset: 0 items_per_page: 10 total_pages: null id: 0 tags: next: ›› previous: ‹‹ expose: items_per_page: false items_per_page_label: 'Items per page' items_per_page_options: '5, 10, 25, 50' items_per_page_options_all: false items_per_page_options_all_label: '- All -' offset: false offset_label: Offset exposed_form: type: basic options: submit_button: Apply reset_button: false reset_button_label: Reset exposed_sorts_label: 'Sort by' expose_sort_order: true sort_asc_label: Asc sort_desc_label: Desc access: type: none options: { } cache: type: none options: { } empty: { } sorts: created: id: created table: node_field_data field: created relationship: none group_type: group admin_label: '' entity_type: node entity_field: created plugin_id: date order: DESC expose: label: '' field_identifier: '' exposed: false granularity: second arguments: { } filters: status: id: status table: node_field_data field: status entity_type: node entity_field: status plugin_id: boolean value: '1' group: 1 expose: operator: '' style: type: default options: grouping: { } row_class: '' default_row_class: true uses_fields: false row: type: fields options: default_field_elements: true inline: { } separator: '' hide_empty: false query: type: views_query options: query_comment: '' disable_sql_rewrite: false distinct: false replica: false query_tags: { } relationships: { } header: { } footer: { } display_extenders: { } cache_metadata: max-age: -1 contexts: - 'languages:language_content' - 'languages:language_interface' - url.query_args - 'user.node_grants:view' tags: { } feed_1: id: feed_1 display_title: Feed display_plugin: feed position: 1 display_options: style: type: rss options: uses_fields: false description: '' row: type: node_rss options: relationship: none view_mode: default display_extenders: { } path: rdf-rss-test cache_metadata: max-age: -1 contexts: - 'languages:language_content' - 'languages:language_interface' - 'user.node_grants:view' tags: { } core/modules/rdf/tests/src/Functional/RssViewIntegrationTest.php 0 → 100644 +52 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\rdf\Functional; use Drupal\Tests\BrowserTestBase; /** * @group rdf * @group legacy */ class RssViewIntegrationTest extends BrowserTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'node', 'rdf_test_namespaces', 'views', ]; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Tests that RSS views have RDF's XML namespaces defined. */ public function testRdfNamespacesAreAddedToRssViews(): void { // RDF's namespaces are only attached when there is content in the feed. $node_type = $this->drupalCreateContentType()->id(); $this->drupalCreateNode(['type' => $node_type]); $this->drupalGet('rdf-rss-test'); $this->assertSession()->statusCodeEquals(200); // Mink insists on treating the page as an HTML document, so we have to use // PHP's built-in DOM extension to examine the RSS feed. $xml = $this->getSession()->getPage()->getContent(); $document = new \DOMDocument(); $this->assertTrue($document->loadXML($xml)); foreach (rdf_get_namespaces() as $prefix => $uri) { if ($prefix === 'dc') { continue; } $this->assertSame($uri, $document->lookupNamespaceURI($prefix)); } } } Loading
core/modules/node/src/Plugin/views/row/Rss.php +0 −9 Original line number Diff line number Diff line Loading @@ -119,15 +119,6 @@ public function render($row) { if (!empty($node->rss_namespaces)) { $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $node->rss_namespaces); } elseif (function_exists('rdf_get_namespaces')) { // Merge RDF namespaces in the XML namespaces in case they are used // further in the RSS content. $xml_rdf_namespaces = []; foreach (rdf_get_namespaces() as $prefix => $uri) { $xml_rdf_namespaces['xmlns:' . $prefix] = $uri; } $this->view->style_plugin->namespaces += $xml_rdf_namespaces; } $item = new \stdClass(); if ($display_mode != 'title') { Loading
core/modules/rdf/rdf.module +18 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\Core\Url; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Template\Attribute; use Drupal\node\NodeInterface; use Drupal\rdf\Entity\RdfMapping; /** Loading Loading @@ -228,6 +229,23 @@ function rdf_entity_prepare_view($entity_type, array $entities, array $displays) } } /** * Implements hook_ENTITY_TYPE_build_defaults_alter(). */ function rdf_node_build_defaults_alter(array &$build, NodeInterface $node) { // Ensure that RSS views define the RDF namespaces. // @see \Drupal\node\Plugin\views\row\Rss::render() if (!isset($node->rss_namespaces)) { $node->rss_namespaces = []; } foreach (rdf_get_namespaces() as $prefix => $uri) { if ($prefix === 'dc') { continue; } $node->rss_namespaces["xmlns:$prefix"] = $uri; } } /** * Implements hook_ENTITY_TYPE_storage_load() for comment entities. */ Loading
core/modules/rdf/tests/rdf_test_namespaces/config/optional/views.view.rdf_rss_test.yml 0 → 100644 +191 −0 Original line number Diff line number Diff line langcode: en status: true dependencies: module: - node id: rdf_rss_test label: RDF RSS Test module: views description: '' tag: '' base_table: node_field_data base_field: nid display: default: id: default display_title: Default display_plugin: default position: 0 display_options: fields: title: id: title table: node_field_data field: title relationship: none group_type: group admin_label: '' entity_type: node entity_field: title plugin_id: field label: '' exclude: false alter: alter_text: false make_link: false absolute: false word_boundary: false ellipsis: false strip_tags: false trim: false 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: true click_sort_column: value type: string settings: link_to_entity: true 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 pager: type: mini options: offset: 0 items_per_page: 10 total_pages: null id: 0 tags: next: ›› previous: ‹‹ expose: items_per_page: false items_per_page_label: 'Items per page' items_per_page_options: '5, 10, 25, 50' items_per_page_options_all: false items_per_page_options_all_label: '- All -' offset: false offset_label: Offset exposed_form: type: basic options: submit_button: Apply reset_button: false reset_button_label: Reset exposed_sorts_label: 'Sort by' expose_sort_order: true sort_asc_label: Asc sort_desc_label: Desc access: type: none options: { } cache: type: none options: { } empty: { } sorts: created: id: created table: node_field_data field: created relationship: none group_type: group admin_label: '' entity_type: node entity_field: created plugin_id: date order: DESC expose: label: '' field_identifier: '' exposed: false granularity: second arguments: { } filters: status: id: status table: node_field_data field: status entity_type: node entity_field: status plugin_id: boolean value: '1' group: 1 expose: operator: '' style: type: default options: grouping: { } row_class: '' default_row_class: true uses_fields: false row: type: fields options: default_field_elements: true inline: { } separator: '' hide_empty: false query: type: views_query options: query_comment: '' disable_sql_rewrite: false distinct: false replica: false query_tags: { } relationships: { } header: { } footer: { } display_extenders: { } cache_metadata: max-age: -1 contexts: - 'languages:language_content' - 'languages:language_interface' - url.query_args - 'user.node_grants:view' tags: { } feed_1: id: feed_1 display_title: Feed display_plugin: feed position: 1 display_options: style: type: rss options: uses_fields: false description: '' row: type: node_rss options: relationship: none view_mode: default display_extenders: { } path: rdf-rss-test cache_metadata: max-age: -1 contexts: - 'languages:language_content' - 'languages:language_interface' - 'user.node_grants:view' tags: { }
core/modules/rdf/tests/src/Functional/RssViewIntegrationTest.php 0 → 100644 +52 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\rdf\Functional; use Drupal\Tests\BrowserTestBase; /** * @group rdf * @group legacy */ class RssViewIntegrationTest extends BrowserTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'node', 'rdf_test_namespaces', 'views', ]; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Tests that RSS views have RDF's XML namespaces defined. */ public function testRdfNamespacesAreAddedToRssViews(): void { // RDF's namespaces are only attached when there is content in the feed. $node_type = $this->drupalCreateContentType()->id(); $this->drupalCreateNode(['type' => $node_type]); $this->drupalGet('rdf-rss-test'); $this->assertSession()->statusCodeEquals(200); // Mink insists on treating the page as an HTML document, so we have to use // PHP's built-in DOM extension to examine the RSS feed. $xml = $this->getSession()->getPage()->getContent(); $document = new \DOMDocument(); $this->assertTrue($document->loadXML($xml)); foreach (rdf_get_namespaces() as $prefix => $uri) { if ($prefix === 'dc') { continue; } $this->assertSame($uri, $document->lookupNamespaceURI($prefix)); } } }