<commit_before><?php
    /**
     * @class PageHandler
     * @author NHN (<EMAIL>)
     * handles page navigation
     * @version 0.1
     *
     * @remarks Getting total counts, number of pages, current page number, number of items per page, 
     *          this class implements methods and contains variables for page navigation
     **/

    class PageHandler extends Handler {

        var $total_count = 0; ///< number of total items
        var $total_page = 0; ///< number of total pages
        var $cur_page = 0; ///< current page number
        var $page_count = 10; ///< number of page links displayed at one time
        var $first_page = 1; ///< first page number
        var $last_page = 1; ///< last page number
        var $point = 0; ///< increments per getNextPage() 

        /**
         * constructor
         * @param int $total_count number of total items
         * @param int $total_page number of total pages
         * @param int $cur_page current page number
         * @param int $page_count number of page links displayed at one time 
		 * @return void
         **/
        function PageHandler($total_count, $total_page, $cur_page, $page_count = 10) {
            $this->total_count = $total_count;
            $this->total_page = $total_page;
            $this->cur_page = $cur_page;
            $this->page_count = $page_count;
            $this->point = 0;

            $first_page = $cur_page - (int)($page_count/2);
            if($first_page<1) $first_page = 1;
            $last_page = $total_page;
            if($last_page>$total_page) $last_page = $total_page;

            $this->first_page = $first_page;
            $this->last_page = $last_page;

            if($total_page < $this->page_count) $this->page_count = $total_page;
        }

        /**
         * request next page
         * @return int next page number
         **/
        function getNextPage() {
            $page = $this->first_page+$this->point++;
            if($this->point > $this->page_count || $page > $this->last_page) $page = 0;
            return $page;
        }
		
        /**
         * return number of page that added offset.
		 * @param int $offset
         * @return int
         **/
		function getPage($offset) 
		{
			return max(min($this->cur_page + $offset, $this->total_page), '');
		}
    }
?>
<commit_msg>fixed a pagination<commit_after><?php
    /**
     * @class PageHandler
     * @author NHN (<EMAIL>)
     * handles page navigation
     * @version 0.1
     *
     * @remarks Getting total counts, number of pages, current page number, number of items per page, 
     *          this class implements methods and contains variables for page navigation
     **/

    class PageHandler extends Handler {

        var $total_count = 0; ///< number of total items
        var $total_page = 0; ///< number of total pages
        var $cur_page = 0; ///< current page number
        var $page_count = 10; ///< number of page links displayed at one time
        var $first_page = 1; ///< first page number
        var $last_page = 1; ///< last page number
        var $point = 0; ///< increments per getNextPage() 

        /**
         * constructor
         * @param int $total_count number of total items
         * @param int $total_page number of total pages
         * @param int $cur_page current page number
         * @param int $page_count number of page links displayed at one time 
		 * @return void
         **/
        function PageHandler($total_count, $total_page, $cur_page, $page_count = 10) {
            $this->total_count = $total_count;
            $this->total_page = $total_page;
            $this->cur_page = $cur_page;
            $this->page_count = $page_count;
            $this->point = 0;

            $first_page = $cur_page - (int)($page_count/2);
            if($first_page<1) $first_page = 1;

			if($total_page > $page_count && $first_page + $page_count - 1 > $total_page)
			{
				$first_page -= $first_page + $page_count - 1 - $total_page;
			}

            $last_page = $total_page;
            if($last_page>$total_page) $last_page = $total_page;

            $this->first_page = $first_page;
            $this->last_page = $last_page;

            if($total_page < $this->page_count) $this->page_count = $total_page;
        }

        /**
         * request next page
         * @return int next page number
         **/
        function getNextPage() {
            $page = $this->first_page+$this->point++;
            if($this->point > $this->page_count || $page > $this->last_page) $page = 0;
            return $page;
        }
		
        /**
         * return number of page that added offset.
		 * @param int $offset
         * @return int
         **/
		function getPage($offset) 
		{
			return max(min($this->cur_page + $offset, $this->total_page), '');
		}
    }
?>

{'fraction_non_alphanumeric': 0.12255406797116375, 'fraction_numerical': 0.007415036045314109, 'mean_word_length': 1.932367149758454, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5505835', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1395, 'n_words': 405}