Skip to content

Commit

Permalink
Fix {{ publicationgenerator outputformat="newsletter" }}
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Parisot committed Sep 6, 2021
1 parent dadecc6 commit 1e08b3e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
19 changes: 9 additions & 10 deletions actions/publicationgenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

// prefix for created pages
// Only used when outputformat="ebook"
$ebookPageNamePrefix = $this->getParameter('pagenameprefix', 'ebook');
$ebookPageNamePrefix = $this->getParameter('pagenameprefix', 'Ebook');

// include default pages in page listing ?
$addInstalledPages = $this->getParameter('addinstalledpage');
Expand Down Expand Up @@ -248,10 +248,8 @@
// $page can be 'SomeTag' or 'SomeTag?parameter=value'
// the query string is used to parametrize book creation
else {
list($page, $qs) = explode('?', $page);
parse_str($qs, $qs);

$output .= '{{include page="' . $page . '" class="'. trim(implode(' ', [$qs['type'], $qs['class']])) .'"}}' . "\n";
$includeCode = $publicationService->getIncludeActionFromPageTag($page);
$output .= $includeCode;
}
}

Expand All @@ -269,9 +267,9 @@
} while (false); // end of ebook specific loop
} elseif (strcasecmp($outputFormat, 'newsletter') === 0) { // We want to produce a newsletter
$fiche['id_typeannonce'] = $formId;
$fiche['bf_titre'] = $_POST["publication-title"];
$fiche['bf_description'] = $_POST["publication-description"];
$fiche['bf_author'] = $_POST["publication-author"];
$fiche['bf_titre'] = implode(' ', [$outputFormat, $_POST["publication"]["title"]]);
$fiche['bf_description'] = $_POST["publication"]["description"];
$fiche['bf_author'] = $_POST["publication"]["authors"];
$fiche['bf_content'] = '';

// Generate the content of the page body
Expand All @@ -285,11 +283,12 @@
// we assume it is a page tag otherwise
// maybe we should also explicitly check it is a valid page tag instead?
else {
$fiche['bf_content'] .= $this->Format('{{include page="' . $page . '" class=""}}' . "\n");
$includeCode = $publicationService->getIncludeActionFromPageTag($page);
$fiche['bf_content'] .= $this->Format($includeCode);
}
}

$acceptedTags = '<h1><h2><h3><h4><h5><h6><hr><hr/><br><br/><span><blockquote><i><u><b><strong><ol><ul><li><small><div><p><a><table><tr><th><td><img><figure><caption><iframe>';
$acceptedTags = '<h1><h2><h3><h4><h5><h6><hr><hr/><br><br/><span><blockquote><i><u><b><strong><ol><ul><li><small><div><p><a><table><tr><th><td><img><figure><caption><iframe><style>';
$fiche['bf_content'] = strip_tags($fiche['bf_content'], $acceptedTags);
$fiche['antispam'] = 1;
$fiche = $entryManager->create($formId, $fiche);
Expand Down
2 changes: 1 addition & 1 deletion actions/publicationlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// recuperation des pages wikis
$sql = 'SELECT DISTINCT resource FROM '.$this->GetConfigValue('table_prefix').'triples';
$sql .= ' WHERE property="http://outils-reseaux.org/_vocabulary/metadata"
AND value LIKE "%publication-title%" OR value LIKE "%\publication\":{\"title\":%"
AND (value LIKE "%publication-title%" OR value LIKE "%\publication\":{\"title\":%")
AND resource LIKE "'.$ebookPageNamePrefix.'%" ';
$sql .= ' ORDER BY resource ASC';

Expand Down
15 changes: 15 additions & 0 deletions services/Publication.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ private function convertToNewOptionsFormat($options) {
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);
Expand Down

0 comments on commit 1e08b3e

Please sign in to comment.