Beispiel #1
0
 /**
  * @param $menuItemTranslation
  * @return bool
  */
 private function setupPage($menuItemTranslation)
 {
     try {
         $this->currentMenuItemTranslation = $menuItemTranslation;
         $this->currentMenuItem = $menuItemTranslation->menuItem;
         $this->locale->setLocale($menuItemTranslation->locale);
         $this->template->setSiteTemplateDir($menuItemTranslation->menuItem->site->templateDir);
         $pageTitle = ((string) $menuItemTranslation->pageTitle === '' ? $menuItemTranslation->title : $menuItemTranslation->pageTitle) . ' | ' . $menuItemTranslation->menuItem->site->name;
         $this->template->setPageTitle($pageTitle);
         $this->template->setPageDescription($menuItemTranslation->longDescription);
         $this->template->setKeywords(explode(',', $menuItemTranslation->keywords));
         setlocale(LC_ALL, $this->locale->getLocale()->locale);
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Beispiel #2
0
 /**
  * @param $menuItemTranslation
  * @return bool
  * @throws \Exception
  */
 protected function setupPage($menuItemTranslation)
 {
     try {
         $this->currentMenuItemTranslation = $menuItemTranslation;
         $this->currentMenuItem = $menuItemTranslation->menuItem;
         $this->db->setTranslatableLocale($menuItemTranslation->locale->locale);
         $this->template->setSiteTemplateDir($menuItemTranslation->menuItem->site->templateDir);
         if ($this->request->isXmlHttpRequest() || $this->user->isAdmin()) {
             $localeId = $this->request->gp('locale_id');
             if ($localeId && is_numeric($localeId)) {
                 $this->locale->setLocale($localeId);
             } else {
                 $this->locale->setLocale($menuItemTranslation->locale);
             }
         } else {
             $this->locale->setLocale($menuItemTranslation->locale);
         }
         $pageTitle = (string) $menuItemTranslation->pageTitle === '' ? $menuItemTranslation->title : $menuItemTranslation->pageTitle;
         $pageTitle = str_replace('[SITE_NAME]', $menuItemTranslation->menuItem->site->name, $pageTitle);
         $this->template->setPageTitle($pageTitle);
         $this->template->setPageDescription($menuItemTranslation->description);
         $this->template->setKeywords(explode(',', $menuItemTranslation->keywords));
         setlocale(LC_ALL, $this->locale->getLocale()->locale);
     } catch (Exception $e) {
         throw new \Exception('Error setup page: ' . $e->getMessage());
     }
     return true;
 }