mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 04:40:44 +02:00
News Carousel Menu is now using the correct method (news class) to load news data.
This commit is contained in:
@@ -1,124 +1,148 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2008-2016 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)
|
||||||
*
|
*
|
||||||
* Carousel Menu
|
* Carousel Menu
|
||||||
*/
|
*/
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if(!defined('e107_INIT'))
|
||||||
|
|
||||||
|
|
||||||
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();
|
|
||||||
$template = e107::getTemplate('news', 'news_menu', 'carousel', true, true);
|
|
||||||
|
|
||||||
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
|
|
||||||
|
|
||||||
e107::getDebug()->log("News Carousel Menu ".print_a($parms,true));
|
|
||||||
|
|
||||||
$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']);
|
exit;
|
||||||
}
|
|
||||||
|
|
||||||
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 != '' ";
|
if(is_string($parm))
|
||||||
|
{
|
||||||
|
parse_str($parm, $parms);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$parms = $parm;
|
||||||
|
}
|
||||||
|
|
||||||
$query .= "
|
if(isset($parms['caption'][e_LANGUAGE]))
|
||||||
ORDER BY n.news_sticky DESC, n.news_datestamp DESC
|
{
|
||||||
LIMIT ".$limit;
|
$parms['caption'] = $parms['caption'][e_LANGUAGE];
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit = vartrue($parms['count'], 5);
|
||||||
|
$tp = e107::getParser();
|
||||||
|
$template = e107::getTemplate('news', 'news_menu', 'carousel', true, true);
|
||||||
|
|
||||||
|
$nobody_regexp = "'(^|,)(" . str_replace(",", "|", e_UC_NOBODY) . ")(,|$)'";
|
||||||
|
|
||||||
|
// e107::getDebug()->log("News Carousel Menu ".print_a($parms,true));
|
||||||
|
/*
|
||||||
|
$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);
|
$news = e107::getObject('e_news_tree'); // get news class.
|
||||||
|
|
||||||
|
$cat = !empty($parms['category']) ? intval($parms['category']) : null;
|
||||||
|
|
||||||
|
$opts = array(
|
||||||
|
'db_order' => 'n.news_sticky DESC, n.news_datestamp DESC',
|
||||||
|
'db_limit' => $limit, // default is 10
|
||||||
|
'db_where' => " 1 "
|
||||||
|
);
|
||||||
|
|
||||||
|
if(vartrue($parms['source']) === 'assigned')
|
||||||
|
{
|
||||||
|
$opts['db_where'] = "FIND_IN_SET(5,n.news_render_type) ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vartrue($parms['source']) === 'sticky')
|
||||||
|
{
|
||||||
|
$opts['db_where'] = "n.news_sticky = 1 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$opts['db_where'] .= " AND n.news_thumbnail != '' ";
|
||||||
|
|
||||||
|
$data = $news->loadJoinActive($cat, false, $opts)->toArray();
|
||||||
|
|
||||||
|
// $data = $sql->retrieve($query,true);
|
||||||
|
|
||||||
|
|
||||||
|
if(empty($data))
|
||||||
|
{
|
||||||
|
e107::getMessage()->addDebug("No News items found with 'carousel' as the template ")->render();
|
||||||
|
|
||||||
if(empty($data))
|
return;
|
||||||
{
|
}
|
||||||
e107::getMessage()->addDebug( "No News items found with 'carousel' as the template ")->render();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
// $tp->setThumbSize(800,0);
|
// $tp->setThumbSize(800,0);
|
||||||
|
|
||||||
$sc = e107::getScBatch('news');
|
$sc = e107::getScBatch('news');
|
||||||
$text = '';
|
$text = '';
|
||||||
$nav = array();
|
$nav = array();
|
||||||
|
|
||||||
foreach($data as $row)
|
foreach($data as $row)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sc->setScVar('news_item', $row);
|
$sc->setScVar('news_item', $row);
|
||||||
|
|
||||||
$vars = array(
|
$vars = array(
|
||||||
'{ACTIVE}' => ($count == 0) ? 'active' : '',
|
'{ACTIVE}' => ($count == 0) ? 'active' : '',
|
||||||
'{COUNT}' => $count,
|
'{COUNT}' => $count,
|
||||||
);
|
);
|
||||||
|
|
||||||
$parsed = str_replace(array_keys($vars), $vars, $template['item']);
|
$parsed = str_replace(array_keys($vars), $vars, $template['item']);
|
||||||
|
|
||||||
$navTemplate = str_replace(array_keys($vars), $vars,$template['nav']);
|
$navTemplate = str_replace(array_keys($vars), $vars, $template['nav']);
|
||||||
$nav[] = $tp->parseTemplate($navTemplate , true, $sc);
|
$nav[] = $tp->parseTemplate($navTemplate, true, $sc);
|
||||||
|
|
||||||
$parsed = $tp->parseTemplate($parsed,true, $sc);
|
$parsed = $tp->parseTemplate($parsed, true, $sc);
|
||||||
$text .= $parsed;
|
$text .= $parsed;
|
||||||
|
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = $template['start'];
|
$header = $template['start'];
|
||||||
|
|
||||||
$footer = str_replace("{NAV}", implode("\n",$nav), $template['end']);
|
$footer = str_replace("{NAV}", implode("\n", $nav), $template['end']);
|
||||||
|
|
||||||
|
|
||||||
if(!empty($parms['caption']))
|
if(!empty($parms['caption']))
|
||||||
{
|
{
|
||||||
e107::getRender()->tablerender($parms['caption'], ($header.$text.$footer) ,'news-carousel'); //TODO Tablerender().
|
e107::getRender()->tablerender($parms['caption'], ($header . $text . $footer), 'news-carousel'); //TODO Tablerender().
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo $header.$text.$footer;
|
echo $header . $text . $footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
e107::js('footer-inline', "
|
||||||
|
|
||||||
e107::js('footer-inline',"
|
|
||||||
clickEvent = false;
|
clickEvent = false;
|
||||||
$('#news-carousel').on('click', '#news-carousel-nav a', function() {
|
$('#news-carousel').on('click', '#news-carousel-nav a', function() {
|
||||||
clickEvent = true;
|
clickEvent = true;
|
||||||
@@ -136,6 +160,6 @@ e107::js('footer-inline',"
|
|||||||
}
|
}
|
||||||
clickEvent = false;
|
clickEvent = false;
|
||||||
});"
|
});"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user