Chris@0: ' . t('About') . ''; Chris@0: $output .= '
' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online documentation for the Aggregator module.', [':aggregator-module' => 'https://www.drupal.org/documentation/modules/aggregator']) . '
'; Chris@0: $output .= '' . t('Many sites publish their headlines and posts in feeds, using a number of standardized XML-based formats. The aggregator supports RSS, RDF, and Atom.') . '
'; Chris@18: $output .= '' . t('Current feeds are listed below, and new feeds may be added. For each feed, the latest items block may be enabled at the blocks administration page.', [':addfeed' => Url::fromRoute('aggregator.feed_add')->toString(), ':block' => (\Drupal::moduleHandler()->moduleExists('block')) ? Url::fromRoute('block.admin_display')->toString() : '#']) . '
'; Chris@0: return $output; Chris@0: Chris@0: case 'aggregator.feed_add': Chris@0: return '' . t('Add a feed in RSS, RDF or Atom format. A feed may only have one entry.') . '
'; Chris@0: Chris@0: case 'aggregator.opml_add': Chris@0: return '' . t('OPML is an XML format for exchanging feeds between aggregators. A single OPML document may contain many feeds. Aggregator uses this file to import all feeds at once. Upload a file from your computer or enter a URL where the OPML file can be downloaded.') . '
'; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_theme(). Chris@0: */ Chris@0: function aggregator_theme() { Chris@0: return [ Chris@0: 'aggregator_feed' => [ Chris@0: 'render element' => 'elements', Chris@0: 'file' => 'aggregator.theme.inc', Chris@0: ], Chris@0: 'aggregator_item' => [ Chris@0: 'render element' => 'elements', Chris@0: 'file' => 'aggregator.theme.inc', Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_entity_extra_field_info(). Chris@0: */ Chris@0: function aggregator_entity_extra_field_info() { Chris@0: $extra = []; Chris@0: Chris@0: $extra['aggregator_feed']['aggregator_feed'] = [ Chris@0: 'display' => [ Chris@0: 'items' => [ Chris@0: 'label' => t('Items'), Chris@0: 'description' => t('Items associated with this feed'), Chris@0: 'weight' => 0, Chris@0: ], Chris@0: // @todo Move to a formatter at https://www.drupal.org/node/2339917. Chris@0: 'image' => [ Chris@0: 'label' => t('Image'), Chris@0: 'description' => t('The feed image'), Chris@0: 'weight' => 2, Chris@0: ], Chris@0: // @todo Move to a formatter at https://www.drupal.org/node/2149845. Chris@0: 'description' => [ Chris@0: 'label' => t('Description'), Chris@0: 'description' => t('The description of this feed'), Chris@0: 'weight' => 3, Chris@0: ], Chris@0: 'more_link' => [ Chris@0: 'label' => t('More link'), Chris@0: 'description' => t('A more link to the feed detail page'), Chris@0: 'weight' => 5, Chris@0: ], Chris@0: 'feed_icon' => [ Chris@0: 'label' => t('Feed icon'), Chris@0: 'description' => t('An icon that links to the feed URL'), Chris@0: 'weight' => 6, Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $extra['aggregator_item']['aggregator_item'] = [ Chris@0: 'display' => [ Chris@0: // @todo Move to a formatter at https://www.drupal.org/node/2149845. Chris@0: 'description' => [ Chris@0: 'label' => t('Description'), Chris@0: 'description' => t('The description of this feed item'), Chris@0: 'weight' => 2, Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: return $extra; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_cron(). Chris@0: * Chris@0: * Queues news feeds for updates once their refresh interval has elapsed. Chris@0: */ Chris@0: function aggregator_cron() { Chris@0: $queue = \Drupal::queue('aggregator_feeds'); Chris@0: Chris@0: $ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh(); Chris@0: foreach (Feed::loadMultiple($ids) as $feed) { Chris@0: if ($queue->createItem($feed)) { Chris@0: // Add timestamp to avoid queueing item more than once. Chris@0: $feed->setQueuedTime(REQUEST_TIME); Chris@0: $feed->save(); Chris@0: } Chris@0: } Chris@0: Chris@0: // Delete queued timestamp after 6 hours assuming the update has failed. Chris@0: $ids = \Drupal::entityQuery('aggregator_feed') Chris@0: ->condition('queued', REQUEST_TIME - (3600 * 6), '<') Chris@0: ->execute(); Chris@0: Chris@0: if ($ids) { Chris@0: $feeds = Feed::loadMultiple($ids); Chris@0: foreach ($feeds as $feed) { Chris@0: $feed->setQueuedTime(0); Chris@0: $feed->save(); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the list of allowed tags. Chris@0: * Chris@0: * @return array Chris@0: * The list of allowed tags. Chris@0: * Chris@0: * @internal Chris@0: */ Chris@0: function _aggregator_allowed_tags() { Chris@0: return preg_split('/\s+|<|>/', \Drupal::config('aggregator.settings')->get('items.allowed_html'), -1, PREG_SPLIT_NO_EMPTY); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_HOOK() for block templates. Chris@0: */ Chris@0: function aggregator_preprocess_block(&$variables) { Chris@0: if ($variables['configuration']['provider'] == 'aggregator') { Chris@0: $variables['attributes']['role'] = 'complementary'; Chris@0: } Chris@0: }