mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 12:41:51 +02:00
Improved control over news images and video. Separate css classes added for each. eg. news-image-1 , news-video-3
This commit is contained in:
parent
182233238f
commit
8d689f2d94
@ -61,9 +61,14 @@ class news_shortcodes extends e_shortcode
|
||||
function sc_newsbody($parm)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
e107::getBB()->setClass("news");
|
||||
$news_body = $tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']);
|
||||
if($this->news_item['news_extended'] && (isset($_POST['preview']) || $this->param['current_action'] == 'extend') && $parm != 'noextend')
|
||||
e107::getBB()->setClass("news"); // For automatic bbcode image resizing.
|
||||
|
||||
if($parm != 'extended')
|
||||
{
|
||||
$news_body = $tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']);
|
||||
}
|
||||
|
||||
if($this->news_item['news_extended'] && (isset($_POST['preview']) || $this->param['current_action'] == 'extend') && ($parm != 'noextend' || $parm != 'body'))
|
||||
{
|
||||
$news_body .= $tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']);
|
||||
}
|
||||
@ -160,7 +165,10 @@ class news_shortcodes extends e_shortcode
|
||||
/**
|
||||
* Render a news navigation link
|
||||
* @param $parm array
|
||||
* @example {NEWSNAVLINK: list=all}
|
||||
* @example {NEWSNAVLINK: list=all} // A list of all items - usually headings and thumbnails
|
||||
* @example {NEWSNAVLINK: list=category} // A list of all items - usually headings and thumbnails from the current category.
|
||||
* @example {NEWSNAVLINK: items=category} // News items for current category.
|
||||
* @example {NEWSNAVLINK: text=myCaption} // Default News item view. ie. news.php
|
||||
*/
|
||||
function sc_newsnavlink($parm='') //TODO add more options.
|
||||
{
|
||||
@ -169,18 +177,14 @@ class news_shortcodes extends e_shortcode
|
||||
{
|
||||
$url = e107::getUrl()->create('news/list/all');
|
||||
}
|
||||
elseif(varset($parm['items']) == 'all') // default page of news items, one after the other. (depending on news prefs)
|
||||
{
|
||||
$url = e107::getUrl()->create('news/list/items');
|
||||
}
|
||||
elseif(varset($parm['items']) == 'category') // news items for current category.
|
||||
{
|
||||
$url = e107::getUrl()->create('news/list/category', $this->news_item);
|
||||
}
|
||||
elseif(varset($parm['list']) == 'category') // A list of all items - usually headings and thumbnails from the current category.
|
||||
elseif(varset($parm['list']) == 'category')
|
||||
{
|
||||
$url = e107::getUrl()->create('news/list/short', $this->news_item); //default for now.
|
||||
}
|
||||
elseif(varset($parm['items']) == 'category')
|
||||
{
|
||||
$url = e107::getUrl()->create('news/list/category', $this->news_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = e107::getUrl()->create('news/list/items'); // default for now.
|
||||
@ -410,23 +414,16 @@ class news_shortcodes extends e_shortcode
|
||||
*/
|
||||
function sc_newsthumbnail($parm = '') //TODO Add support {NEWSTHUMBNAIL: x=y} format
|
||||
{
|
||||
$newsThumb = $this->handleMultiple($parm);
|
||||
$tmp = $this->handleMultiple($parm);
|
||||
$newsThumb = $tmp['file'];
|
||||
|
||||
$class = 'news-thumbnail-'.$tmp['count'];
|
||||
|
||||
if(!$newsThumb && $parm != 'placeholder')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(empty($parm)) // get {SETIMAGE} values when no parm provided.
|
||||
{
|
||||
|
||||
$parm = '|aw='.e107::getParser()->thumbWidth().'&ah='.e107::getParser()->thumbHeight();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($vThumb = e107::getParser()->toVideo($newsThumb, array('thumb'=>'src')))
|
||||
{
|
||||
$src = $vThumb;
|
||||
@ -436,6 +433,11 @@ class news_shortcodes extends e_shortcode
|
||||
{
|
||||
$parms = eHelper::scDualParams($parm);
|
||||
|
||||
if(empty($parms[2])) // get {SETIMAGE} values when no parm provided.
|
||||
{
|
||||
$parms[2] = array('aw' => e107::getParser()->thumbWidth(), 'ah'=> e107::getParser()->thumbHeight());
|
||||
}
|
||||
|
||||
|
||||
if(isset($parms[2]['legacy']) && $parms[2]['legacy']==true) // Legacy mode - swap out thumbnails for actual images and update paths.
|
||||
{
|
||||
@ -471,15 +473,15 @@ class news_shortcodes extends e_shortcode
|
||||
break;
|
||||
|
||||
case 'tag':
|
||||
return "<img class='news_image' src='".$src."' alt='' style='".$this->param['thumbnail']."' />";
|
||||
return "<img class='news_image ".$class."' src='".$src."' alt='' style='".$this->param['thumbnail']."' />";
|
||||
break;
|
||||
|
||||
case 'img':
|
||||
return "<a href='".$_src."' rel='external image'><img class='news_image' src='".$src."' alt='' style='".$this->param['thumbnail']."' /></a>";
|
||||
return "<a href='".$_src."' rel='external image'><img class='news_image ".$class."' src='".$src."' alt='' style='".$this->param['thumbnail']."' /></a>";
|
||||
break;
|
||||
|
||||
default:
|
||||
return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='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='news_image img-responsive img-rounded ".$class."' src='".$src."' alt='' style='".$this->param['thumbnail']."' /></a>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -521,9 +523,10 @@ class news_shortcodes extends e_shortcode
|
||||
|
||||
function sc_newsvideo($parm='')
|
||||
{
|
||||
$item = $this->handleMultiple($parm);
|
||||
$tmp = $this->handleMultiple($parm,'video');
|
||||
$file = $tmp['file'];
|
||||
|
||||
if($video = e107::getParser()->toVideo($item))
|
||||
if($video = e107::getParser()->toVideo($file, array('class'=> 'news-video-'.$tmp['count'])))
|
||||
{
|
||||
return $video;
|
||||
}
|
||||
@ -531,14 +534,31 @@ class news_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
function handleMultiple($parm)
|
||||
function handleMultiple($parm,$type='image')
|
||||
{
|
||||
if(!vartrue($this->news_item['news_thumbnail']) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
$media = explode(",", $this->news_item['news_thumbnail']);
|
||||
$list = array();
|
||||
|
||||
foreach($media as $file)
|
||||
{
|
||||
if($tp->isVideo($file))
|
||||
{
|
||||
$list['video'][] = $file;
|
||||
}
|
||||
else
|
||||
{
|
||||
$list['image'][] = $file;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(is_string($parm) || !vartrue($parm['item']))
|
||||
{
|
||||
@ -550,7 +570,10 @@ class news_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
return varset($media[$item]);
|
||||
$file = varset($list[$type][$item]);
|
||||
$count = $item;
|
||||
|
||||
return array('file'=>$file, 'count'=>varset($parm['item'],1));
|
||||
|
||||
}
|
||||
|
||||
@ -574,12 +597,16 @@ class news_shortcodes extends e_shortcode
|
||||
$parm = array('type'=> $parm);
|
||||
}
|
||||
|
||||
$srcPath = $this->handleMultiple($parm);
|
||||
$tmp = $this->handleMultiple($parm);
|
||||
$srcPath = $tmp['file'];
|
||||
|
||||
$class = "news_image news-image img-responsive img-rounded";
|
||||
$class .= ' news-image-'.$tmp['count'];
|
||||
|
||||
|
||||
if($video = e107::getParser()->toVideo($this->news_item['news_thumbnail']))
|
||||
if($tp->isVideo($this->news_item['news_thumbnail']))
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -611,7 +638,7 @@ class news_shortcodes extends e_shortcode
|
||||
return;
|
||||
}
|
||||
|
||||
$class = "news_image news-image img-responsive img-rounded";
|
||||
|
||||
|
||||
switch(vartrue($parm['type']))
|
||||
{
|
||||
|
@ -2815,6 +2815,19 @@ class e_parser
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check if a file is an video or not.
|
||||
* @param $file string
|
||||
* @return boolean
|
||||
*/
|
||||
function isVideo($file)
|
||||
{
|
||||
$ext = pathinfo($file,PATHINFO_EXTENSION);
|
||||
|
||||
return ($ext == 'youtube') ? true : false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display a Video file.
|
||||
@ -2828,7 +2841,8 @@ class e_parser
|
||||
$thumb = vartrue($parm['thumb']);
|
||||
|
||||
if($type == 'youtube')
|
||||
{
|
||||
{
|
||||
|
||||
$video = '<iframe width="560" height="315" src="//www.youtube.com/embed/'.$id.'" style="border:0px" allowfullscreen></iframe>';
|
||||
$thumbSrc = "https://i1.ytimg.com/vi/".$id."/0.jpg";
|
||||
|
||||
@ -2847,9 +2861,9 @@ class e_parser
|
||||
return '<div class="video-responsive video-thumbnail thumbnail">'.$video.'</div>';
|
||||
}
|
||||
|
||||
return '<div class="'.vartrue($parm['class'],'video-responsive').'">'.$video.'</div>';
|
||||
return '<div class="video-responsive '.vartrue($parm['class']).'">'.$video.'</div>';
|
||||
}
|
||||
|
||||
|
||||
if($type == 'mp4') //TODO FIXME
|
||||
{
|
||||
return '
|
||||
|
@ -44,7 +44,7 @@ $NEWS_TEMPLATE['list']['item'] = '
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
';
|
||||
|
||||
|
||||
@ -121,30 +121,39 @@ $NEWS_TEMPLATE['view']['item'] = '
|
||||
<div class="col-md-8 text-right options">{GLYPH=tags} {NEWSTAGS} {GLYPH=folder-open} {NEWSCATEGORY} </div>
|
||||
</div>
|
||||
<hr>
|
||||
{NEWSIMAGE: item=1&placeholder=1}
|
||||
{NEWSIMAGE: item=1}
|
||||
{NEWSVIDEO: item=1}
|
||||
<hr>
|
||||
<p class="lead">{NEWSSUMMARY}</p>
|
||||
<hr>
|
||||
|
||||
<div class="body">
|
||||
{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=2}
|
||||
{NEWSVIDEO: item=3}
|
||||
|
||||
{NEWSVIDEO: item=3}
|
||||
{NEWSVIDEO: item=4}
|
||||
|
||||
{NEWSBODY=body}
|
||||
<br />
|
||||
{SETIMAGE: w=600&h=600}
|
||||
|
||||
<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>
|
||||
<div class="row news-images-2">
|
||||
<div class="col-md-6">{NEWSIMAGE: item=4}</div>
|
||||
<div class="col-md-6">{NEWSIMAGE: item=5}</div>
|
||||
</div>
|
||||
|
||||
{NEWSVIDEO: item=4}
|
||||
{NEWSVIDEO: item=5}
|
||||
|
||||
<div class="body-extended">
|
||||
{NEWSBODY=extended}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
|
3
news.php
3
news.php
@ -319,7 +319,8 @@ if ($action == 'cat' || $action == 'all' || vartrue($_GET['tag']))
|
||||
}
|
||||
|
||||
$text .= "<div class='center news-list-footer'><a class='btn btn-default' href='".e107::getUrl()->create('news/list/all')."'>".LAN_NEWS_84."</a></div>";
|
||||
|
||||
|
||||
|
||||
ob_start();
|
||||
$ns->tablerender($NEWSLISTTITLE, $text, 'news');
|
||||
$cache_data = ob_get_flush();
|
||||
|
Loading…
x
Reference in New Issue
Block a user