]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'v0.30.x'
authorDan Brown <redacted>
Fri, 18 Dec 2020 14:16:13 +0000 (14:16 +0000)
committerDan Brown <redacted>
Fri, 18 Dec 2020 14:16:13 +0000 (14:16 +0000)
1  2 
app/Entities/Tools/ExportFormatter.php
app/Uploads/ImageRepo.php

index 9cf8b56af2476458d51316044662f6f1e8156e96,508670c850828265bf7a8dd2b7d94082d7335fcf..eb8f6862f23fe76b703c8f0a2514b2f5d61acae9
@@@ -1,15 -1,14 +1,15 @@@
 -<?php namespace BookStack\Entities;
 +<?php namespace BookStack\Entities\Tools;
  
 -use BookStack\Entities\Managers\BookContents;
 -use BookStack\Entities\Managers\PageContent;
 +use BookStack\Entities\Models\Book;
 +use BookStack\Entities\Models\Chapter;
 +use BookStack\Entities\Models\Page;
  use BookStack\Uploads\ImageService;
  use DomPDF;
  use Exception;
  use SnappyPDF;
  use Throwable;
  
 -class ExportService
 +class ExportFormatter
  {
  
      protected $imageService;
      protected function containHtml(string $htmlContent): string
      {
          $imageTagsOutput = [];
 -        preg_match_all("/\<img.*src\=(\'|\")(.*?)(\'|\").*?\>/i", $htmlContent, $imageTagsOutput);
 +        preg_match_all("/\<img.*?src\=(\'|\")(.*?)(\'|\").*?\>/i", $htmlContent, $imageTagsOutput);
  
          // Replace image src with base64 encoded image strings
          if (isset($imageTagsOutput[0]) && count($imageTagsOutput[0]) > 0) {
      {
          $text = $chapter->name . "\n\n";
          $text .= $chapter->description . "\n\n";
-         foreach ($chapter->pages as $page) {
+         foreach ($chapter->getVisiblePages() as $page) {
              $text .= $this->pageToPlainText($page);
          }
          return $text;
       */
      public function bookToPlainText(Book $book): string
      {
-         $bookTree = (new BookContents($book))->getTree(false, true);
+         $bookTree = (new BookContents($book))->getTree(false, false);
          $text = $book->name . "\n\n";
          foreach ($bookTree as $bookChild) {
              if ($bookChild->isA('chapter')) {
index 087fe67c94862f76d4c382c63a42c12f36278ea3,fb2a892286567fa762b25d769ea9f948f1b46dac..b4d743b73447a2cc99dade9b367f78e489020279
@@@ -1,7 -1,7 +1,7 @@@
  <?php namespace BookStack\Uploads;
  
  use BookStack\Auth\Permissions\PermissionService;
 -use BookStack\Entities\Page;
 +use BookStack\Entities\Models\Page;
  use BookStack\Exceptions\ImageUploadException;
  use Exception;
  use Illuminate\Database\Eloquent\Builder;
@@@ -112,7 -112,7 +112,7 @@@ class ImageRep
                  if ($filterType === 'page') {
                      $query->where('uploaded_to', '=', $contextPage->id);
                  } elseif ($filterType === 'book') {
-                     $validPageIds = $contextPage->book->pages()->get(['id'])->pluck('id')->toArray();
+                     $validPageIds = $contextPage->book->pages()->visible()->get(['id'])->pluck('id')->toArray();
                      $query->whereIn('uploaded_to', $validPageIds);
                  }
              };