OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / wiki_main / include / plugin / stationary.inc.php
1 <?php
2 /**
3  * stationaryプラグイン
4  *
5  * 機能:プラグイン作成用の雛形
6  *
7  * PHP versions 5
8  *
9  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
10  *
11  * @package    Magic3 Framework
12  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
13  * @copyright  Copyright 2006-2008 Magic3 Project.
14  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
15  * @version    SVN: $Id: stationary.inc.php 1128 2008-10-25 10:59:47Z fishbone $
16  * @link       http://www.magic3.org
17  */
18
19 // Define someting like this
20 define('PLUGIN_STATIONARY_MAX', 10);
21
22 // Init someting
23 function plugin_stationary_init()
24 {
25         if (PKWK_SAFE_MODE || PKWK_READONLY) return; // Do nothing
26
27         $messages = array(
28                 '_plugin_stationary_A' => 'a',
29                 '_plugin_stationary_B' => array('C' => 'c', 'D'=>'d'),
30                 );
31         set_plugin_messages($messages);
32 }
33
34 // Convert-type plugin: #stationary or #stationary(foo)
35 function plugin_stationary_convert()
36 {
37         // If you don't want this work at secure/productive site,
38         if (PKWK_SAFE_MODE) return ''; // Show nothing
39
40         // If this plugin will write someting,
41         if (PKWK_READONLY) return ''; // Show nothing
42
43         // Init
44         $args = array();
45         $result = '';
46
47         // Get arguments
48         if (func_num_args()) {
49                 $args = func_get_args();
50                 foreach (array_keys($args) as $key)
51                         $args[$key] = trim($args[$key]);
52                 $result = join(',', $args);
53         }
54
55         return '#stationary(' . htmlspecialchars($result) . ')<br />';
56 }
57
58 // In-line type plugin: &stationary; or &stationary(foo); , or &stationary(foo){bar};
59 function plugin_stationary_inline()
60 {
61         if (PKWK_SAFE_MODE || PKWK_READONLY) return ''; // See above
62
63         // {bar} is always exists, and already sanitized
64         $args = func_get_args();
65         $body = strip_autolink(array_pop($args)); // {bar}
66
67         foreach (array_keys($args) as $key)
68                 $args[$key] = trim($args[$key]);
69         $result = join(',', $args);
70
71         return '&amp;stationary(' . htmlspecialchars($result) . '){' . $body . '};';
72 }
73
74 // Action-type plugin: ?plugin=stationary&foo=bar
75 function plugin_stationary_action()
76 {
77         // See above
78         if (PKWK_SAFE_MODE || PKWK_READONLY)
79                 die_message('PKWK_SAFE_MODE or PKWK_READONLY prohibits this');
80
81         $msg  = 'Message';
82         $body = 'Message body';
83
84         return array('msg'=>htmlspecialchars($msg), 'body'=>htmlspecialchars($body));
85 }
86 ?>