Skip to content

Commit c06f2c7

Browse files
committed
Fixing various channel elements.
1 parent 063aa13 commit c06f2c7

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
lines changed

itunes_rss.module

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,17 @@
44
* Implements hook_theme().
55
*/
66
function itunes_rss_theme() {
7-
$theme_registry['views_view_itunes_rss'] = array (
8-
'variables' =>
9-
array (
7+
$theme_registry['views_view_itunes_rss'] = [
8+
'variables' => [
109
'view' => NULL,
1110
'options' => NULL,
1211
'rows' => NULL,
1312
'title' => NULL,
14-
),
13+
],
1514
'path' => 'templates',
16-
'includes' =>
17-
array (
18-
0 => 'core/modules/views/views.theme.inc',
19-
),
15+
'includes' => ['core/modules/views/views.theme.inc'],
2016
'template' => 'views-view-itunes-rss',
21-
);
22-
17+
];
2318
return $theme_registry;
2419
}
2520

@@ -41,4 +36,7 @@ function template_preprocess_views_view_itunes_rss(&$variables) {
4136
$style = $view->style_plugin;
4237
$variables['image_url'] = $style->getImage();
4338
$variables['itunes_category'] = $style->options['category'];
39+
$variables['itunes_explicit'] = $style->options['explicit'] ? 'yes' : 'no';
40+
$variables['itunes_name'] = $style->options['name'];
41+
$variables['itunes_email'] = $style->options['email'];
4442
}

src/Plugin/views/style/ItunesRss.php

+29-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class ItunesRss extends Rss {
3232
public function getItunesChannelFields() {
3333
$fields = [
3434
'type',
35-
'owner',
35+
'name',
36+
'email',
3637
'author',
3738
'subtitle',
3839
'summary',
@@ -53,6 +54,11 @@ public function getItunesChannelFields() {
5354
protected function defineOptions() {
5455
$options = parent::defineOptions();
5556
$options['image'] = ['default' => ''];
57+
$options['name'] = ['default' => ''];
58+
$options['email'] = ['default' => ''];
59+
$options['category'] = ['default' => ''];
60+
$options['sub_category'] = ['default' => ''];
61+
$options['explicit'] = ['default' => ''];
5662

5763
return $options;
5864
}
@@ -74,6 +80,20 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
7480
'#description' => $this->t('This will appear in the RSS feed itself.'),
7581
'#maxlength' => 1024,
7682
];
83+
$form['name'] = [
84+
'#type' => 'textfield',
85+
'#title' => $this->t('Owner name.'),
86+
'#default_value' => $this->options['name'],
87+
'#description' => $this->t('This will appear in the RSS feed itself.'),
88+
'#maxlength' => 1024,
89+
];
90+
$form['email'] = [
91+
'#type' => 'textfield',
92+
'#title' => $this->t('Owner email.'),
93+
'#default_value' => $this->options['email'],
94+
'#description' => $this->t('This will appear in the RSS feed itself.'),
95+
'#maxlength' => 1024,
96+
];
7797
$form['category'] = [
7898
'#type' => 'textfield',
7999
'#title' => $this->t('Category'),
@@ -88,6 +108,12 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
88108
'#description' => $this->t('This will appear in the RSS feed itself.'),
89109
'#maxlength' => 1024,
90110
];
111+
$form['explicit'] = [
112+
'#type' => 'checkbox',
113+
'#title' => $this->t('Explicit'),
114+
'#default_value' => $this->options['explicit'],
115+
'#description' => $this->t('This will appear in the RSS feed itself.'),
116+
];
91117
}
92118

93119
/**
@@ -110,7 +136,8 @@ public function render() {
110136

111137
$this->namespaces = [
112138
'xmlns:itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd',
113-
'version' => '2.0',
139+
'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
140+
'xmlns:atom' => 'http://www.w3.org/2005/Atom',
114141
];
115142

116143
return $build;

templates/views-view-itunes-rss.html.twig

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<channel>
2323
<title>{{ title }}</title>
2424
<link>{{ link }}</link>
25+
<atom:link href="{{ link }}" rel="self" type="application/rss+xml"/>
2526
<description>{{ description }}</description>
2627
<language>{{ langcode }}</language>
2728
{% if image_url %}
@@ -38,6 +39,13 @@
3839
{% endif %}
3940
</itunes:category>
4041
{% endif %}
42+
{% if itunes_name and itunes_email %}
43+
<itunes:owner>
44+
<itunes:name>{{ itunes_name }}</itunes:name>
45+
<itunes:email>{{ itunes_email }}</itunes:email>
46+
</itunes:owner>
47+
{% endif %}
48+
<itunes:explicit>{{ itunes_explicit }}</itunes:explicit>
4149
{{ channel_elements }}
4250
{{ items }}
4351
</channel>

0 commit comments

Comments
 (0)