' . t('About') . ''; $output .= '

' . t('The Announcements module displays announcements from the Drupal community. For more information, see the online documentation for the Announcements module.', array('@documentation' => 'https://www.drupal.org/docs/core-modules-and-themes/core-modules/announcements-feed')) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
' . t('Accessing announcements') . '
'; $output .= '
' . t('Users with the "View drupal.org announcements" permission may click on the "Announcements" item in the administration menu, or access Announcements, to see all announcements relevant to the Drupal version of your site.', array('@link' => url('admin/announcements_feed'))) . '
'; $output .= '
'; return $output; } } /** * Implements hook_menu(). */ function announcements_feed_menu() { $items['admin/announcements_feed'] = array( 'title' => 'Announcements', 'description' => 'Announcements and updates posted by the drupal.org community.', 'page callback' => 'announcements_feed_get_announcements', 'access arguments' => array('access announcements'), 'position' => 'left', 'weight' => 2, 'file' => 'announcements_feed.inc', 'options' => array( 'attributes' => array( 'class' => array('announcement-menu-class'), ), ), ); return $items; } /** * Implements hook_permission(). */ function announcements_feed_permission() { return array( 'access announcements' => array( 'title' => t('View official announcements related to Drupal'), ), ); } /** * Implements hook_theme(). */ function announcements_feed_theme() { return array( 'announcements_feed' => array( 'variables' => array( 'featured' => NULL, 'standard' => NULL, 'feed_link' => NULL, 'count' => 0, ), 'template' => 'announcements-feed', 'path' => drupal_get_path('module', 'announcements_feed'), ), ); } /** * Processes variables for announcements-feed.tpl.php. * * @see announcements-feed.tpl.php */ function template_preprocess_announcements_feed(&$variables) { if (!empty($variables['featured'])) { foreach($variables['featured'] as &$announcement) { _announcements_feed_preprocess_item($announcement); } } if (!empty($variables['standard'])) { foreach($variables['standard'] as &$announcement) { _announcements_feed_preprocess_item($announcement); } } if (isset($variables['feed_link'])) { $variables['feed_link'] = check_url($variables['feed_link']); } } /** * Helper to preprocess individual announcement items. */ function _announcements_feed_preprocess_item(&$item) { $item['title'] = filter_xss($item['title']); $item['teaser'] = filter_xss($item['teaser']); $item['link'] = check_url($item['link']); $item['date_modified'] = check_plain($item['date_modified']); $item['date_published'] = check_plain($item['date_published']); $item['version'] = check_plain($item['version']); } /** * Implements hook_page_alter(). */ function announcements_feed_page_alter(&$page) { if (isset($page['page_top']['toolbar'])) { // If the toolbar is available, add a pre-render function to add the class. $page['page_top']['toolbar']['#pre_render'][] = 'announcements_feed_toolbar_pre_render_alter'; } } /** * Pre-render function for adding default class to announcement link. */ function announcements_feed_toolbar_pre_render_alter($toolbar) { $path = drupal_get_path('module', 'announcements_feed'); $toolbar['#attached']['css'][] = $path . '/announcements_feed-toolbar.css'; module_load_include('inc', 'announcements_feed'); foreach ($toolbar['toolbar_menu']['#links'] as &$link) { if ($link['href'] === 'admin/announcements_feed') { $link['attributes']['class'][] = 'announcement-default'; } } return $toolbar; } /** * Implements hook_cron(). */ function announcements_feed_cron() { module_load_include('inc', 'announcements_feed', 'announcements_feed'); $cron_interval = variable_get('announcements_feed_cron_interval', ANNOUNCEMENTS_FEED_DEFAULT_CRON_INTERVAL); $last_check = variable_get('announcements_feed_last_fetch', 0); $time = time(); if (($time - $last_check) > $cron_interval) { try { announcements_feed_fetch(TRUE); // Update the last_fetch variable to the current time. variable_set('announcements_feed_last_fetch', $time); } catch (Exception $e) { watchdog('announcements_feed', 'Exception occurred: @message', array('@message' => $e->getMessage()), WATCHDOG_ERROR); } } }