2 Omeka core
chris edited this page 2021-10-13 15:24:37 +02:00

Core modifications

We have tried to avoid this as much as possible. However..

Things to do after upgrading the Omeka core.

Disable blocks

https://git.hangar.org/arcHIVE-tech/Docs/wiki/Disabling-modules

Remove unwanted blocks from page edit page

Blocks are:

  • tableOfContents
  • searchingForm

You need to copy the page template from the omeka core into the arcHIVE theme.

Steps

From the omeka core copy ./application/view/omeka/site-admin/page/edit.phtml

And paste it into the arcHIVE theme ./view/omeka/site-admin/page/edit.phtml

Then edit the new file, adding these lines -->>

    <?php foreach ($this->blockLayout()->getLayouts() as $layout): ?>
-->>      <?php if ($layout == "tableOfContents") { continue; } ?>
-->>      <?php if ($layout == "searchingForm") { continue; } ?>
    <button type="button" value="<?php echo $escape($layout); ?>" class="option">
        <?php echo $escape($translate($this->blockLayout()->getLayoutLabel($layout))); ?>
    </button>
    <?php endforeach; ?>

HTML filter

Users can paste text into the Omeka HTML block. This is undesirable because html style and classes are included in the html. We de not want unexpected formats. Edit the core to filter html tags and attributes.

./application/src/Site/BlockLayout/Html.php

Import domdocument

use DOMDocument;

Add this class to the class Html extends AbstractBlockLayout

    public function onHydrate(SitePageBlock $block, ErrorStore $errorStore)
    {
        $data = $block->getData();
        $html = isset($data['html']) ? $this->htmlPurifier->purify($data['html']) : '';
        // archive strip tags
        $html = strip_tags($html, '<p><br><a><ol><ul><li>');
        // archive remove attributes
        $sanitized_html = "";
        $document = new DOMDocument();
        $document->loadHTML($html);
        $paragraphs = $document->getElementsByTagName('p');
        foreach ($paragraphs as $paragraph) {
          $paragraph->removeAttribute('class');
          $paragraph->removeAttribute('style');
          $paragraph->removeAttribute('align');
          $sanitized_html = $sanitized_html .PHP_EOL. $document->saveHTML($paragraph);
        }
        $data['html'] = $html.PHP_EOL;
        $block->setData($data);
    }

Disable YouTube module

We have our own module 'Oembed a la Arc-hive' that handles oembedded objects resizing

Edit /application/config/module.config.php and comment out these two lines

    ......
    'media_ingesters' => [
        'factories' => [
            //'youtube' => Service\Media\Ingester\YoutubeFactory::class,
        ],
    ],
    'media_renderers' => [
        'invokables' => [
            //'youtube' => Media\Renderer\Youtube::class,
        ],
        ........