Location: PHPKode > projects > Phpman > phpman-2.0a_RC2/includes/frontend.html.php
<?php
/**
* Content functions HTML for phpman
* @package phpman
* @copyright (c) 2004 Samuel Suter
* @author Samuel Suter <hide@address.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @version 1.0
**/

/**
* Frontend HTML class for phpman
* Helps building the frontend index site
*/
class pmFrontendHTML {
	
	/**
	* Shows the titlepage
	* @param array $manual_data
	* @param array $authors
	* @return boolean always true
	*/
	function showTitlepage($manual_data,$authors) {
		global $lang;
		?>
		<div class="titleblock">
			<h1 class="title"><?=$manual_data["title"] ?></h1>
			<h1 class="subtitle"><?=$manual_data["subtitle"] ?></h1>
			<p>
				<h1 class="smalltitle"><?=$lang->published_by?></h1>
				<?php
				foreach($authors as $author) {
					?>
					<?=$author["name"]?> &lt;<?=$author["email"]?>&gt;<br>
					<?php
				}
				?>
			</p>
			
			<p><? echo $manual_data["pubdate"] ?></p>
			
			<p><i><? echo $manual_data["copyright"] ?></i></p>
		</div>
		<hr width="600" align="left">
		<?php
		return true;
	}
	
	/**
	* Show TOC
	* @param array $pages
	* @return boolean always true
	*/
	function showToc($pages) {
		global $lang;
		foreach($pages as $page) {
			$pixels = ($page["level"] - 2) * 50;
			$notes = getNumNotes($page["page_ID"]);
			?>
			<span class="toc" style="margin-left: <?=$pixels?>px"><?=$page["number"]?>
			
			<a href="?page_ID=<?=$page["page_ID"]?>&lang=<?=$_GET["lang"]?>" class="toc"><?=$page["title"]?></a>
			</span>
			<?php if($notes) { echo "(".$notes." ".$lang->notes.")"; }?><br>
			<?php
		}
		return true;
	}
	
	/**
	* Shows the navigation for prev and next page
	* @param array $prev
	* @param array $next
	* @return boolean always true
	*/
	function showPrevNext($prev = 0,$next = 0) {
		?>
		<table border="0" cellspacing="2" cellpadding="2" width="100%">
			<tr>
				<td style="background-color: #dddddd">
				<table border="0" cellspacing="2" cellpadding="2" width="100%">
					<tr>
						<td align="left">
						<?php if($prev) { ?>
						<b>&laquo;</b> <a href="?page_ID=<?=$prev["page_ID"] ?>&lang=<?=$_GET["lang"]?>"><?=$prev["title"] ?></a></td>
						<?php } ?>
						<?php if($next) { ?>
						<td align="right"><a href="?page_ID=<?=$next["page_ID"] ?>&lang=<?=$_GET["lang"]?>"><?=$next["title"] ?></a> <b>&raquo;</b></td>
						<?php } ?>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		<?php
		return true;
	}
	
	/**
	* prints the small toc on the left
	* @param array $pages
	* @return boolean always true
	*/
	function printSmalltoc($pages) {
		foreach($pages as $page) {
			$pixels = ($page["level"] - 2) * 30;
			$title = substr($page["title"],0,25);
			if(strlen($title) < strlen($page["title"])) {
				$title .= "...";
			} else {
				$title = $page["title"];
			}
			if($page["page_ID"] == $_GET["page_ID"]) {
				$style = "background-color: #cccccc;";
			} else {
				$style = "";
			}
			?>
			<tr>
				<td style="<?=$style?>"><span style="font-size: 70%"><?=$page["number"]?> </span><a href="?page_ID=<?=$page["page_ID"]?>&lang=<?=$_GET["lang"]?>" class="smalltoc" style="font-size: <?=$font_size?>"><?=$title?></a></td>
			</tr>
			<?php
		}
		return true;
	}
	
	/**
	* Display a page
	* @param array $page_data
	* @return boolean always true
	*/
	function displayPage($page_data,$children) {
		$size = $page_data["level"] - 1;
		?>
		<h<?=$size?>><?=$page_data["number"]?> <?=$page_data["title"]?></h<?=$size?>>
		<?php
		if(count($children) > 0) {
			?>
			<h1 class="smalltitle"><?=$lang->table_of_contents?></h1>
			<?php
			foreach($children as $child) {
				?>
				<span><a href="?page_ID=<?=$child["page_ID"]?>&lang=<?=$_GET["lang"]?>" class="bigtoc"><?=$child["title"]?></a></span><br>
				<?php
			}
			?>
			<br>
			<?php
		}
		//echo parse_page($page_data["content"]);
		echo $page_data["content"];
		$size = $children[0]["level"] - 1;
		?>
		<h<?=$size?>><?=$children[0]["number"]?> <?=$children[0]["title"]?></h<?=$size?>>
		<?php
		//echo parse_page($children[0]["content"]);
		echo $children[0]["content"];
		?>
		<br>
		<br>
		<?php
		return true;
	}
	
