'cet', // Site subfolder - i.e difference between htdocs and Apache docroot. 'SITE_PROXY_OFFSET' => '', // Path which site is reverse proxied via. Leave blank if not required. 'PROXY_HOSTS' => array( 'sydney.edu.au','www-dev.sydney.edu.au','dpm-web-1.publications.usyd.edu.au' ), // Hosts/domains where site may be reverse-proxied via 'HTDOCS_FOLDER_NAME' => 'htdocs', 'HTDOCS_FOLDER_PRODUCTION_NAME' => '', // Used if production server uses alternative naming structure 'LIB_FOLDER_NAME' => 'lib', 'DEFAULTLIB_FOLDER_NAME'=> 'usyd', 'MODULES_FOLDER_NAME' => 'modules', 'CUSTOMLIB_FOLDER_NAME' => 'custom', 'CONF_FOLDER_NAME' => 'conf', 'PREVIEW_FOLDER_NAME' => 'preview', 'BASE_PATH' => '' ); // Setup CMSAPI environment $CMSAPI_Loader = new CMSAPI_Loader($CMSAPI_Config); //var_dump($CMSAPI_Loader); // Setup some backwards-compatibility values $root = CMSAPI_IS_PRODUCTION ? CMSAPI_BASE_PATH : CMSAPI_DOC_PATH; // Medicine $subDirectory = CMSAPI_URL_BASE; // Legacy API // Initialise CMSAPI Page $CURRENT_PAGE = new CMSAPI_Page(CMSAPI_DOC_PATH, CMSAPI_SITE_ROOT_OFFSET, "/includes/globalIncs/global_nav.inc", "/includes/tabs/CET_agents.inc", "/includes/menus/agents_ordbro.inc", "/includes/content/cetbrochureorder_content.inc", "/includes/footer/default.shtml", "CENTRE FOR ENGLISH TEACHING BROCHURE ORDERING FORM", "CET", "The University of Sydney", "" ); // MODULE INCLUDES # V ------------ form builder ---------------------------------------------------------------------------- $CMS_MODULE = null; require_once('cmsForm/cmsForm.php5'); $FORM_MODULE = new cmsForm( $CURRENT_PAGE, array( 'contentPath'=>"/includes/content/cetbrochureorder_content.inc", 'confirmationPath'=>"/includes/content/cetbrochureorder_confirm.inc", 'thankyouPath'=>'/includes/content/cetbrochureorder_thankyou.inc', 'schemaPath'=>"/includes/content/cetbrochureorder_schema.xml", 'formId'=>'15620' ) ); if($CURRENT_PAGE->pageMedia == 'PRINT') { $logoImage = $subDirectory . PAGE_LOGOSRC_PRINT; } else { $logoImage = $subDirectory . PAGE_LOGOSRC_SCREEN; } // asort($CURRENT_PAGE->additionalMenus); // asort($CURRENT_PAGE->additionalTabs); $gmdate_mod = gmdate('D, d M Y H:i:s', filemtime(CMSAPI_DOC_PATH.CMSAPI_SITE_ROOT_OFFSET."/includes/content/cetbrochureorder_content.inc")) . ' GMT'; header("Last-Modified: $gmdate_mod"); ?> <?php echo $CURRENT_PAGE->pageTitleComplete; ?> "; echo ""; ?>
pageTabSetSrc) || count($CURRENT_PAGE->additionalTabs)) { $tabText = $tabTextBefore = $tabTextAfter = ''; $existingActiveTab = false; $activeTabText = 'Agents'; foreach($CURRENT_PAGE->additionalTabs AS $tabItem) { if ($tabItem['isActive'] && !$existingActiveTab) { $li_class = ' class="active"'; $activeTabText = $tabItem['tabText']; $existingActiveTab = true; } else { $a_class = $li_class = ''; } // Look for any menu items $thisTabSubMenu = ''; foreach ($CURRENT_PAGE->additionalMenus as $menuItem) { if ($menuItem['groupId'] == $tabItem['menuGroupId']) { $thisTabSubMenu .= "
  • ".$menuItem['menuText']."
  • "; } } // Generate tab HTML $thisTabText = ''.$tabItem['tabText'].''; if ($thisTabSubMenu) { $thisTabText .= '
      '.$thisTabSubMenu.'
    '; } $thisTabText .= ''; // Position tab item if ($tabItem['tabPosition'] < 0) { $tabTextBefore .= $thisTabText; } else { $tabTextAfter .= $thisTabText; } } if ($CURRENT_PAGE->pageTabSetSrc) { $tabText = file_get_contents($CURRENT_PAGE->pageTabSetSrc); // Replace relevant SSI subDirectories with php ones $tabText = str_replace('(none)',$subDirectory,$tabText); // If API code has specified an active tab, strip static active classes from include $tabText = ($existingActiveTab) ? str_replace(' class="active"','',$tabText) : $tabText; // Insert additional tabs $tabText = str_replace("","\n\n".$tabTextBefore."\n\n",$tabText); $tabText = str_replace("","\n\n".$tabTextAfter."\n\n",$tabText); } else if ($tabTextBefore || $tabTextAfter) { $tabText = "
      ".$tabTextBefore.$tabTextAfter."
    "; } print($tabText); // print('
    '); } ?>
    pageMenuSetSrc) || count($CURRENT_PAGE->additionalMenus)) { $menuText = $menuTextBefore = $menuTextAfter = ''; $existingActiveMenu = false; foreach($CURRENT_PAGE->additionalMenus AS $menuItem) { // If menu has a groupId, then it's destined to be a tab-menu, so don't bother processing it here if(!$menuItem['groupId']) { // Set active classes. Only allow one menu item to be active at a time. if($menuItem['isActive'] && !$existingActiveMenu) { $a_class = ' class="active"'; $li_class = ' class="static"'; $existingActiveMenu = true; } else { // Unset active classes $a_class = $li_class = ''; } // If a submenu set has been specifed, process it if (count($menuItem['subMenu'])) { $submenu = '
      '; foreach($menuItem['subMenu'] as $subMenuItem) { $submenu .= "
    • ".$subMenuItem['menuText']."
    • "; } $submenu .= '
    '; } else { $submenu = ''; } // Menu item HTML $thisMenuText = "".$menuItem['menuText']."$submenu"; // Position menu item if ($menuItem['menuPosition'] < 0) { $menuTextBefore .= $thisMenuText; } else { $menuTextAfter .= $thisMenuText; } } } if ($CURRENT_PAGE->pageMenuSetSrc) { $menuText = file_get_contents($CURRENT_PAGE->pageMenuSetSrc); // Replace relevant SSI subDirectories with php ones $menuText = str_replace('(none)',CMSAPI_URL_BASE,$menuText); // If API code has specified an active tab, strip static active/static classes from include $menuText = ($existingActiveMenu) ? str_replace(' class="static"','',$menuText) : $menuText; $menuText = ($existingActiveMenu) ? str_replace(' class="active"','',$menuText) : $menuText; // Insert additional menus $menuText = str_replace("","\n\n".$menuTextBefore."\n\n",$menuText); $menuText = str_replace("","\n\n".$menuTextAfter."\n\n",$menuText); } else if ($menuTextBefore || $menuTextAfter) { $menuText = "
      ".$menuTextBefore.$menuTextAfter."
    "; } else { $activeTabText =''; } print (""); } ?> pageContentSrc); $contentText = ob_get_clean(); /* If there are API-generated tabs/menus in a page which didn't have them to start with, we inject the correct #content classes */ // Calculate correct CSS classes $tabClass = (!empty($CURRENT_PAGE->pageTabSetSrc) || count($CURRENT_PAGE->additionalTabs)) ? 'withtabs' : 'withouttabs'; $menuClass = (!empty($CURRENT_PAGE->pageMenuSetSrc) || count($CURRENT_PAGE->additionalMenus)) ? 'withmenu' : 'nomenu' ; // Apply classes $contentText = str_replace(array('withouttabs','withtabs'),array('%class%','%class%'),$contentText); $contentText = str_replace('%class%',"$tabClass $menuClass",$contentText); // Replace relevant SSI subDirectories with php ones $contentText = str_replace('(none)',CMSAPI_URL_BASE,$contentText); // Output content print ($contentText); ?>
    pageFooterSrc); ?>
    CMSAPI_Config = $CMSAPI_Config; $this->Env('IS_PRODUCTION', $this->IsProduction()); $this->Env('IS_PROXIED', $this->IsReverseProxied()); $this->SetEnvPaths(); $this->SetGlobals(); $this->SetIncludePaths(); apache_setenv('subDirectory', CMSAPI_URL_BASE); require_once('CMSAPI/Page.php5'); } protected function SetEnvPaths() { // Calculate base path $sBasePath = $this->Config('BASE_PATH'); if ($this->Env('IS_PRODUCTION')) { // If base path is not correctly pre-configured, work it out if (empty($sBasePath) || !is_file($sBasePath.'/'.$this->Config('LIB_FOLDER_NAME').'/CMSAPI/Page.php5')) { $sBasePath = dirname($_SERVER['DOCUMENT_ROOT']); } // Make sure correct htdocs path is set $sHtdocsProductionFolder = $this->Config('HTDOCS_FOLDER_PRODUCTION_NAME'); if (empty($sHtdocsProductionFolder)) { $this->Env('HTDOCS_FOLDER_NAME', $this->Config('HTDOCS_FOLDER_NAME')); } else { $this->Env('HTDOCS_FOLDER_NAME', $sHtdocsProductionFolder); } } else { $aPathParts = split ('/', $_SERVER['SCRIPT_FILENAME']); $sDocFolderName = (in_array($this->Config('PREVIEW_FOLDER_NAME'), $aPathParts)) ? $this->Config('PREVIEW_FOLDER_NAME') : $this->Config('HTDOCS_FOLDER_NAME'); $i = 0; while ($aPathParts[$i] != $sDocFolderName) { $sBasePath .= '/' . $aPathParts[$i++]; } $this->Env('HTDOCS_FOLDER_NAME', $this->Config('HTDOCS_FOLDER_NAME')); } $this->Env('BASE_PATH', $sBasePath); $this->Env('DOC_PATH', $sBasePath.'/'.$this->Env('HTDOCS_FOLDER_NAME')); // Calculate URL offset path $sSiteUrlOffset = ''; $sSiteRootOffset = $this->Config('SITE_ROOT_OFFSET'); if ($this->Env('IS_PROXIED')) { $sSiteUrlOffset = (empty($sSiteRootOffset)) ? '/'.$this->Config('SITE_PROXY_OFFSET') : '/'.$this->Config('SITE_PROXY_OFFSET').'/'.$sSiteRootOffset; } elseif (!empty($sSiteRootOffset)) { $sSiteUrlOffset = '/'.$sSiteRootOffset; } $this->Env('SITE_URL_OFFSET', $sSiteUrlOffset); } protected function IsProduction() { return (!isset($_SERVER['iwarea'])); } protected function IsReverseProxied() { $sProxyOffset = $this->Config('SITE_PROXY_OFFSET'); // If site is reverse proxied, and a proxy offset is defined, check if it is a defined proxy if (!empty($sProxyOffset) && array_key_exists('HTTP_X_FORWARDED_HOST', $_SERVER)) { foreach ($this->Config('PROXY_HOSTS') as $sProxyHost) { if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], $sProxyHost) !== false) { return true; } } } return false; } protected function SetGlobals() { $sBasePath = $this->Env('BASE_PATH'); $sLibFolder = $this->Config('LIB_FOLDER_NAME'); $sSiteRootOffset = $this->Config('SITE_ROOT_OFFSET'); $sSiteProxyOffset = (empty($sSiteProxyOffset)) ? '' : '/' . $sSiteProxyOffset; $sSiteProxyOffset = $this->Config('SITE_PROXY_OFFSET'); $sSiteRootOffset = (empty($sSiteRootOffset)) ? '' : '/' . $sSiteRootOffset; define('CMSAPI_IS_PROXIED', $this->Env('IS_PROXIED')); define('CMSAPI_IS_PRODUCTION', $this->Env('IS_PRODUCTION')); define('CMSAPI_SITE_ROOT_OFFSET', $sSiteRootOffset); // -- VIRTUAL, PHP include w/ CMSAPI_DOC_PATH define('CMSAPI_SITE_PROXY_OFFSET', $sSiteProxyOffset); define('CMSAPI_BASE_PATH', $sBasePath); // Absolute path to folder containing htdocs/lib/conf etc define('CMSAPI_DOC_PATH', $this->Env('DOC_PATH')); // Absolute path to htdocs folder, not including site root offset -- PHP include w/ CMSAPI_DOC_PATH define('CMSAPI_URL_BASE', $this->Env('SITE_URL_OFFSET')); // Context aware URL base, combination of subfolder and proxy location -- SSI/URL generation define('CMSAPI_LIB_PATH', $sBasePath.'/'.$sLibFolder); define('CMSAPI_DEFAULTLIB_PATH', $sBasePath.'/'.$sLibFolder.'/'.$this->Config('DEFAULTLIB_FOLDER_NAME')); define('CMSAPI_CUSTOMLIB_PATH', $sBasePath.'/'.$sLibFolder.'/'.$this->Config('CUSTOMLIB_FOLDER_NAME')); define('CMSAPI_MODULE_PATH', $sBasePath.'/'.$sLibFolder.'/'.$this->Config('MODULES_FOLDER_NAME')); define('CMSAPI_CONF_PATH', $sBasePath.'/'.$this->Config('CONF_FOLDER_NAME').'/'); } protected function SetIncludePaths() { $sDependsPath = CMSAPI_DOC_PATH.'/'.PATH_SEPARATOR; $sDependsPath .= CMSAPI_BASE_PATH.'/'.PATH_SEPARATOR; $sDependsPath .= CMSAPI_CUSTOMLIB_PATH.'/'.PATH_SEPARATOR; $sDependsPath .= CMSAPI_DEFAULTLIB_PATH.'/'.PATH_SEPARATOR; $sDependsPath .= CMSAPI_MODULE_PATH.'/'.PATH_SEPARATOR; ini_set('include_path', ini_get('include_path'). PATH_SEPARATOR .$sDependsPath); } public function Config($sVarName, $sVarValue = Null) { if ($sVarValue === Null && array_key_exists($sVarName, $this->CMSAPI_Config)) { return $this->CMSAPI_Config[$sVarName]; } elseif (!($sVarValue === Null)) { return $this->CMSAPI_Config[$sVarName] = $sVarValue; } return Null; } public function Env($sVarName, $sVarValue = Null) { if ($sVarValue === Null && array_key_exists($sVarName, $this->CMSAPI_Env)) { return $this->CMSAPI_Env[$sVarName]; } elseif (!($sVarValue === Null)) { return $this->CMSAPI_Env[$sVarName] = $sVarValue; } return Null; } }