📄 admin.blog.php
字号:
<?php
// $Id: admin.blog.php,v 1.1.1.1 2005/11/14 00:33:45 phppp Exp $
// ------------------------------------------------------------------------ //
// 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. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// 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 //
// ------------------------------------------------------------------------ //
// Author: phppp (D.J., infomax@gmail.com) //
// URL: http://xoopsforge.com, http://xoops.org.cn //
// Project: Article Project //
// ------------------------------------------------------------------------ //
include("header.php");
require_once(XOOPS_ROOT_PATH . "/class/xoopsformloader.php");
xoops_cp_header();
/*
* To restore basic parameters in case cloned modules are installed
* reported by programfan
*
* This is a tricky fix for incomplete solution of module cone
* it is expected to have a better solution in article 1.0
*/
require XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/include/vars.php";
planet_adminmenu(2);
$op = !empty($_POST["op"])?$_POST["op"]:(!empty($_GET["op"])?$_GET["op"]:"");
$blog_id = !empty($_POST["blog"])?$_POST["blog"]:(!empty($_GET["blog"])?$_GET["blog"]:0);
$blog_id = is_array($blog_id)?array_map("intval", $blog_id):intval($blog_id);
$category_id = intval( !empty($_POST["category"])?$_POST["category"]:(!empty($_GET["category"])?$_GET["category"]:0) );
$start = intval( !empty($_POST["start"])?$_POST["start"]:(!empty($_GET["start"])?$_GET["start"]:0) );
$blog_handler =& xoops_getmodulehandler("blog", $GLOBALS["moddirname"]);
$category_handler =& xoops_getmodulehandler("category", $GLOBALS["moddirname"]);
if($op=="save" && !empty($_POST["fetch"])){
$op="edit";
}
switch($op){
/* save a single blog */
case "save":
if ($blog_id) {
$blog_obj =& $blog_handler->get($blog_id);
} else {
if($blog_exists = $blog_handler->getCount(new Criteria("blog_feed", $_POST['blog_feed']))){
redirect_header("admin.blog.php", 2, planet_constant("AM_BLOGEXISTS"));
exit();
}
$blog_obj =& $blog_handler->create();
$blog_obj->setVar('blog_submitter', $xoopsUser->getVar("uid"));
}
$blog_obj->setVar('blog_title', $_POST['blog_title']);
$blog_obj->setVar('blog_desc', $_POST['blog_desc']);
$blog_obj->setVar('blog_image', $_POST['blog_image']);
$blog_obj->setVar('blog_feed', $_POST['blog_feed']);
$blog_obj->setVar('blog_link', $_POST['blog_link']);
$blog_obj->setVar('blog_language', $_POST['blog_language']);
$blog_obj->setVar('blog_charset', $_POST['blog_charset']);
$blog_obj->setVar('blog_trackback', $_POST['blog_trackback']);
$blog_obj->setVar('blog_status', $_POST['blog_status']);
if (!$blog_handler->insert($blog_obj)) {
}elseif(!empty($_POST["categories"])){
$blog_id = $blog_obj->getVar("blog_id");
if(in_array(0, $_POST["categories"])) $_POST["categories"] = array();
$blog_handler->setCategories($blog_id, $_POST["categories"]);
}
$message = planet_constant("AM_DBUPDATED");
redirect_header("admin.blog.php", 2, $message);
exit();
/* fetch and add a list of blogs to a category */
case "add":
$links = planet_parseLinks($_POST["links"]);
$blogs = array();
foreach($links as $link){
if($blog_exist = $blog_handler->getCount(new Criteria("blog_feed", $link["url"]))) continue;
$blog_obj =& $blog_handler->fetch($link["url"]);
if(!empty($link["title"])) $blog_obj->setVar("blog_title", $link["title"]);
$blog_handler->insert($blog_obj);
$blogs[] = $blog_obj->getVar("blog_id");
unset($blog_obj);
}
if(!empty($_POST["categories"])){
$category_handler =& xoops_getmodulehandler("category", $GLOBALS["moddirname"]);
foreach($_POST["categories"] as $cat_id){
$category_handler->addBlogs($cat_id, $blogs);
}
}
$message = planet_constant("AM_DBUPDATED");
redirect_header("admin.blog.php", 2, $message);
exit();
/* update a list of blogs */
case "update":
foreach($blog_id as $bid){
$blog_obj =& $blog_handler->fetch($bid);
if (!$blog_handler->insert($blog_obj)) {
}
unset($blog_obj);
}
$message = planet_constant("AM_DBUPDATED");
redirect_header("admin.blog.php?category=".$category_id."&start=".$start, 2, $message);
exit();
/* add a list of blogs to a category */
case "register":
if(!empty($_POST["category_dest"])){
if(!is_array($blog_id)) $blog_id = array($blog_id);
$category_handler =& xoops_getmodulehandler("category", $GLOBALS["moddirname"]);
$category_handler->addBlogs($_POST["category_dest"], $blog_id);
}
$message = planet_constant("AM_DBUPDATED");
redirect_header("admin.blog.php?category=".$_POST["category_dest"]."&start=".$start, 2, $message);
exit();
/* remove a list of blogs from a category */
case "remove":
if(!is_array($blog_id)) $blog_id = array($blog_id);
if(!empty($category_id)){
$category_handler =& xoops_getmodulehandler("category", $GLOBALS["moddirname"]);
$category_handler->removeBlogs($category_id, $blog_id);
}
$message = planet_constant("AM_DBUPDATED");
redirect_header("admin.blog.php?category=".$category_id."&start=".$start, 2, $message);
exit();
/* delete a single blog or a list blogs */
case "del":
if(!is_array($blog_id)) $blog_id = array($blog_id);
foreach($blog_id as $bid){
$blog_obj =& $blog_handler->get($bid);
if (!$blog_handler->delete($blog_obj, true)) {
}
unset($blog_obj);
}
$message = planet_constant("AM_DBUPDATED");
redirect_header("admin.blog.php?category=".$category_id."&start=".$start, 2, $message);
exit();
/* empty a single blog or a list blogs */
case "empty":
if(!is_array($blog_id)) $blog_id = array($blog_id);
foreach($blog_id as $bid){
$blog_obj =& $blog_handler->get($bid);
if (!$blog_handler->do_empty($blog_obj)) {
}
}
$message = planet_constant("AM_DBUPDATED");
redirect_header("admin.blog.php?category=".$category_id."&start=".$start, 2, $message);
exit();
/* approve a single blog or a list blogs */
case "approve":
if(!is_array($blog_id)) $blog_id = array($blog_id);
$criteria = new Criteria("blog_id", "(".implode(",", $blog_id).")", "IN");
$blog_handler->updateAll("blog_status", 1, $criteria, true);
$message = planet_constant("AM_DBUPDATED");
redirect_header("admin.blog.php?category=".$category_id."&start=".$start, 2, $message);
exit();
/* mark a single blog or a list blogs as featured */
case "feature":
if(!is_array($blog_id)) $blog_id = array($blog_id);
$criteria = new Criteria("blog_id", "(".implode(",", $blog_id).")", "IN");
$blog_handler->updateAll("blog_status", 2, $criteria, true);
$message = planet_constant("AM_DBUPDATED");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -