diff --git a/e107_admin/db.php b/e107_admin/db.php index fca8d87d6..ebf9a5d55 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -824,39 +824,38 @@ class system_tools $scList = ''; $fList = $f->get_files(e_CORE.'override/shortcodes/single', '\.php$'); + $scList = array(); if(count($fList)) { - $tmp = array(); foreach($fList as $file) { - $tmp[] = strtoupper(substr($file['fname'], 0, -4)); + $scList[] = strtoupper(substr($file['fname'], 0, -4)); } - $scList = implode(',', $tmp); - unset($tmp); + $scList = implode(',', $scList); } $config->set('sc_override', $scList)->save(false); - + // core batch overrides $fList = $f->get_files(e_CORE.'override/shortcodes/batch', '\.php$'); + $scList = array(); if(count($fList)) { - $tmp = array(); foreach($fList as $file) { - $tmp[] = substr($file['fname'], 0, -4); + $scList[] = substr($file['fname'], 0, -4); } - $scList = implode(',', $tmp); - unset($tmp); + $scList = implode(',', $scList); } + $config->set('sc_batch_override', $scList)->save(false); //$pref['sc_override'] = $scList; //save_prefs(); // $mes->add(DBLAN_57.':
'.$pref['sc_override'], E_MESSAGE_SUCCESS); // FIXME lan e107::getRender()->tablerender( - DBLAN_56, DBLAN_57.': ' + ''.DBLAN_56, DBLAN_57.': ' .($config->get('sc_override') ? '
'.$config->get('sc_override') : '(empty)') - .'
Batch shortcodes: ' + .'

Batch shortcodes:' .($config->get('sc_batch_override') ? '
'.$config->get('sc_batch_override') : '(empty)') ); } diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 086845d6f..dd985a080 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -242,7 +242,24 @@ class e_parse_shortcode /** * Get registered SC object * Normally you would use the proxy of this method - e107::getScBatch() - * DRAFT! + * Global File Override ClassName/Path examples: + * 1. Core signup shortcodes + * - Origin ClassName: signup_shortcodes + * - Origin Location: core/shortcodes/batch/signup_shortcodes.php + * - File Override ClassName: override_signup_shortcodes + * - File Override Location: core/override/shortcodes/batch/signup_shortcodes.php + * + * 2. Plugin 'gallery' global shortcode batch (e_shortcode.php) + * - Origin ClassName: gallery_shortcodes + * - Origin Location: plugins/gallery/e_shortcode.php + * - File Override ClassName: override_gallery_shortcodes + * - File Override Location: core/override/shortcodes/batch/gallery_shortcodes.php + * + * 3. Plugin 'forum' regular shortcode batch + * - Origin ClassName: plugin_forum_view_shortcodes + * - Origin Location: plugins/forum/shortcodes/batch/view_shortcodes.php + * - File Override ClassName: override_plugin_forum_view_shortcodes + * - File Override Location: core/override/shortcodes/batch/forum_view_shortcodes.php * * scBatchOverride)) + if($pluginName === TRUE) { - $className = 'override_'.$className; - $globalOverride = true; + $pluginName = str_replace("_shortcodes","",$className); + } + elseif(is_string($pluginName)) + { + $className = 'plugin_'.$pluginName.'_'.str_replace('/', '_', $className); } + $globalOverride = $this->isBatchOverride($className); - // forced override if($overrideClass) { @@ -294,29 +312,42 @@ class e_parse_shortcode $className = $overrideClass; } } - elseif(is_string($pluginName)) - { - $className = 'plugin_'.$pluginName.'_'.str_replace('/', '_', $className); - } - elseif($pluginName === TRUE) - { - $pluginName = str_replace("_shortcodes","",$className); - } - - if ($this->isScClass($className)) // Includes global Shortcode Classes. ie. e_shortcode.php - { - return $this->scClasses[$className]; - } if(!$pluginName) { - $path = ($globalOverride ? e_CORE.'override/shortcodes/batch/' : e_CORE.'shortcodes/batch/').$_class_fname.'.php'; + if(!$globalOverride) + { + $path = e_CORE.'shortcodes/batch/'.$_class_fname.'.php'; + } + else + { + $path = e_CORE.'override/shortcodes/batch/'.$_class_fname.'.php'; + $className = 'override_'.$className; + } } else { - // BC - required. - $pathBC = e_PLUGIN.$pluginName.'/'; - $path = (is_readable($pathBC.$_class_fname.'.php') ? $pathBC : e_PLUGIN.$pluginName.'/shortcodes/batch/').$_class_fname.'.php'; + if(!$globalOverride) + { + // do nothing if it's e_shortcode batch global + if($pluginName.'_shortcodes' !== $className) + { + // BC - required. + $pathBC = e_PLUGIN.$pluginName.'/'; + $path = (is_readable($pathBC.$_class_fname.'.php') ? $pathBC : e_PLUGIN.$pluginName.'/shortcodes/batch/').$_class_fname.'.php'; + } + } + else + { + $path = e_CORE.'override/shortcodes/batch/'.$pluginName.'/'.$_class_fname.'.php'; + $className = 'override_'.$className; + } + } + + // Includes global Shortcode Classes (e_shortcode.php) or already loaded batch + if ($this->isScClass($className)) + { + return $this->scClasses[$className]; } // If it already exists - don't include it again. @@ -456,19 +487,37 @@ class e_parse_shortcode { return $this; } - + foreach ($pref as $key => $val) { - $path = e_PLUGIN.$key.'/e_shortcode.php'; - $classFunc = $key.'_shortcodes'; + $globalOverride = $this->isBatchOverride($key.'_shortcodes'); + if($globalOverride) + { + $path = e_CORE.'override/shortcodes/batch/'.$key.'_shortcodes.php'; + $classFunc = 'override_'.$key.'_shortcodes'; + } + else + { + $path = e_PLUGIN.$key.'/e_shortcode.php'; + $classFunc = $key.'_shortcodes'; + } + if (!include_once($path)) { - continue; + // try to switch back to the batch origin in case it's an override + if($globalOverride) + { + $path = e_PLUGIN.$key.'/e_shortcode.php'; + $classFunc = $key.'_shortcodes'; + if (!include_once($path)) + { + continue; + } + } + else continue; } - - $this->registerClassMethods($classFunc, $path, false); - + $this->registerClassMethods($classFunc, $path, false); } return $this; } @@ -555,8 +604,10 @@ class e_parse_shortcode return in_array($code, $this->scOverride); } - - + function isBatchOverride($name) + { + return in_array($name, $this->scBatchOverride); + } /** * Parse the shortcodes in some text