mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Beginning of new shortcodes, now able to be functions insead of .sc files or batch sc files. Will be done in new forum code for example usage
This commit is contained in:
@@ -11,9 +11,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/e_parse_class.php,v $
|
||||
| $Revision: 1.13 $
|
||||
| $Date: 2007-06-07 19:19:37 $
|
||||
| $Author: e107steved $
|
||||
| $Revision: 1.14 $
|
||||
| $Date: 2007-06-13 02:53:21 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@@ -117,6 +117,11 @@ class e_parse
|
||||
$this->e_modSet[$key] = TRUE;
|
||||
}
|
||||
|
||||
if (!is_object($this->e_sc))
|
||||
{
|
||||
require_once(e_HANDLER."shortcode_handler.php");
|
||||
$this->e_sc = new e_shortcode;
|
||||
}
|
||||
}
|
||||
|
||||
function toDB($data, $nostrip = false, $no_encode = false, $original_author = false, $mod = false)
|
||||
@@ -195,11 +200,6 @@ class e_parse
|
||||
|
||||
|
||||
function parseTemplate($text, $parseSCFiles = TRUE, $extraCodes = "") {
|
||||
if (!is_object($this->e_sc))
|
||||
{
|
||||
require_once(e_HANDLER."shortcode_handler.php");
|
||||
$this->e_sc = new e_shortcode;
|
||||
}
|
||||
return $this->e_sc->parseCodes($text, $parseSCFiles, $extraCodes);
|
||||
}
|
||||
|
||||
|
@@ -12,16 +12,21 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $
|
||||
| $Revision: 1.6 $
|
||||
| $Date: 2007-03-30 13:33:29 $
|
||||
| $Author: lisa_ $
|
||||
| $Revision: 1.7 $
|
||||
| $Date: 2007-06-13 02:53:21 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
if (!isset($tp) || !is_object($tp -> e_sc)) {
|
||||
$tp->e_sc = new e_shortcode;
|
||||
function register_shortcode($code, $filename, $function, $force=false)
|
||||
{
|
||||
global $e_shortcodes;
|
||||
if(!array_key_exists($code, $e_shortcodes) || $force == true)
|
||||
{
|
||||
$e_shortcodes[$code] = array('file' => $filename, 'function' => $function);
|
||||
}
|
||||
}
|
||||
|
||||
class e_shortcode {
|
||||
@@ -34,16 +39,23 @@ class e_shortcode {
|
||||
{
|
||||
global $pref, $register_sc;
|
||||
|
||||
$this->shortcode_functions = array();
|
||||
if(varset($pref['shortcode_list'],'') != '')
|
||||
{
|
||||
foreach($pref['shortcode_list'] as $path=>$namearray)
|
||||
{
|
||||
foreach($namearray as $code=>$uclass)
|
||||
{
|
||||
if($code == 'shortcode_config')
|
||||
{
|
||||
include_once(e_PLUGIN.$path.'/shortcode_config.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = strtoupper($code);
|
||||
$this->registered_codes[$code]['type'] = 'plugin';
|
||||
$this->registered_codes[$code]['path'] = $path;
|
||||
// $this->registered_codes[$code]['perms'] = $uclass;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +69,7 @@ class e_shortcode {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function parseCodes($text, $useSCFiles = TRUE, $extraCodes = '') {
|
||||
$this->parseSCFiles = $useSCFiles;
|
||||
$ret = '';
|
||||
@@ -78,7 +91,7 @@ class e_shortcode {
|
||||
|
||||
function doCode($matches)
|
||||
{
|
||||
global $pref, $e107cache, $menu_pref, $sc_style, $parm, $sql;
|
||||
global $pref, $e107cache, $menu_pref, $sc_style, $parm, $sql, $e_shortcodes;
|
||||
|
||||
if(strpos($matches[1], E_NL) !== false)
|
||||
{
|
||||
@@ -95,11 +108,14 @@ class e_shortcode {
|
||||
$parm = '';
|
||||
}
|
||||
//look for the $sc_mode
|
||||
if (strpos($code, '|')){
|
||||
if (strpos($code, '|'))
|
||||
{
|
||||
list($code, $sc_mode) = explode("|", $code, 2);
|
||||
$code = trim($code);
|
||||
$sc_mode = trim($sc_mode);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
$sc_mode = '';
|
||||
}
|
||||
$parm = trim($parm);
|
||||
@@ -111,6 +127,18 @@ class e_shortcode {
|
||||
$db_debug->logCode(2, $code, $parm, "");
|
||||
}
|
||||
|
||||
/* Check for shortcode registered with $e_shortcodes */
|
||||
if(array_key_exists($code, $e_shortcodes))
|
||||
{
|
||||
include_once($e_shortcodes[$code]['file']);
|
||||
if(function_exists($e_shortcodes[$code]['function']))
|
||||
{
|
||||
$ret = call_user_func($e_shortcodes[$code]['function'], $parm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (is_array($this->scList) && array_key_exists($code, $this->scList))
|
||||
{
|
||||
$shortcode = $this->scList[$code];
|
||||
@@ -157,6 +185,7 @@ class e_shortcode {
|
||||
trigger_error("starting shortcode {".$code."}", E_USER_ERROR);
|
||||
}
|
||||
$ret = eval($shortcode);
|
||||
}
|
||||
|
||||
if($ret != '' || is_numeric($ret))
|
||||
{
|
||||
|
Reference in New Issue
Block a user