Файл: sys/fnc/page.php
Строк: 387
<?php
function page($k_page = 1) { // Выдает текущую страницу
$page = 1;
if (isset($_GET['p'])) {
if ($_GET['p'] == 'end') {
$page = intval($k_page);
} elseif (is_numeric($_GET['p'])) {
$page = intval($_GET['p']);
}
}
if ($page < 1) {
$page = 1;
}
if ($page > $k_page) {
$page = $k_page;
}
return $page;
}
function k_page($k_post = 0, $k_p_str = 10) { // Высчитывает количество страниц
if ($k_post != 0) {
$v_pages = ceil($k_post / $k_p_str);
return $v_pages;
} else {
return 1;
}
}
function str($link = '?', $k_page = 1, $page = 1) { // Вывод номеров страниц (только на первый взгляд кажется сложно ;))
?>
<style>
.pagination a.prev span,.pagination a.next span {
color:#069;
}
.pagination a {
text-decoration:none;
}
.pagination .pagination_ar .page {
color:#06F;
}
.pagination {
background: #fff;
padding:7px 10px;
}
.page_links input.page_choose,.pagination a.prev,.pagination a.next,.pagination .page_links,.pagination .page_links a {
color:#666;
}
.pagination a.prev span,.pagination a.next span {
text-decoration:underline;
}
.pagination .pagination_ar .page {
background:#f5f5f5
}
.pagination a.prev:hover span,.pagination a.next:hover span,.pagination .pagination_ar .page:hover {
color:red;
}
.pagination_ar {
margin-bottom:5px;
font-size:0
}
.pagination .page_links,.pagination .page_links a {
vertical-align:baseline
}
.pagination .page_links a,.pagination .page_links .current,.page_links input.page_choose {
margin:0 0px 0px 0;
-webkit-border-radius:4px;
border-radius:4px
}
.pagination .page_links a,.page_num_input,.pagination .page_links i,.pagination .page_links .current,.page_links input.page_choose, .pagination_ar a,.pagination_ar .page {
font-size:medium;
}
.pagination_ar .page {
font-size:small;
}
.page_num_input {
width:35px;
padding:2px 0;
margin:0;
background:#fff url(http://i.spaces.ru/pagination_page_num_input.png) left top repeat-x;
}
.pagination .pagination_ar .page {
padding:0;
}
.pagination .pagination_ar .page {
margin:0;
}
.text_input {
background:#fff url(http://i.spaces.ru/pagination_page_num_input.png) left top repeat-x;
}
.pagination .pagination_ar .page {
border:none
}
.pagination_ar,.page_links {
_font-size:medium;
}
.pagination .page_links,.pagination .page_links a {
vertical-align:baseline
}
.page_links a,.page_links input.page_choose,button.custom_button {
display:inline-block;
background:#fefefe;
background:-webkit-gradient(linear,left top,left bottom,from(#fefefe),to(#e6e6e6));
background:-moz-linear-gradient(top,#fefefe,#e6e6e6);
background:-o-linear-gradient(top,#fefefe,#e6e6e6);
padding:1px;
border:1px solid #cdcdcd
}
.page_links input.page_choose {
padding:1px 5px
}
.page_links a:hover,.page_links input.page_choose:hover {
background:#fefefe;
background:-webkit-gradient(linear,left top,left bottom,from(#fefefe),to(#d0d0d0));
background:-moz-linear-gradient(top,#fefefe,#d0d0d0);
background:-o-linear-gradient(top,#fefefe,#d0d0d0);
}
.page_links a:active,.page_links input.page_choose:active {
background:#d0d0d0;
background:-webkit-gradient(linear,left top,left bottom,from(#d0d0d0),to(#fefefe));
background:-moz-linear-gradient(top,#d0d0d0,#fefefe);
background:-o-linear-gradient(top,#d0d0d0,#fefefe);
}
.page_links .separate {
padding:1px 2px
}
.small_screen .page_links .search_page_block {
padding:1px 3px 1px 0
}
.page_links .current,input[type= "submit"].main_submit,input[type="submit"].green_button,.white,input[type="submit"].positive_button {
color:#fff
}
.search_page_block i,.page_links .current,.busi,.page_is,div.block {
padding:1px
}
.page_links,.font0 {
font-size:0
}
.page_links i {
padding:0 4px
}
.page_links .current {
background:#686868;
background:-webkit-gradient(linear,left top,left bottom,from(#686868),to(#adadad));
background:-moz-linear-gradient(top,#686868,#adadad);
background:-o-linear-gradient(top,#686868,#adadad);
border:1px solid #737373
}
.pagination_ar,.page_links {
_font-size:medium;
}
.page_links a:hover {
_text-decoration:none;
_background:#fefefe;
}
.page_links .current {
_color:#fff;
}
.page_links a:hover, .page_links input.page_choose:hover, button.custom_button:hover {
background: -webkit-gradient(linear,left top,left bottom,from(#fefefe),to(#d0d0d0));
}
.page_links a:active, .page_links input.page_choose:active, button.custom_button:active {
background:-webkit-gradient(linear,left top,left bottom,from(#d0d0d0),to(#fefefe));
}
.round_corners, .busi_switcher table a, .busi_switcher table span.active_item, .button_block input, .form_button, .friends_access_list, input[type="submit"].main_submit, input[type="submit"].green_button, .edit_button {
-webkit-border-radius: 4px;
border-radius: 4px;
}
.go {
border: 1px solid #a0a0a0;
text-shadow: 1px 1px 0 #fff;
padding: 3px 8px;
margin: 0;
}
.go:hover {
background:#fefefe;
background:-webkit-gradient(linear,left top,left bottom,from(#fefefe),to(#d0d0d0));
background:-moz-linear-gradient(top,#fefefe,#d0d0d0);
background:-o-linear-gradient(top,#fefefe,#d0d0d0);
}
.go:active {
background:#d0d0d0;
background:-webkit-gradient(linear,left top,left bottom,from(#d0d0d0),to(#fefefe));
background:-moz-linear-gradient(top,#d0d0d0,#fefefe);
background:-o-linear-gradient(top,#d0d0d0,#fefefe);
}
.go {
background: #fefefe;
background: -webkit-gradient(linear,left top,left bottom,from(#fefefe),to(#e6e6e6));
background: -moz-linear-gradient(top,#fefefe,#e6e6e6);
background: -o-linear-gradient(top,#fefefe,#e6e6e6);
font-size:medium;
border:1px solid #a0a0a0;
text-shadow:1px 1px 0 #fff;
padding:3px 8px;
margin-left: 2px;
-webkit-border-radius:4px;
border-radius:4px;
cursor: pointer;
}
.separate_links_item {
border-left: 1px solid #CCC;
margin: 0 8px;
}
</style>
<?php
if ($page < 1) {
$page = 1;
}
echo "<div class='pagination'>n";
echo "<div style='pagination_ar'>n";
if ($page > 1) {
echo "<a href='" . $link . "p=" . ($page - 1) . "' class='prev'><span>← Предыдущая</span></a>n";
}
if ($page < $k_page) {
echo ($page > 1 ? "<i class='separate_links_item'></i>" : NULL) . "<a href='" . $link . "p=" . ($page + 1) . "' class='next'><span>Следующая →</span></a>n";
}
echo "</div>n";
echo "<div class='page_links'>n";
if ($page != 1) {
echo "<a href='" . $link . "p=1'><span> 1 </span></a><i></i>n";
} else {
echo "<span class='current'><span> 1 </span></span><i></i>n";
}
for ($ot = -3; $ot <= 3; $ot++) {
if ($page + $ot > 1 && $page + $ot < $k_page) {
if ($ot == -3 && $page + $ot > 2) {
echo " ..";
}
if ($ot != 0) {
echo "<a href='" . $link . "p=" . ($page + $ot) . "'><span> " . ($page + $ot) . " </span></a><i></i>n";
} else {
echo "<span class='current'><span> " . ($page + $ot) . " </span></span><i></i>n";
}
if ($ot == 3 && $page + $ot < $k_page - 1) {
echo " ..";
}
}
}
if ($page != $k_page) {
echo "<a href='" . $link . "p=end'><span> $k_page </span></a><i></i>n";
} elseif ($k_page > 1) {
echo "<span class='current'><span> $k_page </span></span></a><i></i>n";
}
?>
</span>
<?php
echo "</div>n";
echo "</div>n";
echo '</form>';
}