robots_name = $user_agent; return $this->robots_name; }else{ return false; } } //取機器人名 function get_robots_name() { return $_robots_name; } } ?> ',$urlv='',$root=false,$self=true) * @param $TreeClass_Obj:Object 對應的TreeClass Object * @param $now_class_id:int 目前的節點id * @param $link:String 連結url * @param $spaceStr=' > ' 間格字元 * Return Array */ public static function get_TreeClass_Path($TreeClass_Obj,$now_class_id,$link,$spaceStr=' > ',$urlv='',$root=false,$self=true){ //單線取父類節點資料( 目前class id , 是否頂級class , 是否顯示目前class ) $tag_ary = VWMS_SYS_CLASS::get_Parent_Nots_Data($TreeClass_Obj,$now_class_id,$root,$self); $tags=''; if(empty($root))unset($tag_ary[0]); $class_v_Name = (!empty($urlv))?$urlv:'class'; //default if(!empty($tag_ary)){ foreach($tag_ary as $tag){ $href = $link.add_or_edit_Url_v($class_v_Name,$tag['id']); $tags .= $spaceStr.''.$tag['name'].''; } } return $tags; } // 頁碼(now頁碼,所有資料筆數,頁碼數,每頁顯示資料筆數) public static function get_page_num_data($now_page=0,$total_row=0,$view=10,$records=10){ $now_page=intval($now_page); // 預設頁碼 if(!isset($now_page)||empty($now_page))$now_page=1; // 每頁顯示筆數 $records_per_page = $records; // 取得記錄數 $total_records = $total_row; // 計算總頁數 $total_pages = ceil($total_records / $records_per_page); // 計算本頁第一筆記錄的序號 $started_record = $records_per_page * ($now_page - 1); if($total_pages <= $view) { $s_page = 1; $over_page = $total_pages; }else{ if($now_page <= 6) { $s_page = 1; $over_page = $view; }else{ $s_page = $now_page - floor($view/2); if(($now_page + $view-floor($view/2)) <= $total_pages) { $over_page = $now_page + $view-floor($view/2)-1; }else{ $s_page = $total_pages - $view+1; $over_page = $total_pages; } } } $page_ary = array(); $page_ary['pages'][] = array(); $page_ary['now_page'] = 0; $page_ary['total_page'] = 0; $page_ary['prev_page'] = 0; $page_ary['next_page'] = 0; $page_ary['start_page'] = 0; $page_ary['end_page'] = 0; $page_ary['limit_start'] = 0; $p_ary = array(); for($v=$s_page;$v<=$over_page;$v++){ $p_ary[] = $v; } $page_ary['pages'] = $p_ary; $page_ary['now_page'] = $now_page; $page_ary['total_page'] = $total_pages; $page_ary['prev_page'] = ($now_page<=1)?0:($now_page-1); $page_ary['next_page'] = ($now_page>=$total_pages)?0:($now_page+1); $page_ary['start_page'] = ($now_page<=1||$total_pages<=$view)?0:1; $page_ary['end_page'] = ($now_page>=$total_pages||$total_pages<=$view)?0:$total_pages; $page_ary['limit_start'] = $started_record; return $page_ary; // ex: $page_ary = re_page_list_index($page,1000,11,10); } //顯示頁碼 public static function echo_List_Page_Num($page_ary,$url) { $pages = $page_ary['pages']; $now_page = $page_ary['now_page']; $total_pages = $page_ary['total_page']; $prev_page = $page_ary['prev_page']; $next_page = $page_ary['next_page']; $start_page = $page_ary['start_page']; $end_page = $page_ary['end_page']; echo '
'; if($start_page!=0)echo '第一頁'; if($prev_page!=0)echo '上一頁'; if(count($pages)>1){ foreach($pages as $index=>$v ){ if( $v == $now_page){ echo ''.$v.''; }else{ echo ''.$v.''; } } } if($next_page!=0)echo '下一頁'; if($end_page!=0)echo '最終頁'; echo '
'; } //內頁頁碼 public static function echo_Content_Page_Num($page_num_ary,$url,$img_path=''){ echo '
'; if($page_num_ary['first'])echo '第一筆'; if($page_num_ary['prev'])echo '上一筆'; echo '回列表'; if($page_num_ary['next'])echo '下一筆'; if($page_num_ary['last'])echo '最終筆'; echo '
'; } public static function get_Jump_Select_Obj($vname,$Data){ $query_str = ($_GET['s']=='search')?'':$_SERVER['QUERY_STRING']; foreach($Data as $k => $v){ $Data[$k]['id'] = add_or_edit_Url_v($vname,$v['id'],$query_str); } return $Data; } public static function encode_Select_val($arr,$key){ if(!is_array($arr))self::error('function encode_Select_val() 傳入值需為Array'); foreach($arr as $k => $v){ $arr[$k][$key] = url_encode($v[$key]); } return $arr; } private static function error($str){ $Error_Str = "CLASS - V_UI 錯誤事件:".$str; V_ERROR::error($Error_Str); exit; } }config = $sys_config; $this->connect(); $this->db = new DB_Handler($this->config['db_name'], $this->db_Connection); // 連資料庫類 $this->V_TEMPLATES = new V_TEMPLATES(); $this->set_brand_obj();//建立品牌Tree物件 } //資料庫連線 function connect(){ $db_host = $this->config['db_host']; $db_user = $this->config['db_user']; $db_pw = $this->config['db_pw']; $db_name = $this->config['db_name']; $this->db_Connection = mysql_pconnect($db_host,$db_user,$db_pw) or trigger_error(mysql_error(),E_USER_ERROR); } //建立品牌Tree物件 function set_brand_obj(){ $this->brand_Tree_Obj = new TreeClass($this->db_Connection,$this->config['db_name'],'brand_class','不分類',_SYS_LANGUAGE); //建立關聯資料表&對應欄位 $this->brand_Tree_Obj->setLinkTable(array( array('tableName'=>'product','field'=>'brand'), )); } public function error($str='發生錯誤不明錯誤!'){ trigger_error($str, E_USER_ERROR); // 發送錯誤事件 exit; } // 頁面失敗處理(使用者,返回上一頁) function failed($str='發生錯誤不明錯誤!'){ alert_And_Back($str); exit; } }