1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Issue #2029 Allow wrappers to contain core shortcodes.

This commit is contained in:
Cameron
2016-11-15 11:11:19 -08:00
parent d2a0685a67
commit 3089cecf26

View File

@@ -1372,50 +1372,59 @@ class e_parse_shortcode
*/ */
private function makeWrapper($ret, $code, $fullShortcodeKey, $sc_mode) private function makeWrapper($ret, $code, $fullShortcodeKey, $sc_mode)
{ {
$pre = $post = '';
if(isset($this->wrappers[$code]) && !empty($this->wrappers[$code])) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE'] if(isset($this->wrappers[$code]) && !empty($this->wrappers[$code])) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE']
{ {
list($pre, $post) = explode("{---}", $this->wrappers[$code], 2); list($pre, $post) = explode("{---}", $this->wrappers[$code], 2);
return $pre.$ret.$post;
} }
elseif(!empty($fullShortcodeKey) && !empty($this->wrappers[$fullShortcodeKey]) ) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1']
if(!empty($fullShortcodeKey) && !empty($this->wrappers[$fullShortcodeKey]) ) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1']
{ {
list($pre, $post) = explode("{---}", $this->wrappers[$fullShortcodeKey], 2); list($pre, $post) = explode("{---}", $this->wrappers[$fullShortcodeKey], 2);
return $pre.$ret.$post;
} }
else
//if $sc_mode exists, we need it to parse $sc_style
if ($sc_mode)
{ {
$code = $code.'|'.$sc_mode; //if $sc_mode exists, we need it to parse $sc_style
} if($sc_mode)
if (is_array($this->sc_style) && array_key_exists($code, $this->sc_style))
{
$pre = $post = '';
// old way - pre/post keys
if(is_array($this->sc_style[$code]))
{ {
if (isset($this->sc_style[$code]['pre'])) $code = $code.'|'.$sc_mode;
{ }
$pre = $this->sc_style[$code]['pre'];
} if (is_array($this->sc_style) && array_key_exists($code, $this->sc_style))
if (isset($this->sc_style[$code]['post'])) {
{
$post = $this->sc_style[$code]['post']; // old way - pre/post keys
} if(is_array($this->sc_style[$code]))
} {
else // new way - same format as wrapper if (isset($this->sc_style[$code]['pre']))
{ {
list($pre, $post) = explode("{---}", $this->sc_style[$code], 2); $pre = $this->sc_style[$code]['pre'];
}
if (isset($this->sc_style[$code]['post']))
{
$post = $this->sc_style[$code]['post'];
}
}
else // new way - same format as wrapper
{
list($pre, $post) = explode("{---}", $this->sc_style[$code], 2);
}
} }
$ret = $pre.$ret.$post;
} }
if(strpos($pre, '{') !== false) // shortcode found in wrapper
{
$pre = $this->parseCodes($pre, true);
}
return $ret; if(strpos($post, '{') !== false) // shortcode found in wrapper
{
$post = $this->parseCodes($post, true);
}
return $pre.$ret.$post;
} }