Tighten up review content.

Change-Id: I584fc40121a87d9c64c6df147569dbe637feb581
diff --git a/classes/Review.class.inc b/classes/Review.class.inc
index 7c52ca0..48b8d31 100644
--- a/classes/Review.class.inc
+++ b/classes/Review.class.inc
@@ -102,6 +102,10 @@
 		return $this->data['status'];
 	}
 
+	public function isPending() {
+		return $this->getStatus() == 'pending';
+	}
+
 	public function getUrl() {
 		return $this->data['url'];
 	}
diff --git a/classes/Review.class.php b/classes/Review.class.php
deleted file mode 100644
index 827741d..0000000
--- a/classes/Review.class.php
+++ /dev/null
@@ -1,375 +0,0 @@
-<?php
-/*******************************************************************************
- * Copyright (c) 2010 Eclipse Foundation and others.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *******************************************************************************/
-require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/common.php");
-require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/debug.php");
-
-require_once(dirname(__FILE__) . "/Forge.class.inc");
-require_once(dirname(__FILE__) . "/database.inc");
-
-define('REVIEW_TYPE_CREATION', 'creation');
-define('REVIEW_TYPE_GRADUATION', 'graduation');
-define('REVIEW_TYPE_RELEASE', 'release');
-define('REVIEW_TYPE_RESTRUCTURE', 'restructure');
-define('REVIEW_TYPE_TERMINATION', 'termination');
-
-class Review {
-	var $info;
-
-	function __construct($info) {
-		$this->info = $info;
-	}
-
-	/**
-	 * State should be one of 'complete' or 'upcoming'
-	 *
-	 * @param string $state
-	 * @param int $cutoff Only return reviews that have occurred since this date
-	 * @return Review[]
-	 */
-	public static function getReviews($state = 'upcoming', $cutoff = null) {
-	    $reviews = array();
-
-	    foreach(Forge::getForges() as $forge) {
-	        $url = "{$forge->getUrl()}/json/reviews/$state";
-	        if ($list = json_decode(getUrlContents($url), true)) {
-	            foreach($list as $row) {
-	                $review = new Review($row);
-	                if ($cutoff && ($review->getDate() < $cutoff)) continue;
-	                $review->statuses[] = new ReviewStatus($row);
-	                $reviews[$review->getId()] = $review;
-	            }
-	        }
-	    }
-	    usort($reviews, 'sortReviewsByDate');
-	    return $reviews;
-	}
-
-	/**
-	 * Fetch completed reviews from all forges. The results are sorted by date.
-	 * @return Review[]
-	 */
-	public static function getCompletedReviews() {
-		return self::getReviews('complete');
-	}
-
-	function getId() {
-		return $this->info['Id'];
-	}
-
-	function getProjectName() {
-		$name = @$this->info['ProjectName'];
-		if ($name) return $name;
-
-		/*
-		 * If the name hasn't been specified, use the proposal name instead.
-		 * That is, assume that we're looking at a Creation Review that's
-		 * following a proposal.
-		 */
-		return @$this->info['ProposalName'];
-	}
-
-	function getProjectId() {
-		return $this->info['ProjectId'];
-	}
-
-	function getReviewName() {
-		$name = $this->info['ReviewName'];
-		if ($name) return $name;
-
-		/*
-		 * If the review name has not been provided, but a proposal
-		 * name has been provided, assume that this is a creation review.
-		 */
-		if ($this->info['ProposalName']) return 'Creation';
-
-		return "Unknown";
-	}
-
-	function getTitle() {
-		$projectName = $this->getProjectName();
-		$reviewName = $this->getReviewName();
-
-		return "$projectName $reviewName";
-	}
-
-	function getType() {
-	    if ($this->isCreation()) return REVIEW_TYPE_CREATION;
-	    if ($this->isGraduation()) return REVIEW_TYPE_GRADUATION;
-	    if ($this->isRelease()) return REVIEW_TYPE_RELEASE;
-	    if ($this->isRestructure()) return REVIEW_TYPE_RESTRUCTURE;
-	    if ($this->isTermination()) return REVIEW_TYPE_TERMINATION;
-	    return null;
-	}
-
-	function isCreation() {
-		return preg_match('/Creation/i', $this->getReviewName()) ? true : false;
-	}
-
-	/**
-	 * If the name includes the word "release", or if the name is
-	 * just a number, then it's a release.
-	 *
-	 * @return boolean
-	 */
-	function isRelease() {
-		if (preg_match('/release/i', $this->getReviewName())) return true;
-		if (preg_match('/^\d*(\.\d+){0,}$/', trim($this->getReviewName()))) return true;
-		return false;
-	}
-
-	function isGraduation() {
-		return preg_match('/Graduation/i', $this->getReviewName()) ? true : false;
-	}
-
-	function isRestructure() {
-		if (preg_match('/Restruct/i', $this->getReviewName())) return true;
-		if (preg_match('/Move/i', $this->getReviewName())) return true;
-		return false;
-	}
-
-
-	function isTermination() {
-		if (preg_match('/Termination/i', $this->getReviewName())) return true;
-		if (preg_match('/Archiv/i', $this->getReviewName())) return true;
-		return false;
-	}
-
-	function getVersion() {
-		if (preg_match('/(\d+)(\.\d+)?(\.\d+)?/', $this->getReviewName(), $matches)) {

-			$name = $matches[1];

-			$name .= isset($matches[2]) && $matches[2] ? $matches[2] : '.0';

-			$name .= isset($matches[3]) && $matches[3] ? $matches[3] : '.0';

-			return $name;

-		} else if (preg_match('/(\d+(\.\d+){1,2})/', $this->getReviewName())) {
-			return $match[1];
-		} else {
-			return null;
-		}
-	}
-
-	function getReviewDate() {
-		$date = $this->info['ReviewDate'];
-		if (!$date) return null;
-		return strtotime($date);
-	}
-
-	function getDate() {
-		return $this->getReviewDate();
-	}
-
-	function getProjectUrl() {
-		return $this->info['ProjectURL'];
-	}
-
-	function getBugNumber() {
-		return $this->info['BugNumber'];
-	}
-
-	function getIplogUrl() {
-		return $this->info['IPLogURL'];
-	}
-
-	function getLink() {
-		return $this->getSlidesUrl();
-	}
-
-	function getSlidesUrl() {
-		return $this->info['SlidesURL'];
-	}
-
-	function isWithdrawn() {
-		return $this->getReviewWithdrawn() != null;
-	}
-
-	function isSuccessful() {
-		return $this->getReviewSuccessful() != null;
-	}
-
-	function isUnsuccessful() {
-		return $this->getReviewUnsuccessful() != null;
-	}
-
-	function getReviewSuccessful() {
-		return $this->getStatus('Review Successful');
-	}
-
-	function getReviewWithdrawn() {
-		return $this->getStatus('Review Withdrawn');
-	}
-
-	function getReviewUnsuccessful() {
-		return $this->getStatus('Review Unsuccessful');
-	}
-
-	function getWaitingProvisioning() {
-		return $this->getStatus('Waiting Provisioning');
-	}
-
-	/**
-	 * This function provides a line of HTML that describes the receiver; it
-	 * provides links to the various bits of interesting information about
-	 * the review. Yes, this probably doesn't belong here (it's more of
-	 * UI thing).
-	 *
-	 * @return string
-	 */
-	function asHtml($ignore = null) {
-		global $App;
-
-		$projectName = $this->getProjectName();
-		$reviewName = $this->getReviewName();
-		$projectUrl = $this->getProjectUrl();
-		$reviewUrl = $this->getSlidesUrl();
-		$iplogUrl = $this->getIplogUrl();
-		$reviewDate = $this->getReviewDate();
-
-		$projectName = htmlentities($projectName);
-		$reviewName = htmlentities($reviewName);
-		$suffix = 'Review';
-
-		if ($projectUrl) $projectName = "<a href=\"$projectUrl\">$projectName</a>";
-
-		if ($reviewDate) {
-			$reviewDate = $App->getFormattedDate($reviewDate, 'short');
-			$reviewDate = str_replace(' ', '&nbsp;', $reviewDate);
-		} else {
-			$reviewDate= 'unscheduled';
-		}
-
-		if ($reviewUrl)
-			$suffix = "<a href=\"$reviewUrl\">$suffix</a>";
-
-		$icons = '';
-		if ($iplogUrl) {
-			$icons .= "<a href=\"$iplogUrl\"><img style=\"vertical-align:top\" title=\"IP Log\" src=\"http://dev.eclipse.org/small_icons/status/dialog-information.png\"/></a>";
-		}
-
-		if ($this->isSuccessful()) {
-		    $icons .= "<img style=\"vertical-align:top\" title=\"Review Successful\" src=\"/projects/images/ok.gif\">";
-		}
-
-		if ($this->isUnsuccessful()) {
-			$icons .= "<img style=\"vertical-align:top\" title=\"Review Unsuccessful\" src=\"http://dev.eclipse.org/small_icons/actions/process-stop.png\">";
-		}
-
-		if ($this->isWithdrawn()) {
-			$reviewDate = "<strike>$reviewDate</strike>";
-			$projectName = "<strike>$projectName</strike>";
-			$reviewName = "<strike>$reviewName</strike>";
-			$icons .= "<img style=\"vertical-align:top\" title=\"Review Withdrawn\" src=\"http://dev.eclipse.org/small_icons/actions/process-stop.png\">";
-		}
-
-		return "${projectName} $reviewName <nobr>${suffix}${icons}</nobr>";
-	}
-
-	/**
-	 * THIS IS NOT API
-	 */
-	/* private */ function getStatus($text) {
-		foreach($this->statuses as $status) {
-			if ($status->getText() == $text) return $status;
-		}
-		return null;
-	}
-}
-
-class ReviewStatus {
-	var $info;
-
-	function __construct($info) {
-		$this->info = $info;
-	}
-
-	function getText() {
-		return $this->info['Status'];
-	}
-
-	function getDate() {
-		return strtotime($this->info['Date']);
-	}
-}
-
-
-/**
- * This function provides the list of all reviews. Note that the
- * results are cached.
- *
- * @deprecated use Review::getCompletedReviews()
- * @return Review[]
- */
-function get_reviews() {
-    return Review::getCompletedReviews();
-}
-
-
-/**
- * @deprecated
- * @param string $projectId
- */
-function getReviewsForProject($projectId) {
-    $reviews = array();
-    foreach(Review::getCompletedReviews() as $review) {
-        if ($review->getProjectId() == $projectId)
-            $reviews[] = $review;
-    }
-    return $reviews;
-}
-
-/**
- * State should be one of 'complete' or 'upcoming'
- *
- * @deprecated  use Review::getReviews()
- * @param string $state
- * @param int $cutoff Only return reviews that have occurred since this date
- */
-function getReviews($state = 'upcoming', $cutoff = null) {
-    return Review::getReviews($state, $cutoff);
-}
-
-function sortReviewsByDate($a, $b) {
-	$dateA = $a->getReviewDate();
-	$dateB = $b->getReviewDate();
-
-	if ($dateA == $dateB) return 0;
-	return $dateA > $dateB ? -1 : 1;
-}
-
-/**
- * Compare two Reviews for sorting. The most recently completed
- * reviews are sorted first, followed by everything else. Within
- * the groups, everything is sorted by date and then by project id.
- *
- * @internal
- * @param Review $a
- * @param Review $b
- * @return -1, 0, 1 if <,==,>
- */
-function sortReviewsByUpcoming($a, $b) {
-	$now = strtotime('now');
-	$lastWeek = strtotime('-1 week');
-
-	$aDate = $a->getDate();
-	$bDate = $b->getDate();
-
-	$aRecent = ($aDate < $now) && ($aDate > $lastWeek);
-	$bRecent = ($bDate < $now) && ($bDate > $lastWeek);
-
-	if ($aRecent == $bRecent) {
-		if ($aDate < $bDate) return -1;
-		if ($aDate > $bDate) return 1;
-
-		return strcasecmp($a->getProjectId(),$b->getProjectId());
-	}
-
-	if ($aRecent == 1) return -1;
-	return 1;
-}
-?>
\ No newline at end of file
diff --git a/reviews-rss.php b/reviews-rss.php
index 1fd8b5d..b3b8fa3 100644
--- a/reviews-rss.php
+++ b/reviews-rss.php
@@ -23,7 +23,7 @@
 
 //header("Content-Type: application/rss+xml");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");
