Changeset 288 for trunk/includes/global_function.php
- Timestamp:
- Dec 22, 2009, 1:10:06 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/global_function.php
r286 r288 87 87 'Output' => $Result, 88 88 )); 89 } 90 91 $OrderDirSQL = array('ASC', 'DESC'); 92 $OrderArrowImage = array('sort_asc.png', 'sort_desc.png'); 93 94 function GetOrderTableHeader($Columns, $DefaultColumn) 95 { 96 global $OrderDirSQL, $OrderArrowImage; 97 98 if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol']; 99 if(array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir']; 100 if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn; 101 if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = 0; 102 103 // Check OrderCol 104 $Found = false; 105 foreach($Columns as $Column) 106 { 107 if($Column['Name'] == $_SESSION['OrderCol']) 108 { 109 $Found = true; 110 break; 111 } 112 } 113 if($Found == false) $_SESSION['OrderCol'] = $DefaultColumn; 114 // Check OrderDir 115 if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0; 116 117 $Result = ''; 118 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 119 foreach($Columns as $Index => $Column) 120 { 121 $QueryItems['OrderCol'] = $Column['Name']; 122 $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir']; 123 if($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="images/'.$OrderArrowImage[$_SESSION['OrderDir']].'" alt="order arrow">'; 124 else $ArrowImage = ''; 125 if($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>'; 126 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>'; 127 } 128 return(array( 129 'SQL' => ' ORDER BY '.$_SESSION['OrderCol'].' '.$OrderDirSQL[$_SESSION['OrderDir']], 130 'Output' => '<tr>'.$Result.'</tr>') 131 ); 89 132 } 90 133
Note:
See TracChangeset
for help on using the changeset viewer.