Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e71880b
Showing
7 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
F U N C T I O N | ||
|
||
function Plugin for DokuWiki | ||
|
||
All documentation for this plugin can be found at http://www.dokuwiki.org/plugin:function | ||
|
||
If you install this plugin manually, make sure it is installed in lib/plugins/function/ - if the folder is called different it will not work! | ||
|
||
Please refer to http://www.dokuwiki.org/plugins for additional info on how to install plugins in DokuWiki. | ||
|
||
Copyright (C) Tom Cafferty tcafferty@glocalfocal.com | ||
|
||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License | ||
|
||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
|
||
See the COPYING file in your DokuWiki folder for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
/** | ||
* Default settings for the function plugin | ||
* | ||
* @author Tom Cafferty <tcafferty@glocalfocal.com> | ||
*/ | ||
|
||
$conf['file1'] = 'helloWorld.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/** | ||
* Options for the function plugin | ||
* | ||
* @author Tom Cafferty <tcafferty@glocalfocal.com> | ||
*/ | ||
|
||
$meta['file1'] = array('string'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
function run () { | ||
// Create output data | ||
$dataout='<p class="cellGreen">Hello World!</p>'; | ||
// echo $dataout; | ||
return $dataout; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
$lang['file1'] = 'A green Hello World function'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
html { | ||
height: 100%; | ||
} | ||
body { | ||
color: #000; | ||
font-family: Arial, Helvetica, sans-serif; | ||
height: 100%; | ||
} | ||
div#outerContainer { | ||
min-height: 100%; | ||
} | ||
/**************************************/ | ||
/* cell colors */ | ||
/**************************************/ | ||
.cellGreen { | ||
background-color: green; | ||
font-weight: bold; | ||
color: white; | ||
} | ||
.cellLightGreen { | ||
background-color: #90EE90; | ||
font-weight: bold; | ||
} | ||
.cellLightSalmon { | ||
background-color: #FFA07A; | ||
font-weight: bold; | ||
} | ||
.cellDarkOrange { | ||
background-color: #FF8C00; | ||
font-weight: bold; | ||
} | ||
.cellRed { | ||
background-color: red; | ||
font-weight: bold; | ||
color: white; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
/** | ||
* PHP Includes via Syntax | ||
* | ||
* Put your php files in /functions folder and add the path and function | ||
* identifier to the /conf/default.php filr | ||
* | ||
* <function=functionId> | ||
* | ||
* The syntax includes the PHP file per include an puts the result into | ||
* the wiki page. | ||
* | ||
* @license GNU_GPL_v2 | ||
* @author Markus Frosch <markus [at] lazyfrosch [dot] de> | ||
* @author Tom Cafferty <tcafferty [at] glocalfocal [dot] com> | ||
*/ | ||
|
||
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); | ||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); | ||
require_once(DOKU_PLUGIN.'syntax.php'); | ||
|
||
|
||
class syntax_plugin_function extends DokuWiki_Syntax_Plugin { | ||
|
||
function getInfo(){ | ||
return array( | ||
'author' => 'Tom Cafferty', | ||
'email' => 'tcafferty@glocalfocal.com', | ||
'date' => '2012-10-05', | ||
'name' => 'Function', | ||
'desc' => 'Allows you to run a PHP function on Server', | ||
'url' => 'http://www.dokuwiki.org/plugin:function', | ||
); | ||
} | ||
|
||
function getType(){ return 'substition'; } | ||
function getPType(){ return 'normal'; } | ||
function getAllowedTypes() { | ||
return array('substition','protected','disabled'); | ||
} | ||
function getSort(){ return 195; } | ||
|
||
function connectTo($mode) { | ||
$this->Lexer->addSpecialPattern('<function=.*?>',$mode,'plugin_function'); | ||
} | ||
|
||
function handle($match, $state, $pos, &$handler){ | ||
switch ($state) { | ||
case DOKU_LEXER_SPECIAL : | ||
return array($state, $match); | ||
default: | ||
return array($state); | ||
} | ||
} | ||
|
||
function render($mode, &$renderer, $indata) { | ||
global $conf; | ||
if($mode == 'xhtml'){ | ||
list($state, $data) = $indata; | ||
|
||
switch ($state) { | ||
case DOKU_LEXER_SPECIAL : | ||
preg_match("#^<function=(.+)>$#", $data, $matches); | ||
$func = $matches[1]; | ||
if(preg_match("#^[a-z0-9\-_ \./]+$#i", $func)) { | ||
$renderer->info['cache'] = FALSE; | ||
$filename = DOKU_PLUGIN . 'function/functions/' . $this->getConf($func); | ||
include ($filename); | ||
$renderer->doc .= run(); | ||
} | ||
else | ||
$renderer->doc .= $renderer->_xmlEntities($data); | ||
break; | ||
|
||
} | ||
return true; | ||
} | ||
|
||
// unsupported $mode | ||
return false; | ||
} | ||
} | ||
|
||
?> |