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

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

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


switch ($options[2]){	
case "0":  	  	 //最新
$order="order by  nsn  DESC";	
break; 
case "1":      //排序
$order="order by snid  ASC";	
break; 
case "2":      //隨機
$order="order by RAND()";
break; 



}



//$img_date = date("H:i:s");
//$xoops_theme = $GLOBALS['xoopsConfig']['theme_set'];
$dbneme="neilrandomidiom";  //資料表名稱
$where="  where  `enable` = '1'  ".$order."   limit ".$options[1]."";		

foreach($Arr=databasetablewhile($dbneme,$where) as $key=> $val){
$Arr[$key]['content']=preg_replace( "#<li[^>]*>#i", "" , $Arr[$key]['content']);
}

$block['randomidiom']=$Arr;


if(check_mobile()){
$block['randomidiomwidth']=$options[5]; 
$block['randomidiomheight']=$options[6]; 
}else{
$block['randomidiomwidth']=$options[3];
$block['randomidiomheight']=$options[4]; 
}



   
   
   
    $block['timgplay']=$options[0];

    $block['bid']=$options[7];
    $block['menuadmin']=_MB_MENUADMINBUTTON;


   
   

    return $block;
}

//區塊編輯函式
function randomidiom_block_edit($options)
{
  global $xoopsDB, $xoTheme;
  
//模組區塊載入bootstrap3	
neillibrary_bootstrap3blockscss();	

//取得變數
$op=isset($_REQUEST['op'])?$_REQUEST['op']:"";
$bid=isset($_REQUEST['bid'])?$_REQUEST['bid']:"";
	
$bid=bidnamefunction($op=$op,$bid=$bid);
  

//小語切換秒數
$options_table_form['0']=inputtext($class="",$name="options[0]",$value="".$options[0]."",$placeholder="",$id="");	

//顯示顯示按鈕數量
$options_table_form['1']=inputtext($class="",$name="options[1]",$value="".$options[1]."",$placeholder="",$id="");	
 
  	    
//排列方式
$options_table_form['2']=radioinline($class="",$name="options[2]",$text=array(_MB_SHOWTHENUMBER3,_MB_SHOWTHENUMBER4,_MB_SHOWTHENUMBER5),$checked=$options[2]); 

  
//電腦版區塊寬度
$options_table_form['3']=inputtext($class="",$name="options[3]",$value="".$options[3]."",$placeholder="",$id="");	 	

//電腦版區塊高度
$options_table_form['4']=inputtext($class="",$name="options[4]",$value="".$options[4]."",$placeholder="",$id="");	 

//手機版區塊寬度
$options_table_form['5']=inputtext($class="",$name="options[5]",$value="".$options[5]."",$placeholder="",$id="");	 	

//手機版區塊高度
$options_table_form['6']=inputtext($class="",$name="options[6]",$value="".$options[6]."",$placeholder="",$id="");	 


    $form = "{$option['js']}
  <table  class='table'>
  <tr><th>
  " . _MA_NEILRANDOMIDIOM_BLOCLS01. "
  </th><td>
".$options_table_form['0']."
  </td></tr> 	  
  	  
  <tr><th>
  " . _MA_NEILRANDOMIDIOM_BLOCLS02. "
  </th><td>
".$options_table_form['1']."
  </td></tr>
   <tr><th>
  " . _MA_NEILRANDOMIDIOM_BLOCLS03. "
  </th><td>
".$options_table_form['2']."
  </td></tr>
  	  
   <tr><th>
  " . _MA_NEILRANDOMIDIOM_BLOCLS04. "
  </th><td>
".$options_table_form['3']."
  </td></tr>	  
  	 
  	 
  <tr><th>
  " . _MA_NEILRANDOMIDIOM_BLOCLS05. "
  </th><td>
".$options_table_form['4']."
  </td></tr>	  	 
 
   <tr><th>
  " . _MA_NEILRANDOMIDIOM_BLOCLS08. "
  </th><td>
".$options_table_form['5']."
  </td></tr>
 
   <tr><th>
  " . _MA_NEILRANDOMIDIOM_BLOCLS09. "
  </th><td>
".$options_table_form['6']."
  </td></tr> 
  	  
  
  </table>
    <input type='hidden' name='options[7]'  value='".$bid."'> 	   	  
  ";
    return $form;
}
