<?php
/**
 * la.plume Micro CMS
 * ==================
 * COPYRIGHT Patrick Taylor http://www.mini-print.com/
 */

class Page {

	var $source;
	var $Textfilename;

	function Template() {
		$source = "$this->Textfilename";
		$text = file($source) or die("Cannot read file.");
		$banner = trim(array_shift($text));

		$banner = str_replace("%", "", $banner);

		if (strstr($banner, "#")) {
			$showbanner = FALSE;
		} else {
			$showbanner = TRUE;
		}

		if (strstr($banner, "~")) {
			$pword_form = TRUE;
		} else {
			$pword_form = FALSE;
		}

		$title = trim(array_shift($text));

		if (strlen($title) < 1) {
			$title = "Untitled";
		}

		$text = trim(join('', $text));
		require ('settings.php');
		require ('functions.php');
		$content = autop($text);
		$content = convert_chars($content);
		$content = utf8_it($content);
		$content = img_path($content);
		require ('top.php');
		echo "\r\n<div id=\"wrap\">\r\n";
		echo "	<div id=\"content\">\r\n";

		if ($showbanner) {
			echo "\r\n";
			echo '<p id="banner">' . $banner . '</p>';
			echo "\r\n";
		}

		echo "\r\n<h1>$title</h1>\r\n";

		if ($pword_form) {
			require ('pword-form.php');
		}

		if (strlen($content) > 0) {
			echo "\r\n$content";
		} else {
			echo "\r\n<p>No content.</p>\r\n";
		}

		if (file_exists('inc/social.php')) {
			require ('social.php');
		}

		if (COMMENTS) {
			if (!$pword_form || ($pword_form && $show_comments)) {
				if ($source != 'index.txt') {
					require ('comments.php');
					require ('comment-form.php');
				}
			}
		}

		echo "\r\n\r\n	</div>\r\n";
		require ('menu.php');
		if (file_exists('inc/extra.php')) {
			require ('extra.php');
		}
		require ('footer.php');
		if (file_exists('inc/tracking.php')) {
			require ('tracking.php');
		}
		echo "\r\n</div>\r\n\r\n</body>\r\n</html>";
	}

	function SetContent($Data) {
		$this->Content = $Data;
	}
}

?>