1<?php 2/** 3 * Inline Command Plugin - Perform a command whose output is embedded inline. 4 * 5 * See the plugin's wiki documentation for information on creating commands: 6 * http://wiki.splitbrain.org/plugin:command 7 * 8 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 9 * @author Joe Lapp <http://www.spiderjoe.com> 10 * 11 * Modification history: 12 * 13 * 8/26/05 - Reverted back to 'substition'. JTL 14 */ 15 16if(!defined('DOKU_INC')) 17 define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 18if(!defined('DOKU_PLUGIN')) 19 define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 20if(!defined('COMMANDPLUGIN_PATH')) 21 define('COMMANDPLUGIN_PATH', DOKU_PLUGIN.'command/'); 22require_once(COMMANDPLUGIN_PATH.'inc/embedding.php'); 23require_once(COMMANDPLUGIN_PATH.'inc/extension.php'); 24 25class syntax_plugin_command_inline extends CommandEmbedding 26{ 27 function getInfo() 28 { 29 return array( 30 'author' => 'Joe Lapp', 31 'email' => '', 32 'date' => '2005-08-21', 33 'name' => 'Inline Command', 34 'desc' => 'Perform a command whose output is embedded inline', 35 'url' => 'http://wiki.splitbrain.org/plugin:command', 36 ); 37 } 38 39 function getType() 40 { return 'substition'; } 41 42 function getSort() 43 { return 500; } // until I learn better 44 45 function connectTo($mode) 46 { 47 // Because the lexer doesn't accept subpatterns, we'll match invalid 48 // parameter sets, provided that the parameter characters are each 49 // individually valid. The plugin will however report an error. 50 51 $prefix = '\%'; 52 $suffix = '\x28.*?\x29\%'; 53 54 $this->Lexer->addSpecialPattern( 55 $prefix.COMMANDPLUGIN_LEX_CMD.$suffix, 56 $mode, 'plugin_command_inline'); 57 $this->Lexer->addSpecialPattern( 58 $prefix.COMMANDPLUGIN_LEX_CMD_PARAMS.$suffix, 59 $mode, 'plugin_command_inline'); 60 } 61 62 function getEmbeddingType() 63 { 64 return 'inline'; 65 } 66 67 function parseCommandSyntax($match) 68 { 69 $parenPos = strpos($match, '('); 70 $callString = substr($match, 1, $parenPos - 1); 71 // next line works even if there is no content 72 $content = substr($match, $parenPos + 1, -2); 73 return array($callString, $content); 74 } 75} 76 77?>