mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Closes #1484 - theme shortcodes are now registered globally by default. Shortcode handler cleanup.
This commit is contained in:
@@ -100,6 +100,8 @@ class e_parse_shortcode
|
|||||||
$this->loadPluginSCFiles();
|
$this->loadPluginSCFiles();
|
||||||
//$this->loadCoreShortcodes(); DEPRECATED
|
//$this->loadCoreShortcodes(); DEPRECATED
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -479,25 +481,16 @@ class e_parse_shortcode
|
|||||||
{
|
{
|
||||||
global $register_sc;
|
global $register_sc;
|
||||||
|
|
||||||
// $this->registered_codes[$code]['type'] = 'plugin';
|
|
||||||
// $this->registered_codes[$code]['function'] = strtolower($code).'_shortcode';
|
|
||||||
// $this->registered_codes[$code]['path'] = e_PLUGIN.$path.'/shortcodes/single/';
|
|
||||||
// $this->registered_codes[$code]['perms'] = $uclass;
|
|
||||||
|
|
||||||
|
|
||||||
if(deftrue('e_DEVELOPER')) // experimental, could break something. - use theme shortcodes in other templates.
|
|
||||||
{
|
|
||||||
if(file_exists(THEME."theme_shortcodes.php"))
|
if(file_exists(THEME."theme_shortcodes.php"))
|
||||||
{
|
{
|
||||||
$classFunc = 'theme_shortcodes';
|
$classFunc = 'theme_shortcodes';
|
||||||
$path = THEME."theme_shortcodes.php";
|
$path = THEME."theme_shortcodes.php";
|
||||||
include_once($path);
|
include_once($path);
|
||||||
$this->registerClassMethods($classFunc, $path, false);
|
$this->registerClassMethods($classFunc, $path, false);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($register_sc) && is_array($register_sc))
|
|
||||||
|
if (isset($register_sc) && is_array($register_sc)) // legacy load.
|
||||||
{
|
{
|
||||||
foreach ($register_sc as $code)
|
foreach ($register_sc as $code)
|
||||||
{
|
{
|
||||||
@@ -659,33 +652,15 @@ class e_parse_shortcode
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* DEPRECATED admin_shortcodes now loaded inside admin parse function (see boot.php)
|
|
||||||
* Register Core Shortcode Batches.
|
|
||||||
* FIXME - make it smarter - currently loaded all the time (even on front-end)
|
|
||||||
*
|
|
||||||
* @return e_parse_shortcode
|
|
||||||
*/
|
|
||||||
// function loadCoreShortcodes()
|
|
||||||
// {
|
|
||||||
// $coreBatchList = array('admin_shortcodes');
|
|
||||||
//
|
|
||||||
// foreach ($coreBatchList as $cb)
|
|
||||||
// {
|
|
||||||
// $path = e_CORE.'shortcodes/batch/'.$cb.".php";
|
|
||||||
// if (include_once($path))
|
|
||||||
// {
|
|
||||||
// $this->registerClassMethods($cb, $path);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return $this;
|
|
||||||
// }
|
|
||||||
|
|
||||||
function isRegistered($code)
|
function isRegistered($code)
|
||||||
{
|
{
|
||||||
return array_key_exists($code, $this->registered_codes);
|
return array_key_exists($code, $this->registered_codes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function resetScClass($className, $object)
|
public function resetScClass($className, $object)
|
||||||
{
|
{
|
||||||
if(null === $object)
|
if(null === $object)
|
||||||
@@ -939,6 +914,7 @@ class e_parse_shortcode
|
|||||||
$ret = '';
|
$ret = '';
|
||||||
$_method = 'sc_'.strtolower($code);
|
$_method = 'sc_'.strtolower($code);
|
||||||
|
|
||||||
|
|
||||||
// Display e_shortcode.php override info.
|
// Display e_shortcode.php override info.
|
||||||
if((E107_DBG_BBSC || E107_DBG_SC) && isset($this->addonOverride[$_method]) && is_object($this->addedCodes) && method_exists($this->addedCodes, $_method))
|
if((E107_DBG_BBSC || E107_DBG_SC) && isset($this->addonOverride[$_method]) && is_object($this->addedCodes) && method_exists($this->addedCodes, $_method))
|
||||||
{
|
{
|
||||||
@@ -963,12 +939,13 @@ class e_parse_shortcode
|
|||||||
elseif (is_array($this->addedCodes) && array_key_exists($code, $this->addedCodes)) // Its array-based shortcode. Load the code for evaluation later.
|
elseif (is_array($this->addedCodes) && array_key_exists($code, $this->addedCodes)) // Its array-based shortcode. Load the code for evaluation later.
|
||||||
{
|
{
|
||||||
|
|
||||||
$scCode = $this->addedCodes[$code];
|
$ret = $this->addedCodes[$code];
|
||||||
// $_path = print_a($this->backTrace,true);
|
// $_class = "n/a";
|
||||||
//XXX $_path = print_a($this,true);
|
// $_function = "n/a";
|
||||||
|
$_type = 'array';
|
||||||
|
$_path = "(direct to parser)";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif (array_key_exists($code, $this->scList)) // Check to see if we've already loaded the .sc file contents
|
elseif (array_key_exists($code, $this->scList)) // Check to see if we've already loaded the .sc file contents
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1093,7 +1070,10 @@ class e_parse_shortcode
|
|||||||
$_path = $scFile;
|
$_path = $scFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($scFile && file_exists($scFile))
|
|
||||||
|
if(!empty($scFile))
|
||||||
|
{
|
||||||
|
if(file_exists($scFile))
|
||||||
{
|
{
|
||||||
$scCode = file_get_contents($scFile);
|
$scCode = file_get_contents($scFile);
|
||||||
$this->scList[$code] = $scCode;
|
$this->scList[$code] = $scCode;
|
||||||
@@ -1101,11 +1081,12 @@ class e_parse_shortcode
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// $ret = 'Missing!';
|
$_path .= $scFile." MISSING!";
|
||||||
$_path .= " MISSING!";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($scCode))
|
if (!isset($scCode))
|
||||||
{
|
{
|
||||||
if (E107_DBG_BBSC)
|
if (E107_DBG_BBSC)
|
||||||
@@ -1115,21 +1096,37 @@ class e_parse_shortcode
|
|||||||
return $matches[0];
|
return $matches[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (E107_DBG_SC && $scFile)
|
// if (E107_DBG_SC && $scFile)
|
||||||
{
|
// {
|
||||||
// echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : '';
|
// echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : '';
|
||||||
// echo "<br />sc= <b>$code</b>";
|
// echo "<br />sc= <b>$code</b>";
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scCode)
|
if ($scCode) // legacy shortode to be evaluated.
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
$ret = @eval($scCode);
|
$ret = @eval($scCode);
|
||||||
|
}
|
||||||
|
catch (Throwable $t) { // Executed only in PHP 7, will not match in PHP 5.x
|
||||||
|
|
||||||
|
$string = print_a($scCode,true);
|
||||||
|
$string .= "<h4>Added Coded</h4>";
|
||||||
|
$string .= print_a($this->addedCodes,true);
|
||||||
|
e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
echo $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if($ret === false && E107_DEBUG_LEVEL > 0) // Error in Code.
|
if($ret === false && E107_DEBUG_LEVEL > 0) // Error in Code.
|
||||||
{
|
{
|
||||||
$string = print_a($scCode,true);
|
// $string = print_a($scCode,true);
|
||||||
e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string);
|
// e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1207,19 +1204,26 @@ class e_parse_shortcode
|
|||||||
|
|
||||||
$other = array();
|
$other = array();
|
||||||
|
|
||||||
if($_class)
|
if(!empty($_type))
|
||||||
|
{
|
||||||
|
$other['type'] = $_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($_class))
|
||||||
{
|
{
|
||||||
$other['class'] = $_class;
|
$other['class'] = $_class;
|
||||||
}
|
}
|
||||||
if(vartrue($_function))
|
if(!empty($_function))
|
||||||
{
|
{
|
||||||
$other['function'] = $_function;
|
$other['function'] = $_function;
|
||||||
}
|
}
|
||||||
if(vartrue($_path))
|
if(!empty($_path))
|
||||||
{
|
{
|
||||||
$other['path'] = str_replace('../','',$_path);
|
$other['path'] = str_replace('../','',$_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($this->debug_legacy)
|
if($this->debug_legacy)
|
||||||
{
|
{
|
||||||
$other = $this->debug_legacy;
|
$other = $this->debug_legacy;
|
||||||
|
Reference in New Issue
Block a user