diff --git a/endpoints/home/home.php b/endpoints/home/home.php new file mode 100644 index 00000000..4dd0c69f --- /dev/null +++ b/endpoints/home/home.php @@ -0,0 +1,75 @@ + element + if ($_ = DB::Aowow()->selectCell('SELECT `title` FROM ?_home_titles WHERE `active` = 1 AND `locale` = ?d ORDER BY RAND()', Lang::getLocale()->value)) + $this->homeTitle = Util::jsEscape(Cfg::get('NAME').Lang::main('colon').$_); + + // load oneliner + if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_home_oneliner WHERE `active` = 1 ORDER BY RAND() LIMIT 1')) + $this->oneliner = new Markup(new LocString($_, 'text'), [], 'home-oneliner'); + + if ($_ = $this->oneliner?->getJsGlobals()) + $this->extendGlobalData($_); + + // load featuredBox (user web server time) + if ($box = DB::Aowow()->selectRow('SELECT * FROM ?_home_featuredbox WHERE ?d BETWEEN `startDate` AND `endDate` ORDER BY `id` DESC', time())) + { + // define text constants for all fields (STATIC_URL, HOST_URL, etc.) + $box = Util::defStatic($box); + + if ($box['altHomeLogo']) + $this->altHomeLogo = $box['altHomeLogo']; + + $this->featuredBox = array( + 'markup' => new Markup(new LocString($box, 'text'), ['allow' => Markup::CLASS_ADMIN], 'news-generic'), + 'extended' => $box['extraWide'], + 'boxBG' => $box['boxBG'] ?? Cfg::get('STATIC_URL').'/images/'.Lang::getLocale()->json().'/mainpage-bg-news.jpg', + 'overlays' => [] + ); + + if ($_ = $this->featuredBox['markup']->getJsGlobals()) + $this->extendGlobalData($_); + + // load overlay links + foreach (DB::Aowow()->select('SELECT * FROM ?_home_featuredbox_overlay WHERE `featureId` = ?d', $box['id']) as $ovl) + { + $ovl = Util::defStatic($ovl); + + $this->featuredBox['overlays'][] = array( + 'url' => $ovl['url'], + 'left' => $ovl['left'], + 'width' => $ovl['width'], + 'title' => new LocString($ovl, 'title') + ); + } + } + + parent::generate(); + } +} + +?> diff --git a/pages/home.php b/pages/home.php deleted file mode 100644 index 366a94ea..00000000 --- a/pages/home.php +++ /dev/null @@ -1,66 +0,0 @@ -selectRow('SELECT * FROM ?_home_oneliner WHERE active = 1 LIMIT 1')) - $this->oneliner = Util::jsEscape(Util::localizedString($_, 'text')); - - // load featuredBox (user web server time) - $this->featuredBox = DB::Aowow()->selectRow('SELECT id as ARRAY_KEY, n.* FROM ?_home_featuredbox n WHERE ?d BETWEEN startDate AND endDate ORDER BY id DESC LIMIT 1', time()); - if (!$this->featuredBox) - return; - - $this->featuredBox = Util::defStatic($this->featuredBox); - - $this->featuredBox['text'] = Util::localizedString($this->featuredBox, 'text', true); - - if ($_ = Markup::parseTags($this->featuredBox['text'])) - $this->extendGlobalData($_); - - if (empty($this->featuredBox['boxBG'])) - $this->featuredBox['boxBG'] = Cfg::get('STATIC_URL').'/images/'.Lang::getLocale()->json().'/mainpage-bg-news.jpg'; - - // load overlay links - $this->featuredBox['overlays'] = DB::Aowow()->select('SELECT * FROM ?_home_featuredbox_overlay WHERE featureId = ?d', $this->featuredBox['id']); - foreach ($this->featuredBox['overlays'] as &$o) - { - $o['title'] = Util::localizedString($o, 'title', true); - $o['title'] = Util::defStatic($o['title']); - } - } - - protected function generateTitle() - { - if ($_ = DB::Aowow()->selectCell('SELECT title FROM ?_home_titles WHERE active = 1 AND locale = ?d ORDER BY RAND() LIMIT 1', Lang::getLocale()->value)) - $this->homeTitle = Cfg::get('NAME').Lang::main('colon').$_; - } - - protected function generatePath() {} -} - -?> diff --git a/template/pages/home.tpl.php b/template/pages/home.tpl.php index 1262ca4b..b175e7e9 100644 --- a/template/pages/home.tpl.php +++ b/template/pages/home.tpl.php @@ -1,29 +1,32 @@ - +
brick('head'); ?> - + homeTitle): echo " \n"; endif; -if (!empty($this->featuredBox['altHomeLogo'])): +if ($this->altHomeLogo): ?>