handle cases where pageTextId is given but pageText is not in DB
This commit is contained in:
Sarjuuk
2015-07-18 15:16:35 +02:00
parent 3e7a34a2ea
commit 58a235e2e3
2 changed files with 27 additions and 9 deletions

View File

@@ -346,17 +346,28 @@ class ItemPage extends genericPage
// pageText
if ($next = $this->subject->getField('pageTextId'))
{
$this->addJS('Book.js');
$this->addCSS(['path' => 'Book.css']);
while ($next)
{
$row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next);
$next = $row['next_page'];
$this->pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
if ($row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next))
{
$next = $row['next_page'];
$this->pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
}
else
{
Util::addNote(U_GROUP_STAFF, 'Referenced PageTextId #'.$next.' is not in DB');
break;
}
}
}
// add conditional js & css
if ($this->pageText)
{
$this->addJS('Book.js');
$this->addCSS(['path' => 'Book.css']);
}
// subItems
$this->subject->initSubItems();
if (!empty($this->subject->subItems[$this->typeId]))

View File

@@ -206,9 +206,16 @@ class ObjectPage extends GenericPage
{
while ($next)
{
$row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next);
$next = $row['next_page'];
$pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
if ($row = DB::World()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next))
{
$next = $row['next_page'];
$pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
}
else
{
Util::addNote(U_GROUP_STAFF, 'Referenced PageTextId #'.$next.' is not in DB');
break;
}
}
}