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

Source for file UserFieldDecls.php

Documentation is available at UserFieldDecls.php

  1. <?php
  2. /*
  3.  * Created on 26.02.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: UserFieldDecls.php 136 2007-03-02 18:02:29Z nmarkgraf $
  24.  */
  25. require_once 'OpenDocumentPHP/util/ElementFragment.php';
  26. /**
  27.  * UserFieldDecls class.
  28.  * 
  29.  * In this class we store all UserFieldDecl objects.
  30.  *  
  31.  * @author         Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  32.  * @copyright     Copyright in 2006, 2007 by The OpenDocumentPHP Team
  33.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  34.  * @version        $Revision: 136 $
  35.  * @package        OpenDocumentPHP
  36.  * @subpackage  content_body_text
  37.  * @since         0.5.2 - 26.02.2007
  38.  */
  39.  
  40. class UserFieldDecls extends ElementFragment {
  41.     /**
  42.      * Set element root to "text:user-field-decl"
  43.      * 
  44.      * @access         protected
  45.      * @since         0.5.2 - 26.02.2007
  46.      */
  47.     function __setRoot({
  48.         $this->root = $this->domFragment->createElementNS(self :: TEXT'text:user-field-decls');
  49.     }
  50.     
  51.     /**
  52.      * Retrieve User Field Decl by name and type;
  53.      * 
  54.      * @access         public
  55.      * @since         0.5.2 - 26.02.2007
  56.      */
  57.     function getUserFieldDecl($name{
  58.         $node $this->getTag('/office:document-content/office:body/office:text/text:user-field-decls/text:user-field-decl[@text:name="'.$name.'"]''',''-1);
  59.         // echo get_class($node) . ' ' . 'name:' . $node->tagName ."\n";
  60.         /*if ($node->attributes == null) {
  61.             echo "NO ATTRIBUTES!";
  62.         } else {
  63.             echo $node->attributes->item(0)->name.":".$node->attributes->item(0)->value."\n";
  64.             echo $node->attributes->item(1)->name.":".$node->attributes->item(1)->value."\n";
  65.             echo $node->attributes->item(2)->name.":".$node->attributes->item(2)->value."\n";
  66.         }
  67.         */
  68.         $ret NULL;
  69.         if ($node == ''{
  70.             $ret false;
  71.         else {            
  72.             $ret new UserFieldDecl($this->domFragment$node);                                    
  73.         }
  74.         return $ret;
  75.     }
  76.     /**
  77.      * 
  78.      */
  79.     function setUserFieldDecl($name$value{
  80.         $ret false;        
  81.         $oldNode $this->getUserFieldDecl($name);        
  82.         if ($oldNode !== false{            
  83.             $tmp $oldNode->getValueType();
  84.             switch ($tmp{
  85.                 case 'string' 
  86.                     $oldNode->setStringValue($value);
  87.                     $ret true;
  88.                     break;
  89.                 default :
  90.                     // echo "not found: '".$oldNode->getValueType()."'\n";
  91.                     $ret false;
  92.             }            
  93.         }
  94.         return $ret;
  95.     }
  96.     
  97.     /**
  98.      * Append new UserFieldDecl to this set.
  99.      * 
  100.      * @access         public
  101.      * @since         0.5.2 - 26.02.2007
  102.      */
  103.     function appendUserFieldDecl($name$type$value{
  104.         $newNode new UserFieldDecl($this->domFragment);
  105.         $ret false;
  106.         switch ($type{
  107.             case 'string'
  108.                 $newNode->setStringValue(value);
  109.                 break;
  110.             default :
  111.                 $ret false;
  112.         }
  113.         $newNode->setName($name);             
  114.         if (isset($newNode&& $newNode != NULL{
  115.             $this->root->appendChild($newNode->getDocumentFragment);
  116.             $ret true;
  117.         }
  118.         return $ret;
  119.     }
  120. }
  121. ?>

Documentation generated on Tue, 12 Jun 2007 10:01:04 +0200 by phpDocumentor 1.3.2