<commit_before><?php


class CommentPageNav
{
	protected $_tpl;
	protected $ec;

	protected $current_page;
	protected $count;
	protected $limit;
	protected $item_id;
	protected $buttons_count;
	protected $filename;

	public function __construct($ec, $_pdo, $_tpl)
	{
		$this->_tpl = $_tpl;
		$this->_pdo = $_pdo;
		$this->ec = $ec;
	}

	public function create($item_id, $current_page, $limit, $buttons_count, $filename)
	{
		$i = 0;
		foreach(func_get_args() as $arg)
		{
			if ($i === 1)
			{
				continue;
			}

			if ($i === 4)
			{
				break;
			}

			if (!is_numeric($arg) || !$arg)
			{
				throw new systemException('Paramter metody CommentPageNav::create() nie jest numeryczny lub jest równy 0!');
			}

			$i++;
		}

		$this->count = $this->_pdo->getSelectCount('SELECT Count(`id`) FROM [comments] WHERE `content_type` = :filename AND `content_id` = :item_id', array(
			array(':filename', $filename, PDO::PARAM_STR),
			array(':item_id', intval($item_id), PDO::PARAM_INT)
		));

		$this->limit = intval($limit);
		$this->buttons_count = intval($buttons_count);
		$this->filename = $filename;
		$this->current_page = $current_page;
		$this->item_id = intval($item_id);

		$this->parse();
	}

	public function parse()
	{
		if ($this->count)
		{
			$this->ec->paging->setPagesCount($this->count, $this->current_page, $this->ec->comment->getLimit());

			$data = $this->ec->pageNav->create($this->_tpl, $this->buttons_count);

			$this->ec->pageNav->get($data, 'page_nav');
		}

		$this->_tpl->assign('comments', $this->ec->comment->get($this->filename, $this->item_id, $this->current_page, $this->limit));
	}
}<commit_msg>Poprawki do paginacji komentarzy.<commit_after><?php


class CommentPageNav
{
	protected $_tpl;
	protected $ec;

	protected $current_page;
	protected $count;
	protected $limit;
	protected $item_id;
	protected $buttons_count;
	protected $filename;
	protected $dir;
	protected $name;

	public function __construct($ec, $_pdo, $_tpl)
	{
		$this->_tpl = $_tpl;
		$this->_pdo = $_pdo;
		$this->ec = $ec;
	}

	public function create($item_id, $current_page, $limit, $buttons_count, $filename, $name = 'page_nav', $dir = NULL)
	{
		$i = 0;
		foreach(func_get_args() as $arg)
		{
			if ($i === 1)
			{
				continue;
			}

			if ($i === 4)
			{
				break;
			}

			if (!is_numeric($arg) || !$arg)
			{
				throw new systemException('Paramter metody CommentPageNav::create() nie jest numeryczny lub jest równy 0!');
			}

			$i++;
		}

		$this->count = $this->_pdo->getSelectCount('SELECT Count(`id`) FROM [comments] WHERE `content_type` = :filename AND `content_id` = :item_id', array(
			array(':filename', $filename, PDO::PARAM_STR),
			array(':item_id', intval($item_id), PDO::PARAM_INT)
		));

		$this->limit = intval($limit);
		$this->buttons_count = intval($buttons_count);
		$this->filename = $filename;
		$this->current_page = $current_page;
		$this->item_id = intval($item_id);
		$this->dir = $dir;
		$this->name = $name;

		$this->parse();
	}

	public function parse()
	{
		if ($this->count)
		{
			$this->ec->paging->setPagesCount($this->count, $this->current_page, $this->ec->comment->getLimit());

			$data = $this->ec->pageNav->create($this->_tpl, $this->buttons_count);

			$this->ec->pageNav->get($data, $this->name, $this->dir);
		}

		$this->_tpl->assign('comments', $this->ec->comment->get($this->filename, $this->item_id, $this->current_page, $this->limit));
	}
}
{'fraction_non_alphanumeric': 0.1962973846605936, 'fraction_numerical': 0.0023508668821627977, 'mean_word_length': 4.189024390243903, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 83, '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': '4531115', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1266, 'n_words': 242}