index.php 6.25 KB
<!DOCTYPE html>
<html lang="en">

<?php $db = new SQLite3('wiki.db'); ?>
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Slimspots Wiki</title>

    <!-- Bootstrap Core CSS -->
    <link href="static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    
	<!-- Custom CSS -->
	<link href="static/css/slimspots-wiki.css" rel="stylesheet">
	<link href="static/css/styles.css" rel="stylesheet">
	<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

	<!-- FontAwesome -->
	<link rel="stylesheet" href="static/font-awesome/css/font-awesome.min.css">
	
	<script src="static/bootstrap/js/jquery-1.11.0.js"></script>
	

	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div  id="wrapper">
		<!----------------------------------------------------- Sidebar ---------------------------------------------------->
        <div id="sidebar-wrapper">
            <ul class="sidebar-nav">
                <li class="sidebar-brand">
                    <a href="#">
                       <img src="static/gfx/logo.svg" class="img-responsive"/>
                    </a>
                </li>
                
				<?php
               
	
				$page = $db->query("SELECT * FROM page");
                $num_pages = count($page);
				
				for ($i=0;$i<$num_pages;$i++)
	            {

					while ($row = $page->fetchArray()) 
					{
		                
						echo "<li class='has-sub'><a href='#'>".$row[1]."<i class='fa fa-chevron-right fa pull-right chevron-margin' id='valign-icon'></i></a>";
		                echo "<ul>";
		                
		                $sections = $db->query("SELECT * FROM section WHERE page_id = $row[0]"); //$row[0]:  page -> id
		                
		                for ($j=0; $j<count($sections); $j++)
						{
								while ($row1 = $sections->fetchArray())
								{
								echo "<li><a href='?".$row[0]."#".$row1[0]."' class='sub-text-padding'>".$row1[2]."</a></li>";
								}
						}
						
						echo "</ul></li>";
	                }
				}
                	
                ?> 
                              
                
            </ul>
        </div>
        <!-- /#sidebar-wrapper -->

		<!---------------------------------------------------------------------------------------------------------------->
        		
		<div class="container-fluid" id="menu-tray">
			<div class="col-xs-6">
				<a href="#menu-toggle" id="menu-toggle"><i class="fa fa-bars fa-2x icon pull-left"></i></a>
			</div>
			<div class="col-xs-6" id="search-container">
				<form name="#" method="#" action="#" class="form-search">
					<input type="text" class="pull-right" name="#"  id="search-rounded" placeholder="Suche">
				</form>
			</div>
		</div>
		
		<div id="page-content-wrapper">
			<div class="pull-right">	
				<!-- In this table we display the date and time (desktop devices only) -->
				<table id="datetime">
					<tr>
						<td id="date-container">
                      		<span id="day"></span>
					  		  <br>
					  		  <span id="datetime-number">&nbsp;<span id="datum">&nbsp;</span>&nbsp;</span><span id="month">&nbsp;</span>&nbsp;
					  	</td>
					  	<td id="time-container">
							<span id="hour">&nbsp;</span>&nbsp;:&nbsp;<span id="minute">&nbsp;</span>
						</td>
					</tr>
				</table>
			</div>
			
<!-------------------------------------------------------------------->				
			
			<?php
				
			$url=$_SERVER['REQUEST_URI'];
			
			if (strpos($url, '?') === false)
			{
				$current_page=1;
			}
			
			else
			{
				$current_page = explode ('?', $url);
				$current_page=$current_page[1];
			}

			$query = $db->query("SELECT * FROM page WHERE id = $current_page");
			while ($row = $query->fetchArray())
			{
			$page_title = $row[1];
			?>
			
			<div id="container2">
				<h1 id="container2-header">Slimspots Wiki</h1>
			</div>
			
			<article>
				<h2><?php echo $row[1]; ?></h2><hr>
				<p><?php echo $row[2]; ?></p>  
				<div class="all-chapters">
				<?php 
					
					
					$section = $db->query("SELECT * FROM section WHERE page_id = $current_page");
					for ($i=0; $i<count($section); $i++)
					{
						
						
						while ($row1 = $section->fetchArray())
						{
						
							$section_id = $row1[0];
							$section_title = $row1[2];
							$section_text = $row1[3];
							$section_subsections = $row1[4];
							
							echo "<h3 id='".$section_id."'>".$section_id.". ".$section_title."</h3><hr>";
							echo "<p class='margin-bottom-50px'>".$section_text."</p>";
						
							$subsection = $db->query("SELECT * FROM subsection WHERE page_id = $row[0] AND section_id = $row1[0]");
						
							while ($row2 = $subsection->fetchArray())
							{
								$subsection_id = $row2[0];
								$subsection_title = $row2[3];
								$subsection_text = $row2[4];
								
								echo "<h3 id='".$section_id.".".$subsection_id."'>&nbsp;&nbsp;".$section_id.".".$subsection_id.". ".$subsection_title."</h3><hr>";
								echo "<p class='margin-bottom-50px'>".$subsection_text."</p>";
							}
						}
					}
				}
				?>
				</div>
			</article>
		</div>
		<!-- /#page-content-wrapper -->
	</div>
	<!-- /#wrapper -->
	
	<!-- Bootstrap Core JavaScript -->
	<script src="static/bootstrap/js/bootstrap.min.js"></script>
	
	<!-- Update time JavaScript -->
	<script src="static/js/main.js"></script>
	<script src="static/js/updatetime.js"></script>

	<script>
			var ToC =
		"<nav role='navigation' class='table-of-contents'>" +
		"<b><?php echo $page_title; ?></b>" +
		"<ul>";

		var newLine, el, title, link;

		$("article h3").each(function() {
			el = $(this);
			title = el.text();
			link = "#" + el.attr("id");
			newLine =
			"<li>" +
			"<a href='" + link + "'>" +
			title +
			"</a>" +
			"</li>";

			ToC += newLine;
		});
		
		ToC +=
		"</ul>" +
		"</nav>";
		
		

		$(".all-chapters").prepend(ToC);
		</script>

	
	
</body>
</html>