. */ /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; define('WT_SCRIPT_NAME', 'index.php'); require './includes/session.php'; // The only option for action is "ajax" $action = Filter::get('action'); // The default view depends on whether we are logged in if (Auth::check()) { $ctype = Filter::get('ctype', 'gedcom|user', 'user'); } else { $ctype = 'gedcom'; } // Get the blocks list if ($ctype === 'user') { $blocks = get_user_blocks(Auth::id()); } else { $blocks = get_gedcom_blocks($WT_TREE->getTreeId()); } $active_blocks = Module::getActiveBlocks($WT_TREE); // The latest version is shown on the administration page. This updates it every day. fetch_latest_version(); // We generate individual blocks using AJAX if ($action === 'ajax') { $controller = new AjaxController; $controller->pageHeader(); // Check we’re displaying an allowable block. $block_id = Filter::getInteger('block_id'); if (array_key_exists($block_id, $blocks['main'])) { $module_name = $blocks['main'][$block_id]; } elseif (array_key_exists($block_id, $blocks['side'])) { $module_name = $blocks['side'][$block_id]; } else { return; } if (array_key_exists($module_name, $active_blocks)) { echo $active_blocks[$module_name]->getBlock($block_id); } return; } $controller = new PageController; if ($ctype === 'user') { $controller->restrictAccess(Auth::check()); } $controller ->setPageTitle($ctype === 'user' ? I18N::translate('My page') : $WT_TREE->getTitle()) ->setMetaRobots('index,follow') ->setCanonicalUrl(WT_SCRIPT_NAME . '?ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml()) ->pageHeader() // By default jQuery modifies AJAX URLs to disable caching, causing JS libraries to be loaded many times. ->addInlineJavascript('jQuery.ajaxSetup({cache:true});'); if ($ctype === 'user') { echo '