$category_id, 'image_id' => $id, 'rank' => ++$current_rank, ) ); } $fields = array( 'primary' => array('image_id', 'category_id'), 'update' => array('rank') ); mass_updates(IMAGE_CATEGORY_TABLE, $fields, $datas); } // +-----------------------------------------------------------------------+ // | global mode form submission | // +-----------------------------------------------------------------------+ if (isset($_POST['submit'])) { asort($_POST['rank_of_image'], SORT_NUMERIC); save_images_order( $page['category_id'], array_keys($_POST['rank_of_image']) ); array_push( $page['infos'], l10n('Images manual order was saved') ); } // +-----------------------------------------------------------------------+ // | template init | // +-----------------------------------------------------------------------+ $template->set_filenames( array('element_set_ranks' => 'element_set_ranks.tpl') ); $base_url = get_root_url().'admin.php'; // $form_action = $base_url.'?page=element_set_global'; $query = ' SELECT uppercats FROM '.CATEGORIES_TABLE.' WHERE id = '.$page['category_id'].' ;'; $category = pwg_db_fetch_assoc(pwg_query($query)); // Navigation path $navigation = get_cat_display_name_cache( $category['uppercats'], get_root_url().'admin.php?page=cat_modify&cat_id=' ); $template->assign( array( 'CATEGORIES_NAV' => $navigation, 'F_ACTION' => $base_url.get_query_string_diff(array()), ) ); // +-----------------------------------------------------------------------+ // | thumbnails | // +-----------------------------------------------------------------------+ $query = ' SELECT id, path, tn_ext, rank FROM '.IMAGES_TABLE.' JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id WHERE category_id = '.$page['category_id'].' ORDER BY rank ;'; $result = pwg_query($query); // template thumbnail initialization $current_rank = 1; while ($row = pwg_db_fetch_assoc($result)) { $src = get_thumbnail_url($row); list($thumbnail_width, $thumbnail_height) = getimagesize($src); $thumbnail_x_center = $thumbnail_width/2; $thumbnail_y_center = $thumbnail_height/2; $template->append( 'thumbnails', array( 'ID' => $row['id'], 'TN_SRC' => $src, 'RANK' => $current_rank * 10, 'CLIP_TOP' => round($thumbnail_y_center - 96/2), 'CLIP_RIGHT' => round($thumbnail_x_center + 96/2), 'CLIP_BOTTOM' => round($thumbnail_y_center + 96/2), 'CLIP_LEFT' => round($thumbnail_x_center - 96/2) ) ); $current_rank++; } // +-----------------------------------------------------------------------+ // | sending html code | // +-----------------------------------------------------------------------+ $template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_ranks'); ?>