4 * This file is (c) Copyright 2009 by Olivier BERGER, Institut
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * This program has been developed in the frame of the HELIOS
22 * project with financial support of its funders.
28 // Generate a OSLC-CM V1 Service Catalog document (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
30 function projects_to_service_catalog($base_url, $projects) {
32 $doc = new DOMDocument();
33 $doc->formatOutput = true;
35 $root = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:ServiceProviderCatalog");
36 $root = $doc->appendChild($root);
38 $child = $doc->createAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:about");
39 $about = $root->appendChild($child);
40 $child = $doc->createTextNode("");
41 $child = $about->appendChild($child);
43 $child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
44 $title = $root->appendChild($child);
46 // TODO ? : MAY have an oslc_disc:details child element.
48 $child = $doc->createTextNode(TRACKER_TYPE. " Change management service provider catalog");
49 $child = $title->appendChild($child);
51 foreach ($projects as $proj) {
56 $child = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:entry");
57 $entry = $root->appendChild($child);
59 $child = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:ServiceProvider");
60 $sp = $entry->appendChild($child);
62 $child = $doc->createElementNS("http://purl.org/dc/terms/", "dc:title");
63 $title = $sp->appendChild($child);
64 $child = $doc->createTextNode($proj['name']);
65 $child = $title->appendChild($child);
67 $child = $doc->createElementNS("http://open-services.net/xmlns/discovery/1.0/", "oslc_disc:services");
68 $services = $sp->appendChild($child);
69 $child = $doc->createAttributeNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:resource");
70 $resource = $services->appendChild($child);
71 $child = $doc->createTextNode($base_url.'/cm/oslc-cm-service/'.$proj['id']);
72 $child = $resource->appendChild($child);
77 return $doc->saveXML();