<?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.4): Fred Stuurman 
# Current coder & maintainer: Fred Stuurman (fc.stuurman@hccnet.nl)
############################################################################
# edit_content.php: last changed 19/02/2006  , version: 1.0
#                  by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: edit_content.php,v 1.1 2006/10/03 10:33:57 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
# Copyright (C) 2002 - 2005 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");
}

include ("interface/header.inc.php");
include ("interface/menubar.inc.php");
include ("interface/menustart.inc.php");
print "<span class=heading>" . $sas_lang['filemanager_menu'] . "</span><br><br>";
print "<a href=index.php?option=modulemanager&module=$module><span class=link>" . $sas_lang['newsletter_module_newsletters'] . "</a></span><p>";
print "<a href=index.php?option=modulemanager&module=$module&modoption=archive><span class=link>" . $sas_lang['newsletter_module_archive'] . "</a></span><br>";
print "<p><br><a href=index.php?option=modulemanager&module=$module&modoption=users><span class=link>" . $sas_lang['newsletter_module_subscribers'] . "</a></span><br>";
print "<br><a href=index.php?option=modulemanager&module=$module&modoption=users&suboption=not_active><span class=link>" . $sas_lang['newsletter_module_new_subscribers'] . "</a></span><br>";
print "<br><a href=index.php?option=modulemanager&module=$module&modoption=search><span class=link>" . $sas_lang['newsletter_module_search'] . "</a></span><br>";
print "<br><a href=index.php?option=modulemanager&module=$module&modoption=import><span class=link>" . $sas_lang['newsletter_module_import'] . "</a></span><br>";
include ("interface/menuend.inc.php");
include ("interface/pagestart.inc.php");
include ("editors/fckeditor/fckeditor.php");
$template_path = $sas_config['serverpath'] . $sas_config['user_path'] . "/" . $media . "/templates";

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

if (IsSet ($_GET[newsletter]))
{
	$newsletter = $_GET[newsletter];
}

print "<style type=\"text/css\">
SELECT { background-color: #FFFFFF; }
</style>";
print "<FORM METHOD=\"POST\" ACTION=\"index.php?option=modulemanager&module=$module&save_content=$edit_newsletter&newsletter=$newsletter\">";
print "<center><span class=text>&nbsp;" . $sas_lang['title'] . ":&nbsp;" . $title . "</span></center><br>";

print "<TABLE class=\"ToolBar\" id=\"idToolbar\" cellSpacing=\"0\" cellPadding=\"0\"  width=\"700\" border=\"1\">
<TBODY>
<TR style=\"background:ButtonFace\"><td>";
if (is_dir($template_path))
{
	print "<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&edit_newsletter=$edit_newsletter&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>";

$theme_css = $sas_config['url'] . $cmsdir . "/themes/" . $sas_config[theme] . "/style.css";
$height = $sas_config['htmlarea_editor_rows'] * 20;
$fck_lang = strtolower($sas_config[language]);
$oFCKeditor = new FCKeditor('content');
$oFCKeditor->BasePath = 'editors/fckeditor/';
$oFCKeditor->BaseHref = '$site_url';
$oFCKeditor->Config['EditorAreaCSS'] = $theme_css;
$oFCKeditor->Config['DefaultLanguage'] = "$fck_lang";
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = $height;
$oFCKeditor->Value = $content;
$oFCKeditor->Create();

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

print "<br><input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['cancel'] . "\" name=\"backbutton\" onClick=\"parent.location='index.php?option=modulemanager&module=$module&modoption=$modoption&newsletter=$newsletter';\" class=\"backbutton\">";
print "&nbsp;<input type=\"submit\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['save'] . "\" name=\"savebutton\" class=\"savebutton\"><br><br></form>";
?>
