<?php
/*
  欢迎使用DM企业建站系统，本系统由www.demososo.com开发。
 */

if (!defined('IN_DEMOSOSO')) {
    exit('this is wrong page,please back to homepage');
}
 //echo $curstyle;;


$bgcolor=$bgimg=$cssstyle=$nodebtnmore='';
$bgrepeat= 'no-repeat';
$bgposi= 'center center';
$bgsize= 'cover';
$bgattach = '';

$arrcanexcerpt =  array("name", "pidcate","template","despjj","despcontent","editor1text");

if ($act == 'update') {
  //pre($_POST);exit;
  if ($abc1 == '')  { echo '请输入标题'; exit; }
     if(@$_POST['inputmust']=='') {echo $inputmusterror.$backlist;exit;}


     $desp = zbdesp_onlyinsert($_POST['despcontent']); //note: desp and addr not use variable abc1.
     $desptext = zbdesp_onlyinsert($_POST['editor1text']);

    $template = zbdesp_onlyinsert($_POST['template']);
    $despjj = zbdesp_onlyinsert($_POST['despjj']);


    //-----------------
    //$arrcanexcerpt =  array("name", "pidcate","template","templatecur","despjj","pidstylebh");  //move top line


        $bscnt22 = '';
      if(count($_POST)>1){
              foreach ($_POST as  $k=>$v) {
                 if(strtolower($k)=='submit') break;if(strtolower($k)=='inputmust') break;
                if(in_array($k,$arrcanexcerpt))   continue;

                $bscnt22 .= $k.':##'.htmlentitdm(trim($v)).'==#==';

              }
          }
           $bscnt22 = substr($bscnt22,0,-5);
 //--------------
   $pidstylebhv = ",pidstylebh = '$ppid'";
//-----------------

$pidcate =  htmlentitdm(@$_POST['pidcate']);
if($typecur=='bknode'){
$pidcate=str_replace("\\","/",$pidcate);
$pidcate=str_replace(chr(13),"|",$pidcate);
$pidcate=str_replace(chr(32),"",$pidcate);
}

  //--------------------------
    $ss = "update " . TABLE_BLOCK . " set name='$abc1',pidcate='$pidcate',template='$template',despjj='$despjj',desp='$desp',desptext='$desptext' $pidstylebhv,blockcan='$bscnt22'  where   pidname='$pidname' $andlangbh limit 1";
         // echo $ss;exit;
        iquery($ss);
      jump($jumpvp.'&act=edit');
}


if ($act == 'insert') {

    $pidnamecur = 'vblock' . $bshou;

    if ($abc1 == '')  { echo '请输入标题'; exit; }


     if(@$_POST['inputmust']=='') {echo $inputmusterror.$backlist;exit;}
    //$desp = zbdesp_onlyinsert($_POST['despcontent']); //note: desp and addr not use variable abc1.
   // $desptext = zbdesp_onlyinsert($_POST['editor1text']);
   $template = zbdesp_onlyinsert($_POST['template']);
   $despjj = zbdesp_onlyinsert($_POST['despjj']);


    //-----------------
    //$arrcanexcerpt =  array("name", "pidcate","template","templatecur","despjj","pidstylebh");  //move top line


    $bscnt22 = '';
    if(count($_POST)>1){
            foreach ($_POST as  $k=>$v) {
               if(strtolower($k)=='submit') break;if(strtolower($k)=='inputmust') break;
              if(in_array($k,$arrcanexcerpt))   continue;

              $bscnt22 .= $k.':##'.htmlentitdm(trim($v)).'==#==';

            }
        }
         $bscnt22 = substr($bscnt22,0,-5);

//--------------------------
//$tempself = substr($template,0,5);
//$pidstylebhv = 'common';
//if($tempself=='self_') $pidstylebhv = $curstyle;
$pidstylebhv = $ppid;
//if($typecur=='bkblockdh') $pidcate = '';
//else
 $pidcate =  htmlentitdm(@$_POST['pidcate']);
      $ss = "insert into ".TABLE_BLOCK." (pid,pidname,pbh,lang,name,pidcate,template,despjj,pidstylebh,blockcan) values ('$type','$pidnamecur','$user2510','".LANG."','$abc1','$pidcate','$template','$despjj','$pidstylebhv','$bscnt22')";
      // echo $ss;exit;

    iquery($ss);
    jump($jumpvppid);
}



