<commit_before><?php
/**
 * Tatoeba Project, free collaborative creation of multilingual corpuses project
 * Copyright (C) 2009  <NAME> <<EMAIL>>
 *
 * 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/>.
 *
 * PHP version 5
 *
 * @category PHP
 * @package  Tatoeba
 * @author   <NAME> <<EMAIL>>
 * @license  Affero General Public License
 * @link     http://tatoeba.org
 */

/**
 * Helper for contribution logs.
 *
 * @category Contributions
 * @package  Helpers
 * @author   <NAME> <<EMAIL>>
 * @license  Affero General Public License
 * @link     http://tatoeba.org
 */
class LogsHelper extends AppHelper
{

    public $helpers = array('Date', 'Html', 'Languages');
    
    /** 
     * Display a contribution.
     *
     * @param array $contribution Contribution to display.
     * @param array $user         User who contributed.
     *
     * @return void
     */
    public function entry($contribution, $user = null)
    {
        $type = 'link';
        $status = '';
        
        $userName = Sanitize::paranoid($user['username']);
        $userId = Sanitize::paranoid($user['id']);
        
        $contributionText = Sanitize::html($contribution['text']);
        $contributionId = Sanitize::paranoid($contribution['sentence_id']);
        $translationId = Sanitize::paranoid($contribution['translation_id']); 
        $action = Sanitize::paranoid($contribution['action']);
        $contributionDate = $contribution['datetime'];
        $lang = Sanitize::paranoid($contribution['sentence_lang']);
        
        if (empty($translationId)) {
            $type = 'sentence';
        }
        
        switch ($action) {
            case 'suggest' : 
                $type = 'correction';
                $status = 'Suggested'; 
                break;
            
            case 'insert' :
                $status = 'Added';
                break;
            
            case 'update' :
                $status = 'Modified';
                break;
            
            case 'delete' :
                $status = 'Deleted';
                break;
        }
        
        echo '<tr class="'.$type.$status.'">';
        
        // language flag
        echo '<td class="lang">';
        if ($type == 'link') {
            echo '&raquo;';
        } else {
            if ($lang == '') {
                echo '?';
            } else {
                echo $this->Html->image(
                    'flags/'.$lang.".png", 
                    array(
                        "alt" => $lang,
                        "class" => "flag",
                        "title" => $this->Languages->codeToName($lang)
                    )
                );
            }
        }
        echo '</td>';
        
        // sentence text
        echo '<td class="text">';
        echo $this->Html->link(
            $contributionText,
            array(
                "controller" => "sentences",
                "action" => "show",
                $contributionId
            )
        );
        echo '</td>';
        
        // contributor
        echo '<td class="username">';
        echo $this->_displayLinkToUserProfile($username, $userId);
        echo '</td>';
        
        // date of contribution
        echo '<td class="date">';
        echo $this->Date->ago($contributionDate);
        echo '</td>';
        
        echo '</tr>';
    }
    
