28
28
* @version Release: @package_version@
29
29
* @link http://pear.php.net/package/Text_Wiki
30
30
*/
31
- class Text_Wiki {
31
+ class Text_Wiki
32
+ {
32
33
33
34
/**
34
35
*
@@ -41,7 +42,7 @@ class Text_Wiki {
41
42
*/
42
43
43
44
public $ rules = array (
44
- 'Include ' ,
45
+ 'Include ' ,
45
46
'Prefilter ' ,
46
47
'Delimiter ' ,
47
48
// 'Moduledelimiter',
@@ -53,11 +54,11 @@ class Text_Wiki {
53
54
'Module ' ,
54
55
'Module654 ' ,
55
56
56
- 'Iftags ' ,
57
+ 'Iftags ' ,
57
58
58
59
'Comment ' ,
59
60
'Iframe ' ,
60
- 'Date ' ,
61
+ 'Date ' ,
61
62
'Math ' ,
62
63
63
64
'Concatlines ' ,
@@ -335,17 +336,17 @@ class Text_Wiki {
335
336
'render ' => array ()
336
337
);
337
338
338
- /**
339
- * Storage for temporary variables.
340
- */
341
- public $ store = array ();
339
+ /**
340
+ * Storage for temporary variables.
341
+ */
342
+ public $ store = array ();
342
343
343
- public $ vars = array ();
344
+ public $ vars = array ();
344
345
345
- /**
346
- * Stores format while processing the source.
347
- */
348
- public $ currentFormat ;
346
+ /**
347
+ * Stores format while processing the source.
348
+ */
349
+ public $ currentFormat ;
349
350
350
351
/**
351
352
*
@@ -384,7 +385,6 @@ function Text_Wiki($rules = null)
384
385
'render ' ,
385
386
$ this ->fixPath (dirname (__FILE__ )) . 'Wiki/Render/ '
386
387
);
387
-
388
388
}
389
389
390
390
/**
@@ -545,7 +545,6 @@ function getRenderConf($format, $rule, $key = null)
545
545
// no
546
546
return null ;
547
547
}
548
-
549
548
}
550
549
551
550
/**
@@ -685,7 +684,6 @@ function insertRule($name, $tgt = null)
685
684
}
686
685
687
686
return true ;
688
-
689
687
}
690
688
691
689
/**
@@ -806,7 +804,7 @@ function disableRule($name)
806
804
807
805
function transform ($ text , $ format = 'Xhtml ' )
808
806
{
809
- $ this ->currentFormat = $ format ;
807
+ $ this ->currentFormat = $ format ;
810
808
$ this ->parse ($ text );
811
809
$ out = $ this ->render ($ format );
812
810
$ this ->currentFormat = null ;
@@ -840,7 +838,6 @@ function parse($text)
840
838
foreach ($ this ->rules as $ name ) {
841
839
// do not parse the rules listed in $disable
842
840
if (! in_array ($ name , $ this ->disable )) {
843
-
844
841
// load the parsing object
845
842
$ this ->loadParseObj ($ name );
846
843
@@ -850,7 +847,6 @@ function parse($text)
850
847
$ this ->parseObj [$ name ]->parse ();
851
848
}
852
849
}
853
-
854
850
}
855
851
}
856
852
@@ -886,7 +882,7 @@ function render($format = 'Xhtml')
886
882
// load the format object, or crap out if we can't find it
887
883
$ result = $ this ->loadFormatObj ($ format );
888
884
if ($ this ->isError ($ result )) {
889
- return $ result ;
885
+ return $ result ;
890
886
}
891
887
892
888
// pre-rendering activity
@@ -902,33 +898,25 @@ function render($format = 'Xhtml')
902
898
// pass through the parsed source text character by character
903
899
$ k = strlen ($ this ->source );
904
900
for ($ i = 0 ; $ i < $ k ; $ i ++) {
905
-
906
901
// the current character
907
902
$ char = $ this ->source [$ i ];
908
903
909
904
// are alredy in a delimited section?
910
905
if ($ in_delim ) {
911
-
912
906
// yes; are we ending the section?
913
907
if ($ char == $ this ->delim ) {
914
-
915
908
// yes, get the replacement text for the delimited
916
909
// token number and unset the flag.
917
910
$ key = (int )$ key ;
918
911
$ rule = $ this ->tokens [$ key ][0 ];
919
912
$ opts = $ this ->tokens [$ key ][1 ];
920
913
$ output .= $ this ->renderObj [$ rule ]->token ($ opts );
921
914
$ in_delim = false ;
922
-
923
915
} else {
924
-
925
916
// no, add to the dlimited token key number
926
917
$ key .= $ char ;
927
-
928
918
}
929
-
930
919
} else {
931
-
932
920
// not currently in a delimited section.
933
921
// are we starting into a delimited section?
934
922
if ($ char == $ this ->delim ) {
@@ -948,18 +936,19 @@ function render($format = 'Xhtml')
948
936
$ output .= $ this ->formatObj [$ format ]->post ();
949
937
}
950
938
951
- // this is a nasty hack... should be put somewhere else, e.g. Postfilter?
939
+ // this is a nasty hack... should be put somewhere else, e.g. Postfilter?
952
940
953
- // fix TOC tags within entries
954
- $ d = utf8_encode ("\xFC" );
955
- $ output = preg_replace_callback ("/ $ d$ d(.*?) $ d$ d/s " , array ($ this , 'strip ' ), $ output );
941
+ // fix TOC tags within entries
942
+ $ d = utf8_encode ("\xFC" );
943
+ $ output = preg_replace_callback ("/ $ d$ d(.*?) $ d$ d/s " , array ($ this , 'strip ' ), $ output );
956
944
957
945
// return the rendered source text.
958
946
return $ output ;
959
947
}
960
948
961
- public function strip ($ matches ){
962
- return strip_tags ($ matches [1 ]);
949
+ public function strip ($ matches )
950
+ {
951
+ return strip_tags ($ matches [1 ]);
963
952
}
964
953
965
954
/**
@@ -1107,20 +1096,19 @@ function loadParseObj($rule)
1107
1096
1108
1097
$ loc = $ this ->findFile ('parse ' , $ file );
1109
1098
1110
- if ($ loc ) {
1111
- // found the class
1112
- include_once $ loc ;
1113
- } else {
1114
- // can't find the class
1115
- $ this ->parseObj [$ rule ] = null ;
1116
- // can't find the class
1117
- return $ this ->error (
1118
- "Parse rule ' $ rule' not found "
1119
- );
1120
- }
1099
+ if ($ loc ) {
1100
+ // found the class
1101
+ include_once $ loc ;
1102
+ } else {
1103
+ // can't find the class
1104
+ $ this ->parseObj [$ rule ] = null ;
1105
+ // can't find the class
1106
+ return $ this ->error (
1107
+ "Parse rule ' $ rule' not found "
1108
+ );
1109
+ }
1121
1110
1122
1111
$ this ->parseObj [$ rule ] = new $ class ($ this );
1123
-
1124
1112
}
1125
1113
1126
1114
/**
@@ -1142,15 +1130,15 @@ function loadRenderObj($format, $rule)
1142
1130
1143
1131
// load the class
1144
1132
$ loc = $ this ->findFile ('render ' , $ file );
1145
- if ($ loc ) {
1146
- // found the class
1147
- include_once $ loc ;
1148
- } else {
1149
- // can't find the class
1150
- return $ this ->error (
1151
- "Render rule ' $ rule' in format ' $ format' not found "
1152
- );
1153
- }
1133
+ if ($ loc ) {
1134
+ // found the class
1135
+ include_once $ loc ;
1136
+ } else {
1137
+ // can't find the class
1138
+ return $ this ->error (
1139
+ "Render rule ' $ rule' in format ' $ format' not found "
1140
+ );
1141
+ }
1154
1142
1155
1143
$ this ->renderObj [$ rule ] = new $ class ($ this );
1156
1144
}
@@ -1172,15 +1160,15 @@ function loadFormatObj($format)
1172
1160
$ class = "Text_Wiki_Render_ $ format " ;
1173
1161
1174
1162
$ loc = $ this ->findFile ('render ' , $ file );
1175
- if ($ loc ) {
1176
- // found the class
1177
- include_once $ loc ;
1178
- } else {
1179
- // can't find the class
1180
- return $ this ->error (
1181
- "Rendering format class ' $ class' not found "
1182
- );
1183
- }
1163
+ if ($ loc ) {
1164
+ // found the class
1165
+ include_once $ loc ;
1166
+ } else {
1167
+ // can't find the class
1168
+ return $ this ->error (
1169
+ "Rendering format class ' $ class' not found "
1170
+ );
1171
+ }
1184
1172
1185
1173
$ this ->formatObj [$ format ] = new $ class ($ this );
1186
1174
}
@@ -1281,7 +1269,7 @@ function fixPath($path)
1281
1269
$ len = strlen ($ this ->_dirSep );
1282
1270
1283
1271
if (! empty ($ path ) &&
1284
- substr ($ path , -1 * $ len , $ len ) != $ this ->_dirSep ) {
1272
+ substr ($ path , -1 * $ len , $ len ) != $ this ->_dirSep ) {
1285
1273
return $ path . $ this ->_dirSep ;
1286
1274
} else {
1287
1275
return $ path ;
@@ -1302,12 +1290,12 @@ function fixPath($path)
1302
1290
1303
1291
function &error ($ message )
1304
1292
{
1305
- throw new ProcessException ($ message );
1306
- // FIX?
1307
- if (! class_exists ('PEAR_Error ' )) {
1308
- include_once 'PEAR.php ' ;
1309
- }
1310
- return PEAR ::throwError ($ message );
1293
+ throw new ProcessException ($ message );
1294
+ // FIX?
1295
+ if (! class_exists ('PEAR_Error ' )) {
1296
+ include_once 'PEAR.php ' ;
1297
+ }
1298
+ return PEAR ::throwError ($ message );
1311
1299
}
1312
1300
1313
1301
/**
@@ -1324,6 +1312,6 @@ function &error($message)
1324
1312
1325
1313
function isError (&$ obj )
1326
1314
{
1327
- return is_a ($ obj , 'PEAR_Error ' );
1315
+ return is_a ($ obj , 'PEAR_Error ' );
1328
1316
}
1329
1317
}
0 commit comments