190 lines
8.6 KiB
PHP
190 lines
8.6 KiB
PHP
<?php global $session;
|
|
/**
|
|
* Project: BeCast WebEngine - simple site engine
|
|
* File: /modules/news/editcategory.apnl.php
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library 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
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
* @link http://www.becast.at
|
|
* @copyright 2009 becast.at
|
|
* @author Bernhard Jaud <bernhard at becast dot at>
|
|
* @package BeCast WebEngine core
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
* @version $Id: ef38cf94caf9812acfbf9f594045a1ca24c42eae $
|
|
*/
|
|
|
|
If (!defined("IN_BCWE_ADMIN")) {
|
|
die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
|
|
}
|
|
$session->page_begin("edit news category", True);
|
|
|
|
class editcategory_news_panel extends admin_module{
|
|
|
|
function output(){
|
|
global $config, $db,$panel, $session, $root, $core, $admin;
|
|
$fail=FALSE;
|
|
|
|
if(isset($_POST['send'])&& $_POST['send']==1){
|
|
if(isset($_POST['name'])&& $_POST['name']!=""){
|
|
$userfile_name = $_FILES['picture']['name'];
|
|
$userfile_tmp = $_FILES['picture']['tmp_name'];
|
|
$userfile_size = $_FILES['picture']['size'];
|
|
$userfile_type = $_FILES['picture']['type'];
|
|
$filedir = $root.'/newsimages/';
|
|
$size = 700;
|
|
if (isset($_FILES['picture']['name']) && $_FILES['picture']['name']!=""){
|
|
$prod_img = $filedir.$userfile_name;
|
|
$ret=$core->upload_file($prod_img, $userfile_tmp, $size, $size, TRUE, TRUE);
|
|
if($ret!==TRUE){
|
|
$panel->admin_message("Fehler", "Das Bild konnte nicht hochgeladen wrden <br /> Der Fehler war: ". $ret,TRUE,"editcategory_news");
|
|
}
|
|
$result=$db->query("SELECT `picture` FROM `" . $config["prefix"]. "news_category` WHERE `id`='".intval($_POST["id"])."' LIMIT 1");
|
|
$file=$db->fetch_array($result);
|
|
@unlink($filedir.$file['picture']);
|
|
$db->query("UPDATE `" . $config["prefix"]. "news_category` SET `picture`='".$userfile_name."' WHERE `id`='".intval($_POST["id"])."'");
|
|
}elseif($_POST["delimg"]==1){
|
|
$result=$db->query("SELECT `picture` FROM `" . $config["prefix"]. "news_category` WHERE `id`='".intval($_POST["id"])."' LIMIT 1");
|
|
$file=$db->fetch_array($result);
|
|
@unlink($filedir.$file['picture']);
|
|
$db->query("UPDATE `" . $config["prefix"]. "news_category` SET `picture`='' WHERE `id`='".intval($_POST["id"])."'");
|
|
}
|
|
|
|
$name=$db->escape($_POST['name']);
|
|
$active=$db->escape($_POST['active']);
|
|
$db->query("UPDATE `" . $config["prefix"]. "news_category` SET `name`='".$name."', `active`='".$active."' WHERE `id`='".intval($_POST["id"])."'") or die($db->error());
|
|
$panel->admin_message("Danke", "Die Kategorie wurde erfolgreich editiert!.",TRUE,"editcategory_news");
|
|
}else{
|
|
$fail="<span style=\"text-align: center; color: red;\">Der Kategoriename muss angegeben werden!</span>";
|
|
}
|
|
|
|
}elseif(isset($_GET['id'])&& $_GET['id']!=""){
|
|
if($_GET['action']=="edit"){
|
|
$result = $db->query("SELECT * FROM `" . $config["prefix"] . "news_category` WHERE `id`='".intval($_GET['id'])."'");
|
|
$_POST=$db->fetch_array($result);
|
|
/*$resultna=$db->query("SELECT id,name FROM " . $config["prefix"] . "menue");
|
|
while($rowa=$db->fetch_array($resultna)){
|
|
$resultn = $db->query("SELECT m_id FROM " . $config["prefix"] . "article_menue WHERE a_id='".intval($_GET['id'])."' and m_id='".$rowa["id"]."'");
|
|
if($db->num_rows($resultn) >= 1){
|
|
$rowa["checked"]="checked=\"checked\"";
|
|
}
|
|
$navs[]=$rowa;
|
|
}*/
|
|
|
|
|
|
$panel->title="Kategorie editieren";
|
|
$panel->form(array("action"=>$config["path"]."/admin/index.php?panel=editcategory_news"),FALSE,"enctype=\"multipart/form-data\"");
|
|
if($fail){
|
|
$panel->content.=$fail;
|
|
}
|
|
$panel->content.="<h3>Kategoriename:</h3>";
|
|
$panel->field(array("name"=>"name","typ"=>"text","value"=>$_POST["name"]));
|
|
if($_POST["picture"]!=""){
|
|
$panel->content.="<h3>aktuelles Kategoriebild:</h3>";
|
|
$panel->content.="<img src=\"".$config["path"]."/newsimages/".$_POST["picture"]."\" alt=\"Kategoriebild\" />";
|
|
$panel->content.="<br />";
|
|
$panel->checkbox(array("name"=>"delimg","value"=>"1"));
|
|
$panel->content.=" Bild löschen?";
|
|
$panel->content.="<br />";
|
|
}
|
|
$panel->content.="<h3>neues Kategoriebild:</h3>";
|
|
$panel->field(array("name"=>"picture","typ"=>"file"));
|
|
$panel->content.="<br />";
|
|
$panel->content.="<h3>Aktiv:</h3>";
|
|
$panel->select(array("Nein"=>"false","Ja"=>"true"),$_POST["active"],"active");
|
|
$panel->content.="<br />";
|
|
$panel->field(array("name"=>"send","typ"=>"hidden","value"=>"1"));
|
|
$panel->field(array("name"=>"id","typ"=>"hidden","value"=>$_GET['id']));
|
|
$panel->content.="<br />";
|
|
$panel->submit();
|
|
$panel->formClose();
|
|
$panel->parse_page();
|
|
|
|
}elseif($_GET["action"]=="delete" && $_GET["id"]){
|
|
$result=$db->query("SELECT `picture` FROM `" . $config["prefix"] . "news_category` where `id`='".intval($_GET["id"])."'");
|
|
$row = $db->fetch_array($result);
|
|
@unlink($root.'/catimages/'.$row["picture"]);
|
|
$db->query("DELETE FROM `" . $config["prefix"] . "news_category` WHERE `id`='".intval($_GET["id"])."'");
|
|
$panel->admin_message("Kategorie gelöscht!","Die Kategorie wurde erfolgreich gelöscht.",True,"editcategory_news",3);
|
|
}
|
|
|
|
}else{
|
|
$result = $db->query("SELECT * FROM `" . $config["prefix"] . "news_category`");
|
|
while($row=$db->fetch_array($result, $db->ASSOC)){
|
|
$articles[]=$row;
|
|
}
|
|
$panel->title="Vorhandene Kategorien";
|
|
$panel->content.="<table class=\"sortable\" style=\"width: 90%; border-spacing: 2px;\">
|
|
<tr>
|
|
<th style=\"text-align: center;\">ID</th>
|
|
<th style=\"text-align: center;\">Name</th>
|
|
<th style=\"text-align: center;\">Bild</th>
|
|
<th style=\"text-align: center;\">Aktiv</th>
|
|
<th class=\"nosort sortcol\" style=\"text-align: center; width: 18%\">Aktionen</th>
|
|
</tr>";
|
|
if(!empty($articles)){
|
|
foreach($articles as $u){
|
|
$panel->content.="<tr>
|
|
<td style=\"text-align: center;\">".$u["id"]."</td>
|
|
<td style=\"text-align: center;\">".$u["name"]."</td>
|
|
<td style=\"text-align: center;\">".$u["picture"]."</td>";
|
|
if($u["active"]=="true"){
|
|
$panel->content.="<td style=\"text-align: center;\">Ja</td>";
|
|
}else{
|
|
$panel->content.="<td style=\"text-align: center;\">Nein</td>";
|
|
}
|
|
$panel->content.="<td style=\"text-align: center;\"><a onclick=\"return confirmLink(this, 'Willst du wirklich die Kategorie ".$u["categoryname"]." löschen? ')\" href=\"".$config["path"]."/admin/index.php?panel=editcategory_news&action=delete&id=".$u["id"]."\"><img src=\"".$config["path"]."/admin/images/icons/delete.png\" /></a> <a href=\"".$config["path"]."/admin/index.php?panel=editcategory_news&action=edit&id=".$u["id"]."\"><img src=\"".$config["path"]."/admin/images/icons/wrench.png\" /></a></td>
|
|
</tr>";
|
|
}
|
|
}else{
|
|
$panel->content.="<tr>
|
|
<td style=\"text-align: center;\" colspan=\"5\">Keine Kategorien vorhanden.</td>
|
|
</tr>";
|
|
}
|
|
$panel->content.="</table><br />";
|
|
}
|
|
}
|
|
|
|
function meta(){
|
|
$meta.='<script type="text/javascript" src="'.$config["path"].'/js/scriptaculous/prototype.js"></script>
|
|
<script src="'.$config["path"].'/js/fastinit.js" type="text/javascript">
|
|
</script>
|
|
<script src="'.$config["path"].'/js/tablesort.js" type="text/javascript">
|
|
</script>';
|
|
|
|
$meta.='<script type="text/javascript">
|
|
function confirmLink(theLink, text)
|
|
{
|
|
// Confirmation is not required in the configuration file
|
|
// or browser is Opera (crappy js implementation)
|
|
if (typeof(window.opera) != \'undefined\') {
|
|
return true;
|
|
}
|
|
|
|
var is_confirmed = confirm(text);
|
|
if (is_confirmed) {
|
|
if ( typeof(theLink.href) != \'undefined\' ) {
|
|
theLink.href += \'&is_js_confirmed=1\';
|
|
} else if ( typeof(theLink.form) != \'undefined\' ) {
|
|
theLink.form.action += \'?is_js_confirmed=1\';
|
|
}
|
|
}
|
|
|
|
return is_confirmed;
|
|
}
|
|
</script>';
|
|
return $meta;
|
|
}
|
|
}
|
|
?>
|