@@ -29,6 +29,8 @@ public function createFromChapter($chapter)
2929 $ submission = Repo::submission ()->get ($ publication ->getData ('submissionId ' ));
3030 $ context = Application::getContextDAO ()->getById ($ submission ->getData ('contextId ' ));
3131
32+ $ pages = $ this ->extractPages ($ chapter );
33+
3234 return new ThothWork ([
3335 'workType ' => ThothWork::WORK_TYPE_BOOK_CHAPTER ,
3436 'workStatus ' => $ this ->getWorkStatusByDatePublished ($ chapter , $ publication ),
@@ -37,7 +39,9 @@ public function createFromChapter($chapter)
3739 'subtitle ' => $ chapter ->getLocalizedData ('subtitle ' ),
3840 'longAbstract ' => HtmlStripper::stripTags ($ chapter ->getLocalizedData ('abstract ' )),
3941 'doi ' => $ chapter ->getData ('doiObject ' )?->getResolvingUrl(),
40- 'pageCount ' => !empty ($ chapter ->getPages ()) ? (int ) $ chapter ->getPages () : null ,
42+ 'pageInterval ' => $ pages ['pageInterval ' ] ?? null ,
43+ 'firstPage ' => $ pages ['firstPage ' ] ?? null ,
44+ 'lastPage ' => $ pages ['lastPage ' ] ?? null ,
4145 'publicationDate ' => $ chapter ->getDatePublished () ?? $ publication ->getData ('datePublished ' ),
4246 'landingPage ' => $ request ->getDispatcher ()->url (
4347 $ request ,
@@ -60,4 +64,26 @@ public function getWorkStatusByDatePublished($chapter, $publication)
6064
6165 return ThothWork::WORK_STATUS_FORTHCOMING ;
6266 }
67+
68+ private function extractPages ($ chapter ): array
69+ {
70+ $ pages = $ chapter ->getPages ();
71+
72+ if (empty ($ pages )) {
73+ return [];
74+ }
75+
76+ if (strpos ($ pages , '- ' ) === false ) {
77+ return [
78+ 'firstPage ' => trim ($ pages ),
79+ ];
80+ }
81+
82+ list ($ firstPage , $ lastPage ) = explode ('- ' , $ pages );
83+ return [
84+ 'pageInterval ' => trim ($ pages ),
85+ 'firstPage ' => trim ($ firstPage ),
86+ 'lastPage ' => trim ($ lastPage )
87+ ];
88+ }
6389}
0 commit comments