<commit_before><?php

/**
 * BreezePagination
 *
 * The purpose of this file is to create a pagination from an array of items
 * @package Breeze mod
 * @version 1.0 Beta 3
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2012, <NAME>
 * @license http://www.mozilla.org/MPL/MPL-1.1.html
 */

/*
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is http://www.codehive.net/PHP-Array-Pagination-10.html.
 *
 * The Initial Developer of the Original Code is
 * <NAME>.
 * Portions created by the Initial Developer are Copyright (C) 2009
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 * <NAME>
 */

class BreezePagination
{
	public function __construct($array, $page = 1, $link_prefix = false, $link_suffix = false, $limit_page = 20, $limit_number = 10)
	{
		global $scripturl;

		if (empty($array))
			$this->usedArray = array();

		else
		{
			$this->usedArray = $array;
			$this->page = !empty($page) || !$limit_page ? $page : 1;
			$this->linkPrefix = !empty($link_prefix) ? $link_prefix : '';
			$this->linkSufflix = !empty($link_sufflix) ? $link_sufflix : '';
			$this->limitPage = !empty($limit_page) ? $limit_page : 20;
			$this->limitNumber = !empty($limit_number) ? $limit_number : 20;
			$this->panel = '';
			$this->output = array();
			$this->page_cur = '';
			$this->scripturl = $scripturl;
		}
	}

	public function PaginationArray()
	{
		$this->num_rows = count($this->usedArray);

		if (!$this->num_rows or $this->limitPage >= $this->num_rows)
		{
			$this->pagtrue = false;
			return;
		}

		$this->num_pages = ceil($this->num_rows / $this->limitPage);
		$this->page_offset = ($this->page - 1) * $this->limitPage;

		/* Calculating the first number to show */
		if ($this->limitNumber)
		{
			$this->limit_number_start = $this->page - ceil($this->limitNumber / 2);
			$this->limit_number_end = ceil($this->page + $this->limitNumber / 2) - 1;

			if ($this->limit_number_start < 1)
				$this->limit_number_start = 1;

			//In case if the current page is at the beginning.
			$this->dif = ($this->limit_number_end - $this->limit_number_start);

			if ($this->dif < $this->limitNumber)
				$this->limit_number_end = $this->limit_number_end + ($this->limitNumber - ($this->dif + 1));

			if ($this->limit_number_end > $this->num_pages)
				$this->limit_number_end = $this->num_pages;

			//In case if the current page is at the ending.
			$this->dif = ($this->limit_number_end - $this->limit_number_start);

			if ($this->limit_number_start < 1)
				$this->limit_number_start = 1;
		}

		else
		{
			$this->limit_number_start = 1;
			$this->limit_number_end = $this->num_pages;
		}

		/* Let's generate the panel */
		$this->GeneratePageLinks();
		$this->NavigationArrows();
		$this->panel = trim($this->panel);

		$this->output['panel'] = $this->panel; //Panel HTML source.
		$this->output['offset'] = $this->page_offset; //Current page number.
		$this->output['limit'] = $this->limitPage; //Number of resuts per page.
		$this->output['array'] = array_slice($this->usedArray, $this->page_offset, $this->limitPage, true); //Array of current page results.
		$this->output['next'] = $this->num_pages != $this->page ? '<a href="'. $this->scripturl .''. $this->linkPrefix . ($this->page + 1) . $this->linkSufflix .'" id="breeze_next_link" style="display:none;">'. Breeze::text()->getText('pag_next') .'</a>' : '';

		$this->pagtrue = true;
	}

	/* Generating page links. */
	private function GeneratePageLinks()
	{<commit_msg>Global $breezeController on BreezePagination<commit_after><?php

/**
 * BreezePagination
 *
 * The purpose of this file is to create a pagination from an array of items
 * @package Breeze mod
 * @version 1.0 Beta 3
 * @author <NAME> <<EMAIL>>
 * @copyright Copyright (c) 2012, <NAME>
 * @license http://www.mozilla.org/MPL/MPL-1.1.html
 */

/*
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is http://www.codehive.net/PHP-Array-Pagination-10.html.
 *
 * The Initial Developer of the Original Code is
 * <NAME>.
 * Portions created by the Initial Developer are Copyright (C) 2009
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 * <NAME>
 */

class BreezePagination
{
	public function __construct($array, $page = 1, $link_prefix = false, $link_suffix = false, $limit_page = 20, $limit_number = 10)
	{
		global $scripturl, $breezeController;

		if (empty($array))
			$this->usedArray = array();

		else
		{
			$this->usedArray = $array;
			$this->page = !empty($page) || !$limit_page ? $page : 1;
			$this->linkPrefix = !empty($link_prefix) ? $link_prefix : '';
			$this->linkSufflix = !empty($link_sufflix) ? $link_sufflix : '';
			$this->limitPage = !empty($limit_page) ? $limit_page : 20;
			$this->limitNumber = !empty($limit_number) ? $limit_number : 20;
			$this->panel = '';
			$this->output = array();
			$this->page_cur = '';
			$this->scripturl = $scripturl;
			$this->text = $breezeController->get('text');
		}
	}

	public function PaginationArray()
	{
		$this->num_rows = count($this->usedArray);

		if (!$this->num_rows or $this->limitPage >= $this->num_rows)
		{
			$this->pagtrue = false;
			return;
		}

		$this->num_pages = ceil($this->num_rows / $this->limitPage);
		$this->page_offset = ($this->page - 1) * $this->limitPage;

		/* Calculating the first number to show */
		if ($this->limitNumber)
		{
			$this->limit_number_start = $this->page - ceil($this->limitNumber / 2);
			$this->limit_number_end = ceil($this->page + $this->limitNumber / 2) - 1;

			if ($this->limit_number_start < 1)
				$this->limit_number_start = 1;

			//In case if the current page is at the beginning.
			$this->dif = ($this->limit_number_end - $this->limit_number_start);

			if ($this->dif < $this->limitNumber)
				$this->limit_number_end = $this->limit_number_end + ($this->limitNumber - ($this->dif + 1));

			if ($this->limit_number_end > $this->num_pages)
				$this->limit_number_end = $this->num_pages;

			//In case if the current page is at the ending.
			$this->dif = ($this->limit_number_end - $this->limit_number_start);

			if ($this->limit_number_start < 1)
				$this->limit_number_start = 1;
		}

		else
		{
			$this->limit_number_start = 1;
			$this->limit_number_end = $this->num_pages;
		}

		/* Let's generate the panel */
		$this->GeneratePageLinks();
		$this->NavigationArrows();
		$this->panel = trim($this->panel);

		$this->output['panel'] = $this->panel; //Panel HTML source.
		$this->output['offset'] = $this->page_offset; //Current page number.
		$this->output['limit'] = $this->limitPage; //Number of resuts per page.
		$this->output['array'] = array_slice($this->usedArray, $this->page_offset, $this->limitPage, true); //Array of current page results.
		$this->output['next'] = $this->num_pages != $this->page ? '<a href="'. $this->scripturl .''. $this->linkPrefix . ($this->page + 1) . $this->linkSufflix .'" id="breeze_next_link" style="display:none;">'. $this->text->getText('pag_next') .'</a>' : '';

		$this->pagtrue = true;
	}

	/* Generating page links. */
	private function GeneratePageLinks()
	{
{'fraction_non_alphanumeric': 0.1690494105843993, 'fraction_numerical': 0.010032605969400551, 'mean_word_length': 3.7413793103448274, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 178, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '954931', 'n_tokens_mistral': 2976, 'n_tokens_neox': 2666, 'n_words': 684}