blob: f3ac460ae12e8dd733af441efd00cd051744a4fd [file] [log] [blame]
<?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 dirname(__FILE__) . '/Forge.class.inc';
// This file assumes that the $App variable has been defined.
function allTrademarksDo($function) {
simrelTrademarksDo($function);
projectTrademarksDo($function);
productTrademarksDo($function);
}
// function registeredTrademarksDo($function) {
// $function('eclipse', 'Eclipse');
// $function('polarsys', 'PolarSys');
// $function('rt.jetty', 'Jetty');
// }
function simrelTrademarksDo($function, $key='simrel') {
global $App;
$sql = "select name from Simrel order by start desc";
$result = $App->dashboard_sql($sql);
while ($row = mysql_fetch_assoc($result)) {
$id = $row['name'];
normalizedTrademarksDo($function, "{$key}.$id", ucwords($id), 'Eclipse', "http://projects.eclipse.org/releases/$id");
}
}
function productTrademarksDo($function) {
normalizedTrademarksDo($function, 'product.zest', 'Zest', 'Eclipse', "/gef/zest/");
normalizedTrademarksDo($function, 'modeling.emf.emf', 'Ecore', 'Eclipse', "https://wiki.eclipse.org/Ecore");
}
function projectTrademarksDo($function) {
global $App;
$sql = "
select ProjectId as id, name
from Projects
where
not IsComponent
and ParentProjectId not in ('foundation-internal')
order by id";
$result = $App->foundation_sql($sql);
while ($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
if (shouldSkipProjectTrademark($id)) continue;
$name = $row['name'];
$forge = Forge::getForgeForProjectId($id);
if (!$forge) continue;
$url = "/projects/project.php?id=$id";
/*
* If the name includes something in parentheses, then assume
* that something is a nickname or alternative name. Or, if there
* are two names separated by <space><dash><space>, treat them
* as separate names.
*/
if (preg_match('/^([^\\(]+)\s\\(([^\\)]+)\\)/', $name, $matches)) {
normalizedTrademarksDo($function, $id, $matches[1], $forge->getName(), $url);
normalizedTrademarksDo($function, $id, $matches[2], $forge->getName(), $url);
} elseif (preg_match('/^([^-]*)\s\\-\s([^-]*)$/', $name, $matches)) {
normalizedTrademarksDo($function, $id, $matches[1], $forge->getName(), $url);
normalizedTrademarksDo($function, $id, $matches[2], $forge->getName(), $url);
} else {
normalizedTrademarksDo($function, $id, $name, $forge->getName(), $url);
}
}
}
/**
* This function answers whether or not we should skip a particular
* project trademark. Generally, most of the entries that we should
* skip are old, so this list shouldn't change too much over time.
*
* TODO Sort out a means of ignoring via database data.
*
* @param string $id
* @return boolean
*/
function shouldSkipProjectTrademark($id) {
switch ($id) {
case 'galileo' :
case 'polarsys' :
case 'locationtech' :
case 'technology.soc' :
// TODO Need a better means of identifying moved projects
// Moved to technology.athena
case 'technology.soc.athena' :
case 'technology.dash.athena' :
// Moved to rt.equinox
case 'eclipse.equinox' :
case 'eclipse.equinox.bundles' :
case 'eclipse.equinox.p2' :
case 'eclipse.equinox.framework' :
case 'eclipse.equinox.incubator' :
case 'eclipse.incubator.equinox' :
// Moved to eclipse.e4
case 'eclipse.incubator.e4' :
return true;
}
return false;
}
function normalizedTrademarksDo($function, $id, $term, $forge, $url) {
$term = trim($term);
if (empty($term)) return;
$term = preg_replace('/\s?\\[[^\\]]*\\]/','', $term);
if (!preg_match("/(?:$forge|Eclipse)/", $term)) {
$function($id, "$forge $term", $url);
}
$function($id, $term, $url);
}
?>