00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00029 class Block extends Tpl
00030 {
00031 var $block_type;
00032 var $block_title;
00033
00034 function Block($type ='code', $title ='')
00035 {
00036 static $id = 'Block_01';
00037
00038 Tpl::Tpl('Block');
00039 $this->id = $id++;
00040 $this->block_type = $type;
00041 $this->block_title = $title;
00042 }
00043
00044 function to_html($indent, $class)
00045 {
00046 $tag = ($this->block_type=='code' ? 'xmp' : 'pre');
00047 $html = ("\n$indent<$tag $class>"
00048 . Tpl::to_html('', $class)
00049 . "</$tag>\n");
00050 return $html;
00051 }
00052
00053 function line_to_html($line, $indent)
00054 {
00055
00056 $line = regex_replace($line);
00057 return $line;
00058 }
00059
00060 function to_xml($indent)
00061 {
00062 $type = $this->block_type;
00063 switch ($type)
00064 {
00065 case 'code':
00066 $tag = 'programlisting';
00067 break;
00068 case 'scr':
00069 case 'screen':
00070 $tag = 'screen';
00071 break;
00072 case 'll':
00073 $tag = 'literallayout';
00074 break;
00075 case 'fig':
00076 case 'figure':
00077 $tag = 'figure';
00078 break;
00079 case 'xmp':
00080 case 'example':
00081 $tag = 'example';
00082 break;
00083 case 'n':
00084 case 'note':
00085 $tag = 'note';
00086 break;
00087 case 'w':
00088 case 'warning':
00089 $tag = 'warning';
00090 break;
00091 case 'c':
00092 case 'caution':
00093 $tag = 'caution';
00094 break;
00095 case 'imp':
00096 case 'important':
00097 $tag = 'important';
00098 break;
00099 case 'tip':
00100 $tag = 'tip';
00101 break;
00102 }
00103
00104 if ($tag=='programlisting' or $tag=='screen' or $tag=='literallayout')
00105 {
00106 $xml = ("\n$indent<$tag>"
00107 . Tpl::to_xml()
00108 . "</$tag>\n");
00109 }
00110 else if ($tag=='figure' or $tag=='example')
00111 {
00112 $title = $this->block_title;
00113 $xml = ("\n$indent<$tag><title>$title</title>"
00114 . Tpl::to_xml()
00115 . "$indent</$tag>\n");
00116 }
00117 else
00118 {
00119 $title = $this->block_title;
00120 if ($title!='') $title = '<title>'.$title.'</title>';
00121 $xml = "\n$indent<$tag>$title<para>"
00122 . Tpl::to_xml()
00123 . "</para></$tag>\n";
00124 }
00125
00126 return $xml;
00127 }
00128
00129 function line_to_xml($line, $indent)
00130 {
00131 $line = regex_replace($line);
00132 return $line;
00133 }
00134 }
00135 ?>