 
 <?php
/*
  power by JASON.ZHANG  DM建站  www.demososo.com
*/
if(!defined('IN_DEMOSOSO')) {
  exit('this is wrong page,please back to homepage');
}


 if($act=='update'){
  //pre($_POST);

 //ifhaspidname(TABLE_CATE,$abc1);

   if(@$_POST['inputmust']=='') {echo $inputmusterror.$backlist;exit;}
//--------------
$userprevi = @$_POST['userprevi'];
   // pre($userprevi); 
 //  echo count($userprevi);exit;
 
   if(count($userprevi)>0){        
        if(is_array($userprevi)) {
          $v = implode("-",$userprevi);        
        }//end is array
        $ss = "update ".TABLE_NODE." set  pidmulti='$v'  where id='$tid' $andlangbh limit 1";
          // echo $ss;exit;
         iquery($ss);
         jump($jumpv_file);
   }
   else{
     alert('出错，没有选择分类');
     jump($jumpv_file);

   }
   //----------------
 
 
 }
 else if($act=='setcatid'){
         
         $ss = "update ".TABLE_NODE." set  pid='$key'  where id='$tid' $andlangbh limit 1";
          // echo $ss;exit;
         iquery($ss);
         jump($jumpv_file);


 }
 else
 {
  //$desp=zbdesp_imgpath($row['despcan']);
 
  ?>
   <section class="content-header">
   <h1>  修改分类：   </h1>
</section>
 
 
  <form  action="<?php echo $jumpv_file; ?>&act=update" method="post" enctype="multipart/form-data">

 <table class="formtab" >
   <tr>
      <td class="treearr_select_input_catename">
   
            主类： 
            <?php 
                     echo $maincate .' - '.$catpid;
            ?>
             
      </td>
    
    </tr>
  <tr>
      <td class="treearr_select_input_catename">
   
            <p>选择父级分类：</p>
            <p class="cred">提示：如果这里没有选择父级，则父级并不会自动显示子类的文章。</p>
    
 
<?php

function echoarrhtml($tree)
{
  global $jumpv;    global $jumpv_file;   global $pidmulti;    global $pid;
   
$html = '';
foreach($tree as $vsub)
{
  
  $name =  $vsub['name']; 
  $tid=$vsub['id'];  $jsname = jsdelname($vsub['name']);
  $level=$vsub['level'];$last=$vsub['last']; 
  
  $pidname=$vsub['pidname']; 
  $pidhere=$vsub['pid'];  $sta_visiblevv=$vsub['sta_visible']; 
  
  $alias_jump=$vsub['alias_jump'];         
  $aliascc = alias($pidname,'cate');  
  
 $classv = is_int(strpos($pidmulti,$pidname))?'active':'';
 $classhidev = $sta_visiblevv<>'y'?' hidediv':'';

 $checked='';
 $class='style="padding-right:20px"';
 if(is_int(strpos($pidmulti,$pidname))) {
  $checked='checked="checked"';
  $class='style="color:red;padding-right:20px"';
 }

 
  $name = $sta_visiblevv<>'y'?$name.' &nbsp; &nbsp;[隐藏]':$name;

 

 $setcatidv2 = '<a href="'.$jumpv_file.'&act=setcatid&key='.$pidname.'" style="color:#666">设置默认</a>';
  $setcatidvv = $pidname == $pid?' <strong style="color:red">当前为默认(必须勾选)</strong>': $setcatidv2;

 
  $name =  '<input data-parid="'.$pidhere.'" type="checkbox" '.$checked.' value="'.$pidname.'" name="userprevi[]" id="'.$tid.'" size="80"><label   '.$class.' for="'.$tid.'">'.$name.'</label>';
  



  if(@$vsub['son'] == '')
  {
   $html .= '<li>├ <span  class="'.$classv.$classhidev.'" id="'.$pidname.'">'.$name.'</span>'.$setcatidvv.'</li>';  //span for js,avoid li
  }
  else
  {
   $html .= '<li>├ <span  class="'.$classv.$classhidev.'" id="'.$pidname.'">'.$name.'</span>'.$setcatidvv;
   $html .= echoarrhtml($vsub['son']);
   $html = $html."</li>";
  }
}
 return $html ? '<ul class="tree">'.$html.'</ul>' : $html ;
 // return $html;
}

 
 echo '<div class="treearr_select treenodeeditcate">';

      

  // $checked='';
  // $class='style="padding-right:20px"';

   //if(is_int(strpos($pidnamesub,$catpid))) {
   // $checked='checked="checked"';
   // $class='style="color:red;padding-right:20px"';
   //}


   //$maincate =  '<input  type="checkbox" '.$checked.' value="'.$catpid.'" name="userprevi[]" id="maincateid" size="80"><label   '.$class.' for="maincateid">'.$maincate.'</label>';
   

    echo '<ul class="treearr">'; 
        echo '<li ><span>(主类) '.$maincate.'</span>';
        
 //--------------
$sqlsub = "SELECT * from ".TABLE_CATE." where  ppid='$catpid' $andlangbh order by pos desc,id";
//echo $sqlsub;
 $rowlistsub = getall($sqlsub);
 if($rowlistsub=='no') {
  echo '<p>&nbsp;&nbsp;还没有分类，请添加...</p>';
  }
  else{

    
      $indexarr = indexingarr($rowlistsub);
      $getnewarr = getnewtreearr($indexarr);
      //pre($getnewarr);

        echo   echoarrhtml($getnewarr);
      

}

//-----------------
  echo '</li>';
echo '</ul>';

echo '</div>';


?>

 
 
      </td>
    
    </tr>

  

</table>
 
 
<div class="c tc"> 
 
 <input class="mysubmit"     type="submit" name="Submit" value="提交" /> 
     
 <?php echo $inputmust;?>

 </div>

 </form>
<?php
  }
  ?>
  