-
Notifications
You must be signed in to change notification settings - Fork 70
Major Refactoring #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Major Refactoring #529
Changes from 1 commit
01d4b86
c5c184f
b883aec
1d334a8
8c4b141
081fc33
2bef96e
ac65d8f
6afd336
293d84e
0eefd8f
ab12f14
f77f381
decfd8d
4c3a95e
38ca8b2
c617724
8f1c137
bbcdb3f
4526935
5eabda9
b706c93
32d393a
b23d7b8
9220075
5340eaf
fbe4e9d
7002812
7542e5b
01a7083
f200011
a9e9f33
bee95f0
b08d547
c124fc5
212a1ea
837fcad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,12 @@ public function __construct(?int $rev = null, ?int $at = null) | |
| $this->rev = $rev; | ||
| $this->at = $at; | ||
| $this->title = $INPUT->str('book_title'); | ||
| $this->pages = $this->collect(); | ||
|
|
||
| // collected pages are cleaned and checked for read access | ||
| $this->pages = array_filter( | ||
| array_map('cleanID', $this->collect()), | ||
| fn($page) => auth_quickaclcheck($page) >= AUTH_READ | ||
| ); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe Collectors will always obey ACLs thanks to above code. I think before a book export that contained ACL protected pages did return to the book creator page with an error unless skipforbiddenpages was set. Now it basically behaves like skipforbiddenpages is always set, because above code will skip those protected pages by default. |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -55,6 +60,50 @@ public function getTitle(): string | |
| return $this->title; | ||
| } | ||
|
|
||
| /** | ||
| * Get the language to be used for the PDF | ||
| * | ||
| * Use the language of the first page if possible, otherwise fall back to the default language | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getLanguage() | ||
| { | ||
| global $conf; | ||
|
|
||
| $lang = $conf['lang']; | ||
| if ($this->pages == []) return $lang; | ||
|
|
||
|
|
||
| /** @var helper_plugin_translation $trans */ | ||
| $trans = plugin_load('helper', 'translation'); | ||
| if (!$trans) return $lang; | ||
| $tr = $trans->getLangPart($this->pages[0]); | ||
| if ($tr) return $tr; | ||
|
|
||
| return $lang; | ||
| } | ||
|
|
||
| /** | ||
| * Get the set revision if any | ||
| * | ||
| * @return int|null | ||
| */ | ||
| public function getRev(): ?int | ||
| { | ||
| return $this->rev; | ||
| } | ||
|
|
||
| /** | ||
| * Get the set dateat timestamp if any | ||
| * | ||
| * @return int|null | ||
| */ | ||
| public function getAt(): ?int | ||
| { | ||
| return $this->at; | ||
| } | ||
|
|
||
| /** | ||
| * Get the list of page ids to include in the PDF | ||
| * | ||
|
|
@@ -64,4 +113,17 @@ public function getPages(): array | |
| { | ||
| return $this->pages; | ||
| } | ||
|
|
||
| /** | ||
| * Get the list of file paths to include in the PDF | ||
| * | ||
| * Handles $rev if set | ||
| * | ||
| * @return string[] | ||
| * @todo no handling of $at yet | ||
| */ | ||
| public function getFiles(): array | ||
| { | ||
| return array_map(fn($id) => wikiFN($id, $this->rev), $this->pages); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it logical to use an interface here for the collector?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... good question. Currently I need collectors to be children of AbstractCollector, because I use methods from it on the Collector. Using an Interface would make that more difficult, but I might be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not fluent with this kind of patterns, so for in depth ideas others better step in ;-)