帝国cms后台文章添加增加二级或多级联动功能
我们在做一个网站的时候,经常会用多级联动的功能,最常见的二级联动,即一个分类附属于一个分类,最常见的,就是省,市,县。这里我就是在帝国cms后台增加这个功能,当然其他系统也是可以加的。
首先,问这样的问题的同学就应该对帝国的系统模型有一定了解,模型是个很强大的功能,有了这个功能,几乎可以做任何的功能和系统,当然考虑到效率等等,我们要区别使用,但是,理论上是都可以实现的。
这实现这个功能有几个前提:
1,会php和ajax
2,对帝国的系统模型和数据表结构比较了解
看一下效果:
这里“期次”是随“年份”变化的,而“目录一级导航”和“目录二级导航”是随“期次”变化的,即,如果年份改版,其他三个都应该对应变化;
实现:
我从最基本开始讲起,不过前提是大家要做个ajax,对php和帝国cms比较了解;
1、首先因为其所需要的字段不同(即年份,期次等),原来的模型并没有这个字段,所以我们可以单独再新建一个模型;找到 系统->管理数据表,这时候你会看到他几个默认数据表,新闻、文章等,我们可以复制新闻系统数据表起名。但是我因为为了使用方便和习惯,因为新闻表用惯了,就复制备份了一个,然后改了一下名字,叫(杂志系统表phome_ecms_news),然后再复制分别建年份、目录表,然后点管理系统模型,添加模型,添加字段等等,当然要先添加字段,然后添加模型。
ps:这里要注意几个字段就是,年份数据表其实就只有一个字段,就是title,(输入2012等等添加记录),他是个主表,杂志表依附于他,;然后目录和二级目录也是附表,依附于杂志表,所以这两个个表都应该有个共同的字段,叫做期次(或者杂志),我这里用的期次,即qici,(最好字段名都叫一样的,这样方便下面使用),而杂志表应有个字段叫做(年份nf)来外链年份表,这里要注意就是大家要熟悉模型功能,这个qici字段是用的如图:
大家应该知道,因为问二级联动,就应该知道,他的一级联动,这里之所以要每个选项建一个表,就是因为这里的原因,他只能是数据同步这个表,不能加赛选条件。
2、给大家看一下这几个基础表添加数据的界面就大体明白了;
从高到低:
a.年份表添加数据界面:
b.杂志表添加数据界面:
c.一二级目录添加数据页面:一样的页面:
d然后杂志文章添加的页面就是第一个页面了;
f看一下栏目结构:
3.修改后台添加程序了;他的添加文章和修改文章页面其实就是一个页面,利用的参数的不同来控制的。
所以我们找到这个AddNews.php文件,修改,jquery的ajax习惯了我先引入了query.js。
b.为了不影响其他栏目添加,加几个隐含值,直接上代码吧,我这里在添加和修改的位置加了几个隐含值,还加了js代码:想了解的可以对比的看一下。里面都有注释开始和结束
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
<?php define('EmpireCMSAdmin','1'); require("../class/connect.php"); require("../class/db_sql.php"); require("../class/functions.php"); require("../data/dbcache/class.php"); $link=db_connect(); $empire=new mysqlquery(); //验证用户 $lur=is_login(); $logininid=$lur['userid']; $loginin=$lur['username']; $loginrnd=$lur['rnd']; $loginlevel=$lur['groupid']; $loginadminstyleid=$lur['adminstyleid']; $enews=$_GET['enews']; $classid=(int)$_GET['classid']; if(empty($class_r[$classid][classid])) { printerror("ErrorUrl","history.go(-1)"); } //验证权限 $doselfinfo=CheckLevel($logininid,$loginin,$classid,"news"); if(!$class_r[$classid][tbname]||!$class_r[$classid][classid]) { printerror("ErrorUrl","history.go(-1)"); } //非终极栏目 if(!$class_r[$classid]['islast']) { printerror("AddInfoErrorClassid","history.go(-1)"); } $fun_r['AdminInfo']='管理信息'; $bclassid=$class_r[$classid][bclassid]; $id=(int)$_GET['id']; //附件验证码 if($enews=="AddNews") { if(!$doselfinfo['doaddinfo'])//增加权限 { printerror("NotAddInfoLevel","history.go(-1)"); } $filepass=time(); $word='增加信息'; $ecmsfirstpost=1; } else { if(!$doselfinfo['doeditinfo'])//编辑权限 { printerror("NotEditInfoLevel","history.go(-1)"); } $filepass=$id; $word='修改信息'; $ecmsfirstpost=0; } //审核 $ecmscheck=(int)$_GET['ecmscheck']; $addecmscheck=''; $indexchecked=1; if($ecmscheck) { $addecmscheck='&ecmscheck='.$ecmscheck; $indexchecked=0; } //模型 $modid=$class_r[$classid][modid]; $enter=$emod_r[$modid]['enter']; //导航 $url=AdminReturnClassLink($classid).' > '.$word; //会员组 $sql1=$empire->query("select groupid,groupname from {$dbtbpre}enewsmembergroup order by level"); while($l_r=$empire->fetch($sql1)) { $ygroup.="<option value=".$l_r[groupid].">".$l_r[groupname]."</option>"; } if($enews=="AddNews") { $group=str_replace(" value=".$class_r[$classid][groupid].">"," value=".$class_r[$classid][groupid]." selected>",$ygroup); } //初始化数据 $r=array(); $newstime=time(); $r[newstime]=date("Y-m-d H:i:s"); $todaytime=$r[newstime]; $r[checked]=$class_r[$classid][checked]; $r[newspath]=date($class_r[$classid][newspath]); $r[onclick]=0; $r[userfen]=0; $titlefontb=""; $titlefonti=""; $titlefonts=""; $voteeditnum=8; $voter[width]=500; $voter[height]=300; $voter[dotime]='0000-00-00'; $r[dokey]=1; $titleurl=''; if($public_r['onclickrnd']) { $onclick_rndr=explode(',',$public_r['onclickrnd']); $r[onclick]=rand(intval($onclick_rndr[0]),intval($onclick_rndr[1])); $r[totaldown]=$r[onclick]; } else { $r[totaldown]=0; $r[onclick]=0; } //----------- 特殊模型初始化 ----------- //下载地址前缀 if(strstr($enter,',downpath,')||strstr($enter,',onlinepath,')) { $downurlqz=""; $newdownqz=""; $downsql=$empire->query("select urlname,url,urlid from {$dbtbpre}enewsdownurlqz order by urlid"); while($downr=$empire->fetch($downsql)) { $downurlqz.="<option value='".$downr[url]."'>".$downr[urlname]."</option>"; $newdownqz.="<option value='".$downr[urlid]."'>".$downr[urlname]."</option>"; } } //html编辑器 if($emod_r[$modid]['editorf']&&$emod_r[$modid]['editorf']!=',') { include('ecmseditor/infoeditor/fckeditor.php'); } //预设投票 if($enews=="AddNews") { $infoclassr=$empire->fetch1("select definfovoteid from {$dbtbpre}enewsclass where classid='$classid'"); $definfovoteid=0; if($infoclassr['definfovoteid']) { $definfovoteid=$infoclassr['definfovoteid']; } elseif($emod_r[$modid]['definfovoteid']) { $definfovoteid=$emod_r[$modid]['definfovoteid']; } if($definfovoteid) { //投票 $voter=$empire->fetch1("select * from {$dbtbpre}enewsvotemod where voteid='$definfovoteid'"); if($voter['voteid']&&$voter[votetext]) { $d_record=explode("\r\n",$voter[votetext]); for($i=0;$i<count($d_record);$i++) { $j=$i+1; $d_field=explode("::::::",$d_record[$i]); $allvote.="<tr><td width='9%'><div align=center>".$j."</div></td><td width='65%'><input name=vote_name[] type=text value='".$d_field[0]."' size=30></td><td width='26%'><input name=vote_num[] type=text value='".$d_field[1]."' size=6></td></tr>"; } $voteeditnum=$j; $allvote="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$allvote."</table>"; } } } //-----------------------------------------修改信息 if($enews=="EditNews") { //索引表 $index_r=$empire->fetch1("select id,classid,checked from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index where id='$id' limit 1"); if(!$index_r['id']||$index_r['classid']!=$classid) { printerror("ErrorUrl","history.go(-1)"); } //返回表 $infotb=ReturnInfoMainTbname($class_r[$classid][tbname],$index_r['checked']); //主表 $r=$empire->fetch1("select * from ".$infotb." where id='$id' limit 1"); //签发表 if($r[isqf]) { $wfinfor=$empire->fetch1("select tstatus,checktno from {$dbtbpre}enewswfinfo where id='$id' and classid='$classid' limit 1"); } //只能编辑自己的信息 if($doselfinfo['doselfinfo']&&($r[userid]<>$logininid||$r[ismember])) { printerror("NotDoSelfinfo","history.go(-1)"); } //已审核信息不可修改 if($doselfinfo['docheckedit']&&$index_r['checked']) { printerror("NotEditCheckInfoLevel","history.go(-1)"); } //返回表信息 $infodatatb=ReturnInfoDataTbname($class_r[$classid][tbname],$index_r['checked'],$r['stb']); //副表 $finfor=$empire->fetch1("select ".ReturnSqlFtextF($modid)." from ".$infodatatb." where id='$id' limit 1"); $r=array_merge($r,$finfor); //时间 $r['checked']=$index_r['checked']; $newstime=$r['newstime']; $r['newstime']=date("Y-m-d H:i:s",$r['newstime']); //链接地址 $titleurl=$r['titleurl']; if(!$r['isurl']) { $r['titleurl']=''; } //会员组 $group=str_replace(" value=".$r[groupid].">"," value=".$r[groupid]." selected>",$ygroup); //内容存文本 $savetxtf=$emod_r[$modid]['savetxtf']; $newstext_url=''; if($savetxtf) { $newstext_url=$r[$savetxtf]; $r[$savetxtf]=GetTxtFieldText($r[$savetxtf]); } //标题属性 if(strstr($r[titlefont],',')) { $tfontr=explode(',',$r[titlefont]); $r[titlecolor]=$tfontr[0]; $r[titlefont]=$tfontr[1]; } if(strstr($r[titlefont],"b|")) { $titlefontb=" checked"; } if(strstr($r[titlefont],"i|")) { $titlefonti=" checked"; } if(strstr($r[titlefont],"s|")) { $titlefonts=" checked"; } //投票 $pubid=ReturnInfoPubid($classid,$id); $voter=$empire->fetch1("select * from {$dbtbpre}enewsinfovote where pubid='$pubid' limit 1"); if($voter['id']&&$voter[votetext]) { $d_record=explode("\r\n",$voter[votetext]); for($i=0;$i<count($d_record);$i++) { $j=$i+1; $d_field=explode("::::::",$d_record[$i]); $allvote.="<tr><td width='9%'><div align=center>".$j."</div></td><td width='65%'><input name=vote_name[] type=text value='".$d_field[0]."' size=30></td><td width='26%'><input name=vote_num[] type=text value='".$d_field[1]."' size=6><input type=hidden name=vote_id[] value=".$j."><input type=checkbox name=delvote_id[] value=".$j.">删除</td></tr>"; } $voteeditnum=$j; $allvote="<table width='100%' border=0 cellspacing=1 cellpadding=3>".$allvote."</table>"; } } //标题分类 $cttidswhere=''; $tts=''; $caddr=$empire->fetch1("select ttids from {$dbtbpre}enewsclassadd where classid='$classid'"); if($caddr['ttids']!='-') { if($caddr['ttids']&&$caddr['ttids']!=',') { $cttidswhere=' and typeid in ('.substr($caddr['ttids'],1,-1).')'; } $ttsql=$empire->query("select typeid,tname from {$dbtbpre}enewsinfotype where mid='$modid'".$cttidswhere." order by myorder"); while($ttr=$empire->fetch($ttsql)) { $select=''; if($ttr[typeid]==$r[ttid]) { $select=' selected'; } $tts.="<option value='$ttr[typeid]'".$select.">$ttr[tname]</option>"; } } //内容模板 $t_sql=$empire->query("select tempid,tempname from ".GetTemptb("enewsnewstemp")." order by modid,tempid"); while($nt=$empire->fetch($t_sql)) { if($nt[tempid]==$r[newstempid]) { $select=" selected"; } else { $select=""; } $newstemp.="<option value=".$nt[tempid].$select.">".$nt[tempname]."</option>"; } //模板 $votetemp=""; $vtsql=$empire->query("select tempid,tempname from ".GetTemptb("enewsvotetemp")." order by tempid"); while($vtr=$empire->fetch($vtsql)) { if($voter[tempid]==$vtr[tempid]) { $select=" selected"; } else { $select=""; } $votetemp.="<option value='".$vtr[tempid]."'".$select.">".$vtr[tempname]."</option>"; } //同时发布 if(empty($voter['copyids'])||$voter['copyids']=='1') { $copyclassidshowiframe='<IFRAME frameBorder="0" id="showclassnav" name="showclassnav" scrolling="no" src="ShowClassNav.php?ecms=1" style="HEIGHT:0;VISIBILITY:inherit;WIDTH:0;Z-INDEX:1"></IFRAME>'; $copyclassids='<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5"> <tr> <td>同时发布到以下栏目: <input type="checkbox" name="copyinfotitleurl" value="1">采用索引链接</td> </tr> <tr> <td height="25" bgcolor="#FFFFFF" id="copyinfoshowclassnav"></td> </tr> </table>'; } else { $copyclassidshowiframe=''; $copyclassids='<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5"> <tr> <td>同时发布到以下栏目:</td> </tr> <tr> <td height="25" bgcolor="#FFFFFF" id="copyinfoshowclassnav">本信息已同步发布到其他栏目,信息ID:<br>'.$voter[copyids].'</td> </tr> </table>'; } //表单文件 $modfile="../data/html/".$modid.".php"; //栏目链接 $getcurlr['classid']=$classid; $classurl=sys_ReturnBqClassname($getcurlr,9); //当前使用的模板组 $thegid=GetDoTempGid(); $phpmyself=urlencode(eReturnSelfPage(1)); //返回头条和推荐级别名称 $ftnr=ReturnFirsttitleNameList($r['firsttitle'],$r['isgood']); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title><?=$word?></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" href="adminstyle/<?=$loginadminstyleid?>/adminstyle.css" type="text/css"> <link id="luna-tab-style-sheet" type="text/css" rel="stylesheet" href="adminstyle/<?=$loginadminstyleid?>/tab.winclassic.css" disabled="disabled" /> <!-- the id is not needed. It is used here to be able to change css file at runtime --> <style type="text/css"> .dynamic-tab-pane-control .tab-page { width: 100%; } .dynamic-tab-pane-control .tab-page .dynamic-tab-pane-control .tab-page { height: 150px; } form { margin: 0; padding: 0; } /* over ride styles from webfxlayout */ .dynamic-tab-pane-control h2 { font-size:12px; font-weight:normal; text-align: center; width: auto; height: 20; } .dynamic-tab-pane-control h2 a { display: inline; width: auto; } .dynamic-tab-pane-control a:hover { background: transparent; } </style> <script type="text/javascript" src="../data/images/tabpane.js"></script> <script type="text/javascript" src="jquery-1.8.0.min.js"></script> <script type="text/javascript"> function setLinkSrc( sStyle ) { document.getElementById( "luna-tab-style-sheet" ).disabled = sStyle != "luna"; //document.documentElement.style.background = ""; //document.body.style.background = sStyle == "webfx" ? "white" : "ThreeDFace"; } function chgBg(obj,color){ if (document.all || document.getElementById) obj.style.backgroundColor=color; else if (document.layers) obj.bgColor=color; } setLinkSrc( "luna" ); </script> <script> function dovoteadd(){ var i; var str=""; var oldi=0; var j=0; oldi=parseInt(document.add.v_editnum.value); for(i=1;i<=document.add.v_vote_num.value;i++) { j=i+oldi; str=str+"<tr><td width='9%' height=20> <div align=center>"+j+"</div></td><td width='65%'> <div align=center><input type=text name=vote_name[] size=30></div></td><td width='26%'> <div align=center><input type=text name=vote_num[] value=0 size=6></div></td></tr>"; } document.getElementById('addvote').innerHTML="<table width='100%' border=0 cellspacing=1 cellpadding=3>"+str+"</table>"; } function doSpChangeFile(name,url,filesize,filetype,idvar){ document.getElementById(idvar).value=url; if(document.add.filetype!=null) { if(document.add.filetype.value=='') { document.add.filetype.value=filetype; } } if(document.add.filesize!=null) { if(document.add.filesize.value=='') { document.add.filesize.value=filesize; } } } function SpOpenChFile(type,field){ window.open('ecmseditor/FileMain.php?classid=<?=$classid?>&infoid=<?=$id?><?=$addecmscheck?>&filepass=<?=$filepass?>&type='+type+'&sinfo=1&tranfrom=2&field='+field,'','width=700,height=550,scrollbars=yes'); } </script> <script src="ecmseditor/fieldfile/setday.js"></script> <script src="../data/html/postinfo.js"></script> <script> function bs(){ var f=document.add; if(f.title.value.length==0){alert("标题还没写");f.title.focus();return false;} } function foreColor(){ if(!Error()) return; var arr = showModalDialog("../data/html/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0"); if (arr != null) document.add.titlecolor.value=arr; else document.add.titlecolor.focus(); } function FieldChangeColor(obj){ if(!Error()) return; var arr = showModalDialog("../data/html/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0"); if (arr != null) obj.value=arr; else obj.focus(); } </script> <!--自定义二级联动js start--> <script> $(function(){ var enews = $("#enews").val(); if(enews){ var nf = $("#nf").val(); if(document.getElementById("nf")&&document.getElementById("ml")){ checkqici(nf) } } }) //期次ajax function checkqici(id){ var enews = $("#enews").val(); if(id&&enews){ var t_qici = $("#t_qici").val(); $.post("ajax.php",{act:"checkqici",enews:enews,nfid:id,t_qici:t_qici},function(data){ if(data){ $("#qici").html(data); checkm(); }else{ $("#qici").html("<option value=''>无期次请添加</option>"); checkm(); } // }) }else{ $("#nf").html("<option value=''>无年份</option>"); alert("年份错误"); } } function checkm(id){ if(!id){ id = $("#qici").val(); } if(id){ checkml(id); checkml2(id); }else{ alert("本年份无期次,请添加杂志期次"); } } //目录一级导航ajax function checkml(id){ var enews = $("#enews").val(); if(id&&enews){ var t_ml = $("#t_ml").val(); $.post("ajax.php",{act:"checkml",enews:enews,mlid:id,t_ml:t_ml},function(data){ if(data){ $("#ml").html(data); }else{ $("#ml").html("<option value=''>本期无一级导航请添加</option>"); } // }) } } //目录二级ajax function checkml2(id){ var enews = $("#enews").val(); if(id&&enews){ var t_ml2 = $("#t_ml2").val(); $.post("ajax.php",{act:"checkml2",enews:enews,ml2id:id,t_ml2:t_ml2},function(data){ if(data){ $("#ml2").html(data); }else{ $("#ml2").html("<option value=''>本期无二级导航请添加</option>"); } // }) } } </script> <!--自定义二级联动js end--> </head> <body bgcolor="#FFFFFF" text="#000000" onload="document.add.title.focus();"> <!--自定义的 start--> <input type="hidden" id="enews" value="<?php echo $enews;?>" /> <!--自定义的 end--> <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td width="62%" height="25">位置: <?=$url?> </td> <td width="38%"><div align="right"> <?=$enews=='EditNews'?'[<a href="user/ListDolog.php?classid='.$classid.'&id='.$id.'" target="_blank">查看本信息操作日志</a>]':''?> </div></td> </tr> </table> <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tableborder"> <form name="searchinfo" method="GET" action="ListNews.php"> <tr> <td width="42%" title="增加信息后使用本操作将信息显示到前台"> <select name="dore"> <option value="1">刷新当前栏目</option> <option value="2">刷新首页</option> <option value="3">刷新父栏目</option> <option value="4">刷新当前栏目与父栏目</option> <option value="5">刷新父栏目与首页</option> <option value="6" selected>刷新当前栏目、父栏目与首页</option> </select> <input type="button" name="Submit12" value="提交" onclick="self.location.href='ecmsinfo.php?enews=AddInfoToReHtml<?=$addecmscheck?>&classid=<?=$classid?>&dore='+document.searchinfo.dore.value;"> </td> <td width="58%"><div align="right">[<font color="#ffffff"><a href=../../ target=_blank>预览首页</a></font>] [<font color="#ffffff"><a href="<?=$classurl?>" target=_blank>预览栏目</a></font>] [<font color="#ffffff"><a href="file/ListFile.php?type=9&classid=<?=$classid?>">附件管理</a></font>] [<a href="AddClass.php?enews=EditClass&classid=<?=$classid?>">栏目设置</a>] [<a href="ecmschtml.php?enews=ReAllNewsJs&from=<?=$phpmyself?>">刷新所有信息JS</a>] </div></td> </tr> </form> <?php if($enews=='EditNews') { ?> <!--自定义的 start--> <input type="hidden" id="t_qici" value="<?=$r[qici]?>" /> <input type="hidden" id="t_ml" value="<?=$r[ml]?>" /> <input type="hidden" id="t_ml2" value="<?=$r[ml2]?>" /> <!--自定义的 end--> <form name="doinfoform" method="post" action="ecmsinfo.php" onsubmit="return confirm('确认要执行此操作?');"> <tr bgcolor="#FFFFFF"> <td height="32" colspan="2"> <div align="right">原因: <input name="causetext" type="text" id="causetext"> <input type="submit" name="Submit3" value="审核通过" onclick="document.doinfoform.doing.value='2';"> <input type="submit" name="Submit32" value="取消审核" onclick="document.doinfoform.doing.value='3';"> <input type="submit" name="Submit33" value="删除" onclick="document.doinfoform.doing.value='1';"> <font color="#666666">(不填原因表示不通知会员)</font> <input name="enews" type="hidden" id="enews" value="DoInfoAndSendNotice"> <input name="bclassid" type="hidden" id="bclassid" value="<?=$bclassid?>"> <input name="classid" type="hidden" id="classid" value="<?=$classid?>"> <input name="id" type="hidden" id="id" value="<?=$id?>"> <input name="ecmsfrom" type="hidden" id="ecmsfrom" value="<?=$_SERVER['HTTP_REFERER']?>"> <input name="doing" type="hidden" id="doing"> <input name="ecmscheck" type="hidden" id="ecmscheck" value="<?=$ecmscheck?>"> </div></td> </tr> </form> <?php } ?> </table> <br> <form name="add" method="post" enctype="multipart/form-data" action="ecmsinfo.php" onsubmit="return EmpireCMSInfoPostFun(document.add,'<?=$modid?>');"> <div class="tab-pane" id="TabPane1"> <script type="text/javascript"> tb1 = new WebFXTabPane( document.getElementById( "TabPane1" ) ); </script> <div class="tab-page" id="baseinfo"> <h2 class="tab"> <font class=tabcolor>基本信息</font> </h2> <script type="text/javascript">tb1.addTabPage( document.getElementById( "baseinfo" ) );</script> <table width="100%" align="center" cellpadding="3" cellspacing="1" class="tableborder"> <tr class="header"> <td width="16%" height="25"> <div align="left"><?=$word?></div> </td> <td> <input type="submit" name="addnews2" value="提交"> <input type="reset" name="Submit23" value="重置"> <input type=hidden value=<?=$enews?> name=enews> <input type=hidden value=<?=$classid?> name=classid> <input type=hidden value=<?=$bclassid?> name=bclassid> <input name=id type=hidden value=<?=$id?>> <input type=hidden value="<?=$filepass?>" name=filepass> <input type=hidden value="<?=$r[username]?>" name=username> <input name="oldfilename" type="hidden" value="<?=$r[filename]?>"> <input name="oldgroupid" type="hidden" value="<?=$r[groupid]?>"> <input name="oldchecked" type="hidden" value="<?=$r[checked]?>"> <input name="newstext_url" type="hidden" value="<?=$newstext_url?>"> <input name="ecmsfrom" type="hidden" value="<?=$_SERVER['HTTP_REFERER']?>"> <input name="ecmsnfrom" type="hidden" value="<?=$_GET['ecmsnfrom']?>"> <input name="fstb" type="hidden" value="<?=$r[fstb]?>"> <input name="oldttid" type="hidden" value="<?=$r[ttid]?>"> <input name="ecmscheck" type="hidden" id="ecmscheck" value="<?=$ecmscheck?>"> <input name="ztids" type="hidden" id="ztids"> <input name="zcids" type="hidden" id="zcids"> <input name="oldztids" type="hidden" id="oldztids"> <input name="oldzcids" type="hidden" id="oldzcids"></td> </tr> </table> <?php include($modfile); ?> </div> <div class="tab-page" id="spsetting"> <h2 class="tab"> <font class=tabcolor>选项设置</font> </h2> <script type="text/javascript">tb1.addTabPage( document.getElementById( "spsetting" ) );</script> <table width=100% align=center cellpadding=3 cellspacing=1 class="tableborder"> <tr><td class=header>选项设置</td></tr> <tr> <td bgcolor='#ffffff'> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5"> <tr> <td height="25" bgcolor="#FFFFFF">置顶级别: <select name="istop"> <option value="0"<?=$r[istop]==0?' selected':''?>>不置顶</option> <option value="1"<?=$r[istop]==1?' selected':''?>>一级置顶</option> <option value="2"<?=$r[istop]==2?' selected':''?>>二级置顶</option> <option value="3"<?=$r[istop]==3?' selected':''?>>三级置顶</option> <option value="4"<?=$r[istop]==4?' selected':''?>>四级置顶</option> <option value="5"<?=$r[istop]==5?' selected':''?>>五级置顶</option> <option value="6"<?=$r[istop]==6?' selected':''?>>六级置顶</option> <option value="7"<?=$r[istop]==7?' selected':''?>>七级置顶</option> <option value="8"<?=$r[istop]==8?' selected':''?>>八级置顶</option> <option value="9"<?=$r[istop]==9?' selected':''?>>九级置顶</option> </select> 内容模板: <select name="newstempid"> <option value="0"<?=$r[newstempid]==0?' selected':''?>>使用默认模板</option> <?=$newstemp?> </select> <input type="button" name="Submit62222" value="管理内容模板" onclick="window.open('template/ListNewstemp.php?gid=<?=$thegid?>');"> </td> </tr> <tr> <td height="25" bgcolor="#FFFFFF">权限设置: <select name="groupid"> <option value="0">游客</option> <?=$group?> </select> 查看扣除点数: <input name="userfen" type="text" value="<?=$r[userfen]?>" size="6"> , <input type=checkbox name=closepl value=1<?=$r[closepl]==1?" checked":""?>> 关闭评论 </td> </tr> <tr> <td height="25" bgcolor="#FFFFFF">点击数 : <input name="onclick" type="text" id="onclick" value="<?=$r[onclick]?>"> 下载数 : <input name="totaldown" type="text" id="totaldown" value="<?=$r[totaldown]?>"></td> </tr> <tr> <td height="25" bgcolor="#FFFFFF"> 文件名 : <input name="newspath" type="text" id="newspath" value="<?=$r[newspath]?>"> / <input name="filename" type="text" value="<?=$r[filename]?>"> <font color="#666666">(日期目录/文件名)</font></td> </tr> <?php if(strstr($public_r['usetags'],','.$modid.',')) { $infotag_readonly=''; $infotag_copykeyboard=' <input type="button" name="Submit3" value="复制关键字" onclick="document.add.infotags.value=document.add.keyboard.value;">'; if(strstr($public_r['chtags'],','.$modid.',')) { $infotag_readonly=' readonly'; $infotag_copykeyboard=''; } ?> <tr> <td height="25" bgcolor="#FFFFFF">TAGS : <input name="infotags" type="text" id="infotags" value="<?=$r[infotags]?>" size="32"<?=$infotag_readonly?>> <input type="button" name="Submit" value="选择" onclick="window.open('tags/ChangeTags.php?form=add&field=infotags','','width=700,height=550,scrollbars=yes');"> <?=$infotag_copykeyboard?> <input name="oldinfotags" type="hidden" id="oldinfotags" value="<?=$r[infotags]?>"> <font color="#333333">(多个用","逗号格开)</font></td> </tr> <?php } ?> <?php if($class_r[$classid]['link_num']) { ?> <tr> <td height="25" bgcolor="#FFFFFF">相关链接: <input type="radio" name="info_diyotherlink" value="0"<?=$voter[diyotherlink]==0?' checked':''?>> 按关键字查询 <input type="radio" name="info_diyotherlink" value="1"<?=$voter[diyotherlink]==1?' checked':''?>> <a href="#empirecms" title="查看和增加的相关链接" onclick="if(document.getElementsByName('info_diyotherlink')[1].checked==true){window.open('info/OtherLink.php?classid=<?=$classid?>&id=<?=$id?>&enews=<?=$enews?>&form=add&field=info_keyid&keyid='+document.add.info_keyid.value+'&keyboard='+document.add.keyboard.value+'&title='+document.add.title.value,'','width=780,height=550,scrollbars=yes,resizable=yes');}else{alert('请先选择手动相关链接');}">手动相关链接</a> <input name="info_keyid" type="hidden" id="info_keyid" value="<?=$r[keyid]?>"></td> </tr> <?php } ?> </table> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5"> <tr> <td>所属专题</td> </tr> <tr> <td height="25" bgcolor="#FFFFFF"><a href="#empirecms" onclick="window.open('special/PushToZt.php?sinfo=1&classid=<?=$classid?>&id=<?=$id?>','PushToZt','width=360,height=500,scrollbars=yes,left=300,top=150,resizable=yes');">点击选择信息所属专题</a></td> </tr> </table> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5"> <tr> <td>定时发布</td> </tr> <tr> <td height="25" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td>上线时间: <input name="info_infouptime" type="text" id="info_infouptime" value="<?=$voter[infouptime]?date('Y-m-d H:i:s',$voter[infouptime]):''?>"> [<a href="#empirecms" onclick="document.add.info_infouptime.value='<?=$todaytime?>'">当前时间</a>]</td> </tr> <tr> <td>下线时间: <input name="info_infodowntime" type="text" id="info_infodowntime" value="<?=$voter[infodowntime]?date('Y-m-d H:i:s',$voter[infodowntime]):''?>"> [<a href="#empirecms" onclick="document.add.info_infodowntime.value='<?=$todaytime?>'">当前时间</a>]</td> </tr> </table></td> </tr> </table> <?php if($wfinfor[checktno]==101) { ?> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5"> <tr> <td>信息送审</td> </tr> <tr> <td height="25" bgcolor="#FFFFFF"><input name="reworkflow" type="checkbox" value="1"> 重新送审<font color="#333333">(信息被返工后,修改后可选择重新送审)</font> </td> </tr> </table> <?php } ?> <?=$copyclassids?> </td> </tr> </table> </div> <div class="tab-page" id="votesetting"> <h2 class="tab"> <font class=tabcolor>投票设置</font> </h2> <script type="text/javascript">tb1.addTabPage( document.getElementById( "votesetting" ) );</script> <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder"> <tr class="header"> <td height="25" colspan="2">投票设置</td> </tr> <tr bgcolor="#FFFFFF"> <td width="21%" height="25">主题标题</td> <td width="79%" height="25"> <input name="vote_title" type="text" size="60" value="<?=$voter[title]?>"> </td> </tr> <tr bgcolor="#FFFFFF"> <td height="25" valign="top">投票项目</td> <td height="25"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr bgcolor="#DBEAF5"> <td width="9%" height="20"> <div align="center">编号</div></td> <td width="65%"> <div align="center">项目名称</div></td> <td width="26%"> <div align="center">投票数</div></td> </tr> </table> <?php if(($voter['id']&&$voter[votetext])||$definfovoteid) { echo"$allvote"; } else { ?> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td height="24" width="9%"> <div align="center">1</div></td> <td height="24" width="65%"> <div align="center"> <input name="vote_name[]" type="text" size="30"> </div></td> <td height="24" width="26%"> <div align="center"> <input name="vote_num[]" type="text" value="0" size="6"> </div></td> </tr> <tr> <td height="24"> <div align="center">2</div></td> <td height="24"> <div align="center"> <input name="vote_name[]" type="text" size="30"> </div></td> <td height="24"> <div align="center"> <input name="vote_num[]" type="text" value="0" size="6"> </div></td> </tr> <tr> <td height="24"> <div align="center">3</div></td> <td height="24"> <div align="center"> <input name="vote_name[]" type="text" size="30"> </div></td> <td height="24"> <div align="center"> <input name="vote_num[]" type="text" value="0" size="6"> </div></td> </tr> <tr> <td height="24"> <div align="center">4</div></td> <td height="24"> <div align="center"> <input name="vote_name[]" type="text" size="30"> </div></td> <td height="24"> <div align="center"> <input name="vote_num[]" type="text" value="0" size="6"> </div></td> </tr> <tr> <td height="24"> <div align="center">5</div></td> <td height="24"> <div align="center"> <input name="vote_name[]" type="text" size="30"> </div></td> <td height="24"> <div align="center"> <input name="vote_num[]" type="text" value="0" size="6"> </div></td> </tr> <tr> <td height="24"> <div align="center">6</div></td> <td height="24"> <div align="center"> <input name="vote_name[]" type="text" size="30"> </div></td> <td height="24"> <div align="center"> <input name="vote_num[]" type="text" value="0" size="6"> </div></td> </tr> <tr> <td height="24"> <div align="center">7</div></td> <td height="24"> <div align="center"> <input name="vote_name[]" type="text" size="30"> </div></td> <td height="24"> <div align="center"> <input name="vote_num[]" type="text" value="0" size="6"> </div></td> </tr> <tr> <td height="24"> <div align="center">8</div></td> <td height="24"> <div align="center"> <input name="vote_name[]" type="text" size="30"> </div></td> <td height="24"> <div align="center"> <input name="vote_num[]" type="text" value="0" size="6"> </div></td> </tr> </table> <?php } ?> </td> </tr> <tr> <td>投票扩展数量: <input name="v_vote_num" type="text" value="1" size="6"> <input type="button" name="Submit52" value="输出地址" onclick="javascript:dovoteadd();"> <input name="v_editnum" type="hidden" value="<?=$voteeditnum?>"> </td> </tr> <tr> <td id="addvote"></td> </tr> </table></td> </tr> <tr bgcolor="#FFFFFF"> <td height="25">投票类型</td> <td height="25"><input name="vote_class" type="radio" value="0"<?=$voter['voteclass']==0?' checked':''?>> 单选 <input type="radio" name="vote_class" value="1"<?=$voter['voteclass']==1?' checked':''?>> 多选</td> </tr> <tr bgcolor="#FFFFFF"> <td height="25">限制IP</td> <td height="25"><input type="radio" name="dovote_ip" value="0"<?=$voter['doip']==0?' checked':''?>> 不限制 <input name="dovote_ip" type="radio" value="1"<?=$voter['doip']==1?' checked':''?>> 限制(限制后同一IP只能投一次票)</td> </tr> <tr bgcolor="#FFFFFF"> <td height="25">过期时间</td> <td height="25"> <input name="vote_olddotime" type=hidden value="<?=$voter[dotime]?>"> <input name="vote_dotime" type="text" value="<?=$voter[dotime]?>" size="12" onClick="setday(this)"> (超过此期限,将不能投票,0000-00-00为不限制)</td> </tr> <tr bgcolor="#FFFFFF"> <td height="25">查看投票窗口</td> <td height="25">宽度: <input name="vote_width" type="text" value="<?=$voter[width]?>" size="6"> 高度: <input name="vote_height" type="text" value="<?=$voter[height]?>" size="6"></td> </tr> <tr bgcolor="#FFFFFF"> <td height="25">选择模板</td> <td height="25"><select name="vote_tempid"> <?=$votetemp?> </select> <input type="button" name="Submit62223" value="管理投票模板" onclick="window.open('template/ListVotetemp.php?gid=<?=$thegid?>');"> </td> </tr> </table> </div> </div> <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td width="16%"> </td> <td><input type="submit" name="addnews" value=" 提 交 "> <input type="reset" name="Submit2" value="重置"></td> </tr> </table> </form> <?=$copyclassidshowiframe?> </body> </html> <?php db_close(); $empire=null; ?> |
然后就是里面用的这个ajax.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
<?php define('EmpireCMSAdmin','1'); require("../class/connect.php"); require("../class/db_sql.php"); require("../class/functions.php"); require LoadLang("pub/fun.php"); $link=db_connect(); $empire=new mysqlquery(); $editor=1; //验证用户 $lur=is_login(); $logininid=$lur['userid']; $loginin=$lur['username']; $loginrnd=$lur['rnd']; $loginlevel=$lur['groupid']; $loginadminstyleid=$lur['adminstyleid']; //验证权限 CheckLevel($logininid,$loginin,$classid,"user"); $table_pre = 'phome_ecms_'; $enews = $_POST['enews']; $act = $_POST['act']; //期次ajax if('checkqici'==$act){ $nfid = $_POST['nfid']; //年份id $sql = "select `id`,`title` from `{$table_pre}news` where `nf` = '$nfid' order by id asc"; $query =mysql_query($sql); $html = ''; $t_qici = $_POST['t_qici']; while($rs = mysql_fetch_array($query)){ $n=''; if($rs['id']==$t_qici){$n='selected';} $html .='<option '.$n.' value="'.$rs['id'].'">'.$rs['title'].'</option>'; } echo $html; }elseif('checkml'==$act){ $mlid = $_POST['mlid']; //期次id $t_ml = $_POST['t_ml']; $sql = "select `id`,`title` from `{$table_pre}news_ml` where `qici` = '$mlid' order by id asc"; $query =mysql_query($sql); $html = ''; while($rs = mysql_fetch_array($query)){ $n=''; if($rs['id']==$t_ml){$n='selected';} $html .='<option '.$n.' value="'.$rs['id'].'">'.$rs['title'].'</option>'; } echo $html; } elseif('checkml2'==$act){ $ml2id = $_POST['ml2id']; //期次id $t_ml2 = $_POST['t_ml2']; $sql = "select `id`,`title` from `{$table_pre}news_ml2` where `qici` = '$ml2id' order by id asc"; $query =mysql_query($sql); $html = ''; while($rs = mysql_fetch_array($query)){ $n=''; if($rs['id']==$t_ml2){$n='selected';} $html .='<option '.$n.' value="'.$rs['id'].'">'.$rs['title'].'</option>'; } echo $html; } function dump($t){ echo '<pre>'; var_dump($t); echo '</pre>'; } //$sql = "select * from `{$table_pre}_{$n_m}` where `day` = '$time' order by num asc"; |
当然里面可能有些没有用到的隐含值等,也没有删,大家可以看一下。
做这样的功能,前期要先分析自己的程序或页面,需要如何建模型和表,哪个是个主线,比如我这个,主线就是杂志,其他的所有都是根据他来的,年份,目录,还有我们使用最多的文章。
程序本天成,妙手偶得之!我们只是代码的搬运工!
转载请注明:http://www.521php.com/archives/1634/?replytocom=11256
2013年12月09日 上午 9:43 phpcnc | 引用 | #1
Hello,博主,我搭建了个php社区,希望php能有个类似ruby,node的那种社区,现在社区刚刚上线,博主能帮忙介绍下吗?如果博主有兴趣加入那就更好了!地址为:http://phpcnc.org