Changeset 5759 for trunk/admin/element_set_ranks.php
- Timestamp:
- Apr 10, 2010, 3:25:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/element_set_ranks.php
r5196 r5759 85 85 // +-----------------------------------------------------------------------+ 86 86 87 $image_order_choices = array('default', 'rank', 'user_define'); 88 $image_order_choice = 'default'; 89 87 90 if (isset($_POST['submit'])) 88 91 { … … 98 101 l10n('Images manual order was saved') 99 102 ); 103 104 $image_order = null; 105 if (!empty($_POST['image_order_choice']) 106 && in_array($_POST['image_order_choice'], $image_order_choices)) 107 { 108 $image_order_choice = $_POST['image_order_choice']; 109 } 110 111 if ($image_order_choice=='user_define') 112 { 113 for ($i=1; $i<=3; $i++) 114 { 115 if ( !empty($_POST['order_field_'.$i]) ) 116 { 117 if (! empty($image_order) ) 118 { 119 $image_order .= ','; 120 } 121 $image_order .= $_POST['order_field_'.$i]; 122 if ($_POST['order_direction_'.$i]=='DESC') 123 { 124 $image_order .= ' DESC'; 125 } 126 } 127 } 128 } 129 elseif ($image_order_choice=='rank') 130 { 131 $image_order = 'rank'; 132 } 133 $query = ' 134 UPDATE '.CATEGORIES_TABLE.' SET image_order=\''.$image_order.'\' 135 WHERE id='.$page['category_id']; 136 pwg_query($query); 100 137 } 101 138 … … 109 146 $base_url = get_root_url().'admin.php'; 110 147 111 // $form_action = $base_url.'?page=element_set_global';112 113 148 $query = ' 114 SELECT uppercats149 SELECT * 115 150 FROM '.CATEGORIES_TABLE.' 116 151 WHERE id = '.$page['category_id'].' 117 152 ;'; 118 153 $category = pwg_db_fetch_assoc(pwg_query($query)); 154 155 if ($category['image_order']=='rank') 156 { 157 $image_order_choice = 'rank'; 158 } 159 elseif ($category['image_order']!='') 160 { 161 $image_order_choice = 'user_define'; 162 } 119 163 120 164 // Navigation path … … 175 219 } 176 220 221 // image order management 222 $sort_fields = array( 223 '' => '', 224 'date_creation' => l10n('Creation date'), 225 'date_available' => l10n('Post date'), 226 'average_rate' => l10n('Average rate'), 227 'hit' => l10n('Most visited'), 228 'file' => l10n('File name'), 229 'id' => 'Id', 230 'rank' => l10n('Rank'), 231 ); 232 233 $sort_directions = array( 234 'ASC' => l10n('ascending'), 235 'DESC' => l10n('descending'), 236 ); 237 238 $template->assign('image_order_field_options', $sort_fields); 239 $template->assign('image_order_direction_options', $sort_directions); 240 241 $matches = array(); 242 if ( !empty( $category['image_order'] ) ) 243 { 244 preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i', 245 $category['image_order'], $matches); 246 } 247 248 for ($i=0; $i<3; $i++) // 3 fields 249 { 250 $tpl_image_order_select = array( 251 'ID' => $i+1, 252 'FIELD' => array(''), 253 'DIRECTION' => array('ASC'), 254 ); 255 256 if ( isset($matches[1][$i]) ) 257 { 258 $tpl_image_order_select['FIELD'] = array($matches[1][$i]); 259 } 260 261 if (isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0) 262 { 263 $tpl_image_order_select['DIRECTION'] = array('DESC'); 264 } 265 $template->append( 'image_orders', $tpl_image_order_select); 266 } 267 268 $template->assign('image_order_choice', $image_order_choice); 269 270 177 271 // +-----------------------------------------------------------------------+ 178 272 // | sending html code |
Note: See TracChangeset
for help on using the changeset viewer.