if($act=='add'){
  $maxline=8;
  $cus_columns=3;
  $cus_substrnum=300;
  $pidcatemulti='';
  $testimg = 'n';
   $name=$cssname=$template=$desp=$desptext=$pidcate=$namefront=$despjj =$template=$bgcolor=$blockimg=$blockimg2=$blockimg3=$linktitle=$linkurl=$bkbz1=$bkbz2=$bkbz3='';
   $jumpvinsert = $jumpvpt.'&act=insert';

}

 if($act=='edit'){
    $titleh2 = '修改';

    $name = $rowsub['name'];

    $blockimg = $rowsub['blockimg'];$blockimg2 = $rowsub['blockimg2'];$blockimg3 = $rowsub['blockimg3'];
    $pidcate = $rowsub['pidcate'];
    $pidcatemulti=str_replace("|",chr(13),$pidcate);

    $despjj = $rowsub['despjj'];
    $desp = zbdesp_imgpath($rowsub['desp']);
    $desptext = zbdesp_imgpath($rowsub['desptext']);

    $template = $rowsub['template'];

    $maxline=8;$cus_columns=3;$cus_substrnum=30;
    $testimg='n';

    $arr_can = $rowsub['blockcan'];
    $bscntarr = explode('==#==',$arr_can);
    if(count($bscntarr)>1){
      foreach ($bscntarr as   $bsvalue) {
       if(strpos($bsvalue, ':##')){
         $bsvaluearr = explode(':##',$bsvalue);
         $bsccc = $bsvaluearr[0];
         $$bsccc=$bsvaluearr[1];
       }
     }
   }

   $maxline = intval($maxline);
   $cus_columns = intval($cus_columns);

   if($typecur=='bknode') $cus_substrnum = intval($cus_substrnum);
    //$desp = zbdesp_imgpath($rowsub['desp']);
    //$desptext = zbdesp_imgpath($rowsub['desptext']);


  $jumpvinsert = $jumpvpt.'&act=update&pidname='.$pidname;
}

