<?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 - 2.3): Fred Stuurman 
# Current coder & maintainer: Fred Stuurman (fc.stuurman@hccnet.nl)
############################################################################
# edit_content.php: last changed 08/06/2006  , version: 2.4
#                  by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: edit_content2.php,v 1.1 2006/10/03 09:38:29 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.
##############################################################################
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}
print "<script type=\"text/javascript\" src=\"editors/htmlarea/htmlarea.js\"></script>";
print "<script type=\"text/javascript\" src=\"editors/htmlarea/dialog.js\"></script>
       <script type=\"text/javascript\" src=\"editors/htmlarea/popupwin.js\"></script>";
print "<!-- load the TableOperations plugin files -->
       <script type=\"text/javascript\" src=\"editors/htmlarea/plugins/TableOperations/table-operations.js\"></script>";
$language_file = "editors/htmlarea/htmlarea-lang-" . $language . ".js";
if (!file_exists($language_file))
{
	print "<script type=\"text/javascript\" src=\"editors/htmlarea/htmlarea-lang-EN.js\"></script>";
}
else
{
	print "<script type=\"text/javascript\" src=\"" . $language_file . "\"></script>";
}
$language_file = "editors/htmlarea/plugins/TableOperations/table-operations-lang-" . $language . ".js";
if (!file_exists($language_file))
{
	print "<script type=\"text/javascript\" src=\"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 { background-color: #aaa; }

.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; }

</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();
}
</script>

<body onload="initEditor()">

<?php

include ("interface/header.inc.php");
include ("interface/menubar.inc.php");
include ("interface/menustart.inc.php");
print "<span class=heading>" . $sas_lang['filemanager_menu'] . "</span><p>";
print "<span class=link>
  <a href=index.php?option=modulemanager&module=$module&modoption=news>" . $sas_lang['news_module_headlines'] . "</a><p>
  <a href=index.php?option=modulemanager&module=$module&modoption=archive>" . $sas_lang['news_module_archive'] . "</a><p>
  <a href=index.php?option=modulemanager&module=$module&modoption=configuration>" . $sas_lang['configuration'] . "</a><p></span>";
include ("interface/menuend.inc.php");
include ("interface/pagestart.inc.php");
$template_path = $sas_config['serverpath'] . $sas_config['user_path'] . "/" . $media . "/templates";

print "<span class=\"heading\">$modulename</span><br><br>";
if (IsSet ($addarticle))
{
	print "<span class=\"heading\">" . $sas_lang['news_module_addarticle'] . "<br></span>";
}
else
{
	print "<span class=\"heading\">" . $sas_lang['news_module_editarticle'] . "<br></span>";
}
?>
<style type="text/css">
SELECT { background-color: #FFFFFF; }
</style>
<FORM METHOD="POST" ACTION="index.php?option=modulemanager&module=<?php echo $module?>&modoption=<?php echo $modoption ?>&savearticle=<?php echo $editarticle ?>">
<TABLE class="ToolBar" id="idToolbar" cellSpacing="0" cellPadding="0"  width="800" border="1">
<TBODY>
<TR style="background:ButtonFace">
<TD colSpan=18 height="28" valign="bottom">
<?php

if (IsSet ($_GET['template']))
{
	$filename = $template_path . "/" . $_GET['template'];
	if (file_exists($filename))
	{
		$handle = fopen($filename, "r");
		$article_content = fread($handle, filesize($filename));
		fclose($handle);
	}
}
print "<span class=text>&nbsp;" . $sas_lang['title'] . ":&nbsp;</span><input type=\"text\" name=\"article_title\" size=\"30\" value=\"$article_title\">
       <span class=text>&nbsp;" . $sas_lang['date'] . ":&nbsp;</span><input type=\"text\" name=\"article_date\" size=\"20\" value=\"$article_date\">&nbsp;";
print "<span class=text>" . $sas_lang['category'] . ": </span><select size=\"1\" class=text name=\"article_category\">";
$query = "SELECT id,title FROM $news_categorytable";
$result = mysql_query($query);
while ($category_list = mysql_fetch_array($result))
{
	if ($category_list[0] == $article_category)
	{
		print "<option selected value=\"$category_list[0]\">$category_list[1]</option>\n";
	}
	else
	{
		print "<option value=\"$category_list[0]\">$category_list[1]</option>\n";
	}
}
print "</select>";
if (is_dir($template_path))
{
	if (IsSet ($editarticle))
	{
		$option = "editarticle=$editarticle";
	}
	if (IsSet ($addarticle))
	{
		$option = "addarticle=1";
	}
	print "<br><span class=text>&nbsp;" . $sas_lang['template'] . ":&nbsp;&nbsp;</span><select class=text size=\"1\" name=\"template\" 
		onchange=\"parent.location.href='index.php?option=modulemanager&module=$module&modoption=$modoption&$option&template=' + this.options[this.selectedIndex].value\">>\n";
	$dir_handle = @ opendir($template_path);
	print "<option value=\"Kies er een\">" . $sas_lang['choose_one'] . "</option>";
	while ($file = readdir($dir_handle))
	{
		//if($file != ".." AND $file != "." AND $file != "/")
		if ((eregi('.html', $file)) OR (eregi('.htm', $file)))
		{
			echo "<option value=\"$file\">$file</option>";
		}

	}
	closedir($dir_handle);
	print "</select></td>";
}
print "</TR>
  <TR vAlign=center><td>";
if ($highvisibility == "1")
{
	print "<textarea id=\"content\" name=\"article_content\" style=\"width:700\" rows=\"" . $sas_config['htmlarea_editor_rows'] . "\">";
}
else
{
	print "<textarea id=\"content\" name=\"article_content\" style=\"width:825\" rows=\"" . $sas_config['htmlarea_editor_rows'] . "\">";
}
print "$article_content";
?>
</textarea></td><tr></table>

<?php

print "<span class=text>" . $sas_lang['public_area'] . ":</span><input type=\"radio\" value=\"0\" name=\"article_archive\"";
if (($article_archive == 0) AND ($article_public == 0))
{
	print " checked";
}
print ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
print "<span class=text>" . $sas_lang['protected_area'] . ":</span><input type=\"radio\" value=\"3\" name=\"article_archive\"";
if (($article_archive == 0) AND ($article_public == 1))
{
	print " checked";
}
print ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
print "<span class=text>" . $sas_lang['news_module_archive'] . " S@S:</span><input type=\"radio\" value=\"1\" name=\"article_archive\"";
if (($article_archive == 1) AND ($article_public == 0))
{
	print " checked";
}
print ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
print "<span class=text>" . $sas_lang['news_module_archive'] . " " . $sas_lang['protected_area'] . ":</span><input type=\"radio\" value=\"2\" name=\"article_archive\"";
if (($article_archive == 1) AND ($article_public == 1))
{
	print " checked";
}
print "><br>";
print "<br><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['cancel'] . "\" name=\"backbutton\" onClick=\"javascript:parent.location='index.php?option=modulemanager&module=$module&modoption=$modoption';\" class=\"backbutton\">";
print "&nbsp;<input type=\"submit\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['save'] . "\" name=\"savebutton\" class=\"savebutton\"><br><br></form>";

include ("interface/pageend.inc.php");
include ("interface/footer.inc.php");
?>
