root/txp/plugins/TOOLS/trunk/ort_plugintemplate/zem_tpl.php

Revision 259, 2.1 kB (checked in by baby, 4 years ago)

MEJORA: cambio "-rev" por "-r" en el número de versión para que entre el número completo en los 10 caracteres que muestra textpattern

  • Property svn:eol-style set to native
Line 
1<?php
2
3// Either copy classTextile.php to your plugin directory, or uncomment the following
4// line and edit it to give the location where classTextile.php can be found
5#ini_set('include_path', ini_get('include_path') . ':/full/path/to/textile');
6
7if (empty($test)) {
8        exit(compile_plugin());
9}
10
11// -----------------------------------------------------
12
13function extract_section($lines, $section) {
14        $result = "";
15       
16        $start_delim = "# --- BEGIN PLUGIN $section ---";
17        $end_delim = "# --- END PLUGIN $section ---";
18
19        $start = array_search($start_delim, $lines) + 1;
20        $end = array_search($end_delim, $lines);
21
22        $content = array_slice($lines, $start, $end-$start);
23
24        return join("\n", $content);
25
26}
27
28function compile_plugin($file='') {
29        global $plugin;
30
31        if (empty($file))
32                $file = $_SERVER['SCRIPT_FILENAME'];
33
34        if (!isset($plugin['name'])) {
35                $plugin['name'] = basename($file, '.php');
36        }
37
38        # Read the contents of this file, and strip line ends
39        $content = file($file);
40        for ($i=0; $i < count($content); $i++) {
41                $content[$i] = rtrim($content[$i]);
42        }
43
44        $plugin['help'] = trim(extract_section($content, 'HELP'));
45        $plugin['code'] = extract_section($content, 'CODE');
46
47        // textpattern will textile it, and encode html
48        $plugin['help_raw'] = $plugin['help'];
49
50        // This is for bc; and for help that needs to use
51        @include('classTextile.php');
52        if (class_exists('Textile')) {
53                $textile = new Textile();
54                $plugin['help'] = $textile->TextileThis($plugin['help']);
55        }
56
57        $plugin['md5'] = md5( $plugin['code'] );
58
59        $header = <<<EOF
60# {$plugin['name']} v{$plugin['version']}
61# {$plugin['description']}
62# {$plugin['author']}
63# {$plugin['author_uri']}
64
65# ......................................................................
66# This is a plugin for Textpattern - http://textpattern.com/
67# To install: textpattern > admin > plugins
68# Paste the following text into the 'Install plugin' box:
69# ......................................................................
70EOF;
71
72        $body = trim(chunk_split(base64_encode(gzencode(serialize($plugin))), 72));
73
74        // to produce a copy of the plugin for distribution, load this file in a browser.
75        header('Content-type: text/plain');
76
77        return $header."\n\n".$body;
78}
79
80?>
Note: See TracBrowser for help on using the browser.