Skip to content

Commit

Permalink
fix: corrected JSON and PDF download, closes #3139
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Aug 11, 2024
1 parent f8bf0df commit bcec7ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace phpMyFAQ\Controller\Administration;

use League\CommonMark\Exception\CommonMarkException;
use phpMyFAQ\Administration\HttpStreamer;
use phpMyFAQ\Administration\Report;
use phpMyFAQ\Category;
Expand All @@ -31,7 +32,6 @@
use phpMyFAQ\Session\Token;
use phpMyFAQ\Translation;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
Expand Down Expand Up @@ -68,7 +68,7 @@ public function exportFile(Request $request): void
} else {
$httpStreamer->send(HeaderUtils::DISPOSITION_ATTACHMENT);
}
} catch (Exception | \JsonException $e) {
} catch (Exception | \JsonException | CommonMarkException $e) {
echo $e->getMessage();
}
}
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/Export/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function generate(int $categoryId = 0, bool $downwards = true, string $la
// Initialize categories
$this->category->transform($categoryId);

$faqData = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XML, $categoryId, $downwards, $language);
$faqData = $this->faq->get('faq_export_json', $categoryId, $downwards, $language);

foreach ($faqData as $data) {
$generated[] = [
Expand Down
8 changes: 5 additions & 3 deletions phpmyfaq/src/phpMyFAQ/Export/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace phpMyFAQ\Export;

use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Exception\CommonMarkException;
use phpMyFAQ\Category;
use phpMyFAQ\Configuration;
use phpMyFAQ\Date;
Expand Down Expand Up @@ -78,8 +79,9 @@ public function __construct(Faq $faq, Category $category, Configuration $configu
* Generates the export.
*
* @param int $categoryId CategoryHelper Id
* @param bool $downwards If true, downwards, otherwise upward ordering
* @param string $language Language
* @param bool $downwards If true, downwards, otherwise upward ordering
* @param string $language Language
* @throws CommonMarkException
*/
public function generate(int $categoryId = 0, bool $downwards = true, string $language = ''): string
{
Expand All @@ -95,7 +97,7 @@ public function generate(int $categoryId = 0, bool $downwards = true, string $la
$this->pdf->setCategories($this->category->categoryName);
$this->pdf->SetCreator($this->config->getTitle() . ' - ' . System::getPoweredByString());

$faqData = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XML, $categoryId, $downwards, $language);
$faqData = $this->faq->get('faq_export_pdf', $categoryId, $downwards, $language);

$currentCategory = 0;

Expand Down

0 comments on commit bcec7ad

Please sign in to comment.