<?php

	
	
	
// 區塊選單遞迴函式
function neothemesadmin_leftmenureturn($categoryid="", $sortid="", $dbneme="", $sublayer="", $order2="") {
    $sublayer++;
    $menu = array(); // 新增一個陣列來儲存子層選單
    if (!empty($sortid)) {
        $namevar = $sublayer == 1 ? 'sortid' : 'of_sortid';
    } else {
        $namevar = $sublayer == 1 ? 'of_sortid' : 'sortid';
    }
    $where = "  where `categoryid` = '".$categoryid."'  &&  `".$namevar."` = '".$sortid."'  && `enable` = '1' ".$order2."";
    foreach ($sortArr = databasetablewhile($dbneme, $where) as $key => $val) {
        $menu[$sortArr[$key]['sortid']] = $sortArr[$key];
        // 檢查是否有子層選單
        $subMenu = moduledb($dbneme, "where `of_sortid` = '".$sortArr[$key]['sortid']."'");
        if (!empty($subMenu)) {
            $menu[$sortArr[$key]['sortid']]['subMenu'] = neothemesadmin_leftmenureturn($categoryid, $sortid = $sortArr[$key]['sortid'], $dbneme, $sublayer, $order2);
        }
    }
    return $menu; // 返回新的子層選單陣列
}

//間點判斷
function neothemesadmin_focus($modulesid="", $typesof="",$url="") {
global $xoopsModule;
if(!empty($xoopsModule)) $xoopsmoduleid=$xoopsModule->dirname();

if(!empty($typesof) && $modulesid==$xoopsmoduleid){
//比對網址(防外部傳參)
    // 讀取傳入網址
    $httphosturl = httphosturl();
    // 連結網址
    $url1 = urlpregmatch($url);
    // 本地端網址
    $httphosturl['url'];
    $url2 = urlpregmatch($httphosturl['url']);
    // 判斷傳入網址是否為同網站
    return strpos($url2, $url1) === 0;
}

}
	


//order函數
function orderfunction($radiogstyle,$imgstyle){
if($radiogstyle==img){ //判斷按鈕是圖片還是文字
switch ($imgstyle){	
case "random":  	  	 
$order="order by RAND()";
break; 
case "sorting":  
$order="order by  orderid ASC";
break; 
}
}else{
$order="order by  orderid ASC";
}
return $order;
}	



//target函數
function target($target){
   switch ($target){	
 case "0":   
$target = '_self';	 	 
break;		
  case "1":   
$target = '_blank';	 	 
break;
}
return $target;
}

