diff --git a/includes/utilities.php b/includes/utilities.php index 1f5c01c9..bf0ea9d6 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1635,6 +1635,26 @@ class Util return self::$realms; } + + public static function getPageText($ptId) + { + $pages = []; + while ($ptId) + { + if ($row = DB::World()->selectRow('SELECT ptl.Text AS Text_loc?d, pt.* FROM page_text pt LEFT JOIN page_text_locale ptl ON pt.ID = ptl.ID AND locale = ? WHERE pt.ID = ?d', User::$localeId, User::$localeString, $ptId)) + { + $ptId = $row['NextPageID']; + $pages[] = Util::parseHtmlText(Util::localizedString($row, 'Text')); + } + else + { + trigger_error('Referenced PageTextId #'.$ptId.' is not in DB', E_USER_WARNING); + break; + } + } + + return $pages; + } } ?> diff --git a/pages/item.php b/pages/item.php index 690f02f5..1250af11 100644 --- a/pages/item.php +++ b/pages/item.php @@ -330,25 +330,7 @@ class ItemPage extends genericPage // pageText $pageText = []; - if ($next = $this->subject->getField('pageTextId')) - { - while ($next) - { - if ($row = DB::World()->selectRow('SELECT *, Text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.ID = lpt.entry WHERE pt.ID = ?d', $next)) - { - $next = $row['NextPageID']; - $pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text')); - } - else - { - trigger_error('Referenced PageTextId #'.$next.' is not in DB', E_USER_WARNING); - break; - } - } - } - - // add conditional js & css - if ($pageText) + if ($this->pageText = Util::getPageText($this->subject->getField('pageTextId'))) { $this->addJS('Book.js'); $this->addCSS(['path' => 'Book.css']); @@ -356,7 +338,6 @@ class ItemPage extends genericPage $this->headIcons = [$this->subject->getField('iconString'), $this->subject->getField('stackable')]; $this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null; - $this->pageText = $pageText; $this->tooltip = $this->subject->renderTooltip(true); $this->redButtons = array( BUTTON_WOWHEAD => true, diff --git a/pages/object.php b/pages/object.php index c2165bc9..c67b3099 100644 --- a/pages/object.php +++ b/pages/object.php @@ -194,26 +194,7 @@ class ObjectPage extends GenericPage /****************/ // pageText - $pageText = []; - if ($next = $this->subject->getField('pageTextId')) - { - while ($next) - { - if ($row = DB::World()->selectRow('SELECT *, Text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.ID = lpt.entry WHERE pt.ID = ?d', $next)) - { - $next = $row['NextPageID']; - $pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text')); - } - else - { - trigger_error('Referenced PageTextId #'.$next.' is not in DB', E_USER_WARNING); - break; - } - } - } - - // add conditional js & css - if ($pageText) + if ($this->pageText = Util::getPageText($next = $this->subject->getField('pageTextId'))) { $this->addCSS(['path' => 'Book.css']); $this->addJS('Book.js'); @@ -244,7 +225,6 @@ class ObjectPage extends GenericPage } $this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null; - $this->pageText = $pageText; $this->map = $map; $this->relBoss = $relBoss; $this->redButtons = array(