<?php
$this->htmlElement('body')->appendAttribute('class', 'site-pages add');
$this->ckEditor();
$this->headScript()->appendFile($this->assetUrl('js/sortable.js', 'Omeka'));
$this->headScript()->appendFile($this->assetUrl('js/site-page-edit.js', 'Omeka'));
$this->blockLayout()->prepareForm();
$form->prepare();
$escape = $this->plugin('escapeHtml');
?>
<?php echo $this->pageTitle(sprintf($this->translate('Edit Page: “%s”'), $page->title())); ?>

<?php echo $this->form()->openTag($form); ?>
<div id="page-actions">
    <a href="<?php echo $page->siteUrl(); ?>" class="button"><?php echo $this->translate('View'); ?></a>
    <a href="#" class="delete button"><?php echo $this->translate('Delete'); ?></a>
    <button><?php echo $this->translate('Save'); ?></button>
</div>

<?php echo $this->formCollection($form, false); ?>

<?php echo $this->blockLayout()->forms($page); ?>

<?php echo $this->form()->closeTag(); ?>

<div id="new-block" class="active sidebar" data-url="<?php echo $this->url('admin/site/slug/page/default', ['action' => 'block'], true); ?>">
    <h3><?php echo $this->translate('Add New Block'); ?></h3>
    <?php foreach ($this->blockLayout()->getLayouts() as $layout): ?>
    <button type="button" value="<?php echo $escape($layout); ?>" class="option">
        <?php echo $escape($this->translate($this->blockLayout()->getLayoutLabel($layout))); ?>
    </button>
    <?php endforeach; ?>
</div>

<div id="attachment-options" class="sidebar" data-url="<?php echo $this->url(null, ['action' => 'attachment-item-options'], true); ?>">
    <div id="attachment-options-main">
        <a href="#" class="sidebar-close o-icon-close"><span class="screen-reader-text"><?php echo $this->translate('Close Me'); ?></span></a>
        <div id="attachment-item"></div>
        <div id="attachment-caption" class="option">
            <h3><?php echo $this->translate('Caption'); ?></h3>
            <a href="#" class="collapse" aria-label="<?php echo $this->translate('Collapse'); ?>" title="<?php echo $this->translate('Collapse'); ?>"></a>
            <div class="collapsible">
                <textarea class="caption wysiwyg"></textarea>
            </div>
        </div>
    </div>
    <div id="attachment-confirm-panel" class="confirm-panel">
        <button><?php echo $this->translate('Apply changes'); ?></button>
    </div>
</div>

<?php echo $this->deleteConfirm($page, 'page'); ?>

<?php echo $this->partial('common/resource-select-sidebar'); ?>
