Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
CommentLinkPager.php
1 <?php
2 /**
3  * Created by JetBrains PhpStorm.
4  * User: Andrey
5  * Date: 1/17/14
6  * Time: 1:01 PM
7  * To change this template use File | Settings | File Templates.
8  */
9 
10 class CommentLinkPager extends CLinkPager
11 {
12  public $contentId;
13  /**
14  * Creates the URL suitable for pagination.
15  * @param integer $page the page that the URL should point to.
16  * @return string the created URL
17  * @see CPagination::createPageUrl
18  */
19  protected function createPageUrl($page)
20  {
21  $url = Yii::app()->request->getUrl();
22  $name = "clw{$this->contentId}";
23  $newParam = "clw{$this->contentId}=$page";
24  if (($oldValue = Yii::app()->request->getParam($name)) !== null) {
25  $url = str_replace("$name=$oldValue", $newParam, $url);
26  } else {
27  if (strpos($url, '?') !== false) {
28  $url .= '&' . $newParam;
29  } else {
30  $url .= '?' . $newParam;
31  }
32  }
33  $url .= '#list_' . $this->contentId;
34 
35  return $url;
36  }
37 
38  /**
39  * @param boolean $recalculate whether to recalculate the current page based on the page size and item count.
40  * @return integer the zero-based index of the current page. Defaults to 0.
41  * @see CPagination::getCurrentPage
42  */
43  public function getCurrentPage($recalculate=true)
44  {
45  return Yii::app()->request->getParam("clw{$this->contentId}", 0);
46  }
47 
48 }