View file vkclone-0.0.1/protected/components/CPager.php

File size: 1.13Kb
<?php
class CPager extends CBasePager {
	public $htmlOptions = array('class' => 'blue_block center-aligned');
	public $separator = ' | ';

	/**
	 * Runs widget
	 */
	public function run() {
		if ($this->pageCount == 0)
			return;
		$currentPage=$this->getCurrentPage();

		$links = array();
		if ($currentPage > 0) {
			$links[] = $this->generatePageLink(Yii::t('yii','&lt;&lt; First'), 0);
			$links[] = $this->generatePageLink(Yii::t('yii','&lt; Previous'), $currentPage - 1);
		}
		$links[] = CHtml::tag('strong', array(), Yii::t('yii', '{currentPage} page of {pageCount}', array('{currentPage}' => $currentPage + 1, '{pageCount}' => $this->pageCount)));
		if (($currentPage + 1) < $this->pageCount) {
			$links[] = $this->generatePageLink(Yii::t('yii','Next &gt;'), $currentPage + 1);
			$links[] = $this->generatePageLink(Yii::t('yii','Last &gt;&gt;'), $this->pageCount - 1);
		}

		echo CHtml::tag('div', $this->htmlOptions, implode($this->separator, $links));
	}

	/**
	 * Generates link to page
	 */
	private function generatePageLink($label, $page) {
		return CHtml::link(CHtml::tag('strong', array(), $label), $this->createPageUrl($page));
	}
}