-require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/Review.class.php");
+require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/Review.class.inc");
 require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/classes/debug.php");
 $App = new App();
 
@@ -33,8 +33,6 @@
 	if (is_numeric($value) && $value > 0) $age = $value;
 }
 
-$activities = getReviews('complete', "-${age} days");
-
 ?>
 <rss version="2.0">
 <channel>
@@ -63,9 +61,11 @@
 </webMaster>
 <?php
 
-foreach($activities as $activity) {
-	$title = htmlentities($activity->getTitle());
-	$link = $activity->getLink();
+Review::get(strtotime("-${age} days"), function($activity) {
+	if ($activity->isPending()) return;
+	$project = Project::getProject($activity->getProjectId());
+	$title = htmlentities("{$project->getFormalName()} {$activity->getName()}");
+	$link = $activity->getUrl();
 	$date = date('r', $activity->getDate());
 	$guid = sha1($link);
 
@@ -75,7 +75,8 @@
 	echo "\t<pubDate>$date</pubDate>\n";
 	echo "\t<guid isPermaLink=\"false\">$guid</guid>\n";
 	echo "</item>\n";
-}
+
+});
 ?>
 </channel>
 </rss>
diff --git a/tools/announce.php b/tools/announce.php
deleted file mode 100644
index 19592f8..0000000
--- a/tools/announce.php
+++ /dev/null
@@ -1,155 +0,0 @@
-<?php
-/*******************************************************************************
- * Copyright (c) 2016 Eclipse Foundation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Wayne Beaton (Eclipse Foundation)- initial API and implementation
- *******************************************************************************/
-
-require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");	
-require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php"); 	
-require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php"); 	
-$App 	= new App();
-$Nav	= new Nav();
-$Menu 	= new Menu();
-include($App->getProjectCommon());  
-
-require_once (dirname ( __FILE__ ) . '/../classes/Review.class.php');
-require_once (dirname ( __FILE__ ) . '/../classes/Proposal.class.php');
-require_once (dirname ( __FILE__ ) . '/../classes/debug.php');
-
-mustBeFoundationEmployee();
-
-$pageTitle 		= "Open Source Project Announcements";
-$pageKeywords	= "";
-$pageAuthor		= "Wayne Beaton";
-
-function getFutureReviews() {
-    $reviews = array();
-    foreach(getReviews('upcoming') as $review) {
-        if ($review->getReviewDate() < strtotime("now")) continue;
-        if ($review->getReviewDate() > strtotime("+2 weeks")) continue;
-        
-        $reviews[] = $review;
-    }
-    return $reviews;
-}
-
-function dumpInfo() {
-    global $App;
-    
-    dumpReviews($references);
-    dumpProposals($references);
-    
-    $candidates = get_candidate_dates("+1 week");
-    $next = $App->getFormattedDate ($candidates[0], 'long' );
-    $afterThat = $App->getFormattedDate ($candidates[1], 'long' );
-
-    print "<p>We run reviews ending on the first and third Wednesday of each month. Our next scheduled review dates are $next and $afterThat.</p>";
-    
-    $url= "https://www.eclipse.org/projects/handbook/#release";
-    
-    print "For more information about releases and reviews, please see the <a href=\"$url\">Eclipse Project Handbook</a>.";
-}
-
-function get_candidate_dates($date = "now", $max=5) {
-	$date = strtotime($date);
-	$diff = 3 - date('w', $date); // '3' means Wednesday
-	if ($diff < 0) $diff += 7;
-	if ($diff < 7) $diff += 7;
-
-	$date = strtotime("+$diff days", $date);
-	$dates = array();
-	while (true) {
-		if (count($dates) >= $max) break;
-		// There's probably a better way to do this, but
-		// the month boundaries are icky, this works, and is simple.
-		if (project_reviews__is_first_or_third_week($date)) {
-			$dates[] = $date;
-		}
-		$date = strtotime("+1 week", $date);
-	}
-	return $dates;
-}
-function project_reviews__is_first_or_third_week($date) {
-    $day = date('j', $date) - 1; // 0-based day of the month
-    if (floor($day / 7) == 0) return true; // first week
-    if (floor($day / 7) == 2) return true; // third week
-    return false;
-}
-
-function sortReviewsByType (Review $a, Review $b) {
-    if ($a->getReviewDate() == $b->getReviewDate())
-        if ($a->getType() == $b->getType())
-            return strcasecmp($a->getTitle(), $b->getTitle());
-        else
-            return $a->getType() < $b->getType() ? - 1 : 1;
-    else
-        return $a->getReviewDate() < $b->getReviewDate() ? - 1 : 1;
-}
-
-function dumpReviews(&$references) {
-    global $App;
-    if (!$reviews = getFutureReviews ()) return;
-    
-    usort($reviews, 'sortReviewsByType');
-    
-    $lastDate = null;
-    /** @var \Review $review */
-    foreach ( $reviews as $review ) {
-        $date = $App->getFormattedDate ( $review->getDate(), 'long' );
-
-        if ($date != $lastDate) {
-            if ($lastDate) print "</ul>";
-            print "<p>There are some reviews concluding on $date:</p>";
-            print "<ul>";
-        }
-
-        $lastDate = $date;
-
-        $title = trim($review->getTitle());
-        $url = $review->getLink();
-        print "<li><a href=\"$url\">$title</a></li>";
-    }
-    print "</ul>";
-}
-
-function dumpProposals() {
-    if (!$proposals = getProposals()) return;
-    
-    print "<p>We have several proposals open for community review:<p>";
-    print "<ul>";
-    foreach($proposals as $proposal) {
-        $title = $proposal->getName();
-        $url = $proposal->getProposalUrl();
-        
-        print "<li><a href=\"$url\">$title</a></li>";
-    }
-    print "</ul>";
-    
-    $url = "https://www.eclipse.org/forums/eclipse.proposals";
-    
-    print "<p>Please add your comments either directly on the proposal or in the <a href=\"$url\">Proposals forum</a>.</p>";
-}
-
-ob_start();
-
-?>
-<div id="maincontent">
-<div id="midcolumn">
-<h1><?= $pageTitle ?></h1>
-
-<?php dumpInfo(); ?>
-
-</div>
-</div>
-
-<?php
-$html = ob_get_contents();
-ob_end_clean();
-$App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html);
-?>