<commit_before><?php

class RecentSightingsWidget
{
    public $title = 'Recent Sightings';
    public $render = 'SimpleList';
    public $width = 8;
    public $height = 6;
    public $params = array(
        'limit' => 'Maximum amount of sightings to return',
        'last' => 'Limit sightins to last 1d, 12h, ...'
    );
    public $description = 'Widget showing information on recent sightings';
    public $cacheLifetime = false;
    public $autoRefreshDelay = 30;
    public $placeholder =
    '{
        "limit": "10",
        "last": "1d",
    }';

	public function handler($user, $options = array())
	{
        $params = array(
            'last' => empty($options['last']) ? "1d" : $options['last'],
            'limit' => empty($options['limit']) ? "10" : $options['limit']
        );
        $last = $params['last'];
        $limit = $params['limit'];

        $this->Sighting = ClassRegistry::init('Sighting');
        $filters = array( 'last' => $last, 'includeAttribute' => 'true', 'includeEvent' => 'true');
        $data = array();
        $count = 0;

        foreach(json_decode($this->Sighting->restSearch($user, 'json', $filters))->{'response'} as $el) {
            $sighting = $el->{'Sighting'};
            $event = $sighting->{'Event'};
            $attribute = $sighting->{'Attribute'};

            if ($sighting->{'type'} == 0) $type = "Sighting";
            elseif ($sighting->{'type'} == 1) $type = "False positive";
            else $type = "Expiration";

            $output = $attribute->{'value'} . " (id: " . $attribute->{'id'} . ") in " . $event->{'info'} . " (id: " . $event->{'id'} . ")";
            $data[] = array( 'title' => __($type), 'value' => $output, 
                                'html' => sprintf(
                                    ' (Event <a href="%s%s">%s</a>)',
                                    Configure::read('MISP.baseurl') . '/events/view/', $event->{'id'},
                                    $event->{'id'}
                                )
                        );<commit_msg>fix: [i18n] Variables cannot be translated<commit_after><?php

class RecentSightingsWidget
{
    public $title = 'Recent Sightings';
    public $render = 'SimpleList';
    public $width = 8;
    public $height = 6;
    public $params = array(
        'limit' => 'Maximum amount of sightings to return',
        'last' => 'Limit sightins to last 1d, 12h, ...'
    );
    public $description = 'Widget showing information on recent sightings';
    public $cacheLifetime = false;
    public $autoRefreshDelay = 30;
    public $placeholder =
    '{
        "limit": "10",
        "last": "1d",
    }';

	public function handler($user, $options = array())
	{
        $params = array(
            'last' => empty($options['last']) ? "1d" : $options['last'],
            'limit' => empty($options['limit']) ? "10" : $options['limit']
        );
        $last = $params['last'];
        $limit = $params['limit'];

        $this->Sighting = ClassRegistry::init('Sighting');
        $filters = array( 'last' => $last, 'includeAttribute' => 'true', 'includeEvent' => 'true');
        $data = array();
        $count = 0;

        foreach(json_decode($this->Sighting->restSearch($user, 'json', $filters))->{'response'} as $el) {
            $sighting = $el->{'Sighting'};
            $event = $sighting->{'Event'};
            $attribute = $sighting->{'Attribute'};

            if ($sighting->{'type'} == 0) $type = "Sighting";
            elseif ($sighting->{'type'} == 1) $type = "False positive";
            else $type = "Expiration";

            $output = $attribute->{'value'} . " (id: " . $attribute->{'id'} . ") in " . $event->{'info'} . " (id: " . $event->{'id'} . ")";
            $data[] = array( 'title' => $type, 'value' => $output, 
                                'html' => sprintf(
                                    ' (Event <a href="%s%s">%s</a>)',
                                    Configure::read('MISP.baseurl') . '/events/view/', $event->{'id'},
                                    $event->{'id'}
                                )
                        );
{'fraction_non_alphanumeric': 0.19679689395777725, 'fraction_numerical': 0.008250424654210144, 'mean_word_length': 1.8987341772151898, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3302417', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1195, 'n_words': 274}