|
@@ -91,14 +91,18 @@ class PodcastRorController extends ControllerBase {
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
- public function podcast($query, $description) {
|
|
|
+ public function podcast($query, $title, $description, $link,
|
|
|
+ $expected_episodes_per_week
|
|
|
+ ) {
|
|
|
// TODO: add $title argument to the function
|
|
|
$template = $this->twig->loadTemplate(drupal_get_path('module', 'podcast_ror') . '/templates/podcast.html.twig');
|
|
|
$query_results = $this->query($query);
|
|
|
$tmpl_data = [ 'ror' => array('podcast' => $query_results,
|
|
|
'url' => \Drupal::service('path.current')->getPath(),
|
|
|
'description' => $description,
|
|
|
- 'title' => 'Radio Onda Rossa',
|
|
|
+ 'title' => $title,
|
|
|
+ 'link' => $link,
|
|
|
+ 'expected_episodes_per_week' => $expected_episodes_per_week,
|
|
|
)];
|
|
|
$headers = array(
|
|
|
'Content-Type' => 'application/rss+xml',
|
|
@@ -126,19 +130,40 @@ class PodcastRorController extends ControllerBase {
|
|
|
}
|
|
|
public function podcastAll() {
|
|
|
$query = \Drupal::entityQuery('node');
|
|
|
- return $this->podcast($query, 'Tutti gli aggiornamenti, i redazionali, le trasmissioni della radio di chi se la sente');
|
|
|
+ return $this->podcast($query, 'Radio Onda Rossa', 'Tutti gli aggiornamenti, i redazionali, le trasmissioni della radio di chi se la sente',
|
|
|
+ 'http://www.ondarossa.info/',
|
|
|
+ 30
|
|
|
+ );
|
|
|
}
|
|
|
public function podcastByType($contentType) {
|
|
|
$query = \Drupal::entityQuery('node')
|
|
|
->condition('type', $contentType);
|
|
|
// TODO: get "nice name" for $contentType
|
|
|
- return $this->podcast($query, str_replace('+', ', ', $contentType));
|
|
|
+ $what = str_replace('+', ', ', $contentType);
|
|
|
+ return $this->podcast($query,
|
|
|
+ $what . ' (Radio Onda Rossa)',
|
|
|
+ $what,
|
|
|
+ 'http://www.ondarossa.info/',
|
|
|
+ 30
|
|
|
+ );
|
|
|
}
|
|
|
public function podcastByTrxID($trxID) {
|
|
|
+ $term = \Drupal\taxonomy\Entity\Term::load($trxID);
|
|
|
+ $trxName = $term->getName();
|
|
|
+ $trxDescriptionHTML = $term->getDescription();
|
|
|
+ $trxDescription = strip_tags($trxDescriptionHTML);
|
|
|
+ $trxURL = \Drupal\Core\Url::fromRoute('entity.taxonomy_term.canonical',
|
|
|
+ ['taxonomy_term' => $trxID],
|
|
|
+ ['absolute' => TRUE])->toString();
|
|
|
$query = \Drupal::entityQuery('node')
|
|
|
->condition('type', 'news_trasmissioni')
|
|
|
->condition('field_trasmissione', $trxID);
|
|
|
- // TODO: discover Trx name, and pass it as podcast title
|
|
|
- return $this->podcast($query, 'Trasmissione ' . $trxID);
|
|
|
+
|
|
|
+ return $this->podcast($query,
|
|
|
+ $trxName . ' (Radio Onda Rossa)',
|
|
|
+ $trxDescription,
|
|
|
+ $trxURL,
|
|
|
+ 1,
|
|
|
+ );
|
|
|
}
|
|
|
}
|