Location: PHPKode > projects > JaxBlog > JaxBlog/app/common/builder-install.php
<?php

// config.php MUST have already been brought in 
// via require_once() prior to calling this script.

require_once('refolder.php');

function buildInstallPage($header, $onload, $title, $content, $navbar_success_level) {
	
	$html = templateRefolderCSSAndJavascript(FILE_TEMPLATE_INSTALL);
	
	$html = str_replace('[Header]', $header, $html);
	$html = str_replace('[Onload]', $onload, $html);
	$html = str_replace('[Title]', $title, $html);
	$html = str_replace('[Content]', $content, $html);
	$html = str_replace('[Navbar]', buildInstallNavbar($title, $navbar_success_level), $html);
	
	return $html;
}


function buildInstallNavbar($calling_page_name, $success_level) {

	$current = array(
		0=>"<div class=\"navbar_current_div\">Welcome</div>"
		,1=>"<div class=\"navbar_current_div\">Filesystem</div>"
		,2=>"<div class=\"navbar_current_div\">Database</div>"
		,3=>"<div class=\"navbar_current_div\">Success</div>"
	);
	
	$links = array(
		0=>"<div class=\"navbar_div\"><a class=\"navbar_link\" href=\"../install_welcome/install_welcome.php\">Welcome</a></div>"
		,1=>"<div class=\"navbar_div\"><a class=\"navbar_link\" href=\"../install_filesystem/install_filesystem.php\">Filesystem</a></div>"
		,2=>"<div class=\"navbar_div\"><a class=\"navbar_link\" href=\"../install_database/install_database.php\">Database</a></div>"
		,3=>"<div class=\"navbar_div\"><a class=\"navbar_link\" href=\"../install_success/install_success.php\">Success</a></div>"
	);
	
	$index = 0;
	if ($calling_page_name == "Welcome") $index = 0;
	if ($calling_page_name == "Filesystem") $index = 1;
	if ($calling_page_name == "Database") $index = 2;
	if ($calling_page_name == "Success") $index = 3;
	
	// only display as many navbar links as the current success level allows for.
	$max = count($current);
	if ($max > $success_level) $max = $success_level;
	
	$html = '';
	for ($i = 0; $i < $max; $i++) {
		if ($i == $index) {
			$html .= $current[$i] . "\n";
		} else {
			$html .= $links[$i] . "\n";
		}
	}
	
	return $html;

}

function writeFile($path, $contents) {
	try {
		if (!is_writable($path)) return false;
		$file = fopen($path, 'w') or die("can't open file");
		fwrite($file, $contents);
		fclose($file);
		return true;
	} catch (Exception $e) {
		return false;
	}
}

function deleteFile($path) {
	try {
		if (!is_writable($path)) return false;
		unlink($path);
		return true;
	} catch (Exception $e) {
		return false;
	}
}
?>
Return current item: JaxBlog