'; _e('You have not selected a folder that you want to use as a gallery!', $wp_simpleviewer_textdomain); echo '
'; } elseif ( $wp_simpleviewer_form_option == 'create' ) { check_admin_referer($wp_simpleviewer_nonce.'create'); $wp_simpleviewer_gallery = attribute_escape($_POST['wp_simpleviewer_gallery']); $wp_simpleviewer_gallery_dir = $wp_simpleviewer_options['images_dir'].$wp_simpleviewer_gallery.'/'; $wp_simpleviewer_gallery_dir_regular = $wp_simpleviewer_gallery_dir.$wp_simpleviewer_options['folder_regular']; $wp_simpleviewer_gallery_dir_thumbnails = $wp_simpleviewer_gallery_dir.$wp_simpleviewer_options['folder_thumbnails']; $wp_simpleviewer_gallery_url_regular = $wp_simpleviewer_options['images_url'].$wp_simpleviewer_gallery.'/'.$wp_simpleviewer_options['folder_regular'].'/'; $wp_simpleviewer_gallery_url_thumbnails = $wp_simpleviewer_options['images_url'].$wp_simpleviewer_gallery.'/'.$wp_simpleviewer_options['folder_thumbnails'].'/'; $wp_simpleviewer_xmlfile_dir = $wp_simpleviewer_gallery_dir.'gallery.xml'; $wp_simpleviewer_gallery_array = wp_simpleviewer_gallery_array_from_options( $wp_simpleviewer_options, $wp_simpleviewer_gallery_url_regular, $wp_simpleviewer_gallery_url_thumbnails ); cleanup_old_files($wp_simpleviewer_xmlfile_dir, $wp_simpleviewer_gallery_dir_regular, $wp_simpleviewer_gallery_dir_thumbnails); if ( mkdir ($wp_simpleviewer_gallery_dir_regular, 0777) && mkdir ($wp_simpleviewer_gallery_dir_thumbnails, 0777) ) { //create new directories chmod ($wp_simpleviewer_gallery_dir_regular, 0777); chmod ($wp_simpleviewer_gallery_dir_thumbnails, 0777); //start update box for WordPress echo '';
//show GD imaging library version
$gdInfo = gd_info();
_e('GD library version 2 or later is required. You are running version:', $wp_simpleviewer_textdomain);
echo ' '.$gdInfo["GD Version"].'
';
if( ini_get('safe_mode') ){
_e('Safe_mode is enabled in PHP. You will most probably run into problems with the gallery creation.', $wp_simpleviewer_textdomain);
echo '
';
}
_e('Now the images and XML file for the selected folder will be created:', $wp_simpleviewer_textdomain);
echo '
';
//Open directory and add all image filenames to an array sorted by name
$directory_handle = opendir($wp_simpleviewer_gallery_dir);
$files_array = array();
while($file = readdir($directory_handle)) {
if ($file[0] != "." && $file[0] != ".." && !is_dir($wp_simpleviewer_gallery_dir.$file) ) {
if ( getExtension($file) == "jpg" || getExtension($file) == "png" || getExtension($file) == "gif" ){
array_push($files_array, array('name' => $file, 'date' => filemtime($wp_simpleviewer_gallery_dir.'/'.$file)));
} else {
echo $file.': ';
_e('This file will not be included in the gallery - it is no jpg, png or gif file');
echo '
';
}
}
} //end while readdir(...)
if ( !count($files_array) ) {
_e('The directory you selected does not contain any jpg, png or gif files. Please upload them first (and ignore the rest of the page)!', $wp_simpleviewer_textdomain);
echo '
';
} else {
usort($files_array, "wp_simpleviewer_image_sort");
/*If the plugin should hang up while it is creating the thumbs (last line on the admin is: "Now I am working on file xzy.jpg:") you
can try to uncomment the following line (remove // ) to define a new memory limit (40MB in this case). More info on the plugins FAQ.*/
//ini_set("memory_limit","40M");
foreach($files_array as $key => $file_data_array) {
//the script should not work on one image longer than 30s
@set_time_limit(30);
_e('Now I am working on file', $wp_simpleviewer_textdomain);
echo ' '.$file_data_array['name'].':
';
$filename_original = $wp_simpleviewer_gallery_dir.$file_data_array['name'];
$filename_regular = $wp_simpleviewer_gallery_dir_regular."/".$file_data_array['name'];
$filename_thumbnail = $wp_simpleviewer_gallery_dir_thumbnails."/".$file_data_array['name'];
//create regular image and thumbnail
if (!file_exists($filename_regular) && !file_exists($filename_thumbnail) ){
if (create_resized_image($filename_original, $filename_regular, false, $wp_simpleviewer_options['max_image_size'], $wp_simpleviewer_options['resizequality'])){
chmod($filename_regular,0777);
_e('I have created the regular image', $wp_simpleviewer_textdomain);
echo ' ';
if (create_resized_image($filename_original, $filename_thumbnail, true, 65, $wp_simpleviewer_options['resizequality'])){ //thumbnails are suared with 65px width/height
chmod($filename_thumbnail,0777);
_e('and the thumbnail', $wp_simpleviewer_textdomain);
echo ' ';
//and add the image to the gallery array
$wp_simpleviewer_new_image = array( "_c" => array(
"filename" => array( "_v" => $file_data_array['name'] ),
"caption" => array( "_v" => $wp_simpleviewer_options['default_download_link_text'] )
));
if ( !strcmp($wp_simpleviewer_options['default_download_link_text'], __('Filenames should be used for the captions', $wp_simpleviewer_textdomain)) ){
$wp_simpleviewer_new_image["_c"]["caption"]["_v"] = substr($file_data_array['name'], 0, strpos($file_data_array['name'], '.'));
}
wp_simpleviewer_ins2ary( $wp_simpleviewer_gallery_array["simpleviewerGallery"]["_c"]["image"], $wp_simpleviewer_new_image, $key );
_e('and now it has been added to the XML file!', $wp_simpleviewer_textdomain);
echo '
';
}
}
}
} //end for each
} //end if isset files_array
closedir($directory_handle);
wp_simpleviewer_save_gallery($wp_simpleviewer_gallery_array, $wp_simpleviewer_options, $wp_simpleviewer_gallery, $wp_simpleviewer_xmlfile_dir);
echo '
'; _e('Sorry, but I could not create the subfolders for the thumbnails.', $wp_simpleviewer_textdomain); echo '
'; _e('Now the XML file will be recreated...', $wp_simpleviewer_textdomain); wp_simpleviewer_save_gallery($wp_simpleviewer_gallery_array, $wp_simpleviewer_options, $wp_simpleviewer_gallery, $wp_simpleviewer_xmlfile_dir); echo '
|
|
|
|
|
|
|
|
|
| % | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| /> | |
|
|