Początkujący
Postów: 229 Pomógł: 13 Ostrzeżeń: 4
Data rejestracji: 24.10.2006 09:08
|
Witam,
Chciałbym aby w dodatkowych stronach można było oznaczyć kategorie strony coś na podobiznę kategorii dla artykułów. Niestety nie mogę sobie z tym poradzić, czy ktoś wie jak najlepiej to zrobić?
Dodałem plik o nazwie custom_cats.php w folderze "/administrator/" oraz w bazie danych w tabeli _admin wstawiłem nowy wiersz.
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: custom_cats.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../maincore.php";
if (!checkRights("XI") || !defined("iAUTH") || !isset($_GET['aid']) || $_GET['aid'] != iAUTH) { redirect("../index.php"); }
require_once THEMES."templates/admin_header.php";
include LOCALE.LOCALESET."admin/custom-cats.php";
if (isset($_GET['status']) && !isset($message)) {
if ($_GET['status'] == "sn") {
$message = $locale['410'];
} elseif ($_GET['status'] == "su") {
$message = $locale['411'];
} elseif ($_GET['status'] == "deln") {
$message = $locale['412']."<br />\n<span class='small'>".$locale['413']."</span>";
} elseif ($_GET['status'] == "dely") {
$message = $locale['414'];
}
if ($message) { echo "<div id='close-message'><div class='admin-message'>".$message."</div></div>\n"; }
}
if ((isset($_GET['action']) && $_GET['action'] == "delete") && (isset($_GET['cat_id']) && isnum($_GET['cat_id']))) {
$result = dbcount("(page_id)", DB_CUSTOM_PAGES, "page_cat='".$_GET['cat_id']."'");
if (!empty($result)) {
redirect(FUSION_SELF.$aidlink."&status=deln");
} else {
$result = dbquery("DELETE FROM ".DB_CUSTOM_CATS." WHERE custom_cat_id='".$_GET['cat_id']."'");
redirect(FUSION_SELF.$aidlink."&status=dely");
}
} else {
if (isset($_POST['save_cat'])) {
$cat_name = stripinput(trim($_POST['cat_name']));
$cat_description = stripinput(trim($_POST['cat_description']));
$cat_access = isnum($_POST['cat_access']) ? $_POST['cat_access'] : "0";
if (isnum($_POST['cat_sort_by']) && $_POST['cat_sort_by'] == "1") {
$cat_sorting = "page_id ".($_POST['cat_sort_order'] == "ASC" ? "ASC" : "DESC");
} else if (isnum($_POST['cat_sort_by']) && $_POST['cat_sort_by'] == "2") {
$cat_sorting = "page_title ".($_POST['cat_sort_order'] == "ASC" ? "ASC" : "DESC");
} else {
$cat_sorting = "page_title ASC";
}
if ($cat_name) {
if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_GET['cat_id']) && isnum($_GET['cat_id']))) {
$result = dbquery("UPDATE ".DB_CUSTOM_CATS." SET custom_cat_name='$cat_name', custom_cat_description='$cat_description', custom_cat_sorting='$cat_sorting', custom_cat_access='$cat_access' WHERE custom_cat_id='".$_GET['cat_id']."'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
$checkCat = dbcount("(custom_cat_id)", DB_CUSTOM_CATS, "custom_cat_name='".$cat_name."'");
if ($checkCat == 0) {
$result = dbquery("INSERT INTO ".DB_CUSTOM_CATS." (custom_cat_name, custom_cat_description, custom_cat_sorting, custom_cat_access) VALUES ('$cat_name', '$cat_description', '$cat_sorting', '$cat_access')");
redirect(FUSION_SELF.$aidlink."&status=sn");
} else {
$error = 2;
}
}
} else {
$error = 1;
}
}
if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_GET['cat_id']) && isnum($_GET['cat_id']))) {
$result = dbquery("SELECT custom_cat_name, custom_cat_description, custom_cat_sorting, custom_cat_access FROM ".DB_CUSTOM_CATS." WHERE custom_cat_id='".$_GET['cat_id']."'");
if (dbrows($result)) {
$data = dbarray($result);
$cat_name = $data['custom_cat_name'];
$cat_description = $data['custom_cat_description'];
$cat_sorting = explode(" ", $data['custom_cat_sorting']);
if ($cat_sorting[0] == "page_id") { $cat_sort_by = "1"; }
if ($cat_sorting[0] == "page_title") { $cat_sort_by = "2"; }
$cat_sort_order = $cat_sorting[1];
$cat_access = $data['custom_cat_access'];
$formaction = FUSION_SELF.$aidlink."&action=edit&cat_id=".$_GET['cat_id'];
$openTable = $locale['401'];
} else {
redirect(FUSION_SELF.$aidlink);
}
} else {
$cat_name = "";
$cat_description = "";
$cat_sort_by = "2";
$cat_sort_order = "ASC";
$cat_access = "";
$formaction = FUSION_SELF.$aidlink;
$openTable = $locale['400'];
}
$user_groups = getusergroups(); $access_opts = ""; $sel = "";
while(list($key, $user_group) = each($user_groups)){
$sel = ($cat_access == $user_group['0'] ? " selected='selected'" : "");
$access_opts .= "<option value='".$user_group['0']."'$sel>".$user_group['1']."</option>\n";
}
if (isset($error) && isnum($error)) {
if ($error == 1) {
$errorMessage = $locale['460'];
} elseif ($error == 2) {
$errorMessage = $locale['461'];
}
if ($errorMessage) { echo "<div id='close-message'><div class='admin-message'>".$errorMessage."</div></div>\n"; }
}
opentable($openTable);
echo "<form name='addcat' method='post' action='$formaction'>\n";
echo "<table cellpadding='0' cellspacing='0' width='90%'>\n<tr>\n";
echo "<td width='1%' class='tbl' style='white-space:nowrap'>".$locale['420']."</td>\n";
echo "<td class='tbl'><input type='text' name='cat_name' value='".$cat_name."' class='textbox' style='width:80%;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='1%' class='tbl' style='white-space:nowrap'>".$locale['421']."</td>\n";
echo "<td class='tbl'><input type='text' name='cat_description' value='".$cat_description."' class='textbox' style='width:80%;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='1%' class='tbl' style='white-space:nowrap'>".$locale['422']."</td>\n";
echo "<td class='tbl'><select name='cat_sort_by' class='textbox'>\n";
echo "<option value='1'".($cat_sort_by == "1" ? " selected='selected'" : "").">".$locale['423']."</option>\n";
echo "<option value='2'".($cat_sort_by == "2" ? " selected='selected'" : "").">".$locale['424']."</option>\n";
echo "<option value='3'".($cat_sort_by == "3" ? " selected='selected'" : "").">".$locale['425']."</option>\n";
echo "</select>\n<select name='cat_sort_order' class='textbox'>\n";
echo "<option value='ASC'".($cat_sort_order == "ASC" ? " selected='selected'" : "").">".$locale['426']."</option>\n";
echo "<option value='DESC'".($cat_sort_order == "DESC" ? " selected='selected'" : "").">".$locale['427']."</option>\n";
echo "</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='1%' class='tbl' style='white-space:nowrap'>".$locale['428']."</td>\n";
echo "<td class='tbl'><select name='cat_access' class='textbox'>\n".$access_opts."</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td align='center' colspan='2' class='tbl'>\n";
echo "<input type='submit' name='save_cat' value='".$locale['429']."' class='button' /></td>\n";
echo "</tr>\n</table>\n</form>\n";
closetable();
opentable($locale['402']);
echo "<table cellpadding='0' cellspacing='1' width='90%' class='tbl-border'>\n";
$result = dbquery("SELECT custom_cat_id, custom_cat_name, custom_cat_description, custom_cat_access FROM ".DB_CUSTOM_CATS." ORDER BY custom_cat_name");
if (dbrows($result) != 0) {
$i = 0;
echo "<tr>\n";
echo "<td class='tbl2'>".$locale['440']."</td>\n";
echo "<td width='1%' class='tbl2' style='white-space:nowrap'>".$locale['441']."</td>\n";
echo "<td width='1%' class='tbl2' style='white-space:nowrap'>".$locale['442']."</td>\n";
echo "</tr>\n";
while ($data = dbarray($result)) {
$cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2");
echo "<tr>\n";
echo "<td class='$cell_color'><strong>".$data['custom_cat_name']."</strong>\n";
if ($data['custom_cat_description']) { echo "<br /><span class='small'>".trimlink($data['custom_cat_description'], 45)."</span></td>\n"; }
echo "<td width='1%' class='$cell_color' style='white-space:nowrap'>".getgroupname($data['custom_cat_access'])."</td>\n";
echo "<td width='1%' class='$cell_color' style='white-space:nowrap'><a href='".FUSION_SELF.$aidlink."&action=edit&cat_id=".$data['custom_cat_id']."'>".$locale['443']."</a> -\n";
echo "<a href='".FUSION_SELF.$aidlink."&action=delete&cat_id=".$data['custom_cat_id']."' onclick=\"return confirm('".$locale['450']."');\">".$locale['444']."</a></td>\n";
echo "</tr>\n";
$i++;
}
echo "</table>\n";
} else {
echo "<tr><td align='center' class='tbl1'>".$locale['445']."</td></tr>\n</table>\n";
}
closetable();
}
require_once THEMES."templates/footer.php";
?> Kliknij i zaczekaj na załadowanie kodu ...
I nie wyświetla mi się w PA a link wyrzuca na strone główną (nie ma uprawnień?)
Z góry dziękuję za wszystkie sugestie i za pomoc.
Edytowane przez Rafee dnia 28.11.2021 11:34:00
|