Skip to content

Commit 592e3c8

Browse files
committed
Use proper Textile class and methods if available
Thanks, jsoo and jools-r. Fixes #5.
1 parent 9345a6c commit 592e3c8

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

zem_tpl.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
// -----------------------------------------------------
1717

18-
function extract_section($lines, $section) {
18+
function extract_section($lines, $section)
19+
{
1920
$result = "";
2021

2122
$start_delim = "# --- BEGIN PLUGIN $section ---";
@@ -29,19 +30,22 @@ function extract_section($lines, $section) {
2930
return join("\n", $content);
3031
}
3132

32-
function compile_plugin($file='') {
33+
function compile_plugin($file = '')
34+
{
3335
global $plugin;
3436

35-
if (empty($file))
37+
if (empty($file)) {
3638
$file = $_SERVER['SCRIPT_FILENAME'];
39+
}
3740

3841
if (!isset($plugin['name'])) {
3942
$plugin['name'] = basename($file, '.php');
4043
}
4144

4245
// Read the contents of this file, and strip line ends.
4346
$content = file($file);
44-
for ($i=0; $i < count($content); $i++) {
47+
48+
for ($i = 0; $i < count($content); $i++) {
4549
$content[$i] = rtrim($content[$i]);
4650
}
4751

@@ -52,7 +56,10 @@ function compile_plugin($file='') {
5256
$plugin['help_raw'] = $plugin['help'];
5357

5458
// This is for bc; and for help that needs to use it.
55-
if (defined('txpath')) {
59+
if (class_exists('Textile')) {
60+
$textile = new Textile();
61+
$plugin['help'] = $textile->parse($plugin['help']);
62+
} elseif (defined('txpath')) {
5663
global $trace;
5764

5865
include txpath.'/lib/txplib_misc.php';
@@ -63,15 +70,13 @@ function compile_plugin($file='') {
6370

6471
$loader = new \Textpattern\Loader(txpath.'/vendors');
6572
$loader->register();
73+
$loader = new \Textpattern\Loader(txpath.'/lib');
74+
$loader->register();
6675

67-
require txpath.'/lib/classTextile.php';
68-
} else {
69-
@include('classTextile.php');
70-
}
71-
72-
if (class_exists('Textile')) {
73-
$textile = new Textile();
74-
$plugin['help'] = $textile->TextileThis($plugin['help']);
76+
if (class_exists('\Netcarver\Textile\Parser')) {
77+
$textile = new Netcarver\Textile\Parser();
78+
$plugin['help'] = $textile->parse($plugin['help']);
79+
}
7580
}
7681

7782
$plugin['md5'] = md5( $plugin['code'] );

0 commit comments

Comments
 (0)