/** * Shows any new information in a block * * Return the HTML that shows any new stories, comments, etc * * @param string $help Help file for block * @param string $title Title used in block header * @param string $position Position in which block is being rendered 'left', 'right' or blank (for centre) * @return string Return the HTML that shows any new stories, comments, etc * */ function COM_whatsNewBlock($help = '', $title = '', $position = '') { global $_CONF, $_TABLES, $LANG01, $LANG_WHATSNEW, $page, $newstories; $retval = COM_startBlock($title, $help, COM_getBlockTemplate('whats_new_block', 'header', $position)); $topicsql = ''; if ($_CONF['hidenewstories'] == 0 || $_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $topicsql = COM_getTopicSql('AND', 0, $_TABLES['stories']); } if ($_CONF['hidenewstories'] == 0) { $archsql = ''; $archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1"); if (!empty($archivetid)) { $archsql = " AND (tid <> '" . addslashes($archivetid) . "')"; } // Find the newest stories $sql['mssql'] = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $archsql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND'); $sql['mysql'] = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $archsql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND'); $sql['pgsql'] = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (date >= (NOW() - INTERVAL '{$_CONF['newstoriesinterval']} SECOND')) AND (date <= NOW()) AND (draft_flag = 0)" . $archsql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND'); $result = DB_query($sql); $A = DB_fetchArray($result); $nrows = $A['count']; if (empty($title)) { $title = DB_getItem($_TABLES['blocks'], 'title', "name='whats_new_block'"); } // Any late breaking news stories? $retval .= '<h3>' . $LANG01[99] . '</h3>'; if ($nrows > 0) { $newmsg = COM_formatTimeString($LANG_WHATSNEW['new_string'], $_CONF['newstoriesinterval'], $LANG01[11], $nrows); if ($newstories && $page < 2) { $retval .= $newmsg . '<br' . XHTML . '>'; } else { $retval .= COM_createLink($newmsg, $_CONF['site_url'] . '/index.php?display=new') . '<br' . XHTML . '>'; } } else { $retval .= $LANG01[100] . '<br' . XHTML . '>'; } if ($_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0 || $_CONF['hidenewplugins'] == 0) { $retval .= '<br' . XHTML . '>'; } } if ($_CONF['hidenewcomments'] == 0) { // Go get the newest comments $retval .= '<h3>' . $LANG01[83] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval']) . '</small></h3>'; $new_plugin_comments = array(); $new_plugin_comments = PLG_getWhatsNewComment(); if (!empty($new_plugin_comments)) { // Sort array by element lastdate newest to oldest foreach ($new_plugin_comments as $k => $v) { $b[$k] = strtolower($v['lastdate']); } arsort($b); foreach ($b as $key => $val) { $temp[] = $new_plugin_comments[$key]; } $new_plugin_comments = $temp; $newcomments = array(); $count = 0; foreach ($new_plugin_comments as $A) { $count .= +1; $url = ''; $info = PLG_getItemInfo($A['type'], $A['sid'], 'url'); if (!empty($info)) { $url = $info . '#comments'; } // Check to see if url (plugin may not support PLG_getItemInfo if (!empty($url)) { $title = COM_undoSpecialChars(stripslashes($A['title'])); $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...'); if ($title != $titletouse) { $attr = array('title' => htmlspecialchars($title)); } else { $attr = array(); } $acomment = str_replace('$', '$', $titletouse); $acomment = str_replace(' ', ' ', $acomment); if ($A['dups'] > 1) { $acomment .= ' [+' . $A['dups'] . ']'; } $newcomments[] = COM_createLink($acomment, $url, $attr); if ($count == 15) { break; } } } $retval .= COM_makeList($newcomments, 'list-new-comments'); } else { $retval .= $LANG01[86] . '<br' . XHTML . '>' . LB; } if ($_CONF['hidenewplugins'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $retval .= '<br' . XHTML . '>'; } } if ($_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $retval .= '<h3>' . $LANG01[114] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newtrackbackinterval']) . '</small></h3>'; $sql['mssql'] = "SELECT DISTINCT COUNT(*) AS count,{$_TABLES['stories']}.title,t.sid,max(t.date) AS lastdate FROM {$_TABLES['trackback']} AS t,{$_TABLES['stories']} WHERE (t.type = 'article') AND (t.sid = {$_TABLES['stories']}.sid) AND (t.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newtrackbackinterval']} SECOND)))" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.trackbackcode = 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . " GROUP BY t.sid, {$_TABLES['stories']}.title ORDER BY lastdate DESC LIMIT 15"; $sql['mysql'] = "SELECT DISTINCT COUNT(*) AS count,{$_TABLES['stories']}.title,t.sid,max(t.date) AS lastdate FROM {$_TABLES['trackback']} AS t,{$_TABLES['stories']} WHERE (t.type = 'article') AND (t.sid = {$_TABLES['stories']}.sid) AND (t.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newtrackbackinterval']} SECOND)))" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.trackbackcode = 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . " GROUP BY t.sid, {$_TABLES['stories']}.title ORDER BY lastdate DESC LIMIT 15"; $sql['pgsql'] = "SELECT DISTINCT COUNT(*) AS count,{$_TABLES['stories']}.title,t.sid,max(t.date) AS lastdate FROM {$_TABLES['trackback']} AS t,{$_TABLES['stories']} WHERE (t.type = 'article') AND (t.sid = {$_TABLES['stories']}.sid) AND (t.date >= (NOW()+ INTERVAL '{$_CONF['newtrackbackinterval']} SECOND'))" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.trackbackcode = 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . " GROUP BY t.sid, {$_TABLES['stories']}.title ORDER BY lastdate DESC LIMIT 15"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $newcomments = array(); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#trackback'; $title = COM_undoSpecialChars(stripslashes($A['title'])); $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...'); if ($title != $titletouse) { $attr = array('title' => htmlspecialchars($title)); } else { $attr = array(); } $acomment = str_replace('$', '$', $titletouse); $acomment = str_replace(' ', ' ', $acomment); if ($A['count'] > 1) { $acomment .= ' [+' . $A['count'] . ']'; } $newcomments[] = COM_createLink($acomment, $url, $attr); } $retval .= COM_makeList($newcomments, 'list-new-trackbacks'); } else { $retval .= $LANG01[115] . '<br' . XHTML . '>' . LB; } if ($_CONF['hidenewplugins'] == 0) { $retval .= '<br' . XHTML . '>'; } } if ($_CONF['hidenewplugins'] == 0) { list($headlines, $smallheadlines, $content) = PLG_getWhatsNew(); $plugins = count($headlines); if ($plugins > 0) { for ($i = 0; $i < $plugins; $i++) { $retval .= '<h3>' . $headlines[$i] . ' <small>' . $smallheadlines[$i] . '</small></h3>'; if (is_array($content[$i])) { $retval .= COM_makeList($content[$i], 'list-new-plugins'); } else { $retval .= $content[$i]; } if ($i + 1 < $plugins) { $retval .= '<br' . XHTML . '>'; } } } } $retval .= COM_endBlock(COM_getBlockTemplate('whats_new_block', 'footer', $position)); return $retval; }
/** * Shows any new information in a block * * Return the HTML that shows any new stories, comments, etc * * @param string $help Help file for block * @param string $title Title used in block header * @param string $position Position in which block is being rendered 'left', 'right' or blank (for centre) * @return string Return the HTML that shows any new stories, comments, etc * */ function COM_whatsNewBlock($help = '', $title = '', $position = '') { global $_CONF, $_TABLES, $_USER, $_PLUGINS, $LANG01, $LANG_WHATSNEW, $page, $newstories; if (!isset($_CONF['whatsnew_cache_time'])) { $_CONF['whatsnew_cache_time'] = 3600; } $cacheInstance = 'whatsnew__' . CACHE_security_hash() . '__' . $_USER['theme']; $retval = CACHE_check_instance($cacheInstance, 0); if ($retval) { $lu = CACHE_get_instance_update($cacheInstance, 0); $now = time(); if ($now - $lu < $_CONF['whatsnew_cache_time']) { return $retval; } } $T = new Template($_CONF['path_layout'] . 'blocks'); $T->set_file('block', 'whatsnew.thtml'); $items_found = 0; $header = COM_startBlock($title, $help, COM_getBlockTemplate('whats_new_block', 'header', $position), 'whats_new_block'); $T->set_var('block_start', $header); $topicsql = ''; if ($_CONF['hidenewstories'] == 0 || $_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $topicsql = COM_getTopicSql('AND', 0, $_TABLES['stories']); } if ($_CONF['hidenewstories'] == 0) { $archsql = ''; $archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1"); if (!empty($archivetid)) { $archsql = " AND (tid <> '" . DB_escapeString($archivetid) . "')"; } // Find the newest stories $sql = "SELECT * FROM {$_TABLES['stories']} WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $archsql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND') . ' ORDER BY date DESC'; $result = DB_query($sql); $nrows = DB_numRows($result); if (empty($title)) { $title = DB_getItem($_TABLES['blocks'], 'title', "name='whats_new_block'"); } $T->set_block('block', 'section', 'sectionblock'); if ($nrows > 0) { // Any late breaking news stories? $T->set_var('section_title', $LANG01[99]); $T->set_var('interval', COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval'])); $newstory = array(); $T->set_block('block', 'datarow', 'datablock'); while ($A = DB_fetchArray($result)) { $title = COM_undoSpecialChars($A['title']); $title = str_replace(' ', ' ', $title); $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...'); $attr = array('title' => htmlspecialchars($title, ENT_COMPAT, COM_getEncodingt())); $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']); $storyitem = COM_createLink($titletouse, $url, $attr); $newstory[] = $storyitem; $T->set_var('data_item', $storyitem); $T->parse('datablock', 'datarow', true); $items_found++; } $T->parse('sectionblock', 'section', true); } } $T->unset_var('datablock'); if ($_CONF['hidenewcomments'] == 0) { // Go get the newest comments $commentHeader = 0; $newcomments = array(); $commentrow = array(); // get story whats new $stwhere = ''; if (!COM_isAnonUser()) { $stwhere .= "({$_TABLES['stories']}.owner_id IS NOT NULL AND {$_TABLES['stories']}.perm_owner IS NOT NULL) OR "; $stwhere .= "({$_TABLES['stories']}.group_id IS NOT NULL AND {$_TABLES['stories']}.perm_group IS NOT NULL) OR "; $stwhere .= "({$_TABLES['stories']}.perm_members IS NOT NULL)"; } else { $stwhere .= "({$_TABLES['stories']}.perm_anon IS NOT NULL)"; } $sql = "SELECT DISTINCT COUNT(*) AS dups, type, {$_TABLES['stories']}.title, {$_TABLES['stories']}.sid, UNIX_TIMESTAMP(max({$_TABLES['comments']}.date)) AS lastdate FROM {$_TABLES['comments']} LEFT JOIN {$_TABLES['stories']} ON (({$_TABLES['stories']}.sid = {$_TABLES['comments']}.sid)" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.commentcode >= 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . ") WHERE ({$_TABLES['comments']}.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newcommentsinterval']} SECOND))) AND ((({$stwhere}))) GROUP BY {$_TABLES['comments']}.sid,type, {$_TABLES['stories']}.title, {$_TABLES['stories']}.title, {$_TABLES['stories']}.sid ORDER BY 5 DESC LIMIT 15"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $T->set_var('section_title', $LANG01[83]); $T->set_var('interval', COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval'])); $commentHeader = 1; for ($x = 0; $x < $nrows; $x++) { $A = DB_fetchArray($result); $A['url'] = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#comments'; $commentrow[] = $A; } } $pluginComments = PLG_getWhatsNewComment(); $commentrow = array_merge($pluginComments, $commentrow); usort($commentrow, '_commentsort'); $nrows = count($commentrow); if ($nrows > 0) { if ($commentHeader == 0) { $commentHeader = 1; $T->set_var('section_title', $LANG01[83]); $T->set_var('interval', COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval'])); } $newcomments = array(); for ($x = 0; $x < $nrows; $x++) { $titletouse = ''; $url = $commentrow[$x]['url']; $title = COM_undoSpecialChars($commentrow[$x]['title']); $title = str_replace(' ', ' ', $title); $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...'); $attr = array('title' => htmlspecialchars($title, ENT_COMPAT, COM_getEncodingt())); if ($commentrow[$x]['dups'] > 1) { $titletouse .= ' [+' . $commentrow[$x]['dups'] . ']'; } $newcomments[] = COM_createLink($titletouse, $url, $attr); } $T->set_block('block', 'datarow', 'datablock'); foreach ($newcomments as $comment) { $T->set_var('data_item', $comment); $T->parse('datablock', 'datarow', true); $items_found++; } $T->parse('sectionblock', 'section', true); } } $T->unset_var('datablock'); if ($_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $sql = "SELECT DISTINCT COUNT(*) AS count,{$_TABLES['stories']}.title,t.sid,max(t.date) AS lastdate FROM {$_TABLES['trackback']} AS t,{$_TABLES['stories']} WHERE (t.type = 'article') AND (t.sid = {$_TABLES['stories']}.sid) AND (t.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newtrackbackinterval']} SECOND)))" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.trackbackcode = 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . " GROUP BY t.sid, {$_TABLES['stories']}.title ORDER BY lastdate DESC LIMIT 15"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $T->set_var('section_title', $LANG01[114]); $T->set_var('interval', COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newtrackbackinterval'])); $newcomments = array(); $T->set_block('block', 'datarow', 'datablock'); for ($i = 0; $i < $nrows; $i++) { $titletouse = ''; $A = DB_fetchArray($result); $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#trackback'; $title = COM_undoSpecialChars($A['title']); $title = str_replace(' ', ' ', $title); $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...'); $attr = array('title' => htmlspecialchars($title, ENT_COMPAT, COM_getEncodingt())); if ($A['count'] > 1) { $titletouse .= ' [+' . $A['count'] . ']'; } $trackback = COM_createLink($titletouse, $url, $attr); $newcomments[] = $trackback; $T->set_var('data_item', $trackback); $T->parse('datablock', 'datarow', true); $items_found++; } $T->parse('sectionblock', 'section', true); } } $T->unset_var('datablock'); if ($_CONF['hidenewplugins'] == 0) { list($headlines, $smallheadlines, $content) = PLG_getWhatsNew(); $plugins = count($headlines); if ($plugins > 0) { for ($i = 0; $i < $plugins; $i++) { $T->set_var('section_title', $headlines[$i]); $T->set_var('interval', $smallheadlines[$i]); $T->set_block('block', 'datarow', 'datablock'); if (is_array($content[$i])) { foreach ($content[$i] as $item) { $T->set_var('data_item', $item); $T->parse('datablock', 'datarow', true); $items_found++; } } else { $T->set_var('data_item', $content[$i]); $T->parse('datablock', 'datarow', true); $items_found++; } $T->parse('sectionblock', 'section', true); $T->unset_var('datablock'); $T->unset_var('interval'); $T->unset_var('section_title'); } } } if ($items_found == 0) { $T->set_var('no_items_found', $LANG01['no_new_items']); } else { $T->set_var('no_items_found', ''); } $T->set_var('block_end', COM_endBlock(COM_getBlockTemplate('whats_new_block', 'footer', $position))); $T->parse('output', 'block'); $final = $T->finish($T->get_var('output')); CACHE_create_instance($cacheInstance, $final, 0); return $final; }
/** * Shows any new information in a block * * Return the HTML that shows any new stories, comments, etc * * @param string $help Help file for block * @param string $title Title used in block header * @param string $position Position in which block is being rendered 'left', 'right' or blank (for centre) * @return string Return the HTML that shows any new stories, comments, etc * */ function COM_whatsNewBlock($help = '', $title = '', $position = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG_WHATSNEW, $page, $newstories; $retval = COM_startBlock($title, $help, COM_getBlockTemplate('whats_new_block', 'header', $position)); $topicsql = ''; if ($_CONF['hidenewstories'] == 0 || $_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $topicsql = COM_getTopicSql('AND', 0, $_TABLES['stories']); } if ($_CONF['hidenewstories'] == 0) { $archsql = ''; $archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1"); if (!empty($archivetid)) { $archsql = " AND (tid <> '" . addslashes($archivetid) . "')"; } // Find the newest stories $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $archsql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND'); $result = DB_query($sql); $A = DB_fetchArray($result); $nrows = $A['count']; if (empty($title)) { $title = DB_getItem($_TABLES['blocks'], 'title', "name='whats_new_block'"); } // Any late breaking news stories? $retval .= '<h3>' . $LANG01[99] . '</h3>'; if ($nrows > 0) { $newmsg = COM_formatTimeString($LANG_WHATSNEW['new_string'], $_CONF['newstoriesinterval'], $LANG01[11], $nrows); if ($newstories && $page < 2) { $retval .= $newmsg . '<br' . XHTML . '>'; } else { $retval .= COM_createLink($newmsg, $_CONF['site_url'] . '/index.php?display=new') . '<br' . XHTML . '>'; } } else { $retval .= $LANG01[100] . '<br' . XHTML . '>'; } if ($_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0 || $_CONF['hidenewplugins'] == 0) { $retval .= '<br' . XHTML . '>'; } } if ($_CONF['hidenewcomments'] == 0) { // Go get the newest comments $retval .= '<h3>' . $LANG01[83] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval']) . '</small></h3>'; $stwhere = ''; if (!COM_isAnonUser()) { $stwhere .= "({$_TABLES['stories']}.owner_id IS NOT NULL AND {$_TABLES['stories']}.perm_owner IS NOT NULL) OR "; $stwhere .= "({$_TABLES['stories']}.group_id IS NOT NULL AND {$_TABLES['stories']}.perm_group IS NOT NULL) OR "; $stwhere .= "({$_TABLES['stories']}.perm_members IS NOT NULL)"; } else { $stwhere .= "({$_TABLES['stories']}.perm_anon IS NOT NULL)"; } $sql = "SELECT DISTINCT COUNT(*) AS dups, type, {$_TABLES['stories']}.title, {$_TABLES['stories']}.sid, max({$_TABLES['comments']}.date) AS lastdate FROM {$_TABLES['comments']} LEFT JOIN {$_TABLES['stories']} ON (({$_TABLES['stories']}.sid = {$_TABLES['comments']}.sid)" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.commentcode >= 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . ") WHERE ({$_TABLES['comments']}.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newcommentsinterval']} SECOND))) AND ((({$stwhere}))) GROUP BY {$_TABLES['comments']}.sid,type, {$_TABLES['stories']}.title, {$_TABLES['stories']}.title, {$_TABLES['stories']}.sid ORDER BY 5 DESC LIMIT 15"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $newcomments = array(); for ($x = 0; $x < $nrows; $x++) { $A = DB_fetchArray($result); if ($A['type'] == 'article' || empty($A['type'])) { $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#comments'; } $title = COM_undoSpecialChars(stripslashes($A['title'])); $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...'); if ($title != $titletouse) { $attr = array('title' => htmlspecialchars($title)); } else { $attr = array(); } $acomment = str_replace('$', '$', $titletouse); $acomment = str_replace(' ', ' ', $acomment); if ($A['dups'] > 1) { $acomment .= ' [+' . $A['dups'] . ']'; } $newcomments[] = COM_createLink($acomment, $url, $attr); } $retval .= COM_makeList($newcomments, 'list-new-comments'); } else { $retval .= $LANG01[86] . '<br' . XHTML . '>' . LB; } if ($_CONF['hidenewplugins'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $retval .= '<br' . XHTML . '>'; } } if ($_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $retval .= '<h3>' . $LANG01[114] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newtrackbackinterval']) . '</small></h3>'; $sql = "SELECT DISTINCT COUNT(*) AS count,{$_TABLES['stories']}.title,t.sid,max(t.date) AS lastdate FROM {$_TABLES['trackback']} AS t,{$_TABLES['stories']} WHERE (t.type = 'article') AND (t.sid = {$_TABLES['stories']}.sid) AND (t.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newtrackbackinterval']} SECOND)))" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.trackbackcode = 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . " GROUP BY t.sid, {$_TABLES['stories']}.title ORDER BY lastdate DESC LIMIT 15"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $newcomments = array(); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#trackback'; $title = COM_undoSpecialChars(stripslashes($A['title'])); $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...'); if ($title != $titletouse) { $attr = array('title' => htmlspecialchars($title)); } else { $attr = array(); } $acomment = str_replace('$', '$', $titletouse); $acomment = str_replace(' ', ' ', $acomment); if ($A['count'] > 1) { $acomment .= ' [+' . $A['count'] . ']'; } $newcomments[] = COM_createLink($acomment, $url, $attr); } $retval .= COM_makeList($newcomments, 'list-new-trackbacks'); } else { $retval .= $LANG01[115] . '<br' . XHTML . '>' . LB; } if ($_CONF['hidenewplugins'] == 0) { $retval .= '<br' . XHTML . '>'; } } if ($_CONF['hidenewplugins'] == 0) { list($headlines, $smallheadlines, $content) = PLG_getWhatsNew(); $plugins = count($headlines); if ($plugins > 0) { for ($i = 0; $i < $plugins; $i++) { $retval .= '<h3>' . $headlines[$i] . ' <small>' . $smallheadlines[$i] . '</small></h3>'; if (is_array($content[$i])) { $retval .= COM_makeList($content[$i], 'list-new-plugins'); } else { $retval .= $content[$i]; } if ($i + 1 < $plugins) { $retval .= '<br' . XHTML . '>'; } } } } $retval .= COM_endBlock(COM_getBlockTemplate('whats_new_block', 'footer', $position)); return $retval; }
/** * Shows any new information in a block * Return the HTML that shows any new stories, comments, etc * * @param string $help Help file for block * @param string $title Title used in block header * @param string $position Position in which block is being rendered 'left', 'right' or blank (for centre) * @return string Return the HTML that shows any new stories, comments, etc */ function COM_whatsNewBlock($help = '', $title = '', $position = '') { global $_CONF, $_TABLES, $LANG01, $LANG_WHATSNEW; if ($_CONF['whatsnew_cache_time'] > 0) { $cacheInstance = 'whatsnew__' . CACHE_security_hash() . '__' . $_CONF['theme']; $retval = CACHE_check_instance($cacheInstance); if ($retval) { $lu = CACHE_get_instance_update($cacheInstance); $now = time(); if ($now - $lu < $_CONF['whatsnew_cache_time']) { return $retval; } } } $retval = COM_startBlock($title, $help, COM_getBlockTemplate('whats_new_block', 'header', $position)); $topicSql = ''; if ($_CONF['hidenewstories'] == 0 || $_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $topicSql = COM_getTopicSQL('AND', 0, 'ta'); } if ($_CONF['hidenewstories'] == 0) { $where_sql = " AND ta.type = 'article' AND ta.id = sid"; $archiveTid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1"); if (!empty($archiveTid)) { $where_sql .= " AND (ta.tid <> '{$archiveTid}')"; } // Find the newest stories $sql['mysql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL('AND') . $topicSql . COM_getLangSQL('sid', 'AND') . "\n GROUP BY sid, title, date ORDER BY date DESC"; $sql['pgsql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n WHERE (date >= (NOW() - INTERVAL '{$_CONF['newstoriesinterval']} SECOND')) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL('AND') . $topicSql . COM_getLangSQL('sid', 'AND') . "\n GROUP BY sid, title, date ORDER BY date DESC"; $result = DB_query($sql); $numRows = DB_numRows($result); if (empty($title)) { $title = DB_getItem($_TABLES['blocks'], 'title', "name='whats_new_block'"); } // Any late breaking news stories? $retval .= '<h3>' . $LANG01[99] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newstoriesinterval']) . '</small></h3>'; if ($numRows > 0) { $newArticles = array(); for ($x = 0; $x < $numRows; $x++) { $A = DB_fetchArray($result); $url = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $A['sid']); $title = COM_undoSpecialChars(stripslashes($A['title'])); $titleToUse = COM_truncate($title, $_CONF['title_trim_length'], '...'); if ($title != $titleToUse) { $attr = array('title' => htmlspecialchars($title)); } else { $attr = array(); } $anchorText = str_replace('$', '$', $titleToUse); $anchorText = str_replace(' ', ' ', $anchorText); $newArticles[] = COM_createLink($anchorText, $url, $attr); } $retval .= COM_makeList($newArticles, 'list-new-plugins'); } else { $retval .= $LANG01[100] . '<br' . XHTML . '>' . LB; // No new stories } if ($_CONF['hidenewcomments'] == 0 || $_CONF['hidenewplugins'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $retval .= '<div class="divider-whats-new"></div>'; } } if ($_CONF['hidenewcomments'] == 0) { // Go get the newest comments $retval .= '<h3>' . $LANG01[83] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval']) . '</small></h3>'; $new_plugin_comments = PLG_getWhatsNewComment(); if (!empty($new_plugin_comments)) { // Sort array by element lastdate newest to oldest foreach ($new_plugin_comments as $k => $v) { $b[$k] = strtolower($v['lastdate']); } arsort($b); $temp = array(); foreach ($b as $key => $val) { $temp[] = $new_plugin_comments[$key]; } $new_plugin_comments = $temp; $newComments = array(); $count = 0; foreach ($new_plugin_comments as $A) { $count .= +1; $url = ''; $info = PLG_getItemInfo($A['type'], $A['sid'], 'url'); if (!empty($info)) { $url = $info . '#comments'; } // Check to see if url (plugin may not support PLG_getItemInfo if (!empty($url)) { $title = COM_undoSpecialChars(stripslashes($A['title'])); $titleToUse = COM_truncate($title, $_CONF['title_trim_length'], '...'); if ($title != $titleToUse) { $attr = array('title' => htmlspecialchars($title)); } else { $attr = array(); } $anchorComment = str_replace('$', '$', $titleToUse); $anchorComment = str_replace(' ', ' ', $anchorComment); if ($A['dups'] > 1) { $anchorComment .= ' [+' . $A['dups'] . ']'; } $newComments[] = COM_createLink($anchorComment, $url, $attr); if ($count == 15) { break; } } } $retval .= COM_makeList($newComments, 'list-new-comments'); } else { $retval .= $LANG01[86] . '<br' . XHTML . '>' . LB; } if ($_CONF['hidenewplugins'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $retval .= '<div class="divider-whats-new"></div>'; } } if ($_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) { $retval .= '<h3>' . $LANG01[114] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newtrackbackinterval']) . '</small></h3>'; $sql['mysql'] = "SELECT DISTINCT COUNT(*) AS count,s.title,t.sid,max(t.date) AS lastdate\n FROM {$_TABLES['trackback']} AS t, {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta\n WHERE ta.type = 'article' AND ta.id = s.sid AND (t.type = 'article') AND (t.sid = s.sid) AND (t.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newtrackbackinterval']} SECOND)))" . COM_getPermSQL('AND', 0, 2, 's') . " AND (s.draft_flag = 0) AND (s.trackbackcode = 0)" . $topicSql . COM_getLangSQL('sid', 'AND', 's') . "\n GROUP BY t.sid, s.title\n ORDER BY lastdate DESC LIMIT 15"; $sql['pgsql'] = "SELECT DISTINCT COUNT(*) AS count,s.title,t.sid,max(t.date) AS lastdate\n FROM {$_TABLES['trackback']} AS t, {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta\n WHERE ta.type = 'article' AND ta.id = s.sid AND (t.type = 'article') AND (t.sid = s.sid) AND (t.date >= (NOW()+ INTERVAL '{$_CONF['newtrackbackinterval']} SECOND'))" . COM_getPermSQL('AND', 0, 2, 's') . " AND (s.draft_flag = 0) AND (s.trackbackcode = 0)" . $topicSql . COM_getLangSQL('sid', 'AND', 's') . "\n GROUP BY t.sid, s.title\n ORDER BY lastdate DESC LIMIT 15"; $result = DB_query($sql); $numRows = DB_numRows($result); if ($numRows > 0) { $newComments = array(); for ($i = 0; $i < $numRows; $i++) { $A = DB_fetchArray($result); $url = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#trackback'; $title = COM_undoSpecialChars(stripslashes($A['title'])); $titleToUse = COM_truncate($title, $_CONF['title_trim_length'], '...'); if ($title != $titleToUse) { $attr = array('title' => htmlspecialchars($title)); } else { $attr = array(); } $anchorComment = str_replace('$', '$', $titleToUse); $anchorComment = str_replace(' ', ' ', $anchorComment); if ($A['count'] > 1) { $anchorComment .= ' [+' . $A['count'] . ']'; } $newComments[] = COM_createLink($anchorComment, $url, $attr); } $retval .= COM_makeList($newComments, 'list-new-trackbacks'); } else { $retval .= $LANG01[115] . '<br' . XHTML . '>' . LB; } if ($_CONF['hidenewplugins'] == 0) { $retval .= '<div class="divider-whats-new"></div>'; } } if ($_CONF['hidenewplugins'] == 0) { list($headlines, $smallHeadlines, $content) = PLG_getWhatsNew(); $plugins = count($headlines); if ($plugins > 0) { for ($i = 0; $i < $plugins; $i++) { $retval .= '<h3>' . $headlines[$i] . ' <small>' . $smallHeadlines[$i] . '</small></h3>'; if (is_array($content[$i])) { $retval .= COM_makeList($content[$i], 'list-new-plugins'); } else { $retval .= $content[$i]; } if ($i + 1 < $plugins) { $retval .= '<div class="divider-whats-new"></div>'; } } } } $retval .= COM_endBlock(COM_getBlockTemplate('whats_new_block', 'footer', $position)); if ($_CONF['whatsnew_cache_time'] > 0) { CACHE_create_instance($cacheInstance, $retval); } return $retval; }