metallic                Mon Jan 15 16:27:34 2001 EDT

  Modified files:              
    /php4/pear/XML      Render.php 
  Log:
  Added a method to call the HTML and PDF rendering modes(not implemented yet).
  Added the parse function which should allow for finer XML parsing.
  The XML file contents are now stored in a var available to the entire class.
  Added a wrapper around setInputFile() and setInput()
  # This class still has a long ways to go, but this is a start.
  
  
Index: php4/pear/XML/Render.php
diff -u php4/pear/XML/Render.php:1.1 php4/pear/XML/Render.php:1.2
--- php4/pear/XML/Render.php:1.1        Fri Jan 12 15:01:19 2001
+++ php4/pear/XML/Render.php    Mon Jan 15 16:27:34 2001
@@ -16,31 +16,112 @@
 // +---------------------------------------------------------------------+
 // |  Authors:  Sean Grimes <[EMAIL PROTECTED]>                    |
 // +---------------------------------------------------------------------+
+// 
+// $Id: Render.php,v 1.2 2001/01/16 00:27:34 metallic Exp $
 
 /**
-* Render class for rendering HTML. This class inherits 
-* everything from XML_Parser, taking the variables that
-* were parsed and rendering the file appropriatly.
+* Render class for rendering from XML. 
 *
+* This class should render documents from xml.
+* The intended rendering modes will be HTML and
+* the Adobe PDF format. Maybe at some point I 
+* will make it possible to take a document from
+* HTML to PDF, but this is unlikely. 
+* 
 * @author Sean Grimes <[EMAIL PROTECTED]>
 */ 
 
-class XML_Render extends XML_Parser {
+/*** Todo ***
+ ** - Implement the HTML and PDF rendering modes
+ ** - Extend the parse() function to what is needed
+ ** - Implement filesystem commands
+ ** - Come up with the XML language syntax
+ ** - Provide a better class interface 
+ ** - Do some debugging
+***/
 
-       function Render_HTML() {
+require_once "Parser.php";
 
-       }
+class XML_Render extends XML_Parser {
 
-       function _Render_HTML() {
+    var $data; // holds the file contents
 
-       }
+       function XML_Render($charset = 'UTF-8', $mode = "event") {
+               $this->XML_Parser($charset, $mode);
 
-       function Open($file) {
+       }
 
-               $fpointer = fopen($file, "w+");
-       
-       
-       
-       
+       /**
+       * Set the input file.
+       *
+       * This overrides XML_Parser::setInputFile(),
+       * and creates a wrapper around XML_Parser::setInputFile()
+       * and XML_Parser::inputFile(). The functions are so similar
+       * that its confusing me(hint: document XML_Parser).
+       *
+       * @access public
+       * @param $file file to be input
+       */
+       function setInputFile($file) {
+               $fp = @fopen($file, "r");
+               if (is_resource($fp)) {
+                       $this->fp = $fp;
+                       return $this->setInput($file);
+               } else {
+                       return new XML_Parser_Error($php_errormsg); // ??
+               }
+       }
 
+    /** 
+    * Parses the document
+    *
+    * This function extends the capabilities of the 
+    * parse function in XML/Parser.php. The only real
+    * notable change is the addition of a command to 
+    * store the contents of the file to a variable to
+    * make it available to the entire class
+    */
+    function parse() {
+        if(!is_resource($this->fp)) {
+            return new XML_Parser_Error("no input");
+        }
+        if (!is_resource($this->parser)) {
+            return new XML_Parser_Error("no parser");
+        }
+        while ($data = fread($this->fp, 2048)) {
+            $err = $this->parseString($data, $feof($this->fp));
+            if (PEAR::isError($err)) {
+                return $err;
+            }
+        }
+        $this->data = $data;
+        return $true;
+    }
+        
+
+       /**
+       * Renders the XML document.
+       *
+       * This function really isnt implemented yet. 
+       * Basically, I just added the calls for the HTML
+       * and PDF subclass rendering modes. I'm hoping this
+       * class will be easily built onto over PEAR's lifetime.
+       *
+       * @param $mode Rendering mode. Defaults to HTML.
+       * @author Sean Grimes <[EMAIL PROTECTED]>
+       */
+ 
+       function render($mode = 'HTML') {
+               if($mode == 'HTML') {
+                       $html = new XML_Render_HTML();
+                       $html->render();
+               }
+               if($mode == 'PDF') {
+                       $pdf = new XML_Render_PDF();
+                       $pdf->render();
+               } else {
+                       $message = "Error. Unsupported rendering mode.";
+                       new PEAR_Error($message, 0, PEAR_ERROR_RETURN, E_USER_NOTIFY);
+               }
+       }
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to