anpera.net

anpera.net

experimental server @home
Aktuelle Zeit: Do 28 Mär, 2024 15:00

Alle Zeiten sind UTC + 1 Stunde




Ein neues Thema erstellen Auf das Thema antworten  [ 2 Beiträge ] 
Autor Nachricht
BeitragVerfasst: Di 25 Sep, 2007 16:10 
Offline
Freak
Freak
Benutzeravatar

Registriert: Sa 28 Aug, 2004 18:48
Beiträge: 1712
Mir ist aufgefallen, dass dieses ständig passiert, sobald ein Thema die 16. Seite anfängt.. es ist schon oft bissl anstrengend, da immer zu klicken auf ne ältere seite bis man dann am ende ankommt.. kannst du da vielleicht was dran ändern anpera ? *liebguck*


aktuell ist es bei
» Commentary: Much-in-one-bundle (OOP); V 1.1.2

_________________
~Inaktiv und Abwesend solange Mysql hier Moderatorenrechte hat~


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di 25 Sep, 2007 20:56 
Offline
Admin
Admin
Benutzeravatar

Registriert: Di 21 Jan, 2003 01:11
Beiträge: 1604
Wohnort: Haßfurt
Geschlecht: Männlich
LoGD: http://www.anpera.net/logd
Skype: anpera-net
Uff, das ist komplizierter, als es zunächst aussah. Bei der "pagination" wird so viel auf- und abgerundet, dass ich es erstaunlich finde, dass da nicht mehr schief geht.

Mal sehen, ob ich mich am Wochenende da mal genauer durchwuseln kann. Für heute gebe ich auf.

