1<?php 2/** 3 * Block Command Plugin - Perform a command whose output is block-embedded. 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_block extends CommandEmbedding 26{ 27 function getInfo() 28 { 29 return array( 30 'author' => 'Joe Lapp', 31 'email' => '', 32 'date' => '2005-08-21', 33 'name' => 'Block Command', 34 'desc' => 'Perform a command whose output is block-embedded', 35 'url' => 'http://wiki.splitbrain.org/plugin:command', 36 ); 37 } 38 39 function getType() 40 { return 'substition'; } 41 42 function getPType() 43 { return 'block'; } 44 45 function getSort() 46 { return 500; } // until I learn better 47 48 function connectTo($mode) 49 { 50 // Because the lexer doesn't accept subpatterns, we'll match invalid 51 // parameter sets, provided that the parameter characters are each 52 // individually valid. The plugin will however report an error. 53 54 $prefix = '\#'; 55 $suffix = '\x28.*?\x29\#'; 56 57 $this->Lexer->addSpecialPattern( 58 $prefix.COMMANDPLUGIN_LEX_CMD.$suffix, 59 $mode, 'plugin_command_block'); 60 $this->Lexer->addSpecialPattern( 61 $prefix.COMMANDPLUGIN_LEX_CMD_PARAMS.$suffix, 62 $mode, 'plugin_command_block'); 63 } 64 65 function getEmbeddingType() 66 { 67 return 'block'; 68 } 69 70 function parseCommandSyntax($match) 71 { 72 $parenPos = strpos($match, '('); 73 $callString = substr($match, 1, $parenPos - 1); 74 // next line works even if there is no content 75 $content = substr($match, $parenPos + 1, -2); 76 return array($callString, $content); 77 } 78} 79 80?>