Author: kn
Date: Tue Feb  5 14:50:29 2008
New Revision: 7289

Log:
- Rewrote public interfaces as defined by the second desing document.

Added:
    experimental/Document/src/document_manager.php   (with props)
    experimental/Document/src/interfaces/conversions/
    experimental/Document/src/interfaces/conversions/html.php   (with props)
    experimental/Document/src/interfaces/vadation.php   (with props)
Modified:
    experimental/Document/src/interfaces/converter.php
    experimental/Document/src/interfaces/document.php

Added: experimental/Document/src/document_manager.php
==============================================================================
--- experimental/Document/src/document_manager.php (added)
+++ experimental/Document/src/document_manager.php [iso-8859-1] Tue Feb  5 
14:50:29 2008
@@ -1,0 +1,73 @@
+<?php
+/**
+ * File containing the ezcDocumentManager class
+ *
+ * @package Document
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * A ducument type  handler manager class.
+ *
+ * The document manager manages a list of document handlers for document types,
+ * identified by a string. You may overwrite the used implementation for one or
+ * all formats, or add custom implementations for new document types.
+ *
+ * <code>
+ *  // Get a RST document from a file
+ *  $doc = ezcDocumentManager::loadFile( 'rst', '/path/to/my.rst' );
+ *
+ *  // Overwrite the used implementation with a custom RST handler
+ *  ezcDocumentManager::setHandler( 'rst', 'myRsthandler' );
+ *  // This will now use the custom handler
+ *  $doc = ezcDocumentManager::loadFile( 'rst', '/path/to/my.rst' );
+ * </code>
+ * 
+ * @package Document
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ * @mainclass
+ */
+final class ezcDocumentManager
+{
+    /**
+     * Predefined handler list.
+     *
+     * @var array
+     */
+    protected static $handlers = array(
+        'rst'   => 'ezcDocumentRst',
+        // ...
+    );
+
+    /**
+     * Load file with specified handler
+     * 
+     * @param string $format 
+     * @param string $file 
+     * @return ezcDocument
+     */
+    public static function loadFile( $format, $file )
+    {
+        // @TODO: Implement
+    }
+
+    /**
+     * Set handler for format
+     *
+     * Set the format handler for $format to the specified handler class, which
+     * should extend from ezcDocument.
+     * 
+     * @param string $format 
+     * @param string $handler 
+     * @return void
+     */
+    public static function setHandler( $format, $handler )
+    {
+        // @TODO: Implement
+    }
+}
+

Propchange: experimental/Document/src/document_manager.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: experimental/Document/src/interfaces/conversions/html.php
==============================================================================
--- experimental/Document/src/interfaces/conversions/html.php (added)
+++ experimental/Document/src/interfaces/conversions/html.php [iso-8859-1] Tue 
Feb  5 14:50:29 2008
@@ -1,0 +1,31 @@
+<?php
+/**
+ * File containing the ezcDocumentHtmlConversion class
+ *
+ * @package Document
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Interface specifying, that the document may be directly exported to HTML.
+ * 
+ * @package Document
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+interface ezcDocumentHtmlConversion
+{
+    /**
+     * Get document as HTML
+     *
+     * Return the document compiled to HTML.
+     * 
+     * @return string
+     */
+    public function getAsHtml();
+}
+
+?>

Propchange: experimental/Document/src/interfaces/conversions/html.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: experimental/Document/src/interfaces/converter.php
==============================================================================
--- experimental/Document/src/interfaces/converter.php [iso-8859-1] (original)
+++ experimental/Document/src/interfaces/converter.php [iso-8859-1] Tue Feb  5 
14:50:29 2008
@@ -5,17 +5,29 @@
  *
  * @package Document
  * @version //autogen//
- * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
  * @license http://ez.no/licenses/new_bsd New BSD License
- * 
- * A base class for document type handlers.
- *
  */
 
-
+/**
+ * A base class for document type converters.
+ * 
+ * @package Document
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
 interface ezcDocumentConverter
 {
-    static public function convert( ezcDocument $doc, $parameters = array() );
+    /**
+     * Convert documents between two formats
+     * 
+     * Convert documents of the given type to the requested type.
+     *
+     * @param ezcDocument $doc 
+     * @return ezcDocument
+     */
+    abstract public function convert( ezcDocument $doc );
 }
 
 ?>

Modified: experimental/Document/src/interfaces/document.php
==============================================================================
--- experimental/Document/src/interfaces/document.php [iso-8859-1] (original)
+++ experimental/Document/src/interfaces/document.php [iso-8859-1] Tue Feb  5 
14:50:29 2008
@@ -1,75 +1,88 @@
 <?php
