mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 06:07:32 +02:00
Scan overrides looking at the proper location for override batch/shortcode; shortcode handler now respects override settings; admin shortcodes are not auto loaded anymore
This commit is contained in:
@@ -819,24 +819,46 @@ class system_tools
|
|||||||
|
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$f = e107::getFile();
|
$f = e107::getFile();
|
||||||
|
$config = e107::getConfig();
|
||||||
|
|
||||||
$scList = '';
|
$scList = '';
|
||||||
|
|
||||||
$fList = $f->get_files(e_CORE.'override/shortcodes', '\.sc$');
|
$fList = $f->get_files(e_CORE.'override/shortcodes/single', '\.php$');
|
||||||
if(count($fList))
|
if(count($fList))
|
||||||
{
|
{
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
foreach($fList as $file)
|
foreach($fList as $file)
|
||||||
{
|
{
|
||||||
$tmp[] = strtoupper(substr($file['fname'], 0, -3));
|
$tmp[] = strtoupper(substr($file['fname'], 0, -4));
|
||||||
}
|
}
|
||||||
$scList = implode(',', $tmp);
|
$scList = implode(',', $tmp);
|
||||||
unset($tmp);
|
unset($tmp);
|
||||||
}
|
}
|
||||||
$pref['sc_override'] = $scList;
|
$config->set('sc_override', $scList)->save(false);
|
||||||
save_prefs();
|
|
||||||
|
|
||||||
|
$fList = $f->get_files(e_CORE.'override/shortcodes/batch', '\.php$');
|
||||||
|
if(count($fList))
|
||||||
|
{
|
||||||
|
$tmp = array();
|
||||||
|
foreach($fList as $file)
|
||||||
|
{
|
||||||
|
$tmp[] = substr($file['fname'], 0, -4);
|
||||||
|
}
|
||||||
|
$scList = implode(',', $tmp);
|
||||||
|
unset($tmp);
|
||||||
|
}
|
||||||
|
$config->set('sc_batch_override', $scList)->save(false);
|
||||||
|
//$pref['sc_override'] = $scList;
|
||||||
|
//save_prefs();
|
||||||
// $mes->add(DBLAN_57.':<br />'.$pref['sc_override'], E_MESSAGE_SUCCESS);
|
// $mes->add(DBLAN_57.':<br />'.$pref['sc_override'], E_MESSAGE_SUCCESS);
|
||||||
e107::getRender()->tablerender(DBLAN_56, DBLAN_57.':<br />'.$pref['sc_override']);
|
// FIXME lan
|
||||||
|
e107::getRender()->tablerender(
|
||||||
|
DBLAN_56, DBLAN_57.': '
|
||||||
|
.($config->get('sc_override') ? '<br />'.$config->get('sc_override') : '(empty)')
|
||||||
|
.'<br />Batch shortcodes: '
|
||||||
|
.($config->get('sc_batch_override') ? '<br />'.$config->get('sc_batch_override') : '(empty)')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -67,7 +67,8 @@ class e_parse_shortcode
|
|||||||
protected $addedCodes = NULL; // Pointer to a class or array to be used on a single call
|
protected $addedCodes = NULL; // Pointer to a class or array to be used on a single call
|
||||||
protected $registered_codes = array(); // Shortcodes added by plugins TODO make it private
|
protected $registered_codes = array(); // Shortcodes added by plugins TODO make it private
|
||||||
protected $scClasses = array(); // Batch shortcode classes - TODO make it private
|
protected $scClasses = array(); // Batch shortcode classes - TODO make it private
|
||||||
protected $scOverride = array(); // Array of codes found in override/ dir
|
protected $scOverride = array(); // Array of codes found in override/shortcodes dir
|
||||||
|
protected $scBatchOverride = array(); // Array of codes found in override/shortcodes/batch dir
|
||||||
/**
|
/**
|
||||||
* @var e_vars
|
* @var e_vars
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +82,7 @@ class e_parse_shortcode
|
|||||||
$this->loadThemeShortcodes();
|
$this->loadThemeShortcodes();
|
||||||
$this->loadPluginShortcodes();
|
$this->loadPluginShortcodes();
|
||||||
$this->loadPluginSCFiles();
|
$this->loadPluginSCFiles();
|
||||||
$this->loadCoreShortcodes();
|
//$this->loadCoreShortcodes(); DEPRECATED
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,11 +264,18 @@ class e_parse_shortcode
|
|||||||
{
|
{
|
||||||
if(trim($className)==""){ return; }
|
if(trim($className)==""){ return; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$_class_fname = $className;
|
$_class_fname = $className;
|
||||||
|
|
||||||
// plugin override
|
$globalOverride = false;
|
||||||
|
if(null === $overrideClass && in_array($className, $this->scBatchOverride))
|
||||||
|
{
|
||||||
|
$className = 'override_'.$className;
|
||||||
|
$globalOverride = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// forced override
|
||||||
if($overrideClass)
|
if($overrideClass)
|
||||||
{
|
{
|
||||||
if(true === $overrideClass)
|
if(true === $overrideClass)
|
||||||
@@ -300,13 +308,15 @@ class e_parse_shortcode
|
|||||||
return $this->scClasses[$className];
|
return $this->scClasses[$className];
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = ($pluginName ? e_PLUGIN.$pluginName.'/shortcodes/batch/' : e_CORE.'shortcodes/batch/').$_class_fname.'.php';
|
if(!$pluginName)
|
||||||
|
|
||||||
$pathBC = e_PLUGIN.$pluginName.'/'.$_class_fname.'.php';
|
|
||||||
|
|
||||||
if(is_readable($pathBC)) // BC - required.
|
|
||||||
{
|
{
|
||||||
$path = $pathBC;
|
$path = ($globalOverride ? e_CORE.'override/shortcodes/batch/' : e_CORE.'shortcodes/batch/').$_class_fname.'.php';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// BC - required.
|
||||||
|
$pathBC = e_PLUGIN.$pluginName.'/';
|
||||||
|
$path = (is_readable($pathBC.$_class_fname.'.php') ? $pathBC : e_PLUGIN.$pluginName.'/shortcodes/batch/').$_class_fname.'.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it already exists - don't include it again.
|
// If it already exists - don't include it again.
|
||||||
@@ -355,9 +365,21 @@ class e_parse_shortcode
|
|||||||
{
|
{
|
||||||
$code = strtoupper(trim($code));
|
$code = strtoupper(trim($code));
|
||||||
$this->registered_codes[$code]['type'] = 'override';
|
$this->registered_codes[$code]['type'] = 'override';
|
||||||
|
$this->registered_codes[$code]['path'] = e_CORE.'override/shortcodes/single/';
|
||||||
|
$this->registered_codes[$code]['function'] = 'override_'.strtolower($code).'_shortcode';
|
||||||
$this->scOverride[] = $code;
|
$this->scOverride[] = $code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e107::getPref('sc_batch_override'))
|
||||||
|
{
|
||||||
|
$tmp = explode(',', e107::getPref('sc_batch_override'));
|
||||||
|
foreach ($tmp as $code)
|
||||||
|
{
|
||||||
|
//$code = strtoupper(trim($code));
|
||||||
|
//$this->registered_codes[$code]['type'] = 'override';
|
||||||
|
$this->scBatchOverride[] = $code;
|
||||||
|
}
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,25 +506,26 @@ class e_parse_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* DEPRECATED admin_shortcodes now loaded inside admin parse function (see boot.php)
|
||||||
* Register Core Shortcode Batches.
|
* Register Core Shortcode Batches.
|
||||||
* FIXME - make it smarter - currently loaded all the time (even on front-end)
|
* FIXME - make it smarter - currently loaded all the time (even on front-end)
|
||||||
*
|
*
|
||||||
* @return e_parse_shortcode
|
* @return e_parse_shortcode
|
||||||
*/
|
*/
|
||||||
function loadCoreShortcodes()
|
// function loadCoreShortcodes()
|
||||||
{
|
// {
|
||||||
$coreBatchList = array('admin_shortcodes');
|
// $coreBatchList = array('admin_shortcodes');
|
||||||
|
//
|
||||||
foreach ($coreBatchList as $cb)
|
// foreach ($coreBatchList as $cb)
|
||||||
{
|
// {
|
||||||
$path = e_CORE.'shortcodes/batch/'.$cb.".php";
|
// $path = e_CORE.'shortcodes/batch/'.$cb.".php";
|
||||||
if (include_once($path))
|
// if (include_once($path))
|
||||||
{
|
// {
|
||||||
$this->registerClassMethods($cb, $path);
|
// $this->registerClassMethods($cb, $path);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return $this;
|
// return $this;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function isRegistered($code)
|
function isRegistered($code)
|
||||||
{
|
{
|
||||||
@@ -728,10 +751,11 @@ class e_parse_shortcode
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'override':
|
||||||
case 'func':
|
case 'func':
|
||||||
//It is a function, so include the file and call the function
|
//It is a function, so include the file and call the function
|
||||||
$_function = $this->registered_codes[$code]['function'];
|
$_function = $this->registered_codes[$code]['function'];
|
||||||
if ($this->registered_codes[$code]['path'])
|
if (!function_exists($_function) && $this->registered_codes[$code]['path'])
|
||||||
{
|
{
|
||||||
include_once($this->registered_codes[$code]['path'].strtolower($code).'.php');
|
include_once($this->registered_codes[$code]['path'].strtolower($code).'.php');
|
||||||
|
|
||||||
@@ -746,9 +770,9 @@ class e_parse_shortcode
|
|||||||
$scFile = e_PLUGIN.strtolower($this->registered_codes[$code]['path']).'/'.strtolower($code).'.sc';
|
$scFile = e_PLUGIN.strtolower($this->registered_codes[$code]['path']).'/'.strtolower($code).'.sc';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'override':
|
// case 'override':
|
||||||
$scFile = e_CORE.'override/shortcodes/'.strtolower($code).'.sc';
|
// $scFile = e_CORE.'override/shortcodes/'.strtolower($code).'.sc';
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case 'theme':
|
case 'theme':
|
||||||
$scFile = THEME.strtolower($code).'.sc';
|
$scFile = THEME.strtolower($code).'.sc';
|
||||||
|
Reference in New Issue
Block a user