здравствуйте каму не лень очень нужна перевести вот этат кусок кода на php 7 Код (Text): function navigation($gc, $num, $type){ global $tpl, $page; $gcount = $gc; $cnt = $num; $items_count = $cnt; $items_per_page = $gcount; $page_refers_per_page = 5; $pages = ''; $pages_count = ( ( $items_count % $items_per_page != 0 ) ) ? floor( $items_count / $items_per_page ) + 1 : floor( $items_count / $items_per_page ); $start_page = ( $page - $page_refers_per_page <= 0 ) ? 1 : $page - $page_refers_per_page + 1; $page_refers_per_page_count = ( ( $page - $page_refers_per_page < 0 ) ? $page : $page_refers_per_page ) + ( ( $page + $page_refers_per_page > $pages_count ) ? ( $pages_count - $page ) : $page_refers_per_page - 1 ); if($page > 1) $pages .= '<a href="'.$type.($page-1).'" onClick="Page.Go(this.href); return false">«</a>'; else $pages .= ''; if ( $start_page > 1 ) { $pages .= '<a href="'.$type.'1" onClick="Page.Go(this.href); return false">1</a>'; $pages .= '<a href="'.$type.( $start_page - 1 ).'" onClick="Page.Go(this.href); return false">...</a>'; } for ( $index = -1; ++$index <= $page_refers_per_page_count-1; ) { if ( $index + $start_page == $page ) $pages .= '<span>' . ( $start_page + $index ) . '</span>'; else $pages .= '<a href="'.$type.($start_page+$index).'" onClick="Page.Go(this.href); return false">'.($start_page+$index).'</a>'; } if ( $page + $page_refers_per_page <= $pages_count ) { $pages .= '<a href="'.$type.( $start_page + $page_refers_per_page_count ).'" onClick="Page.Go(this.href); return false">...</a>'; $pages .= '<a href="'.$type.$pages_count.'" onClick="Page.Go(this.href); return false">'.$pages_count.'</a>'; } $resif = $cnt/$gcount; if(ceil($resif) == $page) $pages .= ''; else $pages .= '<a href="'.$type.($page+1).'" onClick="Page.Go(this.href); return false">»</a>'; if ( $pages_count <= 1 ) $pages = ''; $tpl_2 = new mozg_template(); $tpl_2->dir = TEMPLATE_DIR; $tpl_2->load_template('nav.tpl'); $tpl_2->set('{pages}', $pages); $tpl_2->compile('content'); $tpl_2->clear(); $tpl->result['content'] .= $tpl_2->result['content']; } function box_navigation($gc, $num, $id, $function, $act){ global $tpl, $page; $gcount = $gc; $cnt = $num; $items_count = $cnt; $items_per_page = $gcount; $page_refers_per_page = 5; $pages = ''; $pages_count = ( ( $items_count % $items_per_page != 0 ) ) ? floor( $items_count / $items_per_page ) + 1 : floor( $items_count / $items_per_page ); $start_page = ( $page - $page_refers_per_page <= 0 ) ? 1 : $page - $page_refers_per_page + 1; $page_refers_per_page_count = ( ( $page - $page_refers_per_page < 0 ) ? $page : $page_refers_per_page ) + ( ( $page + $page_refers_per_page > $pages_count ) ? ( $pages_count - $page ) : $page_refers_per_page - 1 ); if(!$act) $act = "''"; else $act = "'{$act}'"; if($page > 1) $pages .= '<a href="" onClick="'.$function.'('.$id.', '.($page-1).', '.$act.'); return false">«</a>'; else $pages .= ''; if ( $start_page > 1 ) { $pages .= '<a href="" onClick="'.$function.'('.$id.', 1, '.$act.'); return false">1</a>'; $pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page-1).', '.$act.'); return false">...</a>'; } for ( $index = -1; ++$index <= $page_refers_per_page_count-1; ) { if ( $index + $start_page == $page ) $pages .= '<span>' . ( $start_page + $index ) . '</span>'; else $pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page+$index).', '.$act.'); return false">'.($start_page+$index).'</a>'; } if ( $page + $page_refers_per_page <= $pages_count ) { $pages .= '<a href="" onClick="'.$function.'('.$id.', '.($start_page + $page_refers_per_page_count).', '.$act.'); return false">...</a>'; $pages .= '<a href="" onClick="'.$function.'('.$id.', '.$pages_count.', '.$act.'); return false">'.$pages_count.'</a>'; } $resif = $cnt/$gcount; if(ceil($resif) == $page) $pages .= ''; else $pages .= '<a href="/" onClick="'.$function.'('.$id.', '.($page+1).', '.$act.'); return false">»</a>'; if ( $pages_count <= 1 ) $pages = ''; $tpl_2 = new mozg_template(); $tpl_2->dir = TEMPLATE_DIR; $tpl_2->load_template('nav.tpl'); $tpl_2->set('{pages}', $pages); $tpl_2->compile('content'); $tpl_2->clear(); $tpl->result['content'] .= $tpl_2->result['content']; }
sql - нету array - [] код: PHP: <?php class Page { public static $PG = FALSE; public static $MX = FALSE; public static $CP = FALSE; public static $SUMPAGE = FALSE; public static $SET = FALSE; public static function Input( $MAX = 0, $PAGE = 15 ) { self::$MX = $MAX; self::$CP = $PAGE; $ID_PAGE = (int)( $_GET['pg'] ?? 1 ); self::$PG = ( $ID_PAGE > 0 ? $ID_PAGE : 1 ); self::$SUMPAGE = ceil ( self::$MX / self::$CP ); self::$PG = ( self::$PG <= self::$SUMPAGE ? self::$PG : 1 ); self::$SET = ( self::$PG * self::$CP - self::$CP ); } public static function Output( $CLASS = FALSE ) { function __R( $NUM ) { $_GET['pg'] = $NUM; return '/?' . http_build_query ( $_GET ); } if ( self::$SUMPAGE > 1 ) { $PG = $FL = []; # левые паги кнопки if ( self::$PG - 4 > 0 ) $PG[] = '<a id = "RAY_AJAX" class = "PG_BUTTON" href = "' . __R( 1 ) . '">1</a>'; if ( self::$PG - 5 > 0 ) $PG[] = '<a class = "PG_BUTTON">...</a>'; if ( self::$PG - 3 > 0 ) $PG[] = '<a id = "RAY_AJAX" class = "PG_BUTTON" href = "' . __R( ( self::$PG - 3 ) ) . '">' . ( self::$PG - 3 ) . '</a>'; if ( self::$PG - 2 > 0 ) $PG[] = '<a id = "RAY_AJAX" class = "PG_BUTTON" href = "' . __R( ( self::$PG - 2 ) ) . '">' . ( self::$PG - 2 ) . '</a>'; if ( self::$PG - 1 > 0 ) $PG[] = '<a id = "RAY_AJAX" class = "PG_BUTTON" href = "' . __R( ( self::$PG - 1 ) ) . '">' . ( self::$PG - 1 ) . '</a>'; if ( self::$PG == self::$SUMPAGE ) { $PG[] = '<a class = "PG_BUTTON CR_BUTTON">' . self::$PG . '</a>'; } elseif ( self::$PG == 1 ) { $PG[] = '<a class = "PG_BUTTON CR_BUTTON">' . self::$PG . '</a>'; } elseif ( self::$SUMPAGE != 1 ) { $PG[] = '<a class = "PG_BUTTON CR_BUTTON">' . self::$PG . '</a>'; } # правые паги кнопки if ( self::$PG + 1 <= self::$SUMPAGE ) $PG[] = '<a id = "RAY_AJAX" class = "PG_BUTTON" href = "' . __R( ( self::$PG + 1 ) ) . '">' . ( self::$PG + 1 ) . '</a>'; if ( self::$PG + 2 <= self::$SUMPAGE ) $PG[] = '<a id = "RAY_AJAX" class = "PG_BUTTON" href = "' . __R( ( self::$PG + 2 ) ) . '">' . ( self::$PG + 2 ) . '</a>'; if ( self::$PG + 3 <= self::$SUMPAGE ) $PG[] = '<a id = "RAY_AJAX" class = "PG_BUTTON" href = "' . __R( ( self::$PG + 3 ) ) . '">' . ( self::$PG + 3 ) . '</a>'; if ( self::$PG + 5 <= self::$SUMPAGE ) $PG[] = '<a class = "PG_BUTTON">...</a>'; if ( self::$PG + 4 <= self::$SUMPAGE ) $PG[] = '<a id = "RAY_AJAX" class = "PG_BUTTON" href = "' . __R( self::$SUMPAGE ) . '">' . self::$SUMPAGE . '</a>'; return '<div class="' . ( empty ( $CLASS ) ? 'PG_HEADER' : $CLASS ) . '"><div style="text-align:center;">' . implode ( '', $PG ) . '</div></div>'; } else { return FALSE; } } }
только код не оригинальный, драблы заметны и улучшить скомповать можно. Но для начала сойдет --- Добавлено --- PHP: $tpl_2 = new mozg_template(); збс