mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Added wrapper around {NEWSIMAGE} and added support for wrappers for shortcodes with specific parms.
This commit is contained in:
@@ -2182,10 +2182,23 @@ class e107
|
|||||||
list($templateId, $templateKey) = explode('/', $templateId, 2);
|
list($templateId, $templateKey) = explode('/', $templateId, 2);
|
||||||
|
|
||||||
$wrapperRegPath = 'templates/wrapper/'.$templateId;
|
$wrapperRegPath = 'templates/wrapper/'.$templateId;
|
||||||
|
|
||||||
$wrapper = self::getRegistry($wrapperRegPath);
|
$wrapper = self::getRegistry($wrapperRegPath);
|
||||||
|
|
||||||
if(empty($wrapper) || !is_array($wrapper)) $wrapper = array();
|
if(empty($wrapper) || !is_array($wrapper)) $wrapper = array();
|
||||||
|
|
||||||
|
if(strpos($templateKey,'/')!==false) // quick fix support for 3 keys eg. news/view/item
|
||||||
|
{
|
||||||
|
list($templateKey,$templateKey2) = explode("/", $templateKey, 2);
|
||||||
|
if($templateKey && $templateKey2)
|
||||||
|
{
|
||||||
|
$wrapper = (isset($wrapper[$templateKey][$templateKey2]) ? $wrapper[$templateKey][$templateKey2] : array());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // support for 2 keys. eg. contact/form
|
||||||
|
{
|
||||||
if($templateKey) $wrapper = (isset($wrapper[$templateKey]) ? $wrapper[$templateKey] : array());
|
if($templateKey) $wrapper = (isset($wrapper[$templateKey]) ? $wrapper[$templateKey] : array());
|
||||||
|
}
|
||||||
|
|
||||||
if(null !== $scName)
|
if(null !== $scName)
|
||||||
{
|
{
|
||||||
|
@@ -374,6 +374,7 @@ class news {
|
|||||||
|
|
||||||
// Retrieve batch sc object, set required vars
|
// Retrieve batch sc object, set required vars
|
||||||
$sc = e107::getScBatch('news')
|
$sc = e107::getScBatch('news')
|
||||||
|
->wrapper('news/view/item')
|
||||||
->setScVar('news_item', $news)
|
->setScVar('news_item', $news)
|
||||||
->setScVar('param', $param);
|
->setScVar('param', $param);
|
||||||
|
|
||||||
|
@@ -756,11 +756,14 @@ class e_parse_shortcode
|
|||||||
// Do it only once per parsing cylcle and not on every doCode() loop - performance
|
// Do it only once per parsing cylcle and not on every doCode() loop - performance
|
||||||
if(method_exists($this->addedCodes, 'wrapper'))
|
if(method_exists($this->addedCodes, 'wrapper'))
|
||||||
{
|
{
|
||||||
|
// $cname = get_class($this->addedCodes);
|
||||||
|
|
||||||
$tmpWrap = e107::templateWrapper($this->addedCodes->wrapper());
|
$tmpWrap = e107::templateWrapper($this->addedCodes->wrapper());
|
||||||
if(!empty($tmpWrap)) // FIX for #3 above.
|
if(!empty($tmpWrap)) // FIX for #3 above.
|
||||||
{
|
{
|
||||||
$this->wrappers = array_merge($this->wrappers,$tmpWrap);
|
$this->wrappers = array_merge($this->wrappers,$tmpWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -783,6 +786,7 @@ class e_parse_shortcode
|
|||||||
elseif (is_array($extraCodes)) // Array value contains the contents of a .sc file which is then parsed. ie. return " whatever ";
|
elseif (is_array($extraCodes)) // Array value contains the contents of a .sc file which is then parsed. ie. return " whatever ";
|
||||||
{
|
{
|
||||||
$this->addedCodes = &$extraCodes;
|
$this->addedCodes = &$extraCodes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
foreach ($extraCodes as $sc => $code)
|
foreach ($extraCodes as $sc => $code)
|
||||||
{
|
{
|
||||||
@@ -792,6 +796,8 @@ class e_parse_shortcode
|
|||||||
|
|
||||||
// print_a($this);
|
// print_a($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$ret = preg_replace_callback('#\{(\S[^\x02]*?\S)\}#', array(&$this, 'doCode'), $text);
|
$ret = preg_replace_callback('#\{(\S[^\x02]*?\S)\}#', array(&$this, 'doCode'), $text);
|
||||||
$this->parseSCFiles = $saveParseSCFiles; // Restore previous value
|
$this->parseSCFiles = $saveParseSCFiles; // Restore previous value
|
||||||
$this->addedCodes = $saveCodes;
|
$this->addedCodes = $saveCodes;
|
||||||
@@ -822,6 +828,7 @@ class e_parse_shortcode
|
|||||||
global $pref, $e107cache, $menu_pref, $parm, $sql;
|
global $pref, $e107cache, $menu_pref, $parm, $sql;
|
||||||
|
|
||||||
$parmArray = false;
|
$parmArray = false;
|
||||||
|
$fullShortcodeKey = null;
|
||||||
|
|
||||||
if ($this->eVars)
|
if ($this->eVars)
|
||||||
{
|
{
|
||||||
@@ -837,6 +844,7 @@ class e_parse_shortcode
|
|||||||
|
|
||||||
if(preg_match('/^([A-Z_]*):(.*)/', $matches[1], $newMatch))
|
if(preg_match('/^([A-Z_]*):(.*)/', $matches[1], $newMatch))
|
||||||
{
|
{
|
||||||
|
$fullShortcodeKey = $newMatch[0];
|
||||||
$code = $newMatch[1];
|
$code = $newMatch[1];
|
||||||
$parmStr = trim($newMatch[2]);
|
$parmStr = trim($newMatch[2]);
|
||||||
$debugParm = $parmStr;
|
$debugParm = $parmStr;
|
||||||
@@ -1079,13 +1087,21 @@ class e_parse_shortcode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isset($ret) && ($ret != '' || is_numeric($ret)))
|
if (isset($ret) && ($ret != '' || is_numeric($ret)))
|
||||||
{
|
{
|
||||||
// Wrapper support - see contact_template.php
|
// Wrapper support - see contact_template.php
|
||||||
if(isset($this->wrappers[$code]) && !empty($this->wrappers[$code]))
|
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);
|
||||||
$ret = $pre.$ret.$post;
|
$ret = $pre.$ret.$post;
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif(!empty($fullShortcodeKey) && !empty($this->wrappers[$fullShortcodeKey]) ) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1']
|
||||||
|
{
|
||||||
|
list($pre, $post) = explode("{---}", $this->wrappers[$fullShortcodeKey], 2);
|
||||||
|
$ret = $pre.$ret.$post;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1148,12 +1164,24 @@ class e_parse_shortcode
|
|||||||
$other = $this->debug_legacy;
|
$other = $this->debug_legacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($this->wrappers[$code]))
|
||||||
|
{
|
||||||
|
$other['wrapper'] = $this->wrappers[$code];
|
||||||
|
}
|
||||||
|
elseif(!empty($this->wrappers[$fullShortcodeKey]) )
|
||||||
|
{
|
||||||
|
$other['wrapper'] = $this->wrappers[$fullShortcodeKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$info = (isset($this->registered_codes[$code])) ? print_a($this->registered_codes[$code],true) : print_a($other,true);
|
$info = (isset($this->registered_codes[$code])) ? print_a($this->registered_codes[$code],true) : print_a($other,true);
|
||||||
|
|
||||||
$tmp = isset($debugParm) ? $debugParm : $parm;
|
$tmp = isset($debugParm) ? $debugParm : $parm;
|
||||||
|
|
||||||
$db_debug->logCode(2, $code, $tmp, $info);
|
$db_debug->logCode(2, $code, $tmp, $info);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ $NEWS_TEMPLATE['default']['item'] = '
|
|||||||
$NEWS_TEMPLATE['default']['item'] = '
|
$NEWS_TEMPLATE['default']['item'] = '
|
||||||
{SETIMAGE: w=900&h=300}
|
{SETIMAGE: w=900&h=300}
|
||||||
<h2>{NEWSTITLELINK}</h2>
|
<h2>{NEWSTITLELINK}</h2>
|
||||||
<p class="lead">by {NEWSAUTHOR}</p>
|
<p class="lead">{GLYPH=user} {NEWSAUTHOR}</p>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">{GLYPH=time} {NEWSDATE=short} </div>
|
<div class="col-md-4">{GLYPH=time} {NEWSDATE=short} </div>
|
||||||
@@ -112,6 +112,9 @@ $NEWS_TEMPLATE['default']['item'] = '
|
|||||||
|
|
||||||
// As displayed by news.php?extend.1
|
// As displayed by news.php?extend.1
|
||||||
|
|
||||||
|
|
||||||
|
$NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1'] = '<span class="news-images-main pull-left col-xs-12 col-sm-6 col-md-6">{---}</span>';
|
||||||
|
|
||||||
$NEWS_TEMPLATE['view']['item'] = '
|
$NEWS_TEMPLATE['view']['item'] = '
|
||||||
{SETIMAGE: w=900&h=600}
|
{SETIMAGE: w=900&h=600}
|
||||||
<div class="view-item">
|
<div class="view-item">
|
||||||
@@ -126,7 +129,7 @@ $NEWS_TEMPLATE['view']['item'] = '
|
|||||||
|
|
||||||
|
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<span class="news-images-main pull-left col-xs-12 col-sm-6 col-md-6"> {NEWSIMAGE: item=1}</span>
|
{NEWSIMAGE: item=1}
|
||||||
{NEWSBODY=body}
|
{NEWSBODY=body}
|
||||||
<div class="news-videos-1">
|
<div class="news-videos-1">
|
||||||
{NEWSVIDEO: item=1}
|
{NEWSVIDEO: item=1}
|
||||||
|
Reference in New Issue
Block a user