3 * admssw plugin script which produces a full list of public projects with all their details
5 * This file is (c) Copyright 2012 by Olivier BERGER, Institut Mines-Telecom
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once('../../env.inc.php');
24 require_once $gfcommon.'include/pre.php';
26 $pluginname = 'admssw';
28 $script = 'admssw_full';
29 $default_content_type = 'text/html';
31 // check for alternate representations (RDF content-types)
32 $content_type = util_negociate_alternate_content_types($script, $default_content_type);
34 $plugin = plugin_get_object($pluginname);
42 if ( null !== getStringFromRequest('theFirstPage', null)) {
44 $uricomplement = '?theFirstPage';
47 $p = getIntFromRequest('p', 0);
49 $uricomplement = '?p=' . $p;
53 $projectsnum = $plugin->getProjectListSize();
55 // force paging if too many projects
56 if ( ($projectsnum > $pl) && ! ($p > 0) ) {
58 header("Location: ?theFirstPage");
59 header($_SERVER["SERVER_PROTOCOL"]." 303 See Other",true,303);
64 if($content_type != $default_content_type) {
69 $documenturi = util_make_url('/plugins/'.$pluginname.'/full.php');
72 // if paging is requested
74 $maxpage = (int) ($projectsnum / $pl);
76 header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found",true,404);
77 printf("Page %d requested is beyond the maximum %d !", $p, $maxpage);
82 $pageuri = $documenturi . $uricomplement;
85 // process as in content_negociated_projects_list but with full details
86 $graph = $plugin->getProjectListResourcesGraph($documenturi, true, $chunk, $chunksize);
89 $ns = $plugin->admsswNameSpaces();
94 $res = ARC2::getResource($conf);
95 $res->setURI( $pageuri );
96 rdfutils_setPropToUri($res, 'rdf:type', 'ldp:Page');
98 if($p < ( (int) ($projectsnum / $pl) ) ) {
99 $nextpageuri = $documenturi . '?p=' . (string) ($p + 1);
100 rdfutils_setPropToUri($res, 'ldp:nextPage', $nextpageuri);
103 rdfutils_setPropToUri($res, 'ldp:nextPage', 'rdf:nil');
105 rdfutils_setPropToUri($res, 'ldp:pageOf', $documenturi);
107 $count = $graph->addTriples( ARC2::getTriplesFromIndex($res->index) );
110 // We can support only RDF as RDF+XML or Turtle
111 if ($content_type == 'text/turtle' || $content_type == 'application/rdf+xml') {
112 header('Content-type: '. $content_type);
113 if ($content_type == 'text/turtle') {
114 print $graph->serialize($serializer="Turtle")."\n";
116 if ($content_type == 'application/rdf+xml') {
117 print $graph->serialize()."\n";
121 header('HTTP/1.1 406 Not Acceptable',true,406);
122 print $graph->dumpText();
126 $HTML->header(array('title'=>_('Full ADMS.SW export'),'pagename'=>'admssw_full'));
127 $HTML->printSoftwareMapLinks();
129 echo '<p>'. _('This script is meant to produce machine-readable RDF meta-data, in Turtle or RDF/XML formats, which can be obtained with, for instance:').'<br />';
131 $graph = $plugin->getProjectListResourcesGraph(util_make_url('/plugins/'.$pluginname.'/full.php'), true);
133 print $graph->dump();
135 echo _('To access this RDF document, you may use, for instance :<br />');
136 echo '<tt>$ curl -H "Accept: text/turtle" '. util_make_url('/plugins/'.$pluginname.'/full.php') .'</tt>';
138 $HTML->footer(array());
143 // c-file-style: "bsd"