<commit_before><?php
use Cake\Event\Event;
use Cake\I18n\Time;

$isPublished = $article->publish_date <= Time::now();

$buttons = [];
$buttons[] = [
    'html' => $this->Html->link('<i class="fa fa-pencil"></i>', '#', [
        'title' => __('Edit'),
        'class' => 'btn btn-box-tool',
        'escape' => false,
        'data-toggle' => 'modal',
        'data-target' => '#' . $article->slug
    ]),
    'url' => ['plugin' => 'Cms', 'controller' => 'Sites', 'action' => 'edit', 'pass' => [$site->id]]
];
$buttons[] = [
    'html' => $this->Form->postLink(
        '<i class="fa fa-trash"></i>',
        [
            'controller' => 'Articles',
            'action' => 'delete',
            $site->slug,
            $article->slug
        ],
        [
            'confirm' => __('Are you sure you want to delete # {0}?', $article->title),
            'title' => __('Delete'),
            'class' => 'btn btn-box-tool',
            'escape' => false
        ]
    ),
    'url' => ['plugin' => 'Cms', 'controller' => 'Sites', 'action' => 'edit', 'pass' => [$site->id]]
];

$event = new Event('Cms.View.element.beforeRender', $this, [
    'menu' => $buttons,
    'user' => $user
]);
$this->eventManager()->dispatch($event);

$actionButtons = $event->result;

/**
 * BLOCK: Article header
 */
$this->start('article-header') ?>
    <div class="box-header with-border">
        <i class="fa fa-<?= $types[$article->type]['icon'] ?> text-muted"></i>
        <h3 class="box-title">
        <?= $this->Html->link(
            $this->Text->truncate($article->title, 35, ['exact' => false]),
            [
                'controller' => 'Articles',
                'action' => 'view',
                $site->slug,
                $article->type,
                $article->slug
            ],
            ['title' => h($article->title)]
        ) ?></h3>
        <div class="box-tools pull-right">
            <?= $this->fetch('article-action-buttons') ?>
        </div>
    </div>
<?php $this->end();

/**
 * BLOCK: Article body
 */
$this->start('article-body') ?>
<?php
$this->end();

/**
 * BLOCK: Article footer
 */
$this->start('article-footer')
?>
<div class="box-footer small">
    <div class="text-muted text-right">
    <?php
    if ('type' === $this->request->action) {
        $assocUrl = $this->Html->link($article->category->name, [
            'controller' => 'Categories',
            'action' => 'view',
            $site->slug,
            $article->category->slug
        ]);
    } else {
        $assocUrl = $this->Html->link($types[$article->type]['label'], [
            'controller' => 'Articles',
            'action' => 'type',
            $site->slug,
            $article->type
        ]);
    }
    ?>
    <?= $assocUrl ?>
    |
    <?php if ($isPublished) : ?>
        <?= __('Published') ?>
        <?= $article->publish_date->timeAgoInWords([
            'format' => 'MMM d, YYY',
            'end' => '1 month'
        ]) ?>
    <?php else : ?>
        <?= __('Unpublished') ?> <i class="fa fa-eye-slash text-danger"></i>
    <?php endif; ?>
    </div>
</div>
<?php
$this->end();

/**
 * BLOCK: Article box classes
 */
$this->start('article-box-classes');
$this->end();

/**
 * BLOCK: Article action buttons
 */
$this->start('article-action-buttons');
    echo $actionButtons;
$this->end();<commit_msg>Fixes issue with action buttons attached to the wrong element (task #3905)<commit_after><?php
use Cake\Event\Event;
use Cake\I18n\Time;

$isPublished = $article->publish_date <= Time::now();

$buttons = [];
$buttons[] = [
    'html' => $this->Html->link('<i class="fa fa-pencil"></i>', '#', [
        'title' => __('Edit'),
        'class' => 'btn btn-box-tool',
        'escape' => false,
        'data-toggle' => 'modal',
        'data-target' => '#' . $article->slug
    ]),
    'url' => ['plugin' => 'Cms', 'controller' => 'Sites', 'action' => 'edit', 'pass' => [$site->id]]
];
$buttons[] = [
    'html' => $this->Form->postLink(
        '<i class="fa fa-trash"></i>',
        [
            'controller' => 'Articles',
            'action' => 'delete',
            $site->slug,
            $article->slug
        ],
        [
            'confirm' => __('Are you sure you want to delete # {0}?', $article->title),
            'title' => __('Delete'),
            'class' => 'btn btn-box-tool',
            'escape' => false
        ]
    ),
    'url' => ['plugin' => 'Cms', 'controller' => 'Sites', 'action' => 'edit', 'pass' => [$site->id]]
];

$event = new Event('Cms.View.element.beforeRender', $this, [
    'menu' => $buttons,
    'user' => $user
]);
$this->eventManager()->dispatch($event);

$actionButtons = $event->result;

/**
 * BLOCK: Article action buttons
 */
$this->start('article-action-buttons');
    echo $actionButtons;
$this->end();

/**
 * BLOCK: Article header
 */
$this->start('article-header') ?>
    <div class="box-header with-border">
        <i class="fa fa-<?= $types[$article->type]['icon'] ?> text-muted"></i>
        <h3 class="box-title">
        <?= $this->Html->link(
            $this->Text->truncate($article->title, 35, ['exact' => false]),
            [
                'controller' => 'Articles',
                'action' => 'view',
                $site->slug,
                $article->type,
                $article->slug
            ],
            ['title' => h($article->title)]
        ) ?></h3>
        <div class="box-tools pull-right">
            <?= $this->fetch('article-action-buttons') ?>
        </div>
    </div>
<?php $this->end();

/**
 * BLOCK: Article body
 */
$this->start('article-body');
$this->end();

/**
 * BLOCK: Article footer
 */
$this->start('article-footer')
?>
<div class="box-footer small">
    <div class="text-muted text-right">
    <?php
    if ('type' === $this->request->action) {
        $assocUrl = $this->Html->link($article->category->name, [
            'controller' => 'Categories',
            'action' => 'view',
            $site->slug,
            $article->category->slug
        ]);
    } else {
        $assocUrl = $this->Html->link($types[$article->type]['label'], [
            'controller' => 'Articles',
            'action' => 'type',
            $site->slug,
            $article->type
        ]);
    }
    ?>
    <?= $assocUrl ?>
    |
    <?php if ($isPublished) : ?>
        <?= __('Published') ?>
        <?= $article->publish_date->timeAgoInWords([
            'format' => 'MMM d, YYY',
            'end' => '1 month'
        ]) ?>
    <?php else : ?>
        <?= __('Unpublished') ?> <i class="fa fa-eye-slash text-danger"></i>
    <?php endif; ?>
    </div>
</div>
<?php
$this->end();

/**
 * BLOCK: Article box classes
 */
$this->start('article-box-classes');
$this->end();
{'fraction_non_alphanumeric': 0.23431211805038007, 'fraction_numerical': 0.002981070204203309, 'mean_word_length': 2.1064814814814814, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 238, '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': '963439', 'n_tokens_mistral': 2209, 'n_tokens_neox': 2175, 'n_words': 403}