<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author <NAME> <<EMAIL>>
 * @version 1.0, Jan 19, 2017 - 10:57:33 AM
 */
class DocumentsPage
        extends Page {

    private static $icon = "genealogist/images/genealogy.png";

    public function canCreate($member = false) {
        if (!$member || !(is_a($member, 'Member')) || is_numeric($member)) {
            $member = Member::currentUserID();
        }

        return (DataObject::get($this->owner->class)->count() > 0) ? false : true;
    }

}

class DocumentsPage_Controller
        extends Page_Controller {

    private static $allowed_actions = array(
        'doc',
    );
    private static $url_handlers = array(
        'doc/$ID' => 'doc',
        '$action/$ID' => 'index',
    );

    public function init() {
        parent::init();

        Requirements::css("genealogist/css/docs.css");
        if ($this->isRTL()) {
            Requirements::css("genealogist/css/docs-rtl.css");
        }
    }

    /// Sub Pages ///
    public function index(SS_HTTPRequest $request) {
        $action = $this->getRequest()->param('action');
        $id = $this->getRequest()->param('ID');
        $person = null;

        if ($action == 'person' && $id) {
            $person = DataObject::get_by_id('Person', $id);
            $docs = $person->Documents();
        } else if ($action == 'tag' && $id) {
            $docs = DataObject::get_by_id('DocumentTag', $id)->Files();
        } else {
            $docs = DocumentFile::get();
        }

        $paginate = $this->getPaginated($docs);

        $data = array(
            'Docs' => $docs,
            'Results' => $paginate,
            'Individual' => $person,
            'Title' => _t('Genealogy.DOC_LIST', 'Documents List')
        );

        return $data;
    }

    public function doc() {
        $id = $this->getRequest()->param('ID');

        $doc = DocumentFile::get()->byID($id);

        if ($doc) {
            $this->etalage(140, 205);

            return $this<commit_msg>- Fixed minor bug<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author <NAME> <<EMAIL>>
 * @version 1.0, Jan 19, 2017 - 10:57:33 AM
 */
class DocumentsPage
        extends Page {

    private static $icon = "genealogist/images/genealogy.png";

    public function canCreate($member = false) {
        if (!$member || !(is_a($member, 'Member')) || is_numeric($member)) {
            $member = Member::currentUserID();
        }

        return (DataObject::get($this->owner->class)->count() > 0) ? false : true;
    }

}

class DocumentsPage_Controller
        extends Page_Controller {

    private static $allowed_actions = array(
        'doc',
    );
    private static $url_handlers = array(
        'doc/$ID' => 'doc',
        '$action/$ID' => 'index',
    );

    public function init() {
        parent::init();

        Requirements::css("genealogist/css/docs.css");
        if ($this->isRTL()) {
            Requirements::css("genealogist/css/docs-rtl.css");
        }
    }

    /// Sub Pages ///
    public function index(SS_HTTPRequest $request) {
        $action = $this->getRequest()->param('action');
        $id = $this->getRequest()->param('ID');
        $person = null;

        if ($action == 'person' && $id) {
            $person = DataObject::get_by_id('Person', $id);
            $docs = $person->Documents();
        } else if ($action == 'tag' && $id) {
            $docs = DataObject::get_by_id('DocumentTag', $id)->Files();
        } else {
            $docs = DocumentFile::get();
        }

        $paginate = $this->getPaginated($docs);

        $data = array(
            'Docs' => $docs,
            'Results' => $paginate,
            'Individual' => $person,
        );

        return $data;
    }

    public function doc() {
        $id = $this->getRequest()->param('ID');

        $doc = DocumentFile::get()->byID($id);

        if ($doc) {
            $this->etalage(140, 205);

            return $this
{'fraction_non_alphanumeric': 0.1703962703962704, 'fraction_numerical': 0.009790209790209791, 'mean_word_length': 2.1482024944974323, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 52, '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': '4412304', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1273, 'n_words': 292}