'; //print_r($HTTP_GET_VARS); //print ''; // //print '
';
//print_r($HTTP_SERVER_VARS);
//print '
'; /** * This script fetches a page from easysite, and displays it * * Query's: * - pageId = The page to load. * -- Default: PAGE_ID_WEB_ROOT (defined in config.inc.php). * - templateId = The template to use. * -- Default: The page's default template. * - mode = The mode to show the page in. * -- Possible values: cached, compiled, recompiled and editor. * --- The editor value is for the editor to enable editing the page * -- Default: cached. * - state = The state to show the page in. * -- Possible values: edit, waiting, online. * -- Default: online. * * @author Karto * @version $Id: getPage.php 10078 2008-07-23 11:54:03Z hhc $ * @copyright InleadMedia * @package Easysite * @since Easysite 2.5 */ /** * Includes */ require_once('config.inc.php'); // Config include require_once(INCLUDE_DIR.'/dbconstants.php'); // db constants include require_once(INCLUDE_DIR.'/dbintegritet.php'); // dbintegritet include require_once(INCLUDE_DIR.'/dbrelationer.php'); // dbrelationer include require_once(INCLUDE_DIR.'/commonfunctions.inc.php'); // dbrelationer include require_once(CLASS_DIR.'/DbConn.class.php'); // Database include require_once(CLASS_DIR.'/Smarty.class.php'); // Smarty include // require_once(CLASS_DIR.'/TemplateInfo.class.php'); // template info include require_once(CLASS_DIR.'/Page.class.php'); // Page sys include require_once(CLASS_DIR.'/Section.class.php'); // Page sys include require_once(CLASS_DIR.'/Field.class.php'); // Page sys include require_once(CLASS_DIR.'/ContentType.class.php'); // Page sys include require_once(CLASS_DIR.'/smartyPlugins/function.url.php'); // Url rewrite function for smarty require_once(CLASS_DIR."/Language.class.php"); // Language translation require_once(ROOT_DIR.TEMPLATE_BASE_PATH.'/include/commonFunctions.php'); // Common functions for the templates /** * Create a database connection */ $dbc = new DbConn(); // Set the state of the page // If not logged into easysite, the user shouldnt be able to see the draft page (set in config.inc) if(!ALLOW_NON_EASYSITE_USERS_DRAFT && !isset($_COOKIE['easysiteSessionId'])) { $state = 'online'; } switch(strtolower(substr($state, 0, 1))) { case 'd': define('PAGE_STATE', 'draft'); break; case 'p': define('PAGE_STATE', 'proposal'); break; case 'o': default: define('PAGE_STATE', 'online'); break; } /** * Define the pageId */ if (!isset($pageId) || empty($pageId)) { $pageId = PAGE_ID_WEB_ROOT; } if(!($GLOBALS['pageInfo'][$pageId] = Page::pageInfoLight($dbc, $pageId, PAGE_STATE, $_REQUEST['templateId']))) { //print 'ERROR: Unable to find PageId: '.$pageId.' in state: '.PAGE_STATE.''; //header("HTTP/1.0 404 Page Not Found"); // The page does not exist... Display error page. header('Location: '.FRONTEND_URL.'/template/404.php'); die(); } define('PAGE_ID', $pageId); if (!defined('PAGE_STATE_LOADED')) { define('PAGE_STATE_LOADED', PAGE_STATE); } /** * Define the mode and the state */ $mode = strtolower(substr($mode, 0, 2)); if (('co' == $mode || 'dy' == $mode)) // The compiled / dynamic version { define('PAGE_MODE', 'compiled'); // The static version } else if ('re' == $mode) // Recompile it all and display it dynamicly { define('PAGE_MODE', 'recompiled'); // The static version } else if ('ed' == $mode) // Recompile it all and display it dynamicly { require_once(INCLUDE_DIR."/header.php"); $pageId = PAGE_ID; require(BACKEND_DIR."/editors/defaultLockAndPrivCheck.php"); if (true == $readonly) { define('PAGE_MODE', 'readonly'); // The static version } else { define('PAGE_MODE', 'editor'); // The static version } } else // Show the cached / static version... This is ALWAYS the online version { define('PAGE_MODE', 'cached'); // The static version //$state = 'online'; // The online version } /** * Include the frontend user auth */ if (PAGE_MODE != 'editor' && false == $readonly) { // If we are not in the editor, somebody is watching the online page, and need frontenduser require(ROOT_DIR.FRONTEND_PATH.'/comaut.php'); } define('TEMPLATE_ID',$GLOBALS['pageInfo'][$pageId]['templateId']); /** * Define the templateId */ //if (!isset($templateId) || empty($templateId)) //{ // define('TEMPLATE_ID', $GLOBALS['pageInfo'][PAGE_ID]['defaultTemplateId']); //} //else if (!Page::isTemplateIdValid($dbc, PAGE_ID, PAGE_STATE_LOADED, $templateId)) //{ // define('TEMPLATE_ID', Page::getDefaultTemplateId($dbc, PAGE_ID, PAGE_STATE_LOADED)); //} //else //{ // define('TEMPLATE_ID', $templateId); //} /** * init the templateInfo object */ define('TEMPLATE_PATH', TEMPLATE_BASE_PATH.'/'.$GLOBALS['pageInfo'][$pageId]['templateInfo']['path']); define('TEMPLATE_DIR', ROOT_DIR.TEMPLATE_PATH); define('TEMPLATE_URL', ROOT_URL.TEMPLATE_PATH); define('TEMPLATE_TYPE', $GLOBALS['pageInfo'][$pageId]['templateInfo']['type']); /* $templateInfo = new TemplateInfo($dbc, $log); /** * Loads the templateInfo into memory * / if (!$templateInfo->load(TEMPLATE_ID)) { // print 'ERROR: Unable to load templateId: '.TEMPLATE_ID.' in pageId: '.PAGE_ID.''; header("HTTP/1.0 404 Page Not Found"); // The template does not exist... Display error page. exit; } else { define('TEMPLATE_PATH', TEMPLATE_BASE_PATH.'/'.$templateInfo->path); define('TEMPLATE_DIR', ROOT_DIR.TEMPLATE_PATH); define('TEMPLATE_URL', ROOT_URL.TEMPLATE_PATH); } */ /** * Create a smarty instance */ $smarty = new Smarty(); /** * smarty Properties and assignments */ $smarty->template_dir = TEMPLATE_DIR; // name of directory for templates $smarty->compile_dir = ROOT_DIR.TEMPLATE_BASE_PATH.'/compiled'; // name of directory for compiled templates $smarty->cache_dir = ROOT_DIR.FRONTEND_PATH.'/cache'; // name of directory for template cache files if (SITE_CACHE_ACTIVE) { $smarty->compile_id = 'PAGE|'.substr(PAGE_ID, -2).'|'.PAGE_ID.'|'.TEMPLATE_ID.'|'.PAGE_STATE.( PAGE_MODE == 'editor' ? '|editor' : (PAGE_MODE=='readonly'?'|readonly':'|normal') ); // Needed to cache difrent versions of the same template, eg. pageId and templateId //$smarty->compile_id = ''; //$smarty->debugging = true; switch(PAGE_MODE) { case 'compiled': // Just check for changes in the template files, recompile as necessary, NO CACHE case 'readonly': // Just check for changes in the template files, recompile as necessary, NO CACHE $smarty->force_compile = false; // Recompiles the compiled templates $smarty->caching = 0; // Cache the page break; case 'editor': // Just check for changes in the template files, recompile as necessary, NO CACHE case 'recompiled': // force recompile ALL templates, NO CACHE $smarty->force_compile = true; // Recompiles the compiled templates $smarty->caching = 0; // Cache the page break; case 'cached': // DONT recompile ANY templates, GET PAGE FROM CACHE default: $smarty->force_compile = false; // Recompiles the compiled templates $smarty->caching = 1; // Cache the page break; } } else { if (PAGE_MODE == 'editor' && $aut) $smarty->compile_id = $aut->brugerId; else $smarty->compile_id = ''; $smarty->force_compile = true; // Recompiles the compiled templates $smarty->caching = 0; // Cache the page $smarty->use_sub_dirs = false; } //$cache_id = 'PAGE|'.substr(PAGE_ID, -2).'|'.PAGE_ID.'|'.TEMPLATE_ID.'|'.PAGE_STATE.( PAGE_MODE == 'editor' ? '|editor' : (PAGE_MODE=='readonly'?'|readonly':'|normal') ); //switch(PAGE_MODE) //{ // case 'compiled': // Just check for changes in the template files, recompile as necessary, NO CACHE // case 'editor': // Just check for changes in the template files, recompile as necessary, NO CACHE // $smarty->force_compile = false; // Recompiles the compiled templates // $smarty->caching = 0; // Cache the page // break; // case 'recompiled': // force recompile ALL templates, NO CACHE // $smarty->force_compile = true; // Recompiles the compiled templates // $smarty->caching = 0; // Cache the page // break; // case 'cached': // DONT recompile ANY templates, GET PAGE FROM CACHE // default: // $smarty->force_compile = false; // Recompiles the compiled templates // $smarty->caching = 1; // Cache the page // break; //} /** * Checks to see if we need to load the page into memory (for caching, compiling or viewing dynamicly) */ if(!$smarty->is_cached($GLOBALS['pageInfo'][$pageId]['templateInfo']['fileName'])) { /** * init the page object */ $page = new Page($dbc, $log); /** * Loads the page into memory */ if (PAGE_CLASS_SUCCESS !== ($errorCode = $page->load(PAGE_ID, PAGE_STATE_LOADED, TEMPLATE_ID))) { // print 'ERROR: Unable to load PageId: '.PAGE_ID.' in state: '.PAGE_STATE_LOADED.' in mode: '.PAGE_MODE.' errorCode: '.$errorCode.''; //header("HTTP/1.0 404 Page Not Found"); // The template does not exist... Display error page. header('Location: '.FRONTEND_URL.'/template/404.php'); exit; } if($page->locale) { $frontendLanguage = new Language(); $frontendLanguage->setGroup('frontend'); $GLOBALS['frontendLanguageCode'] = $page->locale; setlocale(LC_ALL, $page->locale); } // Generate Noscrip content $noscript = ''; if ($page->metadata['noscript']['description']) $noscript .= $page->metadata['noscript']['description']."\n"; if ((int)$page->metadata['noscript']['nextPagePageId']) $noscript .= getPageLinkWithOverride((int)$page->metadata['noscript']['nextPagePageId'])."\n"; if ((int)$page->metadata['noscript']['sitemapPageId']) $noscript .= getPageLinkWithOverride((int)$page->metadata['noscript']['sitemapPageId'])."\n"; if ($noscript) $noscript = ''; /** * smarty page assignments */ $smarty->assign("page", array( // What info is avaible to the template // Page title override "title" => ( $page->metadata['page']['title'] ? $page->metadata['page']['title'] : $page->title ), "cssTag" => $page->cssTag, "cssUrl" => $page->cssUrl, "cssId" => $page->cssId, "metaTag" => $page->metaTag, "meta" => $page->meta, "templateId" => TEMPLATE_ID, "pageId" => PAGE_ID, "pageState" => PAGE_STATE, "pageMode" => PAGE_MODE, 'pageStateLoaded' => PAGE_STATE_LOADED, 'locked' => $readonly, 'TABLE_BACKEND_PROPERTIES' => TABLE_BACKEND_PROPERTIES, 'noscript' => $noscript )); $smarty->assign("site", array( // What info is avaible to the template "TEMPLATE_URL" => TEMPLATE_URL, "FRONTEND_URL" => FRONTEND_URL, "BACKEND_URL" => BACKEND_URL, "TEMPLATE_DIR" => TEMPLATE_DIR, "FRONTEND_DIR" => FRONTEND_DIR, "BACKEND_DIR" => BACKEND_DIR, "PAGE_ID_WEB_ROOT" => PAGE_ID_WEB_ROOT )); $smarty->assign("TEMPLATE_BASE_DIR", ROOT_DIR.TEMPLATE_BASE_PATH); $smarty->assign("dbc", &$dbc); $smarty->assign("PHP_SELF", &$PHP_SELF); } else { // karto foreslog at dette skulle laves smartere, men det han foreslog var ikke smartere .... h.. synes jeg ... hm.... (anton 21-10-2002 13:17) $smarty->assign("page", array( // What info is avaible to the template "pageId" => PAGE_ID, "pageState" => PAGE_STATE, "pageMode" => PAGE_MODE, 'pageStateLoaded' => PAGE_STATE_LOADED, "templateId" => TEMPLATE_ID, 'locked' => $readonly )); $smarty->assign("site", array( // What info is avaible to the template "TEMPLATE_URL" => TEMPLATE_URL, "FRONTEND_URL" => FRONTEND_URL, "BACKEND_URL" => BACKEND_URL, "TEMPLATE_DIR" => TEMPLATE_DIR, "FRONTEND_DIR" => FRONTEND_DIR, "BACKEND_DIR" => BACKEND_DIR, "PAGE_ID_WEB_ROOT" => PAGE_ID_WEB_ROOT )); $smarty->assign("TEMPLATE_BASE_DIR", ROOT_DIR.TEMPLATE_BASE_PATH); $smarty->assign("dbc", &$dbc); $smarty->assign("PHP_SELF", &$PHP_SELF); } $smarty->assign("template", array( // What info is avaible to the template "TEMPLATE_PATH" => TEMPLATE_PATH , "TEMPLATE_DIR" => TEMPLATE_DIR , "TEMPLATE_URL" => TEMPLATE_URL , "TEMPLATE_BASE_PATH" => TEMPLATE_BASE_PATH , "templateId" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['templateId'] , "path" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['path'] , "fileName" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['fileName'] , "title" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['title'] , "maxNoOfSubTotal" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['maxNoOfSubTotal'] , "defaultCssId" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['defaultCssId'] , "defaultPageTitle" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['defaultPageTitle'] , "defaultPageId" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['defaultPageId'] , "type" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['type'] , "alwaysAvailable" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['alwaysAvailable'] , "active" => $GLOBALS['pageInfo'][$pageId]['templateInfo']['active'] )); /** * Editor stuff * * @todo Find a way to get IE to load files NOT ending in .htc as a htc file. */ if (PAGE_MODE == 'editor') { // $htc = ''."\n"; // $htc .= ''."\n"; // $htc .= ''."\n"; // $htc .= ''."\n"; // $htc .= ''."\n"; //$sql = "SELECT contentTypeId FROM p_contentType"; // $sql = " // SELECT p_contentType.contentTypeId // FROM p_section // , p_field // , p_contentType // WHERE p_section.pageId = ".PAGE_ID." // AND p_field.sectionId = p_section.sectionId // AND p_contentType.contentTypeId = p_field.contentTypeId // "; $sql = " SELECT p_contentType.contentTypeId , p_contentType.className FROM p_contentType "; $qry = $dbc->query($sql); $smarty->assign('fieldId','NewField'); $contentImage = array(); while($qry->next()) { if ($qry->field('className') != 'ContentTypeNavigation' && $qry->field('className') != 'ContentTypeSubmenu') { $contentTypes[$qry->field('contentTypeId')] = 'true'; } } $contentTypes[1] = 'true'; // foreach($contentTypes AS $contentTypeId => $bogus) // { // $htc .= ''."\n"; // } $smarty->assign("editor", array( // What info is avaible to the template "htmlTag" => ' xmlns:field', "headHtc" => $htc, "editorJsFile" => ROOT_DIR.TEMPLATE_BASE_PATH.'/editor.js.tpl', "editorIncFile" => ROOT_DIR.TEMPLATE_BASE_PATH.'/editor.inc.tpl', "contentTypes" => $contentTypes )); } else if(PAGE_MODE == 'readonly') { $smarty->assign('readonly',$readonlyMessage); $smarty->assign('editor',false); } /** * Statestik */ if (PAGE_MODE == 'cached') { // $id = PAGE_ID; // include('./statistik.php'); } /** * Display the page * * cache_id = Bliver kun brugt til cache (Dvs. hvor hele siden gemmes.) * Compile_id = Bliver brugt bde til at cache og compile */ $smarty->display($GLOBALS['pageInfo'][$pageId]['templateInfo']['fileName'],$cache_id); /** * DEBUGGING INFO ABOUT THE PAGE */ print "\r\n"; print ''."\r\n"; print "\r\n"; ?>