mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
- Projekttasks können per klick im Tree erledigt werden
- RDF Klasse Erweiterung für verschachtelte Sequenzen - Projektphase RDF wird jetzt über RDF Klasse erzeugt
This commit is contained in:
+104
-19
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Technikum-Wien
|
||||
/* Copyright (C) 2011 FH Technikum-Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
@@ -15,26 +15,34 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>
|
||||
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
|
||||
* Andreas Österreicher <andreas.oesterreicher@technikum-wien.at>
|
||||
*/
|
||||
/**
|
||||
* RDF Klasse
|
||||
*
|
||||
* Hilfsfunktionen für die Generierung von RDF-Dateien
|
||||
*
|
||||
*/
|
||||
|
||||
class rdf
|
||||
{
|
||||
// Header Variablen
|
||||
public $content_type='Content-type: application/xhtml+xml'; // string
|
||||
public $xml_header='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; // string
|
||||
public $xml_ns; // string
|
||||
protected $rdf_url; // string
|
||||
protected $rdf_url; // string
|
||||
protected static $rdf_text;
|
||||
protected static $nl="\n";
|
||||
protected static $tb="\t";
|
||||
|
||||
// Objekt Variablen
|
||||
protected $counter=0; // int
|
||||
public $obj_id; // string
|
||||
protected $counter=0;
|
||||
public $obj_id;
|
||||
public $obj = array();
|
||||
public $attr = array(); // string
|
||||
|
||||
public $attr = array();
|
||||
protected $childs = array();
|
||||
protected $sequence = array();
|
||||
|
||||
/**
|
||||
* Konstruktor - Uebergibt die Connection und laedt optional eine Reservierung
|
||||
* @param $reservierung_id
|
||||
@@ -46,11 +54,10 @@ class rdf
|
||||
}
|
||||
|
||||
/**
|
||||
* Prueft die Variablen vor dem Speichern
|
||||
* auf Gueltigkeit.
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
* Erstellt ein neues RDF Description Objekt
|
||||
*
|
||||
* @return index des neuen Objekts
|
||||
*/
|
||||
|
||||
public function newObjekt($id)
|
||||
{
|
||||
$this->obj[$this->counter] = new rdf();
|
||||
@@ -58,12 +65,21 @@ class rdf
|
||||
return $this->counter-1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die ID eines Objektes
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
public function setObjID($id)
|
||||
{
|
||||
$this->obj_id=$id;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sendet die HTTP-Header der RDF Datei
|
||||
* @param $cache
|
||||
*/
|
||||
public function sendHeader($cache=false)
|
||||
{
|
||||
|
||||
@@ -82,6 +98,12 @@ class rdf
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die Werte
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $cdata
|
||||
*/
|
||||
public function setAttribut($name,$value,$cdata=true)
|
||||
{
|
||||
$this->attr[$this->counter]->name=$name;
|
||||
@@ -92,30 +114,93 @@ class rdf
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt den RDF Header aus den bestehenden Daten
|
||||
*/
|
||||
public function createRdfHeader()
|
||||
{
|
||||
$this->rdf_text="\n".'<RDF:RDF'."\n\t"
|
||||
.'xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n\t".'xmlns:'.$this->xml_ns.'="'.$this->rdf_url.'/rdf#"'."\n".'>'."\n\t"
|
||||
.'<RDF:Seq about="'.$this->rdf_url.'">'."\n";
|
||||
.'xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n\t".'xmlns:'.$this->xml_ns.'="'.$this->rdf_url.'/rdf#"'."\n".'>'."\n\t";
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt die Descriptions aus den bestehenden Daten
|
||||
*/
|
||||
public function createRdfData()
|
||||
{
|
||||
foreach ($this->obj as $obj)
|
||||
{
|
||||
$this->rdf_text.="\n\t".'<RDF:li>'
|
||||
."\n\t\t".'<RDF:Description id="'.$obj->obj_id.'" about="'.$this->rdf_url.'/'.$obj->obj_id.'" >';
|
||||
$this->rdf_text.="\n\t\t".'<RDF:Description id="'.$obj->obj_id.'" about="'.$this->rdf_url.'/'.$obj->obj_id.'" >';
|
||||
foreach ($obj->attr as $attr)
|
||||
$this->rdf_text.="\n\t\t\t<".$this->xml_ns.':'.$attr->name.'><![CDATA['.$attr->value.']]></'.$this->xml_ns.':'.$attr->name.'>';
|
||||
$this->rdf_text.="\n\t\t".'</RDF:Description>'."\n\t".'</RDF:li>';
|
||||
$this->rdf_text.="\n\t\t".'</RDF:Description>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fuegt ein Objekt zur Sequence hinzu
|
||||
* Wenn eine Parent_id uebergeben wird, wird das Objekt unterhalb dieses Eintrags
|
||||
* angehängt
|
||||
*
|
||||
* @param $id
|
||||
* @param $parent_id
|
||||
*/
|
||||
public function addSequence($id, $parent_id=null)
|
||||
{
|
||||
if(!is_null($parent_id))
|
||||
{
|
||||
$this->childs[$parent_id][]=$id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sequence[]=$id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt die Sequenz
|
||||
* Wenn eine ID uebergeben wird, wird nur die Sequenz unterhalb dieser ID erzeugt
|
||||
*
|
||||
* @param $id
|
||||
*/
|
||||
function createRDFSequence($id=null)
|
||||
{
|
||||
if(is_null($id))
|
||||
{
|
||||
$this->rdf_text.='<RDF:Seq about="'.$this->rdf_url.'">'."\n";
|
||||
foreach ($this->sequence as $id)
|
||||
{
|
||||
$this->createRDFSequence($id);
|
||||
}
|
||||
$this->rdf_text.='</RDF:Seq>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->rdf_text.="\n\t".'<RDF:li RDF:resource="'.$this->rdf_url.'/'.$id.'" >';
|
||||
if(isset($this->childs[$id]))
|
||||
{
|
||||
$this->rdf_text.='<RDF:Seq about="'.$this->rdf_url.'/'.$id.'">'."\n";
|
||||
foreach($this->childs[$id] as $childid)
|
||||
{
|
||||
$this->createRDFSequence($childid);
|
||||
}
|
||||
$this->rdf_text.='</RDF:Seq>'."\n";
|
||||
}
|
||||
$this->rdf_text.='</RDF:li>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert den RDF Footer
|
||||
*/
|
||||
public function createRdfFooter()
|
||||
{
|
||||
$this->rdf_text.='</RDF:Seq>'."\n".'</RDF:RDF>'."\n\t";
|
||||
$this->rdf_text.='</RDF:RDF>'."\n\t";
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert das RDF
|
||||
*/
|
||||
public function sendRdfText()
|
||||
{
|
||||
//echo $this->rdf_text;
|
||||
@@ -123,7 +208,7 @@ class rdf
|
||||
{
|
||||
$this->createRdfHeader();
|
||||
$this->createRdfData();
|
||||
//$this->createRdfSequence();
|
||||
$this->createRdfSequence();
|
||||
$this->createRdfFooter();
|
||||
}
|
||||
echo $this->rdf_text;
|
||||
|
||||
Reference in New Issue
Block a user