mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Othernews fixes. Now works with divs. Use define('OTHERNEWS_COLS',false); to disable html tables.
This commit is contained in:
parent
202007f7cd
commit
1dabbf7123
@ -316,34 +316,36 @@ class news {
|
||||
|
||||
if ($n_restrict == 'userclass')
|
||||
{
|
||||
$news['news_id'] = 0;
|
||||
$news['news_title'] = LAN_NEWS_1;
|
||||
$news['data'] = LAN_NEWS_2;
|
||||
$news['news_extended'] = "";
|
||||
$news['news_allow_comments'] = 1;
|
||||
$news['news_start'] = 0;
|
||||
$news['news_end'] = 0;
|
||||
$news['news_render_type'] = 0;
|
||||
$news['comment_total'] = 0;
|
||||
$news['news_id'] = 0;
|
||||
$news['news_title'] = LAN_NEWS_1;
|
||||
$news['data'] = LAN_NEWS_2;
|
||||
$news['news_extended'] = "";
|
||||
$news['news_allow_comments'] = 1;
|
||||
$news['news_start'] = 0;
|
||||
$news['news_end'] = 0;
|
||||
$news['news_render_type'] = 0;
|
||||
$news['comment_total'] = 0;
|
||||
}
|
||||
|
||||
$tmp = array();
|
||||
$tmp['caticon'] = ICONSTYLE;
|
||||
$tmp['commentoffstring'] = COMMENTOFFSTRING;
|
||||
$tmp['commentlink'] = COMMENTLINK;
|
||||
$tmp['trackbackstring'] = (defined("TRACKBACKSTRING") ? TRACKBACKSTRING : "");
|
||||
$tmp['trackbackbeforestring'] = (defined("TRACKBACKBEFORESTRING") ? TRACKBACKBEFORESTRING : "");
|
||||
$tmp['trackbackafterstring'] = (defined("TRACKBACKAFTERSTRING") ? TRACKBACKAFTERSTRING : "");
|
||||
$tmp['itemlink'] = (defined("NEWSLIST_ITEMLINK")) ? NEWSLIST_ITEMLINK : "";
|
||||
$tmp['thumbnail'] =(defined("NEWSLIST_THUMB")) ? NEWSLIST_THUMB : "border:0px";
|
||||
$tmp['catlink'] = (defined("NEWSLIST_CATLINK")) ? NEWSLIST_CATLINK : "";
|
||||
$tmp['caticon'] = (defined("NEWSLIST_CATICON")) ? NEWSLIST_CATICON : ICONSTYLE;
|
||||
$tmp['caticon'] = defset('ICONSTYLE');
|
||||
$tmp['commentoffstring'] = defset('COMMENTOFFSTRING');
|
||||
$tmp['commentlink'] = defset('COMMENTLINK');
|
||||
$tmp['trackbackstring'] = defset('TRACKBACKSTRING');
|
||||
$tmp['trackbackbeforestring'] = defset('TRACKBACKBEFORESTRING');
|
||||
$tmp['trackbackafterstring'] = defset('TRACKBACKAFTERSTRING');
|
||||
$tmp['itemlink'] = defset('NEWSLIST_ITEMLINK');
|
||||
$tmp['thumbnail'] = defset('NEWSLIST_THUMB', "border:0px");
|
||||
$tmp['catlink'] = defset('NEWSLIST_CATLINK');
|
||||
$tmp['caticon'] = defset('NEWSLIST_CATICON', defset('ICONSTYLE'));
|
||||
|
||||
if(!$param) $param = array();
|
||||
$param = array_merge($tmp, $param);
|
||||
|
||||
|
||||
// Next three images aren't always defined by the caller, even if most of $param is.
|
||||
//XXX All of this should be done via CSS from v2 on.
|
||||
|
||||
if (!isset($param['image_nonew_small']))
|
||||
{
|
||||
if (!defined("IMAGE_nonew_small"))
|
||||
@ -374,23 +376,36 @@ class news {
|
||||
cachevars('current_news_item', $news);
|
||||
cachevars('current_news_param', $param);
|
||||
|
||||
if ($news['news_render_type'] == 1 && $mode != "extend") {
|
||||
if (function_exists("news_list")) {
|
||||
if ($news['news_render_type'] == 1 && $mode != "extend")
|
||||
{
|
||||
if (function_exists("news_list"))
|
||||
{
|
||||
$NEWS_PARSE = news_list($news);
|
||||
} else if ($NEWSLISTSTYLE) {
|
||||
}
|
||||
else if ($NEWSLISTSTYLE)
|
||||
{
|
||||
$NEWS_PARSE = $NEWSLISTSTYLE;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$NEWS_PARSE = "{NEWSICON} <b>{NEWSTITLELINK}</b><div class='smalltext'>{NEWSAUTHOR} ".LAN_NEWS_100." {NEWSDATE} | {NEWSCOMMENTS}</div>";
|
||||
}
|
||||
} else {
|
||||
if ($NEWS_TEMPLATE) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($NEWS_TEMPLATE)
|
||||
{
|
||||
$NEWS_PARSE = $NEWS_TEMPLATE;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (function_exists("news_style"))
|
||||
{
|
||||
$action = varset($param['current_action'], 'default');
|
||||
$NEWS_PARSE = news_style($news, $action, $param);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$NEWS_PARSE = $NEWSSTYLE;
|
||||
}
|
||||
}
|
||||
|
@ -52,14 +52,14 @@ if(!$OTHERNEWS2_STYLE) {
|
||||
}
|
||||
|
||||
if(!defined("OTHERNEWS2_LIMIT")){
|
||||
define("OTHERNEWS2_LIMIT",5);
|
||||
// define("OTHERNEWS2_LIMIT",5);
|
||||
}
|
||||
|
||||
if(!defined("OTHERNEWS2_ITEMLINK")){
|
||||
define("OTHERNEWS2_ITEMLINK","");
|
||||
// define("OTHERNEWS2_ITEMLINK","");
|
||||
}
|
||||
if(!defined("OTHERNEWS2_CATLINK")){
|
||||
define("OTHERNEWS2_CATLINK","");
|
||||
// define("OTHERNEWS2_CATLINK","");
|
||||
}
|
||||
if(!defined("OTHERNEWS2_CATICON")){
|
||||
define("OTHERNEWS2_CATICON","border:0px");
|
||||
@ -69,58 +69,75 @@ if(!defined("OTHERNEWS2_THUMB")){
|
||||
}
|
||||
|
||||
if(!defined("OTHERNEWS2_COLS")){
|
||||
define("OTHERNEWS2_COLS","1");
|
||||
// define("OTHERNEWS2_COLS","1");
|
||||
}
|
||||
|
||||
if(!defined("OTHERNEWS2_CELL")){
|
||||
define("OTHERNEWS2_CELL","padding:0px;vertical-align:top");
|
||||
// define("OTHERNEWS2_CELL","");
|
||||
}
|
||||
|
||||
if(!defined("OTHERNEWS2_SPACING")){
|
||||
define("OTHERNEWS2_SPACING","0");
|
||||
// define("OTHERNEWS2_SPACING","0");
|
||||
}
|
||||
|
||||
$param['itemlink'] = OTHERNEWS2_ITEMLINK;
|
||||
$param['thumbnail'] = OTHERNEWS2_THUMB;
|
||||
$param['catlink'] = OTHERNEWS2_CATLINK;
|
||||
$param['caticon'] = OTHERNEWS2_CATICON;
|
||||
$param['itemlink'] = defset('OTHERNEWS2_ITEMLINK','');
|
||||
$param['thumbnail'] = OTHERNEWS2_THUMB;
|
||||
$param['catlink'] = defset('OTHERNEWS2_CATLINK','');
|
||||
$param['caticon'] = OTHERNEWS2_CATICON;
|
||||
|
||||
$style = OTHERNEWS2_CELL;
|
||||
$nbr_cols = OTHERNEWS2_COLS;
|
||||
$style = defset('OTHERNEWS2_CELL','padding:0px;vertical-align:top');
|
||||
$nbr_cols = defset('OTHERNEWS2_COLS', 1);
|
||||
|
||||
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
|
||||
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 IN (".USERCLASS_LIST.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND FIND_IN_SET(3, n.news_render_type) ORDER BY n.news_datestamp DESC LIMIT 0,".OTHERNEWS2_LIMIT;
|
||||
WHERE n.news_class IN (".USERCLASS_LIST.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")
|
||||
AND FIND_IN_SET(3, n.news_render_type) ORDER BY n.news_datestamp DESC LIMIT 0,". defset('OTHERNEWS2_LIMIT',5);
|
||||
|
||||
if ($sql->db_Select_gen($query)) {
|
||||
$text = "<table style='width:100%' cellpadding='0' cellspacing='".OTHERNEWS2_SPACING."'>";
|
||||
$t = 0;
|
||||
$wid = floor(100/$nbr_cols);
|
||||
while ($row = $sql->db_Fetch()) {
|
||||
$text .= ($t % $nbr_cols == 0) ? "<tr>" : "";
|
||||
$text .= "\n<td style='$style ; width:$wid%;'>\n";
|
||||
|
||||
$text .= $ix->render_newsitem($row, 'return', '', $OTHERNEWS2_STYLE, $param);
|
||||
|
||||
$text .= "\n</td>\n";
|
||||
if (($t+1) % $nbr_cols == 0) {
|
||||
$text .= "</tr>";
|
||||
$t++;
|
||||
if ($sql->db_Select_gen($query))
|
||||
{
|
||||
$text = "";
|
||||
|
||||
if(OTHERNEWS2_COLS !== false)
|
||||
{
|
||||
$text = "<table style='width:100%' cellpadding='0' cellspacing='".defset('OTHERNEWS2_SPACING',0)."'>";
|
||||
$t = 0;
|
||||
$wid = floor(100/$nbr_cols);
|
||||
while ($row = $sql->db_Fetch())
|
||||
{
|
||||
$text .= ($t % $nbr_cols == 0) ? "<tr>" : "";
|
||||
$text .= "\n<td style='$style ; width:$wid%;'>\n";
|
||||
|
||||
$text .= $ix->render_newsitem($row, 'return', '', $OTHERNEWS2_STYLE, $param);
|
||||
|
||||
$text .= "\n</td>\n";
|
||||
if (($t+1) % $nbr_cols == 0) {
|
||||
$text .= "</tr>";
|
||||
$t++;
|
||||
}
|
||||
else {
|
||||
$t++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
while ($t % $nbr_cols != 0)
|
||||
{
|
||||
$text .= "<td style='width:$wid'> </td>\n";
|
||||
$text .= (($t+1) % $nbr_cols == 0) ? "</tr>" : "";
|
||||
$t++;
|
||||
|
||||
}
|
||||
$text .= "</table>";
|
||||
}
|
||||
else // perfect for divs.
|
||||
{
|
||||
while ($row = $sql->db_Fetch())
|
||||
{
|
||||
$text .= $ix->render_newsitem($row, 'return', '', $OTHERNEWS2_STYLE, $param);
|
||||
}
|
||||
}
|
||||
|
||||
while ($t % $nbr_cols != 0){
|
||||
$text .= "<td style='width:$wid'> </td>\n";
|
||||
$text .= (($t+1) % $nbr_cols == 0) ? "</tr>" : "";
|
||||
$t++;
|
||||
|
||||
}
|
||||
$text .= "</table>";
|
||||
|
||||
|
||||
|
||||
|
||||
// Save Data
|
||||
ob_start();
|
||||
|
@ -16,10 +16,8 @@
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
global $e107cache;
|
||||
|
||||
// Load Data
|
||||
if($cacheData = $e107cache->retrieve("nq_othernews"))
|
||||
if($cacheData = e107::getCache()->retrieve("nq_othernews"))
|
||||
{
|
||||
echo $cacheData;
|
||||
return;
|
||||
@ -76,13 +74,13 @@ if(!defined("OTHERNEWS_SPACING")){
|
||||
define("OTHERNEWS_SPACING","0");
|
||||
}
|
||||
|
||||
$param['itemlink'] = OTHERNEWS_ITEMLINK;
|
||||
$param['thumbnail'] = OTHERNEWS_THUMB;
|
||||
$param['catlink'] = OTHERNEWS_CATLINK;
|
||||
$param['caticon'] = OTHERNEWS_CATICON;
|
||||
$param['itemlink'] = defset('OTHERNEWS_ITEMLINK');
|
||||
$param['thumbnail'] = defset('OTHERNEWS_THUMB');
|
||||
$param['catlink'] = defset('OTHERNEWS_CATLINK');
|
||||
$param['caticon'] = defset('OTHERNEWS_CATICON');
|
||||
|
||||
$style = OTHERNEWS_CELL;
|
||||
$nbr_cols = OTHERNEWS_COLS;
|
||||
$style = defset('OTHERNEWS_CELL');
|
||||
$nbr_cols = defset('OTHERNEWS_COLS');
|
||||
|
||||
|
||||
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
|
||||
@ -90,34 +88,52 @@ 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 IN (".USERCLASS_LIST.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") AND FIND_IN_SET(2, n.news_render_type) ORDER BY n.news_datestamp DESC LIMIT 0,".OTHERNEWS_LIMIT;
|
||||
|
||||
if ($sql->db_Select_gen($query)){
|
||||
$text = "<table style='width:100%' cellpadding='0' cellspacing='".OTHERNEWS_SPACING."'>";
|
||||
$t = 0;
|
||||
$wid = floor(100/$nbr_cols);
|
||||
while ($row = $sql->db_Fetch()) {
|
||||
$text .= ($t % $nbr_cols == 0) ? "<tr>" : "";
|
||||
$text .= "\n<td style='$style ; width:$wid%;'>\n";
|
||||
$text .= $ix->render_newsitem($row, 'return', '', $OTHERNEWS_STYLE, $param);
|
||||
|
||||
$text .= "\n</td>\n";
|
||||
if (($t+1) % $nbr_cols == 0) {
|
||||
$text .= "</tr>";
|
||||
$t++;
|
||||
if ($sql->db_Select_gen($query))
|
||||
{
|
||||
$text = "";
|
||||
|
||||
if(OTHERNEWS_COLS !== false)
|
||||
{
|
||||
$text .= "<table style='width:100%' cellpadding='0' cellspacing='".OTHERNEWS_SPACING."'>";
|
||||
$t = 0;
|
||||
|
||||
$wid = floor(100/$nbr_cols);
|
||||
while ($row = $sql->db_Fetch())
|
||||
{
|
||||
$text .= ($t % $nbr_cols == 0) ? "<tr>" : "";
|
||||
$text .= "\n<td style='$style ; width:$wid%;'>\n";
|
||||
$text .= $ix->render_newsitem($row, 'return', '', $OTHERNEWS_STYLE, $param);
|
||||
|
||||
$text .= "\n</td>\n";
|
||||
if (($t+1) % $nbr_cols == 0) {
|
||||
$text .= "</tr>";
|
||||
$t++;
|
||||
}
|
||||
else {
|
||||
$t++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
while ($t % $nbr_cols != 0)
|
||||
{
|
||||
$text .= "<td style='width:$wid'> </td>\n";
|
||||
$text .= (($t+1) % $nbr_cols == 0) ? "</tr>" : "";
|
||||
$t++;
|
||||
|
||||
}
|
||||
|
||||
$text .= "</table>";
|
||||
}
|
||||
else // perfect for divs.
|
||||
{
|
||||
while ($row = $sql->db_Fetch())
|
||||
{
|
||||
$text .= $ix->render_newsitem($row, 'return', '', $OTHERNEWS_STYLE, $param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while ($t % $nbr_cols != 0){
|
||||
$text .= "<td style='width:$wid'> </td>\n";
|
||||
$text .= (($t+1) % $nbr_cols == 0) ? "</tr>" : "";
|
||||
$t++;
|
||||
|
||||
}
|
||||
$text .= "</table>";
|
||||
|
||||
|
||||
// Save Data
|
||||
ob_start();
|
||||
@ -125,7 +141,7 @@ if ($sql->db_Select_gen($query)){
|
||||
$ns->tablerender(TD_MENU_L1, $text, 'other_news');
|
||||
|
||||
$cache_data = ob_get_flush();
|
||||
$e107cache->set("nq_othernews", $cache_data);
|
||||
e107::getCache()->set("nq_othernews", $cache_data);
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user