mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Added wrapper around {NEWSIMAGE} and added support for wrappers for shortcodes with specific parms.
This commit is contained in:
@@ -2182,17 +2182,30 @@ class e107
|
||||
list($templateId, $templateKey) = explode('/', $templateId, 2);
|
||||
|
||||
$wrapperRegPath = 'templates/wrapper/'.$templateId;
|
||||
|
||||
$wrapper = self::getRegistry($wrapperRegPath);
|
||||
|
||||
if(empty($wrapper) || !is_array($wrapper)) $wrapper = array();
|
||||
|
||||
if($templateKey) $wrapper = (isset($wrapper[$templateKey]) ? $wrapper[$templateKey] : 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(null !== $scName)
|
||||
{
|
||||
$scName = strtoupper($scName);
|
||||
return isset($wrapper[$scName]) ? $wrapper[$scName] : '';
|
||||
}
|
||||
|
||||
|
||||
return $wrapper;
|
||||
}
|
||||
|
||||
|
@@ -374,9 +374,10 @@ class news {
|
||||
|
||||
// Retrieve batch sc object, set required vars
|
||||
$sc = e107::getScBatch('news')
|
||||
->wrapper('news/view/item')
|
||||
->setScVar('news_item', $news)
|
||||
->setScVar('param', $param);
|
||||
|
||||
|
||||
$text = e107::getParser()->parseTemplate($NEWS_PARSE, true, $sc);
|
||||
|
||||
if ($mode == 'return')
|
||||
|
@@ -756,11 +756,14 @@ class e_parse_shortcode
|
||||
// Do it only once per parsing cylcle and not on every doCode() loop - performance
|
||||
if(method_exists($this->addedCodes, 'wrapper'))
|
||||
{
|
||||
// $cname = get_class($this->addedCodes);
|
||||
|
||||
$tmpWrap = e107::templateWrapper($this->addedCodes->wrapper());
|
||||
if(!empty($tmpWrap)) // FIX for #3 above.
|
||||
{
|
||||
$this->wrappers = array_merge($this->wrappers,$tmpWrap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -782,7 +785,8 @@ class e_parse_shortcode
|
||||
}
|
||||
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)
|
||||
{
|
||||
@@ -792,6 +796,8 @@ class e_parse_shortcode
|
||||
|
||||
// print_a($this);
|
||||
}
|
||||
|
||||
|
||||
$ret = preg_replace_callback('#\{(\S[^\x02]*?\S)\}#', array(&$this, 'doCode'), $text);
|
||||
$this->parseSCFiles = $saveParseSCFiles; // Restore previous value
|
||||
$this->addedCodes = $saveCodes;
|
||||
@@ -822,6 +828,7 @@ class e_parse_shortcode
|
||||
global $pref, $e107cache, $menu_pref, $parm, $sql;
|
||||
|
||||
$parmArray = false;
|
||||
$fullShortcodeKey = null;
|
||||
|
||||
if ($this->eVars)
|
||||
{
|
||||
@@ -837,6 +844,7 @@ class e_parse_shortcode
|
||||
|
||||
if(preg_match('/^([A-Z_]*):(.*)/', $matches[1], $newMatch))
|
||||
{
|
||||
$fullShortcodeKey = $newMatch[0];
|
||||
$code = $newMatch[1];
|
||||
$parmStr = trim($newMatch[2]);
|
||||
$debugParm = $parmStr;
|
||||
@@ -966,7 +974,7 @@ class e_parse_shortcode
|
||||
// via e107::getScBatch(name)->setParserVars($eVars);
|
||||
// $this->callScFunc($_class, 'setParserVars', $this->eVars);
|
||||
$wrapper = $this->callScFunc($_class, 'wrapper', null);
|
||||
|
||||
|
||||
$ret = $this->callScFuncA($_class, $_method, array($parm, $sc_mode));
|
||||
|
||||
/*if (method_exists($this->scClasses[$_class], $_method))
|
||||
@@ -1079,13 +1087,21 @@ class e_parse_shortcode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isset($ret) && ($ret != '' || is_numeric($ret)))
|
||||
{
|
||||
// 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);
|
||||
$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
|
||||
{
|
||||
@@ -1147,12 +1163,24 @@ class e_parse_shortcode
|
||||
{
|
||||
$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);
|
||||
|
||||
$tmp = isset($debugParm) ? $debugParm : $parm;
|
||||
|
||||
$db_debug->logCode(2, $code, $tmp, $info);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1278,7 +1306,7 @@ class e_shortcode
|
||||
|
||||
if(false === $id) $id = null;
|
||||
$this->wrapper = $id;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@@ -83,7 +83,7 @@ $NEWS_TEMPLATE['default']['item'] = '
|
||||
$NEWS_TEMPLATE['default']['item'] = '
|
||||
{SETIMAGE: w=900&h=300}
|
||||
<h2>{NEWSTITLELINK}</h2>
|
||||
<p class="lead">by {NEWSAUTHOR}</p>
|
||||
<p class="lead">{GLYPH=user} {NEWSAUTHOR}</p>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<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
|
||||
|
||||
|
||||
$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'] = '
|
||||
{SETIMAGE: w=900&h=600}
|
||||
<div class="view-item">
|
||||
@@ -126,7 +129,7 @@ $NEWS_TEMPLATE['view']['item'] = '
|
||||
|
||||
|
||||
<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}
|
||||
<div class="news-videos-1">
|
||||
{NEWSVIDEO: item=1}
|
||||
@@ -138,7 +141,7 @@ $NEWS_TEMPLATE['view']['item'] = '
|
||||
<br />
|
||||
{SETIMAGE: w=400&h=400}
|
||||
|
||||
<div class="row news-images-1">
|
||||
<div class="row news-images-1">
|
||||
<div class="col-md-6">{NEWSIMAGE: item=2}</div>
|
||||
<div class="col-md-6">{NEWSIMAGE: item=3}</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user