mirror of
https://github.com/e107inc/e107.git
synced 2025-03-14 01:19:44 +01:00
Support for multiple images/video in news items. (experimental)
This commit is contained in:
parent
fedf63f1f5
commit
c0746113b6
@ -735,6 +735,16 @@ class news_form_ui extends e_admin_form_ui
|
||||
{
|
||||
if(!vartrue($curval)) return;
|
||||
|
||||
|
||||
if(strpos($curval, ",")!==false)
|
||||
{
|
||||
$tmp = explode(",",$curval);
|
||||
$curval = $tmp[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$vparm = array('thumb'=>'tag','w'=> 80);
|
||||
|
||||
if($thumb = e107::getParser()->toVideo($curval,$vparm))
|
||||
@ -2391,17 +2401,17 @@ class admin_newspost
|
||||
$_POST['news_thumbnail'] = "{e_IMAGE}newspost_images/".$_POST['news_thumbnail'];
|
||||
}
|
||||
|
||||
$text .= $frm->imagepicker('news_thumbnail[0]', $_POST['news_thumbnail'] ,'','media=news&video=1');
|
||||
// $text .= $frm->imagepicker('news_thumbnail[0]', $_POST['news_thumbnail'] ,'','media=news&video=1');
|
||||
|
||||
/*
|
||||
* XXX Experimental
|
||||
|
||||
// * XXX Experimental
|
||||
$thumbTmp = explode(",",$_POST['news_thumbnail']);
|
||||
$text .= $frm->imagepicker('news_thumbnail[0]', varset($thumbTmp[0]),'','news');
|
||||
$text .= $frm->imagepicker('news_thumbnail[1]', varset($thumbTmp[1]),'','news');
|
||||
$text .= $frm->imagepicker('news_thumbnail[2]', varset($thumbTmp[2]),'','news');
|
||||
$text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]),'','news');
|
||||
$text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]),'','news');
|
||||
*/
|
||||
$text .= $frm->imagepicker('news_thumbnail[0]', varset($thumbTmp[0]),'','media=news&video=1');
|
||||
$text .= $frm->imagepicker('news_thumbnail[1]', varset($thumbTmp[1]),'','media=news&video=1');
|
||||
$text .= $frm->imagepicker('news_thumbnail[2]', varset($thumbTmp[2]),'','media=news&video=1');
|
||||
$text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]),'','media=news&video=1');
|
||||
$text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]),'','media=news&video=1');
|
||||
|
||||
|
||||
$text .= "
|
||||
</td>
|
||||
|
@ -366,7 +366,7 @@ class news_shortcodes extends e_shortcode
|
||||
*/
|
||||
function sc_newsthumbnail($parm = '') //TODO Add support {NEWSTHUMBNAIL: x=y} format
|
||||
{
|
||||
$newsThumb = $this->news_item['news_thumbnail'];
|
||||
$newsThumb = $this->handleMultiple($parm);
|
||||
|
||||
if(!$newsThumb && $parm != 'placeholder')
|
||||
{
|
||||
@ -475,25 +475,61 @@ class news_shortcodes extends e_shortcode
|
||||
|
||||
function sc_newsvideo($parm='')
|
||||
{
|
||||
if($video = e107::getParser()->toVideo($this->news_item['news_thumbnail']))
|
||||
$item = $this->handleMultiple($parm);
|
||||
|
||||
if($video = e107::getParser()->toVideo($item))
|
||||
{
|
||||
return $video;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function handleMultiple($parm)
|
||||
{
|
||||
if(!vartrue($this->news_item['news_thumbnail']) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$media = explode(",", $this->news_item['news_thumbnail']);
|
||||
|
||||
if(is_string($parm) || !vartrue($parm['item']))
|
||||
{
|
||||
$item = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$item = ($parm['item'] -1);
|
||||
}
|
||||
|
||||
|
||||
return varset($media[$item]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Display News Images (but not video thumbnails )
|
||||
* @param $parm array
|
||||
* @example {NEWSIMAGE: type=src&placeholder=true}
|
||||
*/
|
||||
function sc_newsimage($parm = '')
|
||||
function sc_newsimage($parm = null)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
$srcPath = ($this->imageItem) ? $this->imageItem : $this->news_item['news_thumbnail'];
|
||||
|
||||
|
||||
if(is_string($parm))
|
||||
{
|
||||
$parm = array('type'=> $parm);
|
||||
}
|
||||
|
||||
$srcPath = $this->handleMultiple($parm);
|
||||
|
||||
if($video = e107::getParser()->toVideo($this->news_item['news_thumbnail']))
|
||||
{
|
||||
return;
|
||||
@ -504,7 +540,7 @@ class news_shortcodes extends e_shortcode
|
||||
|
||||
if(!$srcPath)
|
||||
{
|
||||
if($parm == 'placeholder')
|
||||
if(varset($parm['type']) == 'placeholder' || vartrue($parm['placeholder']))
|
||||
{
|
||||
$src = $tp->thumbUrl(); // placeholder;
|
||||
}
|
||||
@ -524,32 +560,41 @@ class news_shortcodes extends e_shortcode
|
||||
}
|
||||
}
|
||||
|
||||
// return $src;
|
||||
if(vartrue($parm['nolegacy']) && strpos($src,'newspost_images')!==false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch($parm)
|
||||
$class = "news_image news-image img-responsive img-rounded";
|
||||
|
||||
switch(vartrue($parm['type']))
|
||||
{
|
||||
case 'src':
|
||||
return $src;
|
||||
break;
|
||||
|
||||
case 'tag':
|
||||
return "<img class='news_image news-image' src='".$src."' alt='' style='".$this->param['thumbnail']."' />";
|
||||
return "<img class='{$class}' src='".$src."' alt='' style='".$this->param['thumbnail']."' />";
|
||||
break;
|
||||
|
||||
case 'url':
|
||||
default:
|
||||
return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='news_image news-image img-responsive img-rounded' src='".$src."' alt='' style='".$this->param['thumbnail']."' /></a>";
|
||||
return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='{$class}' src='".$src."' alt='' style='".$this->param['thumbnail']."' /></a>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function sc_sticky_icon()
|
||||
{
|
||||
return $this->news_item['news_sticky'] ? $this->param['image_sticky'] : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sc_newstitlelink($parm = '')
|
||||
{
|
||||
parse_str($parm, $parms);
|
||||
|
@ -2761,6 +2761,15 @@ class e_form
|
||||
case 'image': //TODO - thumb, js tooltip...
|
||||
if($value)
|
||||
{
|
||||
|
||||
if(strpos($value,",")!==false)
|
||||
{
|
||||
$tmp = explode(",",$value);
|
||||
$value = $tmp[0];
|
||||
unset($tmp);
|
||||
}
|
||||
|
||||
|
||||
$vparm = array('thumb'=>'tag','w'=> vartrue($parms['thumb_aw'],'80'));
|
||||
|
||||
if($video = e107::getParser()->toVideo($value,$vparm))
|
||||
|
@ -121,15 +121,30 @@ $NEWS_TEMPLATE['view']['item'] = '
|
||||
<div class="col-md-8 text-right options">{GLYPH=tags} {NEWSTAGS} {GLYPH=folder-open} {NEWSCATEGORY} </div>
|
||||
</div>
|
||||
<hr>
|
||||
{NEWSIMAGE=placeholder}
|
||||
{NEWSIMAGE: item=1&placeholder=1}
|
||||
<hr>
|
||||
<p class="lead">{NEWSSUMMARY}</p>
|
||||
<hr>
|
||||
|
||||
<div class="body">
|
||||
{NEWSVIDEO}
|
||||
{NEWSVIDEO: item=1} <!-- if it exists in position 1 -->
|
||||
{NEWSBODY}
|
||||
<br />
|
||||
<div class="row">
|
||||
<div class="col-md-3">{NEWSIMAGE: item=2}</div>
|
||||
<div class="col-md-3">{NEWSIMAGE: item=3}</div>
|
||||
<div class="col-md-3">{NEWSIMAGE: item=4}</div>
|
||||
<div class="col-md-3">{NEWSIMAGE: item=5}</div>
|
||||
</div>
|
||||
|
||||
{NEWSVIDEO: item=2} <!-- if it exists in position 2 -->
|
||||
|
||||
{EXTENDED}
|
||||
|
||||
{NEWSVIDEO: item=3}
|
||||
{NEWSVIDEO: item=4}
|
||||
{NEWSVIDEO: item=5}
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user