mirror of
https://github.com/e107inc/e107.git
synced 2025-08-18 20:31:41 +02:00
@@ -314,6 +314,11 @@ class news_shortcodes extends e_shortcode
|
|||||||
return $this->sc_newsavatar($parm);
|
return $this->sc_newsavatar($parm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sc_news_image($parm=null)
|
||||||
|
{
|
||||||
|
return $this->sc_newsimage($parm);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------- BC compatible Shortcodes ------------------------------------------- //
|
// ----------------------------------- BC compatible Shortcodes ------------------------------------------- //
|
||||||
|
|
||||||
function sc_newscategory($parm=null)
|
function sc_newscategory($parm=null)
|
||||||
@@ -328,23 +333,28 @@ class news_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
$date = ($this->news_item['news_start'] > 0) ? $this->news_item['news_start'] : $this->news_item['news_datestamp'];
|
$date = ($this->news_item['news_start'] > 0) ? $this->news_item['news_start'] : $this->news_item['news_datestamp'];
|
||||||
$con = e107::getDate();
|
$con = e107::getDate();
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
if($parm == '')
|
if($parm == '')
|
||||||
{
|
{
|
||||||
return $con->convert_date($date, 'long');
|
return $tp->toDate($date, 'long');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch($parm)
|
switch($parm)
|
||||||
{
|
{
|
||||||
case 'long':
|
case 'long':
|
||||||
return $con->convert_date($date, 'long');
|
return $tp->toDate($date, 'long');
|
||||||
break;
|
break;
|
||||||
case 'short':
|
case 'short':
|
||||||
return $con->convert_date($date, 'short');
|
return $tp->toDate($date, 'short');
|
||||||
break;
|
break;
|
||||||
case 'forum':
|
case 'forum':
|
||||||
return $con->convert_date($date, 'forum');
|
return $con->convert_date($date, 'forum');
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
return date($parm, $date);
|
return $tp->toDate($date,$parm);
|
||||||
|
// return date($parm, $date);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -722,6 +732,7 @@ class news_shortcodes extends e_shortcode
|
|||||||
* Display News Images (but not video thumbnails )
|
* Display News Images (but not video thumbnails )
|
||||||
* @param $parm array
|
* @param $parm array
|
||||||
* @example {NEWSIMAGE: type=src&placeholder=true}
|
* @example {NEWSIMAGE: type=src&placeholder=true}
|
||||||
|
* @example {NEWSIMAGE: class=img-responsive}
|
||||||
*/
|
*/
|
||||||
function sc_newsimage($parm = null)
|
function sc_newsimage($parm = null)
|
||||||
{
|
{
|
||||||
@@ -735,7 +746,7 @@ class news_shortcodes extends e_shortcode
|
|||||||
$tmp = $this->handleMultiple($parm);
|
$tmp = $this->handleMultiple($parm);
|
||||||
$srcPath = $tmp['file'];
|
$srcPath = $tmp['file'];
|
||||||
|
|
||||||
$class = "news_image news-image img-responsive img-rounded";
|
$class = (!empty($parm['class'])) ? $parm['class'] : "news_image news-image img-responsive img-rounded";
|
||||||
$class .= ' news-image-'.$tmp['count'];
|
$class .= ' news-image-'.$tmp['count'];
|
||||||
$dimensions = null;
|
$dimensions = null;
|
||||||
$srcset = null;
|
$srcset = null;
|
||||||
|
@@ -61,6 +61,13 @@ class news_menu
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "news_carousel":
|
||||||
|
$fields['caption'] = array('title'=> LAN_CAPTION, 'type'=>'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'), 'help'=>LAN_OPTIONAL);
|
||||||
|
$fields['category'] = array('title'=> LAN_CATEGORY, 'type'=>'dropdown', 'writeParms'=>array('optArray'=>$categories, 'default'=>"(".LAN_ALL.")"), 'help'=>"Limit news items to a specific category");
|
||||||
|
$fields['source'] = array('title'=> "Source", 'type'=>'dropdown','writeParms'=>array('optArray'=>$sources), 'help'=>"Assigned items are those with a template assigned to 'News Carousel' ");
|
||||||
|
$fields['count'] = array('title'=> "Number of Items to Display", 'type'=>'number', 'writeParms'=>array('pattern'=>'[0-9]*', 'default'=>4));
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "news_categories":
|
case "news_categories":
|
||||||
$fields['caption'] = array('title'=> LAN_CAPTION, 'type'=>'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'));
|
$fields['caption'] = array('title'=> LAN_CAPTION, 'type'=>'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'));
|
||||||
|
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
@media all and (min-width: 768px)
|
@media all and (min-width: 768px)
|
||||||
{
|
{
|
||||||
#news-carousel-titles { margin-top:20px; padding-left:0px; height:350px }
|
#news-carousel-titles { margin-top:20px; padding-left:0; height:350px }
|
||||||
#news-carousel-images { margin-top:20px; padding-right:0px; height:350px }
|
#news-carousel-images { margin-top:20px; padding-right:0; height:350px }
|
||||||
}
|
}
|
||||||
|
|
||||||
#news-carousel-images .carousel-caption { left:15px; right:15px: margin:0px; padding:0px; bottom:10px; text-align:left }
|
#news-carousel-images .carousel-caption { left:15px; right:15px; margin:0; padding:0; bottom:10px; text-align:left }
|
||||||
#news-carousel-images .carousel-caption h1 { margin:0px }
|
#news-carousel-images .carousel-caption h1 { margin:0 }
|
||||||
#news-carousel-images .carousel-caption small { font-size: 11px; margin: 0px; text-transform: uppercase; }
|
#news-carousel-images .carousel-caption small { font-size: 11px; margin: 0; text-transform: uppercase; }
|
||||||
#news-carousel-nav { width:100%; height:100%; background-color:black }
|
#news-carousel-nav { width:100%; height:100%; background-color:black }
|
||||||
#news-carousel-nav li { border-left:4px solid transparent }
|
#news-carousel-nav li { border-left:4px solid transparent }
|
||||||
#news-carousel-nav li.active { border-left:4px solid rgb(238, 50, 36); }
|
#news-carousel-nav li.active { border-left:4px solid rgb(238, 50, 36); }
|
||||||
|
@@ -1,12 +1,115 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
* Copyright (C) 2008-2016 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* News Carousel Menu
|
* Carousel Menu
|
||||||
*/
|
*/
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
|
||||||
|
if(is_string($parm))
|
||||||
|
{
|
||||||
|
parse_str($parm, $parms);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$parms = $parm;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($parms['caption'][e_LANGUAGE]))
|
||||||
|
{
|
||||||
|
$parms['caption'] = $parms['caption'][e_LANGUAGE];
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit = vartrue($parms['count'],5);
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
$template = e107::getTemplate('news', 'news_menu', 'carousel');
|
||||||
|
|
||||||
|
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT n.*, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon,
|
||||||
|
nc.category_meta_keywords, nc.category_meta_description
|
||||||
|
FROM #news AS n
|
||||||
|
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
|
||||||
|
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()."
|
||||||
|
AND (n.news_end=0 || n.news_end>".time().") ";
|
||||||
|
|
||||||
|
if(!empty($parms['category']))
|
||||||
|
{
|
||||||
|
$query .= " AND n.news_category = ".intval($parms['category']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vartrue($parms['source']) == 'assigned')
|
||||||
|
{
|
||||||
|
$query .= " AND FIND_IN_SET(5,n.news_render_type) ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vartrue($parms['source']) == 'sticky')
|
||||||
|
{
|
||||||
|
$query .= " AND n.news_sticky = 1 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query .= " AND n.news_thumbnail != '' ";
|
||||||
|
|
||||||
|
$query .= "
|
||||||
|
ORDER BY n.news_sticky DESC, n.news_datestamp DESC
|
||||||
|
LIMIT ".$limit;
|
||||||
|
|
||||||
|
$data = $sql->retrieve($query,true);
|
||||||
|
|
||||||
|
if(empty($data))
|
||||||
|
{
|
||||||
|
e107::getMessage()->addDebug( "No News items found with 'carousel' as the template ")->render();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
|
// $tp->setThumbSize(800,0);
|
||||||
|
|
||||||
|
$sc = e107::getScBatch('news');
|
||||||
|
$text = '';
|
||||||
|
|
||||||
|
|
||||||
|
foreach($data as $row)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sc->setScVar('news_item', $row);
|
||||||
|
|
||||||
|
$vars = array(
|
||||||
|
'{ACTIVE}' => ($count == 0) ? 'active' : '',
|
||||||
|
'{COUNT}' => $count,
|
||||||
|
);
|
||||||
|
|
||||||
|
$parsed = str_replace(array_keys($vars), $vars, $template['item']);
|
||||||
|
|
||||||
|
$navTemplate = str_replace(array_keys($vars), $vars,$template['nav']);
|
||||||
|
$nav[] = $tp->parseTemplate($navTemplate , true, $sc);
|
||||||
|
|
||||||
|
$parsed = $tp->parseTemplate($parsed,true, $sc);
|
||||||
|
$text .= $parsed;
|
||||||
|
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$header = $template['start'];
|
||||||
|
|
||||||
|
$footer = str_replace("{NAV}", implode("\n",$nav), $template['end']);
|
||||||
|
|
||||||
|
|
||||||
|
if(!empty($parms['caption']))
|
||||||
|
{
|
||||||
|
e107::getRender()->tablerender($parms['caption'], ($header.$text.$footer) ,'news-carousel'); //TODO Tablerender().
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo $header.$text.$footer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
e107::js('footer-inline',"
|
e107::js('footer-inline',"
|
||||||
clickEvent = false;
|
clickEvent = false;
|
||||||
@@ -29,104 +132,3 @@ e107::js('footer-inline',"
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$NEWS_MENU_TEMPLATE['carousel']['start'] = '
|
|
||||||
<div id="news-carousel" class="carousel slide" data-ride="carousel">
|
|
||||||
<div class="row">
|
|
||||||
<!-- Wrapper for slides -->
|
|
||||||
<div id="news-carousel-images" class="col-md-8">
|
|
||||||
<div class="carousel-inner">';
|
|
||||||
|
|
||||||
|
|
||||||
$NEWS_MENU_TEMPLATE['carousel']['end'] = '
|
|
||||||
|
|
||||||
</div><!-- End Carousel Inner -->
|
|
||||||
</div>
|
|
||||||
<div id="news-carousel-titles" class="col-md-4 ">
|
|
||||||
<ul id="news-carousel-nav" class="nav nav-inverse nav-stacked pull-right ">{NAV}</ul>
|
|
||||||
</div>
|
|
||||||
</div><!-- End Carousel -->
|
|
||||||
</div>
|
|
||||||
';
|
|
||||||
|
|
||||||
|
|
||||||
$NEWS_MENU_TEMPLATE['carousel']['item'] = '<!-- Start Item -->
|
|
||||||
<div class="item {ACTIVE}">
|
|
||||||
{NEWSIMAGE}
|
|
||||||
<div class="carousel-caption">
|
|
||||||
<small>{NEWSDATE}</small>
|
|
||||||
<h1>{NEWSTITLE}</h1>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div><!-- End Item -->';;
|
|
||||||
|
|
||||||
|
|
||||||
$navTemplate = '<li data-target="#news-carousel" data-slide-to="{COUNT}" class="{ACTIVE}"><a href="#">{NEWSSUMMARY}</a></li>';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
|
|
||||||
|
|
||||||
$query = "
|
|
||||||
SELECT n.*, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon,
|
|
||||||
nc.category_meta_keywords, nc.category_meta_description
|
|
||||||
FROM #news AS n
|
|
||||||
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
|
|
||||||
WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()."
|
|
||||||
AND (n.news_end=0 || n.news_end>".time().") AND FIND_IN_SET(5,n.news_render_type)
|
|
||||||
ORDER BY n.news_sticky DESC, n.news_datestamp DESC
|
|
||||||
LIMIT 5";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$data = $sql->retrieve($query,true);
|
|
||||||
|
|
||||||
if(count($data) < 1)
|
|
||||||
{
|
|
||||||
e107::getMessage()->addDebug( "No News items found with 'carousel' as the template ")->render();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = 0;
|
|
||||||
|
|
||||||
$tp->setThumbSize(800,0);
|
|
||||||
|
|
||||||
foreach($data as $row)
|
|
||||||
{
|
|
||||||
$tmp = explode(",",$row['news_thumbnail']); // fix for multiple
|
|
||||||
|
|
||||||
if($video = $tp->toVideo($tmp[0],array('thumb'=>'tag', 'w'=>800)))
|
|
||||||
{
|
|
||||||
$imgTag = $video;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$img = $tp->thumbUrl($tmp[0]);
|
|
||||||
$imgTag = '<img class="img-responsive" src="'.$img.'">';
|
|
||||||
}
|
|
||||||
|
|
||||||
$vars = array(
|
|
||||||
'NEWSTITLE' => $tp->toHtml($row['news_title'],false, 'TITLE'),
|
|
||||||
'NEWSSUMMARY' => vartrue($row['news_summary'],$row['news_title']),
|
|
||||||
'NEWSDATE' => $tp->toDate($row['news_datestamp'],'dd MM, yyyy'),
|
|
||||||
'ACTIVE' => ($count == 0) ? 'active' : '',
|
|
||||||
'COUNT' => $count,
|
|
||||||
'NEWSIMAGE' => '<a href="'.e107::getUrl()->create('news/view/item',$row).'">'.$imgTag.'</a>'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$text .= $tp->simpleParse($NEWS_MENU_TEMPLATE['carousel']['item'], $vars);
|
|
||||||
|
|
||||||
$nav[] = $tp->simpleParse($navTemplate, $vars);
|
|
||||||
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$header = $NEWS_MENU_TEMPLATE['carousel']['start'];
|
|
||||||
|
|
||||||
$footer = str_replace("{NAV}", implode("\n",$nav), $NEWS_MENU_TEMPLATE['carousel']['end']);
|
|
||||||
|
|
||||||
e107::getRender()->tablerender('',$header.$text.$footer,'news-carousel'); //TODO Tablerender().
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -103,3 +103,40 @@ $NEWS_MENU_TEMPLATE['grid']['end'] = '</div>';
|
|||||||
|
|
||||||
|
|
||||||
// $NEWS_MENU_WRAPPER['grid']['NEWSTITLE'] = "<span style='color:red'>{---}</span>"; // example
|
// $NEWS_MENU_WRAPPER['grid']['NEWSTITLE'] = "<span style='color:red'>{---}</span>"; // example
|
||||||
|
|
||||||
|
|
||||||
|
/* Carousel Menu */
|
||||||
|
|
||||||
|
$NEWS_MENU_TEMPLATE['carousel']['start'] = '
|
||||||
|
<div id="news-carousel" class="carousel slide" data-ride="carousel">
|
||||||
|
<div class="row">
|
||||||
|
<!-- Wrapper for slides -->
|
||||||
|
<div id="news-carousel-images" class="col-md-8">
|
||||||
|
<div class="carousel-inner">';
|
||||||
|
|
||||||
|
|
||||||
|
$NEWS_MENU_TEMPLATE['carousel']['end'] = '
|
||||||
|
|
||||||
|
</div><!-- End Carousel Inner -->
|
||||||
|
</div>
|
||||||
|
<div id="news-carousel-titles" class="col-md-4 ">
|
||||||
|
<ul id="news-carousel-nav" class="nav nav-inverse nav-stacked pull-right ">{NAV}</ul>
|
||||||
|
</div>
|
||||||
|
</div><!-- End Carousel -->
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
|
||||||
|
$NEWS_MENU_TEMPLATE['carousel']['item'] = '<!-- Start Item -->
|
||||||
|
<div class="item {ACTIVE}">{SETIMAGE: w=800&h=370&crop=1}
|
||||||
|
{NEWS_IMAGE: class=img-responsive}
|
||||||
|
<div class="carousel-caption">
|
||||||
|
<small>{NEWS_DATE=dd MM, yyyy}</small>
|
||||||
|
<h1>{NEWS_TITLE}</h1>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div><!-- End Item -->';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$NEWS_MENU_TEMPLATE['carousel']['nav'] = '<li data-target="#news-carousel" data-slide-to="{COUNT}" class="{ACTIVE}"><a href="#">{NEWS_SUMMARY}</a></li>';
|
Reference in New Issue
Block a user