From 1d5e08197c6a0088f0855288af794bd1da7c6712 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 30 Jan 2014 10:14:13 -0800 Subject: [PATCH] News Carousel added and a method to check if a menu is loaded. (see e107_plugins/news/e_header.php ) --- e107_admin/newspost.php | 12 +-- e107_handlers/menu_class.php | 28 +++++- e107_plugins/news/e_header.php | 22 ++++ e107_plugins/news/news_carousel.css | 13 +++ e107_plugins/news/news_carousel_menu.php | 123 +++++++++++++++++++++++ 5 files changed, 190 insertions(+), 8 deletions(-) create mode 100644 e107_plugins/news/e_header.php create mode 100644 e107_plugins/news/news_carousel.css create mode 100644 e107_plugins/news/news_carousel_menu.php diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 852a23bd1..ff81562f6 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -395,14 +395,14 @@ class news_admin_ui extends e_admin_ui protected $cats = array(); protected $newspost; - protected $news_renderTypes = array( + protected $news_renderTypes = array( // TODO Placement location and template should be separate. - '0' => "Default", - '1' => "Default - Title", - '4' => "Default - Title/Summary", + '0' => "Default Area", + '1' => "Default Area - Title", + '4' => "Default Area - Title/Summary", '2' => "Sidebar - Othernews", '3' => "Sidebar - Othernews 2", - + '5' => "Carousel", //'5' => "Featurebox" ); @@ -2438,7 +2438,7 @@ class admin_newspost Notify Ping Services: - ".$frm->checkbox('news_ping',1, 1)." + ".$frm->checkbox('news_ping',1, false)." diff --git a/e107_handlers/menu_class.php b/e107_handlers/menu_class.php index d4cd020e7..5cd2780c7 100644 --- a/e107_handlers/menu_class.php +++ b/e107_handlers/menu_class.php @@ -237,8 +237,32 @@ class e_menu 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; + } diff --git a/e107_plugins/news/e_header.php b/e107_plugins/news/e_header.php new file mode 100644 index 000000000..b44039e8b --- /dev/null +++ b/e107_plugins/news/e_header.php @@ -0,0 +1,22 @@ +isLoaded('news_carousel')) +{ + e107::css('news','news_carousel.css'); +} + +?> \ No newline at end of file diff --git a/e107_plugins/news/news_carousel.css b/e107_plugins/news/news_carousel.css new file mode 100644 index 000000000..355fd7966 --- /dev/null +++ b/e107_plugins/news/news_carousel.css @@ -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 } diff --git a/e107_plugins/news/news_carousel_menu.php b/e107_plugins/news/news_carousel_menu.php new file mode 100644 index 000000000..180979a9e --- /dev/null +++ b/e107_plugins/news/news_carousel_menu.php @@ -0,0 +1,123 @@ + +
+ + + +
+ + '; + + + $NEWS_MENU_TEMPLATE['carousel']['item'] = ' +
+ {NEWSIMAGE} + +
';; + + + $navTemplate = '
  • {NEWSSUMMARY}
  • '; + + + + + + $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' => '' + ); + + + $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(). + +