<?PHP

#############################################################################
#           			                   Site@School
# Site@School is a website management system designed for primary schools.
#
# About Site@School:
# Comissioned by: City District 'de Baarsjes', Amsterdam, Netherlands
# Original idea, coding (version 1.0) and design : Mark de Haan (mark@starwave.nl)
# Ideas, improvements, expansions (version 1.1, 1.2, 2.0, 2.1): Fred Stuurman 
# Current coder & maintainer: Fred Stuurman (fc.stuurman@hccnet.nl)
############################################################################
# studenteditor.php: last changed 13/01/2004 2.1                                       
#                 by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: studenteditor.php,v 1.1 2006/10/03 12:27:14 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
# Copyright (C) 2002, 2003, 2004 Municipality of Amsterdam, City District
#  'de Baarsjes', Amsterdam, the Netherlands.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
##############################################################################
$template_path = $serverpath . "/media/templates";

print "<script type=\"text/javascript\" src=\"" . $cmsdir . "/editors/htmlarea/htmlarea2.js\"></script>";
$language_file = $cmsdir . "/editors/htmlarea/htmlarea-lang-" . $language . ".js";

if (!file_exists($language_file))
{
	print "<script type=\"text/javascript\" src=\"" . $cmsdir . "/editors/htmlarea/htmlarea-lang-EN.js\"></script>";
}
else
{
	print "<script type=\"text/javascript\" src=\"" . $language_file . "\"></script>";
}

if (IsSet ($_GET['template']))
{
	$filename = $template_path . "/" . $_GET['template'];
	if (file_exists($filename))
	{
		$handle = fopen($filename, "r");
		$content = fread($handle, filesize($filename));
		fclose($handle);
	}
}

print "<script type=\"text/javascript\" src=\"" . $cmsdir . "/editors/htmlarea/dialog.js\"></script>
       <script type=\"text/javascript\" src=\"" . $cmsdir . "/editors/htmlarea/popupwin2.js\"></script>";
print "<!-- load the TableOperations plugin files -->
       <script type=\"text/javascript\" src=\"" . $cmsdir . "/editors/htmlarea/plugins/TableOperations/table-operations.js\"></script>";
