<commit_before><?php
/**
 * Copyright (c) Qobo Ltd. (https://www.qobo.biz)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Qobo Ltd. (https://www.qobo.biz)
 * @license       https://opensource.org/licenses/mit-license.php MIT License
 */

use Qobo\Utils\Module\ModuleRegistry;

$attributes = isset($attributes) ? $attributes : [];

$class = str_replace('.', '_', $name . '_ids');

$config = ModuleRegistry::getModule($table)->getFields();

$options = [
    'multiple' => true,
    'data-upload-url' => sprintf("/api/%s/upload", $table),
];

if (isset($config[$field]['orderBy']) && 'order' == $config[$field]['orderBy'] && isset($config[$field]['orderDir'])) {
    $options['data-file-order'] = 1;
}

if ($value && $entities && $entities->count()) {
    $options['data-document-id'] = $value;
    $files = [];
    foreach ($entities as $entity) {
        $files[] = [
            'id' => $entity->id,
            'path' => $entity->path,
            'size' => $entity->get('filesize'),
        ];
    }
    //passed to generate previews
    $options['data-files'] = json_encode($files);
}
$attributes += $options;
?>
<div class="form-group <?= $required ? 'required' : '' ?> <?= $this->Form->isFieldError($name) ? 'has-error' : '' ?>">
<?= $this->Form->label($name . '[]', $label) ?>
<?= $this->Html->help($help); ?>
<?= $this->Form->{$type}($name . '[]', $attributes); ?>
<?php if ($entities && $entities->count()) : ?>
    <?php foreach ($entities as $entity) : ?>
        <?= $this->Form->hidden(
            $name . '_ids[]',
            [
                'class' => $class,
                'value' => $entity->id
            ]
        ); ?>
    <?php endforeach; ?><commit_msg>Add more file information (Task #10489)<commit_after><?php
/**
 * Copyright (c) Qobo Ltd. (https://www.qobo.biz)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Qobo Ltd. (https://www.qobo.biz)
 * @license       https://opensource.org/licenses/mit-license.php MIT License
 */

use Qobo\Utils\Module\ModuleRegistry;

$attributes = isset($attributes) ? $attributes : [];

$class = str_replace('.', '_', $name . '_ids');

$config = ModuleRegistry::getModule($table)->getFields();

$options = [
    'multiple' => true,
    'data-upload-url' => sprintf("/api/%s/upload", $table),
];

if (isset($config[$field]['orderBy']) && 'order' == $config[$field]['orderBy'] && isset($config[$field]['orderDir'])) {
    $options['data-file-order'] = 1;
}

if ($value && $entities && $entities->count()) {
    $options['data-document-id'] = $value;
    $files = [];
    foreach ($entities as $entity) {
        $files[] = [
            'id' => $entity->id,
            'path' => $entity->path,
            'size' => $entity->get('filesize'),
            'caption' => h($entity->filename),
            'type' => ('application/pdf' == $entity->mime_type) ? 'pdf' : 'image',
            'file_type' => $entity->mime_type,
        ];
    }
    //passed to generate previews
    $options['data-files'] = json_encode($files);
}
$attributes += $options;
?>
<div class="form-group <?= $required ? 'required' : '' ?> <?= $this->Form->isFieldError($name) ? 'has-error' : '' ?>">
<?= $this->Form->label($name . '[]', $label) ?>
<?= $this->Html->help($help); ?>
<?= $this->Form->{$type}($name . '[]', $attributes); ?>
<?php if ($entities && $entities->count()) : ?>
    <?php foreach ($entities as $entity) : ?>
        <?= $this->Form->hidden(
            $name . '_ids[]',
            [
                'class' => $class,
                'value' => $entity->id
            ]
        ); ?>
    <?php endforeach; ?>
{'fraction_non_alphanumeric': 0.2266769468003084, 'fraction_numerical': 0.001799023387304035, 'mean_word_length': 2.9352881698685542, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 79, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, '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': '2141854', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1230, 'n_words': 252}