Location: PHPKode > projects > ATUIN > atuin/app/models/rdfengine/RDFDocumentModel.php
<?php

require_once 'RDFNodeChannel.php';

/**
 * represents a complete rdf file.
 * it contains a variable number of channel objects.
 *
 * @author Michael Lessnau
 * @version 0.1
 */
class RDFDocumentModel {

   /**
    * @var $channels RDFNodeChannel[] contains the channels
    */
   private $channels;
   
   /**
    * constructor
    */
   public function __construct( ) {
      $this->channels = null;
   }
   
   /**
    * destructor
    */
   public function __destruct( ) {
      // nop
   }
   
   /**
    * setting the class' attributes
    *
    * @param $name string attribute name
    * @param $value mixed attribute value
    */
   public function __set( $name, $value) {
      switch( $name) {
         case 'channels':
            $this->channels = $value;
            break;
      }
   }
   
   /**
    * access the class' attributes
    *
    * @param $name string attribute name
    * @return string attribute value
    */
   public function __get( $name) {
      switch( $name) {
         case 'channels':
            return $this->channels;
      }
      return false;
   }
   
   /**
    * appending a channel object to $this->channels
    *
    * @param $channel RDFNodeChannel channel object
    */
   public function addChannel( $channel) {
      if( $this->channels==null)
         $this->channels = array( );
      foreach( $this->channels as $key => $c) {
         if( strcmp( $c->rdfAbout, $channel->rdfAbout)==0) {
            $this->channels[$key] = $channel;
            return;   
         }
      }
      array_push( $this->channels, $channel);
   }
   
   /**
    * serialize the channel.
    *
    * @return string serialized rdf document
    */
   public function toString( ) {
      $output  = '<' . '?xml version="1.0" encoding="utf-8"?' . '>' . "\n\n";
      $output .= '<rdf:RDF' . "\n";
      $output .= '  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n";
      $output .= '  xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n";
      $output .= '  xmlns="http://purl.org/rss/1.0/"' . "\n";
      $output .= '>' . "\n";
      if( $this->channels!=null) {
         foreach( $this->channels as $channel) {
            $output .= $channel->toString( '  ');
         }
      }
      $output .= '</rdf:RDF>';
      return $output;
   }   
};

?>
Return current item: ATUIN