Function use in articles ver 1.00
This mod will allow the insertion of functions found in snews.php, directly into your articles when using the editor in admin.
This mod will allow the submission of any parameters that the original function requires
Locate //FILE INCLUSION
place the following just after
$fulltext = substr($text, 0, $shorten);
/*article function*/
$ins = strpos($fulltext, '[/func]');
if ($ins > 0) {
$text = str_replace('[func]', '|&|', $fulltext);
$text = str_replace('[/func]', '|&|', $text);
$text = explode('|&|', $text);$num=count($text)-1;$i=1;
while ($i <= $num) {
$func = explode(':|:',$text[$i]);
ob_start();
$returned = call_user_func_array($func[0],explode(',',$func[1]));
$text[$i]= ob_get_clean();
if (empty($text[$i])){$text[$i]=$returned;}
$i=$i+2;
}
$fulltext = implode($text);
}
/*end article function*/
locate
// basic html textarea editor
and directly after case 'break': start = '[break]'; end = ''; break;
add
case 'func':// adding function insertion
url = prompt("<?php echo l('function'); ?>", '');// function name no brackets
title = prompt("<?php echo l('parameters'); ?>", ""); //params, seperated by comma.
start = url !=null ? '[func]'+url+':|:' : ''; // start
end = '[\/func]';// and end tag
break;
To add the button in the editor,
place the following in //ARTICLES FORM
(possibly just after echo html_input('button', 'include', ...)
echo html_input('button', 'func', '', 'Function', '', 'button', 'onclick="tag(\'func\')"', '', '', '', '', '', '', '', '');
then place the following in language function
$l['function']='Function Name - no brackets.';
$l['parameters']='Parameters - if more than one required, separate with a comma. Do not use quotes for empty parameters.';