get_var("SELECT COUNT(*) FROM " .IMAGES_TABLE." WHERE `img_parent` = ".$folder." AND `img_vs_folder` IN (0,1) AND `img_id` NOT IN (SELECT img_id FROM ". IMAGES_TO_ALBUMS_TABLE." WHERE gall_id = ".$id.")"); return $count; } function fgallery_get_restof_images($id, $pagenum, $per_page, $folder, $sort = 3) { global $wpdb; $cond = fgallery_sort_images_condition($sort); $images = $wpdb->get_results("SELECT * FROM ". IMAGES_TABLE. " WHERE img_id NOT IN (SELECT img_id FROM ". IMAGES_TO_ALBUMS_TABLE." WHERE gall_id = ".$id.") AND `img_parent` = ".$folder." AND `img_vs_folder` IN (0,1) ORDER BY `img_vs_folder` DESC, ".$cond." LIMIT ".($pagenum-1)*$per_page.",".$pagenum*$per_page, ARRAY_A); return $images; } function fgallery_addimage_box($id, $pagenum, $per_page, $folder) { $images = fgallery_get_restof_images($id, $pagenum, $per_page, $folder); echo fgallery_render_addimage_box($images, $id); } function fgallery_get_album_name($id) { global $wpdb; $name = $wpdb->get_row("SELECT gall_name FROM ". ALBUMS_TABLE ." WHERE gall_id =".$id, ARRAY_A); return $name['gall_name']; } function fgallery_render_addimage_box($items, $id) { if (count($items) > 0) { $output = '

'.fgallery_get_album_name($id).'

'; $output = '
'; $output .= '
'; if (isset($_GET['folder'])) { $output .= ''.__('Go up', 'fgallery').'...'; } $output .= ''; $output .= wp_nonce_field('fgallery_add_images','fgallery_add_images_to_gallery'); $output .= '
'; } else { echo 'You need to upload images for your gallery here'; } return $output; } if (!empty($_POST) && wp_verify_nonce($_POST['fgallery_add_images_to_gallery'],'fgallery_add_images')) { $ids = $_SESSION['image']; if (empty($ids)) { $ids = $_POST['image']; } $gall_id = $_POST['gall_id']; if (count($ids) > 0) { foreach ($ids as $id) { $image = fgallery_get_image($id); if ($image['img_vs_folder'] == 1) { $wpdb->insert(IMAGES_TABLE, array('img_caption' => $image['img_caption'], 'img_vs_folder' => 2, 'img_date'=>date("Y-m-d H:i:s"))); $parent = $wpdb->insert_id; $wpdb->insert(IMAGES_TO_ALBUMS_TABLE, array('img_id'=>$parent, 'gall_id'=>$gall_id, 'img_order' => 0, 'gall_folder' => 0)); $images = fgallery_get_images(1, 99999999, $image['img_id'], $sort = 3); foreach ($images as $row) { $wpdb->insert(IMAGES_TO_ALBUMS_TABLE, array('img_id'=>$row['img_id'], 'gall_id'=>$gall_id, 'img_order' => 0, 'gall_folder' => $parent)); } } elseif ($image['img_vs_folder'] == 0) { $wpdb->insert(IMAGES_TO_ALBUMS_TABLE, array('img_id'=>$id, 'gall_id'=>$gall_id, 'img_order' => 0)); } } } session_unset(); session_destroy(); ?> > <?php bloginfo('name') ?> › <?php _e('Insert Gallery', 'fgallery'); ?> — <?php _e('WordPress'); ?> > add_query_arg( 'paged', '%#%' ), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $num_pages, 'current' => $pagenum )); ?>
' . __( 'Displaying %s–%s of %s' ) . '%s', number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), number_format_i18n( min( $pagenum * $per_page, $count_posts ) ), number_format_i18n( $count_posts ), $page_links ); echo $page_links_text; ?>