$language_file = $cmsdir . "/editors/htmlarea/plugins/TableOperations/table-operations-lang-" . $language . ".js";
if (!file_exists($language_file))
{
	print "<script type=\"text/javascript\" src=\"" . $cmsdir . "/editors/htmlarea/plugins/TableOperations/table-operations-lang-EN.js\"></script>";
}
else
{
	print "<script type=\"text/javascript\" src=\"" . $language_file . "\"></script>";
}
?>
<style type="text/css">
.htmlarea { background: #fff; }

.htmlarea .toolbar { 
  background: ButtonFace; 
  padding: 1px; 
  border: 1px solid;
  border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
}
.htmlarea .toolbar img { border: none; }

.htmlarea .toolbar .button {
  background: ButtonFace;
  color: ButtonFace;
  border: 1px solid ButtonFace;
  padding: 1px;
  margin: 0px;
}
.htmlarea .toolbar .buttonHover {
  border: 1px solid;
  border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
}
.htmlarea .toolbar .buttonActive, .htmlarea .toolbar .buttonPressed {
  padding: 2px 0px 0px 2px;
  border: 1px solid;
  border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}
.htmlarea .toolbar .buttonPressed {
  background: ButtonHighlight;
}
.htmlarea .toolbar .indicator {
  padding: 0px 3px;
  overflow: hidden;
  width: 20px;
  text-align: center;
  cursor: default;
  border: 1px solid ButtonShadow;
}

.htmlarea .toolbar .buttonDisabled img {
  filter: alpha(opacity = 25);
  -moz-opacity: 25%;
}

.htmlarea .toolbar .separator {
  position: relative;
  margin: 3px;
  border-left: 1px solid ButtonShadow;
  border-right: 1px solid ButtonHighlight;
  width: 0px;
  height: 16px;
  padding: 0px;
}

.htmlarea .toolbar .space { width: 5px; }

.htmlarea .toolbar select { font: 11px Tahoma,Verdana,sans-serif; }

select, select:hover, select:active { background: FieldFace; color: ButtonText; }

BODY {
	FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
TD {
	FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
TH {
	FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
UL {
	FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
P {
	FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
.tdnormal {
	FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
.tdhighlight {
	FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
.boldlist {
	FONT-WEIGHT: bold; FONT-SIZE: 10pt
}
.header {
	FONT-WEIGHT: bold; FONT-SIZE: 12pt
}
.inputbg {
	FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
.submit {
	FONT-SIZE: 10pt; FONT-FAMILY: verdana,sans-serif
}
</style>
<script type="text/javascript">
var editor = null;
function initEditor() 
{
  editor = new HTMLArea("content");
  // register the TableOperations plugin with our editor
  editor.registerPlugin("TableOperations");
  editor.generate();
}
function insertHTML() 
{
  var html = prompt("Enter some HTML code here");
  if (html) 
  {
    editor.insertHTML(html);
  }
}
function highlight() 
{
  editor.surroundHTML('<span style="background:yellow">', '</span>');
}

var userid = "<?PHP echo $userid ?>" ;

</script>

</head>

<body onload="initEditor()">
<?PHP

print "<FORM METHOD=\"POST\" NAME=\"form\" ACTION=\"index.php?section=$section&page=$page&savepage=$editpage\">";
?>
<TABLE class="ToolBar" id="idToolbar" cellSpacing="0" cellPadding="0"  width="100%" border="1">
<TBODY>
<TR style="background:ButtonFace">
<TD colSpan=18 height="28" valign="bottom">
<?PHP

print "<span class=text>&nbsp;" . $sas_lang['title'] . ":&nbsp;</span>
      <input type=\"text\" name=\"title\" size=\"40\" value=\"$title\">
	  <span class=text>&nbsp;" . $sas_lang['order'] . ":&nbsp;</span>
      <input type=\"text\" name=\"order\" size=\"4\" value=\"$order\">
      <input type=\"hidden\" name=\"approved\" value=\"$approved\">";

if (is_dir($template_path))
{
	print "&nbsp;&nbsp;Sjabloon:&nbsp;&nbsp;<select size=\"1\" name=\"template\" 
		onchange=\"parent.location.href='index.php?page=$page&section=$section&option=editpage&editpage=$editpage&template=' + this.options[this.selectedIndex].value\">>\n";
	$dir_handle = @ opendir($template_path);
	echo "<option value=\"Kies er een\">Kies er een</option>";
	while ($file = readdir($dir_handle))
	{
		if ($file != ".." AND $file != "." AND $file != "/")
		{
			echo "<option value=\"$file\">$file</option>";
		}

	}
	closedir($dir_handle);
	print "</select>";
}
print "<tr><td><textarea id=\"content\" name=\"newcontent\" style=\"width:100%\" rows=\"35\">";

print "$content</textarea><td></tr></table>";

print "<table width=\"100%\"><tr>";

if ($invisible == 1)
{
	print "<td align=\"rigth\"><input type=\"checkbox\" name=\"invisible\" value=\"1\" checked>" . $sas_lang['invisible'] . "</td>";
}
else
{
	print "<td align=\"rigth\"><input type=\"checkbox\" name=\"invisible\" value=\"1\">" . $sas_lang['invisible'] . "</td>";
}

if ($_SESSION['usertype'] == "teacher")
{
	print "<td>" . $sas_lang['page_on'] . " &nbsp;&nbsp;&nbsp;" . $sas_lang['teacher_pages'] . "</td>";
	if ($pcheck == "1")
	{
		print "<td><input type=\"radio\" value=\"1\" name=\"check\" checked></td>";
		print "<td>&nbsp;&nbsp;&nbsp;" . $sas_lang['student_pages'] . "</td>";
		print "<td><input type=\"radio\" name=\"check\" value=\"0\"></td>";
		print "<td>&nbsp;&nbsp;&nbsp;" . $sas_lang['both'] . "</td>";
		print "<td><input type=\"radio\" name=\"check\" value=\"2\"></td>";
	}
	elseif ($pcheck == "0")
	{
		print "<td><input type=\"radio\" value=\"1\" name=\"check\"></td>";
		print "<td>&nbsp;&nbsp;&nbsp;" . $sas_lang['student_pages'] . "</td>";
		print "<td><input type=\"radio\" name=\"check\" value=\"0\" checked></td>";
		print "<td>&nbsp;&nbsp;&nbsp;" . $sas_lang['both'] . "</td>";
		print "<td><input type=\"radio\" name=\"check\" value=\"2\"></td>";
	}
	else
	{
		print "<td><input type=\"radio\" value=\"1\" name=\"check\"></td>";
		print "<td>&nbsp;&nbsp;&nbsp;" . $sas_lang['student_pages'] . "</td>";
		print "<td><input type=\"radio\" name=\"check\" value=\"0\"></td>";
		print "<td>&nbsp;&nbsp;&nbsp;" . $sas_lang['both'] . "</td>";
		print "<td><input type=\"radio\" name=\"check\" value=\"2\"  checked></td>";
	}

}
print "</tr></table>";

print "<br><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['cancel'] . "\" name=\"backbutton\" 
		onClick=\"javascript:parent.location='index.php?section=$section&page=$page&release=$editpage';\" class=\"backbutton\">";
print "&nbsp;<input type=\"submit\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['save'] . "\" name=\"savebutton\" class=\"savebutton\"><br><br></form>";
?>