OpenCart

Класс Pagination { ... }

Название свойства Описание
Pagination::$total public mixed $total
Pagination::$page public mixed $page = 1;
Pagination::$limit public mixed $limit = 20;
Pagination::$num_links public mixed $num_links = 10;
Pagination::$url public mixed $url = '';
Pagination::$text public mixed $text = 'Showing {start} to {end} of {total} ({pages} Pages)';
Pagination::$text_first public mixed $text_first = '|<
Pagination::$text_last public mixed $text_last = '>
Pagination::$text_next public mixed $text_next = '>
Pagination::$text_prev public mixed $text_prev = '<
Pagination::$style_links public mixed $style_links = 'links';
Pagination::$style_results public mixed $style_results = 'results';
Тип Возвр. Описание
public mixed render ( )
Исходный код метода:
$total = $this->total;

if ($this->page < 1) {
	$page = 1;
} else {
	$page = $this->page;
}

if (!(int)$this->limit) {
	$limit = 10;
} else {
	$limit = $this->limit;
}

$num_links = $this->num_links;
$num_pages = ceil($total / $limit);

$output = '';

if ($page > 1) {
	$output .= ' <a href="' . str_replace('{page}', 1, $this->url) . '">' . $this->text_first . '</a> <a href="' . str_replace('{page}', $page - 1, $this->url) . '">' . $this->text_prev . '</a> ';
}

if ($num_pages > 1) {
	if ($num_pages <= $num_links) {
		$start = 1;
		$end = $num_pages;
	} else {
		$start = $page - floor($num_links / 2);
		$end = $page + floor($num_links / 2);
	
		if ($start < 1) {
			$end += abs($start) + 1;
			$start = 1;
		}
				
		if ($end > $num_pages) {
			$start -= ($end - $num_pages);
			$end = $num_pages;
		}
	}

	if ($start > 1) {
		$output .= ' .... ';
	}

	for ($i = $start; $i <= $end; $i++) {
		if ($page == $i) {
			$output .= ' <b>' . $i . '</b> ';
		} else {
			$output .= ' <a href="' . str_replace('{page}', $i, $this->url) . '">' . $i . '</a> ';
		}	
	}
					
	if ($end < $num_pages) {
		$output .= ' .... ';
	}
}

if ($page < $num_pages) {
	$output .= ' <a href="' . str_replace('{page}', $page + 1, $this->url) . '">' . $this->text_next . '</a> <a href="' . str_replace('{page}', $num_pages, $this->url) . '">' . $this->text_last . '</a> ';
}

$find = array(
	'{start}',
	'{end}',
	'{total}',
	'{pages}'
);

$replace = array(
	($total) ? (($page - 1) * $limit) + 1 : 0,
	((($page - 1) * $limit) > ($total - $limit)) ? $total : ((($page - 1) * $limit) + $limit),
	$total, 
	$num_pages
);

return ($output ? '<div class="' . $this->style_links . '">' . $output . '</div>' : '') . '<div class="' . $this->style_results . '">' . str_replace($find, $replace, $this->text) . '</div>';

Связанные классы:

Название класса Роль
Нет связанных классов

Комментарии