16
DO NOT USE THE CODE STRAIGHT OUT, YOU WILL BREAK YOUR NEWS MODULE!
My Hacked News Module is streamlined and features I don't use were removed, so it will NOT work for you.
But since you guys want some code to look at, here it is.
<?php
include '../../mainfile.php';
$xoopsOption['template_main'] = 'news_index.html';
include XOOPS_ROOT_PATH.'/header.php';
include_once XOOPS_ROOT_PATH.'/modules/news/class/class.newsstory.php';
if (isset($_GET['storytopic'])) {
$xoopsOption['storytopic'] = intval($_GET['storytopic']);
} else {
$xoopsOption['storytopic'] = 0;
}
if (isset($_GET_['storynum']) ) {
$xoopsOption['storynum'] = intval($_GET['storynum']);
if ($xoopsOption['storynum'] > 30) {
$xoopsOption['storynum'] = $xoopsModuleConfig['storyhome'];
}
} else {
$xoopsOption['storynum'] = $xoopsModuleConfig['storyhome'];
}
if ( isset($_GET['start']) ) {
$start = intval($_GET['start']);
} else {
$start = 0;
}
if ( $xoopsModuleConfig['displaynav'] == 1 ) {
$xoopsTpl->assign('displaynav', true);
$xt = new XoopsTopic($xoopsDB->prefix('topics'));
ob_start();
$xt->makeTopicSelBox(1, $xoopsOption['storytopic'], 'storytopic');
$topic_select = ob_get_contents();
ob_end_clean();
$xoopsTpl->assign('topic_select', $topic_select);
$storynum_options = '';
for ( $i = 5; $i <= 30; $i = $i + 5 ) {
$sel = '';
if ($i == $xoopsOption['storynum']) {
$sel = ' selected="selected"';
}
$storynum_options .= '<option value="'.$i.'"'.$sel.'>'.$i.'</option>';
}
$xoopsTpl->assign('storynum_options', $storynum_options);
} else {
$xoopsTpl->assign('displaynav', false);
}
$sarray = NewsStory::getAllPublished($xoopsOption['storynum'], $start, $xoopsOption['storytopic']);
$scount = count($sarray);
for ( $i = 0; $i < $scount; $i++ ) {
$story = array();
$story['id'] = $sarray[$i]->storyid();
$story['poster'] = $sarray[$i]->uname();
if ( $story['poster'] != false ) {
$story['poster'] = $story['poster'];
} else {
$story['poster'] = $xoopsConfig['anonymous'];
}
$story['posttime'] = date('m/d/Y',$sarray[$i]->published());
$story['text'] = $sarray[$i]->hometext();
$introcount = strlen($story['text']);
$fullcount = strlen($sarray[$i]->bodytext());
$totalcount = $introcount + $fullcount;
$morelink = '';
$storytitle = strtolower($sarray[$i]->title());
$replacethese = array('update: ','update 2: ','update 3: ','rumor: ',''');
$storytitle = html_entity_decode(str_replace($replacethese, "", $storytitle));
$storytitle = str_replace(" ", "-", $storytitle);
$storytitle = ereg_replace("[^[:alnum:]-]", "", $storytitle);
$storytitle = str_replace("--", "-", $storytitle);
if ( $fullcount > 1 ) {
$morelink .= '<b><a href="'.XOOPS_URL.'/news/'.$sarray[$i]->storyid().'-'.$storytitle.'/';
$morelink .= '">'._NW_READMORE.'</a></b>';
}
$story['morelink'] = $morelink;
$story['adminlink'] = '';
$story['mail_link'] = 'mailto:?subject='.sprintf(_NW_INTARTICLE,$xoopsConfig['sitename']).'&body='.sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']).': '.XOOPS_URL.'/news/'.$sarray[$i]->storyid().'-'.$storytitle.'/';
$story['imglink'] = '';
$story['align'] = '';
if ( $sarray[$i]->topicdisplay() ) {
$story['imglink'] = $sarray[$i]->imglink();
$story['align'] = $sarray[$i]->topicalign();
}
$story['title'] = "<a href="".XOOPS_URL."/news/".$sarray[$i]->storyid()."-".$storytitle."/">".$sarray[$i]->title()."</a>";
$xoopsTpl->append('stories', $story);
unset($story);
}
$totalcount = NewsStory::countPublishedByTopic($xoopsOption['storytopic']);
if ( $totalcount > $scount ) {
include_once XOOPS_ROOT_PATH.'/class/pagenav.php';
$pagenav = new XoopsPageNav($totalcount, $xoopsOption['storynum'], $start, 'start');
$pagenav2 = $pagenav->renderNav();
$pagenav2 = str_replace("/modules/news/index.php?start=", "http://www.ewonline.net/news/", $pagenav2);
$pagenav2 = str_replace('">', '/">', $pagenav2);
$pagenav2 = str_replace('http://www.ewonline.net/news/0/', 'http://www.ewonline.net/news.html', $pagenav2);
$xoopsTpl->assign('pagenav', $pagenav2);
} else {
$xoopsTpl->assign('pagenav', '');
}
$xoopsTpl->assign('lang_go', _GO);
$xoopsTpl->assign('lang_on', _ON);
$xoopsTpl->assign('lang_printerpage', _NW_PRINTERFRIENDLY);
$xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY);
include_once XOOPS_ROOT_PATH.'/footer.php';
?>