mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Allow for core shortcode class names other than default. Provides a work-around to possible conflicts between e_shortcode and {plugin}_shortcodes.php
This commit is contained in:
@@ -1016,12 +1016,19 @@ class e107
|
||||
* Override is possible only if class is not already instantiated by shortcode parser
|
||||
*
|
||||
* <code><?php
|
||||
* // core news shortcodes
|
||||
*
|
||||
* // Core news shortcodes (news_shortcodes.php using class news_shortcodes )
|
||||
* e107::getScObject('news');
|
||||
*
|
||||
* // Core page shortcodes (page_shortcodes.php.php with class cpage_shortcode)
|
||||
* e107::getScObject('page', null,'cpage');
|
||||
*
|
||||
* // object of plugin_myplugin_my_shortcodes class -> myplugin/shortcodes/batch/my_shortcodes.php
|
||||
* e107::getScObject('my', 'myplugin');
|
||||
*
|
||||
* // news override - plugin_myplugin_news_shortcodes extends news_shortcodes -> myplugin/shortcodes/batch/news_shortcodes.php
|
||||
* e107::getScObject('news', 'myplugin', true);
|
||||
*
|
||||
* // news override - plugin_myplugin_mynews_shortcodes extends news_shortcodes -> myplugin/shortcodes/batch/mynews_shortcodes.php
|
||||
* e107::getScObject('news', 'myplugin', 'mynews');
|
||||
* </code>
|
||||
|
@@ -262,6 +262,8 @@ class e_parse_shortcode
|
||||
public function getScObject($className, $pluginName = null, $overrideClass = null)
|
||||
{
|
||||
if(trim($className)==""){ return; }
|
||||
|
||||
|
||||
|
||||
$_class_fname = $className;
|
||||
|
||||
@@ -273,8 +275,16 @@ class e_parse_shortcode
|
||||
$overrideClass = $className;
|
||||
}
|
||||
// e.g. class plugin_myplug_news_shortcodes
|
||||
$_class_fname = $overrideClass;
|
||||
$className = 'plugin_'.$pluginName.'_'.str_replace('/', '_', $overrideClass);
|
||||
|
||||
if($pluginName != null)
|
||||
{
|
||||
$_class_fname = $overrideClass;
|
||||
$className = 'plugin_'.$pluginName.'_'.str_replace('/', '_', $overrideClass);
|
||||
}
|
||||
else
|
||||
{
|
||||
$className = $overrideClass;
|
||||
}
|
||||
}
|
||||
elseif(is_string($pluginName))
|
||||
{
|
||||
@@ -318,12 +328,13 @@ class e_parse_shortcode
|
||||
}
|
||||
elseif(E107_DBG_BBSC || E107_DBG_SC)
|
||||
{
|
||||
echo "Couldn't Find Class '".$className."' in <b>".$path."</b>";
|
||||
echo "<h3>Couldn't Find Class '".$className."' in <b>".$path."</b></h3>";
|
||||
}
|
||||
}
|
||||
elseif(E107_DBG_BBSC || E107_DBG_SC)
|
||||
{
|
||||
echo "Couldn't Load: <b>".$path."</b>";
|
||||
echo "<h3>Couldn't Load: <b>".$path."</b></h3>";
|
||||
|
||||
}
|
||||
|
||||
// TODO - throw exception?
|
||||
|
Reference in New Issue
Block a user