function wppa_get_user_upload_html($alb, $width, $where = '', $mcr = false) { static $seqno; // Init $result = ''; $mocc = wppa('mocc'); $occur = wppa('occur'); // Using seqno to distinguish from different places within one occurrence because // the album no is not known when there is a selection box. if ($seqno) { $seqno++; } else { $seqno = '1'; } // Feature enabled? if (!wppa_switch('user_upload_on')) { return ''; } // Login required? if (wppa_switch('user_upload_login')) { if (!is_user_logged_in()) { return ''; } } // I should have access to this album ( $alb > 0 ). if ($alb > '0') { $album_owner = wppa_get_album_item($alb, 'owner'); if ($album_owner != wppa_get_user() && $album_owner != '--- public ---' && !wppa_have_access($alb)) { return ''; } } else { if (!wppa_have_access()) { return ''; } } // Find max files for the user $allow_me = wppa_allow_user_uploads(); if (!$allow_me) { if (wppa_switch('show_album_full')) { $result .= '<div style="clear:both"></div>' . '<span style="color:red">' . __('Max uploads reached', 'wp-photo-album-plus') . wppa_time_to_wait_html('0', true) . '</span>'; } return $result; } // Find max files for the album $allow_alb = wppa_allow_uploads($alb); if (!$allow_alb) { if (wppa_switch('show_album_full')) { $result .= '<div style="clear:both"></div>' . '<span style="color:red">' . __('Max uploads reached', 'wp-photo-album-plus') . wppa_time_to_wait_html($alb) . '</span>'; } return $result; } if (wppa_is_user_blacklisted()) { return ''; } // Find max files for the system $allow_sys = ini_get('max_file_uploads'); // THE max if ($allow_me == '-1') { $allow_me = $allow_sys; } if ($allow_alb == '-1') { $allow_alb = $allow_sys; } $max = min($allow_me, $allow_alb, $allow_sys); // In a widget or multi column responsive? $small = wppa_in_widget() == 'upload' || $mcr; // Ajax upload? $ajax_upload = wppa_switch('ajax_upload') && wppa_browser_can_html5(); // && // WINDOWS 10 / Edge bug // ! strpos( $_SERVER["HTTP_USER_AGENT"], 'Edge' ) && // ! strpos( $_SERVER["HTTP_USER_AGENT"], 'Windows NT 10.0' ); // Create the return url if ($ajax_upload) { $returnurl = wppa_switch('ajax_non_admin') ? WPPA_URL . '/wppa-ajax-front.php' : admin_url('admin-ajax.php'); $returnurl .= '?action=wppa&wppa-action=do-fe-upload'; } else { $returnurl = wppa_get_permalink(); if ($where == 'cover') { $returnurl .= 'wppa-album=' . $alb . '&wppa-cover=0&wppa-occur=' . $occur; } elseif ($where == 'thumb') { $returnurl .= 'wppa-album=' . $alb . '&wppa-cover=0&wppa-occur=' . $occur; } elseif ($where == 'widget' || $where == 'uploadbox') { } if (wppa('page')) { $returnurl .= '&wppa-page=' . wppa('page'); } $returnurl = trim($returnurl, '?'); $returnurl = wppa_trim_wppa_($returnurl); } // Make the HTML $t = $mcr ? 'mcr-' : ''; $result .= '<div style="clear:both"></div>' . '<a' . ' id="wppa-up-' . $alb . '-' . $mocc . '"' . ' class="wppa-upload-' . $where . '"' . ' onclick="' . 'jQuery( \'#wppa-file-' . $t . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-ea-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cats-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#_wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:left; cursor:pointer;' . '" >' . __('Upload Photo', 'wp-photo-album-plus') . '</a>' . '<a' . ' id="_wppa-up-' . $alb . '-' . $mocc . '"' . ' class="wppa-upload-' . $where . '"' . ' onclick="' . 'jQuery( \'#wppa-file-' . $t . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-ea-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-cats-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#_wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:right; cursor:pointer;display:none;' . '" >' . __(wppa_opt('close_text'), 'wp-photo-album-plus') . '</a>' . '<div' . ' id="wppa-file-' . $t . $alb . '-' . $mocc . '"' . ' class="wppa-file-' . $t . $mocc . '"' . ' style="width:' . $width . 'px;text-align:center;display:none; clear:both;"' . ' >' . '<form' . ' id="wppa-uplform-' . $alb . '-' . $mocc . '"' . ' action="' . $returnurl . '"' . ' method="post"' . ' enctype="multipart/form-data"' . ' >' . wppa_nonce_field('wppa-check', 'wppa-nonce', false, false, $alb); // If no album given: select one if (!$alb) { $result .= '<select' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' name="wppa-upload-album"' . ' style="float:left; max-width: ' . $width . 'px;"' . ' onchange="jQuery( \'#wppa-sel-' . $alb . '-' . $mocc . '\' ).trigger( \'onchange\' )"' . ' >' . wppa_album_select_a(array('addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true, 'path' => wppa_switch('hier_albsel'))) . '</select>' . '<br />'; } else { $result .= '<input' . ' type="hidden"' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' name="wppa-upload-album"' . ' value="' . $alb . '"' . ' />'; } // One only ? if (wppa_switch('upload_one_only') && !current_user_can('administrator')) { $result .= '<input' . ' type="file"' . ' accept="image/*"' . (wppa_switch('camera_connect') ? ' capture="capture"' : '') . ' class="wppa-user-file"' . ' style="' . 'width:auto;' . 'max-width:' . $width . ';' . 'margin:6px 0;' . 'float:left;' . __wcs('wppa-box-text') . '"' . ' id="wppa-user-upload-' . $alb . '-' . $mocc . '"' . ' name="wppa-user-upload-' . $alb . '-' . $mocc . '[]"' . ' onchange="jQuery( \'#wppa-user-submit-' . $alb . '-' . $mocc . '\' ).css( \'display\', \'block\' )"' . ' />'; } else { $result .= '<input' . ' type="file"' . ' accept="image/*"' . (wppa_switch('camera_connect') ? ' capture="capture"' : '') . ' multiple="multiple"' . ' class="wppa-user-file"' . ' style="' . 'width:auto;' . 'max-width:' . $width . ';' . 'margin:6px 0;' . 'float:left;' . __wcs('wppa-box-text') . '"' . ' id="wppa-user-upload-' . $alb . '-' . $mocc . '"' . ' name="wppa-user-upload-' . $alb . '-' . $mocc . '[]"' . ' onchange="jQuery( \'#wppa-user-submit-' . $alb . '-' . $mocc . '\' ).css( \'display\', \'block\' )"' . ' />'; } // Explanation if (!wppa_switch('upload_one_only') && !current_user_can('administrator')) { if ($max) { $result .= '<span style="font-size:10px;" >' . sprintf(_n('You may upload %d photo', 'You may upload up to %d photos at once if your browser supports HTML-5 multiple file upload', $max, 'wp-photo-album-plus'), $max) . '</span>'; $maxsize = wppa_check_memory_limit(false); if (is_array($maxsize)) { $result .= '<br />' . '<span style="font-size:10px;" >' . sprintf(__('Max photo size: %d x %d (%2.1f MegaPixel)', 'wp-photo-album-plus'), $maxsize['maxx'], $maxsize['maxy'], $maxsize['maxp'] / (1024 * 1024)) . '</span>'; } } } // Copyright notice if (wppa_switch('copyright_on')) { $result .= '<div style="clear:both;" >' . __(wppa_opt('copyright_notice'), 'wp-photo-album-plus') . '</div>'; } // Watermark if (wppa_switch('watermark_on') && wppa_switch('watermark_user')) { $result .= '<table' . ' class="wppa-watermark wppa-box-text"' . ' style="margin:0; border:0; ' . __wcs('wppa-box-text') . '"' . ' >' . '<tbody>' . '<tr valign="top" style="border: 0 none; " >' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Apply watermark file:', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<select' . ' style="margin:0; padding:0; text-align:left; width:auto; "' . ' name="wppa-watermark-file"' . ' id="wppa-watermark-file"' . ' >' . wppa_watermark_file_select() . '</select>' . '</td>' . '</tr>' . '<tr valign="top" style="border: 0 none; " >' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Position:', 'wp-photo-album-plus') . '</td>' . ($small ? '</tr><tr>' : '') . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<select' . ' style="margin:0; padding:0; text-align:left; width:auto; "' . ' name="wppa-watermark-pos"' . ' id="wppa-watermark-pos"' . ' >' . wppa_watermark_pos_select() . '</select>' . '</td>' . '</tr>' . '</tbody>' . '</table>'; } // Name if (wppa_switch('name_user')) { switch (wppa_opt('newphoto_name_method')) { case 'none': $expl = ''; break; case '2#005': $expl = __('If you leave this blank, iptc tag 005 (Graphic name) will be used as photoname if available, else the original filename will be used as photo name.', 'wp-photo-album-plus'); break; case '2#120': $expl = __('If you leave this blank, iptc tag 120 (Caption) will be used as photoname if available, else the original filename will be used as photo name.', 'wp-photo-album-plus'); break; default: $expl = __('If you leave this blank, the original filename will be used as photo name.', 'wp-photo-album-plus'); } $result .= '<div' . ' class="wppa-box-text wppa-td"' . ' style="' . 'clear:both;' . 'float:left;' . 'text-align:left;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Enter photo name', 'wp-photo-album-plus') . ' ' . '<span style="font-size:10px;" >' . $expl . '</span>' . '</div>' . '<input' . ' type="text"' . ' class="wppa-box-text wppa-file-' . $t . $mocc . '"' . ' style="padding:0; width:' . ($width - 6) . 'px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-name"' . ' />'; } // Description user fillable ? if (wppa_switch('desc_user')) { $desc = wppa_switch('apply_newphoto_desc_user') ? stripslashes(wppa_opt('newphoto_description')) : ''; $result .= '<div' . ' class="wppa-box-text wppa-td"' . ' style="clear:both; float:left; text-align:left; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Enter/modify photo description', 'wp-photo-album-plus') . '</div>' . '<textarea' . ' class="wppa-user-textarea wppa-box-text wppa-file-' . $t . $mocc . '"' . ' style="height:120px; width:' . ($width - 6) . 'px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-desc"' . ' >' . $desc . '</textarea>'; } elseif (wppa_switch('apply_newphoto_desc_user')) { $result .= '<input' . ' type="hidden"' . ' value="' . esc_attr(wppa_opt('newphoto_description')) . '"' . ' name="wppa-user-desc"' . ' />'; } // Custom fields if (wppa_switch('fe_custom_fields')) { for ($i = '0'; $i < '10'; $i++) { if (wppa_opt('custom_caption_' . $i)) { $result .= '<div' . ' class="wppa-box-text wppa-td"' . ' style="clear:both; float:left; text-align:left; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __(wppa_opt('custom_caption_' . $i), 'wp-photo-album-plus') . ': ' . (wppa_switch('custom_visible_' . $i) ? '' : ' <small><i>( ' . __('hidden', 'wp-photo-album-plus') . ' )</i></small>') . '</div>' . '<input' . ' type="text"' . ' class="wppa-box-text wppa-file-' . $t . $mocc . '"' . ' style="padding:0; width:' . ($width - 6) . 'px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-custom-' . $i . '"' . ' />'; } } } // Tags if (wppa_switch('fe_upload_tags')) { // Prepare onclick action $onc = 'wppaPrevTags(\'wppa-sel-' . $alb . '-' . $mocc . '\', \'wppa-inp-' . $alb . '-' . $mocc . '\', \'wppa-upload-album-' . $mocc . '-' . $seqno . '\', \'wppa-prev-' . $alb . '-' . $mocc . '\')'; // Open the tag enter area $result .= '<div class="wppa-box-text wppa-td" style="clear:both; float:left; text-align:left; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >'; // Selection boxes 1..3 for ($i = '1'; $i < '4'; $i++) { if (wppa_switch('up_tagselbox_on_' . $i)) { $result .= '<div style="float:left; margin-right:4px;" >' . '<small>' . __(wppa_opt('up_tagselbox_title_' . $i), 'wp-photo-album-plus') . '</small><br />' . '<select' . ' id="wppa-sel-' . $alb . '-' . $mocc . '-' . $i . '"' . ' style="float:left; margin-right: 4px;"' . ' name="wppa-user-tags-' . $i . '[]"' . (wppa_switch('up_tagselbox_multi_' . $i) ? ' multiple' : '') . ' onchange="' . $onc . '"' . ' >'; if (wppa_opt('up_tagselbox_content_' . $i)) { // List of tags supplied $tags = explode(',', wppa_opt('up_tagselbox_content_' . $i)); $result .= '<option value="" > </option>'; if (is_array($tags)) { foreach ($tags as $tag) { $result .= '<option class="wppa-sel-' . $alb . '-' . $mocc . '" value="' . $tag . '">' . $tag . '</option>'; } } } else { // All existing tags $tags = wppa_get_taglist(); $result .= '<option value="" > </option>'; if (is_array($tags)) { foreach ($tags as $tag) { $result .= '<option class="wppa-sel-' . $alb . '-' . $mocc . '" value="' . $tag['tag'] . '">' . $tag['tag'] . '</option>'; } } } $result .= '</select>' . '</div>'; } } // New tags if (wppa_switch('up_tag_input_on')) { $result .= '<div style="float:left; margin-right:4px;" >' . '<small>' . __(wppa_opt('up_tag_input_title'), 'wp-photo-album-plus') . '</small><br />' . '<input' . ' id="wppa-inp-' . $alb . '-' . $mocc . '"' . ' type="text"' . ' class="wppa-box-text"' . ' style="padding:0; width:150px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-new-tags"' . ' onchange="' . $onc . '"' . ' />' . '</div>'; } // Preview area if (wppa_switch('up_tag_preview')) { $result .= '<div style="margin:0; clear:both;" >' . __('Preview tags:', 'wp-photo-album-plus') . ' <small id="wppa-prev-' . $alb . '-' . $mocc . '"></small>' . '</div>' . '<script type="text/javascript" >jQuery( document ).ready(function() {' . $onc . '})</script>'; } // Close tag enter area $result .= '</div>'; } /* start submit section */ // Onclick submit verify album is known if (!$alb) { $onclick = ' onclick="if ( document.getElementById( \'wppa-upload-album-' . $mocc . '-' . $seqno . '\' ).value == 0 )' . ' {alert( \'' . esc_js(__('Please select an album and try again', 'wp-photo-album-plus')) . '\' );return false;}"'; } else { $onclick = ''; } // The submit button $result .= '<input' . ' type="submit"' . ' id="wppa-user-submit-' . $alb . '-' . $mocc . '"' . $onclick . ' style="display:none; margin: 6px 0; float:right; ' . __wcs('wppa-box-text') . '"' . ' class="wppa-user-submit"' . ' name="wppa-user-submit-' . $alb . '-' . $mocc . '" value="' . __('Upload photo', 'wp-photo-album-plus') . '"' . ' />' . '<div style="clear:both"></div>'; // if ajax: progression bar if ($ajax_upload) { $result .= '<div' . ' id="progress-' . $alb . '-' . $mocc . '"' . ' class="wppa-progress"' . ' style="border-color:' . wppa_opt('bcolor_upload') . '"' . ' >' . '<div id="bar-' . $alb . '-' . $mocc . '" class="wppa-bar" ></div>' . '<div id="percent-' . $alb . '-' . $mocc . '" class="wppa-percent" >0%</div >' . '</div>' . '<div id="message-' . $alb . '-' . $mocc . '" class="wppa-message" ></div>'; } /* End submit section */ // Done $result .= '</form></div>'; // Ajax upload script if ($ajax_upload) { $result .= '<script>' . 'jQuery(document).ready(function() { var options = { beforeSend: function() { jQuery("#progress-' . $alb . '-' . $mocc . '").show(); //clear everything jQuery("#bar-' . $alb . '-' . $mocc . '").width(\'0%\'); jQuery("#message-' . $alb . '-' . $mocc . '").html(""); jQuery("#percent-' . $alb . '-' . $mocc . '").html(""); }, uploadProgress: function(event, position, total, percentComplete) { jQuery("#bar-' . $alb . '-' . $mocc . '").width(percentComplete+\'%\'); if ( percentComplete < 95 ) { jQuery("#percent-' . $alb . '-' . $mocc . '").html(percentComplete+\'%\'); } else { jQuery("#percent-' . $alb . '-' . $mocc . '").html(\'Processing...\'); } }, success: function() { jQuery("#bar-' . $alb . '-' . $mocc . '").width(\'100%\'); jQuery("#percent-' . $alb . '-' . $mocc . '").html(\'Done!\'); }, complete: function(response) { jQuery("#message-' . $alb . '-' . $mocc . '").html( \'<span style="font-size: 10px;" >\'+response.responseText+\'</span>\' );' . ($where == 'thumb' ? 'document.location.reload(true)' : '') . ' }, error: function() { jQuery("#message-' . $alb . '-' . $mocc . '").html( \'<span style="color: red;" >' . __('ERROR: unable to upload files.', 'wp-photo-album-plus') . '</span>\' ); } }; jQuery("#wppa-uplform-' . $alb . '-' . $mocc . '").ajaxForm(options); }); </script>'; } return $result; }
function wppa_get_user_upload_html($xalb, $width, $where = '', $mcr = false) { global $wpdb; global $wppa_supported_video_extensions; global $wppa_supported_audio_extensions; static $seqno; static $albums_granted; $albums_created = array(); // Create granted albums only if not done yet i a previous occurance, // and an album id is given not being '0' if (wppa_is_int($xalb) && $xalb > '0') { if (!in_array($xalb, (array) $albums_granted, true)) { // This function will check if $xalb is a grant parent, // and make my subalbum if it does not already exist. $ta = wppa_grant_albums($xalb); if (!empty($ta)) { $albums_created = array_merge($albums_created, $ta); } // Remember we processed this possible grant parent $albums_granted[] = $xalb; } } elseif (wppa_is_enum($xalb)) { $temp = explode('.', wppa_expand_enum($xalb)); foreach ($temp as $t) { if (!in_array($t, (array) $albums_granted, true)) { $ta = wppa_grant_albums($t); if (!empty($ta)) { $albums_created = array_merge($albums_created, $ta); } $albums_granted[] = $t; } } } // If albums created, add them to the list, so they appear immediately $alb = $xalb; if (!empty($albums_created)) { foreach ($albums_created as $a) { $alb .= '.' . $a; } } // Init $mocc = wppa('mocc'); $occur = wppa('occur'); $yalb = str_replace('.', '', $xalb); // Open wrapper $result = '<div style="clear:both"></div>'; //<div id="fe-upl-wrap-' . $mocc . '" style="background-color:#FFC;" >'; // Using seqno to distinguish from different places within one occurrence because // the album no is not known when there is a selection box. if ($seqno) { $seqno++; } else { $seqno = '1'; } // Feature enabled? if (!wppa_switch('user_upload_on')) { return ''; } // Login required? if (wppa_switch('user_upload_login')) { if (!is_user_logged_in()) { return ''; } } elseif (!is_user_logged_in()) { $public_exist = $wpdb->get_var("SELECT COUNT(*) " . "FROM `" . WPPA_ALBUMS . "` " . "WHERE `owner` = '--- public ---' "); if (!$public_exist) { return ''; } } // Basically there are 3 possibilities for supplied album id(s) // 1. A single album // 2. '' or '0', meaning 'any' // 3. An album enumerations // // Now we are going to test if the visitor has access // Case 1. A single album. I should have access to this album ( $alb > 0 ). if (wppa_is_int($alb) && $alb > '0') { if (!wppa_have_access($alb)) { if (wppa_switch('upload_owner_only')) { return ''; } } } elseif (!$alb) { $alb = trim(wppa_alb_to_enum_children('0') . '.' . wppa_alb_to_enum_children('-1'), '.'); } // Case 3. An enumeration. Test for all albums in the enumeration, and remove the albums that he has no access to. // In this event, if a single album remains, there will not be a selectionbox, but its treated as if a single album was supplied. if (wppa_is_enum($alb)) { $albarr = explode('.', wppa_expand_enum($alb)); foreach (array_keys($albarr) as $key) { if (!wppa_have_access($albarr[$key])) { if (wppa_switch('upload_owner_only')) { unset($albarr[$key]); } } } if (empty($albarr)) { $alb = ''; } if (count($albarr) == 1) { $alb = reset($albarr); } else { $alb = $albarr; } } // If no more albums left, no access, quit this proc. if (!$alb) { return ''; } // The result is: $alb is either an album id, or an array of album ids. Always with upload access. // Find max files for the user $allow_me = wppa_allow_user_uploads(); if (!$allow_me) { if (wppa_switch('show_album_full')) { $result .= '<h6 style="color:red">' . __('Max uploads reached', 'wp-photo-album-plus') . wppa_time_to_wait_html('0', true) . '</h6>'; } return $result; } // Find max files for the album if (wppa_is_int($alb)) { $allow_alb = wppa_allow_uploads($alb); if (!$allow_alb) { if (wppa_switch('show_album_full')) { $result .= '<h6 style="color:red">' . __('Max uploads reached', 'wp-photo-album-plus') . wppa_time_to_wait_html($alb) . '</h6>'; } return $result; } } else { $allow_alb = '-1'; } if (wppa_is_user_blacklisted()) { return ''; } // Find max files for the system $allow_sys = ini_get('max_file_uploads'); // THE max if ($allow_me == '-1') { $allow_me = $allow_sys; } if ($allow_alb == '-1') { $allow_alb = $allow_sys; } $max = min($allow_me, $allow_alb, $allow_sys); // In a widget or multi column responsive? $small = wppa_in_widget() == 'upload' || $mcr; // Ajax upload? $ajax_upload = wppa_switch('ajax_upload') && wppa_browser_can_html5(); // Create the return url if ($ajax_upload) { $returnurl = wppa_switch('ajax_non_admin') ? WPPA_URL . '/wppa-ajax-front.php' : admin_url('admin-ajax.php'); $returnurl .= '?action=wppa&wppa-action=do-fe-upload'; } else { $returnurl = wppa_get_permalink(); if ($where == 'cover') { $returnurl .= 'wppa-album=' . $alb . '&wppa-cover=0&wppa-occur=' . $occur; } elseif ($where == 'thumb') { $returnurl .= 'wppa-album=' . $alb . '&wppa-cover=0&wppa-occur=' . $occur; } elseif ($where == 'widget' || $where == 'uploadbox') { } if (wppa('page')) { $returnurl .= '&wppa-page=' . wppa('page'); } $returnurl = trim($returnurl, '?'); $returnurl = wppa_trim_wppa_($returnurl); } // Make the HTML $t = $mcr ? 'mcr-' : ''; $result .= '<a' . ' id="wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '"' . ' class="wppa-upload-' . $where . ' wppa-album-cover-link"' . ' onclick="' . 'jQuery( \'#wppa-file-' . $t . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-ea-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cats-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#_wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:left; cursor:pointer;' . '" >' . __('Upload Photo', 'wp-photo-album-plus') . '</a>' . '<a' . ' id="_wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '"' . ' class="wppa-upload-' . $where . ' wppa-album-cover-link"' . ' onclick="' . 'jQuery( \'#wppa-file-' . $t . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-ea-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-cats-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#_wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:right; cursor:pointer;display:none;' . '" >' . __(wppa_opt('close_text'), 'wp-photo-album-plus') . '</a>' . '<div' . ' id="wppa-file-' . $t . str_replace('.', '-', $yalb) . '-' . $mocc . '"' . ' class=""' . ' style="width:100%;text-align:center;display:none; clear:both;"' . ' >' . '<form' . ' id="wppa-uplform-' . $yalb . '-' . $mocc . '"' . ' action="' . $returnurl . '"' . ' method="post"' . ' enctype="multipart/form-data"' . ' >' . wppa_nonce_field('wppa-check', 'wppa-nonce', false, false, $yalb); // Single Album given if (wppa_is_int($alb)) { $result .= '<input' . ' type="hidden"' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' name="wppa-upload-album"' . ' value="' . $alb . '"' . ' />'; } else { if (!is_array($alb)) { $alb = explode('.', wppa_expand_enum($alb)); } // Can an selection box be displayed? if (!wppa_opt('fe_upload_max_albums') || wppa_opt('fe_upload_max_albums') > wppa_get_uploadable_album_count($alb)) { // Below max $result .= '<select' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' name="wppa-upload-album"' . ' style="float:left; max-width: 100%;"' . ' onchange="jQuery( \'#wppa-sel-' . $yalb . '-' . $mocc . '\' ).trigger( \'onchange\' )"' . ' >' . wppa_album_select_a(array('addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true, 'path' => wppa_switch('hier_albsel'), 'checkarray' => count($alb) > 1, 'array' => $alb)) . '</select>' . '<br />'; } else { $result .= '<input' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' type="number"' . ' placeholder="' . esc_attr(__('Enter album id', 'wp-photo-album-plus')) . '"' . ' name="wppa-upload-album"' . ' style="float:left; max-width: 100%;"' . ' onchange="jQuery( \'#wppa-sel-' . $yalb . '-' . $mocc . '\' ).trigger( \'onchange\' )"' . ' />' . '<br />'; } } $one_only = wppa_switch('upload_one_only'); $multiple = !$one_only; $on_camera = wppa_switch('camera_connect'); $may_video = wppa_switch('user_upload_video_on'); $may_audio = wppa_switch('user_upload_audio_on'); $accept = '.jpg,.gif,.png'; if ($may_video) { $accept .= ',.' . implode(',.', $wppa_supported_video_extensions); } if ($may_audio) { $accept .= ',.' . implode(',.', $wppa_supported_audio_extensions); } if ($one_only) { if ($on_camera) { if ($may_video) { $value = esc_attr(__('Select Photo / Video / Camera', 'wp-photo-album-plus')); } else { $value = esc_attr(__('Select Photo / Camera', 'wp-photo-album-plus')); } } else { if ($may_video) { $value = esc_attr(__('Select Photo / Video', 'wp-photo-album-plus')); } else { $value = esc_attr(__('Select Photo', 'wp-photo-album-plus')); } } } else { if ($on_camera) { if ($may_video) { $value = esc_attr(__('Select Photos / Video / Camera', 'wp-photo-album-plus')); } else { $value = esc_attr(__('Select Photos / Camera', 'wp-photo-album-plus')); } } else { if ($may_video) { $value = esc_attr(__('Select Photos / Video', 'wp-photo-album-plus')); } else { $value = esc_attr(__('Select Photos', 'wp-photo-album-plus')); } } } $result .= '<input' . ' type="file"' . ' accept="' . $accept . '"' . ($multiple ? ' multiple="multiple"' : '') . ' style="' . 'display:none;' . '"' . ' id="wppa-user-upload-' . $yalb . '-' . $mocc . '"' . ' name="wppa-user-upload-' . $yalb . '-' . $mocc . '[]"' . ' onchange="' . 'jQuery( \'#wppa-user-submit-' . $yalb . '-' . $mocc . '\' ).css( \'display\', \'block\' );' . 'wppaDisplaySelectedFiles(\'wppa-user-upload-' . $yalb . '-' . $mocc . '\')' . '"' . ' />'; if ($on_camera) { $result .= '<script>jQuery(\'#wppa-user-upload-' . $yalb . '-' . $mocc . '\').attr(\'capture\',\'capture\')</script>'; } $result .= '<input' . ' type="button"' . ' style="width:100%;margin-top:8px;margin-bottom:8px;padding-left:0;padding-right:0;"' . ' id="wppa-user-upload-' . $yalb . '-' . $mocc . '-display"' . ' value="' . $value . '"' . ' onclick="jQuery( \'#wppa-user-upload-' . $yalb . '-' . $mocc . '\' ).click();"' . '/>'; // Explanation if (!wppa_switch('upload_one_only')) { if ($max) { $result .= '<div style="font-size:10px;" >' . sprintf(_n('You may upload %d photo', 'You may upload up to %d photos at once if your browser supports HTML-5 multiple file upload', $max, 'wp-photo-album-plus'), $max) . '</div>'; $maxsize = wppa_check_memory_limit(false); if (is_array($maxsize)) { $result .= '<div style="font-size:10px;" >' . sprintf(__('Max photo size: %d x %d (%2.1f MegaPixel)', 'wp-photo-album-plus'), $maxsize['maxx'], $maxsize['maxy'], $maxsize['maxp'] / (1024 * 1024)) . '</div>'; } } } // Copyright notice if (wppa_switch('copyright_on')) { $result .= '<div style="width:100%;clear:both;" >' . __(wppa_opt('copyright_notice'), 'wp-photo-album-plus') . '</div>'; } // Watermark if (wppa_switch('watermark_on') && wppa_switch('watermark_user')) { $result .= '<table' . ' class="wppa-watermark wppa-box-text"' . ' style="margin:0; border:0; ' . __wcs('wppa-box-text') . '"' . ' >' . '<tbody>' . '<tr valign="top" style="border: 0 none; " >' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Apply watermark file:', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<select' . ' style="margin:0; padding:0; text-align:left; width:auto; "' . ' name="wppa-watermark-file"' . ' id="wppa-watermark-file"' . ' >' . wppa_watermark_file_select() . '</select>' . '</td>' . '</tr>' . '<tr valign="top" style="border: 0 none; " >' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Position:', 'wp-photo-album-plus') . '</td>' . ($small ? '</tr><tr>' : '') . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<select' . ' style="margin:0; padding:0; text-align:left; width:auto; "' . ' name="wppa-watermark-pos"' . ' id="wppa-watermark-pos"' . ' >' . wppa_watermark_pos_select() . '</select>' . '</td>' . '</tr>' . '</tbody>' . '</table>'; } // Name if (wppa_switch('name_user')) { switch (wppa_opt('newphoto_name_method')) { case 'none': $expl = ''; break; case '2#005': $expl = __('If you leave this blank, iptc tag 005 (Graphic name) will be used as photoname if available, else the original filename will be used as photo name.', 'wp-photo-album-plus'); break; case '2#120': $expl = __('If you leave this blank, iptc tag 120 (Caption) will be used as photoname if available, else the original filename will be used as photo name.', 'wp-photo-album-plus'); break; default: $expl = __('If you leave this blank, the original filename will be used as photo name.', 'wp-photo-album-plus'); } $result .= '<h6>' . __('Photo name', 'wp-photo-album-plus') . '</h6>' . '<div style="clear:left;font-size:10px;" >' . $expl . '</div>' . '<input' . ' type="text"' . ' class="wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-name"' . ' />'; } // Description user fillable ? if (wppa_switch('desc_user')) { $desc = wppa_switch('apply_newphoto_desc_user') ? stripslashes(wppa_opt('newphoto_description')) : ''; $result .= '<h6>' . __('Photo description', 'wp-photo-album-plus') . '</h6>' . '<textarea' . ' class="wppa-user-textarea wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; height:120px; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-desc"' . ' >' . $desc . '</textarea>'; } elseif (wppa_switch('apply_newphoto_desc_user')) { $result .= '<input' . ' type="hidden"' . ' value="' . esc_attr(wppa_opt('newphoto_description')) . '"' . ' name="wppa-user-desc"' . ' />'; } // Custom fields if (wppa_switch('fe_custom_fields')) { for ($i = '0'; $i < '10'; $i++) { if (wppa_opt('custom_caption_' . $i)) { $result .= '<h6>' . __(wppa_opt('custom_caption_' . $i), 'wp-photo-album-plus') . ': ' . (wppa_switch('custom_visible_' . $i) ? '' : ' <small><i>( ' . __('hidden', 'wp-photo-album-plus') . ' )</i></small>') . '</h6>' . '<input' . ' type="text"' . ' class="wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-custom-' . $i . '"' . ' />'; } } } // Tags if (wppa_switch('fe_upload_tags')) { // Prepare onclick action $onc = 'wppaPrevTags(\'wppa-sel-' . $yalb . '-' . $mocc . '\', \'wppa-inp-' . $yalb . '-' . $mocc . '\', \'wppa-upload-album-' . $mocc . '-' . $seqno . '\', \'wppa-prev-' . $yalb . '-' . $mocc . '\')'; // Open the tag enter area $result .= '<div style="clear:both;" >'; // Selection boxes 1..3 for ($i = '1'; $i < '4'; $i++) { if (wppa_switch('up_tagselbox_on_' . $i)) { $result .= '<h6>' . __(wppa_opt('up_tagselbox_title_' . $i), 'wp-photo-album-plus') . '</h6>' . '<select' . ' id="wppa-sel-' . $yalb . '-' . $mocc . '-' . $i . '"' . ' name="wppa-user-tags-' . $i . '[]"' . (wppa_switch('up_tagselbox_multi_' . $i) ? ' multiple' : '') . ' onchange="' . $onc . '"' . ' >'; if (wppa_opt('up_tagselbox_content_' . $i)) { // List of tags supplied $tags = explode(',', wppa_opt('up_tagselbox_content_' . $i)); $result .= '<option value="" > </option>'; if (is_array($tags)) { foreach ($tags as $tag) { $result .= '<option class="wppa-sel-' . $yalb . '-' . $mocc . '" value="' . urlencode($tag) . '">' . $tag . '</option>'; } } } else { // All existing tags $tags = wppa_get_taglist(); $result .= '<option value="" > </option>'; if (is_array($tags)) { foreach ($tags as $tag) { $result .= '<option class="wppa-sel-' . $yalb . '-' . $mocc . '" value="' . urlencode($tag['tag']) . '">' . $tag['tag'] . '</option>'; } } } $result .= '</select><div style="clear:both;" ></div>'; } } // New tags if (wppa_switch('up_tag_input_on')) { $result .= '<h6>' . __(wppa_opt('up_tag_input_title'), 'wp-photo-album-plus') . '</h6>' . '<input' . ' id="wppa-inp-' . $yalb . '-' . $mocc . '"' . ' type="text"' . ' class="wppa-box-text "' . ' style="padding:0; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-new-tags"' . ' onchange="' . $onc . '"' . ' />'; } // Preview area if (wppa_switch('up_tag_preview')) { $result .= '<h6>' . __('Preview tags:', 'wp-photo-album-plus') . ' <small id="wppa-prev-' . $yalb . '-' . $mocc . '"></small>' . '</h6>' . '<script type="text/javascript" >jQuery( document ).ready(function() {' . $onc . '})</script>'; } // Close tag enter area $result .= '</div>'; } /* The Blogit section */ if (($where == 'widget' || $where == 'uploadbox') && current_user_can('edit_posts') && wppa_switch('blog_it')) { $result .= '<div style="margin-top:6px;" >' . '<input' . ' type="button"' . ' value="' . esc_attr(__('Blog it?', 'wp-photo-album-plus')) . '"' . ' onclick="jQuery(\'#wppa-blogit-' . $yalb . '-' . $mocc . '\').trigger(\'click\')"' . ' />' . ' <input' . ' type="checkbox"' . ' id="wppa-blogit-' . $yalb . '-' . $mocc . '"' . ' name="wppa-blogit"' . ' style="display:none;"' . ' onchange="if ( jQuery(this).attr(\'checked\') ) { ' . 'jQuery(\'#blog-div-' . $yalb . '-' . $mocc . '\').css(\'display\',\'block\'); ' . 'jQuery(\'#wppa-user-submit-' . $yalb . '-' . $mocc . '\').attr(\'value\', \'' . esc_js(__('Upload and blog', 'wp-photo-album-plus')) . '\'); ' . '} ' . 'else { ' . 'jQuery(\'#blog-div-' . $yalb . '-' . $mocc . '\').css(\'display\',\'none\'); ' . 'jQuery(\'#wppa-user-submit-' . $yalb . '-' . $mocc . '\').attr(\'value\', \'' . esc_js(__('Upload photo', 'wp-photo-album-plus')) . '\'); ' . '} "' . ' />' . '<div' . ' id="blog-div-' . $yalb . '-' . $mocc . '"' . ' style="display:none;"' . ' />' . '<h6>' . __('Post title:', 'wp-photo-album-plus') . '</h6>' . '<input' . ' id="wppa-blogit-title-' . $yalb . '-' . $mocc . '"' . ' type="text"' . ' class="wppa-box-text "' . ' style="padding:0; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-post-title"' . ' />' . '<h6>' . __('Text BEFORE the image:', 'wp-photo-album-plus') . '</h6>' . '<textarea' . ' id="wppa-blogit-pretext-' . $yalb . '-' . $mocc . '"' . ' name="wppa-blogit-pretext"' . ' class=wppa-user-textarea wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; height:120px; width:100%; ' . __wcs('wppa-box-text') . '"' . ' >' . '</textarea>' . '<h6>' . __('Text AFTER the image:', 'wp-photo-album-plus') . '</h6>' . '<textarea' . ' id="wppa-blogit-posttext-' . $yalb . '-' . $mocc . '"' . ' name="wppa-blogit-posttext"' . ' class=wppa-user-textarea wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; height:120px; width:100%; ' . __wcs('wppa-box-text') . '"' . '>' . '</textarea>' . '</div>' . '</div>'; } /* start submit section */ // Onclick submit verify album is known if (!$alb) { $onclick = ' onclick="if ( document.getElementById( \'wppa-upload-album-' . $mocc . '-' . $seqno . '\' ).value == 0 )' . ' {alert( \'' . esc_js(__('Please select an album and try again', 'wp-photo-album-plus')) . '\' );return false;}"'; } else { $onclick = ''; } // The submit button $result .= '<div style="height:6px;;clear:both;" ></div>' . '<input' . ' type="submit"' . ' id="wppa-user-submit-' . $yalb . '-' . $mocc . '"' . $onclick . ' style="display:none; margin: 6px 0; float:right;"' . ' class="wppa-user-submit"' . ' name="wppa-user-submit-' . $yalb . '-' . $mocc . '" value="' . esc_attr(__('Upload photo', 'wp-photo-album-plus')) . '"' . ' />' . '<div style="height:6px;clear:both;"></div>'; // if ajax: progression bar if ($ajax_upload) { $result .= '<div' . ' id="progress-' . $yalb . '-' . $mocc . '"' . ' class="wppa-progress "' . ' style="width:100%;border-color:' . wppa_opt('bcolor_upload') . '"' . ' >' . '<div id="bar-' . $yalb . '-' . $mocc . '" class="wppa-bar" ></div>' . '<div id="percent-' . $yalb . '-' . $mocc . '" class="wppa-percent" >0%</div >' . '</div>' . '<div id="message-' . $yalb . '-' . $mocc . '" class="wppa-message" ></div>'; } /* End submit section */ // Done $result .= '</form></div>'; // Ajax upload script if ($ajax_upload) { $result .= '<script>' . 'jQuery(document).ready(function() { var options = { beforeSend: function() { jQuery("#progress-' . $yalb . '-' . $mocc . '").show(); //clear everything jQuery("#bar-' . $yalb . '-' . $mocc . '").width(\'0%\'); jQuery("#message-' . $yalb . '-' . $mocc . '").html(""); jQuery("#percent-' . $yalb . '-' . $mocc . '").html(""); }, uploadProgress: function(event, position, total, percentComplete) { jQuery("#bar-' . $yalb . '-' . $mocc . '").width(percentComplete+\'%\'); if ( percentComplete < 95 ) { jQuery("#percent-' . $yalb . '-' . $mocc . '").html(percentComplete+\'%\'); } else { jQuery("#percent-' . $yalb . '-' . $mocc . '").html(\'Processing...\'); } }, success: function() { jQuery("#bar-' . $yalb . '-' . $mocc . '").width(\'100%\'); jQuery("#percent-' . $yalb . '-' . $mocc . '").html(\'Done!\'); }, complete: function(response) { jQuery("#message-' . $yalb . '-' . $mocc . '").html( \'<span style="font-size: 10px;" >\'+response.responseText+\'</span>\' );' . ($where == 'thumb' ? 'document.location.reload(true)' : '') . ' }, error: function() { jQuery("#message-' . $yalb . '-' . $mocc . '").html( \'<span style="color: red;" >' . __('ERROR: unable to upload files.', 'wp-photo-album-plus') . '</span>\' ); } }; jQuery("#wppa-uplform-' . $yalb . '-' . $mocc . '").ajaxForm(options); }); </script>'; } // Close wrapper // $result .= '</div>'; return $result; }