Просмотр файла sys/widgets/worldnews/index.php

Размер файла: 6.5Kb
<?php

defined('DCMS') or die;

$query = mysql_query("SELECT `format_widget` FROM `wn_set`") or die (mysql_error());
$row = mysql_fetch_array($query);
$format = $row["format_widget"];

$listing = new listing();

if($format == '1'){
	$post = $listing->post();
	$post->hightlight = true;
	$post->icon('worldnews');
	$post->url = '/worldnews/';
	$post->title = __('Мировые новости');
}

if($format == '2'){
	$post = $listing->post();
	$post->hightlight = true;
	$post->icon('worldnews');
	$post->url = '/worldnews/';
	$post->title = __('Мировые новости');
	
	$query = mysql_query("SELECT `title`,`time`,`id` FROM `wn_news` WHERE `status` = 1 order by `unix` DESC LIMIT 0,3") or die (mysql_error());
	while($row = mysql_fetch_array($query)){
		$post = $listing->post();
		$post->icon('newspaper');
		$post->url = '/worldnews/read.php?news='.$row["id"];
		$post->title = __($row["title"]);

	}
}



if($format == '3'){
										@$page = abs(intval($_GET['page']));
										if(empty($page)){$page = 1;}

										$query = mysql_query("SELECT `counts_on_page` FROM `wn_set`");
										$row = mysql_fetch_array($query);

										$num = $row["counts_on_page"]; 
										$result00 = mysql_query("SELECT COUNT(*) FROM `wn_news` WHERE `status` = 1 ");
										$temp = mysql_fetch_array($result00);
										$posts = $temp[0];
										$total = (($posts - 1) / $num) + 1;
										$total =  intval($total);
										$page = intval($page);
										if(empty($page) or $page < 0) $page = 1;
										if($page > $total) $page = $total;
										$start = $page * $num - $num; 
										if(($start == '-1')||($start == '-20'))
											{
												$start = 0;
											}
										if($temp[0] == 0)
										     {
										        echo '<div class="blockmess">Обсуждений нет</div>';
										     }

										$yesterday = date("d.m.Y", time()-3600*24);
										$today = date("d.m.Y");


										$listing = new listing();

													//////
														#if(file_exists(HOME."/worldnews/install/index.php")){
														#header("Location: /worldnews/install");
													#}
													//////

										echo '<div class = "listing">';
												$query = mysql_query("SELECT * FROM `wn_news` WHERE `status` = 1  ORDER by `unix` desc LIMIT $start, $num");
												while(@$row = mysql_fetch_array($query))
													{

														
														$time = $row["time"];
														$date = $row["date"];

														switch ($date) {
															case $today:
																$date = 'cегодня';
																break;

															case $yesterday:
																$date = 'вчера';
																break;

															
															default:
																$date = $date;
																break;
														}

															$post = $listing->post();
															$post->url = 'read.php?news='.$row["id"];
															$post->title = __('<font size = "1">'.$row["time"].'</font> &middot; '.$row["title"]);
															$post->time = $date;
															
															$date = $date["date"];

													}
													$listing->display(__('Первый запуск рекомендуется сделать в ручную. Первый запуск достаточно объемный, и запрос может занять около 60 секунд времени. <br />
																		После первого запуска перейдите в админку и прочитайте что делать дальше. <br />
																		<a href = "sync.php">Запустить</a>
														'));
										echo '</div>';


										do
										                    {
										                    	Error_Reporting(E_ALL & ~E_NOTICE);
										                        if($page - 5 > 0) $page5left = ' <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page - 5) .'" >'. ($page - 5) .'</a>  ';
										                        if($page - 4 > 0) $page4left = ' <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page - 4) .'" >'. ($page - 4) .'</a>  ';
										                        if($page - 3 > 0) $page3left = ' <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page - 3) .'" >'. ($page - 3) .'</a>  ';
										                        if($page - 2 > 0) $page2left = ' <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page - 2) .'" >'.($page - 2) .'</a>  ';
										                        if($page - 1 > 0) $page1left = '<a class="gradient_grey border radius padding" href="/worldnews?page='. ($page - 1) .'" >'.($page - 1) .'</a>  ';

										                        if($page + 5 <= $total) $page5right = '  <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page + 5) .'" >'. ($page + 5) .'</a>';
										                        if($page + 4 <= $total) $page4right = '  <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page + 4) .'" >'. ($page + 4) .'</a>';
										                        if($page + 3 <= $total) $page3right = '  <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page + 3) .'" >'. ($page + 3) .'</a>';
										                        if($page + 2 <= $total) $page2right = '  <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page + 2) .'" >'. ($page + 2) .'</a>';
										                        if($page + 1 <= $total) $page1right = '  <a class="gradient_grey border radius padding" href="/worldnews?page='. ($page + 1) .'" >'. ($page + 1) .'</a>';

										                        // Вывод меню если страниц больше одной
										                        
										                        if ($total > 1)
										                            {
										                                
										                                echo "<div class=\"pages\">";
										                                echo $pervpage.$page5left.$page4left.$page3left.$page2left.$page1left.'<span class="gradient_blue invert border radius padding">'.$page.'</span>'.$page1right.$page2right.$page3right.$page4right.$page5right.$nextpage;
										                                echo "</div>";
										                            }
										                    }
										                
										                    while (@$row = mysql_fetch_array($query));
										}

if($format != 3)
	$listing->display();


?>