1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 17:39:46 +01:00

Support for multiple images/video in news items. (experimental)

This commit is contained in:
Cameron 2014-01-31 06:33:01 -08:00
parent fedf63f1f5
commit c0746113b6
4 changed files with 102 additions and 23 deletions

View File

@ -735,6 +735,16 @@ class news_form_ui extends e_admin_form_ui
{ {
if(!vartrue($curval)) return; if(!vartrue($curval)) return;
if(strpos($curval, ",")!==false)
{
$tmp = explode(",",$curval);
$curval = $tmp[0];
}
$vparm = array('thumb'=>'tag','w'=> 80); $vparm = array('thumb'=>'tag','w'=> 80);
if($thumb = e107::getParser()->toVideo($curval,$vparm)) if($thumb = e107::getParser()->toVideo($curval,$vparm))
@ -2391,17 +2401,17 @@ class admin_newspost
$_POST['news_thumbnail'] = "{e_IMAGE}newspost_images/".$_POST['news_thumbnail']; $_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']); $thumbTmp = explode(",",$_POST['news_thumbnail']);
$text .= $frm->imagepicker('news_thumbnail[0]', varset($thumbTmp[0]),'','news'); $text .= $frm->imagepicker('news_thumbnail[0]', varset($thumbTmp[0]),'','media=news&video=1');
$text .= $frm->imagepicker('news_thumbnail[1]', varset($thumbTmp[1]),'','news'); $text .= $frm->imagepicker('news_thumbnail[1]', varset($thumbTmp[1]),'','media=news&video=1');
$text .= $frm->imagepicker('news_thumbnail[2]', varset($thumbTmp[2]),'','news'); $text .= $frm->imagepicker('news_thumbnail[2]', varset($thumbTmp[2]),'','media=news&video=1');
$text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]),'','news'); $text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]),'','media=news&video=1');
$text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]),'','news'); $text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]),'','media=news&video=1');
*/
$text .= " $text .= "
</td> </td>

View File

@ -366,7 +366,7 @@ class news_shortcodes extends e_shortcode
*/ */
function sc_newsthumbnail($parm = '') //TODO Add support {NEWSTHUMBNAIL: x=y} format 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') if(!$newsThumb && $parm != 'placeholder')
{ {
@ -475,25 +475,61 @@ class news_shortcodes extends e_shortcode
function sc_newsvideo($parm='') 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; 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 ) * 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(); $tp = e107::getParser();
if(is_string($parm))
$srcPath = ($this->imageItem) ? $this->imageItem : $this->news_item['news_thumbnail']; {
$parm = array('type'=> $parm);
}
$srcPath = $this->handleMultiple($parm);
if($video = e107::getParser()->toVideo($this->news_item['news_thumbnail'])) if($video = e107::getParser()->toVideo($this->news_item['news_thumbnail']))
{ {
return; return;
@ -504,7 +540,7 @@ class news_shortcodes extends e_shortcode
if(!$srcPath) if(!$srcPath)
{ {
if($parm == 'placeholder') if(varset($parm['type']) == 'placeholder' || vartrue($parm['placeholder']))
{ {
$src = $tp->thumbUrl(); // 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': case 'src':
return $src; return $src;
break; break;
case 'tag': 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; break;
case 'url': case 'url':
default: 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; break;
} }
} }
function sc_sticky_icon() function sc_sticky_icon()
{ {
return $this->news_item['news_sticky'] ? $this->param['image_sticky'] : ''; return $this->news_item['news_sticky'] ? $this->param['image_sticky'] : '';
} }
function sc_newstitlelink($parm = '') function sc_newstitlelink($parm = '')
{ {
parse_str($parm, $parms); parse_str($parm, $parms);

View File

@ -2761,6 +2761,15 @@ class e_form
case 'image': //TODO - thumb, js tooltip... case 'image': //TODO - thumb, js tooltip...
if($value) if($value)
{ {
if(strpos($value,",")!==false)
{
$tmp = explode(",",$value);
$value = $tmp[0];
unset($tmp);
}
$vparm = array('thumb'=>'tag','w'=> vartrue($parms['thumb_aw'],'80')); $vparm = array('thumb'=>'tag','w'=> vartrue($parms['thumb_aw'],'80'));
if($video = e107::getParser()->toVideo($value,$vparm)) if($video = e107::getParser()->toVideo($value,$vparm))

View File

@ -121,15 +121,30 @@ $NEWS_TEMPLATE['view']['item'] = '
<div class="col-md-8 text-right options">{GLYPH=tags} &nbsp;{NEWSTAGS} &nbsp; {GLYPH=folder-open} &nbsp;{NEWSCATEGORY} </div> <div class="col-md-8 text-right options">{GLYPH=tags} &nbsp;{NEWSTAGS} &nbsp; {GLYPH=folder-open} &nbsp;{NEWSCATEGORY} </div>
</div> </div>
<hr> <hr>
{NEWSIMAGE=placeholder} {NEWSIMAGE: item=1&placeholder=1}
<hr> <hr>
<p class="lead">{NEWSSUMMARY}</p> <p class="lead">{NEWSSUMMARY}</p>
<hr> <hr>
<div class="body"> <div class="body">
{NEWSVIDEO} {NEWSVIDEO: item=1} <!-- if it exists in position 1 -->
{NEWSBODY} {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} {EXTENDED}
{NEWSVIDEO: item=3}
{NEWSVIDEO: item=4}
{NEWSVIDEO: item=5}
</div> </div>
<hr> <hr>