'Drupal News', 'page callback' => 'drupalorg_news_page', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } /** * Use the regular node page, but with a title. */ function drupalorg_news_page() { $output = node_page_default(); drupal_set_title(t('Drupal News')); return $output; } /** * Implementation of hook_form_alter(). */ function drupalorg_news_form_alter(&$form, $form_state, $form_id) { // Remove the news vocabulary on forum forms, if the user is not an admin. // Used to mark news forum topics with tags. if ($form_id == 'forum_node_form') { $form['taxonomy'][DRUPALORG_NEWS_VID]['#access'] = user_access('administer nodes'); } } /** * Implementation of template_preprocess_drupalorg_home(). */ function drupalorg_news_preprocess_drupalorg_home(&$vars) { $vars['tab_content_news'] = drupalorg_news_short_block(); } function drupalorg_news_short_block() { // Get the first three news items ordered by descending publication date. $result = db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.status = 1 AND n.promote = 1 ORDER BY n.created DESC'), array(), 0, 4); $fresh_news = ''; $news_count = 0; while ($nid = db_fetch_object($result)) { $node = node_load($nid->nid); if ($news_count == 0) { // The first news item has a blurb displayed. $fresh_news .= '
'. format_date($node->created, 'custom', 'F j, Y') .'
'; // Cut it to short and sweet to fit into the design. Strip all tags, // so things like big images, distracting links and paragraph tags will // not end up here. The text should be good in itself to display. $fresh_news .= ''. node_teaser(strip_tags($node->teaser), $node->format, 180) .' '. l(t('Read more'), 'node/'. $node->nid) .'
'; } else { // Rest of the items have just their title displayed. $fresh_news .= ''. l($node->title, 'node/'. $node->nid) .'
'; } $news_count++; } // Finally, we have a link to the rest of the items $fresh_news .= ''. l(t('More news…'), 'news') .'
'; return $fresh_news; } /** * Implementation of hook_block(). */ function drupalorg_news_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': return array( 'planet-list' => array( 'info' => t('Planet Drupal subscriptions'), ), 'news-terms' => array( 'info' => t('News category filter links'), 'cache' => BLOCK_CACHE_PER_PAGE, ), 'drupal-news' => array( 'info' => t('Drupal News'), 'cache' => BLOCK_CACHE_PER_PAGE, ), ); return $blocks; case 'view': switch ($delta) { case 'planet-list': $block['content'] = drupalorg_news_planet_drupal_block(); return $block; case 'news-terms': return array( 'content' => theme('links', array( array( 'title' => t('Drupal News'), 'href' => 'news', ), array( 'title' => t('Planet Drupal'), 'href' => 'aggregator/categories/' . DRUPALORG_PLANET_CATEGORY, ), array( 'title' => t('Drupal Association'), 'href' => 'aggregator/sources/628', ), )), ); case 'drupal-news': return array( 'subject' => t('Drupal News'), 'content' => drupalorg_news_short_block(), ); } } } /** * Block to show the list of sources for the Planet as well as their count. */ function drupalorg_news_planet_drupal_block() { $output = ''; $description = db_result(db_query("SELECT description FROM aggregator_category WHERE cid = %d", DRUPALORG_PLANET_CATEGORY)); $result = db_query('SELECT f.* FROM {aggregator_feed} f JOIN {aggregator_category_feed} c ON f.fid = c.fid WHERE c.cid = %d ORDER BY f.title', DRUPALORG_PLANET_CATEGORY); $list = ''. filter_xss_admin($description) .' '. t('Collecting posts from the following @num sources:', array('@num' => $counter)) .'
'; $output .= $list; $output .= theme('xml_icon', url('planet/rss.xml')); return $output; }