Ticket #37: QPaginatorBase.diff

File QPaginatorBase.diff, 2.8 kB (added by fa7ll7en, 5 months ago)

paginator base with set page number in _construct and other changes

  • QPaginatorBase.class.php

     
    1111         * @property integer $ItemsPerPage is how many items you want to display per page when Pagination is enabled 
    1212         * @property integer $PageNumber is the current page number you are viewing 
    1313         * @property integer $TotalItemCount is the total number of items in the ENTIRE recordset -- only used when Pagination is enabled 
     14         * @property string  $QueryVar is the name for the query variable for paginator links so that Pagination is accessible without JS -- feel free to change 
    1415         * @property boolean $UseAjax 
    1516         * @property-read integer $PageCount 
    1617         * @property mixed $WaitIcon 
     
    2526                protected $intItemsPerPage = 15; 
    2627                protected $intPageNumber = 1; 
    2728                protected $intTotalItemCount = 0; 
     29                protected $strQueryVar = 'paginator'; 
    2830                protected $blnUseAjax = false; 
    2931                protected $objPaginatedControl; 
    3032                protected $objWaitIcon = 'default'; 
     
    4446                        } 
    4547                         
    4648                        $this->Setup(); 
     49                        $this->SetPageNumber(); 
    4750                } 
    4851         
    49                 protected function Setup() 
    50                 { 
     52                protected function Setup() { 
    5153                        // Setup Pagination Events 
    5254                        if ($this->blnUseAjax) 
    5355                                $this->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'Page_Click', $this->objWaitIcon)); 
     
    6567                        $this->objPaginatedControl->PageNumber = QType::Cast($strParameter, QType::Integer);                     
    6668                } 
    6769 
     70                public function SetPageNumber() { 
     71                        if (!QApplication::$RequestMode && QApplication::QueryString($this->strQueryVar) != null) { 
     72                                $strParameter = QApplication::QueryString($this->strQueryVar); 
     73                                $this->PageNumber = QType::Cast($strParameter, QType::Integer); 
     74                        } 
     75                } 
     76 
     77                // build the query string 
     78                public function SetPaginatorHref(){ 
     79                        $_GET[$this->strQueryVar] = $this->strActionParameter; //$strActionParameter; 
     80                        return QApplication::GenerateQueryString(); 
     81                } 
     82 
    6883                public function SetPaginatedControl(QPaginatedControl $objPaginatedControl) { 
    6984                        $this->objPaginatedControl = $objPaginatedControl; 
    7085 
     
    8398                                case "ItemsPerPage": return $this->intItemsPerPage; 
    8499                                case "PageNumber": return $this->intPageNumber; 
    85100                                case "TotalItemCount": return $this->intTotalItemCount; 
     101                                case 'QueryVar':return $this->strQueryVar; 
    86102                                case "UseAjax": return $this->blnUseAjax; 
    87103                                case "PageCount": 
    88104                                        return floor($this->intTotalItemCount / $this->intItemsPerPage) + 
     
    147163                                                $objExc->IncrementOffset(); 
    148164                                                throw $objExc; 
    149165                                        } 
     166                                         
     167                                case 'QueryVar': 
     168                                        try { 
     169                                                return ($this->strQueryVar = QType::Cast($mixValue, QType::String)); 
     170                                        } catch (QCallerException $objExc) { 
     171                                                $objExc->IncrementOffset(); 
     172                                                throw $objExc; 
     173                                        } 
    150174 
    151175                                case "UseAjax": 
    152176                                        try {