@@ -28,6 +28,8 @@ public function createFromChapter($chapter)
2828 $ submission = DAORegistry::getDAO ('SubmissionDAO ' )->getById ($ publication ->getData ('submissionId ' ));
2929 $ context = Application::getContextDAO ()->getById ($ submission ->getData ('contextId ' ));
3030
31+ $ pages = $ this ->extractPages ($ chapter );
32+
3133 return new ThothWork ([
3234 'workType ' => ThothWork::WORK_TYPE_BOOK_CHAPTER ,
3335 'workStatus ' => $ this ->getWorkStatusByDatePublished ($ chapter , $ publication ),
@@ -36,7 +38,9 @@ public function createFromChapter($chapter)
3638 'subtitle ' => $ chapter ->getLocalizedData ('subtitle ' ),
3739 'longAbstract ' => HtmlStripper::stripTags ($ chapter ->getLocalizedData ('abstract ' )),
3840 'doi ' => DoiFormatter::resolveUrl ($ chapter ->getStoredPubId ('doi ' )),
39- 'pageCount ' => $ chapter ->getPages (),
41+ 'pageInterval ' => $ pages ['pageInterval ' ] ?? null ,
42+ 'firstPage ' => $ pages ['firstPage ' ] ?? null ,
43+ 'lastPage ' => $ pages ['lastPage ' ] ?? null ,
4044 'publicationDate ' => $ chapter ->getDatePublished () ?? $ publication ->getData ('datePublished ' ),
4145 'landingPage ' => $ request ->getDispatcher ()->url (
4246 $ request ,
@@ -49,6 +53,28 @@ public function createFromChapter($chapter)
4953 ]);
5054 }
5155
56+ private function extractPages ($ chapter ): array
57+ {
58+ $ pages = $ chapter ->getPages ();
59+
60+ if (empty ($ pages )) {
61+ return [];
62+ }
63+
64+ if (strpos ($ pages , '- ' ) === false ) {
65+ return [
66+ 'firstPage ' => trim ($ pages ),
67+ ];
68+ }
69+
70+ list ($ firstPage , $ lastPage ) = explode ('- ' , $ pages );
71+ return [
72+ 'pageInterval ' => trim ($ pages ),
73+ 'firstPage ' => trim ($ firstPage ),
74+ 'lastPage ' => trim ($ lastPage )
75+ ];
76+ }
77+
5278 public function getWorkStatusByDatePublished ($ chapter , $ publication )
5379 {
5480 $ dataPublished = $ chapter ->getDatePublished () ?? $ publication ->getData ('datePublished ' );
0 commit comments