NEW - bug 229522: Generate New & Noteworthy for portal from bugzilla
https://bugs.eclipse.org/bugs/show_bug.cgi?id=229522
diff --git a/new-and-noteworthy/compute-n-and-n.php b/new-and-noteworthy/compute-n-and-n.php
new file mode 100644
index 0000000..a1138aa
--- /dev/null
+++ b/new-and-noteworthy/compute-n-and-n.php
@@ -0,0 +1,130 @@
+<style>
+p, table, td, th {  font-family: verdana, arial, helvetica, geneva; font-size: 10pt}
+pre {  font-family: "Courier New", Courier, mono; font-size: 10pt}
+h2 { font-family: verdana, arial, helvetica, geneva; font-size: 18pt; font-weight: bold ; line-height: 14px}
+code {  font-family: "Courier New", Courier, mono; font-size: 10pt}
+sup {  font-family: verdana, arial, helvetica, geneva; font-size: 10px}
+h3 {  font-family: verdana, arial, helvetica, geneva; font-size: 14pt; font-weight: bold}
+li {  font-family: verdana, arial, helvetica, geneva; font-size: 10pt}
+h1 {  font-family: verdana, arial, helvetica, geneva; font-size: 24pt; font-weight: bold}
+body {  font-family: verdana, arial, helvetica, geneva; font-size: 10pt; margin-top: 5mm; margin-left: 3mm}
+.indextop { font-size: x-large; font-family: verdana, arial, helvetica, sans-serif; font-weight: bold}
+.indexsub { font-size: xx-small; font-family: verdana, arial, helvetica, sans-serif; color: #8080FF}
+a.bar:link {  text-decoration: none; color: #FFFFFF}
+a.bar:visited {  color: #FFFFFF; text-decoration: none}
+a.bar:hover {  color: #FFFFFF; text-decoration: underline}
+a.bar {  color: #FFFFFF}
+</style>
+<h1>Dash M1 - New and Noteworthy</h1>
+<p>This is our first combined Dash + Portal + IPZilla New &amp; Noteworthy.
+  Here are some of the more noteworthy things available in milestone M1 (April 30, 2008) 
+  which is, as always, live on the servers.</p>
+
+<?php
+
+$afterdate = "2008-01-01";
+$url = "https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&component=Commits+Explorer&component=Dashboard&component=IPZilla&component=Portal&component=Process&component=Website&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=noteworthy&bug_status=CLOSED&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=" . $afterdate . "&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=&ctype=rdf&columnlist=bug_id,short_desc";
+$text = file_get_contents( $url );
+$text = preg_replace( "/bz:/", '', $text );
+$text = preg_replace( "/rdf:/", '', $text );
+$text = preg_replace( "/nc:/", '', $text );
+/* */
+$rdf = simplexml_load_string( $text );
+
+$themes_bugs = array();
+foreach( $rdf->result->bugs->Seq->li as $each ) {
+	$id = $each->bug->id;
+	$x = $each->bug->short_desc;
+	preg_match( "/\[([^\]]+)\](.*)/", $x, $matches );
+	$theme = trim($matches[1]);
+	$title = trim($matches[2]);
+	if( !isset($themes_and_bugs[$theme]) ) {
+		$themes_and_bugs[$theme] = array();
+	}
+	$themes_and_bugs[$theme][] = $id;
+}
+?><table border="0" cellpadding="10" cellspacing="0" width="80%">
+<?php
+foreach( $themes_and_bugs as $theme => $bugs ) {
+?><tr>
+    <td colspan="2"><hr />
+      <h2 style="bottom-border: thick solid gray"><?= $theme ?></h2>
+      </td>
+  </tr>
+<?php
+	foreach( $bugs as $bugid ) {
+		/*
+		 * Default image is blank.
+		 */
+		$image = '';
+
+		$url = "https://bugs.eclipse.org/bugs/show_bug.cgi?id=" . $bugid . "&ctype=xml";
+		$text = file_get_contents( $url );
+		$xml = simplexml_load_string( $text );
+		/*
+		 * Default title is from bug title
+		 */
+		if( preg_match( "/\[([^\]]+)\](.*)/", $xml->bug->short_desc, $matches ) ) {
+			$title = trim($matches[2]);
+		} else {
+			$title = trim($xml->bug->short_desc);
+		}
+
+		/*
+		 * Default description is bug description
+		 */
+		$description = '';
+		foreach( $xml->bug->long_desc as $value ) {
+			$description = trim($value->thetext);
+			break;
+		}
+
+		/*
+		 * Look for N&N TITLE
+		 */
+		foreach( $xml->bug->long_desc as $value ) {
+			if( preg_match( "/N&N TITLE:(.*)/", $value->thetext, $matches ) ) {
+				$title = trim($matches[1]);
+			}
+		}
+		/*
+		 * Look for N&N TEXT
+		 */
+		foreach( $xml->bug->long_desc as $value ) {
+			if( preg_match( "/N&N TEXT:(.*)/", $value->thetext, $matches ) ) {
+				$description = trim($matches[1]);
+			}
+		}
+		/*
+		 * Look for N&N IMAGE
+		 */
+		if( $xml->bug->attachment ) {
+			if( $xml->bug->attachment->desc == "N&N IMAGE" ) {
+				$image = "https://bugs.eclipse.org/bugs/attachment.cgi?id=" . $xml->bug->attachment->attachid;
+			}
+		}
+		?>
+  <tr>
+    <td width="30%" valign="top" align="left"><b><?= $title ?></b></td>
+
+    <td width="70%" valign="top"><?= $description ?>
+    <em>(<a href="http://bugs.eclipse.org/<?= $bugid ?>"><?= $bugid ?></a>)</em>
+    <?php
+    if( $image ) {
+    	?>
+      <p><img border="0" src="<?= $image ?>" /></p>
+      <?php
+    }
+    ?>
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2"><p style="bottom-border: thin dotted gray">
+    </td>
+  </tr>
+<?php
+	}
+}
+
+?>
+</table>