[php]class pagination
{
var $requester;
var $parms;
var $start;

// constructor
function pagination($requester='', $parms='', $varname='')
{
$this->requester = $requester;
$this->parms = empty($parms) ? array() : $parms;
$this->varname = empty($varname) ? 'start' : $varname;
}


function append_sid($url, $non_html_amp = false)
{
global $SID;

if ( !empty($SID) && !preg_match('#sid=#', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}

return $url;
}


function get_forks($total_items, $item_per_page, $current_item)
{
global $config;

// get the number of pages
$total_pages = ceil($total_items / $item_per_page);

if ( $total_pages == 1 )
{
return '';
}

// limits:
// - scope_min & scope_max are the limits for the number of pages displayed
// - the percentage is applied to the total items to get the scope
$scope_min = empty($config->data['pagination_min']) ? 5 : intval($config->data['pagination_min']); // 2 on sides + current page
$scope_max = empty($config->data['pagination_max']) ? 11 : intval($config->data['pagination_max']); // 5 on sides + current page
$scope_percent = empty($config->data['pagination_percent']) ? 10 : intval($config->data['pagination_percent']); // 10 %

// center on the current page : $scope is half the number of page around the current page ($middle)
$scope = ceil((min(max(intval($total_items * $scope_percent / 100), $scope_max), $scope_min) - 1) / 2);
$middle = floor($current_item / $item_per_page);

// get forks limits
$left_end = min($scope, $total_pages-1);
$middle_start = max($middle-$scope, $scope, 0);
$middle_end = min( $middle + $scope, $total_pages-$scope );
$right_start = max( $total_pages-$scope-1, 0 );

// middle get over edges
$is_left = $middle_start > $left_end+$scope;
$is_right = $middle_end+$scope < $right_start;
if ( !$is_left )
{
$middle_start = 0;
}
if ( !$is_right )
{
$middle_end = $total_pages-1;
}

// store forks
$forks = array();
if ( $is_left )
{
$forks[] = array(0, $left_end);
}
$forks[] = array($middle_start, $middle_end);
if ( $is_right )
{
$forks[] = array($right_start, $total_pages-1);
}
return $forks;
}

function display($tpl_switch, $total_items, $item_per_page, $current_item, $page_1=true, $item_name_count='', $item_total_count=0)
{
global $template, $config, $user;

if ( empty($item_per_page) )
{
$item_per_page = 50;
}
$pages = $this->get_forks($total_items, $item_per_page, $current_item);
$current_page = floor($current_item / $item_per_page);
$total_pages = ceil($total_items / $item_per_page);
$res = '';

$n_count = !empty($item_total_count) ? $item_total_count : $total_items;
$l_count = ($n_count == 1) ? $item_name_count . '_1' : $item_name_count;

if ( ($total_pages > 1) || (($total_pages == 1) && $page_1) )
{
$template->assign_block_vars($tpl_switch, array(
'START_FIELD' => $this->varname,
'START' => $current_page * $item_per_page,

'U_PREVIOUS' => append_sid($config->url($this->requester, $this->parms + array($this->varname => (($current_page > 0) ? ($current_page-1) * $item_per_page : 0)))),
'L_PREVIOUS' => $user->lang('Previous'),
'I_PREVIOUS' => $user->img('left_arrow'),
'PREVIOUS' => ($current_page > 0) ? ($current_page-1) * $item_per_page : 0,

'U_NEXT' => append_sid($config->url($this->requester, $this->parms + array($this->varname => (($current_page+1 < $total_pages) ? ($current_page+1) * $item_per_page : ($total_pages-1) * $item_per_page)))),
'L_NEXT' => $user->lang('Next'),
'I_NEXT' => $user->img('right_arrow'),
'NEXT' => ($current_page+1 < $total_pages) ? ($current_page+1) * $item_per_page : ($total_pages-1) * $item_per_page,

'L_GOTO' => $user->lang('Goto_page'),
'I_GOTO' => $user->img('icon_gotopost'),
'L_PAGE_OF' => sprintf($user->lang('Page_of'), $current_page+1, $total_pages),
'L_COUNT' => sprintf($user->lang($l_count), $n_count),
));
$template->set_switch($tpl_switch . '.previous', $current_page > 0);
$template->set_switch($tpl_switch . '.next', ($current_page+1) < $total_pages);
$template->set_switch($tpl_switch . '.unique', ($total_pages <= 1) );

// dump the forks
if ( $total_pages > 1 )
{
$first = true;
$count_pages = count($pages);
for ( $j = 0; $j < $count_pages; $j++ )
{
if ( !$first )
{
// send "...,"
$template->set_switch($tpl_switch . '.page_number');
$template->set_switch($tpl_switch . '.page_number.number', false);
}
for ( $k = $pages[$j][0]; $k <= $pages[$j][1]; $k++ )
{
$template->assign_block_vars($tpl_switch . '.page_number', array(
'U_PAGE' => append_sid($config->url($this->requester, $this->parms + array($this->varname => $k * $item_per_page))),
'PAGE' => ($k + 1),
'START' => ($k * $item_per_page),
'L_SEP' => ($j == $count_pages - 1) && ($k == $pages[$j][1]) ? '' : ', ',
));
$last = ($j == $count_pages - 1) && ($k == $pages[$j][1]);
$template->set_switch($tpl_switch . '.page_number.number');
$template->set_switch($tpl_switch . '.page_number.number.current', ($k == $current_page));
$first = false;
}
}
}
}
}
}[/php]

_________________
Praxis ist, wenn alles klappt aber keiner weiß warum. Theorie ist, wenn man weiß wie es geht, aber nichts klappt. Wir haben beides erfolgreich vereinigt: Bei uns klappt nichts und keiner weiß warum!

Neues Video: Marios freier Tag in Second Life


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 2 Beiträge ] 

Alle Zeiten sind UTC + 1 Stunde


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 4 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen
Du darfst keine Antworten zu Themen in diesem Forum erstellen
Du darfst deine Beiträge in diesem Forum nicht ändern
Du darfst deine Beiträge in diesem Forum nicht löschen
Du darfst keine Dateianhänge in diesem Forum erstellen

Suche nach:
Gehe zu:  
cron
POWERED_BY
Deutsche Übersetzung durch phpBB.de
anpera.net - Impressum