    /** 
     * Display a contribution in annexe module.
     *
     * @param array $contribution Contribution to display.
     * @param array $user         User who contributed.
     *
     * @return void
     */
    public function annexeEntry($contribution, $user = null)
    {
        $type = 'link';
        $status = '';
        
        $userName = Sanitize::paranoid($user['username']);
        $userId = Sanitize::paranoid($user['id']);
        
        $contributionText = Sanitize::html($contribution['text']);
        $translationId = Sanitize::paranoid($contribution['translation_id']); 
        $action = Sanitize::paranoid($contribution['action']);
        $contributionDate = $contribution['datetime'];

        if (empty($translationId)) {
            $type = 'sentence';
        } 
        
        switch ($action) {
            case 'suggest' : 
                $type = 'correction';
                $status = 'Suggested'; 
                break;
            case 'insert' :
                $status = 'Added';
                break;
            case 'update' :
                $status = 'Modified';
                break;
            case 'delete' :
                $status = 'Deleted';
                break;
        }
        
        echo '<div class="annexeLogEntry '.$type.$status.'">';
        
        echo '<div>';
        if (isset($username)) {
            echo $this->_displayLinkToUserProfile($username, $userId);<commit_msg>Fixed some warnings in helpers/logs.php.<commit_after><?php
/**
 * Tatoeba Project, free collaborative creation of multilingual corpuses project
 * Copyright (C) 2009  <NAME> <<EMAIL>>
 *
 * 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/>.
 *
 * PHP version 5
 *
 * @category PHP
 * @package  Tatoeba
 * @author   <NAME> <<EMAIL>>
 * @license  Affero General Public License
 * @link     http://tatoeba.org
 */

/**
 * Helper for contribution logs.
 *
 * @category Contributions
 * @package  Helpers
 * @author   <NAME> <<EMAIL>>
 * @license  Affero General Public License
 * @link     http://tatoeba.org
 */
class LogsHelper extends AppHelper
{

    public $helpers = array('Date', 'Html', 'Languages');
    
    /** 
     * Display a contribution.
     *
     * @param array $contribution Contribution to display.
     * @param array $user         User who contributed.
     *
     * @return void
     */
    public function entry($contribution, $user = null)
    {
        $type = 'link';
        $status = '';
        
        if (isset($user)) {
            $username = Sanitize::paranoid($user['username']);
            $userId = Sanitize::paranoid($user['id']);
        }
        
        $contributionText = Sanitize::html($contribution['text']);
        $contributionId = Sanitize::paranoid($contribution['sentence_id']);
        if (isset($contribution['translation_id'])) {
            $translationId = Sanitize::paranoid($contribution['translation_id']); 
        }
        $action = Sanitize::paranoid($contribution['action']);
        $contributionDate = $contribution['datetime'];
        $lang = Sanitize::paranoid($contribution['sentence_lang']);
        
        if (empty($translationId)) {
            $type = 'sentence';
        }
        
        switch ($action) {
            case 'suggest' : 
                $type = 'correction';
                $status = 'Suggested'; 
                break;
            
            case 'insert' :
                $status = 'Added';
                break;
            
            case 'update' :
                $status = 'Modified';
                break;
            
            case 'delete' :
                $status = 'Deleted';
                break;
        }
        
        echo '<tr class="'.$type.$status.'">';
        
        // language flag
        echo '<td class="lang">';
        if ($type == 'link') {
            echo '&raquo;';
        } else {
            if ($lang == '') {
                echo '?';
            } else {
                echo $this->Html->image(
                    'flags/'.$lang.".png", 
                    array(
                        "alt" => $lang,
                        "class" => "flag",
                        "title" => $this->Languages->codeToName($lang)
                    )
                );
            }
        }
        echo '</td>';
        
        // sentence text
        echo '<td class="text">';
        echo $this->Html->link(
            $contributionText,
            array(
                "controller" => "sentences",
                "action" => "show",
                $contributionId
            )
        );
        echo '</td>';
        
        // contributor
        echo '<td class="username">';
        echo $this->_displayLinkToUserProfile($username, $userId);
        echo '</td>';
        
        // date of contribution
        echo '<td class="date">';
        echo $this->Date->ago($contributionDate);
        echo '</td>';
        
        echo '</tr>';
    }
    
    /** 
     * Display a contribution in annexe module.
     *
     * @param array $contribution Contribution to display.
     * @param array $user         User who contributed.
     *
     * @return void
     */
    public function annexeEntry($contribution, $user = null)
    {
        $type = 'link';
        $status = '';
        
        if (isset($user)) {
            $username = Sanitize::paranoid($user['username']);
            $userId = Sanitize::paranoid($user['id']);
        }
        
        $contributionText = Sanitize::html($contribution['text']);
        $translationId = Sanitize::paranoid($contribution['translation_id']); 
        $action = Sanitize::paranoid($contribution['action']);
        $contributionDate = $contribution['datetime'];

        if (empty($translationId)) {
            $type = 'sentence';
        } 
        
        switch ($action) {
            case 'suggest' : 
                $type = 'correction';
                $status = 'Suggested'; 
                break;
            case 'insert' :
                $status = 'Added';
                break;
            case 'update' :
                $status = 'Modified';
                break;
            case 'delete' :
                $status = 'Deleted';
                break;
        }
        
        echo '<div class="annexeLogEntry '.$type.$status.'">';
        
        echo '<div>';
        if (isset($username)) {
            echo $this->_displayLinkToUserProfile($username, $userId);
{'fraction_non_alphanumeric': 0.13124830516134864, 'fraction_numerical': 0.00108469673687065, 'mean_word_length': 1.6168401135288553, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3189184', 'n_tokens_mistral': 3006, 'n_tokens_neox': 2868, 'n_words': 761}