6 * Copyright 2012-2013, Olivier Berger & Institut Mines-Telecom
7 * Copyright 2013, Roland Mas
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 // This Plugin publishes meta-data about the public projects hosted on the forge
26 // as RDF conforming to the ADMS.SW 1.0 specifications :
27 // https://joinup.ec.europa.eu/asset/adms_foss/release/release100
29 require_once('common/include/TroveCat.class.php');
30 require_once('common/frs/FRSFileType.class.php');
31 require_once $gfplugins.'admssw/common/RDFedFRSPackage.class.php' ;
32 require_once('common/include/rdfutils.php');
33 include_once("Graphite.php");
35 class admsswPlugin extends Plugin {
37 //var $trovecat_id_index; // cat_id to TroveCat instances
38 var $trovecat_id_to_shortname; // cat_id to shortname
39 var $trovecat_id_to_path; // cat_id to path
44 * @param number $id plugin identifier
46 public function __construct($id=0) {
48 $this->name = "admssw";
49 $this->text = "ADMS.SW"; // To show in the tabs, use...
51 // The standard RDF namespaces that will be used in the plugin
53 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
54 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
55 'doap' => 'http://usefulinc.com/ns/doap#',
56 'dcterms' => 'http://purl.org/dc/terms/',
57 'admssw' => 'http://purl.org/adms/sw/',
58 'adms' => 'http://www.w3.org/ns/adms#',
59 'foaf' => 'http://xmlns.com/foaf/0.1/',
60 'schema' => 'http://schema.org/',
61 'rad' => 'http://www.w3.org/ns/rad#',
62 'ldp' => 'http://www.w3.org/ns/ldp#'
65 //$this->trovecat_id_index = array();
66 $this->trovecat_id_to_shortname = array();
67 $this->trovecat_id_to_path = array();
69 // Add the doaprdf plugin's namespaces
70 $doaprdfplugin = plugin_get_object ("doaprdf");
71 $ns = $doaprdfplugin->doapNameSpaces();
72 foreach($ns as $s => $u)
74 if (! in_array($u, $this->ns)) {
79 $this->_addHook("project_rdf_metadata"); // will provide some RDF metadata for the project's DOAP profile to 'doaprdf' plugin
80 $this->_addHook("alt_representations"); // declares a link to itself in the link+meta HTML headers of /projects and /softwaremap
81 $this->_addHook("script_accepted_types"); // supported alternate content-types (Accept HTTP header values)
82 $this->_addHook("content_negociated_projects_list"); // registers to be able to return content-negociated content for /projects/...
83 $this->_addHook("softwaremap_links"); // display additional submenu in the softwaremap tool
84 $this->_addHook("project_after_description"); // displays additional info in the project info widget
85 $this->_addHook("content_negociated_trove_list"); // generates the RDF document containing the trove categories as SKOS
86 $this->_addHook("content_negociated_frs_index"); // generates the public projects list/index as RDF
87 $this->_addHook("content_negociated_frs_download_file"); // generates the RDF meta-data about a FRS downloadable file
91 // General conneg related or other hook callbacks
95 * Declares itself as accepting RDF XML or Turtle on /projects and other scripts ...
97 * @param unknown_type $params
99 public function script_accepted_types (&$params) {
100 $script = $params['script'];
101 if ($script == 'projects_list' || $script == 'admssw_full' || $script == 'trove_list' || $script == 'frs_index' || $script == 'frs_download_file') {
102 $params['accepted_types'][] = 'application/rdf+xml';
103 $params['accepted_types'][] = 'text/turtle';
108 * Declares a link to itself in the link+meta HTML headers of /projects and /softwaremap
110 * @param unknown_type $params
112 public function alt_representations (&$params) {
113 $script_name = $params['script_name'];
114 $php_self = $params['php_self'];
115 if ($php_self == '/softwaremap/trove_list.php') {
116 $params['return'][] = '<link rel="alternate" type="application/rdf+xml" title="ADMS.SW RDF Data" href="'. util_make_url ("/plugins/admssw/trove.php") .'"/>';
117 $params['return'][] = '<link rel="alternate" type="text/turtle" title="ADMS.SW RDF Data" href="'. util_make_url ("/plugins/admssw/trove.php") .'"/>';
119 elseif ($script_name == '/softwaremap') {
120 $params['return'][] = '<link rel="alternate" type="application/rdf+xml" title="ADMS.SW RDF Data" href="'. util_make_url ("/projects") .'"/>';
121 $params['return'][] = '<link rel="alternate" type="text/turtle" title="ADMS.SW RDF Data" href="'. util_make_url ("/projects") .'"/>';
123 else if($script_name == '/projects') {
124 $params['return'][] = '<link rel="alternate" type="application/rdf+xml" title="ADMS.SW RDF Data" href="'. util_make_url ($php_self) .'"/>';
125 $params['return'][] = '<link rel="alternate" type="text/turtle" title="ADMS.SW RDF Data" href="'. util_make_url ($php_self) .'"/>';
130 * Add a new link to the softwaremap submenu
132 * @param array $params
134 public function softwaremap_links (&$params) {
136 $params['TITLES'][] = _('ADMS.SW meta-data');
137 $params['URLS'][] = '/plugins/'. $this->name .'/index.php';
138 $params['ATTRS'][] = array('title' => _('ADMS.SW RDF meta-data about forge projects.'), 'class' => 'tabtitle');
142 * Add a line in the project infos widget in the project home
144 * @param array $params
146 public function project_after_description (&$params) {
147 $group_id = $params['group_id'];
148 print '<br />'. sprintf( _('Preview <a href="%1$s">ADMS.SW meta-data</a> about the project'), util_make_url ('/plugins/'. $this->name .'/projectturtle.php?group_id='.$group_id));
157 * Returns namespaces used in ADMS.SW
159 * @return array the namespaces associative array
161 public function admsswNameSpaces() {
166 * Initialize Graphite graph's namespaces
168 private function graphSetAdmsswNameSpaces(&$graph) {
169 $ns = $this->admsswNameSpaces();
170 foreach($ns as $s => $u)
172 $graph->ns( $s, $u );
176 static function repositoryUri() {
177 return util_make_url ('/projects#repo');
181 // Project related methods and callbacks
185 * Provides an HTML preview of a project's ADMS.SW meta-data looking like turtle
187 * @param int $group_id
189 public function htmlPreviewProjectAsTurtle($group_id) {
193 $graph = new Graphite();
195 $this->graphSetAdmsswNameSpaces($graph);
197 $resourceindex = $this->addProjectResourceToGraph($graph, $group_id, $detailed);
199 return $graph->dump();
203 * Provides an ARC2 resource index of a project's ADMS.SW meta-data
205 * @param int $group_id
207 private function addProjectResourceToGraph(&$graph, $group_id, $detailed = false) {
209 // part of the work is done by the doaprdf plugin, which will in turn call us back (see project_rdf_metadata)
210 $doaprdfplugin = plugin_get_object ("doaprdf");
212 $ns = $this->admsswNameSpaces();
214 $resourceindex = $doaprdfplugin->getProjectResourceIndex($group_id, $ns, $detailed);
216 // update the namespaces if they happen to get updated in between
217 foreach($ns as $s => $u)
219 if (! in_array($u, $this->ns)) {
224 $count = $graph->addTriples( ARC2::getTriplesFromIndex($resourceindex) );
230 * Improves the DOAP description made by doaprdf (ARC2 resource) to add ADMS.SW meta-data for a project
232 * @param unknown_type $params
234 * This is a hook callback so part of the resource construction is made in the doaprdf plugin
236 public function project_rdf_metadata (&$params) {
238 # TODO : check that the passed in_Resource is indeed a doap:Project
239 $group_id = $params['group'];
241 // Update the prefixes by ADMS.SW ones
242 $new_prefixes = $this->admsswNameSpaces();
243 foreach($new_prefixes as $s => $u)
245 if (! isset($params['prefixes'][$u])) {
246 $params['prefixes'][$u] = $s;
251 if ($params['details'] == 'full') {
255 // The ARC2 RDF_Resource already initialized by doaprdf plugin
256 $res = $params['in_Resource'];
258 // we could save the type doap:Project in such case, as there's an equivalence, but not sure all consumers do reasoning
259 $types = array('doap:Project', 'admssw:SoftwareProject');
260 rdfutils_setPropToUri($res, 'rdf:type', $types);
263 // Handle project tags
265 if (forge_get_config('use_project_tags')) {
266 $group = group_get_object($group_id);
267 $tags_list = $group->getTags();
269 // connect to FusionForge internals
270 $pm = ProjectManager::instance();
271 $project = $pm->getProject($group_id);
274 $tags = split(', ',$tags_list);
276 // reuse the same as dcterms:subject until further specialization of adms.sw keywords
277 $res->setProp('rad:keyword', $tags);
280 $project_description = $project->getDescription();
281 if($project_description) {
282 // it seems that doap:description is not equivalent to dcterms:description, so repeat
283 $res->setProp('dcterms:description', $project_description);
286 // Handle trove categories
287 $trovecaturis=array('admssw:intendedAudience' => array(),
288 'admssw:locale' => array(),
289 'admssw:userInterfaceType' => array(),
290 'admssw:programmingLanguage' => array(),
291 'schema:operatingSystem' => array(),
292 'admssw:status' => array(),
293 'rad:theme' => array());
294 $trovecats = TroveCat::getProjectCats($group_id);
295 foreach($trovecats as $trovecat) {
296 $cat_id = $trovecat->getId();
297 if(!isset($this->trovecat_id_to_shortname[$cat_id])) {
298 $this->trovecat_id_to_shortname[$cat_id] = $trovecat->getShortName();
300 $idsfullpath = $trovecat->getIdsFullPath();
301 $folders_ids = explode(" :: ", $idsfullpath);
303 foreach ($folders_ids as $id) {
304 if (! isset($this->trovecat_id_to_shortname[$id])) {
305 $supercat = new TroveCat($id);
306 $this->trovecat_id_to_shortname[$id] = $supercat->getShortName();
308 $paths[] = $this->trovecat_id_to_shortname[$id];
310 $path=implode('/', $paths);
311 $this->trovecat_id_to_path[$cat_id] = $path;
312 $trovecaturi = util_make_url ('/softwaremap/trove/'.$path);
313 $rootcatid = $trovecat->getRootCatId();
314 $rootcatshortname = $this->trovecat_id_to_shortname[$rootcatid];
315 // This is a bit hackish
316 switch ($rootcatshortname) {
317 case 'developmentstatus':
318 $trovecaturis['admssw:status'][] = $trovecaturi;
321 $trovecaturis['admssw:intendedAudience'][] = $trovecaturi;
324 $trovecaturis['dcterms:license'][] = $trovecaturi;
327 $trovecaturis['admssw:locale'][] = $trovecaturi;
330 $trovecaturis['schema:operatingSystem'][] = $trovecaturi;
333 $trovecaturis['admssw:programmingLanguage'][] = $trovecaturi;
336 $trovecaturis['rad:theme'][] = $trovecaturi;
340 foreach ($trovecaturis as $prop => $uris) {
342 rdfutils_setPropToUri($res, $prop, $uris);
346 $res->setProp('rdfs:comment', "Generated with the doaprdf and admssw plugins of fusionforge");
348 rdfutils_setPropToUri($res, 'dcterms:isPartOf', admsswPlugin::repositoryUri());
350 // Handle project members
351 $admins = $project->getAdmins() ;
352 $members = $project->getUsers() ;
353 $contributors_uris = array();
354 foreach ($admins as $u) {
355 $contributor_uri = util_make_url_u ($u->getUnixName(),$u->getID());
356 $contributor_uri = rtrim($contributor_uri, '/');
357 $contributor_uri = $contributor_uri . '#person';
358 if (! in_array($contributor_uri, $contributors_uris) ) {
359 $contributors_uris[] = $contributor_uri;
362 foreach ($members as $u) {
363 $contributor_uri = util_make_url_u ($u->getUnixName(),$u->getID());
364 $contributor_uri = rtrim($contributor_uri, '/');
365 $contributor_uri = $contributor_uri . '#person';
366 if (! in_array($contributor_uri, $contributors_uris) ) {
367 $contributors_uris[] = $contributor_uri;
370 rdfutils_setPropToUri($res, 'schema:contributor', $contributors_uris);
372 // Handle FRS releases
373 $release_uris = array();
374 $frs_packages = get_rdfed_frs_packages($project);
375 foreach ($frs_packages as $frs_package) {
376 //print_r($frs_package);
378 if($frs_package->isPublic() && $frs_package->getStatus() == 1) {
379 $package_name = $frs_package->getFileName();
381 $frs_releases = $frs_package->getReleases();
382 foreach ($frs_releases as $frs_release) {
383 if( $frs_release->getStatus() == 1 ) {
384 //print_r($frs_release);
385 $release_uris[] = $frs_release->getUri();
390 if(count($release_uris)) {
391 rdfutils_setPropToUri($res, 'doap:release', $release_uris);
393 // The releases aren't discoverable by follow your nose yet, so add the proper document/script URL to use
394 rdfutils_setPropToUri($res, 'rdfs:seeAlso', util_make_url ('/frs/?group_id='.$group_id));
396 $params['out_Resources'][] = $res;
399 $graph = new Graphite();
400 $this->graphSetAdmsswNameSpaces($graph);
402 $this->addProjectFrsResourcesToGraph($graph, $group_id);
404 $subjects = $graph->allSubjects();
405 foreach ($subjects as $subject) {
406 $resource = $graph->resource( $subject );
407 $triples = $resource->toArcTriples();
409 $index = ARC2::getSimpleIndex($triples, false);
411 $res = ARC2::getResource();
412 $res->setIndex($index);
414 $params['out_Resources'][] = $res;
423 // Project list / SoftwareRepository related methods
427 * Returns the number of projects in a project index
429 public function getProjectListSize() {
430 // same as for trove's full list
431 $projects = get_public_active_projects_asc();
432 return count($projects);
436 * Provides a Graphite graph for resource(s) representing the ADMS.SW SoftwareRepository
438 * @param string URI of the document to use
439 * @param bool are projects to be fully described or just a URI of their resource
440 * @param $chunk number of the chunk to be returned in case of paging
441 * @param $chunksize size of chunks in case of paging
443 public function getProjectListResourcesGraph($documenturi, $detailed=false, $chunk=null, $chunksize=null) {
445 // Construct an ARC2_Resource containing the project's RDF (DOAP) description
446 $ns = $this->admsswNameSpaces();
452 $res = ARC2::getResource($conf);
453 $res->setURI( admsswPlugin::repositoryUri() );
455 // $res->setRel('rdf:type', 'admssw:SoftwareRepository');
456 rdfutils_setPropToUri($res, 'rdf:type', 'admssw:SoftwareRepository');
458 //$res->setProp('doap:name', $projectname);
459 rdfutils_setPropToUri($res, 'adms:accessURL', util_make_url ("/softwaremap/") );
460 $forge_name = forge_get_config ('forge_name');
461 $ff = new FusionForge();
462 $res->setProp('dcterms:description', 'Public projects in the '. $ff->software_name .' Software Map on '. $forge_name );
463 $res->setProp('rdfs:label', $forge_name .' public projects');
464 $res->setProp('adms:supportedSchema', 'ADMS.SW v1.0');
466 // same as for trove's full list
467 $projects = get_public_active_projects_asc();
470 if ( isset($chunk) && isset($chunksize) ) {
471 // TODO : do some checks on $chunk $chunksize values
472 // if ( ($chunk < 1) && ($chunksize >= 1) ) {
475 $projects_chunks = array_chunk($projects, $chunksize);
476 $projects = $projects_chunks[$chunk-1];
479 $proj_uris = array();
480 foreach ($projects as $row_grp) {
481 $proj_uri = util_make_url_g(strtolower($row_grp['unix_group_name']),$row_grp['group_id']).'#project';
482 $proj_uris[] = $proj_uri;
484 if(count($proj_uris)) {
485 rdfutils_setPropToUri($res, 'dcterms:hasPart', $proj_uris);
488 $graph = new Graphite();
489 $this->graphSetAdmsswNameSpaces($graph);
491 $count = $graph->addTriples( ARC2::getTriplesFromIndex($res->index) );
493 // if needed, provide also full details about the projects
494 foreach ($projects as $row_grp) {
495 $group_id = $row_grp['group_id'];
496 //$proj_uri = util_make_url_g(strtolower($row_grp['unix_group_name']),$row_grp['group_id']);
497 $count = $this->addProjectResourceToGraph($graph, $row_grp['group_id'], $detailed);
500 $this->graphSetAdmsswNameSpaces($graph);
502 // The document the document itself
503 $res = ARC2::getResource($conf);
504 $res->setURI( $documenturi );
505 rdfutils_setPropToUri($res, 'rdf:type', 'foaf:Document');
506 rdfutils_setPropToUri($res, 'foaf:primaryTopic', admsswPlugin::repositoryUri() );
507 rdfutils_setPropToXSDdateTime($res, 'dcterms:created', date('c'));
508 $res->setProp('dcterms:title', "ADMS.SW full dump" );
510 $count = $graph->addTriples( ARC2::getTriplesFromIndex($res->index) );
515 public function proces_paging_params_or_redirect($projectsnum, $pl) {
518 if ( null !== getStringFromRequest('theFirstPage', null)) {
522 $p = getIntFromRequest('page', 0);
527 if ( null !== getStringFromRequest('allatonce', null)) {
528 $pl = $projectsnum + 1;
532 // force paging if too many projects
533 if ( ($projectsnum > $pl) && ! ($p > 0) ) {
534 header("Location: ?theFirstPage");
535 header($_SERVER["SERVER_PROTOCOL"]." 303 See Other",true,303);
539 // if paging is requested
541 $maxpage = (int) ($projectsnum / $pl);
543 header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found",true,404);
544 printf("Page %d requested is beyond the maximum %d !", $p, $maxpage);
554 * Provides an HTML preview of the ADMS.SW SoftwareRepository meta-data looking like turtle
556 * @param int $group_id
558 public function htmlPreviewProjectsAsTurtle() {
559 $graph = $this->getProjectListResourcesGraph(util_make_url ("/projects"));
561 return $graph->dump();
565 * Outputs the public projects list as ADMS.SW for /projects
567 * @param unknown_type $params
569 public function content_negociated_projects_list (&$params) {
571 $accept = $params['accept'];
573 // we are asked for RDF either as RDF+XML or Turtle
574 if($accept == 'application/rdf+xml' || $accept == 'text/turtle') {
577 // We will return RDF
578 $params['content_type'] = $accept;
580 $graph = $this->getProjectListResourcesGraph(util_make_url ("/projects"));
582 if ($accept == 'text/turtle') {
583 $doc = $graph->serialize($serializer="Turtle");
585 if ($accept == 'application/rdf+xml') {
586 $doc = $graph->serialize();
589 $params['content'] = $doc . "\n";
596 // Trove related methods
600 * Provides a Graphite graph for resource(s) representing the trove categories as SKOS concepts
603 private function getTroveListResourcesGraph() {
605 // Construct an ARC2_Resource containing the project's RDF (DOAP) description
607 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
608 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
609 'skos' => 'http://www.w3.org/2004/02/skos/core#'
617 $graph = new Graphite();
618 $this->graphSetAdmsswNameSpaces($graph);
620 $rootcats = TroveCat::getAllRoots();
622 foreach($rootcats as $rootcat) {
624 // First the ConceptScheme itself
626 $conceptschemeres = ARC2::getResource($conf);
628 $scheme_shortname = $rootcat->getShortName();
629 $conceptscheme_uri = util_make_url ('/softwaremap/trove/'.$scheme_shortname);
630 $conceptschemeres->setURI( $conceptscheme_uri );
632 // $res->setRel('rdf:type', 'doap:Project');
633 rdfutils_setPropToUri($conceptschemeres, 'rdf:type', 'skos:ConceptScheme');
635 $conceptschemeres->setProp('skos:prefLabel', $rootcat->getFullName());
636 $conceptschemeres->setProp('skos:definition', $rootcat->getDescription());
638 $count = $graph->addTriples( ARC2::getTriplesFromIndex($conceptschemeres->index) );
641 $subcats = $rootcat->listSubTree();
643 // memorize a few indexes
645 foreach($subcats as $subcat) {
646 $cat_id = $subcat->getId();
647 //$this->trovecat_id_index[$cat_id] = &$subcat;
649 $this->trovecat_id_to_shortname[$cat_id] = $subcat->getShortName();
652 foreach($subcats as $subcat) {
653 $cat_id = $subcat->getId();
655 $idsfullpath = $subcat->getIdsFullPath();
657 $folders_ids = explode(" :: ", $idsfullpath);
660 foreach ($folders_ids as $id) {
661 if (isset($this->trovecat_id_to_shortname[$id])) {
662 $paths[] = $this->trovecat_id_to_shortname[$id];
665 $path=implode('/', $paths);
667 $this->trovecat_id_to_path[$cat_id] = $path;
670 // Now, for all Concepts in this ConceptScheme
672 foreach($subcats as $subcat) {
673 $conceptres = ARC2::getResource($conf);
675 $path = $this->trovecat_id_to_path[$subcat->getId()];
676 $conceptres->setURI( util_make_url ('/softwaremap/trove/'.$scheme_shortname.'/'.$path) );
678 // $res->setRel('rdf:type', 'doap:Project');
679 rdfutils_setPropToUri($conceptres, 'rdf:type', 'skos:Concept');
681 rdfutils_setPropToUri($conceptres, 'skos:inScheme', $conceptscheme_uri);
683 $conceptres->setProp('skos:prefLabel', $subcat->getFullName());
684 $conceptres->setProp('skos:definition', $subcat->getDescription());
686 $parentid = $subcat->getParentId();
687 $rootparentid = $subcat->getRootCatId();
689 if ($parentid != $rootparentid) {
690 $parentpath = $this->trovecat_id_to_path[$parentid];
691 rdfutils_setPropToUri($conceptres, 'skos:broader', util_make_url ('/softwaremap/trove/'.$scheme_shortname.'/'.$parentpath) );
694 $count = $graph->addTriples( ARC2::getTriplesFromIndex($conceptres->index) );
703 * Provides an HTML preview of the trove categories as SKOS looking like turtle
706 public function htmlPreviewTroveCatsAsTurtle() {
707 $graph = $this->getTroveListResourcesGraph();
709 return $graph->dump();
713 * Outputs the trove categories as SKOS
715 * @param unknown_type $params
717 public function content_negociated_trove_list (&$params) {
719 $accept = $params['accept'];
721 // we are asked for RDF either as RDF+XML or Turtle
722 if($accept == 'application/rdf+xml' || $accept == 'text/turtle') {
725 // We will return RDF
726 $params['content_type'] = $accept;
728 $graph = $this->getTroveListResourcesGraph();
730 if ($accept == 'text/turtle') {
731 $doc = $graph->serialize($serializer="Turtle");
733 if ($accept == 'application/rdf+xml') {
734 $doc = $graph->serialize();
737 $params['content'] = $doc . "\n";
744 // FRS related methods
748 * Add RDF resources to a Graphite graph for the File Release system
750 * @param Graphite graph to be updated
751 * @param int group id
752 * @param int optional release id
754 private function addProjectFrsResourcesToGraph(&$graph, $group_id, $release_id = false) {
756 $group = &group_get_object($group_id);
758 // if we are passed a release ID, then only process that particular release
761 $frs_release = rdfed_frsrelease_get_object($release_id);
763 // Don't produce RDF for hidden releases
764 if( $frs_release->getStatus() == 1 ) {
765 $frs_package = $frs_release->getFRSPackage();
767 // Only produce RDF for releases of public and not hidden packages
768 if ($frs_package->isPublic() && $frs_package->getStatus() == 1) {
770 $frs_release->saveToGraph($graph);
776 // then produce RDF for all the project's packages
777 $frs_packages = get_rdfed_frs_packages($group);
779 foreach($frs_packages as $frs_package) {
780 // well actually, only for public and not hidden packages
781 if ($frs_package->isPublic() && $frs_package->getStatus() == 1) {
783 $frs_package->saveToGraph($graph);
792 * Outputs the public projects releases as ADMS.SW for /frs
794 * @param unknown_type $params
796 public function content_negociated_frs_index (&$params) {
798 $accept = $params['accept'];
800 // we are asked for RDF either as RDF+XML or Turtle
801 if($accept == 'application/rdf+xml' || $accept == 'text/turtle') {
804 // We will return RDF
805 $params['content_type'] = $accept;
807 $group_id = $params['group_id'];
808 $release_id = $params['release_id'];
810 $graph = new Graphite();
811 $this->graphSetAdmsswNameSpaces($graph);
813 $this->addProjectFrsResourcesToGraph($graph, $group_id, $release_id);
815 if ($accept == 'text/turtle') {
816 $doc = $graph->serialize($serializer="Turtle");
818 if ($accept == 'application/rdf+xml') {
819 $doc = $graph->serialize();
822 $params['content'] = $doc . "\n";
828 * Outputs the public downloadable files as ADMS.SW SoftwarePackages for /frs/download.php...
830 * @param unknown_type $params
832 public function content_negociated_frs_download_file (&$params) {
834 $accept = $params['accept'];
836 // we are asked for RDF either as RDF+XML or Turtle
837 if($accept == 'application/rdf+xml' || $accept == 'text/turtle') {
839 // We will return RDF
840 $params['content_type'] = $accept;
842 $file_id = $params['file_id'];
844 $frs_file = rdfed_frsfile_get_object($file_id);
846 session_redirect404();
849 $frs_release = $frs_file->getFRSRelease();
850 $frs_package = $frs_release->getFRSPackage();
851 $group = $frs_package->getGroup();
853 $graph = new Graphite();
854 $this->graphSetAdmsswNameSpaces($graph);
856 // We only accept files in public and non-hidden project's packages
857 if ($frs_package->isPublic() && $frs_package->getStatus() == 1) {
858 $frs_file->saveToGraph($graph);
861 if ($accept == 'text/turtle') {
862 $doc = $graph->serialize($serializer="Turtle");
864 if ($accept == 'application/rdf+xml') {
865 $doc = $graph->serialize();
868 $params['content'] = $doc . "\n";
876 // c-file-style: "bsd"