| <?php |
| /** |
| * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (http://www.eclipse.org/legal/epl-v10.html). |
| * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. |
| * |
| */ |
| |
| |
| /** |
| * |
| */ |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/common/bug.class.php"); |
| |
| /** |
| * Provides an easy way to create a list of bugs |
| * |
| * This Class provides an easy way to create and enumerate a list of bugs |
| * |
| * @author Eduardo A. Romero Gomez |
| * @license http://www.eclipse.org/legal/epl-v10.html Eclipse Public License - v 1.0 |
| */ |
| class BugList{ |
| var $_bugs = array(); |
| var $ind = 0; |
| |
| /** |
| * Constructor, Creates an empty bug list; |
| * |
| * Creates an empty bug list, you'll have to populte it with the add() method. |
| * |
| * @return BugList an empty list of bugs |
| */ |
| function BugList(){ |
| |
| } |
| |
| /** |
| * Adds a Bug to the list |
| * |
| * @access public |
| * @param Bug $bug the bug to add |
| */ |
| function add($bug){ |
| $this->_bugs[] = $bug; |
| } |
| |
| /** |
| * Removes a Bug from the list |
| * |
| * @access public |
| * @return integer The number of bugs to remove from the list |
| */ |
| function remove($i){ |
| unset($this->_bugs[$i]); |
| } |
| |
| /** |
| * The number of Bug in the list |
| * |
| * @access public |
| * @return integer The number of Bugs on this object. |
| */ |
| function hasBugs(){ |
| return count($this->_bugs); |
| } |
| |
| /** |
| * Gets the <i>n</i>th Bug on this object |
| * |
| * @access public |
| * @return Bug the bug |
| */ |
| function getBugAt($index){ |
| return $this->_bugs[$index]; |
| } |
| |
| /** |
| * Get's the <i>n</i>th Bug on this object |
| * |
| * @access public |
| * @return Bug the bug |
| */ |
| function getBug($index){ |
| return $this->_bugs[$index]; |
| } |
| |
| /** |
| * Get's the Next element of the list |
| * |
| * @access public |
| * @return Bug the next bug |
| */ |
| function getNext() |
| { |
| $bug = $this->_bugs[$this->ind]; |
| $this->ind++; |
| return $bug; |
| } |
| |
| /** |
| * Get's the Previous element on the list |
| * |
| * @access public |
| * @return Bug the previous bug |
| */ |
| function getPrevious() |
| { |
| $bug = $this->_bugs[$this->ind]; |
| $this->ind--; |
| return $bug; |
| } |
| |
| /** |
| * Restarts the List Count, intended to be used after getNext() got the last item in the list |
| */ |
| function reset() |
| { |
| $this->ind = 0; |
| } |
| |
| /** |
| * Returns the Bug List as a Side Item using the Eclipse Website CSS |
| * |
| * @param string $title The title of the Side Item |
| * @return string HTML List with Side Item CSS |
| */ |
| function getAsSideHTML($title = "Top Voted Bugs") |
| { |
| ?> |
| <div class="sideitem"> |
| <h6><?= $title ?></h6> |
| <ul> |
| <?php |
| $num_of_bugs = $this->hasBugs(); |
| if($num_of_bugs == 0) |
| { |
| echo "No bugs found in the Top 10 List"; |
| } |
| else |
| { |
| for($b = 0; $b<$num_of_bugs;$b++) |
| { |
| $bug = $this->getBug($b); |
| ?> |
| <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=<?= $bug->getBugId() ?>" title="<?= $bug->getDescription()?>"> # <?= $bug->getBugid()?> - <?= $bug->getDescription()?></a></li> |
| <? |
| } |
| } |
| ?> |
| </ul> |
| </div> |
| <? |
| } |
| |
| /** |
| * Returns the Bug List using HTML List (<li></li>) tags, useful to show the list in a webpage |
| * not as a side item or in webpages not using the Eclipse Website CSS |
| * |
| * @return string HTML list, items surrounded by <li></li> tags. |
| */ |
| function getAsHTMLlist() |
| { |
| ?> |
| <?php |
| $num_of_bugs = $this->hasBugs(); |
| if($num_of_bugs == 0) |
| { |
| echo "No bugs found in the Top 10 List"; |
| } |
| else |
| { |
| for($b = 0; $b<$num_of_bugs;$b++) |
| { |
| $bug = $this->getBug($b); |
| ?> |
| <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=<?= $bug->getBugId() ?>" title="<?= $bug->getDescription()?>"> # <?= $bug->getBugid()?> - <?= $bug->getDescription()?></a></li> |
| <? |
| } |
| } |
| ?> |
| <? |
| } |
| |
| /** |
| * Returns the Bug List as HTML, useful to show the list in a webpage |
| * not as a side item or in webpages not using the Eclipse Website CSS |
| * |
| * @return string HTML list, items surrounded by <li></li> tags. |
| */ |
| function getAsHTML() |
| { |
| ?> |
| <?php |
| $num_of_bugs = $this->hasBugs(); |
| if($num_of_bugs == 0) |
| { |
| echo "No bugs found in the Top 10 List"; |
| } |
| else |
| { |
| for($b = 0; $b<$num_of_bugs;$b++) |
| { |
| $bug = $this->getBug($b); |
| ?> |
| <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=<?= $bug->getBugId() ?>" title="<?= $bug->getDescription()?>"> # <?= $bug->getBugid()?> - <?= $bug->getDescription()?></a><br/> |
| <? |
| } |
| } |
| ?> |
| <? |
| } |
| } |
| |
| ?> |