blob: c381258efe18b2b4d1203901a3e5cdb77cbf3971 [file] [log] [blame]
<?php
/**
* Copyright (c) 2008, 2018 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* Wayne Beaton (Eclipse Foundation)- initial API and implementation
* Eric Poirier (Eclipse Foundation)
*
* SPDX-License-Identifier: EPL-2.0
*/
require_once ($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");
require_once ($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php");
$App = new App();
$Nav = new Nav();
$Theme = $App->getThemeClass();
include ($App->getProjectCommon());
$kinds = array(
'Bundles' => 'bundle',
'Commands' => 'command',
'Perspectives' => 'perspective',
'Views' => 'view',
'Editors' => 'editor'
);
$kind = 'view';
if (array_key_exists('kind', $_GET))
$kind = $_GET['kind'];
if (!in_array($kind, $kinds))
$kind = 'view';
$sort = 'element';
if (array_key_exists('sort', $_GET))
$sort = $_GET['sort'];
if (!in_array($sort, array(
'month',
'element',
'use',
'users'
)))
$sort = 'element';
$base_url = '/home/data/httpd/writable/udc/reports/data/';
$file = $base_url . $kind . 's.csv';
$csv = file_get_contents($file);
$csv = split("\n", $csv);
$headers = current($csv);
$headers = split(",", $headers);
class Item {
var $yearmonth;
var $element;
var $bundleId;
var $bundleVersion;
var $useCount;
var $userCount;
}
$items = array();
$thismonth = date('Ym', strtotime("-3 month"));
while ($row = next($csv)) {
$row = split(",", $row);
$item = new Item();
$item->yearmonth = current($row);
$item->element = next($row);
$item->bundleId = next($row);
$item->bundleVersion = next($row);
$item->useCount = next($row);
$item->userCount = next($row);
// if ($item->yearmonth >= $thismonth)
$items[] = $item;
}
function sort_by_month($a, $b) {
if ($a->yearmonth == $b->yearmonth)
return 0;
return $a->yearmonth < $b->yearmonth ? 1 : -1;
}
function sort_by_element($a, $b) {
return strcasecmp($a->element, $b->element);
}
function sort_by_use($a, $b) {
if ($a->useCount == $b->useCount)
return 0;
return $a->useCount < $b->useCount ? 1 : -1;
}
function sort_by_users($a, $b) {
if ($a->userCount == $b->userCount)
return 0;
return $a->userCount < $b->userCount ? 1 : -1;
}
usort($items, "sort_by_$sort");
$pageTitle = "Usage Data Collector Results";
$Theme->setPageTitle($pageTitle);
$Theme->setPageKeywords("Eclipse, usage data, usagedata, cortez");
$Theme->setPageAuthor("Wayne Beaton");
$file_date = $App->getFormattedDate(filemtime($file));
$csv = file_get_contents($file);
$csv = split("\n", $csv);
ob_start();
include ("content/en_" . $App->getScriptName());
$html = ob_get_clean();
$Theme->setNav($Nav);
$Theme->setHtml($html);
$Theme->generatePage();