/** * Finds the root page of fallback language for the given page. * * @param PageModel $page * * @return \PageModel|null */ public function findMasterRootForPage(PageModel $page) { $page->loadDetails(); $t = $page::getTable(); $columns = ["{$t}.type='root'", "{$t}.fallback='1'", "{$t}.languageRoot=0", "(\n {$t}.dns=? \n OR {$t}.dns IN (SELECT dns FROM tl_page WHERE type='root' AND fallback='1' AND id IN (SELECT languageRoot FROM tl_page WHERE type='root' AND fallback='1' AND dns=?)) \n OR {$t}.dns IN (SELECT dns FROM tl_page WHERE type='root' AND fallback='1' AND languageRoot IN (SELECT id FROM tl_page WHERE type='root' AND fallback='1' AND dns=?))\n )"]; return PageModel::findOneBy($columns, [$page->domain, $page->domain, $page->domain]); }
public function checkLoginStatus($objPage, $objLayout, \PageRegular $objPageRegular) { global $objPage; $loggedIn = FE_USER_LOGGED_IN; if (\Input::get('logout')) { if (@$this->User->logout()) { $loggedIn = false; } } if (!$loggedIn && $objPage->type != "login" && (Config::get("globalLogin") == 1 || $objPage->type == "error_403")) { $loginPage = PageModel::findOneBy("type", "login"); if (isset($loginPage) && $loginPage->published == 1) { $loginPage->loadDetails(); $objPage = $loginPage; $handler = new LoginPage(\Environment::get("request")); $handler->generate($loginPage); exit; } else { System::log("Please create a Login-Page urgently!!", "LoginPage\\checkLoginStatus", TL_ERROR); if ($objPage->type == "error_403") { return; } $page403_model = \PageModel::find403ByPid($objPage->rootId); if (isset($page403_model) && $page403_model->published == 1) { $page403_model->loadDetails(); $objPage = $page403_model; $handler = new PageError403(); $handler->generate($page403_model->id, $page403_model->rootId); exit; } else { System::log("Please create a 403-Error-Page urgently!!", "LoginPage\\checkLoginStatus", TL_ERROR); $objPage->template = 'fe_login'; $objPage->templateGroup = $objLayout->templates; $objPageRegular->createTemplate($objPage, $objLayout); } } } }
/** * Add the file meta information to the request * * @param string $strUuid * @param string $strPtable * @param integer $intPid */ public static function addFileMetaInformationToRequest($strUuid, $strPtable, $intPid) { $objFile = \FilesModel::findByUuid($strUuid); if ($objFile === null) { return; } $arrMeta = \StringUtil::deserialize($objFile->meta); if (empty($arrMeta)) { return; } $objPage = null; if ($strPtable == 'tl_article') { $objPage = \PageModel::findOneBy(array('tl_page.id=(SELECT pid FROM tl_article WHERE id=?)'), $intPid); } else { // HOOK: support custom modules if (isset($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest']) && is_array($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'])) { foreach ($GLOBALS['TL_HOOKS']['addFileMetaInformationToRequest'] as $callback) { if (($val = \System::importStatic($callback[0])->{$callback[1]}($strPtable, $intPid)) !== false) { $objPage = $val; } } if ($objPage instanceof Result && $objPage->numRows < 1) { return; } if (is_object($objPage) && !$objPage instanceof PageModel) { $objPage = \PageModel::findByPk($objPage->id); } } } if ($objPage === null) { return; } $objPage->loadDetails(); // Convert the language to a locale (see #5678) $strLanguage = str_replace('-', '_', $objPage->rootLanguage); if (isset($arrMeta[$strLanguage])) { if (\Input::post('title') == '' && !empty($arrMeta[$strLanguage]['title'])) { \Input::setPost('title', $arrMeta[$strLanguage]['title']); } if (\Input::post('alt') == '' && !empty($arrMeta[$strLanguage]['alt'])) { \Input::setPost('alt', $arrMeta[$strLanguage]['alt']); } if (\Input::post('caption') == '' && !empty($arrMeta[$strLanguage]['caption'])) { \Input::setPost('caption', $arrMeta[$strLanguage]['caption']); } } }