| <?php | |
| /** | |
| * ***************************************************************************** | |
| * Copyright (c) 2017 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 dirname ( __FILE__ ) . '/../../eclipse.org-common/system/app.class.php'; | |
| require_once dirname ( __FILE__ ) . '/../../eclipse.org-common/system/nav.class.php'; | |
| require_once dirname ( __FILE__ ) . '/../../eclipse.org-common/system/menu.class.php'; | |
| $App = new App (); | |
| $Nav = new Nav (); | |
| $Menu = new Menu (); | |
| include ($App->getProjectCommon ()); | |
| require_once dirname ( __FILE__ ) . '/../classes/Project.class.php'; | |
| require_once dirname ( __FILE__ ) . '/../classes/debug.php'; | |
| require_once dirname ( __FILE__ ) . '/../classes/database.inc'; | |
| // | |
| // Begin: page-specific settings. Change these. | |
| $pageTitle = "Future Eclipse Project Releases"; | |
| $pageKeywords = ""; | |
| $pageAuthor = "Wayne Beaton"; | |
| class Release { | |
| var $project; | |
| var $name; | |
| var $date; | |
| function __construct($project, $name, $date) { | |
| $this->project = $project; | |
| $this->name = $name; | |
| $this->date = $date; | |
| } | |
| function getId() { | |
| return $this->project->getId(); | |
| } | |
| function getUrl() { | |
| return $this->project->getUrl(); | |
| } | |
| function getName() { | |
| return $this->project->getName() . ' ' . $this->name; | |
| } | |
| function getDate() { | |
| return $this->date; | |
| } | |
| } | |
| function getFutureReleases() { | |
| $releases = array(); | |
| $sql = " | |
| select | |
| project as id, name, date | |
| from ProjectReleases | |
| where date > date(now()) | |
| order by date"; | |
| query('dashboard', $sql, array(), function($row) use (&$releases) { | |
| $project = Project::getProject($row['id']); | |
| $name = $row['name']; | |
| $date = strtotime($row['date']); | |
| $reviewDate = getProbableReviewDate($date); | |
| $releases[$reviewDate][] = new Release($project, $name, $date); | |
| }); | |
| return $releases; | |
| } | |
| function dumpFutureReleases() { | |
| foreach(getFutureReleases() as $date => $releases) { | |
| echo "<h3>" . ($date == 0 ? "It's already too late" : ("For review on " . date('Y-m-d', $date))) . "</h3>"; | |
| echo "<ul>"; | |
| foreach($releases as $release) { | |
| echo "<li><a href=\"{$release->getUrl()}\">{$release->getName()}</a> "; | |
| echo date('Y-m-d', $release->getDate()); | |
| dumpOpenCQs($release); | |
| echo "</li>"; | |
| } | |
| echo "</ul>"; | |
| } | |
| } | |
| function dumpOpenCQs(Release $release) { | |
| echo "<ul>"; | |
| $sql = ' | |
| select | |
| b.bug_id as id, b.short_desc as title | |
| from bugs as b | |
| join components as c on b.component_id=c.id | |
| where c.name=\'$id\' | |
| and bug_status in (\'NEW\', \'REOPENED\')'; | |
| query ('ipzilla', $sql, array('$id' => $release->getId()), function ($row) { | |
| $id = $row ['id']; | |
| $title = $row ['title']; | |
| echo "<li><a target=_blank href=\"https://dev.eclipse.org/ipzilla/show_bug.cgi?id=$id\">$id</a> $title</li>"; | |
| }); | |
| echo "</ul>"; | |
| } | |
| function getProbableReviewDate($date) { | |
| $diff = date('w', $date) - 3; // '3' means Wednesday | |
| if ($diff < 0) | |
| $diff += 7; | |
| $date = strtotime("-$diff days", $date); | |
| $now = strtotime('now'); | |
| $dates = array(); | |
| while ($date > $now) { | |
| // There's probably a better way to do this, but | |
| // the month boundaries are icky, this works, and is simple. | |
| if (isFirstOrThirdWeek($date)) { | |
| return $date; | |
| } | |
| $date = strtotime("-1 week", $date); | |
| } | |
| return 0; | |
| } | |
| /** | |
| * Answers whether the provided date represents the | |
| * | |
| * @param int $date | |
| */ | |
| function isFirstOrThirdWeek($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; | |
| } | |
| ob_start (); | |
| ?> | |
| <div id="maincontent"> | |
| <div id="midcolumn"> | |
| <h1><?=$pageTitle?></h1> | |
| <p><strong>EXPERIMENTAL</strong>. This page shows a list of upcoming releases and—where they | |
| exist—corresponding lists of open intellectual property review requests (CQs). Note that the | |
| CQs are associated with the projects, not with any particular release. This is for informational | |
| purposes only.</p> | |
| <?php dumpFutureReleases(); ?> | |
| </div> | |
| </div> | |
| <?php | |
| $html = ob_get_contents (); | |
| ob_end_clean (); | |
| $App->generatePage ( $theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html ); | |
| ?> |