	/**
	* Print the notes of a page
	* @param array $notes
	* @param array $page_data
	* @return boolean always true
	*/
	function printNotes($notes,$page_data) {
		global $lang;
		?>
		<div id="usernotes">
			<div class="head">
				<small><?=$lang->notes?></small><br />
				<strong><?php echo $page_data["title"]; ?></strong>
			</div>
			<?php if (count($notes) < 1) { ?>
			<div class="note">
				<?=$lang->no_notes?>
			</div>
			<?php } else {
				foreach($notes as $note) { ?>
					<div class="note">
						<strong><?php echo $note["name"]; ?></strong><br />
						<?php echo date("d-M-Y H:i", $note["time"]); ?>
						
						<div class="text">
							<div class="phpcode">
								<code>
								<span class="html">
								<?php
								ob_start();
								highlight_string($note["content"]);
								$note = ob_get_contents();
								ob_end_clean();
								echo html_activate_urls($note); ?>
								</code>
								</span>
							</div>
						</div>
					</div>
				<?php }
			} ?>
		</div>
		<div id="usernotes">
			<!-- START add a note -->
			<form method="post" action="?manual_ID=<?=$_GET["manual_ID"]; ?>&page_ID=<?=$_GET["page_ID"]; ?>&lang=<?=$_GET["lang"]; ?>">
			<div class="note">
				<strong><?=$lang->add_note?></strong>
				<div class="text">
					<table border="0" cellspacing="2" cellpadding="2">
					<input type="hidden" name="data[time]" value="<?=time()?>">
					<input type="hidden" name="data[page_ID]" value="<?=$_GET["page_ID"]?>">
						<tr>
							<td valign="top"><b><?=$lang->name?>:</b></td>
							<td valign="top"><input type="text" name="data[name]" value="" size="45" /></td>
						</tr>
						<tr>
							<td valign="top"><b><?=$lang->note?>:</b></td>
							<td valign="top"><textarea name="data[content]" rows="8" cols="45"></textarea></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="submit" name="submit_note" value="<?=$lang->submit?>" /></td>
						</tr>
					
					</table>
				</div>
			</div>
			</form>
			<!-- END add a note -->
		</div>
		<?php
		return true;
	}
	
	function mainIndex($title = '',$manual_data = 0,$page_data = 0,$include_page = '') {
		global $database,$lang,$time_start;
		?>
		<html>
		<head>
			<title><?=$title?></title>
			<link rel="stylesheet" href="style.css" />
		</head>
		<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
		<table border="0" cellspacing="0" cellpadding="0" height="100%" width="100%">
			<tr>
				<td width="230" valign="top" class="toc_cell">
				<?php include("inc_smalltoc.php"); ?>
				</td>
				<td valign="top" class="manual_cell">
				<?php include($include_page); ?>
				</td>
			</tr>
			<tr>
				<td width="230" class="bottom_left_cell" height="50" align="right" valign="middle">
				<form method="POST" action="?page=search">
				Search: <input type="text" name="query_string" size="15" value="">
				<input type="hidden" name="boolean" value="AND">
				</form>
				</td>
				<td class="bottom_cell" height="50">
				<?php
				$time_end = getmicrotime();
				$time = round($time_end - $time_start,5);
				?>
				<small>created with phpman by Samuel Suter &lt;<a href="mailto:hide@address.com">hide@address.com</a>&gt; (<?=$time?> sec)</small>
				</td>
			</tr>
		</table>
		</body>
		</html>
		<?php
	}
	
	function searchResults($rows,$parents) {
		foreach($rows as $row) {
			?>
			<table border="0" cellspacing="2" cellpadding="2" width="100%">
			
			<tr>
			<td style="background-color: #bbbbbb" valign="top">
			<?php
			foreach($parents[$row["page_ID"]] AS $parent) {
				?>
				<a href="?page_ID=<?=$parent["page_ID"]?>&lang=<?=$parent["isocode"]?>"><small><?=$parent["title"]?></small></a> / 
				<?php
			}
			?>
			<a href="?page_ID=<?=$row["page_ID"]?>&lang=<?=$row["isocode"]?>"><?=$row["title"]?></a>
			</td>
			</tr>
			
			<tr>
			<td style="background-color: #eeeeee" valign="top">
			<?=$row["content"]?>
			</td>
			</tr>
			
			<tr>
			<td height=\"10\"></td>
			</tr>
		
			</table>
			<?php
		}
	}
};
?>
Return current item: Phpman