<?php
/*
DynPage V1.01 - A simple Content Management System
Copyright (C) 2009-2010 Matthias Wiede <hide@address.com>
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 3 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, see http://www.gnu.org/licenses.
*/
if (!defined ('DYNPAGE_LOGIN')) {
exit;
}
require_once ("lib/input.inc.php");
$cssFilename = ROOT_PATH."/content/ckeditor.css";
$defaultCSS = "@import \"ckeditor_default.css\";";
$FIELDS = array
(
"ckeditor_css" => "0;s;*",
"ckeditor_combo_styles" => "0;s;*;".trim (getConf ("ckeditor_combo_styles"), ',')
);
$values=array ();
$errors=array ();
$fShowErrors = false;
if ($cmd=="new" || $cmd=="edit")
$fShowErrors = true;
$errCnt = loadInputParams ($FIELDS, $values, 0, $errors, true, $fShowErrors);
$errText = "";
$successText = "";
switch ($cmd)
{
case "edit":
if ($errCnt>0)
$errText = "Please check marked fields.";
else
if (isDemo ()) {
$errText = "Cannot save styles in Demo mode.";
}
else
{
// Save css file
$fh = fopen ($cssFilename, "w+");
if ($fh) {
fwrite ($fh, $defaultCSS."\n");
fwrite ($fh, $values["ckeditor_css"]);
fclose ($fh);
$successText = "CKeditor styles saved.";
}
// Save rest
setConf ("ckeditor_combo_styles", urlencode ($values["ckeditor_combo_styles"]));
}
break;
}
// Load from file
if ($cmd!="edit" && file_exists ($cssFilename)) {
$fh = fopen ($cssFilename, "r");
if (!feof($fh)) {
$line = fgets($fh);
if ($line==$defaultCSS)
$values["ckeditor_css"] = fread ($fh, filesize ($cssFilename)-ftell ($fh));
else
$values["ckeditor_css"] = fread ($fh, filesize ($cssFilename));
}
$values["ckeditor_combo_styles"] = urldecode (getConf ("ckeditor_combo_styles"));
}
?>