content.php 914 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Elgg Polls plugin
  4. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
  5. */
  6. elgg_load_library('elgg:polls');
  7. $widget = elgg_extract("entity", $vars);
  8. //get the num of polls the user want to display
  9. $limit = (int) $widget->limit;
  10. //if no number has been set, default to 3
  11. if($limit < 1) {
  12. $limit = 3;
  13. }
  14. //the page owner
  15. $owner = $widget->getOwnerEntity();
  16. $options = array(
  17. 'type' => 'object',
  18. 'subtype' => 'poll',
  19. 'container_guid' => $owner->getGUID(),
  20. 'limit' => $limit
  21. );
  22. echo '<h3 class="poll-widget-title">' . elgg_echo('polls:widget:think', array($owner->name)) . "</h3>";
  23. if ($polls = elgg_get_entities($options)){
  24. foreach($polls as $pollpost) {
  25. echo elgg_view("polls/widget", array('entity' => $pollpost));
  26. }
  27. } else {
  28. echo "<p>" . elgg_echo('polls:widget:no_polls', array($owner->name)) . "</p>";
  29. }