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

Source for file html.php

Documentation is available at html.php

  1. <?php
  2. require_once 'OpenDocument.php'// open document class
  3.  
  4. //open test.odt
  5. $odt OpenDocument::open('test.odt');
  6. //output content as html
  7. echo toHTML($odt"\n";
  8.  
  9. function toHTML($obj)
  10. {
  11.     $html '';
  12.     foreach ($obj->getChildren(as $child{
  13.         switch (get_class($child)) {
  14.         case 'OpenDocument_Element_Text':
  15.             $html .= $child->text;
  16.             break;
  17.         case 'OpenDocument_Element_Paragraph':
  18.             $html .= '<p>';
  19.             $html .= toHTML($child);
  20.             $html .= '</p>';
  21.             break;
  22.         case 'OpenDocument_Element_Span':
  23.             $html .= '<span>';
  24.             $html .= toHTML($child);
  25.             $html .= '</span>';
  26.             break;
  27.         case 'OpenDocument_Element_Heading':
  28.             $html .= '<h' $child->level . '>';
  29.             $html .= toHTML($child);
  30.             $html .= '</h' $child->level . '>';
  31.             break;
  32.         case 'OpenDocument_Element_Hyperlink':
  33.             $html .= '<a href="' $child->location . '" target="' $child->target . '">';
  34.             $html .= toHTML($child);
  35.             $html .= '</a>';
  36.             break;
  37.         default:
  38.             $html .= '<del>unknown element</del>';
  39.         }
  40.     }
  41.     return $html;
  42. }
  43.  
  44. ?>

Documentation generated on Mon, 11 Mar 2019 15:51:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.