form.article.elements.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 411 行 · 第 1/2 页
PHP
411 行
$attach = _DELETE." <a href=".XOOPS_URL."/".$xoopsModuleConfig["path_upload"]."/".$attachment["name_saved"]." targe="_blank" >".$attachment["name_display"]."</a>";
$delete_attach_checkbox->addOption($key, $attach);
}
$upload_tray->addElement($delete_attach_checkbox);
}
$form_element["active"]["userfile"] =& $upload_tray;
}else{
$form_element["active"]["userfile"] = null;
}
*/
// Spot Image
$image_tray = new XoopsFormElementTray(art_constant("MD_IMAGE_ARTICLE"), "<br />");
$image_current = empty($art_image["file"]) ? _NONE : _DELETE . "<input type=\"checkbox\" name=\"image_del\" value=\"".$art_image["file"]."\"><div style=\"padding: 8px;\"><img src=\"" . XOOPS_URL . "/" .$xoopsModuleConfig["path_image"]."/" . $art_image["file"] . "\" name=\"img\" id=\"img\" alt=\"\" /></div>";
$image_tray->addElement(new XoopsFormLabel(art_constant("MD_IMAGE_CURRENT"), $image_current));
$image_tray->addElement(new XoopsFormText(art_constant("MD_IMAGE_CAPTION"), "art_image_caption", 50, 255, @$art_image["caption"]));
//$form_element["active"]["art_image_hidden"] = array();
if($canupload){
$image_option_tray = new XoopsFormElementTray(art_constant("MD_IMAGE_UPLOAD"), "<br />");
$image_option_tray->addElement(new XoopsFormFile("", "userfile",""));
if (!empty($art_image_file_tmp)){
$image_option_tray->addElement(new XoopsFormLabel("", "<a href=\"".XOOPS_URL . "/" .$xoopsModuleConfig["path_image"]."/" .$art_image_file_tmp."\" target=\"_blank\">".art_constant("MD_IMAGE_UPLOADED")."</a>"));
$form_element["active"]["art_image"][] = new XoopsFormHidden("art_image_file_tmp", $art_image_file_tmp);
}
$image_tray->addElement($image_option_tray);
}
$form_element["active"]["art_image"][] = $image_tray;
$form_element["inactive"]["art_image"] = null;
// Template set
include_once dirname(__FILE__)."/functions.render.php";
if( $templates = art_getTemplateList("article") ){
$template_option_tray = new XoopsFormElementTray(art_constant("MD_TEMPLATE_SELECT"), "<br />");
$template_select = new XoopsFormSelect("", "art_template", $art_template);
$template_select->addOptionArray($templates);
$template_option_tray->addElement($template_select);
$form_element["active"]["art_template"] = $template_option_tray;
}else{
//$form_element["active"]["art_template"] = null;
}
$form_element["inactive"]["art_template"] = new XoopsFormHidden("art_template", $art_template);
// Category
// Only author and administrators have the right to change categories
// Moderator has the right to remove the article from his category
$categories =& $category_handler->getTree(0, "submit", "----");
$cat_options = array();
$top_categories = array();
$cat_pid = 0;
foreach($categories as $id => $cat){
$cat_options[$id] = $cat["prefix"] . $cat["cat_title"];
if($cat["cat_pid"] ==0) {
$top_categories[$id]["cat"] = $cat;
$cat_pid = $id;
}else{
$top_categories[$cat_pid]["sub"][$id] = $cat;
}
}
// base category
$form_element["inactive"]["cat_id"] = new XoopsFormHidden("cat_id", $cat_id);
if(art_isAdministrator() || $isAuthor){
$cat_select = new XoopsFormSelect("", "cat_id", $cat_id);
$cat_select->addOptionArray($cat_options);
$cat_option_tray = new XoopsFormElementTray(art_constant("MD_CATEGORY_BASE"), "<br />");
$cat_option_tray->addElement($cat_select);
$form_element["active"]["cat_id"] = $cat_option_tray;
}else{
$form_element["active"]["cat_id"] =& $form_element["inactive"]["cat_id"];
}
$col_num = 3;
$col_wid = floor( 95/$col_num );
$category_string = "<div>";
$top_count = 0;
//$form_element["active"]["category_hidden"] = array();
//$form_element["inactive"]["category_hidden"] = array();
foreach ( array_keys($top_categories) as $id){
$top_count++;
$cat = $top_categories[$id]["cat"];
$sub = empty($top_categories[$id]["sub"]) ? array() : $top_categories[$id]["sub"];
$category_string .="<div style=\"float: left; width: {$col_wid}%\">\n";
$category_string .= "<div>" . $cat["prefix"];
if($category_handler->getPermission($id, "moderate")) {
$category_string .= "<input type=\"checkbox\" name=\"category[]\"";
if(is_array($category) && in_array($id, $category)) $category_string .=" checked";
$category_string .=" value=\"{$id}\" />";
}else{
$category_string .= "<input type=\"checkbox\" name=\"category_disable\"";
if(is_array($category) && in_array($id, $category)){
$category_string .=" \"checked\"";
$form_element["active"]["category"][] = new XoopsFormHidden("category[]", $id);
}
$category_string .=" \"disabled\" />";
}
$category_string .= $cat["cat_title"]."</div>\n";
if(is_array($category) && in_array($id, $category)){
$form_element["inactive"]["category"][] = new XoopsFormHidden("category[]", $id);
}
foreach($sub as $sid => $scat){
$category_string .= "<div>" . $scat["prefix"];
if($category_handler->getPermission($sid, "moderate")) {
$category_string .= "<input type=\"checkbox\" name=\"category[]\"";
if(is_array($category) && in_array($sid, $category)) $category_string .=" checked";
$category_string .=" value=\"{$sid}\" />";
}else{
$category_string .= "<input type=\"checkbox\" name=\"category_disable\"";
if(is_array($category) && in_array($sid, $category)){
$category_string .=" \"checked\"";
$form_element["active"]["category"][] = new XoopsFormHidden("category[]", $sid);
}
$category_string .=" \"disabled\" />";
}
$category_string .= $scat["cat_title"]."</div>\n";
if(is_array($category) && in_array($id, $category)){
$form_element["inactive"]["category"][] = new XoopsFormHidden("category[]", $sid);
}
}
$category_string .= "</div>\n";
if($top_count == $col_num) {
$top_count = 0;
$category_string .= "</div>\n<br style=\"clear: both;\" /><div style=\"margin-top: 10px;\">";
}
}
$category_string .= "</div>\n";
$form_element["active"]["category"][] = new XoopsFormLabel(art_constant("MD_CATEGORY"), $category_string);
//$form_element["inactive"]["category"] = null;
// Topic
$permission_handler =& xoops_getmodulehandler("permission", $GLOBALS["artdirname"]);
$allowed_cats = $permission_handler->getCategories("submit");
$topic_handler =& xoops_getmodulehandler("topic", $GLOBALS["artdirname"]);
$criteria = new CriteriaCompo(new Criteria("top_expire", time(), ">"));
$tags = array("top_title", "cat_id");
$topic_string = "";
//$form_element["active"]["topic_hidden"] = array();
if( $topics_obj = $topic_handler->getByCategory($allowed_cats, $xoopsModuleConfig["topics_max"], 0, $criteria, $tags) ) {
foreach ($topics_obj as $top_id=>$top){
if($topic_handler->getPermission($top, "moderate")) {
$topic_string .="<div><input type=\"checkbox\" name=\"topic[]\"";
if(in_array($top_id, $topic)) {
$topic_string .=" \"checked\"";
}
$topic_string .=" value=\"".$top_id."\" />".$top->getVar("top_title")."</div>";
}else{
$topic_string .="<div><input type=\"checkbox\" name=\"topic_disable\"";
if(in_array($top_id, $topic)){
$topic_string .=" \"checked\"";
$form_element["active"]["topic"][] = new XoopsFormHidden("topic[]", $top_id);
}
$topic_string .=" \"disabled\" />".$top->getVar("top_title")."</div>";
}
if(in_array($top_id, $topic)) {
$form_element["inactive"]["topic"][] = new XoopsFormHidden("topic[]", $top_id);
}
}
$form_element["active"]["topic"][] = new XoopsFormLabel(art_constant("MD_TOPIC"), $topic_string);
}else{
//$form_element["active"]["topic"] = null;
}
//$form_element["inactive"]["topic"] = null;
// Forum
if(!empty($xoopsModuleConfig["forum"]) && $isModerator && !$article_obj->getVar("art_forum")){
$form_element["active"]["forum"] = new XoopsFormRadioYN(art_constant("MD_FORUM"), "forum", 0, _YES, " " . _NO);
}
// External Links
$form_element["active"]["art_elinks"] = new XoopsFormTextArea(art_constant("MD_ELINKS"), "art_elinks", $art_elinks, 3);
$form_element["inactive"]["art_elinks"] = new XoopsFormHidden("art_elinks", $art_elinks);
// Trackbacks
if(!empty($xoopsModuleConfig["do_trackback"])){
$form_element["active"]["trackbacks"] = new XoopsFormTextArea(art_constant("MD_TRACKBACKS"), "trackbacks", $trackbacks, 3);
$form_element["inactive"]["trackbacks"] = new XoopsFormHidden("trackbacks", $trackbacks);
}
// Notify for approval
if ( !$canPublish && is_object($xoopsUser) && $xoopsModuleConfig["notification_enabled"]) {
$form_element["active"]["notify"] = new XoopsFormRadioYN(art_constant("MD_NOTIFY_ON_APPROVAL"), "notify", $notify, _YES, " " . _NO);
$form_element["inactive"]["notify"] = new XoopsFormHidden("notify", $notify);
}
// Approval option
if( $article_obj->getVar("art_time_submit") && !$article_obj->getVar("art_time_publish") && $isModerator){
$form_element["active"]["approved"] = new XoopsFormRadioYN(art_constant("MD_APPROVE"), "approved", 1, _YES, " " . _NO );
$form_element["inactive"]["approved"] =& $form_element["active"]["approved"];
}
// Update publish time
if( $article_obj->getVar("art_time_publish") && $isModerator){
$update_time_value = ( !empty($_POST["update_time_value"]) && !empty($_POST["update_time"]) ) ? intval( strtotime( @$_POST["update_time_value"]["date"] ) + @$_POST["update_time_value"]["time"] ) : $article_obj->getVar("art_time_publish");
$date_tray = new XoopsFormElementTray(art_constant("MD_UPDATE_TIME"));
$date_tray->addElement( new XoopsFormDateTime("", "update_time_value", 15, $update_time_value ) );
$select_option = new XoopsFormCheckBox("", "update_time", intval( @$_POST["update_time"] ));
$select_option->addOption(1, "<strong>"._YES."</strong>");
$date_tray->addElement( $select_option );
$form_element["active"]["update_time"] = $date_tray;
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?