blob: 8ca9bd53a6ee8e27d6a67f58580c25eeba9667a8 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2017 Eclipse Foundation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0
*******************************************************************************/
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");
require_once dirname(__FILE__) . '/../classes/Project.class.php';
require_once dirname(__FILE__) . '/../classes/database.inc';
require_once dirname(__FILE__) . '/../classes/common.php';
require_once dirname(__FILE__) . '/../classes/debug.php';
$App = new App();
$Nav = new Nav();
$Menu = new Menu();
include($App->getProjectCommon());
$pageTitle = "Eclipse Projects by Programming Language";
$pageKeywords = "";
$pageAuthor = "Wayne Beaton";
ob_start();
$languages = array();
$sql = "select language, project from ProjectLanguages";
query('dashboard', $sql, array(), function($row) use (&$languages) {
if ($project = Project::getProject($row['project'])) {
$languages[$row['language']]['projects'][] = $project;
}
});
/**
* Sort an array based on mapped values. Key/value associations
* are maintained. A mapping function is provided to transform
* the elements of the area into values that are fed into the
* sorting function. The sorting function is optional: if it
* is not provided, then it is assumed that the mapping function
* provide numeric values that are compared for sort order.
*
* @param mixed $values
* @param callable $map
* @param callable $function
*/
function masort(&$values, $map, $function = 'masort_int') {
uasort($values, function($a, $b) use ($map, $function) {
return $function($map($a), $map($b));
});
}
/**
* @internal
* The default sort comparator.
*/
function masort_int($a, $b) {return $a == $b ? 0 : $a < $b;}
masort($languages, function($value) {return count($value['projects']);});
// TODO show the file extension mappings.
?>
<div id="maincontent">
<div id="midcolumn">
<h1><?= $pageTitle ?></h1>
<p>
<strong>EXPERIMENTAL!</strong>
</p>
<?php
foreach($languages as $language => $data) {
echo "<h3>$language</h3>";
echo "<ul>";
masort($data['projects'], function($project) {return $project->getNickname();}, 'strcasecmp');
/** @var \Project $project */
foreach($data['projects'] as $project) {
echo "<li><a href=\"{$project->getUrl()}\">{$project->getFormalName()}</a></li>";
}
echo "</ul>";
}
?>
</div>
</div>
<?php
$html = ob_get_contents();
ob_end_clean();
$App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html);
?>