<?php
include_once XOOPS_ROOT_PATH . "/modules/neothemesadmin/block_function.php";
include_once XOOPS_ROOT_PATH . "/modules/neillibrary/function.php";
include_once XOOPS_ROOT_PATH . "/modules/neillibrary/function/blocksfunction.php";	



function neilaboutusbox_block_show($options,$thisvar){
global $xoopsDB, $xoTheme,$xoopsModule;	


//開啟neothemesconfig資料表
$configList=moduledb($dbneme="neothemesconfig",$where=" where `nsn` = '1'");

//聯絡資訊
$block['neilaboutusbox']['aboutbox']=base64_decode($configList['aboutustext']);

//區塊位置
$block['side']=$thisvar->getVar('side');

if($block['side']=='5' || $block['side']=='9'){
$block['blockside']="side1"; //中上 中下
}else if($block['side']=='10' || $block['side']=='11' || $block['side']=='12'){
$block['blockside']="side2"; //頁尾左中右
}else if($block['side']=='3' || $block['side']=='4' || $block['side']=='7' || $block['side']=='8'){
$block['blockside']="side3"; //中間上下左右
}else if($block['side']=='0' || $block['side']=='1'){
$block['blockside']="side4"; //左右區塊
}




//圖檔
$block['neilaboutusbox']['blockimg']=XOOPS_URL."/uploads/neothemesadmin/".$options[0].".png?state=".date("H:i:s")."";

$block['setting']=neil_modulessetting($modulesid="neothemesadmin",$total="");
//bid
$block['cat_id']=$thisvar->getVar('bid');  
$block['neilaboutusbox']['url']=$options[2];

 
 
//顯示裝置判斷
foreach(explode(',', $options[3]) as  $val){
if($val=='1' && $block['setting']['themefolder']=='computer'){
return $block;
}
if($val=='2' && $block['setting']['themefolder']=='phone'){
return $block;
}
}
if(empty($options[3])){
return $block;
}
 
 
 
  //   return $block; 
}




//區塊編輯函式
function neilaboutusbox_block_edit($options)
{
  global $xoopsDB, $xoTheme;
//模組區塊載入bootstrap3	
neillibrary_bootstrap3blockscss();	
  
  
include_once XOOPS_ROOT_PATH . "/modules/neothemesadmin/class/themeset.php";
//取得變數
$op=isset($_REQUEST['op'])?$_REQUEST['op']:"";
$bid=isset($_REQUEST['bid'])?$_REQUEST['bid']:"";
	
$bid=bidnamefunction($op=$op,$bid=$bid);


//先建構class($themesetclass)
$themesetclass   = new  themesetclass;  
$topvsplit =$themesetclass-> themespublicb($variableok,$setting); 
list($variableok,$setting) = $topvsplit;

//切割$setting陣列內容
$variablesplit=cuttingfunction($cutting=$variableok,$sign=";"); 

$configList=moduledb($dbneme="neothemesconfig",$where=" where `nsn` = '1'");

$blockvar['1']=inputtextarea($class="",$name="aboutustext",$id="aboutustext",$rows="6",$cols="80",$value="".htmlspecialchars(base64_decode($configList['aboutustext'])).""); 
$blockvar['2']=typefile($multiple=false,$name="upfile[]",$id="blockimg",$class=""); 
  	
//已上傳圖黨
$blockvar['3']=XOOPS_URL."/uploads/neothemesadmin/".$options[0].".png?state=".date("H:i:s")."";


//圖檔連結位置
$blockvar['4']=inputtext($class="",$name="options[2]",$value=$options[2],$placeholder=$options[2],$id="");	

//顯示裝置
$blockvar['5']=neillibrary_displaydevice($oval=$options[3],$nameval="options[3][]");



if(file_exists(XOOPS_ROOT_PATH.'/uploads/neothemesadmin/'.$options[0].'.png')){
$imgbox="
   <tr><th >
  " . _MB_SHOWTHENUMBER22. "
  </th><td>
<img  class='thumbnail'  src='".$blockvar['3']."'> 

  </td></tr>

";
}


    $form = "{$option['js']}
    
    
    
    
    
  <table  class='table'>
  	  
  	  
   <tr><th style='width: 10%;'>
  " . _MB_SHOWTHENUMBER20. "
  </th><td>
".$blockvar['1']."
  </td></tr>
  	   
  	   
     <tr><th>
  " . _MB_SHOWTHENUMBER21. "
  </th><td>
".$blockvar['2']."
     <div class='preview'></div>  
   <div id='blockimgname' name='".$variablesplit['18'].",neothemesadmin'></div>  	 		 
  </td></tr>
  		 
  	".$imgbox."	
  		
 <input type='hidden' name='options[1]'  value='".$bid."'>     		  	   		 	   
 <tr><th>
  " . _MA_ABOUTBOX02. "
  </th><td>
".$blockvar['4']."
  </td></tr>  
  
       <tr>          	
        <th >"._MS_SHARED248."</th>
        <td> <div class='col-sm-12'>
    ".$blockvar['5']."	
    <br />
           </div></td>   
      </tr> 
  
  
  </table>
	  	  
<script src='".XOOPS_URL."/modules/neillibrary/js/ckeditor/ckeditor.js'></script>
<script>	
CKEDITOR.replace('aboutustext' , {
toolbar : 'my' ,
skin: 'moono'
	    });
</script>  
		  
<script>var xoopsjsurl='".XOOPS_URL."';</script>		  
<script src='".XOOPS_URL."/modules/neothemesadmin/js/ajaxjs.js'></script>	  
<script src='" . XOOPS_URL . "/modules/neillibrary/js/customize.js'></script>	
<script>aboutustextbtn();previewfunction();</script>		
  ";
    return $form;
}
