<?php
// (c) 2014 Trinity Desktop Project
// All Rights Reserved
// Authors: Elizabeth Liddell, Timothy Pearson, and Calvin Morrison

include("globals.php");
include("tde-head-and-foot.php");
doHeader("Trinity Desktop Environment", "Home", "_");

include ("media/news-javascript.php");

// Override for main page
$newscollapsedlines = 10000;
?>

<P><H2>Efficient. Productive.</H2>
The Trinity Desktop Environment (TDE) project is a computer desktop environment for Unix-like operating systems
with a primary goal of retaining the function and form of traditional desktop computers.
<P CLASS="spacer">
<P><SPAN CLASS="snapwrapper">
    <A HREF="media/screenshots/large/tde6.png"><IMG ALT="Introductory Screenshot" SRC="media/screenshots/large/tde6_mainpage.png" CLASS="snap" ID="introsnap"></A>
</SPAN>
<P STYLE="text-align:center"><A HREF="screenshots.php">More Screenshots</A>
<P CLASS="spacer">
<a href="rss.php" title="Website RSS"><img alt="RSS Feed" src="media/tde-rss.png" id="rssicon" /></a>
<a href="https://floss.social/@tde" rel="me" title="Mastodon channel"><img alt="Mastodon channel" src="media/mastodon-icon.png" id="rssicon" /></a>
<h2>Latest News</h2>
<?php
if ($handle = opendir('./news/')) {
	$filenames = array();
	while ($file = readdir($handle)) {
		$filenames[] = $file;
	}
	rsort($filenames);

	$file=$filenames[0];
	if ($file != "." && $file != "..") {
		echo "<h3>$file: ";

		$data = file_get_contents("news/$file"); //read the file
		$data = str_replace("http://", "https://", $data); //force https images and links
		$convert = explode("\n", $data); //create array separate by new line
		for ($i=0;$i<count($convert);$i++) {
				echo $convert[$i]. '<br>'; //write value by index
				if ($i == 0) {
					echo "</h3>";
				}
				if ($i == $newscollapsedlines) {
					echo '<div id="hiddennews-' . $file . '" style="display: none">';
				}
		}
		if (count($convert) > $newscollapsedlines) {
			echo '</div>';
			echo '<noscript><div class="floatleft"><a href=\'/newsentry.php?entry=' . $file . '\'>Read entire entry on separate page</a><BR>Javascript is not available or turned off</div></noscript>';
			echo '<div class="floatleft"><a id="hiddennews-toggler-' . $file . '" href="javascript:toggle(\'hiddennews-' . $file . '\',\'hiddennews-toggler-' . $file . '\');" >show all text of this entry</a></div>';
			echo '<div class="floatright"><a href=\'/newsentry.php?entry=' . $file . '\'>permalink</a></div>';
			echo '<div style="clear: both;"></div>';
		}
		else {
			echo '<div class="floatright"><a href=\'/newsentry.php?entry=' . $file . '\'>permalink</a></div>';
			echo '<div style="clear: both;"></div>';
		}
	}
	echo "<div class=\"clearall\"></div><br><br>";
	echo "<p class=\"spacer\">";
	echo '<div class="floatright"><div class="plain"> <a href="news.php">click here for older news</a> </div></div>';
	closedir($handle);
}
?>

<?php
	doFooter();
?>
