<commit_before><?php
/**
 * Tatoeba Project, free collaborative creation of multilingual corpuses project
 * Copyright (C) 2014  <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace App\View\Helper;

use App\View\Helper\AppHelper;
use Cake\Routing\Router;

class PagesHelper extends AppHelper
{
    public function formatTitle($pageTitle) {
        return $pageTitle . __(' - Tatoeba');
    }

    public function formatTitleWithResultCount($paginator, $title, $real_total = 0) {
        $n = $paginator->param('count');
        if ($real_total == 0 || $real_total == $n) {
            /* @translators: this formats the title at the top of every page
               that shows a list of sentences (search, browse by language,
               adopt sentences…) by appending the number of results. Note
               the use of &nbsp; which is a non-breaking space. */
            $title = format(__n('{title} ({n} result)',
                                '{title} ({n}&nbsp;results)',
                                $n, true),
                            compact('title', 'n')
            );
        } else {
            /* @translators: this formats the title at the top of the search
               page by appending the number of results. Tatoeba is only able
               to display {thousand} results (that should always be turned
               into “1000”), but {n} results actually exist in the corpus.
               Note the use of &nbsp; which is a non-breaking space. */
            $title = format(__n('{title} ({thousand}&nbsp;results out of {n} occurrence)',
                                '{title} ({thousand}&nbsp;results out of {n}&nbsp;occurrences)',
                                $real_total, true),
                            array('title' => $title, 'thousand' => $n, 'n' => $real_total)
            );
        }
        $title = sprintf('<h2>%s</h2>', $title);
        return $title;
    }

    public function currentPageUrl() {
        return Router::reverse($this->request);
    }

    /**
     * Display a message if a vocabulary item exists and its numSentences count
     * is different than the Sphinx real total.
     *
     * @param  array $vocabulary Vocabulary item.
     * @param  int   $real_total Total number of sentences found by Sphinx.
     *
     * @return string
     */
    public function sentencesMayNotAppear($vocabulary, $real_total)
    {
        if ($real_total == null) {
            $real_total = 0;
        }

        if (!empty($vocabulary) && $real_total != $vocabulary['Vocabulary']['numSentences']) {
            echo format(__(
                'Recently added sentences may not appear in search results.',
                true
            ));
        }
    }
}
?>
<commit_msg>Remove unwanted _csrfToken GET parameter in URLs<commit_after><?php
/**
 * Tatoeba Project, free collaborative creation of multilingual corpuses project
 * Copyright (C) 2014  <NAME>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace App\View\Helper;

use App\View\Helper\AppHelper;

class PagesHelper extends AppHelper
{
    public function formatTitle($pageTitle) {
        return $pageTitle . __(' - Tatoeba');
    }

    public function formatTitleWithResultCount($paginator, $title, $real_total = 0) {
        $n = $paginator->param('count');
        if ($real_total == 0 || $real_total == $n) {
            /* @translators: this formats the title at the top of every page
               that shows a list of sentences (search, browse by language,
               adopt sentences…) by appending the number of results. Note
               the use of &nbsp; which is a non-breaking space. */
            $title = format(__n('{title} ({n} result)',
                                '{title} ({n}&nbsp;results)',
                                $n, true),
                            compact('title', 'n')
            );
        } else {
            /* @translators: this formats the title at the top of the search
               page by appending the number of results. Tatoeba is only able
               to display {thousand} results (that should always be turned
               into “1000”), but {n} results actually exist in the corpus.
               Note the use of &nbsp; which is a non-breaking space. */
            $title = format(__n('{title} ({thousand}&nbsp;results out of {n} occurrence)',
                                '{title} ({thousand}&nbsp;results out of {n}&nbsp;occurrences)',
                                $real_total, true),
                            array('title' => $title, 'thousand' => $n, 'n' => $real_total)
            );
        }
        $title = sprintf('<h2>%s</h2>', $title);
        return $title;
    }

    public function currentPageUrl() {
        return $this->request->here();
    }

    /**
     * Display a message if a vocabulary item exists and its numSentences count
     * is different than the Sphinx real total.
     *
     * @param  array $vocabulary Vocabulary item.
     * @param  int   $real_total Total number of sentences found by Sphinx.
     *
     * @return string
     */
    public function sentencesMayNotAppear($vocabulary, $real_total)
    {
        if ($real_total == null) {
            $real_total = 0;
        }

        if (!empty($vocabulary) && $real_total != $vocabulary['Vocabulary']['numSentences']) {
            echo format(__(
                'Recently added sentences may not appear in search results.',
                true
            ));
        }
    }
}
?>

{'fraction_non_alphanumeric': 0.10105045125018494, 'fraction_numerical': 0.00414262464861666, 'mean_word_length': 2.1123388581952116, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '498585', 'n_tokens_mistral': 1813, 'n_tokens_neox': 1742, 'n_words': 678}