-
 /**
  * File containing the ezcDocument class
  *
  * @package Document
  * @version //autogen//
- * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
  * @license http://ez.no/licenses/new_bsd New BSD License
- * 
- * A base class for document type handlers.
- *
  */
 
-
+/**
+ * A base class for document type handlers.
+ * 
+ * @package Document
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
 abstract class ezcDocument
 {
     /**
-     * Returns current document in DOM format
-     * Should be implemented in derived class
+     * Create document from input string
      * 
-     * @return DOMDocument
+     * Create a document of the current type handler class and parse it into a
+     * usable internal structure.
+     *
+     * @param string $string 
+     * @return void
      */
-    public function getDOM()
+    abstract public function loadString( $string );
+
+    /**
+     * Create document from file
+     *
+     * Create a document of the current type handler class and parse it into a
+     * usable internal structure. The default implementation just calls
+     * loadString(), but you may want to provide an optimized implementation.
+     * 
+     * @param string $file 
+     * @return void
+     */
+    public function loadFile( $file )
     {
-        // throw exception
+        if ( !file_exists( $file ) || !is_readable( $file ) )
+        {
+            throw new ezcBaseFileNotFoundException( $file );
+        }
+
+        $this->loadString(
+            file_get_contents( $file )
+        );
     }
 
     /**
-     * Returns current document in XML format
-     * Should be implemented in derived class
+     * Return document compiled to the docbook format
      * 
-     * @return string
+     * The internal document structure is compiled to the docbook format and
+     * the resulting docbook document is returned.
+     *
+     * This method is required for all formats to have one central format, so
+     * that each format can be compiled into each other format using docbook as
+     * an intermediate format.
+     *
+     * You may of course just call an existing converter for this conversion.
+     *
+     * @return ezcDocumentDocbook
      */
-    public function getXML()
-    {
-        // throw exception
-    }
+    abstract public function getAsDocbook();
 
     /**
-     * Returns current document in text format
-     * Should be implemented in derived class
+     * Create document from docbook document
+     *
+     * A document of the docbook format is provided and the internal document
+     * structure should be created out of this.
+     *
+     * This method is required for all formats to have one central format, so
+     * that each format can be compiled into each other format using docbook as
+     * an intermediate format.
+     *
+     * You may of course just call an existing converter for this conversion.
      * 
-     * @return string
+     * @param ezcDocumentDocbook $document 
+     * @return void
      */
-    public function getText()
-    {
-        // throw exception
-    }
-
-    /**
-     * Returns name of the file where the document is stored
-     * Should be implemented in derived class
-     * 
-     * @return string
-     */
-    public function getFileName()
-    {
-        // throw exception
-    }
-
-    /**
-     * Returns name of the document format
-     * 
-     * @return string
-     */
-    public function getFormatName()
-    {
-        return $this->formatName;
-    }
-
-    protected $formatName;
+    abstract public function createFromDocbook( ezcDocumentDocbook $document );
 }
 
 ?>

Added: experimental/Document/src/interfaces/vadation.php
==============================================================================
--- experimental/Document/src/interfaces/vadation.php (added)
+++ experimental/Document/src/interfaces/vadation.php [iso-8859-1] Tue Feb  5 
14:50:29 2008
@@ -1,0 +1,50 @@
+<?php
+/**
+ * File containing the ezcDocumentHtmlConversion class
+ *
+ * @package Document
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Interface specifying, that the document may be directly exported to HTML.
+ * 
+ * @package Document
+ * @version //autogen//
+ * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+interface ezcDocumentValidation
+{
+    /**
+     * Validate the input file
+     *
+     * Validate the input file against the specification of the current
+     * document format.
+     *
+     * Returns true, if the validation succeded, and an array with
+     * ezcDocumentValidationError objects otherwise.
+     * 
+     * @param string $file
+     * @return mixed
+     */
+    public function validateFile( $file );
+
+    /**
+     * Validate the input string
+     *
+     * Validate the input string against the specification of the current
+     * document format.
+     *
+     * Returns true, if the validation succeded, and an array with
+     * ezcDocumentValidationError objects otherwise.
+     * 
+     * @param string $string
+     * @return mixed
+     */
+    public function validateString( $string );
+}
+
+?>

Propchange: experimental/Document/src/interfaces/vadation.php
------------------------------------------------------------------------------
    svn:eol-style = native


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to