Also ich weiß jetzt nicht, ob es sowas schon gibt, aber ich hab mal die Funktion für einen Kunden geschrieben. Ist jetzt zwar nich komplett ausgereichft
Aber naja ^^ Vllt bringts dich ja weiter
include/admin/news.php
<?php
# Copyright by: Manuel Staechele
# Support: www.ilch.de
defined ('main') or die ( 'no direct access' );
defined ('admin') or die ( 'only admin access' );
$design = new design ( 'Admins Area', 'Admins Area', 2 );
$design->header();
//-----------------------------------------------------------|
##
###
####
##### F u n k t i o n e n
function getKats ( $akt ) {
$katAR = array();
$kats = '';
$erg = db_query("SELECT DISTINCT news_kat FROM `prefix_news`");
while ($row = db_fetch_object($erg)) {
$katAr[] = $row->news_kat;
}
$katAr[] = 'Allgemein';
$katAr = array_unique($katAr);
foreach($katAr as $a) {
if (trim($a) == trim($akt)) {
$sel = ' selected';
} else {
$sel = '';
}
$kats .= '<option'.$sel.'>'.$a.'</option>';
}
return ($kats);
}
function getCoverages ( $akt ) {
$coverAR = array();
$covers = '';
$erg = db_query("SELECT news_coverages FROM `prefix_news`");
while ($row = db_fetch_object($erg)) {
$coverAr[] = $row->news_coverages;
}
$coverAr[0] = '1';
$coverAr[1] = '2';
$coverAr[2] = '3';
$coverAr[3] = '4';
$coverAr = array_unique($coverAr);
foreach($coverAr as $a) {
if (trim($a) == trim($akt)) {
$sel = ' selected';
} else {
$sel = '';
}
$covers .= '<option'.$sel.'>'.$a.'</option>';
}
return ($covers);
}
##### F u n k t i o n
####
###
##
#
##
###
####
##### A k t i o n e n
if ( !empty($_REQUEST['um']) ) {
$um = $_REQUEST['um'];
if ( $um == 'insert' ) {
# insert
$text = escape($_POST['txt'], 'textarea');
if ( $_POST['katLis'] == 'neu' ) {
$_POST['katLis'] = $_POST['kat'];
}
db_query("INSERT INTO `prefix_news` (news_title,user_id,news_time,news_recht,news_kat,news_text,news_links,news_coverages)
VALUES ('".$_POST['titel']."',".$_SESSION['authid'].",NOW(),".$_POST['grecht'].",'".$_POST['katLis']."','".$text."','".$_POST['links']."','".$_POST['coverages']."')");
# insert
} elseif ( $um == 'change' ) {
# edit
$text = escape($_POST['txt'],'textarea');
if ( $_POST['katLis'] == 'neu' ) {
$_POST['katLis'] = $_POST['kat'];
}
db_query('UPDATE `prefix_news` SET
news_title = "'.$_POST['titel'].'",
user_id = "'.$_SESSION['authid'].'",
news_recht = "'.$_POST['grecht'].'",
news_kat = "'.$_POST['katLis'].'",
news_links = "'.$_POST['links'].'",
news_coverages = "'.$_POST['coverages'].'",
news_text = "'.$text.'" WHERE news_id = "'.$_POST['newsID'].'" LIMIT 1');
$edit = $_POST['newsID'];
}
}
# edit
# del
if ( $menu->get(1) == 'del' ) {
db_query('DELETE FROM `prefix_news` WHERE news_id = "'.$menu->get(2).'" LIMIT 1');
}
#del
##### A k t i o n e n
####
###
##
#
##
###
####
##### h t m l E i n g a b e n
if ( empty ($doNoIn) ) {
$limit = 20; // Limit
$page = ($menu->getA(1) == 'p' ? $menu->getE(1) : 1 );
$MPL = db_make_sites ($page , '' , $limit , "?news" , 'news' );
$anfang = ($page - 1) * $limit;
if ( $menu->get(1) != 'edit' ) {
$FnewsID = '';
$Faktion = 'insert';
$Fueber = '';
$Fstext = '';
$Ftxt = '';
$Fgrecht = '';
$FkatLis = '';
$Flinks = '';
$Fcoverages = '';
$Fsub = 'Eintragen';
} else {
$row = db_fetch_object(db_query("SELECT * FROM `prefix_news` WHERE news_id = ".$menu->get(2)));
$FnewsID = $row->news_id;
$Faktion = 'change';
$Fueber = $row->news_title;
$Ftxt = stripslashes($row->news_text);
$Fgrecht = $row->news_recht;
$FkatLis = $row->news_kat;
$Flinks = $row->news_links;
$Fcoverages = $row->news_coverages;
$Fsub = 'Ändern';
}
$tpl = new tpl ( 'news', 1);
$ar = array
(
'NEWSID' => $FnewsID,
'AKTION' => $Faktion,
'MPL' => $MPL,
'UEBER' => $Fueber,
'txt' => $Ftxt,
'SMILIS' => getsmilies(),
'grecht' => dbliste($Fgrecht,$tpl,'grecht',"SELECT id,name FROM prefix_grundrechte ORDER BY id DESC"),
'KATS' => getKats($FkatLis),
'links' => $Flinks,
'coverages' => getCoverages($Fcoverages),
'FSUB' => $Fsub
);
$tpl->set_ar_out($ar,0);
# e d i t , d e l e t e
$abf = 'SELECT news_id,news_title
FROM `prefix_news`
ORDER BY news_time DESC
LIMIT '.$anfang.','.$limit;
$erg = db_query($abf);
$class = '';
while ($row = db_fetch_object($erg) ) {
$class = ($class == 'Cmite' ? 'Cnorm' : 'Cmite' );
$tpl->set_ar_out( array ( 'ID' => $row->news_id, 'class' => $class, 'TITEL' => $row->news_title ) , 1 );
}
# e d i t , d e l e t e
$tpl->set_ar_out( array ('MPL' => $MPL ) , 2 );
}
$design->footer();
?>
include/admin/templates/news.html
<script type="text/javascript" src="include/includes/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
oFCKeditor.BasePath = "include/includes/fckeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
<script language="JavaScript" type="text/javascript"><!--
function delcheck ( DELID ) {
var frage = confirm ( "Willst du diesen Eintrag wirklich l�schen?" );
if ( frage == true ) {
document.location.href="?news-del-"+DELID;
}
}
function delKcheck ( DELID , NID) {
var frage = confirm ( "Willst du dieses Kommentar wirklich l�schen?" );
if ( frage == true ) {
document.location.href="?news-sKoms-"+NID+"-Kdel-"+DELID+"#"+NID;
}
}
function sichtbar(){
if( document.form.katLis.value=="neu"){
document.form.kat.style.visibility="visible";
} else {
document.form.kat.style.visibility="hidden";
}
}
//--></script>
<table cellpadding="0" cellspacing="0" border="0"><tr><td><img src="include/images/icons/admin/news.png" /></td><td width="30"></td><td valign="bottom"><h1>News</h1></td></tr></table>
<hr style="width: 400px; margin: 0px;" >
<br /><br />
<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td valign="top">
<form method="POST" name="form" onsubmit="return submitForm();">
<input type="hidden" name="um" value="{AKTION}">
<input type="hidden" name="newsID" value="{NEWSID}">
<table cellpadding="2" cellspacing="1" border="0" class="border" width="100%">
<tr>
<td class="Cmite" align="right"><strong>Titel : </strong></td>
<td class="Cnorm"><input size="72" type="text" name="titel" value="{UEBER}"></td>
</tr><tr>
<td class="Cmite" align="right"><strong>News : </strong></td>
<td rowspan="2" class="Cnorm">
</td>
</tr><tr>
<td rowspan="2" valign="top" class="Cmite">{SMILIS}</td>
</tr><tr>
<td class="Cnorm">
<textarea id="MyTextarea" name="txt" tabindex="2">{txt}</textarea>
</td>
</tr>
<tr>
<td class="Cmite" align="right"><strong>Coverages? : </strong></td>
<td class="Cnorm"><select name="coverages">{coverages}</select></td>
</tr>
<tr>
<td class="Cmite" align="right"><strong>Links : </strong></td>
<td class="Cnorm"><input size="40" type="text" name="links" value="{links}"> Links ohne <b>http//:</b> angeben! Bsp.: google.de , gidf.de</td>
</tr>
<tr>
<td class="Cmite" align="right"><strong>Sichtbar ab : </strong></td>
<td class="Cnorm"><select name="grecht">{_list_grecht@<option%1 value="%2">%3</option>}</select></td>
</tr><tr>
<td class="Cmite" align="right"><strong>Kategorie : </strong></td>
<td class="Cnorm"><select onChange="sichtbar()" name="katLis">{KATS}<option value="neu">Neu:</option></select> <input type="text" name="kat" size="40"></td>
</tr><tr class="Cdark">
<td></td>
<td><input type="submit" value="{FSUB}" name="submit"></td>
</tr>
</table>
</form>
<br /><br />
<div class="info_box">
<b>Merke (Coverages Bild)</b>
<br />
<span class="smalfont">
Das Coverages Bild muss in den Ordner include/images/coverages/
<br />
Das Bild muss genau wie die Coverages Nummer heissen z.B. wenn die Coverages Nummer
<b>1</b> ist dann muss das Bild <b>1</b> heissen...
<br />
Die Endung muss .jpg sein bei uns also z.B. 1.jpg
</span>
</div>
<div class="info_box">
<b>Merke (Kategorie Bild)</b>
<br />
<span class="smalfont">
Das Kategorie Bild muss in den Ordner include/images/news/
<br />
Das Bild muss genau wie die Kategorie heissen z.B. wenn die Kategorie
Allgemein heisst dann muss das Bild Allgemein heissen;)...
<br />
Die Endung muss entweder .jpg oder .gif sein bei uns also z.B. Allgemein.jpg
</span>
</div>
<div class="info_box">
<b>Merke (Vorschau Funktion)</b>
<br />
<span class="smalfont">
Soll nur ein kleinerer Vorschautext angezeigt werden, einfach erst die Vorschau
eingeben und nach der Vorschau dann <b>[PREVIEWENDE]</b> schreiben. Dann den langen
Text eintragen.
</span>
</div>
</td><td width="75"> </td><td valign="top">
{MPL}
<table cellpadding="3" cellspacing="1" border="0" class="border">
{EXPLODE}<tr class="{class}">
<td><a href="#" name="{ID}"></a><a href="javascript:delcheck({ID})"><img src="include/images/icons/del.gif" alt="Löschen" title="Löschen" border="0"></a></td>
<td><a href="?news-edit-{ID}"><img src="include/images/icons/edit.gif" alt="Verändern" title="Verändern" border="0"></a></td>
<td>{TITEL}</td>
</tr>{EXPLODE}
</table>
{MPL}
</td></tr></table>
<script language="JavaScript" type="text/javascript">
<!--
sichtbar();
//-->
</script>
Es muss natürlich noch eine Zeile in der news-Tabelle gemacht werden.. ABer das sollte ja auch jetzt nicht so das große Problem sein oder
Und dann natürlich noch die
include/contents/news.php und
include/templates/news.html entsprechend anpassen