<?php

    
require("functions.php");

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

    
$id $_SERVER['QUERY_STRING'];
    
$item null;

    if (!empty(
$id))
    {
        for (
$i 0$i count($res['PROJECTS']['PROJECT']); $i++)
        {
            
$thisitem $res['PROJECTS']['PROJECT'][$i];

            if (
$thisitem['ID'] == $id)
            {
                
$item $thisitem;
                break;
            }
        }
    }

?>
<!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 - Projects<?php if ($item != null) { echo " - $item[TITLE]"; } ?></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 active" href="projects.php" title="View the projects in development">Projects</a>
          <a class="main-nav-item" 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">Projects</h1>
        <p class="lead main-description">Find all our projects in development below.
          <br>All source code is GNU General Public License (GPL)</p>
      </div>

      <div class="row">

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

<?php

    
if (empty($id))
    {
        
$links "";

        for (
$i 0$i count($res['PROJECTS']['PROJECT']); $i++)
        {
            
$item $res['PROJECTS']['PROJECT'][$i];

            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>
            <p>
$item[DESC]</p>
            <p><a href="projects.php?
$item[ID]">Visit project page</a></p>
            <hr>
          </div><!-- /.main-post -->

END_OF_HTML;

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

        print <<<END_OF_HTML

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

        <div class="col-sm-3 col-sm-offset-1 main-sidebar">

          <div class="sidebar-module">
            <h4>Projects Library</h4>
            <ol class="list-unstyled">
              
$links
            </ol>
          </div>

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

END_OF_HTML;

    }
    else
    {
        if (
$item != null)
        {
            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>
            <p>
$item[DESC]</p>
            <p><br></p>
            <div style="border-bottom: 1px solid black; clear: both;">Specifications</div><br>
            <ul>
              <li>Development Status: 
$item[DEVSTATUS]</li>
              <li>Environment: 
$item[ENVIRONMENT]</li>
              <li>OS: 
$item[OS]</li>
              <li>Target Audience: 
$item[AUDIENCE]</li>
              <li>Programming Language: 
$item[LANGUAGE]</li>
              <li>Topic: 
$item[TOPIC]</li>
            </ul>
            <p><br></p>
            <div style="border-bottom: 1px solid black; clear: both;">Screenshots</div><br>
            <ul><img src="images/screenshots/
$item[ID].png" alt="$item[ID].png" /></ul>
            <p><br></p>
            <div style="border-bottom: 1px solid black; clear: both;">Project files</div><br>
            <ul><a href="browse.php?id=
$item[ID]">Browse project source code</a></ul>
            <hr>
            <p><a href="projects.php">Back to Projects page</a></p>

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

        <div class="col-sm-3 col-sm-offset-1 main-sidebar">

          <div class="sidebar-module">
            <h4>Downloads</h4>
            <ol class="list-unstyled">
              <li><hr></li>
              <li style="border-bottom: 1px solid black;">Binaries</li>

END_OF_HTML;

            foreach (
$item['BINARIES'] as $key1 => $val1)
            {
                foreach (
$val1['FILE'] as $key2 => $val2)
                {
                    
$file $val2;

                    print <<<END_OF_HTML

              <li><br><ul><li><h4>
$file[VERSION]</h4><small>$file[RELEASED]</small><br><a href="$file[URL]">$file[NAME]</a></li></ul></li>
              <li><hr></li>

END_OF_HTML;
                }
                break;
            }

            print <<<END_OF_HTML

              <li style="border-bottom: 1px solid black;">Sources</li>

END_OF_HTML;

            
$is_first true;

            foreach (
$item['SOURCES'] as $key1 => $val1)
            {
                foreach (
$val1['FILE'] as $key2 => $val2)
                {
                    
$file $val2;
                    
$browse "";

                    if (
$is_first)
                    {
                        
$is_first false;
                        
$browse " <small>(<a href=\"browse.php?id=$item[ID]\"><small>browse source code</small></a>)</small>";
                    }

                    print <<<END_OF_HTML

              <li><br><ul><li><h4>
$file[VERSION]$browse</h4><small>$file[RELEASED]</small><br><a href="$file[URL]">$file[NAME]</a></li></ul></li>
              <li><hr></li>

END_OF_HTML;
                }
                break;
            }

            print <<<END_OF_HTML

            </ol>
          </div>

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

END_OF_HTML;

        }
        else
        {
            print <<<END_OF_HTML

          <div class="main-post">
            <h2 class="main-post-title">Project not found</h2>
            <p>The project you are looking for is no longer available.</p>
            <hr>
            <p><a href="projects.php">Back to Projects page</a></p>

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

END_OF_HTML;

        }
    }

?>
      </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="projects.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>