CommonDoctypeDeclaration.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2007 by Ivan Y. Khvostishkov                            *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 /* $Id: CommonDoctypeDeclaration.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00024     final class CommonDoctypeDeclaration extends DoctypeDeclaration
00025     {
00026         private $organization   = null;
00027         
00028         private $type           = null;
00029         private $subtype        = null;
00030         private $version        = null;
00031         private $variant        = null;
00032         private $language       = null;
00033         
00037         public static function create()
00038         {
00039             return new self;
00040         }
00041         
00045         public function setOrganization($organization)
00046         {
00047             $this->organization = $organization;
00048             
00049             return $this;
00050         }
00051         
00052         public function getOrganization()
00053         {
00054             return $this->organization;
00055         }
00056         
00060         public function setType($type)
00061         {
00062             $this->type = $type;
00063             
00064             return $this;
00065         }
00066         
00067         public function getType()
00068         {
00069             return $this->type;
00070         }
00071         
00075         public function setSubtype($subtype)
00076         {
00077             $this->subtype = $subtype;
00078             
00079             return $this;
00080         }
00081         
00082         public function getSubtype()
00083         {
00084             return $this->subtype;
00085         }
00086         
00090         public function setVersion($version)
00091         {
00092             $this->version = $version;
00093             
00094             return $this;
00095         }
00096         
00097         public function getVersion()
00098         {
00099             return $this->version;
00100         }
00101         
00105         public function setVariant($variant)
00106         {
00107             $this->variant = $variant;
00108             
00109             return $this;
00110         }
00111         
00112         public function getVariant()
00113         {
00114             return $this->variant;
00115         }
00116         
00120         public function setLanguage($language)
00121         {
00122             $this->language = $language;
00123             
00124             return $this;
00125         }
00126         
00127         public function getLanguage()
00128         {
00129             return $this->language;
00130         }
00131         
00135         public function setFpi($fpi)
00136         {
00137             parent::setFpi($fpi);
00138             
00139             preg_match(
00140                 '~^-//([a-z0-9]+)//DTD ([a-z]+)'
00141                 .' ?([a-z]+)? ?(\d+\.\d+)?'.
00142                 ' ?([a-z]+)?//([a-z]+)$~i',
00143                 $fpi,
00144                 $matches
00145             );
00146             
00147             $this->organization = !empty($matches[1]) ? $matches[1] : null;
00148             $this->type = !empty($matches[2]) ? $matches[2] : null;
00149             
00150             $this->subtype = !empty($matches[3]) ? $matches[3] : null;
00151             $this->version = !empty($matches[4]) ? $matches[4] : null;
00152             $this->variant = !empty($matches[5]) ? $matches[5] : null;
00153             $this->language = !empty($matches[6]) ? $matches[6] : null;
00154             
00155             return $this;
00156         }
00157         
00158         public function getFpi()
00159         {
00160             if (!$this->organization)
00161                 return null;
00162             
00163             return
00164                 '-//'.$this->organization.'//DTD '.$this->type
00165                 .($this->subtype ? ' '.$this->subtype : null)
00166                 .($this->version ? ' '.$this->version : null)
00167                 .($this->variant ? ' '.$this->variant : null)
00168                 .'//'.$this->language;
00169         }
00170     }
00171 ?>

Generated on Sun Dec 9 21:56:24 2007 for onPHP by  doxygen 1.5.4