From 93a63adaa554a38a39a53f48c473d109c99314c2 Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Wed, 13 Mar 2024 10:52:27 +0300 Subject: [PATCH] fix(publication): regex to pass queries to preview --- actions/BarreRedactionAction__.php | 2 +- actions/Bazar2PublicationAction.php | 4 +- actions/PublicationGeneratorAction.php | 12 +- controllers/ApiController.php | 22 +- controllers/PdfController.php | 109 +++--- handlers/PreviewHandler.php | 3 +- handlers/ShowHandler__.php | 2 +- services/Publication.php | 309 +++++++++--------- services/SessionManager.php | 2 +- tests/actions/Bazar2PublicationActionTest.php | 8 +- tests/services/PdfHelperTest.php | 12 +- 11 files changed, 245 insertions(+), 240 deletions(-) diff --git a/actions/BarreRedactionAction__.php b/actions/BarreRedactionAction__.php index 14ff104..9feb040 100644 --- a/actions/BarreRedactionAction__.php +++ b/actions/BarreRedactionAction__.php @@ -13,7 +13,7 @@ public function run() $this->render( '@bazar/entries/_publication_button.twig', [ - 'forPage'=>true + 'forPage' => true ] )."\n".'', $this->output diff --git a/actions/Bazar2PublicationAction.php b/actions/Bazar2PublicationAction.php index 79b83e8..fdedd26 100644 --- a/actions/Bazar2PublicationAction.php +++ b/actions/Bazar2PublicationAction.php @@ -29,10 +29,10 @@ public function run() unset($queries['wiki']); } $href = $this->wiki->Href('pdf'.testUrlInIframe(), null, $queries// merge GET with wiki and following params - +[ + + [ 'via' => 'bazarliste', 'template-page' => $this->arguments['templatepage'], - ]+( + ] + ( empty($this->arguments['excludedfields']) ? [] : [ diff --git a/actions/PublicationGeneratorAction.php b/actions/PublicationGeneratorAction.php index c3d5db0..71fc78b 100644 --- a/actions/PublicationGeneratorAction.php +++ b/actions/PublicationGeneratorAction.php @@ -40,7 +40,7 @@ public function formatArguments($args) return $deprecatedParameters + [ 'outputformat' => $this->formatString($args, 'outputformat', 'ebook'), - 'formid' => (!empty($args['formid']) && is_scalar($args['formid']) && intval($args['formid'])>0) ? strval($args['formid']) : '', + 'formid' => (!empty($args['formid']) && is_scalar($args['formid']) && intval($args['formid']) > 0) ? strval($args['formid']) : '', // Indicates if fields and elements are "read only" 'readonly' => isset($args['readonly']) && in_array($args['readonly'], ['',true], true), // Pages used for intro and outro @@ -87,9 +87,9 @@ public function run() list( 'ebookPageName' => $ebookPageName, - 'selectedPages'=>$selectedPages, - 'publicationStart'=>$publicationStart, - 'publicationEnd'=>$publicationEnd, + 'selectedPages' => $selectedPages, + 'publicationStart' => $publicationStart, + 'publicationEnd' => $publicationEnd, ) = $this->getEbookPageName($results); try { @@ -358,7 +358,7 @@ protected function managePost(array $post, array &$messages, string $ebookPageNa )) { // there is no publication-cover-image $messages[] = [ - 'message' =>_t('PUBLICATION_NOT_IMAGE_FILE'), + 'message' => _t('PUBLICATION_NOT_IMAGE_FILE'), 'type' => 'danger' ]; } else { @@ -432,7 +432,7 @@ protected function managePost(array $post, array &$messages, string $ebookPageNa $fiche = $this->entryManager->create($this->arguments['formid'], $fiche); if (!empty($fiche)) { $messages[] = [ - 'message' =>_t('PUBLICATION_NEWSLETTER_CREATED'), + 'message' => _t('PUBLICATION_NEWSLETTER_CREATED'), 'type' => 'success' ]; } else { diff --git a/controllers/ApiController.php b/controllers/ApiController.php index daddd78..41ad531 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -27,7 +27,7 @@ public function getStatus($uuid) return new ApiResponse($status, Response::HTTP_OK); } - /** + /** * @Route("/api/pdf/getTmpCookie",methods={"GET"}, options={"acl":{"public","+"}},priority=2) */ public function getTmpCookie() @@ -77,11 +77,11 @@ public function getPdf() $this->pdfHelper->prepareSession($uuid); list( - 'pageTag'=>$pageTag, - 'sourceUrl'=>$sourceUrl, - 'hash'=>$hash, - 'dlFilename'=>$dlFilename, - 'fullFilename'=>$fullFilename + 'pageTag' => $pageTag, + 'sourceUrl' => $sourceUrl, + 'hash' => $hash, + 'dlFilename' => $dlFilename, + 'fullFilename' => $fullFilename ) = $this->pdfHelper->getFullFileName( $_GET ?? [], @@ -94,7 +94,7 @@ public function getPdf() $file_exists = file_exists($fullFilename); $this->pdfHelper->setValueInSession($uuid, PdfHelper::SESSION_FILE_STATUS, $file_exists ? 1 : 0); if (!$file_exists - || ($file_exists && $this->wiki->UserIsAdmin() && isset($_GET['refresh']) && $_GET['refresh']==1) + || ($file_exists && $this->wiki->UserIsAdmin() && isset($_GET['refresh']) && $_GET['refresh'] == 1) ) { $this->pdfHelper->useBrowserToCreatePdfFromPage($sourceUrl, $fullFilename, $uuid, $cookies); } @@ -116,7 +116,7 @@ public function getPdf() if ($isOld && !$forceNewFormat) { if (isset($cause['canExecChromium']) && $cause['canExecChromium'] === false) { $output = $this->renderInSquelette('@templates/alert-message.twig', [ - 'type'=> 'danger', + 'type' => 'danger', 'message' => _t('PUBLICATION_NO_EXECUTABLE_FILE_FOUND_ON_PATH').' : ' .$this->params->get('htmltopdf_path').'
' ._t('PUBLICATION_DID_YOU_INSTALL_CHROMIUM_OR_SET_UP_PATH') @@ -125,14 +125,14 @@ public function getPdf() } if (isset($cause['domainAuthorized']) && $cause['domainAuthorized'] === false) { $output = $this->renderInSquelette('@templates/alert-message.twig', [ - 'type'=> 'danger', + 'type' => 'danger', 'message' => _t('PUBLICATION_DOMAIN_NOT_AUTORIZED').' : '.parse_url($_GET['url'] ?? '', PHP_URL_HOST), ]); return new Response($output, Response::HTTP_OK); } if (isset($cause['pdfCreationError']) && $cause['pdfCreationError'] === true) { $output = $this->renderInSquelette('@publication/old-error-message.twig', [ - 'sourceUrl'=> $_GET['url'] ?? '', + 'sourceUrl' => $_GET['url'] ?? '', 'message' => $ex->getMessage(), 'html' => $cause['pdfCreationErrorHTML'] ?? '' ]); @@ -140,7 +140,7 @@ public function getPdf() } } return new ApiResponse([ - 'error'=>true, + 'error' => true, 'cause' => $cause ], Response::HTTP_INTERNAL_SERVER_ERROR); } else { diff --git a/controllers/PdfController.php b/controllers/PdfController.php index e00206b..c1647d1 100644 --- a/controllers/PdfController.php +++ b/controllers/PdfController.php @@ -5,70 +5,69 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use YesWiki\Core\YesWikiController; use YesWiki\Publication\Service\PdfHelper; -use YesWiki\Publication\Service\SessionManager; use YesWiki\Wiki; class PdfController extends YesWikiController { - protected $params; - protected $pdfHelper; + protected $params; + protected $pdfHelper; - public function __construct( - ParameterBagInterface $params, - PdfHelper $pdfHelper, - Wiki $wiki - ) { - $this->params = $params; - $this->pdfHelper = $pdfHelper; - $this->wiki = $wiki; - } - - public function run(bool $inIframe = false) - { - if ( - !empty($_GET['url']) && is_string($_GET['url']) && - !empty($_GET['urlPageTag']) && is_string($_GET['urlPageTag']) && - !empty($_GET['hash']) && is_string($_GET['hash']) + public function __construct( + ParameterBagInterface $params, + PdfHelper $pdfHelper, + Wiki $wiki ) { - // redirect to api - if (!method_exists($this->wiki, 'isCli') || !$this->wiki->isCli()) { - header('Access-Control-Allow-Origin: *'); - header('Access-Control-Expose-Headers: Location, Slug, Accept, Content-Type'); - } - $filteredParams = array_filter($_GET, function ($v, $k) { - return in_array($k, ['url', 'urlPageTag', 'hash', 'refresh', 'forceNewFormat', 'via', 'template-page'], true) && is_scalar($v); - }, ARRAY_FILTER_USE_BOTH); - $this->wiki->redirect($this->wiki->href('', 'api/pdf/getPdf', $filteredParams + [ - 'fromOldPath' => '1' - ], false)); + $this->params = $params; + $this->pdfHelper = $pdfHelper; + $this->wiki = $wiki; } - list( - 'pageTag' => $pageTag, - 'sourceUrl' => $sourceUrl, - 'hash' => $hash, - ) = - $this->pdfHelper->getSourceUrl($_GET ?? [], $_SERVER ?? []); + public function run(bool $inIframe = false) + { + if ( + !empty($_GET['url']) && is_string($_GET['url']) && + !empty($_GET['urlPageTag']) && is_string($_GET['urlPageTag']) && + !empty($_GET['hash']) && is_string($_GET['hash']) + ) { + // redirect to api + if (!method_exists($this->wiki, 'isCli') || !$this->wiki->isCli()) { + header('Access-Control-Allow-Origin: *'); + header('Access-Control-Expose-Headers: Location, Slug, Accept, Content-Type'); + } + $filteredParams = array_filter($_GET, function ($v, $k) { + return in_array($k, ['url', 'urlPageTag', 'hash', 'refresh', 'forceNewFormat', 'via', 'template-page'], true) && is_scalar($v); + }, ARRAY_FILTER_USE_BOTH); + $this->wiki->redirect($this->wiki->href('', 'api/pdf/getPdf', $filteredParams + [ + 'fromOldPath' => '1' + ], false)); + } + + list( + 'pageTag' => $pageTag, + 'sourceUrl' => $sourceUrl, + 'hash' => $hash, + ) = + $this->pdfHelper->getSourceUrl($_GET ?? [], $_SERVER ?? []); - $method = $inIframe ? 'render' : 'renderInSquelette'; + $method = $inIframe ? 'render' : 'renderInSquelette'; - // simplier handler for client rendering - if (!$this->pdfHelper->canExecChromium()) { - $this->wiki->redirect($sourceUrl . '&browserPrintAfterRendered=1'); - return; - } else { - return $this->$method('@publication/handler-pdf.twig', [ - 'isAdmin' => $this->wiki->UserIsAdmin(), - 'isIframe' => $inIframe, - 'pageTag' => $pageTag, - 'sourceUrl' => $sourceUrl, - 'hash' => $hash, - 'urls' => [ - 'local' => $this->pdfHelper->canExecChromium() ? $this->wiki->href('', 'api/pdf/getPdf') : '', - 'external' => empty($this->params->get('htmltopdf_service_url')) ? '' : $this->params->get('htmltopdf_service_url'), - ], - 'refresh' => in_array($_GET['refresh'] ?? false, [1, "1", true, "true"], true), - ]); + // simplier handler for client rendering + if (!$this->pdfHelper->canExecChromium()) { + $this->wiki->redirect($sourceUrl . '&browserPrintAfterRendered=1'); + return; + } else { + return $this->$method('@publication/handler-pdf.twig', [ + 'isAdmin' => $this->wiki->UserIsAdmin(), + 'isIframe' => $inIframe, + 'pageTag' => $pageTag, + 'sourceUrl' => $sourceUrl, + 'hash' => $hash, + 'urls' => [ + 'local' => $this->pdfHelper->canExecChromium() ? $this->wiki->href('', 'api/pdf/getPdf') : '', + 'external' => empty($this->params->get('htmltopdf_service_url')) ? '' : $this->params->get('htmltopdf_service_url'), + ], + 'refresh' => in_array($_GET['refresh'] ?? false, [1, "1", true, "true"], true), + ]); + } } - } } diff --git a/handlers/PreviewHandler.php b/handlers/PreviewHandler.php index f04ac62..092fc14 100644 --- a/handlers/PreviewHandler.php +++ b/handlers/PreviewHandler.php @@ -102,7 +102,6 @@ protected function getContentAndPublication(array $get): array // backward compatibilty if (preg_match('#{{\s*bazar.+id="(.+)".+}}#siU', $this->wiki->page['body'], $matches)) { list(, $formId) = $matches; - $query = $get['query'] ?? ''; $results = $this->entryManager->search(['query' => $query, 'formsIds' => [$formId]]); @@ -120,7 +119,7 @@ protected function getContentAndPublication(array $get): array $actionName = $matches[2]; $matches = []; $params = []; - preg_match_all('/([a-zA-Z0-9_]*)=\"(.*)\"/U', $actionText, $matches); + preg_match_all('/([a-zA-Z0-9_]*)=\\\\?\"(.*)\\\\?\"/mU', $actionText, $matches); foreach ($matches[0] as $id => $match) { $params[$matches[1][$id]] = $matches[2][$id]; } diff --git a/handlers/ShowHandler__.php b/handlers/ShowHandler__.php index 6127a49..7790b3c 100644 --- a/handlers/ShowHandler__.php +++ b/handlers/ShowHandler__.php @@ -11,7 +11,7 @@ class ShowHandler__ extends YesWikiHandler public function run() { if ($this->getService(AclService::class)->hasAccess('read') && ( - isset($this->wiki->page['metadatas']['publication-title'])|| + isset($this->wiki->page['metadatas']['publication-title']) || isset($this->wiki->page['metadatas']['publication']['title']) )) { $metadata = $this->getService(Publication::class)->getOptions($this->wiki->page['metadatas']); diff --git a/services/Publication.php b/services/Publication.php index d4df3a0..846905e 100644 --- a/services/Publication.php +++ b/services/Publication.php @@ -5,167 +5,174 @@ define('PUBLICATION_LAYOUT_BOOK', 'book'); define('PUBLICATION_LAYOUT_FANZINE', 'fanzine'); -class Publication { - private $modes = [ - PUBLICATION_LAYOUT_BOOK, - PUBLICATION_LAYOUT_FANZINE - ]; - - // Publication modes that require to load Paged.js to assemble the paged content - private $pagedLayouts = [ - PUBLICATION_LAYOUT_BOOK - ]; - - private $fanzineLayouts = [ - // one page, folded in 4 (8 pages per sheet) - // see https://en.wikibooks.org/wiki/Zine_Making/Putting_pages_together#Single-page_options - 'single-page', - // many pages, folded in 2 (2 pages per sheet) - // see https://support.epson.net/fun/articles/86 - 'recto-folio', - // many pages, folded in 2, recto-verso (4 pages per sheet) - // see https://en.wikibooks.org/wiki/Zine_Making/Putting_pages_together#Folio_(folding_in_half) - // 'recto-verso-folio', - // many pages, folded in 4, recto-verso (8 pages per sheet) - // see https://en.wikibooks.org/wiki/Zine_Making/Putting_pages_together#Quarto_(folding_in_quarter) - // 'recto-verso-quarto', - // many pages, folded in 6, recto verso (12 pages per sheet) - // see https://en.wikibooks.org/wiki/Zine_Making/Putting_pages_together#Folding_into_six - // 'recto-verso-sexto' - ]; - - private $defaultOptions = [ - // Publication options - "publication" => [ - "title" => '', - "description" => '', - "authors" => '' - ], - "publication-hide-links-url" => '1', - "publication-cover-image" => '', - "publication-cover-page" => '0', - "publication-mode" => 'book', - // Book options - "publication-book" => [ - "print-fold" => '0', - "print-marks" => '0', - "pagination" => 'bottom-center', - "page-format" => 'A4', - "page-orientation" => 'portrait', - ], - // Fanzine options - "publication-fanzine" => [ - "layout" => 'single-page' - ], - ]; - - public function isMode($mode) { - return in_array($mode, $this->modes); - } - - public function isPaged($layout) { - return in_array($layout, $this->pagedLayouts); - } - - private function convertToNewOptionsFormat($options) { - // Publication Options - if (isset($options['publication-title'])) { - $options['publication']['title'] = $options['publication-title']; - unset($options['publication-title']); - } - - if (isset($options['publication-description'])) { - $options['publication']['description'] = $options['publication-description']; - unset($options['publication-description']); - } +class Publication +{ + private $modes = [ + PUBLICATION_LAYOUT_BOOK, + PUBLICATION_LAYOUT_FANZINE + ]; + + // Publication modes that require to load Paged.js to assemble the paged content + private $pagedLayouts = [ + PUBLICATION_LAYOUT_BOOK + ]; + + private $fanzineLayouts = [ + // one page, folded in 4 (8 pages per sheet) + // see https://en.wikibooks.org/wiki/Zine_Making/Putting_pages_together#Single-page_options + 'single-page', + // many pages, folded in 2 (2 pages per sheet) + // see https://support.epson.net/fun/articles/86 + 'recto-folio', + // many pages, folded in 2, recto-verso (4 pages per sheet) + // see https://en.wikibooks.org/wiki/Zine_Making/Putting_pages_together#Folio_(folding_in_half) + // 'recto-verso-folio', + // many pages, folded in 4, recto-verso (8 pages per sheet) + // see https://en.wikibooks.org/wiki/Zine_Making/Putting_pages_together#Quarto_(folding_in_quarter) + // 'recto-verso-quarto', + // many pages, folded in 6, recto verso (12 pages per sheet) + // see https://en.wikibooks.org/wiki/Zine_Making/Putting_pages_together#Folding_into_six + // 'recto-verso-sexto' + ]; + + private $defaultOptions = [ + // Publication options + "publication" => [ + "title" => '', + "description" => '', + "authors" => '' + ], + "publication-hide-links-url" => '1', + "publication-cover-image" => '', + "publication-cover-page" => '0', + "publication-mode" => 'book', + // Book options + "publication-book" => [ + "print-fold" => '0', + "print-marks" => '0', + "pagination" => 'bottom-center', + "page-format" => 'A4', + "page-orientation" => 'portrait', + ], + // Fanzine options + "publication-fanzine" => [ + "layout" => 'single-page' + ], + ]; - if (isset($options['publication-author'])) { - $options['publication']['authors'] = $options['publication-author']; - unset($options['publication-author']); + public function isMode($mode) + { + return in_array($mode, $this->modes); } - // Book Options - if (isset($options['publication-page-orientation'])) { - $options['publication-book']['page-orientation'] = $options['publication-page-orientation']; - unset($options['publication-page-orientation']); + public function isPaged($layout) + { + return in_array($layout, $this->pagedLayouts); } - if (isset($options['publication-page-format'])) { - $options['publication-book']['page-format'] = $options['publication-page-format']; - unset($options['publication-page-format']); + private function convertToNewOptionsFormat($options) + { + // Publication Options + if (isset($options['publication-title'])) { + $options['publication']['title'] = $options['publication-title']; + unset($options['publication-title']); + } + + if (isset($options['publication-description'])) { + $options['publication']['description'] = $options['publication-description']; + unset($options['publication-description']); + } + + if (isset($options['publication-author'])) { + $options['publication']['authors'] = $options['publication-author']; + unset($options['publication-author']); + } + + // Book Options + if (isset($options['publication-page-orientation'])) { + $options['publication-book']['page-orientation'] = $options['publication-page-orientation']; + unset($options['publication-page-orientation']); + } + + if (isset($options['publication-page-format'])) { + $options['publication-book']['page-format'] = $options['publication-page-format']; + unset($options['publication-page-format']); + } + + if (isset($options['publication-book-fold'])) { + $options['publication-book']['print-fold'] = $options['publication-book-fold']; + unset($options['publication-book-fold']); + } + + if (isset($options['publication-print-marks'])) { + $options['publication-book']['print-marks'] = $options['publication-print-marks']; + unset($options['publication-print-marks']); + } + + if (isset($options['publication-pagination'])) { + $options['publication-book']['pagination'] = $options['publication-pagination']; + unset($options['publication-pagination']); + } + + return $options; } - if (isset($options['publication-book-fold'])) { - $options['publication-book']['print-fold'] = $options['publication-book-fold']; - unset($options['publication-book-fold']); + /** + * @example PageTag?type=publication-end + */ + public function getIncludeActionFromPageTag($tag) + { + [$page, $qs] = array_pad(explode('?', $tag), 2, ''); + parse_str($qs, $params); + + return sprintf( + '{{include page="%s" class="%s"%s}}' . "\n", + $page, + trim(implode(' ', $params)), + isset($params['type']) ? ' type="'.$params['type'].'"' : '' + ); } - if (isset($options['publication-print-marks'])) { - $options['publication-book']['print-marks'] = $options['publication-print-marks']; - unset($options['publication-print-marks']); + public function getOptions(...$args) + { + $options = array_replace_recursive($this->defaultOptions, ...$args); + return $this->convertToNewOptionsFormat($options); } - if (isset($options['publication-pagination'])) { - $options['publication-book']['pagination'] = $options['publication-pagination']; - unset($options['publication-pagination']); + public function getStyles($metadatas, $options = []) + { + $isDebug = $options['debug'] === 'yes'; + $mode = $metadatas['publication-mode']; + + return array_merge( + // Common styles + [ + "yeswiki-publication", + "publication--" . $metadatas['publication-mode'], + $isDebug ? 'debug' : '', + // OPTION book-cover + $metadatas['publication-cover-page'] === '1' ? "publication--has-cover" : '', + // OPTION hide-links-from-print + $metadatas['publication-hide-links-url'] === '1' ? "hide-links-url" : '', + ], + /* BOOK Styles */ + $mode === 'book' ? [ + // could be chosen, when creating an eBook + "page-format--" . $metadatas['publication-book']['page-format'], + // could be chosen when creating an eBook + "page-orientation--" . $metadatas['publication-book']['page-orientation'], + // OPTION book-fold + $metadatas['publication-book']['print-fold'] === '1' ? "book-fold" : '', + // OPTION show-print-marks + $metadatas['publication-book']['print-marks'] === '1' ? "show-print-marks" : '', + // OPTION show-print-marks + "page-number-position--" . $metadatas['publication-book']['pagination'], + + ] : [], + /* FANZINE Styles */ + $mode === 'fanzine' ? [ + "fanzine-" . $metadatas['publication-fanzine']['layout'] + ] : [], + ); } - - return $options; - } - - /** - * @example PageTag?type=publication-end - */ - public function getIncludeActionFromPageTag ($tag) { - [$page, $qs] = array_pad(explode('?', $tag), 2, ''); - parse_str($qs, $params); - - return sprintf( - '{{include page="%s" class="%s"%s}}' . "\n", - $page, - trim(implode(' ', $params)), - isset($params['type']) ? ' type="'.$params['type'].'"' : '' - ); - } - - public function getOptions(...$args) { - $options = array_replace_recursive($this->defaultOptions, ...$args); - return $this->convertToNewOptionsFormat($options); - } - - public function getStyles($metadatas, $options = []) { - $isDebug = $options['debug'] === 'yes'; - $mode = $metadatas['publication-mode']; - - return array_merge( - // Common styles - [ - "yeswiki-publication", - "publication--" . $metadatas['publication-mode'], - $isDebug ? 'debug' : '', - // OPTION book-cover - $metadatas['publication-cover-page'] === '1' ? "publication--has-cover" : '', - // OPTION hide-links-from-print - $metadatas['publication-hide-links-url'] === '1' ? "hide-links-url" : '', - ], - /* BOOK Styles */ - $mode === 'book' ? [ - // could be chosen, when creating an eBook - "page-format--" . $metadatas['publication-book']['page-format'], - // could be chosen when creating an eBook - "page-orientation--" . $metadatas['publication-book']['page-orientation'], - // OPTION book-fold - $metadatas['publication-book']['print-fold'] === '1' ? "book-fold" : '', - // OPTION show-print-marks - $metadatas['publication-book']['print-marks'] === '1' ? "show-print-marks" : '', - // OPTION show-print-marks - "page-number-position--" . $metadatas['publication-book']['pagination'], - - ] : [], - /* FANZINE Styles */ - $mode === 'fanzine' ? [ - "fanzine-" . $metadatas['publication-fanzine']['layout'] - ] : [], - ); - } } diff --git a/services/SessionManager.php b/services/SessionManager.php index eacb410..5ec7f09 100644 --- a/services/SessionManager.php +++ b/services/SessionManager.php @@ -80,7 +80,7 @@ protected function updateSession(?array $savedSession) public function isEqual($a, $b): bool { if (is_float($a) && is_float($b)) { - return (abs($a-$b)<1E-9); + return (abs($a - $b) < 1E-9); } elseif (is_float($a) != is_float($b)) { return false; } else { diff --git a/tests/actions/Bazar2PublicationActionTest.php b/tests/actions/Bazar2PublicationActionTest.php index 7d1407f..781f0e1 100644 --- a/tests/actions/Bazar2PublicationActionTest.php +++ b/tests/actions/Bazar2PublicationActionTest.php @@ -31,7 +31,7 @@ public function testWikiExisting(): Wiki */ public function testRun(string $templatepage, bool $displayTemplateAlert, bool $throwException, Wiki $wiki) { - $templateString = empty($templatepage) ? '' :" templatepage=\"$templatepage\""; + $templateString = empty($templatepage) ? '' : " templatepage=\"$templatepage\""; $yesWikiString = "{{bazar2publication$templateString}}"; $exceptionThrown = false; @@ -59,17 +59,17 @@ public function providerTestRun() { return [ 'default behaviour' => [ - 'templatepage'=>'', + 'templatepage' => '', 'templatepage alert displayed' => false, 'exception thrown' => false ], 'wrong template page' => [ - 'templatepage'=>' ', + 'templatepage' => ' ', 'templatepage alert displayed' => true, 'exception thrown' => false ], 'template from template Page' => [ - 'templatepage'=>'PageTitre', // because PageTitre exists all the time + 'templatepage' => 'PageTitre', // because PageTitre exists all the time 'templatepage alert displayed' => false, 'exception thrown' => false ], diff --git a/tests/services/PdfHelperTest.php b/tests/services/PdfHelperTest.php index 0d60974..7f5573d 100644 --- a/tests/services/PdfHelperTest.php +++ b/tests/services/PdfHelperTest.php @@ -80,7 +80,7 @@ public function testGetPageEntriesContent(string $pageTagMode, ?string $via, arr $templatesNameToDelete[] = $templateName; } } - // } + // } } else { $pageTag = $this->getPageTagWithoutBazar2Publication(); } @@ -196,7 +196,7 @@ public function dataProvider() 'bazarlisteIds' => [], 'withTemplate' => true, 'clean' => true, - 'expected' => ["template content"=>"{{content}}"] + 'expected' => ["template content" => "{{content}}"] ], 'entry with via with template' => [ 'mode' => 'entry', @@ -204,7 +204,7 @@ public function dataProvider() 'bazarlisteIds' => [], 'withTemplate' => true, 'clean' => true, - 'expected' => ["template content"=>"{{content}}"] + 'expected' => ["template content" => "{{content}}"] ] ]; } @@ -458,12 +458,12 @@ protected function setRootPage(Wiki $wiki): array $previousPageContent = $wiki->page; $rootPageTag = $this->getParam($wiki, 'root_page'); $this->setPage($wiki, [ - 'tag'=>$rootPageTag, + 'tag' => $rootPageTag, 'content' => $this->getService($wiki, PageManager::class)->getOne($rootPageTag) ]); return [ - 'tag'=>$previousPageTag, - 'content'=>$previousPageContent + 'tag' => $previousPageTag, + 'content' => $previousPageContent ]; }