$this->checkConfig();
$this->checkPageLabels();
+ $this->checkChapters();
// We need to be able to reference both navOrder and navOrderH so convert both to arrays
// We also make sure there are no empty items in the arrays (see: http://php.net/manual/en/function.array-filter.php#111091)
}
+ protected function checkChapters()
+ {
+ $num = $this->_fluidbook->chaptersPagesNumber;
+ foreach ($this->_fluidbook->getChapters() as $chapter) {
+ if (in_array($chapter['decoration'], ['nocut', 'forcecut', 'column_head', 'separator'])) {
+ continue;
+ }
+ $error = ($num === 'virtual' && !$this->virtualToPhysical($chapter['page'], true)) || ($num === 'physical' && $chapter['page'] > $this->_fluidbook->getPagesNumber());
+ if ($error) {
+ FluidbookHealthIssues::addIssue($this->book_id, FluidbookHealthIssues::TYPE_CHAPTER_PAGE_NOT_EXIST, ['chapter' => $chapter['label'], 'page' => $chapter['page']]);
+ }
+
+ }
+ }
+
protected function checkConfig()
{
if ($this->isMobileFirst() && $this->fluidbookSettings->mobilefirstFluidbookId) {
return $this->linkScale;
}
- public function virtualToPhysical($virtual): string|int
+ public function virtualToPhysical($virtual, $returnFalseIfNotExist = false): string|int
{
if (isset($this->pageLabels[$virtual])) {
return $virtual;
}
if (!in_array($virtual, $this->numerotation)) {
+ if ($returnFalseIfNotExist) {
+ return false;
+ }
return $virtual;
}
$p = array_search($virtual, $this->numerotation);
const TYPE_MOBILEFIRST_CONFIG = 3;
const TYPE_TTS_VOICE_INVALID = 4;
const TYPE_COMPILE_FILES = 5;
+ const TYPE_CHAPTER_PAGE_NOT_EXIST=6;
const CRIT_ERROR = 5;
const CRIT_WARNING = 3;
* __('Ce fluidbook mobile first a le paramètre "Identifiant du fluidbook Mobile first" défini. Ce paramètre est réservé aux fluidbooks Desktop')
* __('La voix d\'audiodescription :voice est invalide')
* __('L\'erreur suivante s\'est produite lors de la compilation du fluidbook : :error')
+ * __('Page introuvable pour le chapitre intitulé :chapter (Page :page). L\'élement ne sera pas affiché dans la publication')
*
*/
return [
'criticality' => self::CRIT_ERROR,
'text' => 'L\'erreur suivante s\'est produite lors de la compilation du fluidbook : :error',
],
+ static::TYPE_CHAPTER_PAGE_NOT_EXIST =>
+ [
+ 'summary' => __('Page de sommaire introuvable'),
+ 'criticality' => self::CRIT_ERROR,
+ 'text' => 'Page introuvable pour le chapitre intitulé :chapter (Page :page). L\'élement ne sera pas affiché dans la publication.',
+ 'fixText' => __('Editer le sommaire'),
+ 'fixURL' => route('fluidbook-publication.edit', ['id' => $fluidbookId]) . '#s_section_chapters',
+ ],
];
}