Exemplo n.º 1
0
function nw_b_news_randomnews_show($options) {
    include_once NW_MODULE_PATH . '/include/functions.php';
    $myts =& MyTextSanitizer::getInstance();
    $block = array();
	$block['sort']=$options[0];

	$tmpstory = new nw_NewsStory;
	$restricted = nw_getmoduleoption('restrictindex', NW_MODULE_DIR_NAME);
	$dateformat = nw_getmoduleoption('dateformat', NW_MODULE_DIR_NAME);
	$infotips = nw_getmoduleoption('infotips', NW_MODULE_DIR_NAME);
	if($dateformat == '') {
		$dateformat = 's';
	}
    if ($options[4] == 0) {
        $stories = $tmpstory->getRandomNews($options[1],0,$restricted,0,1, $options[0]);
    } else {
        $topics = array_slice($options, 4);
        $stories = $tmpstory->getRandomNews($options[1],0,$restricted,$topics, 1, $options[0]);
    }
	unset($tmpstory);
    if(count($stories)==0) {
    	return '';
    }
    foreach ( $stories as $story ) {
        $news = array();
        $title = $story->title();
		if (strlen($title) > $options[2]) {
			$title = xoops_substr($title,0,$options[2]+3);
		}
		$news['title'] = $title;
        $news['id'] = $story->storyid();
        $news['date'] = formatTimestamp($story->published(), $dateformat);
        $news['hits'] = $story->counter();
        $news['rating'] = $story->rating();
        $news['votes'] = $story->votes();
        $news['author']= sprintf("%s %s",_POSTEDBY,$story->uname());
        $news['topic_title'] = $story->topic_title();
        $news['topic_color']= '#'.$myts->displayTarea($story->topic_color);

        if ($options[3] > 0) {
        	$html = $story->nohtml() == 1 ? 0 : 1;
        	$news['teaser'] = nw_truncate_tagsafe($myts->displayTarea($story->hometext, $html), $options[3]+3);
        	$news['infotips'] = '';
        }
        else {
        	$news['teaser'] = '';
			if($infotips>0) {
				$news['infotips'] = ' title="'.nw_make_infotips($story->hometext()).'"';
			} else {
				$news['infotips'] = '';
			}
        }
        $block['stories'][] = $news;
    }
    //DNPROSSI ADDED
	$block['newsmodule_url']= NW_MODULE_URL;
    
    $block['lang_read_more']=_MB_NW_READMORE;
    
    // DNPROSSI SEO
    $seo_enabled = nw_getmoduleoption('nw_seo_enable', NW_MODULE_DIR_NAME);
	if ( $seo_enabled == 1 ) {
		$block['urlrewrite']= "true";
	} else { 
		$block['urlrewrite']= "false"; 
	}  
    
    return $block;
}