/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; global $wppa_opt; require_once dirname(__FILE__) . '/wppa-links.php'; require_once dirname(__FILE__) . '/wppa-styles.php'; require_once dirname(__FILE__) . '/wppa-functions.php'; require_once dirname(__FILE__) . '/wppa-thumbnails.php'; require_once dirname(__FILE__) . '/wppa-boxes-html.php'; require_once dirname(__FILE__) . '/wppa-slideshow.php'; wppa_initialize_runtime(); wppa('in_widget', 'lasten'); wppa_bump_mocc(); extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => '', 'albumenum' => '', 'timesince' => 'yes', 'display' => 'thumbs', 'includesubs' => 'no')); $widget_title = apply_filters('widget_title', $instance['title']); $page = in_array(wppa_opt('lasten_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('lasten_widget_linkpage', __('Last Ten Uploaded Photos', 'wp-photo-album-plus')); $max = wppa_opt('lasten_count'); $album = $instance['album']; $timesince = $instance['timesince']; $display = $instance['display']; $albumenum = $instance['albumenum']; $subs = $instance['includesubs'] == 'yes'; switch ($album) { case '-99': // 'Multiple see below' is a list of id, seperated by comma's $album = str_replace(',', '.', $albumenum); if ($subs) { $album = wppa_expand_enum(wppa_alb_to_enum_children($album)); } $album = str_replace('.', ',', $album); break; case '0': // ---all--- break; case '-2': // ---generic--- $albs = $wpdb->get_results("SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = '0'", ARRAY_A); $album = ''; foreach ($albs as $alb) { $album .= '.' . $alb['id']; } $album = ltrim($album, '.'); if ($subs) { $album = wppa_expand_enum(wppa_alb_to_enum_children($album)); } $album = str_replace('.', ',', $album); break; default: if ($subs) { $album = wppa_expand_enum(wppa_alb_to_enum_children($album)); $album = str_replace('.', ',', $album); } break; } $album = trim($album, ','); // Eiter look at timestamp or at date/time modified $order_by = wppa_switch('lasten_use_modified') ? 'modified' : 'timestamp'; // If you want only 'New' photos in the selection, the period must be <> 0; if (wppa_switch('lasten_limit_new') && wppa_opt('max_photo_newtime')) { $newtime = " `" . $order_by . "` >= " . (time() - wppa_opt('max_photo_newtime')); if ($album) { $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE (" . $newtime . ") AND `album` IN ( " . $album . " ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `" . $order_by . "` DESC LIMIT " . $max; } else { $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE (" . $newtime . ") AND `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `" . $order_by . "` DESC LIMIT " . $max; } } else { if ($album) { $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` IN ( " . $album . " ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `" . $order_by . "` DESC LIMIT " . $max; } else { $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `" . $order_by . "` DESC LIMIT " . $max; } } $thumbs = $wpdb->get_results($q, ARRAY_A); $widget_content = "\n" . '<!-- WPPA+ LasTen Widget start -->'; $maxw = wppa_opt('lasten_size'); $maxh = $maxw; $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5; $maxh += $lineheight; if ($timesince == 'yes') { $maxh += $lineheight; } $count = '0'; if ($thumbs) { foreach ($thumbs as $image) { $thumb = $image; // Make the HTML for current picture if ($display == 'thumbs') { $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">'; } else { $widget_content .= "\n" . '<div class="wppa-widget" >'; } if ($image) { $no_album = !$album; if ($no_album) { $tit = __('View the most recent uploaded photos', 'wp-photo-album-plus'); } else { $tit = esc_attr(__(stripslashes($image['description']))); } $link = wppa_get_imglnk_a('lasten', $image['id'], '', $tit, '', $no_album, str_replace(',', '.', $album)); $file = wppa_get_thumb_path($image['id']); $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ltthumb'); $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']); $imgevents = wppa_get_imgevents('thumb', $image['id'], true); $title = $link ? esc_attr(stripslashes($link['title'])) : ''; $widget_content .= wppa_get_the_widget_thumb('lasten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents); $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">'; if ($timesince == 'yes') { $widget_content .= "\n\t" . '<div>' . wppa_get_time_since($image[$order_by]) . '</div>'; } $widget_content .= '</div>'; } else { // No image $widget_content .= __('Photo not found', 'wp-photo-album-plus'); } $widget_content .= "\n" . '</div>'; $count++; if ($count == wppa_opt('lasten_count')) { break; } } } else { $widget_content .= __('There are no uploaded photos (yet)', 'wp-photo-album-plus'); } $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ LasTen Widget end -->'; echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; wppa('in_widget', false); }
function _wppa_comment_admin() { global $wpdb; $continue = true; // Check input wppa_vfy_arg('tab', true); wppa_vfy_arg('edit_id'); wppa_vfy_arg('wppa-page'); wppa_vfy_arg('commentid'); wppa_vfy_arg('delete_id'); if (isset($_GET['tab'])) { if ($_GET['tab'] == 'edit') { $id = $_GET['edit_id']; $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_COMMENTS . " WHERE id = %s LIMIT 1", $id), ARRAY_A); if ($comment) { ?> <div class="wrap"> <?php $iconurl = WPPA_URL . '/img/comment.png'; ?> <div id="icon-album" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> <br /> </div> <h2><?php _e('Photo Albums -> Edit Comment', 'wp-photo-album-plus'); ?> </h2> <?php $action = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments'); if (isset($_GET['wppa-page'])) { $action .= '&compage=' . strval(intval($_GET['wppa-page'])); } if (isset($_GET['commentid'])) { $action .= '&commentid=' . strval(intval($_GET['commentid'])); } ?> <form action="<?php echo $action; ?> " method="post"> <?php wp_nonce_field('$wppa_nonce', WPPA_NONCE); ?> <input type="hidden" name="edit_comment" value="<?php echo $comment['id']; ?> " /> <table class="form-table albumtable"> <tbody> <tr style="vertical-align:top" > <th> <?php $photo = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_PHOTOS . " WHERE id = %s", $comment['photo']), "ARRAY_A"); ?> <?php $url = wppa_fix_poster_ext(wppa_get_thumb_url($comment['photo']), $comment['photo']); ?> <img src="<?php echo $url; ?> " /> </th> <td> <?php echo __($photo['name']) . '<br/><br/>' . __(stripslashes($photo['description'])); ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('Photo:', 'wp-photo-album-plus'); ?> </label></th> <td><?php echo $comment['photo']; ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('Album:', 'wp-photo-album-plus'); ?> </label></th> <td><?php echo wppa_get_album_name($photo['album']); ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('User:'******'wp-photo-album-plus'); ?> </label></th> <td><input style="width:300px;" type="text" name="user" value="<?php echo $comment['user']; ?> " /></td> </tr> <tr> <th scope="row"><label ><?php _e('Email:', 'wp-photo-album-plus'); ?> </label></th> <td><input style="width:300px;" type="text" name="email" value="<?php echo $comment['email']; ?> " /></td> </tr> <tr> <th scope="row"><label><?php _e('Comment:', 'wp-photo-album-plus'); ?> </label></th> <td><textarea style="width:300px; height:150px;" name="comment"><?php echo esc_textarea(stripslashes($comment['comment'])); ?> </textarea></td> </tr> </tbody> </table> <p> <input type="submit" class="button-primary" name="wppa_submit" value="<?php _e('Save Changes', 'wp-photo-album-plus'); ?> " /> </p> </form> <?php } $continue = false; } if ($_GET['tab'] == 'delete') { $id = strval(intval($_GET['delete_id'])); $photo = $wpdb->get_var($wpdb->prepare("SELECT `photo` FROM `" . WPPA_COMMENTS . "` WHERE `id` = %s", $id)); $iret = $wpdb->query($wpdb->prepare("DELETE FROM `" . WPPA_COMMENTS . "` WHERE `id` = %s LIMIT 1", $id)); if ($iret !== false) { if (wppa_switch('search_comments')) { wppa_index_update('photo', $photo); } wppa_update_message(__('Comment deleted', 'wp-photo-album-plus')); } else { wppa_error_message('Error deleting comment'); } $continue = true; } } if ($continue) { // Update anything or do bulkaction if (isset($_POST['wppa_submit'])) { // Security check check_admin_referer('$wppa_nonce', WPPA_NONCE); // Updates $iret = true; if (isset($_POST['wppa_comadmin_show'])) { wppa_update_option('wppa_comadmin_show', $_POST['wppa_comadmin_show']); } if (isset($_POST['wppa_comadmin_linkpage'])) { wppa_update_option('wppa_comadmin_linkpage', $_POST['wppa_comadmin_linkpage']); } if (isset($_POST['wppa_comadmin_order'])) { wppa_update_option('wppa_comadmin_order', $_POST['wppa_comadmin_order']); } if (isset($_POST['edit_comment'])) { $iret = wppa_edit_comment($_POST['edit_comment']); } // Bulk actions if (isset($_POST['bulkaction'])) { switch ($_POST['bulkaction']) { case 'approveall': $coms_to_proc = $wpdb->get_results("SELECT `id` FROM `" . WPPA_COMMENTS . "` WHERE status = 'pending'", ARRAY_A); $query = "UPDATE " . WPPA_COMMENTS . " SET status = 'approved' WHERE status = 'pending'"; if ($wpdb->query($query) === false) { wppa_error_message(__('Could not bulk update status', 'wp-photo-album-plus')); $iret = false; } else { if ($coms_to_proc) { foreach ($coms_to_proc as $item) { wppa_send_comment_approved_email($item['id']); } } $iret = true; } break; case 'spamall': $query = "UPDATE " . WPPA_COMMENTS . " SET status = 'spam' WHERE status = 'pending'"; if ($wpdb->query($query) === false) { wppa_error_message(__('Could not bulk update status', 'wp-photo-album-plus')); $iret = false; } else { $iret = true; } break; case 'delspam': $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status = 'spam'"; if ($wpdb->query($query) === false) { wppa_error_message(__('Could not bulk delete spam', 'wp-photo-album-plus')); $iret = false; } break; } } if ($iret) { wppa_update_message(__('Changes Saved', 'wp-photo-album-plus')); } // Clear (super)cache wppa_clear_cache(); } // Submit // Delete trash $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status = 'trash'"; $wpdb->query($query); // Initialize normal display $wppa_comadmin_linkpage = get_option('wppa_comadmin_linkpage', '0'); if ($wppa_comadmin_linkpage) { $exists = $wpdb->get_var("SELECT `post_title` FROM `" . $wpdb->posts . "` WHERE `ID` = " . $wppa_comadmin_linkpage); if (!$exists) { $wppa_comadmin_linkpage = '0'; update_option('wppa_comadmin_linkpage', '0'); } } $moderating = isset($_REQUEST['commentid']); ?> <div class="wrap"> <?php $iconurl = WPPA_URL . '/img/comment.png'; ?> <div id="icon-album" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> <br /> </div> <h2> <?php if ($moderating) { _e('Photo Albums -> Moderate Comment', 'wp-photo-album-plus'); } else { _e('Photo Albums -> Comment admin', 'wp-photo-album-plus'); } ?> </h2> <?php if (!wppa_switch('show_comments')) { _e('<h3>The Comment system is not activated</h3><p>To activate: check Table II item 18 on the <b>Photo Albums -> Settings</b> screen and press <b>Save Changes</b>', 'wp-photo-album-plus'); } ?> <?php if (!$moderating) { ?> <!-- Statistics --> <table> <tbody> <tr> <td><h3 style="margin:0; color:#777777;"><?php _e('Total:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "`"); echo $count; ?> </h3></td> </tr> <tr> <td><h3 style="margin:0; color:green;"><?php _e('Approved:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'approved'"); echo $count; ?> </h3></td> </tr> <tr> <td><h3 style="margin:0; color:#e66f00;"><?php _e('Pending:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'pending'"); echo $count; ?> </h3></td> </tr> <tr> <td><h3 style="margin:0; color:red;"><?php _e('Spam:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'spam'"); echo $count; ?> </h3></td> </tr> <?php if (wppa_opt('spam_maxage') != 'none') { ?> <tr> <td><h3 style="margin:0; color:red;"><?php _e('Auto deleted spam:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php echo get_option('wppa_spam_auto_delcount', '0'); ?> </h3></td> </tr> <?php } ?> </tbody> </table> <!-- end statistics --> <!-- Settings --> <div style="border:1px solid #ccc; padding:4px; margin:4px 0" > <h3><?php _e('Settings', 'wp-photo-album-plus'); ?> </h3> <form action="<?php echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments'); ?> " method="post"> <p> <?php wp_nonce_field('$wppa_nonce', WPPA_NONCE); _e('Linkpage:', 'wp-photo-album-plus'); ?> <select name="wppa_comadmin_linkpage"> <option value="0" <?php if ($wppa_comadmin_linkpage == '0') { echo 'selected="selected"'; } ?> disabled="disabled" ><?php _e('--- Please select a page ---', 'wp-photo-album-plus'); ?> </option> <?php $query = "SELECT `ID`, `post_title`, `post_content` FROM `" . $wpdb->posts . "` WHERE `post_type` = 'page' AND `post_status` = 'publish' ORDER BY `post_title` ASC"; $pages = $wpdb->get_results($query, ARRAY_A); if ($pages) { foreach ($pages as $page) { if (stripos($page['post_content'], '%%wppa%%') !== false || stripos($page['post_content'], '[wppa') !== false) { if ($wppa_comadmin_linkpage == $page['ID']) { $sel = 'selected="selected"'; } else { $sel = ''; } echo '<option value="' . $page['ID'] . '" ' . $sel . '>' . __($page['post_title'], 'wp-photo-album-plus') . '</option>'; } } } ?> </select> <?php _e('You can see the photo and all its comments on the selected page by clicking on the thumbnail image', 'wp-photo-album-plus'); ?> </p> <?php $comment_show = wppa_opt('comadmin_show'); ?> <p> <?php _e('Display status:', 'wp-photo-album-plus'); ?> <select name="wppa_comadmin_show"> <option value="all" <?php if ($comment_show == 'all') { echo 'selected="selected"'; } ?> ><?php _e('all', 'wp-photo-album-plus'); ?> </option> <option value="pending" <?php if ($comment_show == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('pending', 'wp-photo-album-plus'); ?> </option> <option value="approved" <?php if ($comment_show == 'approved') { echo 'selected="selected"'; } ?> ><?php _e('approved', 'wp-photo-album-plus'); ?> </option> <option value="spam" <?php if ($comment_show == 'spam') { echo 'selected="selected"'; } ?> ><?php _e('spam', 'wp-photo-album-plus'); ?> </option> </select> <?php $comment_order = wppa_opt('comadmin_order'); ?> <?php _e('Display order:', 'wp-photo-album-plus'); ?> <select name="wppa_comadmin_order"> <option value="timestamp" <?php if ($comment_order == 'timestamp') { echo 'selected="selected"'; } ?> ><?php _e('timestamp', 'wp-photo-album-plus'); ?> </option> <option value="photo" <?php if ($comment_order == 'photo') { echo 'selected="selected"'; } ?> ><?php _e('photo', 'wp-photo-album-plus'); ?> </option> </select> <?php _e('Bulk action:', 'wp-photo-album-plus'); ?> <select name="bulkaction"> <option value=""><?php ?> </option> <option value="approveall"><?php _e('Approve all pending', 'wp-photo-album-plus'); ?> </option> <option value="spamall"><?php _e('Move all pending to spam', 'wp-photo-album-plus'); ?> </option> <option value="delspam"><?php _e('Delete all spam', 'wp-photo-album-plus'); ?> </option> </select> <input type="submit" class="button-primary" name="wppa_submit" value="<?php _e('Save Settings / Perform bulk action', 'wp-photo-album-plus'); ?> " /> </p> </form> </div> <!-- End Settings --> <?php } if ($moderating) { $pagesize = '1'; $where = " WHERE `id` = '" . $_REQUEST['commentid'] . "'"; $order = ''; $curpage = '1'; $limit = ''; } else { $pagsize = wppa_opt('comment_admin_pagesize'); $where = $comment_show == 'all' ? '' : " WHERE `status` = '" . $comment_show . "'"; $order = " ORDER BY `" . $comment_order . "`"; if ($comment_order == 'timestamp') { $order .= " DESC"; } if (isset($_GET['wppa-page'])) { $curpage = strval(intval($_GET['wppa-page'])); $offset = (strval(intval($_GET['wppa-page'])) - 1) * $pagsize; $limit = " LIMIT " . $offset . "," . $pagsize; } else { $limit = ' LIMIT 0,' . $pagsize; $curpage = '1'; } if ($pagsize == '0') { $limit = ''; } // Paginating is off $nitems = $wpdb->get_var("SELECT COUNT(*) FROM " . WPPA_COMMENTS . $where); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments'); wppa_admin_page_links($curpage, $pagsize, $nitems, $link); } ?> <table class="widefat"> <thead style="font-weight: bold" class=""> <tr> <th scope="col"><?php _e('Photo', 'wp-photo-album-plus'); ?> <br /> <?php _e('(Album)', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('#', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('IP', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('User', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Email', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Time since', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Comment', 'wp-photo-album-plus'); ?> </th> <th scope="col" style="width: 130px;" ><?php _e('Status', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Edit', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Delete', 'wp-photo-album-plus'); ?> </th> </tr> </thead> <tbody class="wppa_table_1"> <?php $comments = $wpdb->get_results("SELECT * FROM `" . WPPA_COMMENTS . "`" . $where . $order . $limit, ARRAY_A); if ($comments) { foreach ($comments as $com) { ?> <tr> <?php $photo = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_PHOTOS . " WHERE id = %s", $com['photo']), 'ARRAY_A'); if ($photo) { $alb = $photo['album']; $pname = __($photo['name'], 'wp-photo-album-plus'); $albname = '(' . wppa_get_album_name($alb) . ')'; } else { $alb = ''; $pname = ''; $albname = ''; } if ($wppa_comadmin_linkpage == '0') { ?> <td style="text-align:center"> <img src="<?php echo wppa_fix_poster_ext(wppa_get_thumb_url($com['photo']), $com['photo']); ?> " style="max-height:64px;max-width:64px;" /> <br /> <?php echo $albname; ?> </td><?php } else { $url = get_page_link($wppa_comadmin_linkpage); if (strpos($url, '?')) { $url .= '&'; } else { $url .= '?'; } $url .= 'wppa-album=' . $alb . '&wppa-photo=' . $com['photo'] . '&wppa-occur=1'; ?> <td style="text-align:center"> <a href="<?php echo $url; ?> " target="_blank"> <img title="<?php _e('Click to see the fullsize photo and all comments', 'wp-photo-album-plus'); ?> " src="<?php echo wppa_fix_poster_ext(wppa_get_thumb_url($com['photo']), $com['photo']); ?> " style="max-height:64px;max-width:64px;" /> </a> <br /> <?php echo $albname; ?> </td><?php } ?> <td><?php echo $com['photo']; ?> </td> <td><?php echo $com['ip']; ?> </td> <td><?php echo $com['user']; ?> </td> <td><?php if ($com['email']) { $subject = str_replace(' ', '%20', sprintf(__('Reply to your comment on photo: %s on %s', 'wp-photo-album-plus'), $pname, get_bloginfo('name'))); echo '<a href="mailto:' . $com['email'] . '?Subject=' . $subject . '" title="' . __('Reply', 'wp-photo-album-plus') . '" >' . $com['email'] . '</a>'; } else { echo $com['email']; } ?> </td> <td><?php echo wppa_get_time_since($com['timestamp']); ?> </td> <td><?php echo stripslashes($com['comment']); ?> </td> <td> <input type="hidden" id="photo-nonce-<?php echo $com['photo']; ?> " value="<?php echo wp_create_nonce('wppa_nonce_' . $com['photo']); ?> " /> <select name="status['<?php echo $com['id']; ?> ']" onchange="jQuery('#wppa-comment-spin-<?php echo $com['id']; ?> ').css('visibility', 'visible'); wppaAjaxUpdateCommentStatus(<?php echo $com['photo']; ?> , <?php echo $com['id']; ?> , this.value)"> <option value="pending" <?php if ($com['status'] == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('Pending', 'wp-photo-album-plus'); ?> </option> <option value="approved" <?php if ($com['status'] == 'approved') { echo 'selected="selected"'; } ?> ><?php _e('Approved', 'wp-photo-album-plus'); ?> </option> <option value="spam" <?php if ($com['status'] == 'spam') { echo 'selected="selected"'; } ?> ><?php _e('Spam', 'wp-photo-album-plus'); ?> </option> </select> <img id="wppa-comment-spin-<?php echo $com['id']; ?> " src="<?php echo wppa_get_imgdir() . 'spinner.gif'; ?> " style="visibility:hidden" /> </td> <?php $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments&tab=edit&edit_id=' . $com['id']); if (isset($_GET['wppa-page'])) { $url .= '&compage=' . strval(intval($_GET['wppa-page'])); } if (isset($_GET['commentid'])) { $url .= '&commentid=' . strval(intval($_GET['commentid'])); } ?> <?php $delurl = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments&tab=delete&delete_id=' . $com['id']); ?> <td style="color:green; cursor:pointer;" onclick="document.location='<?php echo $url; ?> '"><b><?php _e('Edit', 'wp-photo-album-plus'); ?> </b></td> <td style="color:red; cursor:pointer;" onclick="if (confirm('<?php _e('Are you sure you want to delete this comment?', 'wp-photo-album-plus'); ?> ')) document.location = '<?php echo $delurl; ?> ';"><b><?php _e('Delete', 'wp-photo-album-plus'); ?> </b></td> </tr> <?php } } ?> </tbody> <tfoot style="font-weight: bold" class=""> <tr> <th scope="col"><?php _e('Photo', 'wp-photo-album-plus'); ?> <br /> <?php _e('(Album)', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('#', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('IP', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('User', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Email', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Time since', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Comment', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Status', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Edit', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Delete', 'wp-photo-album-plus'); ?> </th> </tr> </tfoot> </table> <?php if (!$moderating) { wppa_admin_page_links($curpage, $pagsize, $nitems, $link); } ?> </form> </div> <?php } }
function wppa_get_thumb_default($id) { global $wpdb; // Validate args if (!wppa_is_int($id) || $id < '0') { wppa_dbg_msg('Please check file wppa-theme.php or any other php file that calls wppa_get_thumb_default(). Argument 1: photo id is missing or illegal!', 'red', 'force'); die('Please check your configuration'); } // Initialize $result = ''; // Get the photo info $thumb = wppa_cache_thumb($id); // Get the album info $album = wppa_cache_album($thumb['album']); wppa('current_album', $album['id']); // Get photo info $is_video = wppa_is_video($id); $has_audio = wppa_has_audio($id); $com_alt = wppa('is_comten') && wppa_switch('comten_alt_display') && !wppa_in_widget(); $frameattr_a = wppa_get_thumb_frame_style_a(); $framestyle = $frameattr_a['style']; $framewidth = $frameattr_a['width']; $frameheight = $frameattr_a['height']; // Get class depending of comment alt display if ($com_alt) { $class = 'thumbnail-frame-comalt thumbnail-frame-comalt-' . wppa('mocc') . ' thumbnail-frame-photo-' . $id; } else { $class = 'thumbnail-frame thumbnail-frame-' . wppa('mocc') . ' thumbnail-frame-photo-' . $id; } // If no image to display, die gracefully $imgsrc = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id); if (!wppa_is_video($id) && !is_file($imgsrc) && !wppa_has_audio($id)) { $result .= '<div' . ' class="' . $class . '"' . ' style="' . $framestyle . '; color:red;" >' . 'Missing thumbnail image #' . $id . '</div>'; return $result; } // Find image attributes $alt = $album['alt_thumbsize'] == 'yes' ? '_alt' : ''; $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, wppa_opt('thumbsize' . $alt), 'optional', 'thumb'); $imgstyle = $imgattr_a['style']; $imgwidth = $imgattr_a['width']; $imgheight = $imgattr_a['height']; $imgmargintop = $imgattr_a['margin-top']; $imgmarginbottom = $imgattr_a['margin-bottom']; // Special case for comment alt display if ($com_alt) { $imgwidth = wppa_opt('comten_alt_thumbsize'); $imgheight = round($imgwidth * $imgattr_a['height'] / $imgattr_a['width']); $imgstyle .= 'float:left; margin:0 20px 8px 0;width:' . $imgwidth . 'px; height:' . $imgheight . 'px;'; } // Cursor depends on link $cursor = $imgattr_a['cursor']; // Find the required image sizes if (wppa_switch('use_thumb_popup')) { // Landscape? if ($imgwidth > $imgheight) { $popwidth = wppa_opt('popupsize'); $popheight = round($popwidth * $imgheight / $imgwidth); } else { $popheight = wppa_opt('popupsize'); $popwidth = round($popheight * $imgwidth / $imgheight); } } else { $popwidth = $imgwidth; $popheight = $imgheight; } // More image attributes $imgurl = wppa_fix_poster_ext(wppa_get_thumb_url($id, '', $popwidth, $popheight), $id); $events = wppa_get_imgevents('thumb', $id); $imgalt = wppa_get_imgalt($id); // returns something like ' alt="Any text" ' $title = esc_attr(wppa_get_photo_name($id)); // Feed ? if (is_feed()) { $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, '100', '4', 'thumb'); $style = $imgattr_a['style']; $result .= '<a href="' . get_permalink() . '">' . '<img src="' . $imgurl . '" ' . $imgalt . ' title="' . $title . '" style="' . $style . '" />' . '</a>'; return $result; } // Open Com alt wrapper if ($com_alt) { $result .= '<div>'; } // Open the thumbframe $result .= '<div' . ' id="thumbnail_frame_' . $id . '_' . wppa('mocc') . '"' . ' class="' . $class . '"' . ' style="' . $framestyle . '"' . ' >'; // Open the image container $imgcontheight = $com_alt ? $imgheight : max($imgwidth, $imgheight); if (!is_file($imgsrc)) { $imgcontheight = 2 * wppa_get_audio_control_height(); } if ($com_alt) { $framewidth = $imgwidth + '4'; } $result .= '<div' . ' class="wppa-tn-img-container"' . ' style="' . 'height:' . $imgcontheight . 'px;' . 'width:' . $framewidth . 'px;' . ($com_alt ? 'float:left;' : '') . 'overflow:hidden;"' . '>'; // The medals if at the top $medalsize = $com_alt ? 'S' : 'M'; $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => $medalsize, 'where' => 'top')); // The audio when no popup if (wppa_switch('thumb_audio') && wppa_has_audio($id) && !$com_alt) { $result .= '<div style="position:relative;z-index:11;">'; $is_safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari'); $cont_h = $is_safari ? 16 : 28; $audiotop = $imgattr_a['height'] + $imgattr_a['margin-top'] - $cont_h; if (!is_file($imgsrc)) { // Audio without image $audiotop = wppa_get_audio_control_height(); $imgwidth = wppa_opt('tf_width'); $imgheight = wppa_get_audio_control_height(); } $result .= wppa_get_audio_html(array('id' => $id, 'width' => $imgwidth, 'height' => $cont_h, 'style' => 'position:absolute;top:' . $audiotop . 'px;left:0;border:none;')); $result .= '</div>'; } // Get the image link if (wppa('is_topten')) { $no_album = !wppa('start_album'); if ($no_album) { $tit = __('View the top rated photos', 'wp-photo-album-plus'); } else { $tit = esc_attr(__(stripslashes($thumb['description']))); } $link = wppa_get_imglnk_a('thumb', $id, '', $tit, '', $no_album); } else { $link = wppa_get_imglnk_a('thumb', $id); } // voor parent uplr // See if ajax possible if ($link) { // Is link an url? if ($link['is_url']) { if (wppa_switch('allow_ajax') && wppa_opt('thumb_linktype') == 'photo' && wppa_opt('thumb_linkpage') == '0' && !wppa_switch('thumb_blank') && !(wppa_switch('thumb_overrule') && $thumb['linkurl']) && !wppa('is_topten') && !wppa('is_lasten') && !wppa('is_comten') && !wppa('is_featen') && !wppa('is_tag') && !wppa('is_upldr') && !wppa('src') && !wppa('supersearch') && (wppa_is_int(wppa('start_album')) || wppa('start_album') == '')) { // Ajax possible // The a img ajax $p = wppa('calendar') ? '' : '&wppa-photo=' . $id; $onclick = 'wppaDoAjaxRender( ' . wppa('mocc') . ', \'' . wppa_get_slideshow_url_ajax(wppa('start_album'), '0') . '&wppa-photo=' . $id . '\', \'' . wppa_convert_to_pretty(wppa_get_slideshow_url(wppa('start_album'), '0') . $p) . '\' )'; $result .= '<a style="position:static;" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">'; // Video? if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => $onclick, 'lb' => false, 'class' => '', 'style' => $imgstyle)); } else { $result .= '<img' . ' onclick="' . $onclick . '"' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />'; } // Close the a img ajax $result .= '</a>'; } else { // The a img non ajax $result .= '<a style="position:static;" href="' . $link['url'] . '" target="' . $link['target'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">'; if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '" ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />'; } // Close the img non ajax $result .= '</a>'; } } elseif ($link['is_lightbox']) { $title = wppa_get_lbtitle('thumb', $id); // The a img $result .= '<a href="' . $link['url'] . '" target="' . $link['target'] . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($id)) . '"' . ' data-videonatwidth="' . wppa_get_videox($id) . '"' . ' data-videonatheight="' . wppa_get_videoy($id) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($id)) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[occ' . wppa('mocc') . ']"' . ' ' . wppa('lbtitle') . '="' . $title . '" ' . ' class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">'; if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => $cursor, 'events' => $events, 'title' => wppa_zoom_in($id), 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle)); } else { $title = wppa_zoom_in($id); $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' />'; } // Close the a img $result .= '</a>'; } else { // is onclick // The div img $result .= '<div onclick="' . $link['url'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">'; if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />'; } $result .= '</div>'; $result .= '<script type="text/javascript">'; $result .= '/* <![CDATA[ */'; $result .= 'wppaPopupOnclick[' . $id . '] = "' . $link['url'] . '";'; $result .= '/* ]]> */'; $result .= '</script>'; } } else { // no link if (wppa_switch('use_thumb_popup')) { $result .= '<div id="x-' . $id . '-' . wppa('mocc') . '">'; if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => '', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle)); } else { $result .= '<img' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '"' . ' ' . $events . ' />'; } $result .= '</div>'; } else { if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => '', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle)); } else { $result .= '<img' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '"' . ' ' . $events . ' />'; } } } // The medals if near the bottom $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => $medalsize, 'where' => 'bot')); // Close the image container $result .= '</div>'; /* // The audio when popup if ( wppa_switch( 'use_thumb_popup' ) && wppa_switch( 'thumb_audio' ) && wppa_has_audio( $id ) && ! $com_alt ) { $result .= wppa_get_audio_html( array( 'id' => $id, 'width' => $imgwidth )); } */ // Comten alt display? if ($com_alt) { $result .= '<div' . ' class="wppa-com-alt wppa-com-alt-' . wppa('mocc') . '"' . ' style="' . 'height:' . $imgheight . 'px;' . 'overflow:auto;' . 'margin: 0 0 8px 10px;' . 'border:1px solid ' . wppa_opt('bcolor_alt') . ';' . '"' . ' >'; $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s AND `status` = 'approved' ORDER BY `timestamp` DESC", $id), ARRAY_A); $first = true; if ($comments) { foreach ($comments as $com) { $result .= '<h6' . ' style="' . 'font-size:10px;' . 'line-height:12px;' . 'font-weight:bold;' . 'padding:' . ($first ? '0' : '6px') . ' 0 0 6px;' . 'margin:0;float:left;' . '"' . '>' . $com['user'] . ' ' . __('wrote', 'wp-photo-album-plus') . ' ' . wppa_get_time_since($com['timestamp']) . ':' . '</h6>' . '<p' . ' style="' . 'font-size:10px;' . 'line-height:12px;' . 'padding:0 0 0 6px;' . 'text-align:left;' . 'margin:0;' . 'clear:left;' . '"' . '>' . html_entity_decode(convert_smilies(stripslashes($com['comment']))) . '</p>'; $first = false; } } $result .= '</div>'; } else { // Open the subtext container $margtop = wppa_switch('align_thumbtext') ? '' : 'margin-top:' . -$imgmarginbottom . 'px;'; $subtextcontheight = $frameheight - max($imgwidth, $imgheight); if (!wppa_switch('align_thumbtext')) { $subtextcontheight += $imgmarginbottom; } $result .= '<div' . ' style="' . 'height:' . $subtextcontheight . 'px;' . 'width:' . $framewidth . 'px;' . 'position:absolute;' . $margtop . 'overflow:hidden;' . '" >'; // Single button voting system if (wppa_opt('rating_max') == '1' && wppa_switch('vote_thumb')) { $mylast = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_RATING . '` WHERE `photo` = %s AND `user` = %s ORDER BY `id` DESC LIMIT 1', $id, wppa_get_user()), ARRAY_A); $buttext = $mylast ? __(wppa_opt('voted_button_text'), 'wp-photo-album-plus') : __(wppa_opt('vote_button_text'), 'wp-photo-album-plus'); $result .= '<input' . ' id="wppa-vote-button-' . wppa('mocc') . '-' . $id . '"' . ' class="wppa-vote-button-thumb"' . ' style="margin:0;"' . ' type="button"' . ' onclick="wppaVoteThumb( ' . wppa('mocc') . ', ' . $id . ' )"' . ' value="' . $buttext . '"' . ' />'; } // Name if (wppa_switch('thumb_text_name') || wppa_switch('thumb_text_owner')) { $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . wppa_get_photo_name($id, wppa_switch('thumb_text_owner'), false, false, wppa_switch('thumb_text_name')) . '</div>'; } // searching, link to album // if ( wppa( 'src' ) || wppa( 'supersearch' ) || ( ( wppa( 'is_comten') || wppa( 'is_topten' ) || wppa( 'is_lasten' ) || wppa( 'is_featen') ) && wppa( 'start_album' ) != $thumb['album'] ) ) { if (wppa_switch('thumb_text_virt_album') && wppa_is_virtual() && wppa('start_album') != $thumb['album']) { $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . '<a' . ' href="' . wppa_get_album_url($thumb['album']) . '"' . ' >' . '<span class="wppa-tnpar" >(</span>' . stripslashes(__(wppa_get_album_name($thumb['album']), 'wp-photo-album-plus')) . '<span class="wppa-tnpar" >)</span>' . '</a>' . '</div>'; } // Share if (wppa_switch('share_on_thumbs')) { $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . wppa_get_share_html($id, 'thumb') . '</div>'; } // Delete and Edit links if (wppa_switch('edit_thumb') && !wppa_is_user_blacklisted()) { if (wppa_user_is('administrator') || current_user_can('wppa_moderate') || wppa_get_user() == wppa_get_photo_owner($id) && wppa_switch('upload_edit')) { $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . '<a' . ' style="color:red;cursor:pointer;"' . ' onclick="' . esc_attr('if ( confirm( "' . __('Are you sure you want to remove this photo?', 'wp-photo-album-plus') . '" ) ) wppaAjaxRemovePhoto( ' . wppa('mocc') . ', ' . $id . ', false ); return false;') . '"' . ' >' . __('Delete', 'wp-photo-album-plus') . '</a>' . ' ' . '<a' . ' style="color:green;cursor:pointer;"' . ' onclick="wppaEditPhoto( ' . wppa('mocc') . ', ' . $id . ' ); return false;"' . ' >' . __('Edit', 'wp-photo-album-plus') . '</a>' . '</div>'; } } // Description if (wppa_switch('thumb_text_desc') || $thumb['status'] == 'pending' || $thumb['status'] == 'scheduled') { $desc = ''; if ($thumb['status'] == 'pending' || $thumb['status'] == 'scheduled') { $desc .= wppa_moderate_links('thumb', $id); } $desc .= wppa_get_photo_desc($id, wppa_switch('allow_foreign_shortcodes_thumbs')); $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . $desc . '</div>'; } // Rating if (wppa_switch('thumb_text_rating')) { $rating = wppa_get_rating_by_id($id); if ($rating && wppa_switch('show_rating_count')) { $rating .= ' ( ' . wppa_get_rating_count_by_id($id) . ' )'; } $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . $rating . '</div>'; } // Comcount if (wppa_switch('thumb_text_comcount')) { $comcount = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `photo` = " . $id); if ($comcount) { $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . sprintf(_n('%d comment', '%d comments', $comcount, 'wp-photo-album-plus'), $comcount) . '</div>'; } } // Viewcount if (wppa_switch('thumb_text_viewcount')) { $result .= '<div' . ' class="wppa-thumb-text"' . ' style="clear:both;' . __wcs('wppa-thumb-text') . '"' . ' >' . sprintf(_n('%d view', '%d views', $thumb['views'], 'wp-photo-album-plus'), $thumb['views']) . '</div>'; } // Close the subtext container $result .= '</div>'; } // if ! $com_alt // Close the thumbframe $result .= '</div>'; if ($com_alt) { $result .= '</div>'; } return $result; }
function wppa_comment_html($id, $comment_allowed) { global $wpdb; global $current_user; global $wppa_first_comment_html; $result = ''; if (wppa_in_widget()) { return $result; } // NOT in a widget // Find out who we are either logged in or not $vis = is_user_logged_in() ? 'display:none; ' : ''; if (!$wppa_first_comment_html) { $wppa_first_comment_html = true; // Find user if (wppa_get_post('comname')) { wppa('comment_user', wppa_get_post('comname')); } if (wppa_get_post('comemail')) { wppa('comment_email', wppa_get_post('comemail')); } elseif (is_user_logged_in()) { get_currentuserinfo(); wppa('comment_user', $current_user->display_name); //user_login; wppa('comment_email', $current_user->user_email); } } // Loop the comments already there $n_comments = 0; if (wppa_switch('comments_desc')) { $ord = 'DESC'; } else { $ord = ''; } $comments = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . WPPA_COMMENTS . ' WHERE photo = %s ORDER BY id ' . $ord, $id), ARRAY_A); wppa_dbg_q('Q-Comm'); $com_count = count($comments); $color = 'darkgrey'; if (wppa_opt('fontcolor_box')) { $color = wppa_opt('fontcolor_box'); } if ($comments && (is_user_logged_in() || !wppa_switch('comment_view_login'))) { $result .= ' <div' . ' id="wppa-comtable-wrap-' . wppa('mocc') . '"' . ' style="display:none;"' . '>' . '<table' . ' id="wppacommentstable-' . wppa('mocc') . '"' . ' class="wppa-comment-form"' . ' style="margin:0; "' . '>' . '<tbody>'; foreach ($comments as $comment) { // Show a comment either when it is approved, or it is pending and mine or i am a moderator if ($comment['status'] == 'approved' || current_user_can('wppa_moderate') || current_user_can('wppa_comments') || ($comment['status'] == 'pending' || $comment['status'] == 'spam') && $comment['user'] == wppa('comment_user')) { $n_comments++; $result .= ' <tr' . ' class="wppa-comment-' . $comment['id'] . '"' . ' valign="top"' . ' style="border-bottom:0 none; border-top:0 none; border-left: 0 none; border-right: 0 none; "' . ' >' . '<td' . ' valign="top"' . ' class="wppa-box-text wppa-td"' . ' style="vertical-align:top; width:30%; border-width: 0 0 0 0; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . $comment['user'] . ' ' . __('wrote:', 'wp-photo-album-plus') . '<br />' . '<span style="font-size:9px; ">' . wppa_get_time_since($comment['timestamp']) . '</span>'; // Avatar ? if (wppa_opt('comment_gravatar') != 'none') { // Find the default if (wppa_opt('comment_gravatar') != 'url') { $default = wppa_opt('comment_gravatar'); } else { $default = wppa_opt('comment_gravatar_url'); } // Find the avatar, init $avt = false; $usr = false; // First try to find the user by email address ( works only if email required on comments ) if ($comment['email']) { $usr = get_user_by('email', $comment['email']); } // If not found, try to find the user by login name ( works only if login name is equal to display name ) if (!$usr) { $usr = get_user_by('login', $comment['user']); } // Still no user, try to find him by display name if (!$usr) { $usr = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE `display_name` = %s", $comment['user'])); // Accept this user if he is the only one with this display name if (count($usr) != 1) { $usr = false; } } // If a user is found, see for local Avatar ? if ($usr) { $avt = str_replace("'", "\"", get_avatar($usr->ID, wppa_opt('gravatar_size'), $default)); } // Global avatars off ? try myself if (!$avt) { $avt = ' <img' . ' class="wppa-box-text wppa-td"' . ' src="http://www.gravatar.com/avatar/' . md5(strtolower(trim($comment['email']))) . '.jpg?d=' . urlencode($default) . '&s=' . wppa_opt('gravatar_size') . '"' . ' alt="' . __('Avatar', 'wp-photo-album-plus') . '"' . ' />'; } // Compose the html $result .= ' <div class="com_avatar">' . $avt . '</div>'; } $result .= '</td>'; $txtwidth = floor(wppa_get_container_width() * 0.7) . 'px'; $result .= '<td' . ' class="wppa-box-text wppa-td"' . ' style="width:70%; word-wrap:break-word; border-width: 0 0 0 0;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<p' . ' class="wppa-comment-textarea wppa-comment-textarea-' . wppa('mocc') . '"' . ' style="' . 'margin:0;' . 'background-color:transparent;' . 'width:' . $txtwidth . ';' . 'max-height:90px;' . 'overflow:auto;' . 'word-wrap:break-word;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . html_entity_decode(esc_js(stripslashes(wppa_convert_smilies($comment['comment'])))); if ($comment['status'] != 'approved' && (current_user_can('wppa_moderate') || current_user_can('wppa_comments'))) { if (wppa('no_esc')) { $result .= wppa_moderate_links('comment', $id, $comment['id']); } else { $result .= wppa_html(esc_js(wppa_moderate_links('comment', $id, $comment['id']))); } } elseif ($comment['status'] == 'pending' && $comment['user'] == wppa('comment_user')) { $result .= '<br /><span style="color:red; font-size:9px;" >' . __('Awaiting moderation', 'wp-photo-album-plus') . '</span>'; } elseif ($comment['status'] == 'spam' && $comment['user'] == wppa('comment_user')) { $result .= '<br /><span style="color:red; font-size:9px;" >' . __('Marked as spam', 'wp-photo-album-plus') . '</span>'; } $result .= '</p>' . '</td>' . '</tr>' . '<tr class="wppa-comment-' . $comment['id'] . '">' . '<td colspan="2" style="padding:0">' . '<hr style="background-color:' . $color . '; margin:0;" />' . '</td>' . '</tr>'; } } $result .= '</tbody>' . '</table>' . '</div>'; } // See if we are currently in the process of adding/editing this comment $is_current = $id == wppa('comment_photo') && wppa('comment_id'); if ($is_current) { $txt = wppa('comment_text'); $btn = __('Edit!', 'wp-photo-album-plus'); } else { $txt = ''; $btn = __('Send!', 'wp-photo-album-plus'); } // Prepare the callback url $returnurl = wppa_get_permalink(); $album = wppa_get_get('album'); if ($album !== false) { $returnurl .= 'wppa-album=' . $album . '&'; } $cover = wppa_get_get('cover'); if ($cover) { $returnurl .= 'wppa-cover=' . $cover . '&'; } $slide = wppa_get_get('slide'); if ($slide !== false) { $returnurl .= 'wppa-slide&'; } $occur = wppa_get_get('occur'); if ($occur) { $returnurl .= 'wppa-occur=' . $occur . '&'; } $lasten = wppa_get_get('lasten'); if ($lasten) { $returnurl .= 'wppa-lasten=' . $lasten . '&'; } $topten = wppa_get_get('topten'); if ($topten) { $returnurl .= 'wppa-topten=' . $topten . '&'; } $comten = wppa_get_get('comten'); if ($comten) { $returnurl .= 'wppa-comten=' . $comten . '&'; } $tag = wppa_get_get('tag'); if ($tag) { $returnurl .= 'wppa-tag=' . $tag . '&'; } $returnurl .= 'wppa-photo=' . $id; // The comment form if ($comment_allowed) { $result .= '<div' . ' id="wppa-comform-wrap-' . wppa('mocc') . '"' . ' style="display:none;"' . ' >' . '<form' . ' id="wppa-commentform-' . wppa('mocc') . '"' . ' class="wppa-comment-form"' . ' action="' . $returnurl . '"' . ' method="post"' . ' onsubmit="return wppaValidateComment( ' . wppa('mocc') . ' )"' . ' >' . wp_nonce_field('wppa-nonce-' . wppa('mocc'), 'wppa-nonce-' . wppa('mocc'), false, false) . ($album ? '<input type="hidden" name="wppa-album" value="' . $album . '" />' : '') . ($cover ? '<input type="hidden" name="wppa-cover" value="' . $cover . '" />' : '') . ($slide ? '<input type="hidden" name="wppa-slide" value="' . $slide . '" />' : '') . '<input' . ' type="hidden"' . ' name="wppa-returnurl"' . ' id="wppa-returnurl-' . wppa('mocc') . '"' . ' value="' . $returnurl . '"' . ' />' . ($is_current ? '<input' . ' type="hidden"' . ' id="wppa-comment-edit-' . wppa('mocc') . '"' . ' name="wppa-comment-edit"' . ' value="' . wppa('comment_id') . '"' . ' />' : '') . '<input type="hidden" name="wppa-occur" value="' . wppa('occur') . '" />' . '<table id="wppacommenttable-' . wppa('mocc') . '" style="margin:0;">' . '<tbody>' . '<tr valign="top" style="' . $vis . '">' . '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your name:', 'wp-photo-album-plus') . '</td>' . '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . '<input' . ' type="text"' . ' name="wppa-comname"' . ' id="wppa-comname-' . wppa('mocc') . '"' . ' style="width:100%; " value="' . wppa('comment_user') . '"' . ' />' . '</td>' . '</tr>'; if (wppa_switch('comment_email_required')) { $result .= '<tr valign="top" style="' . $vis . '">' . '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your email:', 'wp-photo-album-plus') . '</td>' . '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . '<input' . ' type="text"' . ' name="wppa-comemail"' . ' id="wppa-comemail-' . wppa('mocc') . '"' . ' style="width:100%;"' . ' value="' . wppa('comment_email') . '"' . ' />' . '</td>' . '</tr>'; } $result .= '<tr valign="top" style="vertical-align:top;">' . '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your comment:', 'wp-photo-album-plus') . '<br />' . wppa('comment_user') . '<br />'; if (is_user_logged_in() && wppa_opt('comment_captcha') == 'all' || !is_user_logged_in() && wppa_opt('comment_captcha') != 'none') { $wid = '20%'; if (wppa_opt('fontsize_box')) { $wid = wppa_opt('fontsize_box') * 1.5 . 'px'; } $captkey = $id; if ($is_current) { $captkey = $wpdb->get_var($wpdb->prepare('SELECT `timestamp` FROM `' . WPPA_COMMENTS . '` WHERE `id` = %s', wppa('comment_id'))); } wppa_dbg_q('Q-Com-ts'); $result .= wppa_make_captcha($captkey) . '<input' . ' type="text"' . ' id="wppa-captcha-' . wppa('mocc') . '"' . ' name="wppa-captcha"' . ' style="width:' . $wid . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' /> '; } $result .= '<input type="button" name="commentbtn" onclick="wppaAjaxComment( ' . wppa('mocc') . ', ' . $id . ' )" value="' . $btn . '" style="margin:0 4px 0 0;" />' . '<img id="wppa-comment-spin-' . wppa('mocc') . '" src="' . wppa_get_imgdir() . 'wpspin.gif" style="display:none;" />' . '</td>' . '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >'; if (wppa_switch('comment_smiley_picker')) { $result .= wppa_get_smiley_picker_html('wppa-comment-' . wppa('mocc')); } $result .= '<textarea' . ' name="wppa-comment"' . ' id="wppa-comment-' . wppa('mocc') . '"' . ' style="height:60px; width:100%; "' . '>' . esc_textarea(stripslashes($txt)) . '</textarea>' . '</td>' . '</tr>' . '</tbody>' . '</table>' . '</form>' . '</div>'; } else { if (wppa_switch('login_links')) { $result .= sprintf(__('You must <a href="%s">login</a> to enter a comment', 'wp-photo-album-plus'), site_url('wp-login.php', 'login')); } else { $result .= __('You must login to enter a comment', 'wp-photo-album-plus'); } } $result .= '<div id="wppa-comfooter-wrap-' . wppa('mocc') . '" style="display:block;" >' . '<table id="wppacommentfooter-' . wppa('mocc') . '" class="wppa-comment-form" style="margin:0;">' . '<tbody>' . '<tr style="text-align:center;">' . '<td style="text-align:center; cursor:pointer;' . __wcs('wppa-box-text') . '" >' . '<a onclick="wppaOpenComments( ' . wppa('mocc') . ', -1 ); return false;" >'; if ($n_comments) { $result .= sprintf(_n('%d comment', '%d comments', $n_comments, 'wp-photo-album-plus'), $n_comments); } else { if ($comment_allowed) { $result .= __('Leave a comment', 'wp-photo-album-plus'); } } $result .= '</a>' . '</td>' . '</tr>' . '</tbody>' . '</table>' . '</div>' . '<div style="clear:both"></div>'; return $result; }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; require_once dirname(__FILE__) . '/wppa-links.php'; require_once dirname(__FILE__) . '/wppa-styles.php'; require_once dirname(__FILE__) . '/wppa-functions.php'; require_once dirname(__FILE__) . '/wppa-thumbnails.php'; require_once dirname(__FILE__) . '/wppa-boxes-html.php'; require_once dirname(__FILE__) . '/wppa-slideshow.php'; wppa_initialize_runtime(); wppa('in_widget', 'com'); wppa_bump_mocc(); // Hide widget if not logged in and login required to see comments if (wppa_switch('comment_view_login') && !is_user_logged_in()) { return; } extract($args); $page = in_array(wppa_opt('comment_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_comment_widget_linkpage', __('Recently commented photos', 'wp-photo-album-plus')); $max = wppa_opt('comten_count'); $widget_title = apply_filters('widget_title', $instance['title']); $photo_ids = wppa_get_comten_ids($max); $widget_content = "\n" . '<!-- WPPA+ Comment Widget start -->'; $maxw = wppa_opt('comten_size'); $maxh = $maxw + 18; if ($photo_ids) { foreach ($photo_ids as $id) { // Make the HTML for current comment $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">'; $image = wppa_cache_thumb($id); if ($image) { $link = wppa_get_imglnk_a('comten', $id, '', '', true); $file = wppa_get_thumb_path($id); $imgstyle_a = wppa_get_imgstyle_a($id, $file, $maxw, 'center', 'comthumb'); $imgstyle = $imgstyle_a['style']; $width = $imgstyle_a['width']; $height = $imgstyle_a['height']; $cursor = $imgstyle_a['cursor']; $imgurl = wppa_get_thumb_url($id, '', $width, $height); $imgevents = wppa_get_imgevents('thumb', $id, true); $title = ''; $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s ORDER BY `timestamp` DESC", $id), ARRAY_A); if ($comments) { $first_comment = $comments['0']; foreach ($comments as $comment) { $title .= $comment['user'] . ' ' . __('wrote', 'wp-photo-album-plus') . ' ' . wppa_get_time_since($comment['timestamp']) . ":\n"; $title .= $comment['comment'] . "\n\n"; } } $title = esc_attr(strip_tags(trim($title))); $album = '0'; $display = 'thumbs'; $widget_content .= wppa_get_the_widget_thumb('comten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents); } else { $widget_content .= __('Photo not found.', 'wp-photo-album-plus'); } $widget_content .= "\n\t" . '<span style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; cursor:pointer;" title="' . esc_attr($first_comment['comment']) . '" >' . $first_comment['user'] . '</span>'; $widget_content .= "\n" . '</div>'; } } else { $widget_content .= 'There are no commented photos (yet).'; } $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ comment Widget end -->'; echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; wppa('in_widget', false); }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; require_once dirname(__FILE__) . '/wppa-links.php'; require_once dirname(__FILE__) . '/wppa-styles.php'; require_once dirname(__FILE__) . '/wppa-functions.php'; require_once dirname(__FILE__) . '/wppa-thumbnails.php'; require_once dirname(__FILE__) . '/wppa-boxes-html.php'; require_once dirname(__FILE__) . '/wppa-slideshow.php'; wppa_initialize_runtime(); wppa('in_widget', 'upldr'); wppa_bump_mocc(); extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'name', 'ignore' => 'admin', 'parent' => '')); $widget_title = apply_filters('widget_title', $instance['title']); $page = in_array('album', wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_upldr_widget_linkpage', __('User uploaded photos', 'wp-photo-album-plus')); $ignorelist = explode(',', $instance['ignore']); $upldrcache = wppa_get_upldr_cache(); $needupdate = false; $users = wppa_get_users(); $workarr = array(); $selalbs = str_replace('.', ',', wppa_expand_enum(wppa_alb_to_enum_children(wppa_expand_enum($instance['parent'])))); // Make the data we need if ($users) { foreach ($users as $user) { if (!in_array($user['user_login'], $ignorelist)) { $me = wppa_get_user(); if ($user['user_login'] != $me && isset($upldrcache[$this->get_widget_id()][$user['user_login']]['c'])) { $photo_count = $upldrcache[$this->get_widget_id()][$user['user_login']]['c']; } else { if ($instance['parent']) { $query = $wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND `album` IN (" . $selalbs . ") AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", $user['user_login'], $me); //); } else { $query = $wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", $user['user_login'], $me); //); } $photo_count = $wpdb->get_var($query); if ($user['user_login'] != $me) { $upldrcache[$this->get_widget_id()][$user['user_login']]['c'] = $photo_count; $needupdate = true; } } if ($photo_count) { if ($user['user_login'] != $me && isset($upldrcache[$this->get_widget_id()][$user['user_login']]['d'])) { $last_dtm = $upldrcache[$this->get_widget_id()][$user['user_login']]['d']; } else { if ($instance['parent']) { $last_dtm = $wpdb->get_var($wpdb->prepare("SELECT `timestamp` FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND `album` IN (" . $selalbs . ") AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT 1", $user['user_login'], $me)); } else { $last_dtm = $wpdb->get_var($wpdb->prepare("SELECT `timestamp` FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT 1", $user['user_login'], $me)); } } if ($user['user_login'] != $me) { $upldrcache[$this->get_widget_id()][$user['user_login']]['d'] = $last_dtm; $needupdate = true; } $workarr[] = array('login' => $user['user_login'], 'name' => $user['display_name'], 'count' => $photo_count, 'date' => $last_dtm); } } } } else { $widget_content = __('There are too many registered users in the system for this widget', 'wp-photo-album-plus'); echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; return; } if ($needupdate) { update_option('wppa_upldr_cache', $upldrcache); } // Bring me to top $myline = false; if (is_user_logged_in()) { $me = wppa_get_user(); foreach (array_keys($workarr) as $key) { $user = $workarr[$key]; if ($user['login'] == $me) { $myline = $workarr[$key]; unset($workarr[$key]); } } } // Sort workarray $ord = $instance['sortby'] == 'name' ? SORT_ASC : SORT_DESC; $workarr = wppa_array_sort($workarr, $instance['sortby'], $ord); // Create widget content $widget_content = "\n" . '<!-- WPPA+ Upldr Widget start -->'; $widget_content .= '<div class="wppa-upldr" style="max-height:180px; overflow:auto"><table><tbody>'; $albs = $instance['parent'] ? wppa_alb_to_enum_children(wppa_expand_enum($instance['parent'])) : ''; $a = $albs ? wppa_trim_wppa_('&wppa-album=' . $albs) : ''; if ($myline) { $user = $myline; $widget_content .= '<tr class="wppa-user" > <td style="padding: 0 3px;" ><a href="' . wppa_get_upldr_link($user['login']) . $a . '" title="' . __('Photos uploaded by', 'wp-photo-album-plus') . ' ' . $user['name'] . '" ><b>' . $user['name'] . '</b></a></td> <td style="padding: 0 3px;" ><b>' . $user['count'] . '</b></td> <td style="padding: 0 3px;" ><b>' . wppa_get_time_since($user['date']) . '</b></td> </tr>'; } foreach ($workarr as $user) { $widget_content .= '<tr class="wppa-user" > <td style="padding: 0 3px;" ><a href="' . wppa_get_upldr_link($user['login']) . $a . '" title="' . __('Photos uploaded by', 'wp-photo-album-plus') . ' ' . $user['name'] . '" >' . $user['name'] . '</a></td> <td style="padding: 0 3px;" >' . $user['count'] . '</td> <td style="padding: 0 3px;" >' . wppa_get_time_since($user['date']) . '</td> </tr>'; } $widget_content .= '</tbody></table></div>'; $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ Upldr Widget end -->'; // Output echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; wppa('in_widget', false); }
function wppa_album_photos($album = '', $photo = '', $owner = '', $moderate = false) { global $wpdb; // Check input wppa_vfy_arg('wppa-page'); $pagesize = wppa_opt('photo_admin_pagesize'); $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1'; $skip = ($page - '1') * $pagesize; $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize; if ($album) { if ($album == 'search') { $count = wppa_get_edit_search_photos('', 'count_only'); $photos = wppa_get_edit_search_photos($limit); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring'])); } else { $counts = wppa_treecount_a($album); $count = $counts['selfphotos'] + $counts['pendphotos']; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s ' . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album); } } elseif ($photo && !$moderate) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $photo), ARRAY_A); $link = ''; } elseif ($owner) { $count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `' . WPPA_PHOTOS . '` WHERE `owner` = %s', $owner)); $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `owner` = %s ORDER BY `timestamp` DESC' . $limit, $owner), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_edit_photo'); } elseif ($moderate) { if (!current_user_can('wppa_moderate')) { wp_die(__('You do not have the rights to do this', 'wp-photo-album-plus')); } if ($photo) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $photo), ARRAY_A); $link = ''; } else { // Photos with pending comments? $cmt = $wpdb->get_results("SELECT `photo` FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'pending'", ARRAY_A); if ($cmt) { $orphotois = ''; foreach ($cmt as $c) { $orphotois .= "OR `id` = " . $c['photo'] . " "; } } else { $orphotois = ''; } $count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `' . WPPA_PHOTOS . '` WHERE `status` = %s ' . $orphotois, 'pending')); $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `status` = %s ' . $orphotois . ' ORDER BY `timestamp` DESC' . $limit, 'pending'), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_moderate_photos'); } if (empty($photos)) { if ($photo) { echo '<p>' . __('This photo is no longer awaiting moderation.', 'wp-photo-album-plus') . '</p>'; } else { echo '<p>' . __('There are no photos awaiting moderation at this time.', 'wp-photo-album-plus') . '</p>'; } if (current_user_can('administrator')) { echo '<h3>' . __('Manage all photos by timestamp', 'wp-photo-album-plus') . '</h3>'; $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "`"); $photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC" . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_moderate_photos'); } else { return; } } } else { wppa_dbg_msg('Missing required argument in wppa_album_photos() 1', 'red', 'force'); } if ($link && isset($_REQUEST['quick'])) { $link .= '&quick'; } wppa_show_search_statistics(); if (empty($photos)) { if ($photo) { echo '<div id="photoitem-' . $photo . '" class="photoitem" style="width: 99%; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 );"> <span style="color:red">' . sprintf(__('Photo %s has been removed.', 'wp-photo-album-plus'), $photo) . '</span> </div>'; } else { if (isset($_REQUEST['wppa-searchstring'])) { echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>'; } else { echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>'; } } } else { $wms = array('toplft' => __('top - left', 'wp-photo-album-plus'), 'topcen' => __('top - center', 'wp-photo-album-plus'), 'toprht' => __('top - right', 'wp-photo-album-plus'), 'cenlft' => __('center - left', 'wp-photo-album-plus'), 'cencen' => __('center - center', 'wp-photo-album-plus'), 'cenrht' => __('center - right', 'wp-photo-album-plus'), 'botlft' => __('bottom - left', 'wp-photo-album-plus'), 'botcen' => __('bottom - center', 'wp-photo-album-plus'), 'botrht' => __('bottom - right', 'wp-photo-album-plus')); $temp = wppa_get_water_file_and_pos('0'); $wmfile = isset($temp['select']) ? $temp['select'] : ''; $wmpos = isset($temp['pos']) && isset($wms[$temp['pos']]) ? $wms[$temp['pos']] : ''; wppa_admin_page_links($page, $pagesize, $count, $link); foreach ($photos as $photo) { $is_multi = wppa_is_multi($photo['id']); $is_video = wppa_is_video($photo['id']); $has_audio = wppa_has_audio($photo['id']); ?> <a id="photo_<?php echo $photo['id']; ?> " name="photo_<?php echo $photo['id']; ?> "></a> <div class="widefat wppa-table-wrap" id="photoitem-<?php echo $photo['id']; ?> " style="width:99%; position: relative;" > <!-- Left half starts here --> <div style="width:49.5%; float:left; border-right:1px solid #ccc; margin-right:0;"> <input type="hidden" id="photo-nonce-<?php echo $photo['id']; ?> " value="<?php echo wp_create_nonce('wppa_nonce_' . $photo['id']); ?> " /> <table class="wppa-table wppa-photo-table" style="width:98%" > <tbody> <!-- Preview --> <tr> <th> <label ><?php echo 'ID = ' . $photo['id'] . '. ' . __('Preview:', 'wp-photo-album-plus'); ?> </label> <br /> <?php echo sprintf(__('Album: %d<br />(%s)', 'wp-photo-album-plus'), $photo['album'], wppa_get_album_name($photo['album'])); ?> <br /><br /> <?php if (!$is_video) { ?> <?php _e('Rotate', 'wp-photo-album-plus'); ?> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo left?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rotleft', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('left', 'wp-photo-album-plus'); ?> </a> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo 180°?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rot180', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('180°', 'wp-photo-album-plus'); ?> </a> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo right?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rotright', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('right', 'wp-photo-album-plus'); ?> </a> <br /> <span style="font-size: 9px; line-height: 10px; color:#666;"> <?php if (wppa('front_edit')) { _e('If it says \'Photo rotated\', the photo is rotated.', 'wp-photo-album-plus'); } else { $refresh = '<a onclick="wppaReload()" >' . __('Refresh', 'wp-photo-album-plus') . '</a>'; echo sprintf(__('If it says \'Photo rotated\', the photo is rotated. %s the page.', 'wp-photo-album-plus'), $refresh); } ?> </span> <?php } ?> </th> <td> <?php $src = wppa_get_thumb_url($photo['id']); $big = wppa_get_photo_url($photo['id']); if ($is_video) { reset($is_video); $big = str_replace('xxx', current($is_video), $big); ?> <a href="<?php echo $big; ?> " target="_blank" title="<?php _e('Preview fullsize video', 'wp-photo-album-plus'); ?> " > <?php echo wppa_get_video_html(array('id' => $photo['id'], 'width' => '160', 'height' => '160' * wppa_get_videoy($photo['id']) / wppa_get_videox($photo['id']), 'controls' => false, 'use_thumb' => true)); ?> </a><?php } else { if ($has_audio) { $big = wppa_fix_poster_ext($big, $photo['id']); $src = wppa_fix_poster_ext($src, $photo['id']); } ?> <a href="<?php echo $big; ?> " target="_blank" title="<?php _e('Preview fullsize photo', 'wp-photo-album-plus'); ?> " > <img src="<?php echo $src; ?> " alt="<?php echo $photo['name']; ?> " style="max-width: 160px; vertical-align:middle;" /> </a><?php if ($has_audio) { $audio = wppa_get_audio_html(array('id' => $photo['id'], 'width' => '160', 'controls' => true)); ?> <br /> <?php if ($audio) { echo $audio; } else { echo '<span style="color:red;">' . __('Audio disabled', 'wp-photo-album-plus') . '</span>'; } } } ?> </td> </tr> <!-- Upload --> <tr> <th > <label><?php _e('Upload:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $timestamp = $photo['timestamp']; if ($timestamp) { echo wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $timestamp) . ' ' . __('local time', 'wp-photo-album-plus') . ' '; } if ($photo['owner']) { if (wppa_switch('photo_owner_change') && wppa_user_is('administrator')) { echo '</td></tr><tr><th><label>' . __('Owned by:', 'wp-photo-album-plus') . '</label></th><td>'; echo '<input type="text" onkeyup="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'owner\', this )" onchange="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'owner\', this )" value="' . $photo['owner'] . '" />'; } else { echo __('By:', 'wp-photo-album-plus') . ' ' . $photo['owner']; } } ?> </td> </tr> <!-- Modified --> <tr> <th> <label><?php _e('Modified:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $modified = $photo['modified']; if ($modified > $timestamp) { echo wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $modified) . ' ' . __('local time', 'wp-photo-album-plus'); } else { _e('Not modified', 'wp-photo-album-plus'); } ?> </td> </tr> <!-- EXIF Date --> <tr> <th> <label><?php _e('EXIF Date', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php if (wppa_user_is('administrator')) { echo '<input type="text" onkeyup="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'exifdtm\', this )" onchange="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'exifdtm\', this )" value="' . $photo['exifdtm'] . '" />'; } else { echo $photo['exifdtm']; } ?> </td> </tr> <!-- Rating --> <tr > <th > <label><?php _e('Rating:', 'wp-photo-album-plus'); ?> </label> </th> <td class="wppa-rating" > <?php $entries = wppa_get_rating_count_by_id($photo['id']); if ($entries) { echo __('Entries:', 'wp-photo-album-plus') . ' ' . $entries . '. ' . __('Mean value:', 'wp-photo-album-plus') . ' ' . wppa_get_rating_by_id($photo['id'], 'nolabel') . '.'; } else { _e('No ratings for this photo.', 'wp-photo-album-plus'); } $dislikes = wppa_dislike_get($photo['id']); if ($dislikes) { echo ' <span style="color:red" >' . sprintf(__('Disliked by %d visitors', 'wp-photo-album-plus'), $dislikes) . '</span>'; } $pending = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = %s AND `status` = 'pending'", $photo['id'])); if ($pending) { echo ' <span style="color:orange" >' . sprintf(__('%d pending votes.', 'wp-photo-album-plus'), $pending) . '</span>'; } ?> </td> </tr> <!-- Views --> <tr > <th > <label><?php _e('Views', 'wp-photo-album-plus'); ?> </label> </th> <td > <?php echo $photo['views']; ?> </td> </tr> <!-- P_order --> <?php if (!wppa_switch('porder_restricted') || current_user_can('administrator')) { ?> <tr > <th > <label><?php _e('Photo sort order #:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" id="porder-<?php echo $photo['id']; ?> " value="<?php echo $photo['p_order']; ?> " style="width: 50px" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'p_order', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'p_order', this )" /> </td> </tr> <?php } ?> <?php if (!isset($_REQUEST['quick'])) { ?> <?php if (!isset($album_select[$photo['album']])) { $album_select[$photo['album']] = wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $photo['album'], 'selected' => '0', 'addpleaseselect' => true)); } ?> <!-- Move --> <tr > <th > <input type="button" style="" onclick="if( document.getElementById( 'moveto-<?php echo $photo['id']; ?> ' ).value != 0 ) { if ( confirm( '<?php _e('Are you sure you want to move this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'moveto', document.getElementById( 'moveto-<?php echo $photo['id']; ?> ' ) ) } else { alert( '<?php _e('Please select an album to move the photo to first.', 'wp-photo-album-plus'); ?> ' ); return false;}" value="<?php echo esc_attr(__('Move photo to', 'wp-photo-album-plus')); ?> " /> </th> <td > <select id="moveto-<?php echo $photo['id']; ?> " style="width:100%;" ><?php echo $album_select[$photo['album']]; ?> </select> </td> </tr> <!-- Copy --> <tr > <th > <input type="button" style="" onclick="if ( document.getElementById( 'copyto-<?php echo $photo['id']; ?> ' ).value != 0 ) { if ( confirm( '<?php _e('Are you sure you want to copy this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'copyto', document.getElementById( 'copyto-<?php echo $photo['id']; ?> ' ) ) } else { alert( '<?php _e('Please select an album to copy the photo to first.', 'wp-photo-album-plus'); ?> ' ); return false;}" value="<?php echo esc_attr(__('Copy photo to', 'wp-photo-album-plus')); ?> " /> </th> <td > <select id="copyto-<?php echo $photo['id']; ?> " style="width:100%;" ><?php echo $album_select[$photo['album']]; ?> </select> </td> </tr> <?php } ?> <!-- Delete --> <?php if (!wppa('front_edit')) { ?> <tr > <th style="padding-top:0; padding-bottom:4px;"> <input type="button" style="color:red;" onclick="if ( confirm( '<?php _e('Are you sure you want to delete this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxDeletePhoto( <?php echo $photo['id']; ?> )" value="<?php echo esc_attr(__('Delete photo', 'wp-photo-album-plus')); ?> " /> </th> </tr> <?php } ?> <!-- Auto Page --> <?php if (wppa_switch('auto_page') && (current_user_can('edit_posts') || current_user_can('edit_pages'))) { ?> <tr style=="vertical-align:bottom;" > <th style="padding-top:0; padding-bottom:4px;"> <label> <?php _e('Autopage Permalink:', 'wp-photo-album-plus'); ?> </label> </th> <td > <?php echo get_permalink(wppa_get_the_auto_page($photo['id'])); ?> </td> </tr> <?php } ?> <!-- Link url --> <?php if (!wppa_switch('link_is_restricted') || current_user_can('administrator')) { ?> <tr > <th > <label><?php _e('Link url:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:60%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linkurl', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linkurl', this )" value="<?php echo stripslashes($photo['linkurl']); ?> " /> <select style="float:right;" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktarget', this )" > <option value="_self" <?php if ($photo['linktarget'] == '_self') { echo 'selected="selected"'; } ?> ><?php _e('Same tab', 'wp-photo-album-plus'); ?> </option> <option value="_blank" <?php if ($photo['linktarget'] == '_blank') { echo 'selected="selected"'; } ?> ><?php _e('New tab', 'wp-photo-album-plus'); ?> </option> </select> </td> </tr> <!-- Link title --> <tr > <th > <label><?php _e('Link title:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:97%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktitle', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktitle', this )" value="<?php echo stripslashes($photo['linktitle']); ?> " /> </td> </tr> <?php if (current_user_can('wppa_settings')) { ?> <tr style="padding-left:10px; font-size:9px; line-height:10px; color:#666;" > <td colspan="2" style="padding-top:0" > <?php _e('If you want this link to be used, check \'PS Overrule\' checkbox in table VI.', 'wp-photo-album-plus'); ?> </td> </tr> <?php } ?> <?php } ?> <!-- Alt custom field --> <?php if (wppa_opt('alt_type') == 'custom') { ?> <tr > <th > <label><?php _e('HTML Alt attribute:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:100%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'alt', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'alt', this )" value="<?php echo stripslashes($photo['alt']); ?> " /> </td> </tr> <?php } ?> </tbody> </table> </div> <!-- Right half starts here --> <div style="width:50%; float:left; border-left:1px solid #ccc; margin-left:-1px;"> <table class="wppa-table wppa-photo-table" > <tbody> <!-- Filename --> <tr> <th> <label><?php _e('Filename:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php echo $photo['filename']; if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { ?> <input type="button" onclick="jQuery( '#re-up-<?php echo $photo['id']; ?> ' ).css( 'display', '' );" value="<?php _e('Update file', 'wp-photo-album-plus'); ?> " /> <?php } ?> </td> </tr> <?php if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { ?> <tr id="re-up-<?php echo $photo['id']; ?> " style="display:none" > <th> </th> <td> <form id="wppa-re-up-form-<?php echo $photo['id']; ?> " onsubmit="wppaReUpload( event,<?php echo $photo['id']; ?> , '<?php echo $photo['filename']; ?> ' )" > <input type="file" id="wppa-re-up-file-<?php echo $photo['id']; ?> " /> <input type="submit" id="wppa-re-up-butn-<?php echo $photo['id']; ?> " value="<?php _e('Upload', 'wp-photo-album-plus'); ?> " /> </form> </td> </tr> <?php } ?> <!--- Video sizes --> <?php if ($is_video) { ?> <tr> <th> <label><?php _e('Video size:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <tr> <td> <?php _e('Width:', 'wp-photo-album-plus'); ?> </td> <td> <input style="width:50px;margin:0 4px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videox', this ); " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videox', this ); " value="<?php echo $photo['videox']; ?> " /><?php echo sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_width')); ?> </td> </tr> <tr> <td> <?php _e('Height:', 'wp-photo-album-plus'); ?> </td> <td> <input style="width:50px;margin:0 4px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videoy', this ); " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videoy', this ); " value="<?php echo $photo['videoy']; ?> " /><?php echo sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_height')); ?> </td> </tr> </table> </td> </tr> <tr> <th> <label><?php _e('Formats:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <?php foreach ($is_video as $fmt) { echo '<tr>' . '<td>' . $fmt . '</td>' . '<td>' . __('Filesize:', 'wp-photo-album-plus') . '</td>' . '<td>' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($photo['id']))) . '</td>' . '</tr>'; } ?> </table> </td> </tr> <?php } ?> <!-- Audio --> <?php if ($has_audio) { ?> <tr> <th> <label><?php _e('Formats:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <?php foreach ($has_audio as $fmt) { echo '<tr>' . '<td>' . $fmt . '</td>' . '<td>' . __('Filesize:', 'wp-photo-album-plus') . '</td>' . '<td>' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($photo['id']))) . '</td>' . '</tr>'; } ?> </table> </td> </tr> <?php } ?> <!-- Filesizes --> <tr> <th> <label><?php $is_video || $has_audio ? _e('Poster:', 'wp-photo-album-plus') : _e('Photo sizes:', 'wp-photo-album-plus'); ?> </label> </th> <td> <table class="wppa-subtable" > <tr> <td> <?php _e('Source file:', 'wp-photo-album-plus'); ?> </td> <?php $sp = wppa_get_source_path($photo['id']); if (is_file($sp)) { $ima = getimagesize($sp); ?> <td> <?php echo $ima['0'] . ' x ' . $ima['1'] . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($sp); ?> </td> <td> <a style="cursor:pointer; font-weight:bold;" title="<?php _e('Remake display file and thumbnail file', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'remake', this )"><?php _e('Remake files', 'wp-photo-album-plus'); ?> </a> </td> <?php } else { ?> <td> <span style="color:orange;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <td> </td> <?php } ?> </tr> <tr> <td> <?php _e('Display file:', 'wp-photo-album-plus'); ?> </td> <?php $dp = wppa_fix_poster_ext(wppa_get_photo_path($photo['id']), $photo['id']); if (is_file($dp)) { ?> <td> <?php echo floor(wppa_get_photox($photo['id'])) . ' x ' . floor(wppa_get_photoy($photo['id'])) . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($dp); ?> </td> <td> </td> <?php } else { ?> <td> <span style="color:red;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <td> </td> <?php } ?> </tr> <tr> <td> <?php _e('Thumbnail file:', 'wp-photo-album-plus'); ?> </td> <?php $tp = wppa_fix_poster_ext(wppa_get_thumb_path($photo['id']), $photo['id']); if (is_file($tp)) { ?> <td> <?php echo floor(wppa_get_thumbx($photo['id'])) . ' x ' . floor(wppa_get_thumby($photo['id'])) . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($tp); ?> </td> <?php } else { ?> <td> <span style="color:red;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <?php } ?> <td> <a style="cursor:pointer; font-weight:bold;" title="<?php _e('Remake thumbnail file', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'remakethumb', this )"><?php _e('Remake', 'wp-photo-album-plus'); ?> </a> </td> </tr> </table> </td> </tr> <!-- Stereo --> <?php if (wppa_switch('enable_stereo')) { ?> <tr> <th> <label><?php _e('Stereophoto:', 'wp-photo-album-plus'); ?> </label> </th> <td> <select id="stereo-<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'stereo', this )" > <option value="0" <?php if ($photo['stereo'] == '0') { echo 'selected="selected" '; } ?> ><?php _e('no stereo image or ready anaglyph', 'wp-photo-album-plus'); ?> </option> <option value="1" <?php if ($photo['stereo'] == '1') { echo 'selected="selected" '; } ?> ><?php _e('Left - right stereo image', 'wp-photo-album-plus'); ?> </option> <option value="-1" <?php if ($photo['stereo'] == '-1') { echo 'selected="selected" '; } ?> ><?php _e('Right - left stereo image', 'wp-photo-album-plus'); ?> </option> <select> <td> </tr> <tr> <th> <label><?php _e('Images:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $files = glob(WPPA_UPLOAD_PATH . '/stereo/' . $photo['id'] . '-*.*'); if (!empty($files)) { sort($files); $c = 0; echo '<table><tbody>'; foreach ($files as $file) { if (!$c) { echo '<tr>'; } if (is_file($file)) { echo '<td style="padding:0;" ><a href="' . str_replace(WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $file) . '" target="_blank" >' . basename($file) . '</a></td>'; } if (strpos(basename($file), '_flat')) { $c++; } $c = ($c + 1) % 2; if (!$c) { echo '</tr>'; } } if ($c) { echo '<td style="padding:0;" ></td></tr>'; } echo '</tbody></table>'; } ?> </td> </tr> <?php } ?> <!-- Location --> <?php if ($photo['location'] || wppa_switch('geo_edit')) { ?> <tr> <th> <label><?php _e('Location:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $loc = $photo['location'] ? $photo['location'] : '///'; $geo = explode('/', $loc); echo $geo['0'] . ' ' . $geo['1'] . ' '; if (wppa_switch('geo_edit')) { ?> <?php _e('Lat:', 'wp-photo-album-plus'); ?> <input type="text" style="width:100px;" id="lat-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lat', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lat', this );" value="<?php echo $geo['2']; ?> " /> <?php _e('Lon:', 'wp-photo-album-plus'); ?> <input type="text" style="width:100px;" id="lon-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lon', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lon', this );" value="<?php echo $geo['3']; ?> " /> <?php if (!wppa('front_edit')) { ?> <span class="description"><br /><?php _e('Refresh the page after changing to see the degrees being updated', 'wp-photo-album-plus'); ?> </span> <?php } ?> <?php } ?> </td> </tr> <?php } ?> <!-- Name --> <tr > <th > <label><?php _e('Photoname:', 'wp-photo-album-plus'); ?> </label> </th> <?php if (wppa_switch('use_wp_editor')) { ?> <td> <input type="text" style="width:100%;" id="pname-<?php echo $photo['id']; ?> " value="<?php echo esc_attr(stripslashes($photo['name'])); ?> " /> <input type="button" class="button-secundary" value="<?php _e('Update Photo name', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', document.getElementById( 'pname-<?php echo $photo['id']; ?> ' ) );" /> </td> <?php } else { ?> <td> <input type="text" style="width:100%;" id="pname-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', this );" value="<?php echo esc_attr(stripslashes($photo['name'])); ?> " /> </td> <?php } ?> </tr> <!-- Description --> <?php if (!wppa_switch('desc_is_restricted') || wppa_user_is('administrator')) { ?> <tr> <th> <label><?php _e('Description:', 'wp-photo-album-plus'); ?> </label> </th> <?php if (wppa_switch('use_wp_editor')) { ?> <td> <?php $alfaid = wppa_alfa_id($photo['id']); // $quicktags_settings = array( 'buttons' => 'strong,em,link,block,ins,ul,ol,li,code,close' ); wp_editor(stripslashes($photo['description']), 'wppaphotodesc' . $alfaid, array('wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => true)); //, 'quicktags' => $quicktags_settings ) ); ?> <input type="button" class="button-secundary" value="<?php _e('Update Photo description', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', document.getElementById( 'wppaphotodesc'+'<?php echo $alfaid; ?> ' ), false, '<?php echo $alfaid; ?> ' )" /> <img id="wppa-photo-spin-<?php echo $photo['id']; ?> " src="<?php echo wppa_get_imgdir() . 'wpspin.gif'; ?> " style="visibility:hidden" /> </td> <?php } else { ?> <td> <textarea style="width: 100%; height:120px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', this )" ><?php echo stripslashes($photo['description']); ?> </textarea> </td> <?php } ?> </tr> <?php } else { ?> <tr> <th> <label><?php _e('Description:', 'wp-photo-album-plus'); ?> </label> </th> <td> <div style="width: 100%; height:120px; overflow:auto;" ><?php echo stripslashes($photo['description']); ?> </div> </td> </tr> <?php } ?> <!-- Custom --> <?php if (wppa_switch('custom_fields')) { $custom = wppa_get_photo_item($photo['id'], 'custom'); if ($custom) { $custom_data = unserialize($custom); } else { $custom_data = array('', '', '', '', '', '', '', '', '', ''); } foreach (array_keys($custom_data) as $key) { if (wppa_opt('custom_caption_' . $key)) { ?> <tr> <th> <label><?php echo wppa_opt('custom_caption_' . $key) . ':<br /><small>(w#cc' . $key . ')</small>'; ?> </label> </th> <td> <?php echo '<small>(w#cd' . $key . ')</small>'; ?> <input type="text" style="width:85%; float:right;" id="pname-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'custom_<?php echo $key; ?> ', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'custom_<?php echo $key; ?> ', this );" value="<?php echo esc_attr(stripslashes($custom_data[$key])); ?> " /> </td> </tr> <?php } } } ?> <!-- Tags --> <tr style="vertical-align:middle;" > <th > <label ><?php _e('Tags:', 'wp-photo-album-plus'); ?> </label> <span class="description" > <br /> </span> </th> <td > <input id="tags-<?php echo $photo['id']; ?> " type="text" style="width:100%;" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'tags', this )" value="<?php echo stripslashes(trim($photo['tags'], ',')); ?> " /> <span class="description" > <?php _e('Separate tags with commas.', 'wp-photo-album-plus'); ?> <?php _e('Examples:', 'wp-photo-album-plus'); ?> <select onchange="wppaAddTag( this.value, 'tags-<?php echo $photo['id']; ?> ' ); wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'tags', document.getElementById( 'tags-<?php echo $photo['id']; ?> ' ) )" > <?php $taglist = wppa_get_taglist(); if (is_array($taglist)) { echo '<option value="" >' . __('- select -', 'wp-photo-album-plus') . '</option>'; foreach ($taglist as $tag) { echo '<option value="' . $tag['tag'] . '" >' . $tag['tag'] . '</option>'; } } else { echo '<option value="0" >' . __('No tags yet', 'wp-photo-album-plus') . '</option>'; } ?> </select> <?php _e('Select to add', 'wp-photo-album-plus'); ?> </span> </td> </tr> <!-- Status --> <tr style="vertical-align:middle;" > <th> <label ><?php _e('Status:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php if ((current_user_can('wppa_admin') || current_user_can('wppa_moderate')) && !isset($_REQUEST['quick'])) { ?> <table> <tr> <td> <select id="status-<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'status', this ); wppaPhotoStatusChange( <?php echo $photo['id']; ?> ); "> <option value="pending" <?php if ($photo['status'] == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('Pending', 'wp-photo-album-plus'); ?> </option> <option value="publish" <?php if ($photo['status'] == 'publish') { echo 'selected="selected"'; } ?> ><?php _e('Publish', 'wp-photo-album-plus'); ?> </option> <?php if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) { $dis = ' disabled'; } else { $dis = ''; } ?> <option value="featured" <?php if ($photo['status'] == 'featured') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Featured', 'wp-photo-album-plus'); ?> </option> <option value="gold" <?php if ($photo['status'] == 'gold') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Gold', 'wp-photo-album-plus'); ?> </option> <option value="silver" <?php if ($photo['status'] == 'silver') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Silver', 'wp-photo-album-plus'); ?> </option> <option value="bronze" <?php if ($photo['status'] == 'bronze') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Bronze', 'wp-photo-album-plus'); ?> </option> <option value="scheduled" <?php if ($photo['status'] == 'scheduled') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Scheduled', 'wp-photo-album-plus'); ?> </option> <option value="private" <?php if ($photo['status'] == 'private') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Private', 'wp-photo-album-plus'); ?> </option> </select> </td> <td class="wppa-datetime-<?php echo $photo['id']; ?> " > <?php echo wppa_get_date_time_select_html('photo', $photo['id'], true); ?> </td> </tr> </table> <?php } else { ?> <input type="hidden" id="status-<?php echo $photo['id']; ?> " value="<?php echo $photo['status']; ?> " /> <table> <tr> <td> <?php if ($photo['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'publish') { _e('Publish', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'featured') { _e('Featured', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'gold') { _e('Gold', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'silver') { _e('Silver', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'bronze') { _e('Bronze', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'scheduled') { _e('Scheduled', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'private') { _e('Private', 'wp-photo-album-plus'); } ?> </td> <td class="wppa-datetime-<?php echo $photo['id']; ?> " > <?php echo wppa_get_date_time_select_html('photo', $photo['id'], false); ?> </td> </tr> </table> <?php } ?> <span id="psdesc-<?php echo $photo['id']; ?> " class="description" style="display:none;" ><?php _e('Note: Featured photos should have a descriptive name; a name a search engine will look for!', 'wp-photo-album-plus'); ?> </span> </td> </tr> <!-- Watermark --> <?php if (!$is_video || is_file(wppa_fix_poster_ext(wppa_get_photo_path($photo['id']), $photo['id']))) { ?> <tr style="vertical-align:middle;" > <th > <label><?php _e('Watermark:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $user = wppa_get_user(); if (wppa_switch('watermark_on')) { if (wppa_switch('watermark_user') || current_user_can('wppa_settings')) { echo __('File:', 'wppa', 'wp-photo-album-plus') . ' '; ?> <select id="wmfsel_<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'wppa_watermark_file_<?php echo $user; ?> ', this );" > <?php echo wppa_watermark_file_select(); ?> </select> <?php echo '<br />' . __('Pos:', 'wp-photo-album-plus') . ' '; ?> <select id="wmpsel_<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'wppa_watermark_pos_<?php echo $user; ?> ', this );" > <?php echo wppa_watermark_pos_select(); ?> </select> <input type="button" class="button-secundary" value="<?php _e('Apply watermark', 'wp-photo-album-plus'); ?> " onclick="if ( confirm( '<?php echo esc_js(__('Are you sure? Once applied it can not be removed!', 'wp-photo-album-plus')) . '\\n\\n' . esc_js(__('And I do not know if there is already a watermark on this photo', 'wp-photo-album-plus')); ?> ' ) ) wppaAjaxApplyWatermark( <?php echo $photo['id']; ?> , document.getElementById( 'wmfsel_<?php echo $photo['id']; ?> ' ).value, document.getElementById( 'wmpsel_<?php echo $photo['id']; ?> ' ).value )" /> <?php } else { echo __('File:', 'wppa', 'wp-photo-album-plus') . ' ' . __($wmfile, 'wp-photo-album-plus'); if ($wmfile != '--- none ---') { echo ' ' . __('Pos:', 'wp-photo-album-plus') . ' ' . $wmpos; } } ?> <img id="wppa-water-spin-<?php echo $photo['id']; ?> " src="<?php echo wppa_get_imgdir() . 'wpspin.gif'; ?> " style="visibility:hidden" /><?php } else { _e('Not configured', 'wp-photo-album-plus'); } ?> </td> </tr> <?php } ?> <!-- Remark --> <tr style="vertical-align: middle;" > <th > <label style="color:#070"><?php _e('Remark:', 'wp-photo-album-plus'); ?> </label> </th> <td id="photostatus-<?php echo $photo['id']; ?> " style="padding-left:10px; width: 400px;"> <?php if (wppa_is_video($photo['id'])) { echo sprintf(__('Video %s is not modified yet', 'wp-photo-album-plus'), $photo['id']); } else { echo sprintf(__('Photo %s is not modified yet', 'wp-photo-album-plus'), $photo['id']); } ?> </td> </tr> </tbody> </table> <script type="text/javascript">wppaPhotoStatusChange( <?php echo $photo['id']; ?> )</script> </div> <div style="clear:both;"></div> <?php if (!isset($_REQUEST['quick'])) { ?> <div class="wppa-links" > <table style="width:100%" > <tbody> <?php if (current_user_can('edit_posts') || current_user_can('edit_pages')) { ?> <tr> <td><?php _e('Single image shortcode', 'wp-photo-album-plus'); ?> :</td> <td><?php echo esc_js('[wppa type="photo" photo="' . $photo['id'] . '" size="' . wppa_opt('fullsize') . '"][/wppa]'); ?> </td> </tr> <?php } ?> <?php if (is_file(wppa_get_source_path($photo['id']))) { ?> <tr> <td><?php _e('Permalink', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_source_pl($photo['id']); ?> </td> </tr> <?php } ?> <tr> <td><?php _e('Hi resolution url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_hires_url($photo['id']); ?> </td> </tr> <?php if (is_file(wppa_get_photo_path($photo['id']))) { ?> <tr> <td><?php _e('Display file url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_lores_url($photo['id']); ?> </td> </tr> <?php } ?> <?php if (is_file(wppa_get_thumb_path($photo['id']))) { ?> <tr> <td><?php _e('Thumbnail file url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_tnres_url($photo['id']); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php } ?> </div> <!-- Comments --> <?php $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s ORDER BY `timestamp` DESC", $photo['id']), ARRAY_A); if ($comments) { ?> <div class="widefat" style="width:99%; font-size:11px;" > <table class="wppa-table widefat wppa-setting-table" > <thead> <tr style="font-weight:bold;" > <td style="padding:0 4px;" >#</td> <td style="padding:0 4px;" >User</td> <td style="padding:0 4px;" >Time since</td> <td style="padding:0 4px;" >Status</td> <td style="padding:0 4px;" >Comment</td> </tr> </thead> <tbody> <?php foreach ($comments as $comment) { echo ' <tr> <td style="padding:0 4px;" >' . $comment['id'] . '</td> <td style="padding:0 4px;" >' . $comment['user'] . '</td> <td style="padding:0 4px;" >' . wppa_get_time_since($comment['timestamp']) . '</td>'; if (current_user_can('wppa_comments') || current_user_can('wppa_moderate') || wppa_get_user() == $photo['owner'] && wppa_switch('owner_moderate_comment')) { $p = $comment['status'] == 'pending' ? 'selected="selected" ' : ''; $a = $comment['status'] == 'approved' ? 'selected="selected" ' : ''; $s = $comment['status'] == 'spam' ? 'selected="selected" ' : ''; $t = $comment['status'] == 'trash' ? 'selected="selected" ' : ''; echo ' <td style="padding:0 4px;" > <select style="height: 20px; font-size: 11px; padding:0;" onchange="wppaAjaxUpdateCommentStatus( ' . $photo['id'] . ', ' . $comment['id'] . ', this.value )" > <option value="pending" ' . $p . '>' . __('Pending', 'wp-photo-album-plus') . '</option> <option value="approved" ' . $a . '>' . __('Approved', 'wp-photo-album-plus') . '</option> <option value="spam" ' . $s . '>' . __('Spam', 'wp-photo-album-plus') . '</option> <option value="trash" ' . $t . '>' . __('Trash', 'wp-photo-album-plus') . '</option> </select > </td> '; } else { echo '<td style="padding:0 4px;" >'; if ($comment['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'approved') { _e('Approved', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'spam') { _e('Spam', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'trash') { _e('Trash', 'wp-photo-album-plus'); } echo '</td>'; } echo '<td style="padding:0 4px;" >' . $comment['comment'] . '</td> </tr> '; } ?> </tbody> </table> </div> <?php } ?> <!-- </div> --> <div style="clear:both;margin-top:7px;"></div> <?php } /* foreach photo */ wppa_admin_page_links($page, $pagesize, $count, $link); } /* photos not empty */ }
function wppa_album_photos($album = '', $photo = '', $owner = '', $moderate = false) { global $wpdb; // Check input wppa_vfy_arg('wppa-page'); $pagesize = wppa_opt('photo_admin_pagesize'); $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1'; $skip = ($page - '1') * $pagesize; $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize; // Edit the photos in a specific album if ($album) { // Special album case: search (see last album line in album table) if ($album == 'search') { $count = wppa_get_edit_search_photos('', 'count_only'); $photos = wppa_get_edit_search_photos($limit); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_admin_menu' . '&tab=edit' . '&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring'])); } else { $counts = wppa_treecount_a($album); $count = $counts['selfphotos'] + $counts['pendphotos']; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` = %s " . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_admin_menu' . '&tab=edit' . '&edit_id=' . $album); } } elseif ($photo && !$moderate) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `id` = %s", $photo), ARRAY_A); $link = ''; } elseif ($owner) { $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `owner` = %s", $owner)); $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `owner` = %s " . "ORDER BY `timestamp` DESC " . $limit, $owner), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_edit_photo'); } elseif ($moderate) { // Can i moderate? if (!current_user_can('wppa_moderate')) { wp_die(__('You do not have the rights to do this', 'wp-photo-album-plus')); } // Moderate a single photo if ($photo) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `id` = %s", $photo), ARRAY_A); $link = ''; } else { $cmt = $wpdb->get_results("SELECT `photo` " . "FROM `" . WPPA_COMMENTS . "` " . "WHERE `status` = 'pending' " . "OR `status` = 'spam'", ARRAY_A); if ($cmt) { $orphotois = ''; foreach ($cmt as $c) { $orphotois .= "OR `id` = " . $c['photo'] . " "; } } else { $orphotois = ''; } $count = $wpdb->get_var("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` = 'pending' " . $orphotois); $photos = $wpdb->get_results("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` = 'pending' " . $orphotois . " " . "ORDER BY `timestamp` DESC " . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_moderate_photos'); } // No photos to moderate if (empty($photos)) { // Single photo moderate requested if ($photo) { echo '<p>' . __('This photo is no longer awaiting moderation.', 'wp-photo-album-plus') . '</p>'; } else { echo '<p>' . __('There are no photos awaiting moderation at this time.', 'wp-photo-album-plus') . '</p>'; } // If i am admin, i can edit all photos here, sorted by timestamp desc if (wppa_user_is('administrator')) { echo '<h3>' . __('Manage all photos by timestamp', 'wp-photo-album-plus') . '</h3>'; $count = $wpdb->get_var("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "`"); $photos = $wpdb->get_results("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "ORDER BY `timestamp` DESC" . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_moderate_photos'); } else { return; } } } else { wppa_dbg_msg('Missing required argument in wppa_album_photos() 1', 'red', 'force'); return; } // Quick edit skips a few time consuming settings like copy and move to other album $quick = isset($_REQUEST['quick']); if ($link && $quick) { $link .= '&quick'; } // In case it is a seaerch and edit, show the search statistics wppa_show_search_statistics(); // If no photos selected produce apprpriate message and quit if (empty($photos)) { // A specific photo requested if ($photo) { echo '<div id="photoitem-' . $photo . '" class="photoitem" style="width:100%; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 );">' . '<span style="color:red">' . sprintf(__('Photo %s has been removed.', 'wp-photo-album-plus'), $photo) . '</span>' . '</div>'; } else { // Search if (isset($_REQUEST['wppa-searchstring'])) { echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>'; } else { echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>'; } } return; } else { // Local js functions placed here as long as there is not yet a possibility to translate texts in js files ?> <script> function wppaTryMove( id, video ) { var query; if ( ! jQuery( '#target-' + id ).val() ) { alert( '<?php echo esc_js(__('Please select an album to move to first.', 'wp-photo-album-plus')); ?> ' ); return false; } if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to move this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to move this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'moveto', document.getElementById( 'target-' + id ) ); } } function wppaTryCopy( id, video ) { var query; if ( ! jQuery( '#target-' + id ).val() ) { alert( '<?php echo esc_js(__('Please select an album to copy to first.', 'wp-photo-album-plus')); ?> ' ); return false; } if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to copy this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to copy this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'copyto', document.getElementById( 'target-' + id ) ); } } function wppaTryDelete( id, video ) { var query; if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to delete this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to delete this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxDeletePhoto( id ) } } function wppaTryRotLeft( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo left?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rotleft', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryRot180( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo 180°?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rot180', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryRotRight( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo right?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rotright', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryFlip( id ) { var query = '<?php echo esc_js(__('Are you sure you want to flip this photo?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'flip', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryWatermark( id ) { var wmFile = jQuery( '#wmfsel_' + id ).val(); if ( wmFile == '--- none ---' ) { alert( '<?php echo esc_js(__('No watermark selected', 'wp-photo-album-plus')); ?> ' ); return; } var query = '<?php echo esc_js(__('Are you sure? Once applied it can not be removed!', 'wp-photo-album-plus')); ?> '; query += '\n'; query += '<?php echo esc_js(__('And I do not know if there is already a watermark on this photo', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxApplyWatermark( id, document.getElementById( 'wmfsel_' + id ).value, document.getElementById( 'wmpsel_' + id ).value ); } } </script> <?php // Get the current watermark file settings $wms = array('toplft' => __('top - left', 'wp-photo-album-plus'), 'topcen' => __('top - center', 'wp-photo-album-plus'), 'toprht' => __('top - right', 'wp-photo-album-plus'), 'cenlft' => __('center - left', 'wp-photo-album-plus'), 'cencen' => __('center - center', 'wp-photo-album-plus'), 'cenrht' => __('center - right', 'wp-photo-album-plus'), 'botlft' => __('bottom - left', 'wp-photo-album-plus'), 'botcen' => __('bottom - center', 'wp-photo-album-plus'), 'botrht' => __('bottom - right', 'wp-photo-album-plus')); $temp = wppa_get_water_file_and_pos('0'); $wmfile = isset($temp['select']) ? $temp['select'] : ''; $wmpos = isset($temp['pos']) && isset($wms[$temp['pos']]) ? $wms[$temp['pos']] : ''; $mvt = esc_attr(__('Move video', 'wp-photo-album-plus')); $mpt = esc_attr(__('Move photo', 'wp-photo-album-plus')); $cvt = esc_attr(__('Copy video', 'wp-photo-album-plus')); $cpt = esc_attr(__('Copy photo', 'wp-photo-album-plus')); // Display the pagelinks wppa_admin_page_links($page, $pagesize, $count, $link); // Display all photos foreach ($photos as $photo) { // We may not use extract(), so we do something like it here manually, hence controlled. $id = $photo['id']; $timestamp = $photo['timestamp']; $modified = $photo['modified']; $owner = $photo['owner']; $crypt = $photo['crypt']; $album = $photo['album']; $name = stripslashes($photo['name']); $description = stripslashes($photo['description']); $exifdtm = $photo['exifdtm']; $views = $photo['views']; $clicks = $photo['clicks']; $p_order = $photo['p_order']; $linktarget = $photo['linktarget']; $linkurl = $photo['linkurl']; $linktitle = stripslashes($photo['linktitle']); $alt = stripslashes($photo['alt']); $filename = $photo['filename']; $videox = $photo['videox']; $videoy = $photo['videoy']; $location = $photo['location']; $status = $photo['status']; $tags = trim(stripslashes($photo['tags']), ','); $stereo = $photo['stereo']; // See if item is a multimedia item $is_multi = wppa_is_multi($id); $is_video = wppa_is_video($id); // returns array of extensions $b_is_video = empty($is_video) ? 0 : 1; // boolean $has_audio = wppa_has_audio($id); // returns array of extensions $b_has_audio = empty($has_audio) ? 0 : 1; // boolean // Various usefull vars $owner_editable = wppa_switch('photo_owner_change') && wppa_user_is('administrator'); $sortby_orderno = wppa_get_album_item($album, 'p_order_by') == '1' || wppa_get_album_item($album, 'p_order_by') == '-1'; echo "\n" . '<a id="photo_' . $id . '" ></a>'; echo '<div' . ' id="photoitem-' . $id . '"' . ' class="wppa-table-wrap"' . ' style="width:100%;position:relative;"' . ' >'; echo '<input' . ' type="hidden"' . ' id="photo-nonce-' . $id . '"' . ' value="' . wp_create_nonce('wppa_nonce_' . $id) . '"' . ' />'; echo "\n" . '<!-- Section 1 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>'; // -- Preview thumbnail --- echo '<tr>' . '<td>'; $src = wppa_get_thumb_url($id); $big = wppa_get_photo_url($id); if ($is_video) { reset($is_video); $big = str_replace('xxx', current($is_video), $big); echo '<a' . ' href="' . $big . '"' . ' target="_blank"' . ' title="' . esc_attr(__('Preview fullsize video', 'wp-photo-album-plus')) . '"' . ' >' . wppa_get_video_html(array('id' => $id, 'tagid' => 'video-' . $id, 'width' => '160', 'height' => '160' * wppa_get_videoy($id) / wppa_get_videox($id), 'controls' => false, 'use_thumb' => true)) . '</a>'; } else { if ($has_audio) { $big = wppa_fix_poster_ext($big, $id); $src = wppa_fix_poster_ext($src, $id); } echo '<a' . ' href="' . $big . '"' . ' target="_blank"' . ' title="' . esc_attr(__('Preview fullsize photo', 'wp-photo-album-plus')) . '"' . ' >' . '<img' . ' src="' . $src . '"' . ' alt="' . esc_attr($name) . '"' . ' style="max-width: 160px; vertical-align:middle;"' . ' />' . '</a>'; if ($has_audio) { $audio = wppa_get_audio_html(array('id' => $id, 'tagid' => 'audio-' . $id, 'width' => '160', 'controls' => true)); echo '<br />' . ($audio ? $audio : '<span style="color:red;">' . __('Audio disabled', 'wp-photo-album-plus') . '</span>'); } } echo '</td>'; echo '<td>' . 'ID = ' . $id . '. ' . __('Crypt:', 'wp-photo-album-plus') . ' ' . $crypt . '. ' . __('Filename:', 'wp-photo-album-plus') . ' ' . $filename . '. ' . __('Upload:', 'wp-photo-album-plus') . ' ' . wppa_local_date('', $timestamp) . ' ' . __('local time', 'wp-photo-album-plus') . '. ' . ($owner_editable ? '' : __('By:', 'wp-photo-album-plus') . ' ' . $owner); if ($owner_editable) { echo __('Owned by:', 'wp-photo-album-plus') . '<input' . ' type="text"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'owner\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'owner\', this )"' . ' value="' . $owner . '"' . ' />'; } echo ' ' . sprintf(__('Album: %d (%s).', 'wp-photo-album-plus'), $album, wppa_get_album_name($album)); // Modified if ($modified > $timestamp) { echo ' ' . __('Modified:', 'wp-photo-album-plus') . ' ' . wppa_local_date('', $modified) . ' ' . __('local time', 'wp-photo-album-plus'); } else { echo ' ' . __('Not modified', 'wp-photo-album-plus'); } echo '. ' . __('EXIF Date:', 'wp-photo-album-plus'); if (wppa_user_is('administrator')) { // Admin may edit exif date echo '<input' . ' type="text"' . ' style="width:125px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'exifdtm\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'exifdtm\', this )"' . ' value="' . $exifdtm . '"' . ' />'; } else { echo $exifdtm . '.'; } echo ' '; // Location if ($photo['location'] || wppa_switch('geo_edit')) { echo __('Location:', 'wp-photo-album-plus') . ' '; $loc = $location ? $location : '///'; $geo = explode('/', $loc); echo $geo['0'] . ' ' . $geo['1'] . '. '; if (wppa_switch('geo_edit')) { echo __('Lat:', 'wp-photo-album-plus') . '<input' . ' type="text"' . ' style="width:100px;"' . ' id="lat-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'lat\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'lat\', this );"' . ' value="' . $geo['2'] . '"' . ' />' . __('Lon:', 'wp-photo-album-plus') . '<input type="text"' . ' style="width:100px;"' . ' id="lon-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'lon\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'lon\', this );"' . ' value="' . $geo['3'] . '"' . ' />'; } } // Changeable p_order echo __('Photo sort order #:', 'wp-photo-album-plus'); if ($sortby_orderno && (!wppa_switch('porder_restricted') || wppa_user_is('administrator'))) { echo '<input' . ' type="text"' . ' id="porder-' . $id . '"' . ' value="' . $p_order . '"' . ' style="width:30px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'p_order\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'p_order\', this )"' . ' />' . ' '; } else { echo $p_order . '. '; } // Rating $entries = wppa_get_rating_count_by_id($id); if ($entries) { if (wppa_opt('rating_display_type') == 'likes') { echo __('Likes:', 'wp-photo-album-plus') . ' ' . $entries . '. '; } else { echo __('Rating:', 'wp-photo-album-plus') . ' ' . __('Entries:', 'wp-photo-album-plus') . ' ' . $entries . ', ' . __('Mean value:', 'wp-photo-album-plus') . ' ' . wppa_get_rating_by_id($id, 'nolabel') . '. '; } } else { echo __('No ratings for this photo.', 'wp-photo-album-plus') . ' '; } $dislikes = wppa_dislike_get($id); if ($dislikes) { echo '<span style="color:red" >' . sprintf(__('Disliked by %d visitors', 'wp-photo-album-plus'), $dislikes) . '. ' . '</span>'; } $pending = wppa_pendrat_get($id); if ($pending) { echo '<span style="color:orange" >' . sprintf(__('%d pending votes.', 'wp-photo-album-plus'), $pending) . ' ' . '</span>'; } // Views if (wppa_switch('track_viewcounts')) { echo __('Views', 'wp-photo-album-plus') . ': ' . $views . '. '; } // Clicks if (wppa_switch('track_clickcounts')) { echo __('Clicks', 'wp-photo-album-plus') . ': ' . $clicks . '. '; } // Status echo '<br />' . __('Status:', 'wp-photo-album-plus') . ' '; if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) { if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) { $dis = ' disabled="disabled"'; } else { $dis = ''; } $sel = ' selected="selected"'; echo '<select' . ' id="status-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'status\', this ); wppaPhotoStatusChange( ' . $id . ' );"' . ' >' . '<option value="pending"' . ($status == 'pending' ? $sel : '') . ' >' . __('Pending', 'wp-photo-album-plus') . '</option>' . '<option value="publish"' . ($status == 'publish' ? $sel : '') . ' >' . __('Publish', 'wp-photo-album-plus') . '</option>' . '<option value="featured"' . ($status == 'featured' ? $sel : '') . $dis . ' >' . __('Featured', 'wp-photo-album-plus') . '</option>' . '<option value="gold"' . ($status == 'gold' ? $sel : '') . $dis . ' >' . __('Gold', 'wp-photo-album-plus') . '</option>' . '<option value="silver"' . ($status == 'silver' ? $sel : '') . $dis . ' >' . __('Silver', 'wp-photo-album-plus') . '</option>' . '<option value="bronze"' . ($status == 'bronze' ? $sel : '') . $dis . ' >' . __('Bronze', 'wp-photo-album-plus') . '</option>' . '<option value="scheduled"' . ($status == 'scheduled' ? $sel : '') . $dis . ' >' . __('Scheduled', 'wp-photo-album-plus') . '</option>' . '<option value="private"' . ($status == 'private' ? $sel : '') . $dis . ' >' . __('Private', 'wp-photo-album-plus') . '</option>' . '</select>' . wppa_get_date_time_select_html('photo', $id, true); } else { echo '<input' . ' type="hidden"' . ' id="status-' . $id . '"' . ' value="' . $status . '"' . ' />'; if ($status == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($status == 'publish') { _e('Publish', 'wp-photo-album-plus'); } elseif ($status == 'featured') { _e('Featured', 'wp-photo-album-plus'); } elseif ($status == 'gold') { _e('Gold', 'wp-photo-album-plus'); } elseif ($status == 'silver') { _e('Silver', 'wp-photo-album-plus'); } elseif ($status == 'bronze') { _e('Bronze', 'wp-photo-album-plus'); } elseif ($status == 'scheduled') { _e('Scheduled', 'wp-photo-album-plus'); } elseif ($status == 'private') { _e('Private', 'wp-photo-album-plus'); } echo wppa_get_date_time_select_html('photo', $id, false) . '<span id="psdesc-' . $id . '" class="description" style="display:none;" >' . __('Note: Featured photos should have a descriptive name; a name a search engine will look for!', 'wp-photo-album-plus') . '</span>'; } echo ' '; // Update status field echo __('Remark:', 'wp-photo-album-plus') . ' ' . '<span' . ' id="photostatus-' . $id . '"' . ' style="font-weight:bold;color:#00AA00;"' . ' >' . ($is_video ? sprintf(__('Video %s is not modified yet', 'wp-photo-album-plus'), $id) : sprintf(__('Photo %s is not modified yet', 'wp-photo-album-plus'), $id)) . '</span>'; // New Line echo '<br />'; // --- Available files --- echo __('Available files:', 'wp-photo-album-plus') . ' '; // Source echo __('Source file:', 'wp-photo-album-plus') . ' '; $sp = wppa_get_source_path($id); if (is_file($sp)) { $ima = getimagesize($sp); echo $ima['0'] . ' x ' . $ima['1'] . ' px, ' . wppa_get_filesize($sp) . '. '; } else { echo __('Unavailable', 'wp-photo-album-plus') . '. '; } // Display echo ($is_video || $has_audio ? __('Poster file:', 'wp-photo-album-plus') : __('Display file:', 'wp-photo-album-plus')) . ' '; $dp = wppa_fix_poster_ext(wppa_get_photo_path($id), $id); if (is_file($dp)) { echo floor(wppa_get_photox($id)) . ' x ' . floor(wppa_get_photoy($id)) . ' px, ' . wppa_get_filesize($dp) . '. '; } else { echo '<span style="color:red;" >' . __('Unavailable', 'wp-photo-album-plus') . '. ' . '</span>'; } // Thumbnail if (!$is_video) { echo __('Thumbnail file:', 'wp-photo-album-plus') . ' '; $tp = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id); if (is_file($tp)) { echo floor(wppa_get_thumbx($id)) . ' x ' . floor(wppa_get_thumby($id)) . ' px, ' . wppa_get_filesize($tp) . '. '; } else { echo '<span style="color:red;" >' . __('Unavailable', 'wp-photo-album-plus') . '. ' . '</span>'; } } // New line echo '<br />'; // Video if ($b_is_video) { echo __('Video size:', 'wp-photo-album-plus') . ' ' . __('Width:', 'wp-photo-album-plus') . '<input' . ' style="width:50px;margin:0 4px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'videox\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'videox\', this )"' . ' value="' . $videox . '"' . ' />' . sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_width')) . __('Height:', 'wp-photo-album-plus') . '<input' . ' style="width:50px;margin:0 4px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'videoy\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'videoy\', this )"' . ' value="' . $videoy . '"' . ' />' . sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_height')) . ' ' . __('Formats:', 'wp-photo-album-plus') . ' '; $c = 0; foreach ($is_video as $fmt) { echo $fmt . ' ' . __('Filesize:', 'wp-photo-album-plus') . ' ' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($id))); $c++; if ($c == count($is_video)) { echo '. '; } else { echo ', '; } } } // Audio if ($b_has_audio) { echo __('Formats:', 'wp-photo-album-plus') . ' '; $c = 0; foreach ($has_audio as $fmt) { echo $fmt . ' ' . __('Filesize:', 'wp-photo-album-plus') . ' ' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($id))); $c++; if ($c == count($is_video)) { echo '. '; } else { echo ', '; } } } echo '</td>' . '</tr>' . '</tbody>' . '</table>'; echo "\n" . '<!-- Section 2 -->'; if (wppa_switch('enable_stereo') && !$is_multi || (!$is_multi || is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id)))) { echo '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>' . '<tr>' . '<td>'; // Stereo if (wppa_switch('enable_stereo') && !$is_multi) { echo __('Stereophoto:', 'wp-photo-album-plus') . ' ' . '<select' . ' id="stereo-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'stereo\', this )"' . ' >' . '<option value="0"' . ($stereo == '0' ? ' selected="selected"' : '') . ' >' . __('no stereo image or ready anaglyph', 'wp-photo-album-plus') . '</option>' . '<option value="1"' . ($stereo == '1' ? ' selected="selected"' : '') . ' >' . __('Left - right stereo image', 'wp-photo-album-plus') . '</option>' . '<option value="-1"' . ($stereo == '-1' ? ' selected="selected"' : '') . ' >' . __('Right - left stereo image', 'wp-photo-album-plus') . '</option>' . '</select>' . ' '; __('Images:', 'wp-photo-album-plus') . ' '; $files = glob(WPPA_UPLOAD_PATH . '/stereo/' . $id . '-*.*'); $c = 0; if (!empty($files)) { sort($files); foreach ($files as $file) { echo '<a href="' . str_replace(WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $file) . '" target="_blank" >' . basename($file) . '</a>'; $c++; if ($c == count($files)) { echo '. '; } else { echo ', '; } } } } // Watermark if (!$is_multi || is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id))) { echo __('Watermark:', 'wp-photo-album-plus') . ' '; if (wppa_switch('watermark_on')) { $user = wppa_get_user(); if (wppa_switch('watermark_user') || current_user_can('wppa_settings')) { echo '<select' . ' id="wmfsel_' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'wppa_watermark_file_' . $user . '\', this );"' . ' >' . wppa_watermark_file_select() . '</select>' . __('Pos:', 'wp-photo-album-plus') . ' ' . '<select' . ' id="wmpsel_' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'wppa_watermark_pos_' . $user . '\', this );"' . ' >' . wppa_watermark_pos_select() . '</select>' . '<input' . ' type="button"' . ' class="button-secundary"' . ' value="' . esc_attr(__('Apply watermark', 'wp-photo-album-plus')) . '"' . ' onclick="wppaTryWatermark( ' . $id . ' )"' . ' />'; } else { echo __('File:', 'wp-photo-album-plus') . ' ' . __($wmfile, 'wp-photo-album-plus') . ' '; if ($wmfile != '--- none ---') { echo __('Pos:', 'wp-photo-album-plus') . ' ' . $wmpos; } } echo '<img' . ' id="wppa-water-spin-' . $id . '"' . ' src="' . wppa_get_imgdir() . 'spinner.gif' . '"' . ' alt="Spin"' . ' style="visibility:hidden"' . ' />'; } else { echo __('Not configured', 'wp-photo-album-plus'); } echo ' '; } echo '</td>' . '</tr>' . '</tbody>' . '</table>'; } echo "\n" . '<!-- Section 3 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>' . '<tr>' . '<td>'; // --- Actions --- // Rotate if (!$b_is_video) { echo '<input' . ' type="button"' . ' onclick="wppaTryRotLeft( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate left', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryRot180( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate 180°', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryRotRight( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate right', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryFlip( ' . $id . ' )"' . ' value="' . esc_attr(__('Flip', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Remake displayfiles if (!$is_video) { echo '<input' . ' type="button"' . ' title="' . esc_attr(__('Remake display file and thumbnail file', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'remake\', this, ' . (wppa('front_edit') ? 'false' : 'true') . ' )"' . ' value="' . esc_attr(__('Remake files', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Remake thumbnail if (!$is_video) { echo '<input' . ' type="button"' . ' title=' . esc_attr(__('Remake thumbnail file', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'remakethumb\', this, ' . (wppa('front_edit') ? 'false' : 'true') . ' )"' . ' value="' . esc_attr(__('Remake thumbnail file', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Move/copy if (!$quick) { $max = wppa_opt('photo_admin_max_albums'); if (!$max || wppa_get_total_album_count() < $max) { // If not done yet, get the album options html with the current album excluded if (!isset($album_select[$album])) { $album_select[$album] = wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $album, 'selected' => '0', 'addpleaseselect' => true)); } echo __('Target album for copy/move:', 'wp-photo-album-plus') . '<select' . ' id="target-' . $id . '"' . ' >' . $album_select[$album] . '</select>'; } else { echo __('Target album for copy/move:', 'wp-photo-album-plus') . '<input' . ' id="target-' . $id . '"' . ' type="number"' . ' style="height:20px;"' . ' placeholder="' . __('Album id', 'wp-photo-album-plus') . '"' . ' />'; } echo ' '; echo '<input' . ' type="button"' . ' onclick="wppaTryMove( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? $mvt : $mpt) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryCopy( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? $cvt : $cpt) . '"' . ' />' . ' '; } // Delete if (!wppa('front_edit')) { echo '<input' . ' type="button"' . ' style="color:red;"' . ' onclick="wppaTryDelete( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? esc_attr(__('Delete video', 'wp-photo-album-plus')) : esc_attr(__('Delete photo', 'wp-photo-album-plus'))) . '"' . ' />' . ' '; } // Re-upload if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { echo '<input' . ' type="button"' . ' onclick="jQuery( \'#re-up-' . $id . '\' ).css( \'display\', \'inline-block\' )"' . ' value="' . esc_attr(__('Re-upload file', 'wp-photo-album-plus')) . '"' . ' />' . '<div id="re-up-' . $id . '" style="display:none" >' . '<form' . ' id="wppa-re-up-form-' . $id . '"' . ' onsubmit="wppaReUpload( event, ' . $id . ', \'' . $filename . '\' )"' . ' >' . '<input' . ' type="file"' . ' id="wppa-re-up-file-' . $id . '"' . ' />' . '<input' . ' type="submit"' . ' id="wppa-re-up-butn-' . $id . '"' . ' value="' . esc_attr(__('Upload', 'wp-photo-album-plus')) . '"' . ' />' . '</form>' . '</div>'; } // Refresh /* if ( ! wppa( 'front_edit' ) ) { echo '<input' . ' type="button"' . ' onclick="wppaReload( \'#photo_' . $id . '\')"' . ' value="' . esc_attr( __( 'Refresh page', 'wp-photo-album-plus' ) ) . '"' . ' />'; } */ echo '</td>' . '</tr>' . '</tbody>' . '</table>'; echo "\n" . '<!-- Section 4 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>'; // Name echo '<tr>' . '<td>' . __('Photoname:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' id="pname-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'name\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'name\', this );"' . ' value="' . esc_attr(stripslashes($name)) . '"' . ' />' . '</td>' . '<td>' . '</td>' . '</tr>'; // Description if (!wppa_switch('desc_is_restricted') || wppa_user_is('administrator')) { echo '<tr>' . '<td>' . __('Description:', 'wp-photo-album-plus') . '</td>'; if (wppa_switch('use_wp_editor')) { $alfaid = wppa_alfa_id($id); echo '<td>'; wp_editor($description, 'wppaphotodesc' . $alfaid, array('wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => true)); echo '</td>' . '<td>' . '<input' . ' type="button"' . ' class="button-secundary"' . ' value="' . esc_attr(__('Update Photo description', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', document.getElementById( \'wppaphotodesc' . $alfaid . '\' ), false, \'' . $alfaid . '\' )"' . ' />' . '<img' . ' id="wppa-photo-spin-' . $id . '"' . ' src="' . wppa_get_imgdir() . 'spinner.gif"' . ' style="visibility:hidden"' . ' />' . '</td>'; } else { echo '<td>' . '<textarea' . ' style="width:100%;height:60px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' . ' >' . $description . '</textarea>' . '</td>' . '<td>' . '</td>'; } echo '</tr>'; } else { echo '<tr>' . '<td>' . __('Description:', 'wp-photo-album-plus') . '</td>' . '<td>' . $description . '</td>' . '<td>' . '</td>' . '</tr>'; } // Tags echo '<tr>' . '<td>' . __('Tags:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' id="tags-' . $id . '"' . ' type="text"' . ' style="width:100%;"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'tags\', this )"' . ' value="' . $tags . '"' . ' />' . '<br />' . '<span class="description" >' . __('Separate tags with commas.', 'wp-photo-album-plus') . '</span>' . '</td>' . '<td>' . '<select' . ' onchange="wppaAddTag( this.value, \'tags-' . $id . '\' ); wppaAjaxUpdatePhoto( ' . $id . ', \'tags\', document.getElementById( \'tags-' . $id . '\' ) )"' . ' >'; $taglist = wppa_get_taglist(); if (is_array($taglist)) { echo '<option value="" >' . __('- select -', 'wp-photo-album-plus') . '</option>'; foreach ($taglist as $tag) { echo '<option value="' . $tag['tag'] . '" >' . $tag['tag'] . '</option>'; } } else { echo '<option value="0" >' . __('No tags yet', 'wp-photo-album-plus') . '</option>'; } echo '</select>' . '<br />' . '<span class="description" >' . __('Select to add', 'wp-photo-album-plus') . '</span>' . '</td>' . '</tr>'; // Custom if (wppa_switch('custom_fields')) { $custom = wppa_get_photo_item($photo['id'], 'custom'); if ($custom) { $custom_data = unserialize($custom); } else { $custom_data = array('', '', '', '', '', '', '', '', '', ''); } foreach (array_keys($custom_data) as $key) { if (wppa_opt('custom_caption_' . $key)) { echo '<tr>' . '<td>' . apply_filters('translate_text', wppa_opt('custom_caption_' . $key)) . '<small style="float:right" >' . '(w#cc' . $key . ')' . '</small>:' . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' id="custom_' . $key . '-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'custom_' . $key . '\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'custom_' . $key . '\', this );"' . ' value="' . esc_attr(stripslashes($custom_data[$key])) . '"' . '/>' . '</td>' . '<td>' . '<small>(w#cd' . $key . ')</small>' . '</td> ' . '</tr>'; } } } // -- Auto Page -- if (wppa_switch('auto_page') && (current_user_can('edit_posts') || current_user_can('edit_pages'))) { $appl = get_permalink(wppa_get_the_auto_page($id)); echo '<tr>' . '<td>' . __('Autopage Permalink:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<a href="' . $appl . '" target="_blank" >' . $appl . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // -- Link url -- if (!wppa_switch('link_is_restricted') || wppa_user_is('administrator')) { echo '<tr>' . '<td>' . __('Photo specific link url:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' id="pislink-' . $id . '"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'linkurl\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linkurl\', this )"' . ' value="' . esc_attr($linkurl) . '"' . ' />' . '</td>' . '<td>' . '<select' . ' id="pistarget-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linktarget\', this )"' . ' >' . '<option' . ' value="_self"' . ($linktarget == '_self' ? ' selected="selected"' : '') . ' >' . __('Same tab', 'wp-photo-album-plus') . '</option>' . '<option' . ' value="_blank"' . ($linktarget == '_blank' ? ' selected="selected"' : '') . ' >' . __('New tab', 'wp-photo-album-plus') . '</option>' . '</select>' . '<input' . ' type="button"' . ' onclick="window.open( jQuery( \'#pislink-' . $id . '\' ).val(), jQuery( \'#pistarget-' . $id . '\' ).val() );"' . ' value="' . __('Tryit!', 'wp-photo-album-plus') . '"' . ' />' . '</td>' . '</tr>'; // -- Link title -- echo '<tr>' . '<td>' . __('Photo specific link title:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'linktitle\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linktitle\', this )"' . ' value="' . esc_attr($linktitle) . '"' . ' />'; if (current_user_can('wppa_settings')) { echo '<br />' . '<span class="description" >' . __('If you want this link to be used, check \'PS Overrule\' checkbox in table VI.', 'wp-photo-album-plus') . '</span>'; } echo '</td>' . '<td>' . '</td>' . '</tr>'; } // -- Custom ALT field -- if (wppa_opt('alt_type') == 'custom') { echo '<tr>' . '<td>' . __('HTML Alt attribute:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'alt\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'alt\', this )"' . ' value="' . esc_attr($alt) . '"' . ' />' . '</td>' . '<td>' . '</td>' . '</tr>'; } // If Quick, skip the following items for speed and space if (!$quick) { // Shortcode if (current_user_can('edit_posts') || current_user_can('edit_pages')) { echo '<tr>' . '<td>' . __('Single image shortcode', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '[wppa type="photo" photo="' . $id . '"][/wppa]' . '</td>' . '<td>' . '<small>' . sprintf(__('See %s The documentation %s for more shortcode options.', 'wp-photo-album-plus'), '<a href="http://wppa.nl/shortcode-reference/" target="_blank" >', '</a>') . '</small>' . '</td>' . '</tr>'; } // Source permalink if (is_file(wppa_get_source_path($id))) { $spl = wppa_get_source_pl($id); echo '<tr>' . '<td>' . __('Permalink', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $spl . '" target="_blank" >' . $spl . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // High resolution url $hru = wppa_get_hires_url($id); echo '<tr>' . '<td>' . __('Hi resolution url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $hru . '" target="_blank" >' . $hru . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; // Display file if (is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id))) { $lru = wppa_fix_poster_ext(wppa_get_lores_url($id), $id); echo '<tr>' . '<td>' . __('Display file url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $lru . '" target="_blank" >' . $lru . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // Thumbnail if (is_file(wppa_fix_poster_ext(wppa_get_thumb_path($id), $id))) { $tnu = wppa_fix_poster_ext(wppa_get_tnres_url($id), $id); echo '<tr>' . '<td>' . __('Thumbnail file url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $tnu . '" target="_blank" >' . $tnu . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } } echo '</tbody>' . '</table>'; echo "\n" . '<!-- Section 5 -->'; // Comments $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s ORDER BY `timestamp` DESC", $id), ARRAY_A); if ($comments && !$quick) { echo '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<thead>' . '<tr style="font-weight:bold;" >' . '<td style="padding:0 4px;" >#</td>' . '<td style="padding:0 4px;" >User</td>' . '<td style="padding:0 4px;" >Time since</td>' . '<td style="padding:0 4px;" >Status</td>' . '<td style="padding:0 4px;" >Comment</td>' . '</tr>' . '</thead>' . '<tbody>'; foreach ($comments as $comment) { echo ' <tr id="com-tr-' . $comment['id'] . '" > <td style="padding:0 4px;" >' . $comment['id'] . '</td> <td style="padding:0 4px;" >' . $comment['user'] . '</td> <td style="padding:0 4px;" >' . wppa_get_time_since($comment['timestamp']) . '</td>'; if (current_user_can('wppa_comments') || current_user_can('wppa_moderate') || wppa_get_user() == $photo['owner'] && wppa_switch('owner_moderate_comment')) { $p = $comment['status'] == 'pending' ? 'selected="selected" ' : ''; $a = $comment['status'] == 'approved' ? 'selected="selected" ' : ''; $s = $comment['status'] == 'spam' ? 'selected="selected" ' : ''; $t = $comment['status'] == 'trash' ? 'selected="selected" ' : ''; echo '<td style="padding:0 4px;" >' . '<select' . ' id="com-stat-' . $comment['id'] . '"' . ' style=""' . ' onchange="wppaAjaxUpdateCommentStatus( ' . $id . ', ' . $comment['id'] . ', this.value );wppaSetComBgCol(' . $comment['id'] . ');"' . ' >' . '<option value="pending" ' . $p . '>' . __('Pending', 'wp-photo-album-plus') . '</option>' . '<option value="approved" ' . $a . '>' . __('Approved', 'wp-photo-album-plus') . '</option>' . '<option value="spam" ' . $s . '>' . __('Spam', 'wp-photo-album-plus') . '</option>' . '<option value="trash" ' . $t . '>' . __('Trash', 'wp-photo-album-plus') . '</option>' . '</select >' . '</td>'; } else { echo '<td style="padding:0 4px;" >'; if ($comment['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'approved') { _e('Approved', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'spam') { _e('Spam', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'trash') { _e('Trash', 'wp-photo-album-plus'); } echo '</td>'; } echo '<td style="padding:0 4px;" >' . $comment['comment'] . '</td> </tr>' . '<script>wppaSetComBgCol(' . $comment['id'] . ')</script>'; } echo '</tbody>' . '</table>'; } echo '<script>wppaPhotoStatusChange( ' . $id . ' )</script>' . '<div style="clear:both;"></div>' . '</div>' . '<div style="clear:both;margin-top:7px;"></div>'; } /* foreach photo */ wppa_admin_page_links($page, $pagesize, $count, $link); } /* photos not empty */ }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; global $wppa_opt; global $wppa; require_once dirname(__FILE__) . '/wppa-links.php'; require_once dirname(__FILE__) . '/wppa-styles.php'; require_once dirname(__FILE__) . '/wppa-functions.php'; require_once dirname(__FILE__) . '/wppa-thumbnails.php'; require_once dirname(__FILE__) . '/wppa-boxes-html.php'; require_once dirname(__FILE__) . '/wppa-slideshow.php'; wppa_initialize_runtime(); $wppa['in_widget'] = 'lasten'; $wppa['mocc']++; extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => '', 'albumenum' => '', 'timesince' => 'yes', 'display' => 'thumbs')); $widget_title = apply_filters('widget_title', $instance['title']); $page = in_array($wppa_opt['wppa_lasten_widget_linktype'], $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_lasten_widget_linkpage', __a('Last Ten Uploaded Photos')); // $page = $wppa_opt['wppa_lasten_widget_linkpage']; $max = $wppa_opt['wppa_lasten_count']; $album = $instance['album']; $timesince = $instance['timesince']; $display = $instance['display']; $albumenum = $instance['albumenum']; $generic = $album == '-2'; if ($generic) { $album = '0'; $max += '1000'; } if ($album == '-99') { $album = implode("' OR `album` = '", explode(',', $albumenum)); } // If you want only 'New' photos in the selection, the period must be <> 0; if (wppa_switch('wppa_lasten_limit_new') && wppa_opt('wppa_max_photo_newtime')) { $newtime = " `timestamp` >= " . (time() - wppa_opt('wppa_max_photo_newtime')); if ($album) { $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE (" . $newtime . ") AND ( `album` = '" . $album . "' ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `timestamp` DESC LIMIT " . $max; } else { $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE (" . $newtime . ") AND `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `timestamp` DESC LIMIT " . $max; } } else { if ($album) { $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE ( `album` = '" . $album . "' ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `timestamp` DESC LIMIT " . $max; } else { $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `timestamp` DESC LIMIT " . $max; } } // echo $q; $thumbs = $wpdb->get_results($q, ARRAY_A); $widget_content = "\n" . '<!-- WPPA+ LasTen Widget start -->'; $maxw = $wppa_opt['wppa_lasten_size']; $maxh = $maxw; $lineheight = $wppa_opt['wppa_fontsize_widget_thumb'] * 1.5; $maxh += $lineheight; if ($timesince == 'yes') { $maxh += $lineheight; } $count = '0'; if ($thumbs) { foreach ($thumbs as $image) { global $thumb; $thumb = $image; if ($generic && wppa_is_separate($thumb['album'])) { continue; } // Make the HTML for current picture if ($display == 'thumbs') { $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">'; } else { $widget_content .= "\n" . '<div class="wppa-widget" >'; } if ($image) { $no_album = !$album; if ($no_album) { $tit = __a('View the most recent uploaded photos', 'wppa_theme'); } else { $tit = esc_attr(wppa_qtrans(stripslashes($image['description']))); } $link = wppa_get_imglnk_a('lasten', $image['id'], '', $tit, '', $no_album, $albumenum); $file = wppa_get_thumb_path($image['id']); $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ltthumb'); $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']); $imgevents = wppa_get_imgevents('thumb', $image['id'], true); $title = $link ? esc_attr(stripslashes($link['title'])) : ''; $widget_content .= wppa_get_the_widget_thumb('lasten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents); $widget_content .= "\n\t" . '<div style="font-size:' . $wppa_opt['wppa_fontsize_widget_thumb'] . 'px; line-height:' . $lineheight . 'px;">'; if ($timesince == 'yes') { $widget_content .= "\n\t" . '<div>' . wppa_get_time_since($image['timestamp']) . '</div>'; } $widget_content .= '</div>'; } else { // No image $widget_content .= __a('Photo not found.', 'wppa_theme'); } $widget_content .= "\n" . '</div>'; $count++; if ($count == $wppa_opt['wppa_lasten_count']) { break; } } } else { $widget_content .= 'There are no uploaded photos (yet).'; } $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ LasTen Widget end -->'; echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; $wppa['in_widget'] = false; }
function wppa_comment_html($id, $comment_allowed) { global $wpdb; global $wppa; global $current_user; global $wppa_first_comment_html; $result = ''; if ($wppa['in_widget']) { return $result; } // NOT in a widget // Find out who we are either logged in or not $vis = is_user_logged_in() ? $vis = 'display:none; ' : ''; if (!$wppa_first_comment_html) { $wppa_first_comment_html = true; // Find user if (wppa_get_post('comname')) { $wppa['comment_user'] = wppa_get_post('comname'); } if (wppa_get_post('comemail')) { $wppa['comment_email'] = wppa_get_post('comemail'); } elseif (is_user_logged_in()) { get_currentuserinfo(); $wppa['comment_user'] = $current_user->display_name; //user_login; $wppa['comment_email'] = $current_user->user_email; } } // Loop the comments already there $n_comments = 0; if (wppa_switch('comments_desc')) { $ord = 'DESC'; } else { $ord = ''; } $comments = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . WPPA_COMMENTS . ' WHERE photo = %s ORDER BY id ' . $ord, $id), ARRAY_A); wppa_dbg_q('Q-Comm'); $com_count = count($comments); $color = 'darkgrey'; if (wppa_opt('wppa_fontcolor_box')) { $color = wppa_opt('wppa_fontcolor_box'); } if ($comments) { $result .= '<div id="wppa-comtable-wrap-' . $wppa['mocc'] . '" style="display:none;" >'; $result .= '<table id="wppacommentstable-' . $wppa['mocc'] . '" class="wppa-comment-form" style="margin:0; "><tbody>'; foreach ($comments as $comment) { // Show a comment either when it is approved, or it is pending and mine or i am a moderator if ($comment['status'] == 'approved' || current_user_can('wppa_moderate') || current_user_can('wppa_comments') || ($comment['status'] == 'pending' || $comment['status'] == 'spam') && $comment['user'] == $wppa['comment_user']) { $n_comments++; $result .= '<tr class="wppa-comment-' . $comment['id'] . '" valign="top" style="border-bottom:0 none; border-top:0 none; border-left: 0 none; border-right: 0 none; " >'; $result .= '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:30%; border-width: 0 0 0 0; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >'; $result .= $comment['user'] . ' ' . __a('wrote:'); $result .= '<br /><span style="font-size:9px; ">' . wppa_get_time_since($comment['timestamp']) . '</span>'; if (wppa_opt('wppa_comment_gravatar') != 'none') { // Find the default if (wppa_opt('wppa_comment_gravatar') != 'url') { $default = wppa_opt('wppa_comment_gravatar'); } else { $default = wppa_opt('wppa_comment_gravatar_url'); } // Find the avatar $avt = ''; $usr = get_user_by('login', $comment['user']); if ($usr) { // Local Avatar ? $avt = str_replace("'", "\"", get_avatar($usr->ID, wppa_opt('wppa_gravatar_size'), $default)); } if ($avt == '') { // Global avatars off, try myself $avt = '<img class="wppa-box-text wppa-td" src="http://www.gravatar.com/avatar/' . md5(strtolower(trim($comment['email']))) . '.jpg?d=' . urlencode($default) . '&s=' . wppa_opt('wppa_gravatar_size') . '" alt="' . __a('Avatar') . '" />'; } // Compose the html $result .= '<div class="com_avatar">' . $avt . '</div>'; } $result .= '</td>'; $txtwidth = floor(wppa_get_container_width() * 0.7) . 'px'; $result .= '<td class="wppa-box-text wppa-td" style="width:70%; word-wrap:break-word; border-width: 0 0 0 0;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . '<p class="wppa-comment-textarea wppa-comment-textarea-' . $wppa['mocc'] . '" style="margin:0; background-color:transparent; width:' . $txtwidth . '; max-height:90px; overflow:auto; word-wrap:break-word;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . html_entity_decode(esc_js(stripslashes(wppa_convert_smilies($comment['comment'])))); if ($comment['status'] != 'approved' && (current_user_can('wppa_moderate') || current_user_can('wppa_comments'))) { if ($wppa['no_esc']) { $result .= wppa_moderate_links('comment', $id, $comment['id']); } else { $result .= wppa_html(esc_js(wppa_moderate_links('comment', $id, $comment['id']))); } } elseif ($comment['status'] == 'pending' && $comment['user'] == $wppa['comment_user']) { $result .= '<br /><span style="color:red; font-size:9px;" >' . __a('Awaiting moderation') . '</span>'; } elseif ($comment['status'] == 'spam' && $comment['user'] == $wppa['comment_user']) { $result .= '<br /><span style="color:red; font-size:9px;" >' . __a('Marked as spam') . '</span>'; } $result .= '</p>'; $result .= '</td>'; $result .= '</tr>'; $result .= '<tr class="wppa-comment-' . $comment['id'] . '"><td colspan="2" style="padding:0"><hr style="background-color:' . $color . '; margin:0;" /></td></tr>'; } } $result .= '</tbody></table>'; $result .= '</div>'; } // See if we are currently in the process of adding/editing this comment $is_current = $id == $wppa['comment_photo'] && $wppa['comment_id']; // $debugtext=' ( id='.$id.', comment_photo='.$wppa['comment_photo'].', comment_id='.$wppa['comment_id'].' )'; if ($is_current) { $txt = $wppa['comment_text']; $btn = __a('Edit!'); } else { $txt = ''; $btn = __a('Send!'); } // Prepare the callback url $returnurl = wppa_get_permalink(); $album = wppa_get_get('album'); if ($album !== false) { $returnurl .= 'wppa-album=' . $album . '&'; } $cover = wppa_get_get('cover'); if ($cover) { $returnurl .= 'wppa-cover=' . $cover . '&'; } $slide = wppa_get_get('slide'); if ($slide !== false) { $returnurl .= 'wppa-slide&'; } $occur = wppa_get_get('occur'); if ($occur) { $returnurl .= 'wppa-occur=' . $occur . '&'; } $lasten = wppa_get_get('lasten'); if ($lasten) { $returnurl .= 'wppa-lasten=' . $lasten . '&'; } $topten = wppa_get_get('topten'); if ($topten) { $returnurl .= 'wppa-topten=' . $topten . '&'; } $comten = wppa_get_get('comten'); if ($comten) { $returnurl .= 'wppa-comten=' . $comten . '&'; } $tag = wppa_get_get('tag'); if ($tag) { $returnurl .= 'wppa-tag=' . $tag . '&'; } $returnurl .= 'wppa-photo=' . $id; // The comment form if ($comment_allowed) { $result .= '<div id="wppa-comform-wrap-' . $wppa['mocc'] . '" style="display:none;" >'; $result .= '<form id="wppa-commentform-' . $wppa['mocc'] . '" class="wppa-comment-form" action="' . $returnurl . '" method="post" style="" onsubmit="return wppaValidateComment( ' . $wppa['mocc'] . ' )">'; $result .= wp_nonce_field('wppa-nonce-' . wppa('mocc'), 'wppa-nonce-' . wppa('mocc'), false, false); //, $alb ); if ($album) { $result .= '<input type="hidden" name="wppa-album" value="' . $album . '" />'; } if ($cover) { $result .= '<input type="hidden" name="wppa-cover" value="' . $cover . '" />'; } if ($slide) { $result .= '<input type="hidden" name="wppa-slide" value="' . $slide . '" />'; } $result .= '<input type="hidden" name="wppa-returnurl" id="wppa-returnurl-' . wppa('mocc') . '" value="' . $returnurl . '" />'; if ($is_current) { $result .= '<input type="hidden" id="wppa-comment-edit-' . $wppa['mocc'] . '" name="wppa-comment-edit" value="' . $wppa['comment_id'] . '" />'; } $result .= '<input type="hidden" name="wppa-occur" value="' . $wppa['occur'] . '" />'; $result .= '<table id="wppacommenttable-' . $wppa['mocc'] . '" style="margin:0;">'; $result .= '<tbody>'; $result .= '<tr valign="top" style="' . $vis . '">'; $result .= '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your name:') . '</td>'; $result .= '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" ><input type="text" name="wppa-comname" id="wppa-comname-' . $wppa['mocc'] . '" style="width:100%; " value="' . $wppa['comment_user'] . '" /></td>'; $result .= '</tr>'; if (wppa_switch('comment_email_required')) { $result .= '<tr valign="top" style="' . $vis . '">'; $result .= '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your email:') . '</td>'; $result .= '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" ><input type="text" name="wppa-comemail" id="wppa-comemail-' . $wppa['mocc'] . '" style="width:100%; " value="' . $wppa['comment_email'] . '" /></td>'; $result .= '</tr>'; } $result .= '<tr valign="top" style="vertical-align:top;">'; $result .= '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your comment:') . '<br />' . $wppa['comment_user'] . '<br />'; if (wppa_switch('comment_captcha')) { $wid = '20%'; if (wppa_opt('wppa_fontsize_box')) { $wid = wppa_opt('wppa_fontsize_box') * 1.5 . 'px'; } $captkey = $id; if ($is_current) { $captkey = $wpdb->get_var($wpdb->prepare('SELECT `timestamp` FROM `' . WPPA_COMMENTS . '` WHERE `id` = %s', $wppa['comment_id'])); } wppa_dbg_q('Q-Com-ts'); $result .= wppa_make_captcha($captkey) . '<input type="text" id="wppa-captcha-' . $wppa['mocc'] . '" name="wppa-captcha" style="width:' . $wid . '; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" /> '; } // orig $result .= '<input type="submit" name="commentbtn" value="'.$btn.'" style="margin:0;" /></td>'; $result .= '<input type="button" name="commentbtn" onclick="wppaAjaxComment( ' . $wppa['mocc'] . ', ' . $id . ' )" value="' . $btn . '" style="margin:0 4px 0 0;" />'; $result .= '<img id="wppa-comment-spin-' . $wppa['mocc'] . '" src="' . wppa_get_imgdir() . 'wpspin.gif" style="display:none;" />'; $result .= '</td>'; $result .= '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >'; /* if ( wppa_switch( 'use_wp_editor' ) ) { $quicktags_settings = array( 'buttons' => 'strong,em,link,block,ins,ul,ol,li,code,close' ); ob_start(); wp_editor( stripslashes( $txt ), 'wppacomment'.wppa_alfa_id( $id ), array( 'wpautop' => false, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => false, 'quicktags' => $quicktags_settings ) ); $editor = ob_get_clean(); $result .= str_replace( "'", '"', $editor ); } else { /**/ if (wppa_switch('comment_smiley_picker')) { $result .= wppa_get_smiley_picker_html('wppa-comment-' . $wppa['mocc']); } $result .= '<textarea name="wppa-comment" id="wppa-comment-' . $wppa['mocc'] . '" style="height:60px; width:100%; ">' . esc_textarea(stripslashes($txt)) . '</textarea>'; /* } /* */ $result .= '</td>'; $result .= '</tr>'; $result .= '</tbody>'; $result .= '</table>'; $result .= '</form>'; // $result.=$debugtext; $result .= '</div>'; } else { if (wppa_switch('login_links')) { $result .= sprintf(__a('You must <a href="%s">login</a> to enter a comment'), site_url('wp-login.php', 'login')); } else { $result .= __a('You must login to enter a comment'); } } $result .= '<div id="wppa-comfooter-wrap-' . $wppa['mocc'] . '" style="display:block;" >'; $result .= '<table id="wppacommentfooter-' . $wppa['mocc'] . '" class="wppa-comment-form" style="margin:0;">'; $result .= '<tbody><tr style="text-align:center; "><td style="text-align:center; cursor:pointer;' . __wcs('wppa-box-text') . '" ><a onclick="wppaOpenComments( ' . $wppa['mocc'] . ', -1 ); return false;">'; // wppaStartStop( '.$wppa['mocc'].', -1 ); return false;">'; if ($n_comments) { $result .= sprintf(__a('%d comments'), $n_comments); } else { if ($comment_allowed) { $result .= __a('Leave a comment'); } } $result .= '</a></td></tr></tbody></table>'; $result .= '</div><div style="clear:both"></div>'; return $result; }