<?php

    
require("functions.php");

    
$res XMLtoArray(file_get_contents("snippets.xml")) or die("Unable to read the snippets xml file.");

?>
<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <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="JaviteSoft - Open source and code examples">
    <meta name="author" content="JaviteSoft">

    <title>JaviteSoft - Snippets</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <link href="css/global.css" rel="stylesheet">
    <link rel="icon" href="favicon.ico">
    <link rel="apple-touch-icon" href="apple-touch-icon.png"/>
    <link rel="apple-touch-icon-precomposed" href="apple-touch-icon.png"/>
  </head>

  <body>

    <a name="top"></a>
    <div class="main-masthead fixed-nav-bar">
      <div class="container">
        <nav class="main-nav">
          <a class="main-nav-item" href="index.php">Home</a>
          <a class="main-nav-item" href="projects.php" title="View the projects in development">Projects</a>
          <a class="main-nav-item active" href="snippets.php" title="View the code snippets library">Snippets</a>
          <a class="main-nav-item" href="depends.php" title="Download any dependencies required">Dependencies</a>
          <a class="main-nav-item" href="contact.php" title="Contact JaviteSoft">Contact</a>
          <a class="main-nav-item" href="about.php" title="About JaviteSoft">About</a>
        </nav>
      </div>
    </div>

    <div class="container">

      <div class="main-header">
        <h1 class="main-title">Code snippets</h1>
        <p class="lead main-description">Find all our code examples below in the Snippets Library.</p>
      </div>

      <div class="row">

        <div class="col-sm-8 main-main">

<?php

    $links 
"";

    for (
$i 0$i count($res['SNIPPETS']['SNIPPET']); $i++)
    {
        
$item $res['SNIPPETS']['SNIPPET'][$i];
        
$code htmlspecialchars($item[CODE]);

        print <<<END_OF_HTML

          <div class="main-post"><a name="
$item[ID]"></a>
            <h2 class="main-post-title">
$item[TITLE]</h2>
            <p class="main-post-meta">
$item[CREATED] by <a href="contact.php">Java</a></p>

            <hr>
<pre><code>
$code</code></pre>

            <p>
              <a href="#top">Back to top</a>
            </p>

          </div><!-- /.main-post -->

END_OF_HTML;

        
$links .= "<li><hr></li><li><a href=\"#$item[ID]\">$item[TITLE]</a></li>";
    }

?>
        </div><!-- /.main-main -->

        <div class="col-sm-3 col-sm-offset-1 main-sidebar">
          <div class="sidebar-module">
            <h4>Snippets Library</h4>
            <ol class="list-unstyled">
              <?php echo $links?>
            </ol>
          </div>
        </div><!-- /.main-sidebar -->

      </div><!-- /.row -->

    </div><!-- /.container -->

    <footer class="main-footer">
      <p>Copyright &copy; 2015 JaviteSoft. All Rights Reserved.</p>
      <p>
        <a href="#top">Back to top</a>
      </p>
      <p>
        <a href="snippets.phps"><small>View page source</small></a>
      </p>
    </footer>


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="js/ie10-viewport-bug-workaround.js"></script>
    <!-- Fix for local page links -->
    <script src="js/fix_anchors.js"></script>
  
</body>
</html>