2006-12-02 04:36:16 +00:00
< ? php
/*
2008-12-03 12:38:08 +00:00
* e107 website system
*
2011-11-29 14:16:24 +00:00
* Copyright ( C ) 2008 - 2011 e107 Inc ( e107 . org )
2008-12-03 12:38:08 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* News frontend
*
2010-03-16 13:44:41 +00:00
* $URL $
* $Id $
2006-12-02 04:36:16 +00:00
*/
2009-12-30 21:04:11 +00:00
/**
* @ package e107
* @ subpackage user
2010-02-10 18:18:01 +00:00
* @ version $Id $ ;
2009-12-30 21:04:11 +00:00
*
* News front page display
*/
2008-12-02 23:44:19 +00:00
2006-12-02 04:36:16 +00:00
require_once ( " class2.php " );
2009-08-28 15:30:25 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_' . e_PAGE );
2006-12-02 04:36:16 +00:00
require_once ( e_HANDLER . " news_class.php " );
2009-11-15 21:41:50 +00:00
//require_once(e_HANDLER."comment_class.php");
//$cobj = new comment;
2006-12-02 04:36:16 +00:00
2008-12-03 12:38:08 +00:00
if ( isset ( $NEWSHEADER ))
2007-06-07 20:34:02 +00:00
{
2011-11-29 14:16:24 +00:00
require_once ( HEADERF );
require_once ( FOOTERF );
exit ;
2006-12-02 04:36:16 +00:00
}
2007-06-07 20:34:02 +00:00
2010-01-06 20:14:45 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/lan_news.php' ); // Temporary
2009-07-10 20:30:09 +00:00
$cacheString = 'news.php_default_' ;
2006-12-02 04:36:16 +00:00
$action = '' ;
2007-06-07 20:34:02 +00:00
$sub_action = '' ;
2010-01-06 20:14:45 +00:00
$order = 'news_datestamp' ;
2007-06-07 20:34:02 +00:00
$newsfrom = 0 ;
2010-01-06 20:14:45 +00:00
if ( ! defined ( 'ITEMVIEW' ))
2007-06-07 20:34:02 +00:00
{
2011-11-29 14:16:24 +00:00
define ( 'ITEMVIEW' , varset ( $pref [ 'newsposts' ], 15 ));
2006-12-02 04:36:16 +00:00
}
2008-12-03 12:38:08 +00:00
if ( e_QUERY )
2007-06-07 20:34:02 +00:00
{
2011-11-29 14:16:24 +00:00
$tmp = explode ( " . " , e_QUERY );
$action = $tmp [ 0 ]; // At least one parameter here
2010-01-06 20:14:45 +00:00
$sub_action = varset ( $tmp [ 1 ], '' ); // Usually a numeric category, or numeric news item number, but don't presume yet
2011-11-29 14:16:24 +00:00
// $id = varset($tmp[2],''); // ID of specific news item where required
$newsfrom = intval ( varset ( $tmp [ 2 ], 0 )); // Item number for first item on multi-page lists
$cacheString = 'news.php_' . e_QUERY ;
2006-12-02 04:36:16 +00:00
}
2007-06-07 20:34:02 +00:00
//$newsfrom = (!is_numeric($action) || !e_QUERY ? 0 : ($action ? $action : e_QUERY));
// Usually the first query parameter is the action.
// For any of the 'list' modes (inc month, day), the action being second is a legacy situation
// .... which can hopefully go sometime
2009-09-14 18:22:16 +00:00
//SecretR: Gone, gone...
2007-06-07 20:34:02 +00:00
if ( is_numeric ( $action ) && isset ( $tmp [ 1 ]) && (( $tmp [ 1 ] == 'list' ) || ( $tmp [ 1 ] == 'month' ) || ( $tmp [ 1 ] == 'day' )))
{
$action = $tmp [ 1 ];
$sub_action = varset ( $tmp [ 0 ], '' );
2006-12-02 04:36:16 +00:00
}
2007-06-07 20:34:02 +00:00
2008-12-03 12:38:08 +00:00
if ( $action == 'all' || $action == 'cat' )
2007-06-07 20:34:02 +00:00
{
2011-11-29 14:16:24 +00:00
$sub_action = intval ( varset ( $tmp [ 1 ], 0 ));
2006-12-02 04:36:16 +00:00
}
2007-06-07 20:34:02 +00:00
/*
Variables Used :
2011-11-29 14:16:24 +00:00
$action - the basic display format / filter
$sub_action - category number or news item number
$newsfrom - first item number in list ( default 0 ) - derived from nextprev
$order - sets the listing order for 'list' format
2007-06-07 20:34:02 +00:00
*/
2006-12-02 04:36:16 +00:00
$ix = new news ;
$nobody_regexp = " '(^|,)( " . str_replace ( " , " , " | " , e_UC_NOBODY ) . " )(,| $ )' " ;
2011-11-29 14:16:24 +00:00
// URL settings (nextprev)
$newsUrlparms = array ( 'page' => '--FROM--' );
if ( $sub_action )
{
switch ( $action )
{
case 'list' :
$newsUrlparms [ 'id' ] = $sub_action ;
$newsRoute = 'list/category' ;
break ;
case 'cat' :
$newsUrlparms [ 'id' ] = $sub_action ;
$newsRoute = 'list/short' ;
break ;
2011-11-30 15:14:02 +00:00
case 'day' :
case 'month' :
$newsUrlparms [ 'id' ] = $sub_action ;
$newsRoute = 'list/' . $action ;
break ;
2011-11-29 14:16:24 +00:00
default :
$newsRoute = 'list/items' ;
break ;
}
}
else $newsRoute = 'list/items' ;
$newsRoute = 'news/' . $newsRoute ;
2007-06-07 20:34:02 +00:00
//------------------------------------------------------
// DISPLAY NEWS IN 'CATEGORY' FORMAT HERE
//------------------------------------------------------
// Just title and a few other details
if ( $action == 'cat' || $action == 'all' )
{ // --> Cache
2008-11-29 15:35:31 +00:00
if ( $newsCachedPage = checkCache ( $cacheString ))
2007-06-07 20:34:02 +00:00
{
2006-12-02 04:36:16 +00:00
require_once ( HEADERF );
2008-11-29 15:35:31 +00:00
renderCache ( $newsCachedPage , TRUE );
2006-12-02 04:36:16 +00:00
}
// <-- Cache
2007-06-07 20:34:02 +00:00
$category = intval ( $sub_action );
2008-12-03 12:38:08 +00:00
if ( $action == 'cat' && $category != 0 )
2007-06-07 20:34:02 +00:00
{
2006-12-02 04:36:16 +00:00
$gen = new convert ;
2010-01-06 20:14:45 +00:00
$sql -> db_Select ( " news_category " , " * " , " category_id=' { $category } ' " );
2006-12-02 04:36:16 +00:00
$row = $sql -> db_Fetch ();
extract ( $row ); // still required for the table-render. :(
}
2007-06-07 20:34:02 +00:00
if ( $action == 'all' )
{
if ( ! defined ( " NEWSALL_LIMIT " )) { define ( " NEWSALL_LIMIT " , 10 ); }
2006-12-02 04:36:16 +00:00
// show archive of all news items using list-style template.
2007-02-07 01:20:47 +00:00
$news_total = $sql -> db_Count ( " news " , " (*) " , " WHERE news_class REGEXP ' " . e_CLASS_REGEXP . " ' AND NOT (news_class REGEXP " . $nobody_regexp . " ) AND news_start < " . time () . " AND (news_end=0 || news_end> " . time () . " ) " );
2009-09-14 18:22:16 +00:00
$query = "
2010-02-10 21:53:56 +00:00
SELECT n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name , nc . category_icon ,
nc . category_meta_keywords , nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
2009-09-14 18:22:16 +00:00
FROM #news AS n
2006-12-02 04:36:16 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
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(). "
2008-12-03 12:38:08 +00:00
AND ( n . news_end = 0 || n . news_end > " .time(). " )
ORDER BY n . news_sticky DESC , n . news_datestamp DESC
2007-06-07 20:34:02 +00:00
LIMIT " .intval( $newsfrom ). " , " .NEWSALL_LIMIT;
2006-12-02 04:36:16 +00:00
$category_name = " All " ;
}
2007-06-07 20:34:02 +00:00
elseif ( $action == 'cat' )
{
2006-12-02 04:36:16 +00:00
// show archive of all news items in a particular category using list-style template.
$news_total = $sql -> db_Count ( " news " , " (*) " , " WHERE news_class REGEXP ' " . e_CLASS_REGEXP . " ' AND NOT (news_class REGEXP " . $nobody_regexp . " ) AND news_start < " . time () . " AND (news_end=0 || news_end> " . time () . " ) AND news_category= " . intval ( $sub_action ));
2007-06-07 20:34:02 +00:00
if ( ! defined ( " NEWSLIST_LIMIT " )) { define ( " NEWSLIST_LIMIT " , 10 ); }
2009-09-14 18:22:16 +00:00
$query = "
SELECT n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name , nc . category_icon , nc . category_meta_keywords ,
2010-02-10 21:53:56 +00:00
nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
2009-09-14 18:22:16 +00:00
FROM #news AS n
2006-12-02 04:36:16 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
2009-09-14 18:22:16 +00:00
WHERE n . news_category = " .intval( $sub_action ). "
2008-12-03 12:38:08 +00:00
AND n . news_start < " .time(). " AND ( n . news_end = 0 || n . news_end > " .time(). " )
2009-09-14 18:22:16 +00:00
AND n . news_class REGEXP '".e_CLASS_REGEXP."' AND NOT ( n . news_class REGEXP " . $nobody_regexp . " )
2008-12-03 12:38:08 +00:00
ORDER BY n . news_datestamp DESC
2007-06-07 20:34:02 +00:00
LIMIT " .intval( $newsfrom ). " , " .NEWSLIST_LIMIT;
2006-12-02 04:36:16 +00:00
}
2010-02-10 21:53:56 +00:00
2009-09-14 18:22:16 +00:00
$newsList = array ();
if ( $sql -> db_Select_gen ( $query ))
{
$newsList = $sql -> db_getList ();
}
2010-02-10 21:53:56 +00:00
2009-09-14 18:22:16 +00:00
if ( $action == 'cat' ) setNewsFrontMeta ( $newsList [ 1 ], 'category' );
elseif ( $category_name )
2007-06-07 20:34:02 +00:00
{
2009-12-30 21:04:11 +00:00
define ( 'e_PAGETITLE' , $tp -> toHTML ( $category_name , FALSE , 'TITLE' ));
2006-12-02 04:36:16 +00:00
}
2011-11-29 12:09:05 +00:00
$currentNewsAction = $action ;
2006-12-02 04:36:16 +00:00
require_once ( HEADERF );
2011-11-29 12:09:05 +00:00
$action = $currentNewsAction ;
2006-12-02 04:36:16 +00:00
2007-06-07 20:34:02 +00:00
if ( ! $NEWSLISTSTYLE )
{
2006-12-02 04:36:16 +00:00
$NEWSLISTSTYLE = "
< div style = 'padding:3px;width:100%' >
< table style = 'border-bottom:1px solid black;width:100%' cellpadding = '0' cellspacing = '0' >
< tr >
< td style = 'vertical-align:top;padding:3px;width:20px' >
{ NEWSCATICON }
</ td >< td style = 'text-align:left;padding:3px' >
2007-11-08 21:06:03 +00:00
{ NEWSTITLELINK = extend }
2006-12-02 04:36:16 +00:00
< br />
{ NEWSSUMMARY }
< span class = 'smalltext' >
{ NEWSDATE }
{ NEWSCOMMENTS }
</ span >
</ td >< td style = 'width:55px' >
{ NEWSTHUMBNAIL }
</ td ></ tr ></ table >
</ div > \n " ;
}
2010-02-10 21:53:56 +00:00
2009-09-14 18:22:16 +00:00
$param = array ();
2006-12-02 04:36:16 +00:00
$param [ 'itemlink' ] = ( defined ( " NEWSLIST_ITEMLINK " )) ? NEWSLIST_ITEMLINK : " " ;
$param [ 'thumbnail' ] = ( defined ( " NEWSLIST_THUMB " )) ? NEWSLIST_THUMB : " border:0px " ;
$param [ 'catlink' ] = ( defined ( " NEWSLIST_CATLINK " )) ? NEWSLIST_CATLINK : " " ;
$param [ 'caticon' ] = ( defined ( " NEWSLIST_CATICON " )) ? NEWSLIST_CATICON : ICONSTYLE ;
2009-09-14 18:22:16 +00:00
$param [ 'current_action' ] = $action ;
2011-11-29 14:16:24 +00:00
2010-04-25 15:04:53 +00:00
// NEW - allow news batch shortcode override (e.g. e107::getScBatch('news', 'myplugin', true); )
e107 :: getEvent () -> trigger ( 'news_list_parse' , $newsList );
2011-11-29 14:16:24 +00:00
2006-12-02 04:36:16 +00:00
foreach ( $newsList as $row )
{
2011-11-29 14:16:24 +00:00
$text .= $ix -> render_newsitem ( $row , 'return' , '' , $NEWSLISTSTYLE , $param );
2006-12-02 04:36:16 +00:00
}
$icon = ( $row [ 'category_icon' ]) ? " <img src=' " . e_IMAGE . " icons/ " . $row [ 'category_icon' ] . " ' alt='' /> " : " " ;
2008-12-02 23:44:19 +00:00
2011-11-29 14:16:24 +00:00
// Deprecated.
2011-06-17 01:13:05 +00:00
// $parms = $news_total.",".$amount.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action={$action}&subaction={$category}");
2011-11-29 14:16:24 +00:00
// $parms = $news_total.",".$amount.",".$newsfrom.",".e_SELF.'?'.$action.".".$category.".[FROM]";
//
// $text .= "<div class='nextprev'>".$tp->parseTemplate("{NEXTPREV={$parms}}")."</div>";
$amount = ( $action == " all " ) ? NEWSALL_LIMIT : NEWSLIST_LIMIT ;
$nitems = defined ( 'NEWS_NEXTPREV_NAVCOUNT' ) ? '&navcount=' . NEWS_NEXTPREV_NAVCOUNT : '' ;
$url = rawurlencode ( e107 :: getUrl () -> create ( $newsRoute , $newsUrlparms ));
$parms = 'tmpl_prefix=' . deftrue ( 'NEWS_NEXTPREV_TMPL' , 'default' ) . '&total=' . $news_total . '&amount=' . $amount . '¤t=' . $newsfrom . $nitems . '&url=' . $url ;
$text .= $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
2006-12-02 04:36:16 +00:00
2011-11-29 14:16:24 +00:00
if ( ! $NEWSLISTTITLE )
2007-06-07 20:34:02 +00:00
{
2009-12-30 21:04:11 +00:00
$NEWSLISTTITLE = LAN_NEWS_82 . " ' " . $tp -> toHTML ( $category_name , FALSE , 'TITLE' ) . " ' " ;
2007-11-08 21:06:03 +00:00
}
else
{
2011-11-29 14:16:24 +00:00
$NEWSLISTTITLE = str_replace ( " { NEWSCATEGORY} " , $tp -> toHTML ( $category_name , FALSE , 'TITLE' ), $NEWSLISTTITLE );
2006-12-02 04:36:16 +00:00
}
2010-04-05 21:35:09 +00:00
$text .= " <div style='text-align:center;'><a href=' " . e_SELF . " '> " . LAN_NEWS_84 . " </a></div> " ;
2006-12-02 04:36:16 +00:00
ob_start ();
2011-11-29 16:07:12 +00:00
$ns -> tablerender ( $NEWSLISTTITLE , $text , 'news' );
2006-12-02 04:36:16 +00:00
$cache_data = ob_get_flush ();
setNewsCache ( $cacheString , $cache_data );
require_once ( FOOTERF );
exit ;
}
2007-06-07 20:34:02 +00:00
//------------------------------------------------------
// DISPLAY SINGLE ITEM IN EXTENDED FORMAT HERE
//------------------------------------------------------
2010-02-10 21:53:56 +00:00
if ( $action == 'extend' )
2007-06-07 20:34:02 +00:00
{ // --> Cache
2008-11-29 15:35:31 +00:00
if ( $newsCachedPage = checkCache ( $cacheString ))
2007-11-08 21:06:03 +00:00
{
2011-11-29 14:16:24 +00:00
require_once ( HEADERF );
2010-01-06 20:14:45 +00:00
renderCache ( $newsCachedPage , TRUE ); // This exits if cache used
2006-12-02 04:36:16 +00:00
}
// <-- Cache
2008-12-03 12:38:08 +00:00
if ( isset ( $pref [ 'trackbackEnabled' ]) && $pref [ 'trackbackEnabled' ])
2007-10-15 19:16:04 +00:00
{
2011-11-29 14:16:24 +00:00
$query = "
2010-02-10 21:53:56 +00:00
SELECT COUNT ( tb . trackback_pid ) AS tb_count , n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name ,
nc . category_icon , nc . category_meta_keywords , nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
2009-09-14 18:22:16 +00:00
FROM #news AS n
2007-10-15 19:16:04 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id
2008-12-03 12:38:08 +00:00
WHERE n . news_id = " .intval( $sub_action ). " AND 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(). " )
2007-11-08 21:06:03 +00:00
GROUP by n . news_id " ;
2007-10-15 19:16:04 +00:00
}
else
{
2011-11-29 14:16:24 +00:00
$query = "
2010-02-10 21:53:56 +00:00
SELECT n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name , nc . category_icon , nc . category_meta_keywords ,
2009-09-14 18:22:16 +00:00
nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
FROM #news AS n
2006-12-02 04:36:16 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
2010-02-10 21:53:56 +00:00
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(). " )
2009-09-14 18:22:16 +00:00
AND n . news_id = " .intval( $sub_action );
2007-10-15 19:16:04 +00:00
}
2009-10-31 15:02:02 +00:00
if ( $sql -> db_Select_gen ( $query ))
2009-09-14 18:22:16 +00:00
{
2009-10-31 15:02:02 +00:00
$news = $sql -> db_Fetch ();
2010-01-06 20:14:45 +00:00
$id = $news [ 'news_category' ]; // Use category of this news item to generate next/prev links
2010-02-10 21:53:56 +00:00
2009-10-31 15:02:02 +00:00
//***NEW [SecretR] - comments handled inside now
e107 :: setRegistry ( 'news/page_allow_comments' , ! $news [ 'news_allow_comments' ]);
if ( ! $news [ 'news_allow_comments' ] && isset ( $_POST [ 'commentsubmit' ]))
{
$pid = intval ( varset ( $_POST [ 'pid' ], 0 )); // ID of the specific comment being edited (nested comments - replies)
2010-02-10 21:53:56 +00:00
2009-10-31 15:02:02 +00:00
$clean_authorname = $_POST [ 'author_name' ];
$clean_comment = $_POST [ 'comment' ];
$clean_subject = $_POST [ 'subject' ];
2010-02-10 21:53:56 +00:00
2009-10-31 15:02:02 +00:00
e107 :: getSingleton ( 'comment' ) -> enter_comment ( $clean_authorname , $clean_comment , 'news' , $sub_action , $pid , $clean_subject );
}
2010-02-10 21:53:56 +00:00
2009-10-31 15:02:02 +00:00
//More SEO
setNewsFrontMeta ( $news );
/*
if ( $news [ 'news_title' ])
{
2011-11-29 14:16:24 +00:00
if ( $pref [ 'meta_news_summary' ] && $news [ 'news_title' ])
{
define ( " META_DESCRIPTION " , SITENAME . " : " . $news [ 'news_title' ] . " - " . $news [ 'news_summary' ]);
}
define ( " e_PAGETITLE " , $news [ 'news_title' ]);
2009-10-31 15:02:02 +00:00
} */
2010-03-16 13:43:30 +00:00
/* FIXME - better implementation : cache , shortcodes , do it inside the model / shortcode class itself .
2010-01-06 20:14:45 +00:00
if ( TRUE )
{
2011-11-29 14:16:24 +00:00
// Added by nlStart - show links to previous and next news
if ( ! isset ( $news [ 'news_extended' ])) $news [ 'news_extended' ] = '' ;
$news [ 'news_extended' ] .= " <div style='text-align:center;'><a href=' " . e_SELF . " ?cat. " . $id . " '> " . LAN_NEWS_85 . " </a> <a href=' " . e_SELF . " '> " . LAN_NEWS_84 . " </a></div> " ;
$prev_query = " SELECT news_id, news_title FROM `#news`
WHERE `news_id` < " .intval( $sub_action ). " AND `news_category` = " . $id . " AND `news_class` REGEXP '".e_CLASS_REGEXP."'
AND NOT ( `news_class` REGEXP " . $nobody_regexp . " )
AND `news_start` < " .time(). " AND ( `news_end` = 0 || `news_end` > " .time().') ORDER BY `news_id` DESC LIMIT 1';
$sql -> db_Select_gen ( $prev_query );
$prev_news = $sql -> db_Fetch ();
if ( $prev_news )
{
$news [ 'news_extended' ] .= " <div style='float:right;'><a href=' " . e_SELF . " ?extend. " . $prev_news [ 'news_id' ] . " '> " . LAN_NEWS_86 . " </a></div> " ;
}
$next_query = " SELECT news_id, news_title FROM `#news` AS n
WHERE `news_id` > " .intval( $sub_action ). " AND `news_category` = " . $id . " AND `news_class` REGEXP '".e_CLASS_REGEXP."'
AND NOT ( `news_class` REGEXP " . $nobody_regexp . " )
AND `news_start` < " .time(). " AND ( `news_end` = 0 || `news_end` > " .time().') ORDER BY `news_id` ASC LIMIT 1';
$sql -> db_Select_gen ( $next_query );
$next_news = $sql -> db_Fetch ();
if ( $next_news )
{
$news [ 'news_extended' ] .= " <div style='float:left;'><a href=' " . e_SELF . " ?extend. " . $next_news [ 'news_id' ] . " '> " . LAN_NEWS_87 . " </a></div> " ;
}
$news [ 'news_extended' ] .= " <br /><br /> " ;
2010-03-16 13:43:30 +00:00
} */
2010-01-06 20:14:45 +00:00
2011-11-29 12:09:05 +00:00
$currentNewsAction = $action ;
2009-10-31 15:02:02 +00:00
require_once ( HEADERF );
2011-11-29 12:09:05 +00:00
$action = $currentNewsAction ;
2010-02-10 21:53:56 +00:00
2009-10-31 15:02:02 +00:00
$param = array ();
$param [ 'current_action' ] = $action ;
2010-02-10 21:53:56 +00:00
2009-10-31 15:02:02 +00:00
ob_start ();
$ix -> render_newsitem ( $news , 'extend' , '' , '' , $param );
if ( e107 :: getRegistry ( 'news/page_allow_comments' ))
{
global $comment_edit_query ; //FIXME - kill me
$comment_edit_query = 'comment.news.' . $news [ 'news_id' ];
e107 :: getSingleton ( 'comment' ) -> compose_comment ( 'news' , 'comment' , $news [ 'news_id' ], null , $news [ 'news_title' ], FALSE );
}
$cache_data = ob_get_contents ();
ob_end_flush ();
setNewsCache ( $cacheString , $cache_data );
require_once ( FOOTERF );
exit ;
}
else
2009-09-14 18:22:16 +00:00
{
2009-10-31 15:02:02 +00:00
$action = 'default' ;
2009-09-14 18:22:16 +00:00
}
2006-12-02 04:36:16 +00:00
}
2007-06-07 20:34:02 +00:00
//------------------------------------------------------
// DISPLAY NEWS IN LIST FORMAT HERE
//------------------------------------------------------
// Show title, author, first part of news item...
if ( empty ( $order ))
{
2011-11-29 14:16:24 +00:00
$order = 'news_datestamp' ;
2006-12-02 04:36:16 +00:00
}
2010-09-06 12:34:06 +00:00
$order = $tp -> toDB ( $order , true ); /// @todo - try not to use toDB() - triggers prefilter
2006-12-02 04:36:16 +00:00
2007-05-21 19:19:03 +00:00
$interval = $pref [ 'newsposts' ];
2007-06-07 20:34:02 +00:00
switch ( $action )
{
2011-11-29 14:16:24 +00:00
case " list " :
$sub_action = intval ( $sub_action );
// $news_total = $sql->db_Count("news", "(*)", "WHERE news_category={$sub_action} AND news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")");
$query = "
2010-02-10 21:53:56 +00:00
SELECT SQL_CALC_FOUND_ROWS n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name ,
2009-09-14 18:22:16 +00:00
nc . category_icon , nc . category_meta_keywords , nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
FROM #news AS n
2006-12-02 04:36:16 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
2008-12-03 12:38:08 +00:00
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 n . news_category = { $sub_action }
2007-06-07 20:34:02 +00:00
ORDER BY n . news_sticky DESC , " . $order . " DESC LIMIT " .intval( $newsfrom ). " , " .ITEMVIEW;
2011-11-29 14:16:24 +00:00
break ;
2007-02-07 01:20:47 +00:00
2007-06-07 20:34:02 +00:00
2011-11-29 14:16:24 +00:00
case " item " :
$sub_action = intval ( $sub_action );
$news_total = 1 ;
if ( isset ( $pref [ 'trackbackEnabled' ]) && $pref [ 'trackbackEnabled' ])
{
$query = "
2010-02-10 21:53:56 +00:00
SELECT COUNT ( tb . trackback_pid ) AS tb_count , n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name ,
2009-09-14 18:22:16 +00:00
nc . category_icon , nc . category_meta_keywords , nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
FROM #news AS n
2006-12-02 04:36:16 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
2007-12-11 20:38:56 +00:00
LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id
2008-12-03 12:38:08 +00:00
WHERE n . news_id = { $sub_action } AND n . news_class REGEXP '".e_CLASS_REGEXP."' AND NOT ( n . news_class REGEXP " . $nobody_regexp . " )
2007-12-11 20:38:56 +00:00
AND n . news_start < " .time(). " AND ( n . news_end = 0 || n . news_end > " .time(). " )
GROUP by n . news_id " ;
2011-11-29 14:16:24 +00:00
}
else
{
$query = "
2009-09-14 18:22:16 +00:00
SELECT n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name , nc . category_icon ,
nc . category_meta_keywords , nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
FROM #news AS n
2007-12-11 20:38:56 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
2008-12-03 12:38:08 +00:00
WHERE n . news_id = { $sub_action } AND n . news_class REGEXP '".e_CLASS_REGEXP."' AND NOT ( n . news_class REGEXP " . $nobody_regexp . " )
2007-12-11 20:38:56 +00:00
AND n . news_start < " .time(). " AND ( n . news_end = 0 || n . news_end > " .time(). " ) " ;
2011-11-29 14:16:24 +00:00
}
break ;
case " month " :
case " day " :
$item = $tp -> toDB ( $sub_action ) . '20000101' ;
$year = substr ( $item , 0 , 4 );
$month = substr ( $item , 4 , 2 );
if ( $action == 'day' )
{
$day = substr ( $item , 6 , 2 );
$lastday = $day ;
}
else
{ // A month's worth
$day = 1 ;
$lastday = date ( " t " , $startdate );
}
$startdate = mktime ( 0 , 0 , 0 , $month , $day , $year );
$enddate = mktime ( 23 , 59 , 59 , $month , $lastday , $year );
$query = "
2010-02-10 21:53:56 +00:00
SELECT SQL_CALC_FOUND_ROWS n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name ,
2009-09-14 18:22:16 +00:00
nc . category_icon , nc . category_meta_keywords , nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
FROM #news AS n
2006-12-02 04:36:16 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
2008-12-03 12:38:08 +00:00
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 n . news_render_type < 2 AND n . news_datestamp > { $startdate } AND n . news_datestamp < { $enddate }
2007-06-07 20:34:02 +00:00
ORDER BY " . $order . " DESC LIMIT " .intval( $newsfrom ). " , " .ITEMVIEW;
2011-11-29 14:16:24 +00:00
break ;
2007-06-07 20:34:02 +00:00
2011-11-29 14:16:24 +00:00
case 'default' :
default :
$action = '' ;
$cacheString = 'news.php_default_' ; // Make sure its sensible
// $news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().") AND news_render_type<2" );
2006-12-02 04:36:16 +00:00
2011-11-29 14:16:24 +00:00
if ( ! isset ( $pref [ 'newsposts_archive' ]))
{
$pref [ 'newsposts_archive' ] = 0 ;
}
$interval = $pref [ 'newsposts' ] - $pref [ 'newsposts_archive' ]; // Number of 'full' posts to show
2006-12-02 04:36:16 +00:00
2011-11-29 14:16:24 +00:00
// Get number of news item to show
if ( isset ( $pref [ 'trackbackEnabled' ]) && $pref [ 'trackbackEnabled' ]) {
$query = "
2010-02-10 21:53:56 +00:00
SELECT SQL_CALC_FOUND_ROWS COUNT ( tb . trackback_pid ) AS tb_count , n .* , u . user_id , u . user_name , u . user_customtitle ,
nc . category_name , nc . category_icon , nc . category_meta_keywords , nc . category_meta_description ,
2009-09-14 18:22:16 +00:00
COUNT ( * ) AS tbcount { $rewrite_cols_cat }{ $rewrite_cols }
FROM #news AS n
2006-12-02 04:36:16 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id
2007-06-07 20:34:02 +00:00
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(). " )
2006-12-02 04:36:16 +00:00
AND n . news_render_type < 2
GROUP by n . news_id
2007-03-24 18:47:43 +00:00
ORDER BY news_sticky DESC , " . $order . " DESC LIMIT " .intval( $newsfrom ). " , " . $pref['newsposts'] ;
2011-11-29 14:16:24 +00:00
}
else
{
$query = "
2010-02-10 21:53:56 +00:00
SELECT SQL_CALC_FOUND_ROWS n .* , u . user_id , u . user_name , u . user_customtitle , nc . category_name , nc . category_icon ,
2009-09-14 18:22:16 +00:00
nc . category_meta_keywords , nc . category_meta_description { $rewrite_cols_cat }{ $rewrite_cols }
FROM #news AS n
2006-12-02 04:36:16 +00:00
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
2007-06-07 20:34:02 +00:00
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(). " )
2006-12-02 04:36:16 +00:00
AND n . news_render_type < 2
2007-03-24 18:47:43 +00:00
ORDER BY n . news_sticky DESC , " . $order . " DESC LIMIT " .intval( $newsfrom ). " , " . $pref['newsposts'] ;
2011-11-29 14:16:24 +00:00
}
2007-06-07 20:34:02 +00:00
} // END - switch($action)
2006-12-02 04:36:16 +00:00
2008-11-29 15:35:31 +00:00
if ( $newsCachedPage = checkCache ( $cacheString )) // normal news front-page - with cache.
2006-12-02 04:36:16 +00:00
{
require_once ( HEADERF );
if ( ! $action )
{
2009-12-12 16:40:41 +00:00
// Removed, themes should use {FEATUREBOX} shortcode instead
2011-11-29 14:16:24 +00:00
// if (isset($pref['fb_active']))
// {
// require_once(e_PLUGIN."featurebox/featurebox.php");
// }
2011-11-29 16:07:12 +00:00
// Removed, legacy
// if (isset($pref['nfp_display']) && $pref['nfp_display'] == 1)
// {
// require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php");
// }
2006-12-02 04:36:16 +00:00
}
//news archive
if ( $action != " item " && $action != 'list' && $pref [ 'newsposts_archive' ]) {
if ( $sql -> db_Select_gen ( $query )) {
$newsAr = $sql -> db_getList ();
if ( $newsarchive = checkCache ( 'newsarchive' )){
2008-11-29 15:35:31 +00:00
$newsCachedPage = $newsCachedPage . $newsarchive ;
2006-12-02 04:36:16 +00:00
} else {
2007-06-07 20:34:02 +00:00
show_newsarchive ( $newsAr , $interval );
2006-12-02 04:36:16 +00:00
}
}
}
2008-11-29 15:35:31 +00:00
renderCache ( $newsCachedPage , TRUE );
2006-12-02 04:36:16 +00:00
}
2008-12-03 12:38:08 +00:00
if ( ! ( $news_total = $sql -> db_Select_gen ( $query )))
2007-06-07 20:34:02 +00:00
{ // No news items
2011-11-29 14:16:24 +00:00
require_once ( HEADERF );
echo " <br /><br /><div style='text-align:center'><b> " . ( strstr ( e_QUERY , " month " ) ? LAN_NEWS_462 : LAN_NEWS_83 ) . " </b></div><br /><br /> " ;
require_once ( FOOTERF );
exit ;
2008-12-03 12:38:08 +00:00
}
2007-06-07 20:34:02 +00:00
$newsAr = $sql -> db_getList ();
2008-12-02 20:51:52 +00:00
$news_total = $sql -> total_results ;
2007-10-15 19:16:04 +00:00
// Get number of entries
2008-12-02 20:51:52 +00:00
//$sql -> db_Select_gen("SELECT FOUND_ROWS()");
2007-06-07 20:34:02 +00:00
$frows = $sql -> db_Fetch ();
2008-12-02 20:51:52 +00:00
//$news_total = $frows[0];
2006-12-02 04:36:16 +00:00
2007-06-07 20:34:02 +00:00
//echo "<br />Total ".$news_total." items found, ".count($newsAr)." displayed, Interval = {$interval}<br /><br />";
2006-12-02 04:36:16 +00:00
2009-12-30 21:04:11 +00:00
$p_title = ( $action == " item " ) ? $newsAr [ 1 ][ 'news_title' ] : $tp -> toHTML ( $newsAr [ 1 ][ 'category_name' ], FALSE , 'TITLE' );
2006-12-02 04:36:16 +00:00
2009-09-14 18:22:16 +00:00
switch ( $action )
{
case 'item' :
setNewsFrontMeta ( $newsAr [ 1 ]);
2011-11-29 14:16:24 +00:00
break ;
2009-09-14 18:22:16 +00:00
case 'list' :
setNewsFrontMeta ( $newsAr [ 1 ], 'category' );
2011-11-29 14:16:24 +00:00
break ;
2009-09-14 18:22:16 +00:00
}
/* if ( $action != " " && ! is_numeric ( $action ))
2006-12-02 04:36:16 +00:00
{
2011-11-29 14:16:24 +00:00
if ( $action == " item " && $pref [ 'meta_news_summary' ] && $newsAr [ 1 ][ 'news_title' ])
{
define ( " META_DESCRIPTION " , SITENAME . " : " . $newsAr [ 1 ][ 'news_title' ] . " - " . $newsAr [ 1 ][ 'news_summary' ]);
}
define ( " e_PAGETITLE " , $p_title );
2009-09-14 18:22:16 +00:00
} */
2006-12-02 04:36:16 +00:00
2011-11-29 12:09:05 +00:00
$currentNewsAction = $action ;
2006-12-02 04:36:16 +00:00
require_once ( HEADERF );
2011-11-29 12:09:05 +00:00
$action = $currentNewsAction ;
2006-12-02 04:36:16 +00:00
if ( ! $action )
{
2009-12-12 16:40:41 +00:00
// Removed, themes should use {FEATUREBOX} shortcode instead
2011-11-29 14:16:24 +00:00
// if (isset($pref['fb_active'])){ // --->feature box
// require_once(e_PLUGIN."featurebox/featurebox.php");
// }
2006-12-02 04:36:16 +00:00
2011-11-29 16:07:12 +00:00
// Removed, legacy
// if (isset($pref['nfp_display']) && $pref['nfp_display'] == 1){
// require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php");
// }
2006-12-02 04:36:16 +00:00
}
2008-12-03 12:38:08 +00:00
if ( isset ( $pref [ 'news_unstemplate' ]) && $pref [ 'news_unstemplate' ] && file_exists ( THEME . " news_template.php " ))
2007-06-07 20:34:02 +00:00
{
2006-12-02 04:36:16 +00:00
// theme specific template required ...
require_once ( THEME . " news_template.php " );
2007-06-07 20:34:02 +00:00
if ( $ALTERNATECLASS1 )
{
2011-11-29 14:16:24 +00:00
return TRUE ;
2006-12-02 04:36:16 +00:00
}
$newscolumns = ( isset ( $NEWSCOLUMNS ) ? $NEWSCOLUMNS : 1 );
$newspercolumn = ( isset ( $NEWSITEMSPERCOLUMN ) ? $NEWSITEMSPERCOLUMN : 10 );
$newsdata = array ();
$loop = 1 ;
2009-09-14 18:22:16 +00:00
$param = array ();
$param [ 'current_action' ] = $action ;
2006-12-02 04:36:16 +00:00
foreach ( $newsAr as $news ) {
if ( is_array ( $ALTERNATECLASSES )) {
2011-11-29 12:09:05 +00:00
$newsdata [ $loop ] .= " <div class=' { $ALTERNATECLASSES [ 0 ] } '> " . $ix -> render_newsitem ( $news , " return " , '' , '' , $param ) . " </div> " ;
2006-12-02 04:36:16 +00:00
$ALTERNATECLASSES = array_reverse ( $ALTERNATECLASSES );
} else {
2009-09-14 18:22:16 +00:00
$newsdata [ $loop ] .= $ix -> render_newsitem ( $news , 'return' , '' , '' , $param );
2006-12-02 04:36:16 +00:00
}
$loop ++ ;
if ( $loop > $newscolumns ) {
$loop = 1 ;
}
}
$loop = 1 ;
foreach ( $newsdata as $data ) {
$var = " ITEMS { $loop } " ;
$$var = $data ;
$loop ++ ;
}
$text = preg_replace ( " / \ { (.*?) \ }/e " , '$\1' , $NEWSCLAYOUT );
require_once ( HEADERF );
2011-06-17 01:13:05 +00:00
// Deprecated
// $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action=".($action ? $action : 'default' )."&subaction=".($sub_action ? $sub_action : "0"));
2011-11-29 14:16:24 +00:00
$sub_action = intval ( $sub_action );
// $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]";
$amount = ITEMVIEW ;
$nitems = defined ( 'NEWS_NEXTPREV_NAVCOUNT' ) ? '&navcount=' . NEWS_NEXTPREV_NAVCOUNT : '' ;
$url = rawurlencode ( e107 :: getUrl () -> create ( $newsRoute , $newsUrlparms ));
$parms = 'tmpl_prefix=' . deftrue ( 'NEWS_NEXTPREV_TMPL' , 'default' ) . '&total=' . $news_total . '&amount=' . $amount . '¤t=' . $newsfrom . $nitems . '&url=' . $url ;
$text .= $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
// $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
// $text .= ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : "");
// $text=''.$text.'<center>'.$nextprev.'</center>';
echo $text ;
setNewsCache ( $cacheString , $text );
2008-12-03 12:38:08 +00:00
}
else
2007-06-07 20:34:02 +00:00
{
2006-12-02 04:36:16 +00:00
ob_start ();
$newpostday = 0 ;
$thispostday = 0 ;
$pref [ 'newsHeaderDate' ] = 1 ;
$gen = new convert ();
if ( ! defined ( " DATEHEADERCLASS " )) {
define ( " DATEHEADERCLASS " , " nextprev " );
// if not defined in the theme, default class nextprev will be used for new date header
}
// #### normal newsitems, rendered via render_newsitem(), the $query is changed above (no other changes made) ---------
2009-09-14 18:22:16 +00:00
$param = array ();
$param [ 'current_action' ] = $action ;
2011-11-29 16:07:12 +00:00
// NEW - news category title when in list
2011-11-30 15:14:02 +00:00
if ( $sub_action && 'list' == $action && vartrue ( $newsAr [ 1 ][ 'category_name' ]))
2011-11-29 16:07:12 +00:00
{
2011-11-30 15:14:02 +00:00
// we know category name - pass it to the nexprev url
$category_name = $newsUrlparms [ 'name' ] = $newsAr [ 1 ][ 'category_name' ];
2011-11-29 16:07:12 +00:00
if ( ! isset ( $NEWSLISTCATTITLE ))
{
$NEWSLISTCATTITLE = " <h1 class='newscatlist-title'> " . $tp -> toHTML ( $category_name , FALSE , 'TITLE' ) . " </h1> " ;
}
else
{
$NEWSLISTCATTITLE = str_replace ( " { NEWSCATEGORY} " , $tp -> toHTML ( $category_name , FALSE , 'TITLE' ), $NEWSLISTCATTITLE );
}
echo $NEWSLISTCATTITLE ;
}
2010-02-10 21:53:56 +00:00
2006-12-02 04:36:16 +00:00
$i = 1 ;
while ( isset ( $newsAr [ $i ]) && $i <= $interval ) {
$news = $newsAr [ $i ];
// render new date header if pref selected ...
$thispostday = strftime ( " %j " , $news [ 'news_datestamp' ]);
2008-12-03 12:38:08 +00:00
if ( $newpostday != $thispostday && ( isset ( $pref [ 'news_newdateheader' ]) && $pref [ 'news_newdateheader' ]))
2007-06-07 20:34:02 +00:00
{
2011-11-29 14:16:24 +00:00
echo " <div class=' " . DATEHEADERCLASS . " '> " . strftime ( " %A %d %B %Y " , $news [ 'news_datestamp' ]) . " </div> " ;
2006-12-02 04:36:16 +00:00
}
$newpostday = $thispostday ;
$news [ 'category_id' ] = $news [ 'news_category' ];
2008-12-03 12:38:08 +00:00
if ( $action == " item " )
2007-06-07 20:34:02 +00:00
{
2011-11-29 14:16:24 +00:00
unset ( $news [ 'news_render_type' ]);
2006-12-02 04:36:16 +00:00
}
2009-09-14 18:22:16 +00:00
$ix -> render_newsitem ( $news , 'default' , '' , '' , $param );
2006-12-02 04:36:16 +00:00
$i ++ ;
}
2008-12-02 23:44:19 +00:00
2011-11-29 14:16:24 +00:00
$amount = ITEMVIEW ;
$nitems = defined ( 'NEWS_NEXTPREV_NAVCOUNT' ) ? '&navcount=' . NEWS_NEXTPREV_NAVCOUNT : '' ;
$url = rawurlencode ( e107 :: getUrl () -> create ( $newsRoute , $newsUrlparms ));
2011-11-30 15:14:02 +00:00
// Example of passing route data instead building the URL outside the shortcode - for a reference only
// $url = rawurlencode('url::'.$newsRoute.'::'.http_build_query($newsUrlparms, null, '&'));
2011-11-29 14:16:24 +00:00
$parms = 'tmpl_prefix=' . deftrue ( 'NEWS_NEXTPREV_TMPL' , 'default' ) . '&total=' . $news_total . '&amount=' . $amount . '¤t=' . $newsfrom . $nitems . '&url=' . $url ;
echo $tp -> parseTemplate ( " { NEXTPREV= { $parms } } " );
// $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]";
// $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
// echo ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : "");
2006-12-02 04:36:16 +00:00
$cache_data = ob_get_clean ();
require_once ( HEADERF );
echo $cache_data ;
setNewsCache ( $cacheString , $cache_data );
}
// ##### --------------------------------------------------------------------------------------------------------------
2007-06-07 20:34:02 +00:00
function show_newsarchive ( $newsAr , $i = 1 )
{
global $ns , $gen , $pref , $tp , $news_archive_shortcodes , $NEWSARCHIVE , $news2 ;
2006-12-02 04:36:16 +00:00
// do not show the news archive on the news.php?item.X page (but only on the news mainpage)
2010-02-10 21:53:56 +00:00
require_once ( e_CORE . 'shortcodes/batch/news_archives.php' );
2006-12-02 04:36:16 +00:00
2007-06-07 20:34:02 +00:00
$textnewsarchive = '' ;
2006-12-02 04:36:16 +00:00
ob_start ();
2007-06-07 20:34:02 +00:00
$i ++ ; // First entry to show
2006-12-02 04:36:16 +00:00
while ( isset ( $newsAr [ $i ]))
{
$news2 = $newsAr [ $i ];
// Code from Lisa
// copied from the rss creation, but added here to make sure the url for the newsitem is to the news.php?item.X
// instead of the actual hyperlink that may have been added to a newstitle on creation
$search = array ();
$replace = array ();
$search [ 0 ] = " / \ <a href= \" (.*?) \" >(.*?)< \ /a>/si " ;
$replace [ 0 ] = '\\2' ;
$search [ 1 ] = " / \ <a href='(.*?)'>(.*?)< \ /a>/si " ;
$replace [ 1 ] = '\\2' ;
$search [ 2 ] = " / \ <a href='(.*?)'>(.*?)< \ /a>/si " ;
$replace [ 2 ] = '\\2' ;
$search [ 3 ] = " / \ <a href="(.*?)">(.*?)< \ /a>/si " ;
$replace [ 3 ] = '\\2' ;
$search [ 4 ] = " / \ <a href='(.*?)'>(.*?)< \ /a>/si " ;
$replace [ 4 ] = '\\2' ;
$news2 [ 'news_title' ] = preg_replace ( $search , $replace , $news2 [ 'news_title' ]);
// End of code from Lisa
$gen = new convert ;
$news2 [ 'news_datestamp' ] = $gen -> convert_date ( $news2 [ 'news_datestamp' ], " short " );
if ( ! $NEWSARCHIVE ){
$NEWSARCHIVE = " <div>
< table style = 'width:98%;' >
< tr >
< td >
< div > { ARCHIVE_BULLET } < b > { ARCHIVE_LINK } </ b > < span class = 'smalltext' >< i > { ARCHIVE_AUTHOR } @ ({ ARCHIVE_DATESTAMP }) ({ ARCHIVE_CATEGORY }) </ i ></ span ></ div >
</ td >
</ tr >
</ table >
</ div > " ;
}
2007-06-07 20:34:02 +00:00
2006-12-02 04:36:16 +00:00
$textnewsarchive .= $tp -> parseTemplate ( $NEWSARCHIVE , FALSE , $news_archive_shortcodes );
$i ++ ;
}
$ns -> tablerender ( $pref [ 'newsposts_archive_title' ], $textnewsarchive , 'news_archive' );
$newsarchive = ob_get_contents ();
ob_end_flush (); // dump collected data
setNewsCache ( 'newsarchive' , $newsarchive );
}
// #### new: news archive ---------------------------------------------------------------------------------------------
2008-12-03 12:38:08 +00:00
if ( $action != " item " && $action != 'list' && $pref [ 'newsposts_archive' ])
2007-06-07 20:34:02 +00:00
{
2011-11-29 14:16:24 +00:00
show_newsarchive ( $newsAr , $interval );
2006-12-02 04:36:16 +00:00
}
// #### END -----------------------------------------------------------------------------------------------------------
if ( $action != " item " ) {
if ( is_numeric ( $action )){
$action = " " ;
}
2011-11-29 14:16:24 +00:00
// $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'."[FROM].".$action.(isset($sub_action) ? ".".$sub_action : "");
// $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
// echo ($nextprev ? "<div class='nextprev'>".$nextprev."</div>" : "");
2006-12-02 04:36:16 +00:00
}
if ( is_dir ( " remotefile " )) {
require_once ( e_HANDLER . " file_class.php " );
$file = new e_file ;
2011-11-29 14:16:24 +00:00
// $reject = array('$.','$..','/','CVS','thumbs.db','*._$', 'index', 'null*', 'Readme.txt');
// $crem = $file -> get_files(e_BASE."remotefile", "", $reject);
2008-11-20 20:35:24 +00:00
$crem = $file -> get_files ( e_BASE . " remotefile " , '~Readme\.txt' );
2006-12-02 04:36:16 +00:00
if ( count ( $crem )) {
foreach ( $crem as $loadrem ) {
if ( strstr ( $loadrem [ 'fname' ], " load_ " )) {
require_once ( e_BASE . " remotefile/ " . $loadrem [ 'fname' ]);
}
}
}
}
if ( isset ( $pref [ 'nfp_display' ]) && $pref [ 'nfp_display' ] == 2 ) {
require_once ( e_PLUGIN . " newforumposts_main/newforumposts_main.php " );
}
render_newscats ();
require_once ( FOOTERF );
// =========================================================================
function setNewsCache ( $cache_tag , $cache_data ) {
global $e107cache ;
$e107cache -> set ( $cache_tag , $cache_data );
$e107cache -> set ( $cache_tag . " _title " , defined ( " e_PAGETITLE " ) ? e_PAGETITLE : '' );
$e107cache -> set ( $cache_tag . " _diz " , defined ( " META_DESCRIPTION " ) ? META_DESCRIPTION : '' );
}
function checkCache ( $cacheString ){
global $pref , $e107cache ;
$cache_data = $e107cache -> retrieve ( $cacheString );
$cache_title = $e107cache -> retrieve ( $cacheString . " _title " );
$cache_diz = $e107cache -> retrieve ( $cacheString . " _diz " );
$etitle = ( $cache_title != " e_PAGETITLE " ) ? $cache_title : " " ;
$ediz = ( $cache_diz != " META_DESCRIPTION " ) ? $cache_diz : " " ;
if ( $etitle ){
define ( e_PAGETITLE , $etitle );
}
if ( $ediz ){
2011-11-29 14:16:24 +00:00
define ( " META_DESCRIPTION " , $ediz );
2006-12-02 04:36:16 +00:00
}
if ( $cache_data ) {
return $cache_data ;
} else {
return false ;
}
}
function renderCache ( $cache , $nfp = FALSE ){
global $pref , $tp , $sql , $CUSTOMFOOTER , $FOOTER , $cust_footer , $ph ;
2009-09-13 10:29:56 +00:00
global $db_debug , $ns , $eTimingStart , $error_handler , $db_time , $sql2 , $mySQLserver , $mySQLuser , $mySQLpassword , $mySQLdefaultdb , $e107 ;
2006-12-02 04:36:16 +00:00
echo $cache ;
2006-12-23 18:38:33 +00:00
if ( isset ( $nfp ) && isset ( $pref [ 'nfp_display' ]) && $pref [ 'nfp_display' ] == 2 ) {
2006-12-02 04:36:16 +00:00
require_once ( e_PLUGIN . " newforumposts_main/newforumposts_main.php " );
}
render_newscats ();
require_once ( FOOTERF );
exit ;
}
function render_newscats (){ // -- CNN Style Categories. ----
global $pref , $ns , $tp ;
if ( isset ( $pref [ 'news_cats' ]) && $pref [ 'news_cats' ] == '1' ) {
2009-12-30 21:04:11 +00:00
$text3 = $tp -> toHTML ( " { NEWS_CATEGORIES} " , TRUE , 'TITLE' );
2006-12-02 04:36:16 +00:00
$ns -> tablerender ( LAN_NEWS_23 , $text3 , 'news_cat' );
}
}
2009-09-14 18:22:16 +00:00
function setNewsFrontMeta ( $news , $type = 'news' )
{
if ( $type == 'news' )
{
if ( $news [ 'news_title' ] && ! defined ( 'e_PAGETITLE' ))
{
define ( 'e_PAGETITLE' , $news [ 'news_title' ]);
}
2010-02-10 21:53:56 +00:00
2009-09-14 18:22:16 +00:00
if ( $news [ 'news_meta_keywords' ] && ! defined ( 'META_KEYWORDS' ))
{
define ( 'META_KEYWORDS' , $news [ 'news_meta_keywords' ]);
}
2010-02-10 21:53:56 +00:00
2009-09-14 18:22:16 +00:00
if ( $news [ 'news_meta_description' ] && ! defined ( 'META_DESCRIPTION' ))
{
define ( 'META_DESCRIPTION' , $news [ 'news_meta_description' ]);
}
return ;
}
2010-02-10 21:53:56 +00:00
2009-09-14 18:22:16 +00:00
if ( $news [ 'category_name' ] && ! defined ( 'e_PAGETITLE' ))
{
define ( 'e_PAGETITLE' , $news [ 'category_name' ]);
}
2010-02-10 21:53:56 +00:00
2009-09-14 18:22:16 +00:00
if ( $news [ 'category_meta_keywords' ] && ! defined ( 'META_KEYWORDS' ))
{
define ( 'META_KEYWORDS' , $news [ 'category_meta_keywords' ]);
}
2010-02-10 21:53:56 +00:00
2009-09-14 18:22:16 +00:00
if ( $news [ 'category_meta_description' ] && ! defined ( 'META_DESCRIPTION' ))
{
define ( 'META_DESCRIPTION' , $news [ 'category_meta_description' ]);
}
}
2006-12-02 04:36:16 +00:00
?>