form.article.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 142 行
PHP
142 行
<?php
/**
* Article management
*
* @copyright The XOOPS project http://www.xoops.org/
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Taiwen Jiang (phppp or D.J.) <php_pp@hotmail.com>
* @since 1.00
* @version $Id$
* @package module::article
*/
if (!defined("XOOPS_ROOT_PATH")) exit();
include_once XOOPS_ROOT_PATH."/modules/".$GLOBALS["artdirname"]."/class/xoopsformloader.php";
// The form
$form_art = new XoopsThemeForm("", "formarticle", XOOPS_URL."/modules/".$GLOBALS["artdirname"]."/action.article.php", 'post', true);
$form_art->setExtra("enctype=\"multipart/form-data\"");
if(!empty($_POST["form_mode"])){
$form_mode = $_POST["form_mode"];
}elseif(!$form_mode = art_getcookie("form_mode")){
$form_mode = @$xoopsModuleConfig["form_mode"];
}
include dirname(__FILE__)."/form.article.elements.php";
include_once dirname(__FILE__)."/form.article.config.php";
$elements_active = empty($form_art_elements[$form_mode]) ? $form_art_elements["full"] : $form_art_elements[$form_mode];
foreach($elements_active as $element) {
if(empty($form_element["active"][$element])) continue;
if(is_array($form_element["active"][$element])) {
foreach(array_keys($form_element["active"][$element]) as $key) {
$form_art->addElement($form_element["active"][$element][$key]);
}
}else{
$form_art->addElement($form_element["active"][$element]);
}
}
$elements_inactive = array_diff($form_art_elements["full"], $elements_active);
foreach($elements_inactive as $element) {
if(empty($form_element["inactive"][$element])) continue;
if(is_array($form_element["inactive"][$element])) {
foreach(array_keys($form_element["inactive"][$element]) as $key) {
$form_art->addElement($form_element["inactive"][$element][$key]);
}
}else{
$form_art->addElement($form_element["inactive"][$element]);
}
}
// Hidden options
$form_art->addElement(new XoopsFormHidden("newpage", $newpage));
$form_art->addElement(new XoopsFormHidden("page", $page));
$form_art->addElement(new XoopsFormHidden("art_id", $article_obj->getVar("art_id")));
$form_art->addElement(new XoopsFormHidden("from", $from));
// backward compatible
if(!class_exists("XoopsSecurity")){
$post_valid = 1;
$_SESSION['submit_token'] = $post_valid;
$form_art->addElement(new XoopsFormHidden('post_valid', $post_valid));
}
// Form actions
// "save": save as draft
// "save_edit": save and continue to edit
// "publish": regular submission
// "preview": preview and continue to edit
$button_tray = new XoopsFormElementTray("");
$i=0;
$i_tab = 3; //?
// Submit to publish
if(!$article_obj->getVar("art_time_submit")){
$button[$i] = new XoopsFormButton("", "publish", art_constant("MD_PUBLISH_ARTICLE"), "submit");
$button[$i]->setExtra("tabindex=$i_tab");
}
// Just save it
$i++;
$i_tab++;
if($article_obj->getVar("art_time_submit")){
$button[$i] = new XoopsFormButton("", "save", art_constant("MD_SAVE"), "submit");
}else{
$button[$i] = new XoopsFormButton("", "save", art_constant("MD_SAVE_DRAFT"), "submit");
}
$button[$i]->setExtra("tabindex=$i_tab");
$i++;
$i_tab++;
$button[$i] = new XoopsFormButton("", "save_edit", art_constant("MD_SAVE_EDIT"), "submit");
$button[$i]->setExtra("tabindex=$i_tab");
$i++;
$i_tab++;
$button[$i] = new XoopsFormButton("", "btn_preview", _PREVIEW, "button");
$button[$i]->setExtra("tabindex=$i_tab");
$button[$i]->setExtra('onclick="window.document.'.$form_art->getName().'.preview.value=1; window.document.'.$form_art->getName().'.submit()"');
$form_art->addElement(new XoopsFormHidden('preview', 0));
if($article_obj->getVar("art_id")){
$i++;
$i_tab++;
$button[$i] = new XoopsFormButton("", "btn_del", art_constant("MD_DELETE_PAGE"), "button");
$button[$i]->setExtra("tabindex=$i_tab");
$button[$i]->setExtra('onclick="window.document.'.$form_art->getName().'.del.value=1; window.document.'.$form_art->getName().'.submit()"');
$form_art->addElement(new XoopsFormHidden('del', 0));
if($isAuthor || $category_handler->getPermission($category_obj, "moderate") ){
$i++;
$i_tab++;
$button[$i] = new XoopsFormButton("", "btn_delete", art_constant("MD_DELETE_ARTICLE"), "button");
$button[$i]->setExtra("tabindex=$i_tab");
$button[$i]->setExtra('onclick="window.document.'.$form_art->getName().'.delart.value=1; window.document.'.$form_art->getName().'.submit()"');
$form_art->addElement(new XoopsFormHidden('delart', 0));
}
}
$i++;
$i_tab++;
$cancel_button = new XoopsFormButton('', 'cancel', _CANCEL, 'button');
if ( !$article_obj->getVar("art_id") ){
$extra = "view.category.php?category=".intval($cat_id);
}else{
$extra = "view.article.php?article=".$article_obj->getVar("art_id")."&category=".$cat_id."&page=".$page;
}
$cancel_button->setExtra("onclick='window.document.location=\"".$extra."\"'");
$button[$i] =& $cancel_button;
$button[$i]->setExtra("tabindex=$i_tab");
foreach(array_keys($button) as $btn){
$button_tray->addElement($button[$btn]);
}
$form_art->addElement($button_tray);
// Display the form
$form_art->display();
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?