Changeset 13087
- Timestamp:
- Feb 10, 2012, 10:41:08 PM (13 years ago)
- Location:
- trunk/admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/configuration.php
r13068 r13087 107 107 // image order management 108 108 $sort_fields = array( 109 '' => '', 110 'rank' => l10n('Rank'), 111 'file' => l10n('File name'), 112 'name' => l10n('Photo name'), 113 'date_creation' => l10n('Creation date'), 114 'date_available' => l10n('Post date'), 115 'rating_score' => l10n('Rating score'), 116 'hit' => l10n('Most visited'), 117 'id' => 'Id', 109 '' => '', 110 'file ASC' => l10n('file name, A → Z'), 111 'file DESC' => l10n('file name, Z → A'), 112 'name ASC' => l10n('photo title, A → Z'), 113 'name DESC' => l10n('photo title, Z → A'), 114 'date_creation DESC' => l10n('date created, new → old'), 115 'date_creation ASC' => l10n('date created, old → new'), 116 'date_available DESC' => l10n('date posted, new → old'), 117 'date_available ASC' => l10n('date posted, old → new'), 118 'rating_score DESC' => l10n('rating score, high → low'), 119 'rating_score ASC' => l10n('rating score, low → high'), 120 'hit DESC' => l10n('visits, high → low'), 121 'hit ASC' => l10n('visits, low → high'), 122 'id ASC' => l10n('numeric identifier, 1 → 9'), 123 'id DESC' => l10n('numeric identifier, 9 → 1'), 124 'rank ASC' => l10n('manual sort order'), 118 125 ); 119 120 $sort_directions = array( 121 'ASC' => l10n('ascending'), 122 'DESC' => l10n('descending'), 123 ); 126 124 127 125 128 //------------------------------ verification and registration of modifications … … 134 137 if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) ) 135 138 { 136 if ( !empty($_POST['order_by _field']) )137 { 138 $order_by = array();139 $order_by _inside_category = array();139 if ( !empty($_POST['order_by']) ) 140 { 141 // limit to the number of available parameters 142 $order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2)); 140 143 141 for ($i=0; $i<count($_POST['order_by_field']); $i++) 142 { 143 if ( $i >= (count($sort_fields)-1) ) break; // limit to the number of available parameters 144 if ( empty($_POST['order_by_field'][$i]) ) 145 { 146 array_push($page['errors'], l10n('No field selected')); 147 break; 148 } 149 else 150 { 151 // there is no rank outside categories 152 if ($_POST['order_by_field'][$i] != 'rank') 153 { 154 $order_by[] = $_POST['order_by_field'][$i].' '.$_POST['order_by_direction'][$i]; 155 } 156 $order_by_inside_category[] = $_POST['order_by_field'][$i].' '.$_POST['order_by_direction'][$i]; 157 } 158 } 144 // there is no rank outside categories 145 unset($order_by[ array_search('rank ASC', $order_by) ]); 146 159 147 // must define a default order_by if user want to order by rank only 160 148 if ( count($order_by) == 0 ) … … 165 153 $_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by); 166 154 $_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category); 167 unset($_POST['order_by_field']); 155 } 156 else 157 { 158 array_push($page['errors'], l10n('No field selected')); 168 159 } 169 160 } … … 324 315 if ( isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom']) ) 325 316 { 326 $order_by = array(array( 327 'FIELD' => '', 328 'DIRECTION' => 'ASC', 329 )); 330 317 $order_by = array(''); 331 318 $template->assign('ORDER_BY_IS_CUSTOM', true); 332 319 } … … 337 324 $order_by = str_replace('ORDER BY ', null, $order_by); 338 325 $order_by = explode(', ', $order_by); 339 foreach ($order_by as $field)340 {341 $field= explode(' ', $field);342 $out[] = array(343 'FIELD' => $field[0],344 'DIRECTION' => $field[1],345 );346 }347 $order_by = $out;348 326 } 349 327 … … 359 337 'week_starts_on_options_selected' => $conf['week_starts_on'], 360 338 'order_by' => $order_by, 361 'order_field_options' => $sort_fields, 362 'order_direction_options' => $sort_directions, 339 'order_by_options' => $sort_fields, 363 340 ) 364 341 ); -
trunk/admin/element_set_ranks.php
r13013 r13087 105 105 } 106 106 107 $image_order = null;108 107 if (!empty($_POST['image_order_choice']) 109 108 && in_array($_POST['image_order_choice'], $image_order_choices)) … … 112 111 } 113 112 113 $image_order = null; 114 114 if ($image_order_choice=='user_define') 115 115 { 116 for ($i= 1; $i<=3; $i++)116 for ($i=0; $i<3; $i++) 117 117 { 118 if ( !empty($_POST['order_field_'.$i]))118 if (!empty($_POST['image_order'][$i])) 119 119 { 120 if (! empty($image_order) ) 121 { 122 $image_order .= ','; 123 } 124 $image_order .= $_POST['order_field_'.$i]; 125 if ($_POST['order_direction_'.$i]=='DESC') 126 { 127 $image_order .= ' DESC'; 128 } 120 if (!empty($image_order)) $image_order.= ','; 121 $image_order.= $_POST['image_order'][$i]; 129 122 } 130 123 } … … 135 128 } 136 129 $query = ' 137 UPDATE '.CATEGORIES_TABLE.' SET image_order=\''.$image_order.'\' 130 UPDATE '.CATEGORIES_TABLE.' 131 SET image_order=\''.$image_order.'\' 138 132 WHERE id='.$page['category_id']; 139 133 pwg_query($query); … … 273 267 // image order management 274 268 $sort_fields = array( 275 '' => '', 276 'date_creation' => l10n('Creation date'), 277 'date_available' => l10n('Post date'), 278 'rating_score' => l10n('Rating score'), 279 'hit' => l10n('Most visited'), 280 'file' => l10n('File name'), 281 'name' => l10n('Photo name'), 282 'id' => 'Id', 283 'rank' => l10n('Rank'), 269 '' => '', 270 'file' => l10n('file name, A → Z'), 271 'file DESC' => l10n('file name, Z → A'), 272 'name' => l10n('photo title, A → Z'), 273 'name DESC' => l10n('photo title, Z → A'), 274 'date_creation DESC' => l10n('date created, new → old'), 275 'date_creation' => l10n('date created, old → new'), 276 'date_available DESC' => l10n('date posted, new → old'), 277 'date_available' => l10n('date posted, old → new'), 278 'rating_score DESC' => l10n('rating score, high → low'), 279 'rating_score' => l10n('rating score, low → high'), 280 'hit DESC' => l10n('visits, high → low'), 281 'hit' => l10n('visits, low → high'), 282 'id' => l10n('numeric identifier, 1 → 9'), 283 'id DESC' => l10n('numeric identifier, 9 → 1'), 284 'rank' => l10n('manual sort order'), 284 285 ); 285 286 286 $sort_directions = array( 287 'ASC' => l10n('ascending'), 288 'DESC' => l10n('descending'), 289 ); 290 291 $template->assign('image_order_field_options', $sort_fields); 292 $template->assign('image_order_direction_options', $sort_directions); 293 294 $matches = array(); 295 if ( !empty( $category['image_order'] ) ) 296 { 297 preg_match_all('/([a-z_]+) *(?:(asc|desc)(?:ending)?)? *(?:, *|$)/i', 298 $category['image_order'], $matches); 299 } 287 $template->assign('image_order_options', $sort_fields); 288 289 $image_order = explode(',', $category['image_order']); 300 290 301 291 for ($i=0; $i<3; $i++) // 3 fields 302 292 { 303 $tpl_image_order_select = array( 304 'ID' => $i+1, 305 'FIELD' => array(''), 306 'DIRECTION' => array('ASC'), 307 ); 308 309 if ( isset($matches[1][$i]) ) 310 { 311 $tpl_image_order_select['FIELD'] = array($matches[1][$i]); 312 } 313 314 if (isset($matches[2][$i]) and strcasecmp($matches[2][$i],'DESC')==0) 315 { 316 $tpl_image_order_select['DIRECTION'] = array('DESC'); 317 } 318 $template->append( 'image_orders', $tpl_image_order_select); 293 if ( isset($image_order[$i]) ) 294 { 295 $template->append('image_order', $image_order[$i]); 296 } 297 else 298 { 299 $template->append('image_order', ''); 300 } 319 301 } 320 302 -
trunk/admin/themes/default/template/configuration.tpl
r13024 r13087 109 109 {foreach from=$main.order_by item=order} 110 110 <span class="filter {if $ORDER_BY_IS_CUSTOM}transparent{/if}"> 111 <select name="order_by _field[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>112 {html_options options=$main.order_ field_options selected=$order.FIELD}111 <select name="order_by[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}> 112 {html_options options=$main.order_by_options selected=$order} 113 113 </select> 114 <select name="order_by_direction[]" {if $ORDER_BY_IS_CUSTOM}disabled{/if}>115 {html_options options=$main.order_direction_options selected=$order.DIRECTION }116 </select>117 114 <a class="removeFilter">{'delete'|@translate}</a> 118 115 </span> … … 129 126 {footer_script require='jquery'} 130 127 // counters for displaying of addFilter link 131 fields = {$main.order_by|@count}; max_fields = {$main.order_field_options|@count}; max_fields--;128 fields = {$main.order_by|@count}; max_fields = Math.ceil({$main.order_by_options|@count}/2); 132 129 133 130 {literal} … … 150 147 jQuery(document).ready(function () { 151 148 $('.addFilter').click(function() { 152 rel = $(this).attr('rel');153 149 $(this).prev('span.filter').clone().insertBefore($(this)); 154 $(this).prev('span.filter').children('select[name="order_by_field[]"]').val(''); 155 $(this).prev('span.filter').children('select[name="order_by_direction[]"]').val('ASC'); 150 $(this).prev('span.filter').children('select[name="order_by[]"]').val(''); 156 151 157 152 fields++; -
trunk/admin/themes/default/template/element_set_ranks.tpl
r13013 r13087 79 79 <label for="image_order_user_define">{'automatic order'|@translate}</label> 80 80 <div id="image_order_user_define_options"> 81 {foreach from=$image_order sitem=order}81 {foreach from=$image_order item=order} 82 82 <p class="field"> 83 <select name=" order_field_{$order.ID}">84 {html_options options=$image_order_ field_options selected=$order.FIELD}83 <select name="image_order[]"> 84 {html_options options=$image_order_options selected=$order} 85 85 </select> 86 <select name="order_direction_{$order.ID}">87 {html_options options=$image_order_direction_options selected=$order.DIRECTION }88 </select>89 86 </p> 90 87 {/foreach}
Note: See TracChangeset
for help on using the changeset viewer.