function nw_b_news_latestnews_show($options)
{
    global $xoopsTpl, $xoopsUser, $xoopsConfig;
    include_once NW_MODULE_PATH . '/include/functions.php';

    $block = array();
    
    include_once NW_MODULE_PATH . '/class/class.newsstory.php';
    include_once NW_MODULE_PATH . '/class/class.sfiles.php';
    include_once NW_MODULE_PATH . '/class/class.newstopic.php';
    include_once NW_MODULE_PATH . '/class/class.latestnews.php'; //Bandit-X
    include_once XOOPS_ROOT_PATH . '/class/tree.php';

    if (file_exists(NW_MODULE_PATH . '/language/'.$xoopsConfig['language'].'/main.php')) {
        include_once NW_MODULE_PATH . '/language/'.$xoopsConfig['language'].'/main.php';
    }else{
        include_once NW_MODULE_PATH . '/language/english/main.php';
    }

    $myts =& MyTextSanitizer::getInstance();
    $sfiles = new nw_sFiles();

    $dateformat = nw_getmoduleoption('dateformat', NW_MODULE_PATH);
    if($dateformat == '') {
		$dateformat = 's';
	}

    $limit = $options[0];
    $column_count = $options[1];
    $letters = $options[2];
    $imgwidth = $options[3];
    $imgheight = $options[4];
    $border = $options[5];
    $bordercolor = $options[6];
    $selected_stories = $options[7];
	
	$block['spec']['columnwidth'] = intval(1/$column_count*100);
    if ($options[8] == 1) {
   	    $imgposition = 'right';
    } else {
        $imgposition = 'left';
    }
    
	$xoopsTpl->assign( 'xoops_module_header' , '<style type="text/css">
	.itemText {text-align: left;} 
	.latestnews { border-bottom: 1px solid #cccccc; } 
	</style>' . $xoopsTpl->get_template_vars("xoops_module_header") );

     if (!isset($options[26])) {
        $sarray = nw_Latestnewsstory::getAllPublished($limit, $selected_stories, 0, true, 0, 0, true, $options[25], false);
    } else {
   	    $topics = array_slice($options, 26);
       	$sarray = nw_Latestnewsstory::getAllPublished($limit, $selected_stories, 0, true, $topics, 0, true, $options[25], false);
   	}

    $scount = count($sarray);
    $k = 0;
    $columns = array();
    if($scount > 0)
    {
    	$storieslist=array();
    	foreach ($sarray as $storyid => $thisstory) {
    		$storieslist[] = $thisstory->storyid();
    	}
		$filesperstory = $sfiles->getCountbyStories($storieslist);

	    foreach ($sarray as $key => $thisstory) {
            $storyid = $thisstory->storyid();
	    	$filescount = array_key_exists($thisstory->storyid(),$filesperstory) ? $filesperstory[$thisstory->storyid()] : 0;
            $published = formatTimestamp($thisstory->published(), $dateformat);
			$bodytext = $thisstory->bodytext;
			$news = $thisstory->prepare2show($filescount);
            
            $len = strlen($thisstory->hometext());
            if ($letters < $len && $letters > 0){

			$patterns = array();
			$replacements = array();
			
			if($options[4] != 0) { $height = 'height="'.$imgheight.'"'; } // set height = 0 in block option for auto height
			
            $startdiv = '<div style="float:'.$imgposition.'"><a href="' . NW_MODULE_URL . '/article.php?storyid='.$storyid.'">'; 
            $style = 'style="border: '.$border.'px solid #'.$bordercolor.'"';
			$enddiv = 'alt="'.$thisstory->title.'" width="'.$imgwidth.'" '.$height.' /></a></div>';
		
     		$patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 width=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
			$patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
			$patterns[] = "/\[img]([^\"\(\)\?\&'<>]*)\[\/img\]/sU"; 
			$patterns[] = "/<img src=\"(.*)\" \/>/sU";             
			$patterns[] = "/<img src=(.*) \/>/sU";             

			$replacements[] = $startdiv.'<img '.$style.' src="\\3" '.$enddiv;
			$replacements[] = $startdiv.'<img '.$style.' src="\\3" '.$enddiv;
			$replacements[] = $startdiv.'<img '.$style.' src="\\1" '.$enddiv;
			$replacements[] = $startdiv.'<img '.$style.' src="\\1" '.$enddiv;
			$replacements[] = $startdiv.'<img '.$style.' src="\\1" '.$enddiv;

			$letters = strrpos(substr($thisstory->hometext,0, $letters), ' ');
			$news['text'] = preg_replace($patterns, $replacements, xoops_substr($thisstory->hometext, 0, $letters + 3));
			}
			
            if(is_object($xoopsUser) && $xoopsUser->isAdmin(-1)){
                $news['admin'] = '<a href="' . NW_MODULE_URL . '/admin/index.php?op=edit&amp;storyid='.$storyid.'"><img src="' . NW_MODULE_URL . '/images/edit_block.png" alt="'._EDIT.'" width="18" /></a> <a href="' . NW_MODULE_URL . '/admin/index.php?op=delete&amp;storyid='.$storyid.'"><img src="' . NW_MODULE_URL . '/images/delete_block.png" alt="'._DELETE.'" width="20" /></a>';
            } else {
       	        $news['admin'] = '';
            }
            if ($options[9] == 1) {
        	   $block['topiclink'] = '| <a href="' . NW_MODULE_URL . '/topics_directory.php">'._AM_NW_TOPICS_DIRECTORY.'</a> ';
            }
       	    if ($options[10] == 1) {
        	   $block['archivelink'] = '| <a href="' . NW_MODULE_URL . '/archive.php">'._MA_NW_NEWSARCHIVES.'</a> ';
            }
            if ($options[11] == 1) {
                if (empty($xoopsUser))
                {
                    $block['submitlink'] = '';
                } else {
                    $block['submitlink'] = '| <a href="' . NW_MODULE_URL . '/submit.php">'._MA_NW_SUBMITNEWS.'</a> ';
                }
            }

            $news['poster'] = '';
        	if ($options[12] == 1) {
                if ( $thisstory->uname() != '' ) {
					$news['poster'] = ''._MB_NW_LATESTNEWS_POSTER.' '.$thisstory->uname().'';
				}
            }
	        $news['posttime'] = '';
            if ($options[13] == 1) {
                if ( $thisstory->uname() != '' ) {
                    $news['posttime'] = ''._ON.' '.$published.'';
                } else
                {
					$news['posttime'] = ''._MB_NW_POSTED.' '._ON.' '.$published.'';
				}
	        } 
	        $news['topic_image'] = '';
	        $news['topic_articlepicture'] = '';
			if ($options[14] == 1) {
       			$news['topic_image'] = ''.$thisstory->imglink().'';
        	}        
	        $news['topic_title'] = '';
			if ($options[15] == 1) {
       			$news['topic_title'] = ''.$thisstory->textlink().'';
       			$news['topic_separator'] =  ( $thisstory->textlink() != '' ) ? _MB_NW_SP : '';
        	}
        	
            $news['read'] = '';
			if ($options[16] == 1) {
                $news['read']= '&nbsp;('.$thisstory->counter.' '._READS.')';
        	}

            $comments = $thisstory->comments();
            if(!empty($bodytext) || $comments>0){
            	$news['more'] = '<a href="' . NW_MODULE_URL . '/article.php?storyid='.$storyid.'">'. _MA_NW_READMORE .'</a>';
			}else{
        		$news['more'] = '';
			}
			
			if ($options[17] == 1) {
				if ($comments > 0) {
				//shows 1 comment instead of 1 comm. if comments ==1
				//langugage file modified accordingly
  		            if ($comments == 1) {
						$news['comment'] ='&nbsp;'._MA_NW_ONECOMMENT.'</a>&nbsp;';
	            	} else {
						$news['comment'] ='&nbsp;'.$comments.'&nbsp;'._MB_NW_NW_COMMENTS.'</a>&nbsp;';
					}
				} else {
					$news['comment'] ='&nbsp;'._MB_NW_NO_COMMENT.'</a>&nbsp;';
				}
			}

            $news['print'] = '';
			if ($options[18] == 1) {
                $news['print']= '<a href="' . NW_MODULE_URL . '/print.php?storyid='.$storyid.'" rel="nofollow"><img src="' . NW_MODULE_URL . '/images/print.png" width="22" alt="'._MA_NW_PRINTERFRIENDLY.'" /></a>';
        	}

            $news['pdf'] = '';
			if ($options[19] == 1) {
   				 $news['pdf']= '&nbsp;<a href="' . NW_MODULE_URL . '/makepdf.php?storyid='.$storyid.'" rel="nofollow"><img src="' . NW_MODULE_URL . '/images/acrobat.png" width="20" alt="'._MA_NW_MAKEPDF.'" /></a>&nbsp;';
        	}

            $news['email'] = '';
			if ($options[20] == 1) {
                $news['email']= '<a href="mailto:?subject='.sprintf(_MA_NW_INTARTICLE,$xoopsConfig['sitename']).'&amp;body='.sprintf(_MA_NW_INTARTFOUND, $xoopsConfig['sitename']).':  ' . NW_MODULE_URL . '/article.php?storyid='.$storyid.'" rel="nofollow"><img src="' . NW_MODULE_URL . '/images/friend.png" width="20" alt="'._MA_NW_SENDSTORY.'" /></a>&nbsp;';
        	}

			if ($options[21] == 1) {
//            $block['morelink'] = '&nbsp;<a href="' . NW_MODULE_URL . '/index.php?storytopic=0&start='.$limit.'">'._MB_NW_NW_MORE_STORIES.'</A> ';
              $block['morelink'] = '&nbsp;<a href="' . NW_MODULE_URL . '/index.php ">'._MB_NW_MORE_STORIES.'</A> ';
        	}
            
	        if ($options[22] == 1) {
				$block['latestnews_scroll'] = true;
	        } else {
				$block['latestnews_scroll'] = false;
	        }
			
	        $block['scrollheight'] = $options[23];
	        $block['scrollspeed'] = $options[24];

			$columns[$k][] = $news;
            $k++;
        	if ($k == $column_count) {
	            $k = 0;
        	}
		}
 	}
    unset($news);
    $block['columns']  = $columns;
    return $block;
}
Exemple #2
0
	} else {
		$topic_frontpage=false;
	}
	$sarray = nw_NewsStory::getAllPublished($xoopsOption['storynum'], $start, $xoopsModuleConfig['restrictindex'], $xoopsOption['storytopic'], 0, true, 'published', $topic_frontpage);

    $scount = count($sarray);
    $xoopsTpl->assign('story_count', $scount);
    $k = 0;
    $columns = array();
    if($scount>0)
    {
    	$storieslist=array();
    	foreach ($sarray as $storyid => $thisstory) {
    		$storieslist[]=$thisstory->storyid();
    	}
		$filesperstory = $sfiles->getCountbyStories($storieslist);

	    foreach ($sarray as $storyid => $thisstory) {
	    	$filescount = array_key_exists($thisstory->storyid(),$filesperstory) ? $filesperstory[$thisstory->storyid()] : 0;
        	$story = $thisstory->prepare2show($filescount);
        	// The line below can be used to display a Permanent Link image
        	// $story['title'] .= "&nbsp;&nbsp;<a href='".NW_MODULE_URL . "/article.php?storyid=".$sarray[$i]->storyid()."'><img src='".NW_MODULE_URL . "/images/x.gif' alt='Permanent Link' /></a>";
        	$story['news_title'] = $story['title'];
        	$story['title'] = $thisstory->textlink().'&nbsp;:&nbsp;'.$story['title'];
        	$story['topic_title'] = $thisstory->textlink();
        	$story['topic_separator'] =  ( $thisstory->textlink() != '' ) ? _MA_NW_SP : '';
        	$story['topic_color'] = '#'.$myts->displayTarea($thisstory->topic_color);
	       	if($firsttitle=='') {
       			$firsttitle=$myts->htmlSpecialChars($thisstory->topic_title()) . ' - ' .  $myts->htmlSpecialChars($thisstory->title());
       		}
        	$columns[$k][] = $story;