<commit_before><?php

namespace Symbiote\AdvancedWorkflow\DataObjects;

use SilverStripe\Control\HTTPRequest;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;

/**
 * A workflow action attached to a {@link WorkflowInstance} that has been run,
 * and is either currently running, or has finished.
 *
 * Each step of the workflow has one of these created for it - it refers back
 * to the original action definition, but is unique for each step of the
 * workflow to ensure re-entrant behaviour.
 *
 * @license BSD License (http://silverstripe.org/bsd-license/)
 * @package advancedworkflow
 */
class WorkflowActionInstance extends DataObject
{
    private static $db = array(
        'Comment'  => 'Text',
        'Finished' => 'Boolean'
    );

    private static $has_one = array(
        'Workflow'   => WorkflowInstance::class,
        'BaseAction' => WorkflowAction::class,
        'Member'     => Member::class,
    );

    private static $summary_fields = array(
        'BaseAction.Title',
        'Comment',
        'Created',
        'Member.Name',
    );

    private static $table_name = 'WorkflowActionInstance';

    public function fieldLabels($includerelations = true)
    {
        $labels = parent::fieldLabels($includerelations);
        $labels['BaseAction.Title'] = _t('WorkflowActionInstance.Title', 'Title');
        $labels['Comment'] = _t('WorkflowAction.CommentLabel', 'Comment');
        $labels['Member.Name'] = _t('WorkflowAction.Author', 'Author');
        $labels['Finished'] = _t('WorkflowAction.FinishedLabel', 'Finished');
        $labels['BaseAction.Title'] = _t('WorkflowAction.TITLE', 'Title');

        return $labels;
    }

    /**
     * Gets fields for when this is part of an active workflow
     */
    public function updateWorkflowFields($fields)
    {
        $fieldDiff = $this->Workflow()->getTargetDiff();

        foreach ($fieldDiff as $field) {
            $display = ReadonlyField::create('workflow-' . $field->Name, $field->Title, $field->Diff)
                ->setDontEscape(true)
                ->addExtraClass('workflow-field-diff');
            $fields->push($display);
        }

        if ($this->BaseAction()->AllowCommenting) {
            $fields->push(new TextareaField('Comment', _t('WorkflowAction.COMMENT', 'Comment')));
        }
    }<commit_msg>FIX Remove use of FormField::$dontEscape (gone) and replace with HTMLText<commit_after><?php

namespace Symbiote\AdvancedWorkflow\DataObjects;

use SilverStripe\Control\HTTPRequest;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\Security\Member;

/**
 * A workflow action attached to a {@link WorkflowInstance} that has been run,
 * and is either currently running, or has finished.
 *
 * Each step of the workflow has one of these created for it - it refers back
 * to the original action definition, but is unique for each step of the
 * workflow to ensure re-entrant behaviour.
 *
 * @license BSD License (http://silverstripe.org/bsd-license/)
 * @package advancedworkflow
 */
class WorkflowActionInstance extends DataObject
{
    private static $db = array(
        'Comment'  => 'Text',
        'Finished' => 'Boolean'
    );

    private static $has_one = array(
        'Workflow'   => WorkflowInstance::class,
        'BaseAction' => WorkflowAction::class,
        'Member'     => Member::class,
    );

    private static $summary_fields = array(
        'BaseAction.Title',
        'Comment',
        'Created',
        'Member.Name',
    );

    private static $table_name = 'WorkflowActionInstance';

    public function fieldLabels($includerelations = true)
    {
        $labels = parent::fieldLabels($includerelations);
        $labels['BaseAction.Title'] = _t('WorkflowActionInstance.Title', 'Title');
        $labels['Comment'] = _t('WorkflowAction.CommentLabel', 'Comment');
        $labels['Member.Name'] = _t('WorkflowAction.Author', 'Author');
        $labels['Finished'] = _t('WorkflowAction.FinishedLabel', 'Finished');
        $labels['BaseAction.Title'] = _t('WorkflowAction.TITLE', 'Title');

        return $labels;
    }

    /**
     * Gets fields for when this is part of an active workflow
     */
    public function updateWorkflowFields($fields)
    {
        $fieldDiff = $this->Workflow()->getTargetDiff();

        foreach ($fieldDiff as $field) {
            $display = ReadonlyField::create(
                'workflow-' . $field->Name,
                $field->Title,
                DBField::create_field('HTMLText', $field->Diff)
            )
                ->addExtraClass('workflow-field-diff');
            $fields->push($display);
        }

        if ($this->BaseAction()->AllowCommenting) {
            $fields->push(new TextareaField('Comment', _t('WorkflowAction.COMMENT', 'Comment')));
        }
    }
{'fraction_non_alphanumeric': 0.13046033300685603, 'fraction_numerical': 0.0, 'mean_word_length': 3.0652866242038215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, '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': '922546', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1438, 'n_words': 346}