diff options
author | cash <cash.costello@gmail.com> | 2009-01-18 22:32:30 +0000 |
---|---|---|
committer | cash <cash.costello@gmail.com> | 2009-01-18 22:32:30 +0000 |
commit | 33c172943ddd2431773bbdb3c4cd23fce295f8d5 (patch) | |
tree | f0ce399af3d9da04d4d905db7b76a90fa598d5ec /views | |
parent | 0ffdb7c5fe3ccea8c5067d22a57da3214cd0fccb (diff) | |
download | elgg-33c172943ddd2431773bbdb3c4cd23fce295f8d5.tar.gz elgg-33c172943ddd2431773bbdb3c4cd23fce295f8d5.tar.bz2 |
added settings on num of entries to include and whether to include the post date
Diffstat (limited to 'views')
-rw-r--r-- | views/default/widgets/feed_reader/edit.php | 49 | ||||
-rw-r--r-- | views/default/widgets/feed_reader/view.php | 41 |
2 files changed, 77 insertions, 13 deletions
diff --git a/views/default/widgets/feed_reader/edit.php b/views/default/widgets/feed_reader/edit.php index 3b14dcc97..f74462135 100644 --- a/views/default/widgets/feed_reader/edit.php +++ b/views/default/widgets/feed_reader/edit.php @@ -1,4 +1,53 @@ +<?php
+ $num_items = $vars['entity']->num_items;
+ if (!isset($num_items)) $num_items = 10;
+
+ $excerpt = $vars['entity']->excerpt;
+ if (!isset($excerpt)) $excerpt = 0;
+
+ $post_date = $vars['entity']->post_date;
+ if (!isset($post_date)) $post_date = 0;
+
+?>
+
<p>
<?php echo elgg_echo("simplepie:feed_url"); ?>
<input type="text" name="params[feed_url]" value="<?php echo htmlentities($vars['entity']->feed_url); ?>" />
</p>
+
+ <p>
+<?php echo elgg_echo('simplepie:num_items'); ?>
+
+<?php
+ echo elgg_view('input/pulldown', array(
+ 'internalname' => 'params[num_items]',
+ 'options_values' => array( '5' => '5',
+ '8' => '8',
+ '10' => '10',
+ '12' => '12',
+ '15' => '15',
+ ),
+ 'value' => $num_items
+ ));
+?>
+ </p>
+
+ <p>
+<?php
+ echo elgg_view('input/hidden', array('internalname' => 'params[excerpt]', 'js' => 'id="params[excerpt]"', 'value' => $excerpt ));
+ echo "<input class='input-checkboxes' type='checkbox' value='' name='excerptcheckbox' onclick=\"document.getElementById('params[excerpt]').value = 1 - document.getElementById('params[excerpt]').value;\" ";
+ if ($excerpt) echo "checked='yes'";
+ echo " />";
+ echo ' ' . elgg_echo('simplepie:excerpt');
+?>
+ </p>
+
+ <p>
+<?php
+ echo elgg_view('input/hidden', array('internalname' => 'params[post_date]', 'js' => 'id="params[post_date]"', 'value' => $post_date ));
+ echo "<input class='input-checkboxes' type='checkbox' value='' name='post_datecheckbox' onclick=\"document.getElementById('params[post_date]').value = 1 - document.getElementById('params[post_date]').value;\" ";
+ if ($post_date) echo "checked='yes'";
+ echo " />";
+ echo ' ' . elgg_echo('simplepie:post_date');
+?>
+ </p>
diff --git a/views/default/widgets/feed_reader/view.php b/views/default/widgets/feed_reader/view.php index b640890d2..300c56ec7 100644 --- a/views/default/widgets/feed_reader/view.php +++ b/views/default/widgets/feed_reader/view.php @@ -9,29 +9,44 @@ $feed_url = $vars['entity']->feed_url; if($feed_url){ - $feed = new SimplePie($feed_url); + $excerpt = $vars['entity']->excerpt; + $num_items = $vars['entity']->num_items; + $post_date = $vars['entity']->post_date; + + echo $feed_url; + $feed = new SimplePie(); + $feed->set_feed_url($feed_url); + //$feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL); + $feed->init(); $feed->handle_content_type(); - - +echo $post_date; + echo $feed->get_item_quantity(); +?> +<h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1><br /> +<?php + if ($num_items > $feed->get_item_quantity()) + $num_items = $feed->get_item_quantity(); + + foreach ($feed->get_items(0,$num_items) as $item): ?> -<h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1> - <?php - /* - Here, we'll loop through all of the items in the feed, and $item represents the current item in the loop. - */ - foreach ($feed->get_items() as $item): - ?> <div class="item"> - <h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2> - <p><?php echo $item->get_description(); ?></p> - <p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p> + <p><h3><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h3></p> + <?php if ($excerpt) echo '<p>' . $item->get_description(true) . '</p>'; ?> + <?php if ($post_date) + { + ?> + <p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p> + <?php } ?> </div> <?php endforeach; ?> + <?php } else { echo '<p>' . elgg_echo('simplepie:notset') . '</p>'; } ?> + +<!-- <p><?php //echo $item->get_description(); ?></p> --> |