OpenDocumentPHP
[ class tree: OpenDocumentPHP ] [ index: OpenDocumentPHP ] [ all elements ]

Source for file ElementFragment.php

Documentation is available at ElementFragment.php

  1. <?php
  2. /*
  3.  * Created on 21.01.2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  4.  *
  5.  * PHP versions 5.2 or better.
  6.  *
  7.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  8.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  9.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  10.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  11.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  12.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  14.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  17.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18.  *
  19.  * This software consists of voluntary contributions made by many individuals
  20.  * and is licensed under the GPL. For more information please see
  21.  * <http://opendocumentphp.org>.
  22.  * 
  23.  * $Id: ElementFragment.php 147 2007-03-05 15:53:48Z nmarkgraf $
  24.  */
  25. require_once 'OpenDocumentPHP/util/Fragment.php';
  26. /**
  27.  * Abstract ElementFragment class.
  28.  *  
  29.  * @author         Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  30.  * @copyright     Copyright in 2006, 2007 by The OpenDocumentPHP Team
  31.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  32.  * @version        $Revision: 147 $
  33.  * @package        OpenDocumentPHP
  34.  * @subpackage  util
  35.  * @abstract
  36.  * @since         0.5.0 - 08.02.2007
  37.  * @deprecated  0.5.2 - 05.03.2007 Use ODPElement instead of Fragment or ElementFragment!
  38.  */
  39. abstract class ElementFragment extends Fragment {
  40.     /**
  41.      * Constructor method.
  42.      * 
  43.      * @since         0.5.0 - 08.02.2007
  44.      */
  45.     function __construct($domFragment$root null{
  46.         parent :: __construct($domFragment$root);
  47.         if (isset ($root&& $root != null{
  48.         else {
  49.             $this->__setRoot();
  50.         }
  51.     }
  52.     /**
  53.      * Set the $root attribute correctly.
  54.      * 
  55.      * @abstract
  56.      * @access         protected
  57.      * @since         0.5.0 - 08.02.2007
  58.      */
  59.     abstract protected function __setRoot();
  60.     /**
  61.      * Set an attribute with namespace, tag and value.
  62.      * If an attibute old exists, it will be removed first.
  63.      *  
  64.      * @return      mixed <b>True</b> if there was no old attibute, else the old attribute node.
  65.      * @access         public
  66.      * @since         0.5.0 - 08.02.2007
  67.      */
  68.     function setAttributeNS($namespace$tag$value{
  69.         $ret true;
  70.         if ($this->root->hasAttributeNS($namespace$tag)) {
  71.             $ret $this->root->removeAttributeNS($namespace$tag);
  72.         }
  73.         $this->root->setAttributeNS($namespace$tag$value);
  74.         return $ret;
  75.     }
  76.     /**
  77.      * Retreive an attribute by namespace and tag.
  78.      * 
  79.      * @return      mixed The value of the retrieved attribute or <b>false</b> if there is no such attribute.
  80.      * @access         public
  81.      * @since         0.5.0 - 08.02.2007
  82.      */
  83.     function getAttributeNS($namespace$tag{
  84.         $ret false;
  85.         if ($this->root->hasAttributeNS($namespace$tag)) {
  86.             $ret $this->root->getAttributeNS($namespace$tag);
  87.             // echo "got AttributeNS '".$namespace.'\':'.$tag.'='.$ret."\n";
  88.         }
  89.         return $ret;
  90.     }
  91.     /**
  92.      * Retrieve the current Class as DOMElement.
  93.      * 
  94.      * @return         DOMElement The current class as DOMElement.
  95.      * @access         public
  96.      * @since         0.5.0 - 08.02.2007
  97.      */
  98.     function getElement({
  99.         return $this->getDocumentFragment();
  100.     }
  101. }
  102. ?>

Documentation generated on Tue, 12 Jun 2007 09:59:44 +0200 by phpDocumentor 1.3.2