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


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

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


$dbneme="neil_textblock";  //資料表名稱
$where="  where  `enable` = '1'  ".$order."   limit ".$options[0]."";		
$neil_textblockArr=databasetablewhile($dbneme,$where); 
foreach($neil_textblockArr as $key=> $val){
$target=pagemethod($types=$neil_textblockArr[$key]['target']);		
$neil_textblockArr[$key]['target']=$target['way'];	
}


$themefolder=neil_modulessetting($modulesid="neothemesadmin",$total="");
$block['themefolder']=$themefolder['themefolder'];  
$block['neil_difference']=$themefolder['themefolder']=='computer' ? '5' : '10'; // get TRUE
$block['neil_textblockArr']=$neil_textblockArr;

$block['blockList']['bid']=$thisvar->getVar('bid');
$configvar=configvar($modulesid="neothemesadmin");
$block['illustrate']=$configvar['neothemesadmin10'];


    return $block;
}

//區塊編輯函式
function neiltextblock_block_edit($options)
{
  global $xoopsDB, $xoTheme;  

	
neillibrary_bootstrap3blockscss($typevar="3");	

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

$configvar=configvar($modulesid="neothemesadmin");

//顯示簡介數量
$options_table_form['1']=inputtext($class="",$name="options[0]",$value="".$options[0]."",$placeholder="",$id="");	
//簡介排列方式
$options_table_form['2']=radioinline($class="",$name="options[1]",$text=array(_MS_SHARED217,_MS_SHARED218,_MS_SHARED219),$checked=$options[1]); 

//區塊說明文字
$options_table_form['3']=inputtextarea($class="",$name="",$id="introductiontext",$rows="4",$cols="80",$value=$configvar['neothemesadmin10']);


 $form = "{$option['js']}
  <div class='alert alert-info' role='alert'>"._MS_SHARED216."</div>
  <table class='table table-striped'>  	  
  <tr><th>
  " . _MA_NEILNEILTEXTBLOCK_BLOCLS01. "
  </th><td>
".$options_table_form['1']."
  </td></tr> 
  <tr><th>
  " . _MS_SHARED220. "
  </th><td>
".$options_table_form['2']."
  </td></tr> 
 
               <tr>          	
        <th >"._MS_SHARED226."</th>
        <td> <div class='col-sm-12'>
    ".$options_table_form['3']."	
    <br />
           </div></td>   
      </tr>   
 
  	   
  </table>
<script src='".XOOPS_URL."/modules/neillibrary/js/ckeditor/ckeditor.js'></script>
<script>
CKEDITOR.replace('introductiontext' , {
toolbar : 'my' ,
skin: 'moono'	
	    });
</script>    	  
<script>var xoopsjsurl='".XOOPS_URL."';</script>	  	  
<script src='".XOOPS_URL."/modules/neothemesadmin/js/ajaxjs.js'></script>	  

<script>neothemesadmin_introductionblock();</script>		 	  
  ";
    return $form;
}