:
if(!is_numeric($title_length)) $title_length = 30; //
if(!is_numeric($short_story_length)) $short_story_length = 80; // -
if(!is_numeric($img_maxsize)) $img_maxsize = 60; //
if(!is_numeric($news_num)) $news_num = 10; //
if(!is_numeric($sort_news_var)) $sort_news_var = 2; // 1 - , 2 - , 3 - , 4 - .
if(!is_numeric($titleonly)) $titleonly = 0; //0 - , 1 - , 2 - , 3 - .
if(!is_numeric($showcomments)) $showcomments = 1; //1 - , 0 - .
if(!is_string($bad_cat)) $bad_cat = '1500'; // , () : '10-11'. 1500 , id=1500 :)
if(!is_string($good_cat)) $good_cat = '0'; // , () : '10-11'. 0 - ( . )
////// /////////
if(!is_string($boxwrap)) $boxwrap = ul; // , .
if(!is_string($newswrap)) $newswrap = li; // , .
if(!is_string($newsprefix)) $newsprefix = rarr; // , 0 - , → '&' ';' , .. . : http://wdh.suncloud.ru/entities.htm
if(!is_string($boxclass)) $boxclass = r_news; // , . css :)
/*==========================================
tpl :
--------------------------------------------
{include file="engine/modules/r_news.php?&block_num=1&title_length=50&short_story_length=30&img_maxsize=80&news_num=20&sort_news_var=4&titleonly=0&showcomments=0&bad_cat=5-8-9&boxwrap=div&newswrap=span&newsprefix=0&boxclass=custom"}
============================================
( style.css :)
--------------------------------------------
.r_news li {display: block; position: relative; border-bottom: 1px solid #ddd; padding: 5px; color: #514f51; font: normal 10px/14px "Trebuchet MS", Tahoma, serif;}
.r_news li:first-line { font: normal 13px/16px Arial, serif;}
.r_news li:hover { background: #F5F5F5; color: #000;}
.r_news li b { color: #2d9dff;}
.r_news li:hover b, .r_news li:hover a{ color: #000;}
.r_news li a { text-decoration: none;}
.r_news li a:hover { text-decoration: underline; color: #2d9dff;}
==========================================*/
//***************** **********************//
$r_news_block = dle_cache( "r_news_block", $block_num);
if( !$r_news_block ) {
if ($sort_news_var == '1') {
$news_var = 'RAND()';
} if ($sort_news_var == '2') {
$news_var = 'date DESC';
} if ($sort_news_var == '3') {
$news_var = 'comm_num DESC';
} if ($sort_news_var == '4') {
$news_var = 'news_read DESC';
};
if ($newsprefix == '0') {
$newspref = '';
} else {
$newspref = '&'.$newsprefix.';';
};
$bad_category = str_replace('-', ',', $bad_cat);
$good_category = str_replace('-', ',', $good_cat);
if ($good_category == '0') {
$rr = $db->query('SELECT id, date, title, short_story, comm_num, SUBSTRING_INDEX(category,",",1) as category, alt_name, flag FROM '.PREFIX .'_post WHERE approve="1" AND category NOT IN ('.$bad_category.') ORDER BY '.$news_var.' LIMIT 0,'.$news_num);
} else {
$rr = $db->query('SELECT id, date, title, short_story, comm_num, SUBSTRING_INDEX(category,",",1) as category, alt_name, flag FROM '.PREFIX .'_post WHERE approve="1" AND category IN ('.$good_category.') ORDER BY '.$news_var.' LIMIT 0,'.$news_num);
};
while ($row = $db->get_row($rr))
{
if ($showcomments == '1') {
$comm_n = '('.$row['comm_num'].')';
} else {
$comm_n = '';
};//--
$ttl = stripslashes($row['title']);
$title_short = $ttl;
if( strlen( $title_short ) > $title_length ) $title_short = substr( $title_short, 0, $title_length ) . " ..."; //-- --
$s_story = strip_tags(str_replace(array('<br>','<br />')," ",$row['short_story'])); //-- --
if( strlen( $s_story ) > $short_story_length ) $s_story = substr( $s_story, 0, $short_story_length ) . " ..."; //-- --
$full_link = $config['http_home_url'].get_url($row['category'])."/".$row['id']."-".$row['alt_name'].".html"; //-- --
/*-----------------------
preg_match('|<img(.*) src="([^"]*)"[^>]*>|is', $row['short_story'], $ps);
if($ps[2])
{
$img_parts = pathinfo($ps[2]);
$img_link = $img_parts['dirname'].'/'.$img_parts['basename'];
*/
//----- --->
$count_img = preg_match_all('%(((http://www)|(http://)|(www))[-a-zA-Z0-9@:\%_\+.~#?&//=]+)\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)%i', $row['short_story'], $img_match);
if ($count_img > 0){
$img_parts = pathinfo($img_match[0][0]);
$img_link = $img_parts['dirname'].'/'.$img_parts['basename'];
$img_info = @getimagesize($img_link);
$img_width = $img_info[0];
$img_height = $img_info[1];
if ($img_width > $img_height)
{
$img_code = '<a href="'.$full_link.'"><IMG src="'.$img_link.'" alt="'.$ttl.'" width="'.$img_maxsize.'"/></a>';
} else $img_code = '<a href="'.$full_link.'"><IMG src="'.$img_link.'" alt="'.$ttl.'" height="'.$img_maxsize.'"/></a>';
}
else { $img_code ='<img src="{THEME}/images/nothumb.gif" alt="'.$ttl.'" width="'.$img_maxsize.'" height="'.$img_maxsize.'"/>';};
//<----- ---
///--- ------
$noimage_block .= '
<'.$newswrap.'>
<b>'.$newspref.' <a href="'.$full_link.'" title="'.$ttl.'">'.$title_short.'</a></b> '.$comm_n.'<br />
'.$s_story.'</'.$newswrap.'>';
$titleonly_block .= '
<'.$newswrap.'>
<b>'.$newspref.' <a href="'.$full_link.'" title="'.$ttl.'">'.$title_short.'</a></b> '.$comm_n.' </'.$newswrap.'>';
$image_block .= '
<'.$newswrap.'>
<div style="margin-bottom: 5px;"><b>'.$newspref.' <a href="'.$full_link.'" title="'.$ttl.'">'.$title_short.'</a></b> '.$comm_n.'</div>
<div style="padding-right: 3px; padding-bottom: 3px; float: left; width:'.$img_maxsize.'; height:'.$img_maxsize.';">'.$img_code.'</div>
<div style="margin-top: -3px;">'.$s_story.'</div><div style="clear: both; height:0;"></div></'.$newswrap.'>';
$image_block_s .= '
<'.$newswrap.'>
<div style="margin-bottom: 5px;"><b>'.$newspref.' <a href="'.$full_link.'" title="'.$ttl.'">'.$title_short.'</a></b> '.$comm_n.'</div>
<div style="width:'.$img_maxsize.'; height:'.$img_maxsize.';">'.$img_code.'</div></'.$newswrap.'>';
if ($titleonly == '0') {
$r_news = $noimage_block; }
if ($titleonly == '1') {
$r_news = $titleonly_block; }
if ($titleonly == '2') {
$r_news = $image_block; }
if ($titleonly == '3') {
$r_news = $image_block_s; }
};
$r_news_block = '<'.$boxwrap.' class="'.$boxclass.'">'.$r_news.'</'.$boxwrap.'>';
$db->free();
create_cache( "r_news_block". $block_num, $r_news_block);
}
///--- ------
echo $r_news_block;
?>