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

Source for file UserFieldDecls.php

Documentation is available at UserFieldDecls.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /*
  6.  * Created on 26. Feb. 2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  7.  */
  8.  
  9. /**
  10.  * UserFieldDecls class file.
  11.  * 
  12.  * PHP versions 5
  13.  *   
  14.  * LICENSE:
  15.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  16.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  17.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  19.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26.  *
  27.  * This software consists of voluntary contributions made by many individuals
  28.  * and is licensed under the GPL. For more information please see
  29.  * <http://opendocumentphp.org>.
  30.  * 
  31.  * $Id: UserFieldDecls.php 256 2007-08-01 14:16:10Z nmarkgraf $
  32.  * 
  33.  * @category    File Formats
  34.  * @package     OpenDocumentPHP
  35.  * @subpackage  content_body_text
  36.  * @author      Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  37.  * @copyright   Copyright in 2006, 2007 by The OpenDocumentPHP Team
  38.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  39.  * @version     SVN: $Id: UserFieldDecls.php 256 2007-08-01 14:16:10Z nmarkgraf $
  40.  * @link        http://opendocumentphp.org
  41.  * @since       0.5.2 - 26. Feb. 2007
  42.  */
  43.  
  44. /**
  45.  * 
  46.  */
  47. require_once 'OpenDocumentPHP/util/ODPElement.php';
  48.  
  49. /**
  50.  * UserFieldDecls class.
  51.  * 
  52.  * In this class we store all UserFieldDecl objects.
  53.  *  
  54.  * @category    File Formats
  55.  * @package     OpenDocumentPHP
  56.  * @subpackage  content_body_text
  57.  * @author      Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  58.  * @copyright   Copyright in 2006, 2007 by The OpenDocumentPHP Team
  59.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  60.  * @version     Release: @package_version@
  61.  * @link        http://opendocumentphp.org
  62.  * @since       0.5.2 - 26. Feb. 2007
  63.  */
  64.  
  65. class UserFieldDecls extends ODPElement 
  66. {
  67.     /**
  68.      * Constructor method.
  69.      * 
  70.      * @since       0.5.2 - 26. Feb. 2007
  71.      */
  72.     function __construct($elem=null$value=null$namespace=null
  73.     {         
  74.         if (is_null($elem)) {
  75.            parent::__construct('text:user-field-decls'''self::TEXT);
  76.         else {
  77.             if ($elem instanceof DOMElement{
  78.                 parent::__construct($elem);
  79.             else {
  80.                 parent::__construct($elem$value$namespace);         
  81.             }            
  82.         }   
  83.     }
  84.     
  85.     /**
  86.      * Retrieve User Field Decl by name and type;
  87.      * 
  88.      * @access         public
  89.      * @since         0.5.2 - 26.02.2007
  90.      */
  91.     function getUserFieldDecl($name{
  92.         $node $this->getTag('/office:document-content/office:body/office:text/text:user-field-decls/text:user-field-decl[@text:name="'.$name.'"]''',''-1);
  93.         // echo get_class($node) . ' ' . 'name:' . $node->tagName ."\n";
  94.         /*if ($node->attributes == null) {
  95.             echo "NO ATTRIBUTES!";
  96.         } else {
  97.             echo $node->attributes->item(0)->name.":".$node->attributes->item(0)->value."\n";
  98.             echo $node->attributes->item(1)->name.":".$node->attributes->item(1)->value."\n";
  99.             echo $node->attributes->item(2)->name.":".$node->attributes->item(2)->value."\n";
  100.         }
  101.         */
  102.         $ret NULL;
  103.         if ($node == ''{
  104.             $ret false;
  105.         else {            
  106.             $ret new UserFieldDecl($node);                                    
  107.         }
  108.         return $ret;
  109.     }
  110.     /**
  111.      * 
  112.      */
  113.     function setUserFieldDecl($name$value{
  114.         $ret false;        
  115.         $oldNode $this->getUserFieldDecl($name);        
  116.         if ($oldNode !== false{            
  117.             $tmp $oldNode->getValueType();
  118.             switch ($tmp{
  119.                 case 'string' 
  120.                     $oldNode->setStringValue($value);
  121.                     $ret true;
  122.                     break;
  123.                 default :
  124.                     // echo "not found: '".$oldNode->getValueType()."'\n";
  125.                     $ret false;
  126.             }            
  127.         }
  128.         return $ret;
  129.     }
  130.     
  131.     /**
  132.      * Append new UserFieldDecl to this set.
  133.      * 
  134.      * @access         public
  135.      * @since         0.5.2 - 26.02.2007
  136.      */
  137.     function appendUserFieldDecl($name$type$value{
  138.         $newNode new UserFieldDecl();
  139.         $this->appendChuld($newNode);
  140.         
  141.         $ret false;
  142.         switch ($type{
  143.             case 'string'
  144.                 $newNode->setStringValue(value);
  145.                 break;
  146.             default :
  147.                 $ret false;
  148.         }
  149.         $newNode->setName($name);             
  150.         if (isset($newNode&& $newNode != NULL{        
  151.             $ret true;
  152.         }
  153.         return $ret;
  154.     }
  155. }
  156. ?>

Documentation generated on Wed, 18 Jun 2008 06:34:05 +0200 by phpDocumentor 1.3.2