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

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

$xoTheme->addScript('modules/neillibrary/js/numscroller/numscroller-1.0.js');


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


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


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

$block['items']=$block['setting']['themefolder']=='computer' ? $options[2] : 1; 
$block['options']=$options;
$block['bid']=$thisvar->getVar('bid');


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


//顯示裝置判斷
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;
}


}



//區塊編輯函式
function neildgblock_block_edit($options){
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]); 

//下拉選單(呈現方式)橫列數量
foreach(array(_MS_SHARED264,_MS_SHARED265,_MS_SHARED266,_MS_SHARED269) as $key=> $val){
$key=$key+1;	
$blockvar['2'].=optionselect($dataid=$key,$optionname=$val,$oid="".$options[2]."",$value=$key);
}

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

//滾動值增量
$blockvar['4']=inputtext($class="",$name="options[4]",$value="".$options[4]."",$placeholder="",$id="");

//滾動總秒數
$blockvar['5']=inputtext($class="",$name="options[5]",$value="".$options[5]."",$placeholder="",$id="");

$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>
  "._MA_NEIL_POPUPADS_BLOCK09."
  </th><td>
  <div class='col-sm-12'>
  <select class='form-control'  name='options[2]'>       
  ".$blockvar['2']."    	   	  	        							
  </select>
  </div>
  </td></tr>  

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

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

";

    return $form;
}