mirror of
https://github.com/e107inc/e107.git
synced 2025-08-13 18:14:26 +02:00
News Carousel added and a method to check if a menu is loaded. (see e107_plugins/news/e_header.php )
This commit is contained in:
@@ -395,14 +395,14 @@ class news_admin_ui extends e_admin_ui
|
|||||||
protected $cats = array();
|
protected $cats = array();
|
||||||
protected $newspost;
|
protected $newspost;
|
||||||
|
|
||||||
protected $news_renderTypes = array(
|
protected $news_renderTypes = array( // TODO Placement location and template should be separate.
|
||||||
|
|
||||||
'0' => "Default",
|
'0' => "Default Area",
|
||||||
'1' => "Default - Title",
|
'1' => "Default Area - Title",
|
||||||
'4' => "Default - Title/Summary",
|
'4' => "Default Area - Title/Summary",
|
||||||
'2' => "Sidebar - Othernews",
|
'2' => "Sidebar - Othernews",
|
||||||
'3' => "Sidebar - Othernews 2",
|
'3' => "Sidebar - Othernews 2",
|
||||||
|
'5' => "Carousel",
|
||||||
//'5' => "Featurebox"
|
//'5' => "Featurebox"
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2438,7 +2438,7 @@ class admin_newspost
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Notify Ping Services: </td>
|
<td>Notify Ping Services: </td>
|
||||||
<td>".$frm->checkbox('news_ping',1, 1)."</td>
|
<td>".$frm->checkbox('news_ping',1, false)."</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@@ -237,8 +237,32 @@ class e_menu
|
|||||||
return $eMenuArea;
|
return $eMenuArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if a menu is currently active.
|
||||||
|
* @param string $menuname (without the '_menu.php' )
|
||||||
|
*/
|
||||||
|
function isLoaded($menuname)
|
||||||
|
{
|
||||||
|
if(empty($menuname))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($this->eMenuActive as $area)
|
||||||
|
{
|
||||||
|
foreach($area as $menu)
|
||||||
|
{
|
||||||
|
if($menu['menu_name'] == $menuname."_menu")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
22
e107_plugins/news/e_header.php
Normal file
22
e107_plugins/news/e_header.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2014 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
* Related configuration module - News
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
|
||||||
|
if(USER_AREA && e107::getMenu()->isLoaded('news_carousel'))
|
||||||
|
{
|
||||||
|
e107::css('news','news_carousel.css');
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
13
e107_plugins/news/news_carousel.css
Normal file
13
e107_plugins/news/news_carousel.css
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
#news-carousel.carousel .item { height:350px }
|
||||||
|
#news-carousel-titles { padding-left:0px; height:350px }
|
||||||
|
#news-carousel-images { padding-right:0px; 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 h1 { margin:0px }
|
||||||
|
#news-carousel-images .carousel-caption small { font-size: 11px; margin: 0px; text-transform: uppercase; }
|
||||||
|
#news-carousel-nav { width:100%; height:100%; background-color:black }
|
||||||
|
#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 a { display: block; padding: 15px 20px; border-bottom: 1px solid rgb(34, 34, 34); color: rgb(153, 153, 153); }
|
||||||
|
#news-carousel-nav li.active a, #news-carousel-nav li a:hover { color: white; background-color:#111111 }
|
123
e107_plugins/news/news_carousel_menu.php
Normal file
123
e107_plugins/news/news_carousel_menu.php
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
* News Carousel Menu
|
||||||
|
*/
|
||||||
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
e107::js('footer-inline',"
|
||||||
|
clickEvent = false;
|
||||||
|
$('#news-carousel').on('click', '#news-carousel-nav a', function() {
|
||||||
|
clickEvent = true;
|
||||||
|
$('#news-carousel-nav li').removeClass('active');
|
||||||
|
$(this).parent().addClass('active');
|
||||||
|
}).on('slid.bs.carousel', function(e) {
|
||||||
|
if(!clickEvent) {
|
||||||
|
var count = $('#news-carousel-nav').children().length -1;
|
||||||
|
var current = $('#news-carousel-nav li.active');
|
||||||
|
current.removeClass('active').next().addClass('active');
|
||||||
|
var id = parseInt(current.data('slide-to'));
|
||||||
|
if(count == id) {
|
||||||
|
$('#news-carousel-nav li').first().addClass('active');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clickEvent = false;
|
||||||
|
});"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$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,400);
|
||||||
|
|
||||||
|
foreach($data as $row)
|
||||||
|
{
|
||||||
|
$img = $tp->thumbUrl($row['news_thumbnail']);
|
||||||
|
|
||||||
|
$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' => '<img class="img-responsive" src="'.$img.'">'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$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().
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user