form.topic.php

来自「php 开发的内容管理系统」· PHP 代码 · 共 95 行

PHP
95
字号
<?php
// $Id: form.topic.php,v 1.1.1.1 2005/11/10 19:51:17 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                                                 //
// ------------------------------------------------------------------------ //
if (!defined("XOOPS_ROOT_PATH")) exit();

//require_once(XOOPS_ROOT_PATH . "/class/xoopstree.php");
include_once XOOPS_ROOT_PATH."/modules/".$GLOBALS["artdirname"]."/class/xoopsformloader.php";


// Form
$form_art = new XoopsThemeForm(art_constant("MD_TOPIC")." ".$topic_obj->getVar("top_title"), "formtopic", XOOPS_URL."/modules/".$GLOBALS["artdirname"]."/action.topic.php");
$form_art->setExtra("enctype=\"multipart/form-data\"");

// Title
$form_art->addElement(new XoopsFormText(art_constant("MD_TITLE"), "top_title", 50, 255, $topic_obj->getVar("top_title")), true);

// Description
$form_art->addElement(new XoopsFormTextArea(art_constant("MD_DESCRIPTION"), "top_description", $topic_obj->getVar("top_description")));

// Parent category
if(art_isAdministrator()){
	require_once(XOOPS_ROOT_PATH."/modules/".$GLOBALS["artdirname"]."/class/tree.php");
	$category_handler =& xoops_getmodulehandler("category", $GLOBALS["artdirname"]);
    $tags = array("cat_id", "cat_pid", "cat_title", "cat_order");
    $categories = $category_handler->getAllByPermission("moderate", $tags);
	$mytree = new artTree($categories, "cat_id");
	$box = $mytree->makeSelBox("cat_id", "--", $topic_obj->getVar("cat_id"));
	$form_art->addElement(new XoopsFormLabel(art_constant("MD_CATEGORY"), $box));
}else{
	$form_art->addElement(new XoopsFormHidden("cat_id", $topic_obj->getVar("cat_id")));
}

// Order
$form_art->addElement(new XoopsFormText(art_constant("MD_ORDER"), "top_order", 20, 20, $topic_obj->getVar("top_order")));

// expire
$top_expire=($topic_obj->isNew())?(time()+$xoopsModuleConfig["topic_expire"]*3600*24):$topic_obj->getVar("top_expire");
$form_art->addElement(new XoopsFormDateTime(art_constant("MD_EXPIRATION"), "top_expire", 15, intval($top_expire)));

// Template set
$templates =& art_getTemplateList("topic");
if(count($templates)>0){
	$template_option_tray = new XoopsFormElementTray(art_constant("MD_TEMPLATE_SELECT"), "<br />");
	$template_select = new XoopsFormSelect("", "top_template", $topic_obj->getVar("top_template"));
	$template_select->addOptionArray($templates);
	$template_option_tray->addElement($template_select);
	$form_art->addElement($template_option_tray);
}

// Sponsor links
$form_art->addElement(new XoopsFormTextArea(art_constant("MD_SPONSOR"), "top_sponsor", $topic_obj->getVar("top_sponsor", "e")));
//$form_art->addElement(new XoopsFormLabel(art_constant("MD_SPONSOR_DESC"), art_constant("MD_SPONSOR_DESC_TEXT")));

$form_art->addElement(new XoopsFormHidden("top_id", $topic_obj->getVar("top_id")));
$form_art->addElement(new XoopsFormHidden("from", $from));

$button_tray = new XoopsFormElementTray("", "");
$button_tray->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit"));
$cancel_button = new XoopsFormButton('', 'cancel', _CANCEL, 'button');
if(!empty($from)){
	$extra = "admin/admin.topic.php";
}elseif ( !$topic_obj->getVar("top_id") ) {
    $extra = "view.category.php?category=".intval($category_id);
}else{
    $extra = "view.topic.php?topic=".$topic_obj->getVar("cat_id");
}
$cancel_button->setExtra("onclick='window.document.location=\"".$extra."\"'");
$button_tray->addElement($cancel_button);
$form_art->addElement($button_tray);

$form_art->display();
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?