| 1 |
<?php |
| 2 |
global $maxgalleria; |
| 3 |
$nextgen = $maxgalleria->nextgen; |
| 4 |
|
| 5 |
if ($nextgen->is_nextgen_installed()) { |
| 6 |
// Get all the NextGEN galleries |
| 7 |
$nextgen_galleries = $nextgen->get_nextgen_galleries(); |
| 8 |
|
| 9 |
// Get all the MaxGalleria galleries in publish, private, and draft status |
| 10 |
$args = array( |
| 11 |
'post_type' => MAXGALLERIA_POST_TYPE, |
| 12 |
'post_status' => 'publish,private,draft', |
| 13 |
'numberposts' => -1, // All of them |
| 14 |
'orderby' => 'title', |
| 15 |
'order' => 'ASC' |
| 16 |
); |
| 17 |
|
| 18 |
$maxgalleria_galleries = get_posts($args); |
| 19 |
} |
| 20 |
?> |
| 21 |
|
| 22 |
<script type="text/javascript"> |
| 23 |
jQuery(document).ready(function() { |
| 24 |
jQuery("#import_button").click(function() { |
| 25 |
// Reset the import counters |
| 26 |
jQuery.ajax({ |
| 27 |
type: "POST", |
| 28 |
url: "<?php echo admin_url('admin-ajax.php') ?>", |
| 29 |
data: "action=reset_nextgen_import" |
| 30 |
}); |
| 31 |
|
| 32 |
// Hide/show message and progress bar |
| 33 |
jQuery("#import_message").hide(); |
| 34 |
jQuery("#import_progress").show(); |
| 35 |
jQuery("#import_progress .progress .bar").css("width", "0%"); |
| 36 |
|
| 37 |
// Start the import process |
| 38 |
var form_data = jQuery("#import_form").serialize(); |
| 39 |
form_data += "&action=import_nextgen_gallery"; |
| 40 |
jQuery.ajax({ |
| 41 |
type: "POST", |
| 42 |
url: "<?php echo admin_url('admin-ajax.php') ?>", |
| 43 |
data: form_data, |
| 44 |
success: function(message) { |
| 45 |
if (message != "") { |
| 46 |
clearInterval(interval_id); |
| 47 |
jQuery("#import_message").html(message); |
| 48 |
jQuery("#import_message").show(); |
| 49 |
jQuery("#import_progress").delay(2500).slideUp(500); |
| 50 |
} |
| 51 |
} |
| 52 |
}); |
| 53 |
|
| 54 |
// Start polling |
| 55 |
interval_id = setInterval(pollImportPercent, 500); |
| 56 |
|
| 57 |
return false; |
| 58 |
}); |
| 59 |
}); |
| 60 |
|
| 61 |
function pollImportPercent() { |
| 62 |
jQuery.ajax({ |
| 63 |
type: "POST", |
| 64 |
url: "<?php echo admin_url('admin-ajax.php') ?>", |
| 65 |
data: "action=get_nextgen_import_percent", |
| 66 |
success: function(percentage) { |
| 67 |
jQuery("#import_progress .progress .bar").css("width", percentage + "%"); |
| 68 |
} |
| 69 |
}); |
| 70 |
|
| 71 |
return false; |
| 72 |
} |
| 73 |
</script> |
| 74 |
|
| 75 |
<div id="maxgalleria-admin"> |
| 76 |
<div class="wrap"> |
| 77 |
<div class="icon32"> |
| 78 |
<a href="http://maxgalleria.com" target="_blank"><img src="<?php echo MAXGALLERIA_PLUGIN_URL ?>/images/maxgalleria-icon-32.png" alt="MaxGalleria" /></a> |
| 79 |
</div> |
| 80 |
|
| 81 |
<h2 class="title"><?php _e('MaxGalleria: NextGEN Importer', 'maxgalleria') ?></h2> |
| 82 |
|
| 83 |
<div class="clear"></div> |
| 84 |
|
| 85 |
<div class="section"> |
| 86 |
<div class="inside"> |
| 87 |
<div class="import"> |
| 88 |
<?php if ($nextgen->is_nextgen_installed()) { ?> |
| 89 |
<div id="import_message" class="alert alert-success" style="display: none;"></div> |
| 90 |
|
| 91 |
<div id="import_progress" class="alert alert-info" style="display: none;"> |
| 92 |
<table> |
| 93 |
<tr> |
| 94 |
<td valign="top" width="40" rowspan="2"> |
| 95 |
<img src="<?php echo MAXGALLERIA_PLUGIN_URL ?>/images/loading.gif" style="margin-top: 3px;" /> |
| 96 |
</td> |
| 97 |
<td valign="top"> |
| 98 |
<h4><?php _e('Please wait while the images are imported from NextGEN. This may take a few minutes, depending on the number and size of the images.', 'maxgalleria') ?></h4> |
| 99 |
</td> |
| 100 |
</tr> |
| 101 |
<tr> |
| 102 |
<td valign="top"> |
| 103 |
<div class="progress"> |
| 104 |
<div class="bar" style="width: 0%;"></div> |
| 105 |
</div> |
| 106 |
</td> |
| 107 |
</tr> |
| 108 |
</table> |
| 109 |
</div> |
| 110 |
|
| 111 |
<?php if (isset($nextgen_galleries)) { ?> |
| 112 |
<form id="import_form" method="post"> |
| 113 |
<table> |
| 114 |
<tr> |
| 115 |
<td> |
| 116 |
<h4 style="margin: 0px;"><?php _e('Which NextGEN gallery do you want to import?', 'maxgalleria') ?></h4> |
| 117 |
</td> |
| 118 |
</tr> |
| 119 |
<tr> |
| 120 |
<td> |
| 121 |
<select id="nextgen_gallery_id" name="nextgen_gallery_id"> |
| 122 |
<?php |
| 123 |
foreach ($nextgen_galleries as $gallery) { |
| 124 |
$picture_count = $nextgen->get_nextgen_gallery_picture_count($gallery->gid); |
| 125 |
|
| 126 |
$number = ''; |
| 127 |
if ($picture_count == 0) { $number = __(' (0 images)', 'maxgalleria'); } |
| 128 |
if ($picture_count == 1) { $number = __(' (1 image)', 'maxgalleria'); } |
| 129 |
if ($picture_count > 1) { $number = sprintf(__(' (%d images)', 'maxgalleria'), $picture_count); } |
| 130 |
|
| 131 |
echo '<option value="' . $gallery->gid . '">' . $gallery->title . $number . '</option>'; |
| 132 |
} |
| 133 |
?> |
| 134 |
</select> |
| 135 |
</td> |
| 136 |
</tr> |
| 137 |
<tr> |
| 138 |
<td> </td> |
| 139 |
</tr> |
| 140 |
<tr> |
| 141 |
<td> |
| 142 |
<h4 style="margin: 0px;"><?php _e('Where do you want to import it?', 'maxgalleria') ?></h4> |
| 143 |
</td> |
| 144 |
</tr> |
| 145 |
<tr> |
| 146 |
<td> |
| 147 |
<input type="radio" id="maxgalleria_gallery_new" name="maxgalleria_gallery_where" value="new" checked="checked" /> |
| 148 |
<label for="maxgalleria_gallery_new"><?php _e('New MaxGalleria gallery', 'maxgalleria') ?></label> |
| 149 |
<br /> |
| 150 |
<input type="text" id="maxgalleria_gallery_title" name="maxgalleria_gallery_title" value="<?php _e('Enter gallery title', 'maxgalleria') ?>" /> |
| 151 |
|
| 152 |
<br /><br /> |
| 153 |
|
| 154 |
<input type="radio" id="maxgalleria_gallery_existing" name="maxgalleria_gallery_where" value="existing" /> |
| 155 |
<label for="maxgalleria_gallery_existing"><?php _e('Existing MaxGalleria gallery', 'maxgalleria') ?></label> |
| 156 |
|
| 157 |
<br /> |
| 158 |
|
| 159 |
<select id="maxgalleria_gallery_id" name="maxgalleria_gallery_id"> |
| 160 |
<?php foreach ($maxgalleria_galleries as $gallery) { ?> |
| 161 |
<?php |
| 162 |
$options = new MaxGalleryOptions($gallery->ID); |
| 163 |
if ($options->is_image_gallery()) { |
| 164 |
$args = array('post_parent' => $gallery->ID, 'post_type' => 'attachment', 'numberposts' => -1); |
| 165 |
$attachments = get_posts($args); |
| 166 |
|
| 167 |
$number = ''; |
| 168 |
if (count($attachments) == 0) { $number = __(' (0 images)', 'maxgalleria'); } |
| 169 |
if (count($attachments) == 1) { $number = __(' (1 image)', 'maxgalleria'); } |
| 170 |
if (count($attachments) > 1) { $number = sprintf(__(' (%d images)', 'maxgalleria'), count($attachments)); } |
| 171 |
|
| 172 |
echo '<option value="' . $gallery->ID . '">' . $gallery->post_title . $number . '</option>'; |
| 173 |
} |
| 174 |
?> |
| 175 |
<?php } ?> |
| 176 |
</select> |
| 177 |
</td> |
| 178 |
</tr> |
| 179 |
<tr> |
| 180 |
<td> </td> |
| 181 |
</tr> |
| 182 |
<tr> |
| 183 |
<td> |
| 184 |
<input type="button" class="button-primary" id="import_button" value="<?php _e('Import NextGEN Gallery', 'maxgalleria') ?>" /> |
| 185 |
</td> |
| 186 |
</tr> |
| 187 |
</table> |
| 188 |
|
| 189 |
<?php wp_nonce_field($nextgen->nonce_nextgen_importer['action'], $nextgen->nonce_nextgen_importer['name']) ?> |
| 190 |
</form> |
| 191 |
<?php } else { ?> |
| 192 |
<h4><?php _e('You do not have any NextGEN galleries.', 'maxgalleria') ?></h4> |
| 193 |
<?php } ?> |
| 194 |
<?php } else { ?> |
| 195 |
<h4><?php _e('You do not have the NextGEN Gallery plugin installed.', 'maxgalleria') ?></h4> |
| 196 |
<?php } ?> |
| 197 |
</div> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
</div> |
| 201 |
</div> |
| 202 |
|