Update 'Upgrading Omeka core'

chris 2021-10-13 12:13:44 +02:00
parent 81884502fe
commit 911c54efb6
1 changed files with 33 additions and 1 deletions

@ -7,7 +7,6 @@ https://git.hangar.org/arcHIVE-tech/Docs/wiki/Disabling-modules
## Remove unwanted blocks from page edit page
Blocks are:
* **HTML**: 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. For this reason we have developed the Markdown text module. Markdown allows basic HTML formatting without extra unwanted text formatting. But we also want to remove the HTML block so users cannot include it in their pages.
* **tableOfContents**
* **searchingForm**
@ -29,4 +28,37 @@ Then edit the new file, adding these lines `-->>`
<?php echo $escape($translate($this->blockLayout()->getLayoutLabel($layout))); ?>
</button>
<?php endforeach; ?>
```
**HTML**: 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);
}
```