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

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


$xoTheme->addStylesheet(XOOPS_URL.'/modules/neillibrary/js/bxslider/css/jquery.bxslider.css');	

$block['setting']=neil_modulessetting($modulesid="neothemesadmin");	


//讀取neothemesconfig資料表
$configList=moduledb($dbneme="neothemesconfig",$where=" where `nsn` = '1'");
//字串轉陣列
$fieldsplit=phpconversion($conversion=$configList['field'],$type="unserialize"); 




switch ($options[1]){	
case "0":      //排序
$order="order by  nnumber  ASC";	
break; 	
case "1":  	  	 //最新
$order="order by  nsn  DESC";	
break; 
}


$dbneme="neothemesflash";  //資料表名稱
$where="  where  `enable`='1' &&  `typeval`='1'   ".$order."   limit ".$options[0]."";		
$block['content']=databasetablewhile($dbneme,$where);

$block['width']=($fieldsplit[24]+20);

$block['options']=$options;
$block['bid']=$thisvar->getVar('bid');

/*$options[3]=explode(',', $options[3]);
$block['height']=$block['setting']['themefolder']=='computer' ? $options[3][0] : $options[3][1]; 
*/

$block['illustrate']=neillibrary_textprocessing($val=$thisvar->getVar('content', 'e'),$item = "1"); //說明文字


$titleArr=cuttingfunction($cutting=xlanguagePlugin($thisvar->getVar('title')),$sign="-");	
$block['titlevar']=$block['setting']['themefolder']=='computer' ? $thisvar->getVar('title') : $titleArr['0']; // get TRUE


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



//區塊編輯函式
function neilplayer_block_edit($options,$thisvar){
global $xoopsDB, $xoTheme;
  
  
	
neillibrary_bootstrap3blockscss($typevar="3");	

//顯示數量
$blockvar['0']=inputtext($class="",$name="options[0]",$value="".$options[0]."",$placeholder="",$id="");
//顯示方式
$blockvar['1']=radioinline($class="",$name="options[1]",$text=array(_MA_NEIL_POPUPADS_BLOCK07,_MA_NEIL_POPUPADS_BLOCK08),$checked=$options[1]); 

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


/*
$options[3]=explode(',', $options[3]);
//區塊高度-電腦
$blockvar['3']['0']=inputtext($class="",$name="options[3][0]",$value="".$options[3][0]."",$placeholder="",$id="");
//區塊高度-手機
$blockvar['3']['1']=inputtext($class="",$name="options[3][1]",$value="".$options[3][1]."",$placeholder="",$id="");
*/



//相簿呈現方式
$style_Arr = array(); //建構陣列
//銷售中相簿
$i=0;
$style_Arr[$i]['id']='horizontal';  //水平滑動效果
$style_Arr[$i]['title']=_MA_NEIL_PLAYER_BLOCK4;
$i++;
$style_Arr[$i]['id']='vertical';  //垂直滑動效果
$style_Arr[$i]['title']=_MA_NEIL_PLAYER_BLOCK5;
$i++;
$style_Arr[$i]['id']='fade';  //淡入淡出效果
$style_Arr[$i]['title']=_MA_NEIL_PLAYER_BLOCK6;


//下拉選單(播放方式)
foreach($style_Arr as $key=> $val){
$blockvar['3'].=optionselect($dataid=$val['id'],$optionname=$val['title'],$oid=$options[3],$value=$val['id']);
}



//自動撥放秒數
$blockvar['4']=inputtext($class="",$name="options[4]",$value="".$options[4]."",$placeholder="",$id="");

//區塊說明文字
$blockvar['5']=inputtextarea($class="",$name="content_block",$id="",$rows="4",$cols="80",$value=$thisvar->getVar('content', 'e'));

//自動撥放
$blockvar['6']=radioinline($class="",$name="options[5]",$text=array(_MS_SHARED04,_MS_SHARED03),$checked=$options[5]); 




$form = "{$option['js']}
  <table  class='table'>
  <tr><th>
  " ._MA_NEIL_POPUPADS_BLOCK05. "
  </th><td>
  <div class='col-sm-12'>  	  
  ".$blockvar['0']."
  </div>	  
  </td></tr> 	
  	  
  <tr><th>
  " ._MA_NEIL_POPUPADS_BLOCK06. "
  </th><td>
  <div class='col-sm-12'>	  
  ".$blockvar['1']."
  </div>	  
  </td></tr>  

  <tr><th>
  " ._MS_SHARED248. "
  </th><td>
  <div class='col-sm-12'>	  
  ".$blockvar['2']."
  </div>	  
  </td></tr> 	  
 
  <tr><th>
  " ._MA_NEIL_PLAYER_BLOCK7. "
  </th><td>
  <div class='col-sm-12'>	  
  <select id=productstatus class='form-control' name='options[3]' >
  <option   data-id='' value='' >"._MA_NEIL_PLAYER_BLOCK7."</option>
  ".$blockvar['3']."
  </select>
  </div>	  
  </td></tr> 
  	  
  <tr><th>
  " ._MA_NEIL_PLAYER_BLOCK2. "
  </th><td>
  <div class='col-sm-12'>	  
  ".$blockvar['4']."
  </div>	  
  </td></tr> 

  <tr><th>
  " ._MA_NEIL_PLAYER_BLOCK8. "
  </th><td>
  <div class='col-sm-12'>	  
  ".$blockvar['6']."
  </div>	  
  </td></tr> 

  <tr>          	
  <th >"._MS_SHARED226."</th>
  <td> <div class='col-sm-12'>
  ".$blockvar['5']."	
  </div></td>   
  </tr>   	  
  	     	  	  
  </table>

";

    return $form;
}