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

Source for file OpenDocumentText.php

Documentation is available at OpenDocumentText.php

  1. <?php
  2. /*
  3.  * Created on 04.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: OpenDocumentText.php 182 2007-06-11 13:32:34Z nmarkgraf $
  24.  */
  25. require_once 'OpenDocumentPHP/OpenDocumentAbstract.php';
  26. /**
  27.  * OpenDocumentText class.
  28.  *   
  29.  * You could uses this class as follows:
  30.  * 
  31.  * <code>
  32.  *         $text = new OpenDocumentText( 'YourFavoriteTextDocument.odt' );
  33.  *         // do some thing with it
  34.  *         ...
  35.  *         // And write it back
  36.  *         $text->close();
  37.  * </code>
  38.  * 
  39.  * Be aware that even if <b>you</b> do not modifiy the OpenDocument, the library will!
  40.  * So do not expect the that the file is absolut the same after you run the close method.
  41.  * 
  42.  * @author         Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  43.  * @copyright     Copyright in 2006, 2007 by The OpenDocumentPHP Team
  44.  * @license     http://www.gnu.org/licenses/gpl.html GNU Public License 2.0 or above.
  45.  * @version        $Revision: 182 $
  46.  * @package        OpenDocumentPHP
  47.  * @since         0.5.0 - 08.02.2007
  48.  */
  49.     /**
  50.      * Namespace TEXT
  51.      */
  52.     const odmTextNamespace = 'application/vnd.oasis.opendocument.text';
  53.     /**
  54.      * Constructor method.
  55.      * 
  56.      * Read (and if not exists create) an OpenDocument text file.
  57.      * 
  58.      * @param         string fullpath Full path and name of the document
  59.      * @since         0.5.0 - 08.02.2007
  60.      */
  61.     function __construct($fullpath=null{
  62.         // Construct a text document
  63.         parent :: __construct(self :: odmTextNamespace);
  64.         // Is the variable $fullpath given?
  65.         if (isset($fullpath&& is_string($fullpath)) {            
  66.             if (file_exists($fullpath)) {
  67.                 // File does exist, so we can load it via open.
  68.                 parent :: open($fullpath);
  69.             else {
  70.                 // File does not exist, so we can create it.        
  71.                 parent :: open($fullpathself :: CREATEself :: odmTextNamespace);
  72.                 // Clean it, with a fresh init call.                
  73.                 $this->init();                
  74.                 // Set everything to a OpenDocument TEXT file.
  75.                 $this->content->setText();
  76.             }
  77.         else {
  78.             // JUST A CLEAN FILE WITH NO FILE NAME JET!!!! DANGER!!!!
  79.             $this->init();
  80.             $this->content->setText();
  81.         }
  82.     }
  83.     /**     
  84.      * @since        0.5.2 - 21.03.2007
  85.      */
  86.     function setDefaultStyles({
  87.         
  88.     }
  89.     /**
  90.      * Setup some default data for the meta.xml.
  91.      * 
  92.      * @since        0.5.2 - 21.03.2007
  93.      */
  94.     function setDefaultMeta({
  95.         // =====================================================================
  96.         $dc $this->getMeta()->getDublinCoreFragment();
  97.         // ---------------------------------------------------------------------
  98.         $dc->setSubject('A generated subject by OpenDocumentPHP.');
  99.         $dc->setTitle('This is a generated title by OpenDocumentPHP.');
  100.         $dc->setDescription('This is a short description by OpenDocumentPHP.');
  101.         $dc->setLanguage('en');
  102.         // =====================================================================    
  103.         $meta $this->getMeta()->getMetaFragment();
  104.         // ---------------------------------------------------------------------        
  105.     }
  106. }
  107. ?>

Documentation generated on Tue, 12 Jun 2007 10:00:31 +0200 by phpDocumentor 1.3.2