diff --git a/README.md b/README.md index ed94764..400e9d7 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,14 @@ composer install chmod -R a+w vendor/mpdf/mpdf/tmp ``` +Setup some permissions + +``` +cd omeka/files +mkdir docs +chown www-data docs +``` + ## LISENCE The module is released under the [MIT] License. diff --git a/config/module.config.php b/config/module.config.php index e6a5d7e..9607054 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -17,6 +17,13 @@ return [ Form\TechDocumentBlockForm::class => Form\TechDocumentBlockForm::class, ], ], + /* + 'media_ingesters' => [ + 'factories' => [ + 'TechDocument_media' => Service\Media\Ingester\TechDocumentMediaFactory::class, + ], + ], + */ 'DefaultSettings' => [ 'TechDocumentBlockForm' => [ 'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;', diff --git a/src/Service/BlockLayout/TechDocumentFactory.php b/src/Service/BlockLayout/TechDocumentFactory.php index c76b66d..2be88fc 100644 --- a/src/Service/BlockLayout/TechDocumentFactory.php +++ b/src/Service/BlockLayout/TechDocumentFactory.php @@ -11,8 +11,9 @@ class TechDocumentFactory implements FactoryInterface { return new TechDocument( $services->get('FormElementManager'), - $services->get('Config')['DefaultSettings']['TechDocumentBlockForm'] + $services->get('Config')['DefaultSettings']['TechDocumentBlockForm'], + $services->get('Config')['file_store']['local']['base_path'] ?: (OMEKA_PATH . '/files') ); } } -?> \ No newline at end of file +?> diff --git a/src/Site/BlockLayout/TechDocument.php b/src/Site/BlockLayout/TechDocument.php index ecd3ad9..f6721e6 100644 --- a/src/Site/BlockLayout/TechDocument.php +++ b/src/Site/BlockLayout/TechDocument.php @@ -1,15 +1,18 @@ formElementManager = $formElementManager; $this->defaultSettings = $defaultSettings; + $this->storage_dir = $storage_dir; } public function getLabel() { return 'Techical document'; } + + public function onHydrate(SitePageBlock $block, ErrorStore $errorStore): void + { + $data = $block->getData(); + $site_title = $block->getPage()->getSite()->getTitle(); + + $parsedown = new Parsedown(); + $text = "# ".$site_title." ".$dir."\n"; + $text .= "## Arc-hive technical documentation\n"; + $text .= "### Characteristics\n"; + $text .= $data['characteristics']; + + $html = $parsedown->setBreaksEnabled(true)->text($text); + $mpdf = new \Mpdf\Mpdf(); + $mpdf->WriteHTML($html); + $mpdf->Output($this->storage_dir.'/docs/'.$site_title.'.pdf', \Mpdf\Output\Destination::FILE); + } + public function form(PhpRenderer $view, SiteRepresentation $site, SitePageRepresentation $page = null, @@ -69,17 +95,6 @@ class TechDocument extends AbstractBlockLayout public function render(PhpRenderer $view, SitePageBlockRepresentation $block) { - $parsedown = new Parsedown(); - $text = "# Arc-hive technical documentation\n"; - $text .= "## characteristics\n"; - $text .= $block->dataValue('characteristics'); - - $html = $parsedown->text($text); - $mpdf = new \Mpdf\Mpdf(); - $mpdf = $mpdf->WriteHTML($html); - $mpdf->Output(); - - - return $html; + return ""; } }