/[drupal]/contributions/modules/diggthis/diggthis.pages.inc
ViewVC logotype

Contents of /contributions/modules/diggthis/diggthis.pages.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Sep 3 12:54:46 2008 UTC (14 months, 3 weeks ago) by yaph
Branch: MAIN
CVS Tags: DRUPAL-6--2-1-RC1, HEAD
Branch point for: DRUPAL-6--2
Changes since 1.1: +5 -2 lines
File MIME type: text/x-php
Call theme function for an individual story to get rid off the foreach loop in the theme function
1 <?php
2 // $Id: diggthis.pages.inc,v 1.1 2008/09/03 12:12:47 yaph Exp $
3
4 /**
5 * @file
6 * Pages for the diggthis module.
7 */
8
9 /**
10 * Do the Digg API request and retrieve the XML feed
11 * with the top Digg stories for a given domain.
12 *
13 * @return $html
14 * An HTML string with markup for the Digg stories or
15 * an empty string if an error occurred
16 *
17 * @todo replace hard coded urls
18 */
19 function diggthis_top_stories() {
20 $html = '';
21
22 $domain = trim(variable_get('diggthis_stories_domain', ''));
23 if (empty($domain)) {
24 drupal_set_message(t('There is no domain entered in the diggthis settings.'));
25 return $html;
26 }
27
28 $appkey = url($_GET['q'], array('absolute' => TRUE));
29 $domain = drupal_urlencode($domain);
30 //$options = array(
31 // 'query' => array('count' => 10,
32 // 'appkey' => $appkey,
33 // 'domain' => $domain,
34 // 'type' => 'php',
35 // 'sort' => 'digg_count-desc'),
36 // 'absolute' => TRUE
37 //);
38 // ugly but calling url() twice does not work due to urlencodeing
39 $query_string = '?count=10&sort=digg_count-desc&type=xml&appkey=' . $appkey . '&domain=' . $domain;
40 $xml = diggthis_request($query_string);
41 if ($xml) {
42 $data = simplexml_load_string($xml);
43 foreach ($data->story as $story) {
44 $html .= theme('diggthis_story', $story);
45 }
46 }
47 else {
48 drupal_set_message(t('An error occurred. Digg top stories could not be retrieved.'));
49 }
50 return $html;
51 }

  ViewVC Help
Powered by ViewVC 1.1.2