class.Paragraph.php

Go to the documentation of this file.
00001 <?php
00002   /*
00003    This  file is part  of WikiConverter.   WikiConverter is  a program
00004    that  converts   text/wiki  into   other  formats  (like   html  or
00005    xml/docbook).
00006 
00007    Copyright (c) 2005 Dashamir Hoxha, dhoxha@inima.al
00008 
00009    WikiConverter  is free  software;  you can  redistribute it  and/or
00010    modify  it under the  terms of  the GNU  General Public  License as
00011    published by the Free Software  Foundation; either version 2 of the
00012    License, or (at your option) any later version.
00013 
00014    WikiConverter is  distributed in the  hope that it will  be useful,
00015    but  WITHOUT ANY  WARRANTY; without  even the  implied  warranty of
00016    MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
00017    General Public License for more details.
00018 
00019    You should have  received a copy of the  GNU General Public License
00020    along  with  WikiConverter; if  not,  write  to  the Free  Software
00021    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022    USA
00023   */
00024 
00029 class Paragraph extends Tpl
00030 {
00031   function Paragraph()
00032   {
00033     static $id = 'Paragraph_01';
00034                 
00035     Tpl::Tpl('Paragraph');
00036     $this->id = $id++;
00037   }
00038 
00039   function to_html($indent, $class)
00040   {
00041     $html = ("\n$indent<p $class>"
00042              . Tpl::to_html($indent, $class)
00043              . "</p>\n");
00044     return $html;
00045   }
00046 
00047   function to_xml($indent)
00048   {
00049     $pattern1 = '#^(\\s*<comment>\\d+</comment>\\s*)+$#';
00050     $contents = implode("\n", $this->contents);
00051     if (preg_match($pattern1, $contents))
00052       {
00053         //don't enclose in <para> tags
00054         $xml = "\n$indent" . Tpl::to_xml($indent) . "\n";
00055       }
00056     else
00057       {
00058         $xml = ("\n$indent<para>"
00059                 . Tpl::to_xml($indent)
00060                 . "</para>\n");
00061       }
00062 
00063     return $xml;
00064   }
00065 }
00066 ?>

Generated on Wed Jan 9 08:27:32 2008 for DokBookWiki by  doxygen 1.5.2