if($act=='add' || $act=='edit'){
?>

<form  onsubmit="javascript:return checkhere(this)" action="<?php echo $jumpvinsert; ?>" method="post" enctype="multipart/form-data">
    <table class="formtab">
        <tr>
            <td width="12%" class="tr">标题：</td>
            <td width="88%">
                <input name="name" type="text"   value="<?php echo $name; ?>" class="form-control" />
               <div class="c5"> </div>
                <?php echo $xz_must; ?>

 <?php
if($act=='edit')  {
   // if($ppid4<>'dmre') echo  adm_previewlink($pidname);
   echo  adm_previewlink($pidname);
echo  admblockid($pidname);
}
//--------------


//if($typecur=='bkblockdh') {
    //$num= num_subnode(TABLE_NODE,'pid',$pidname);

    // echo ' <a target="_blank" href="../mod_node/mod_blockdh.php?lang='.LANG.'&pid='.$pidcate.'">[管理]</a>';
    //echo '<p> <a class="but1" target="_blank" href="mod_effectnode.php?lang='.LANG.'&pid='.$pidname.'">效果区块内容管理('.$num.')</a></p>';
// }

?>
    </td>
  </tr>


  <?php
        require_once HERE_ROOT.'mod_block/plugin_cssname.php';

      ?>



 <tr style="background:#dce8f4">
            <td  class="tr">  分类标识：</td>
            <td  class="selectTOinput">

 <?php
 if($typecur=='bknode'){
 ?>
 <textarea class="form-control" rows="6" name="pidcate"><?php echo $pidcatemulti; ?></textarea>
 <?php
 }
 else{
 ?>
 <input name="pidcate" type="text"  value="<?php echo $pidcate; ?>" class="form-control" />
 <?php } ?>
 <?php echo $xz_must; ?>

<?php
if($typecur=='bknode' && MULTICATE<>'y')   echo ' <a class="needpopup" href="../mod_module/mod_showfile.php?lang='.LANG.'&file=cateid">查看分类标识></a> ';
if($typecur=='bkblockdh')  echo '<a class="needpopup" href="../mod_module/mod_showfile.php?lang='.LANG.'&file=cateideffect">查看效果区块内容标识></a> ';


?>
 <br />
<?php


if($pidcate<>''){
    if(!is_int(strpos($pidcate,'|'))){
        $catname = get_field(TABLE_CATE,'name',$pidcate,'pidname');
        if($catname=='noid') {
         if($pidcate<>'nocate') echo '<span style="color:red">分类标识不对</span>';
        }
        else {


           if($typecur=='bknode' && MULTICATE<>'y')    echo spanred($catname);
           if($typecur=='bkblockdh')    echo '<a  target="_blank" href="../mod_cateeffect/mod_blockdh.php?lang='.LANG.'&pid='.$pidcate.'">'.spanred($catname).'</a> ';


        }
    }
}



?>


   </td>
  </tr>



        <?php


        require_once HERE_ROOT.'mod_block/plugin_block_inc_template.php';
        ?>


   <tr>
            <td  class="tr">  </td>
            <td  >
            <br />
            <span class="cblue"><i class="fa fa-exclamation-triangle fa-2x"></i> 下面的参数是否在前台显示，取决于选择的效果文件</span>
            </td>
        </tr>
 <tr>
            <td  class="tr">  参数：</td>
            <td  >
            记录数：
            <input name="maxline" type="text"  value="<?php echo $maxline; ?>"  size="10" /><?php echo $xz_must; ?>
            <div class="c5"> </div>
                  列数：<select name="cus_columns">
                          <?php select_from_arr($arr_columns,$cus_columns,'');?>
                     </select>
       <?php

          if($cus_columns>$maxline) echo '<span class="cred">提示：列数大于允许的记录数。</span>';
          ?>
              <div class="c5"> </div>

              <?php
              if($typecur=='bknode'){ //摘要长度仅作用于文章区块。
              ?>
              摘要的内容长度：
                <input name="cus_substrnum" type="text"   value="<?php echo $cus_substrnum; ?>"  size="10" />
                (为整数，如果为0，则不显示摘要)
                  <div class="c5"> </div>
                  <?php
                  }
                  ?>


<div class="c5"> </div>
前台标题： <input name="namefront" type="text"  value="<?php echo $namefront; ?>"  size="30" /><?php echo $xz_maybe; ?>

                  <div class="c5"> </div>
 前台副标题：<br />
 <textarea class="form-control" rows="3" name="despjj"><?php echo $despjj; ?></textarea> <?php echo $xz_maybe; ?>
 

      </td>
   </tr>

   <?php


     if($act=='edit')    require_once HERE_ROOT.'mod_block/tpl_block_img.php';
        ?>

   <?php
if($typecur=='bknode'){
?>
   <tr>
            <td  class="tr">   显示更多的字样：</td>
            <td  >  <input name="nodebtnmore" type="text"  value="<?php echo $nodebtnmore; ?>"  size="30" /><?php echo $xz_maybe; ?>

           </td>
        </tr>
        <?php
}
?>
        <?php
        require_once HERE_ROOT.'mod_region/plugin_region_editlink.php';
        require_once HERE_ROOT.'mod_region/plugin_region_editbg.php';
        require_once HERE_ROOT.'mod_block/tpl_block_bz.php';
        ?>

        <tr>

        <tr>
            <td class="tr">内容： </td>
            <td>

           <p>
   <a class="needpopup" href="../mod_imgfj/mod_imgfj.php?pid=<?php  echo $pidname;?>&lang=<?php  echo LANG;?>" target="_blank">私有编辑器附件管理(<?php  echo num_imgfj($pidname);?>)</a>
|
<?php echo $text_imgfjlink_bjq;?>
               </p>



<?php require_once('../plugin/editor_textarea.php'); //textarea is in this file ?>

            </td>
        </tr>



            <td></td>
            <td>
                <input  class="mysubmit mysubmitbig" type="submit" name="Submit" value="提交"></td>
        </tr>
    </table>

      <?php echo $inputmust;?>

</form>

<script>
    function checkhere(thisForm) {
        if (thisForm.name.value == "")
        {
            alert("请输入标题。");
            thisForm.name.focus();
            return (false);
        }

          if (thisForm.pidcate.value == "")
        {
            alert("请输入分类标识。");
            thisForm.pidcate.focus();
            return (false);
        }
        if (thisForm.maxline.value == "")
        {
            alert("请输入记录数。");
            thisForm.maxline.focus();
            return (false);
        }
        if (thisForm.template.value == "")
        {
            alert("请输入效果文件。");
            thisForm.template.focus();
            return (false);
        }

        // return;

    }




</script>

<?php

}


?>
