<commit_before><?php

use Respect\Validation\Validator;

include_once WIDGETS_PATH.'Post/Post.php';

class Blog extends WidgetBase {
    public $_paging = 10;

    private $_from;
    private $_node;
    private $_item;
    private $_id;
    private $_contact;
    private $_messages;
    private $_page;
    private $_mode;
    private $_tag;

    function load()
    {
        if($this->_view == 'node') {
            $this->_from = $this->get('s');
            $this->_node = $this->get('n');

            if(!$this->validateServerNode($this->_from, $this->_node)) return;

            $pd = new \Modl\ItemDAO;
            $this->_item = $pd->getItem($this->_from, $this->_node);
            $this->_mode = 'group';

            $this->url = Route::urlize('node', array($this->_from, $this->_node));
        } elseif($this->_view == 'tag' && $this->validateTag($this->get('t'))) {
            $this->_mode = 'tag';
            $this->_tag = $this->get('t');
            $this->title = '#'.$this->_tag;
        } else {
            $this->_from = $this->get('f');

            $cd = new \modl\ContactDAO();
            $this->_contact = $cd->get($this->_from, true);
            if(filter_var($this->_from, FILTER_VALIDATE_EMAIL)) {
                $this->_node = 'urn:xmpp:microblog:0';
            } else {
                return;
            }
            $this->_mode = 'blog';

            $this->url = Route::urlize('blog', $this->_from);
        }

        $pd = new \modl\PostnDAO();

        if($this->_id = $this->get('i')) {
            if(Validator::intType()->between(1, 100)->validate((int)$this->_id)) {
                if(isset($this->_tag)) {
                    $this->_messages = $pd->getPublicTag($this->get('t'), $this->_id * $this->_paging, $this->_paging + 1);
                } else {
                    $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, $this->_id * $this->_paging, $this->_paging + 1);
                }<commit_msg>Fix Blog pagination and unique article view<commit_after><?php

use Respect\Validation\Validator;

include_once WIDGETS_PATH.'Post/Post.php';

class Blog extends WidgetBase {
    public $_paging = 10;

    private $_from;
    private $_node;
    private $_item;
    private $_id;
    private $_contact;
    private $_messages;
    private $_page;
    private $_mode;
    private $_tag;

    function load()
    {
        if($this->_view == 'node') {
            $this->_from = $this->get('s');
            $this->_node = $this->get('n');

            if(!$this->validateServerNode($this->_from, $this->_node)) return;

            $pd = new \Modl\ItemDAO;
            $this->_item = $pd->getItem($this->_from, $this->_node);
            $this->_mode = 'group';

            $this->url = Route::urlize('node', array($this->_from, $this->_node));
        } elseif($this->_view == 'tag' && $this->validateTag($this->get('t'))) {
            $this->_mode = 'tag';
            $this->_tag = $this->get('t');
            $this->title = '#'.$this->_tag;
        } else {
            $this->_from = $this->get('f');

            $cd = new \modl\ContactDAO();
            $this->_contact = $cd->get($this->_from, true);
            if(filter_var($this->_from, FILTER_VALIDATE_EMAIL)) {
                $this->_node = 'urn:xmpp:microblog:0';
            } else {
                return;
            }
            $this->_mode = 'blog';

            $this->url = Route::urlize('blog', $this->_from);
        }

        $pd = new \modl\PostnDAO();

        if($this->_id = $this->get('i')) {
            if(Validator::stringType()->between('1', '100')->validate($this->_id)) {
                if(isset($this->_tag)) {
                    $this->_messages = $pd->getPublicTag($this->get('t'), $this->_id * $this->_paging, $this->_paging + 1);
                } else {
                    $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, $this->_id * $this->_paging, $this->_paging + 1);
                }
{'fraction_non_alphanumeric': 0.19539078156312625, 'fraction_numerical': 0.0045090180360721445, 'mean_word_length': 1.9687732342007436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 109, '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': '6241578', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1223, 'n_words': 214}