function _wppa_comment_admin() { global $wpdb; global $wppa; $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 . '/images/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', 'wppa'); ?> </h2> <?php $action = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments'); if (isset($_GET['wppa-page'])) { $action .= '&compage=' . $_GET['wppa-page']; } if (isset($_GET['commentid'])) { $action .= '&commentid=' . $_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 wppa_qtrans($photo['name']) . '<br/><br/>' . wppa_qtrans(stripslashes($photo['description'])); ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('Photo:', 'wppa'); ?> </label></th> <td><?php echo $comment['photo']; ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('Album:', 'wppa'); ?> </label></th> <td><?php echo wppa_get_album_name($photo['album']); ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('User:'******'wppa'); ?> </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:', 'wppa'); ?> </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:', 'wppa'); ?> </label></th> <td><textarea style="width:300px; height:150px;" name="comment"><?php echo stripslashes($comment['comment']); ?> </textarea></td> </tr> </tbody> </table> <p> <input type="submit" class="button-primary" name="wppa_submit" value="<?php _e('Save Changes', 'wppa'); ?> " /> </p> </form> <?php } $continue = false; } if ($_GET['tab'] == 'delete') { $id = $_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('wppa_search_comments')) { wppa_index_update('photo', $photo); } wppa_update_message(__('Comment deleted', 'wppa')); } else { wppa_error_message('Error deleting comment', 'wppa'); } $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': $query = "UPDATE " . WPPA_COMMENTS . " SET status = 'approved' WHERE status = 'pending'"; if ($wpdb->query($query) === false) { wppa_error_message(__('Could not bulk update status', 'wppa')); $iret = false; } else { $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', 'wppa')); $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', 'wppa')); $iret = false; } break; } } if ($iret) { wppa_update_message(__('Changes Saved', 'wppa')); } // 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 . '/images/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', 'wppa'); } else { _e('Photo Albums -> Comment admin', 'wppa'); } ?> </h2> <?php if (!wppa_switch('wppa_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>', 'wppa'); } ?> <?php if (!$moderating) { ?> <!-- Statistics --> <table> <tbody> <tr> <td><h3 style="margin:0; color:#777777;"><?php _e('Total:', 'wppa'); ?> </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:', 'wppa'); ?> </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:', 'wppa'); ?> </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:', 'wppa'); ?> </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('wppa_spam_maxage') != 'none') { ?> <tr> <td><h3 style="margin:0; color:red;"><?php _e('Auto deleted spam:', 'wppa'); ?> </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', 'wppa'); ?> </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:', 'wppa'); ?> <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 ---', 'wppa'); ?> </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']) . '</option>'; } } } ?> </select> <?php _e('You can see the photo and all its comments on the selected page by clicking on the thumbnail image', 'wppa'); ?> </p> <?php $comment_show = wppa_opt('wppa_comadmin_show'); ?> <p> <?php _e('Display status:', 'wppa'); ?> <select name="wppa_comadmin_show"> <option value="all" <?php if ($comment_show == 'all') { echo 'selected="selected"'; } ?> ><?php _e('all', 'wppa'); ?> </option> <option value="pending" <?php if ($comment_show == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('pending', 'wppa'); ?> </option> <option value="approved" <?php if ($comment_show == 'approved') { echo 'selected="selected"'; } ?> ><?php _e('approved', 'wppa'); ?> </option> <option value="spam" <?php if ($comment_show == 'spam') { echo 'selected="selected"'; } ?> ><?php _e('spam', 'wppa'); ?> </option> </select> <?php $comment_order = wppa_opt('wppa_comadmin_order'); ?> <?php _e('Display order:', 'wppa'); ?> <select name="wppa_comadmin_order"> <option value="timestamp" <?php if ($comment_order == 'timestamp') { echo 'selected="selected"'; } ?> ><?php _e('timestamp', 'wppa'); ?> </option> <option value="photo" <?php if ($comment_order == 'photo') { echo 'selected="selected"'; } ?> ><?php _e('photo', 'wppa'); ?> </option> </select> <?php _e('Bulk action:', 'wppa'); ?> <select name="bulkaction"> <option value=""><?php ?> </option> <option value="approveall"><?php _e('Approve all pending', 'wppa'); ?> </option> <option value="spamall"><?php _e('Move all pending to spam', 'wppa'); ?> </option> <option value="delspam"><?php _e('Delete all spam', 'wppa'); ?> </option> </select> <input type="submit" class="button-primary" name="wppa_submit" value="<?php _e('Save Settings / Perform bulk action', 'wppa'); ?> " /> </p> </form> </div> <!-- End Settings --> <?php } if ($moderating) { $pagesize = '1'; $where = " WHERE `id` = '" . $_REQUEST['commentid'] . "'"; $order = ''; $curpage = '1'; $limit = ''; } else { $pagsize = wppa_opt('wppa_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 = $_GET['wppa-page']; $offset = ($_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', 'wppa'); ?> <br /> <?php _e('(Album)', 'wppa'); ?> </th> <th scope="col"><?php _e('#', 'wppa'); ?> </th> <th scope="col"><?php _e('IP', 'wppa'); ?> </th> <th scope="col"><?php _e('User', 'wppa'); ?> </th> <th scope="col"><?php _e('Email', 'wppa'); ?> </th> <th scope="col"><?php _e('Time since', 'wppa'); ?> </th> <th scope="col"><?php _e('Comment', 'wppa'); ?> </th> <th scope="col" style="width: 130px;" ><?php _e('Status', 'wppa'); ?> </th> <th scope="col"><?php _e('Edit', 'wppa'); ?> </th> <th scope="col"><?php _e('Delete', 'wppa'); ?> </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']); $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="<? echo $url ?>" target="_blank"> <img title="<?php _e('Click to see the fullsize photo and all comments', 'wppa'); ?> " 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', 'wppa'), $pname, get_bloginfo('name'))); echo '<a href="mailto:' . $com['email'] . '?Subject=' . $subject . '" title="' . __('Reply', 'wppa') . '" >' . $com['email'] . '</a>'; } else { echo $com['email']; } ?> </td> <td><?php echo wppa_get_time_since($com['timestamp']); ?> </td> <td><?php echo $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', 'wppa'); ?> </option> <option value="approved" <?php if ($com['status'] == 'approved') { echo 'selected="selected"'; } ?> ><?php _e('Approved', 'wppa'); ?> </option> <option value="spam" <?php if ($com['status'] == 'spam') { echo 'selected="selected"'; } ?> ><?php _e('Spam', 'wppa'); ?> </option> </select> <img id="wppa-comment-spin-<?php echo $com['id']; ?> " src="<?php echo wppa_get_imgdir() . 'wpspin.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=' . $_GET['wppa-page']; } if (isset($_GET['commentid'])) { $url .= '&commentid=' . $_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', 'wppa'); ?> </b></td> <td style="color:red; cursor:pointer;" onclick="if (confirm('<?php _e('Are you sure you want to delete this comment?', 'wppa'); ?> ')) document.location = '<?php echo $delurl; ?> ';"><b><?php _e('Delete', 'wppa'); ?> </b></td> </tr> <?php } } ?> </tbody> <tfoot style="font-weight: bold" class=""> <tr> <th scope="col"><?php _e('Photo', 'wppa'); ?> <br /> <?php _e('(Album)', 'wppa'); ?> </th> <th scope="col"><?php _e('#', 'wppa'); ?> </th> <th scope="col"><?php _e('IP', 'wppa'); ?> </th> <th scope="col"><?php _e('User', 'wppa'); ?> </th> <th scope="col"><?php _e('Email', 'wppa'); ?> </th> <th scope="col"><?php _e('Time since', 'wppa'); ?> </th> <th scope="col"><?php _e('Comment', 'wppa'); ?> </th> <th scope="col"><?php _e('Status', 'wppa'); ?> </th> <th scope="col"><?php _e('Edit', 'wppa'); ?> </th> <th scope="col"><?php _e('Delete', 'wppa'); ?> </th> </tr> </tfoot> </table> <?php if (!$moderating) { wppa_admin_page_links($curpage, $pagsize, $nitems, $link); } ?> </form> </div> <?php } }
function wppa_walbum_select($sel = '') { global $wpdb; $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY `name`", ARRAY_A); wppa_dbg_q('Q-Asel'); wppa_cache_album('add', $albums); if (is_numeric($sel)) { $type = 1; } elseif (strchr($sel, ',')) { $type = 2; // Array $albs = explode(',', $sel); } elseif ($sel == 'all') { $type = 3; } elseif ($sel == 'sep') { $type = 4; } elseif ($sel == 'all-sep') { $type = 5; } elseif ($sel == 'topten') { $type = 6; } elseif ($sel == 'featured') { $type = 7; } else { $type = 0; } // Nothing yet $result = '<option value="" >' . __('- select (another) album or a set -', 'wppa') . '</option>'; foreach ($albums as $album) { switch ($type) { case 1: $dis = $album['id'] == $sel; break; case 2: $dis = in_array($album['id'], $albs); break; case 3: $dis = true; break; case 4: $dis = $album['a_parent'] == '-1'; break; case 5: $dis = $album['a_parent'] != '-1'; break; case 6: $dis = false; break; case 7: $dis = false; break; default: $dis = false; } if ($dis) { $dis = 'disabled="disabled"'; } else { $dis = ''; } $result .= '<option ' . $dis . ' value="' . $album['id'] . '">( ' . $album['id'] . ' )'; if ($album['id'] < '1000') { $result .= ' '; } if ($album['id'] < '100') { $result .= ' '; } if ($album['id'] < '10') { $result .= ' '; } $result .= wppa_qtrans(stripslashes($album['name'])) . '</option>'; } $sel = $type == 3 ? 'selected="selected"' : ''; $result .= '<option value="all" ' . $sel . ' >' . __('- all albums -', 'wppa') . '</option>'; $sel = $type == 4 ? 'selected="selected"' : ''; $result .= '<option value="sep" ' . $sel . ' >' . __('- all -separate- albums -', 'wppa') . '</option>'; $sel = $type == 5 ? 'selected="selected"' : ''; $result .= '<option value="all-sep" ' . $sel . ' >' . __('- all albums except -separate-', 'wppa') . '</option>'; $sel = $type == 6 ? 'selected="selected"' : ''; $result .= '<option value="topten" ' . $sel . ' >' . __('- top rated photos -', 'wppa') . '</option>'; $sel = $type == 7 ? 'selected="selected"' : ''; $result .= '<option value="featured" ' . $sel . ' >' . __('- featured photos -', 'wppa') . '</option>'; $result .= '<option value="clr" >' . __('- start over -', 'wppa') . '</option>'; return $result; }
function wppa_get_meta_data($file, $item, $opt) { $result = ''; $opt2 = ''; if ($opt == '( ') { $opt2 = ' )'; } if ($opt == '{') { $opt2 = '}'; } if ($opt == '[') { $opt2 = ']'; } if (is_file($file)) { $handle = fopen($file, "r"); if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { if (substr($buffer, 0, 5) == $item . '=') { if ($opt == '') { $result = substr($buffer, 5, strlen($buffer) - 6); } else { $result = $opt . wppa_qtrans(substr($buffer, 5, strlen($buffer) - 6)) . $opt2; } // Translate for display purposes only } } if (!feof($handle)) { _e('Error: unexpected fgets() fail in wppa_get_meta_data().', 'wppa'); } fclose($handle); } } return $result; }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; global $wppa; 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(); extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => '', 'width' => $wppa_opt['wppa_widget_width'], 'height' => round($wppa_opt['wppa_widget_width'] * $wppa_opt['wppa_maxheight'] / $wppa_opt['wppa_fullsize']), 'ponly' => 'no', 'linkurl' => '', 'linktitle' => '', 'subtext' => '', 'supertext' => '', 'valign' => 'center', 'timeout' => '4', 'film' => 'no', 'browse' => 'no', 'name' => 'no', 'numbar' => 'no', 'desc' => 'no')); $title = apply_filters('widget_title', $instance['title']); $album = $instance['album']; $width = $instance['width']; $height = $instance['height']; if ($height == '0') { $height = round($width * $wppa_opt['wppa_maxheight'] / $wppa_opt['wppa_fullsize']); } $ponly = $instance['ponly']; $linkurl = $instance['linkurl']; $linktitle = $instance['linktitle']; $supertext = wppa_qtrans($instance['supertext']); $subtext = wppa_qtrans($instance['subtext']); $valign = $instance['valign']; $timeout = $instance['timeout'] * 1000; $film = $instance['film']; $browse = $instance['browse']; $name = $instance['name']; $numbar = $instance['numbar']; $desc = $instance['desc']; $page = in_array($wppa_opt['wppa_slideonly_widget_linktype'], $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_slideonly_widget_linkpage', __a('Widget landing page')); if (is_numeric($album)) { echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } if ($linkurl != '' && $wppa_opt['wppa_slideonly_widget_linktype'] == 'widget') { $wppa['in_widget_linkurl'] = $linkurl; $wppa['in_widget_linktitle'] = wppa_qtrans($linktitle); } if ($supertext != '') { echo '<div style="padding-top:2px; padding-bottom:4px; text-align:center">' . $supertext . '</div>'; } echo '<div style="padding-top:2px; padding-bottom:4px;" >'; $wppa['auto_colwidth'] = false; $wppa['in_widget'] = 'ss'; $wppa['in_widget_frame_height'] = $height; $wppa['in_widget_frame_width'] = $width; $wppa['in_widget_timeout'] = $timeout; $wppa['portrait_only'] = $ponly == 'yes'; $wppa['ss_widget_valign'] = $valign; $wppa['film_on'] = $film == 'yes'; $wppa['browse_on'] = $browse == 'yes'; $wppa['name_on'] = $name == 'yes'; $wppa['numbar_on'] = $numbar == 'yes'; $wppa['desc_on'] = $desc == 'yes'; echo wppa_albums($album, 'slideonly', $width, 'center'); $wppa['desc_on'] = false; $wppa['numbar_on'] = false; $wppa['name_on'] = false; $wppa['browse_on'] = false; $wppa['film_on'] = false; $wppa['ss_widget_valign'] = ''; $wppa['portrait_only'] = false; $wppa['in_widget_timeout'] = '0'; $wppa['in_widget_frame_height'] = ''; $wppa['in_widget_frame_width'] = ''; $wppa['in_widget'] = false; $wppa['fullsize'] = ''; // Reset to prevent inheritage of wrong size in case widget is rendered before main column echo '</div>'; if ($linkurl != '') { $wppa['in_widget_linkurl'] = ''; $wppa['in_widget_linktitle'] = ''; } if ($subtext != '') { echo '<div style="padding-top:2px; padding-bottom:0px; text-align:center">' . $subtext . '</div>'; } echo $after_widget; } else { echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo __a('No album defined yet.', 'wppa_theme'); echo $after_widget; } }
function wppa_get_thumb_masonry($id) { global $wpdb; // Init if (!$id) { wppa_dbg_msg('Please check file wppa-theme.php or any other php file that calls wppa_thumb_masonry(). Argument 1: photo id is missing!', 'red', 'force'); die('Please check your configuration'); } $result = ''; $cont_width = wppa_get_container_width(); $count_cols = ceil($cont_width / wppa_opt('thumbsize')); // Get the photo info $thumb = wppa_cache_thumb($id); // Get the album info $album = wppa_cache_album($thumb['album']); // Get photo info $is_video = wppa_is_video($id); $has_audio = wppa_has_audio($id); $imgsrc = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id); if (!wppa_is_video($id) && !is_file($imgsrc)) { $result .= '<div' . ' class=""' . ' style="' . 'font-size:10px;' . 'color:red;' . 'width:' . wppa_opt('thumbsize') . 'px;' . 'position:static;' . 'float:left;' . '"' . ' >' . sprintf(__a('Missing thumbnail image #%s'), $id) . '</div>'; return $result; } $alt = $album['alt_thumbsize'] == 'yes' ? '_alt' : ''; $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, wppa_opt('thumbsize' . $alt), 'optional', 'thumb'); // Verical style ? if (wppa_opt('thumbtype') == 'masonry-v') { $imgwidth = wppa_opt('thumbsize'); $imgheight = $imgwidth * wppa_get_thumbratioyx($id); $imgstyle = 'width:100%; height:auto; margin:0; position:relative; box-sizing:border-box;'; $frame_h = ''; } else { $imgheight = wppa_opt('thumbsize'); $imgwidth = $imgheight * wppa_get_thumbratioxy($id); $imgstyle = 'height:100%; width:auto; margin:0; position:relative; box-sizing:border-box;'; $frame_h = 'height:100%; '; } // Padding if (wppa_is_int(wppa_opt('tn_margin') / 2)) { $imgstyle .= ' padding:' . wppa_opt('tn_margin') / 2 . 'px;'; } else { $p1 = floor(wppa_opt('tn_margin') / 2); $p2 = ceil(wppa_opt('tn_margin') / 2); $imgstyle .= ' padding:' . $p1 . 'px ' . $p2 . 'px ' . $p2 . 'px ' . $p1 . 'px;'; } // Cursor $cursor = $imgattr_a['cursor']; // Popup ? 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; } $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_masonry_title($id)); // 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="' . $title . '"' : '') . ' style="' . $style . '"' . ' />' . '</a>'; return; } // Get the image link if (wppa('is_topten')) { $no_album = !wppa('start_album'); if ($no_album) { $tit = __a('View the top rated photos'); } else { $tit = esc_attr(wppa_qtrans(stripslashes($thumb['description']))); } $link = wppa_get_imglnk_a('thumb', $id, '', $tit, '', $no_album); } else { $link = wppa_get_imglnk_a('thumb', $id); } // voor parent uplr // Open the thumbframe $result .= ' <div' . ' id="thumbnail_frame_masonry_' . $id . '_' . wppa('mocc') . '"' . ' style="' . $frame_h . 'position:static;' . 'float:left;' . 'font-size:12px;' . 'line-height:8px;' . 'overflow:hidden;' . '" >'; // The medals $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top')); // See if ajax possible if ($link) { if ($link['is_url']) { // 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 $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') . "&wppa-photo=" . $id) . "' )"; $result .= '<a style="position:static;" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">'; if ($is_video) { // $result .= '<video preload="metadata" onclick="'.$onclick.'" id="i-'.$id.'-'.wppa( 'mocc' ).'" '.$imgalt.' title="'.$title.'" style="'.$imgstyle.' cursor:pointer;" '.$events.' >'.wppa_get_video_body( $id ).'</video>'; $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, '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, 'use_thumb' => true)); } else { $result .= '<img' . ' onclick="' . $onclick . '"' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />'; } $result .= '</a>'; } else { // non ajax // 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 .= '<video preload="metadata" id="i-'.$id.'-'.wppa( 'mocc' ).'" '.$imgalt.' title="'.$title.'" width="'.$imgwidth.'" height="'.$imgheight.'" style="'.$imgstyle.' cursor:pointer;" '.$events.' >'.wppa_get_video_body( $id ).'</video>'; $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, '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, 'use_thumb' => true)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . 'cursor:pointer;"' . ' ' . $events . ' />'; } $result .= '</a>'; } } elseif ($link['is_lightbox']) { // The a img $title = wppa_get_lbtitle('thumb', $id); $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') . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' class="thumb-img"' . ' id="x-' . $id . '-' . wppa('mocc') . '">'; // The image $title = wppa_zoom_in($id); // Video? if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => $cursor, 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' />'; } $result .= '</a>'; } else { // The div img $result .= '<div onclick="' . $link['url'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">'; // Video? if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, '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, 'use_thumb' => true)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' 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 .= '<video preload="metadata" '.$imgalt.' title="'.$title.'" width="'.$imgwidth.'" height="'.$imgheight.'" style="'.$imgstyle.'" '.$events.' >'.wppa_get_video_body( $id ).'</video>'; $result .= wppa_get_video_html(array('id' => $id, '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, 'use_thumb' => true)); } else { $result .= '<img' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '"' . ' ' . $events . ' />'; } $result .= '</div>'; } else { if ($is_video) { // $result .= '<video preload="metadata" '.$imgalt.' title="'.$title.'" width="'.$imgwidth.'" height="'.$imgheight.'" style="'.$imgstyle.'" '.$events.' >'.wppa_get_video_body( $id ).'</video>'; $result .= wppa_get_video_html(array('id' => $id, '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, 'use_thumb' => true)); } else { $result .= '<img' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '" ' . $events . ' />'; } } } // The audio when no popup if (wppa_switch('thumb_audio') && wppa_has_audio($id)) { $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, 'tagid' => 'a-' . $id . '-' . wppa('mocc'), 'style' => 'width:100%;position:absolute;bottom:0;margin:0;padding:' . wppa_opt('tn_margin') / 2 . 'px;left:0;border:none;z-index:10;')); $result .= '</div>'; } // The medals $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot')); // Close the thumbframe $result .= '</div><!-- #thumbnail_frame_masonry_' . $id . '_' . wppa('mocc') . ' -->'; return $result; }
/** @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(); extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => '')); $widget_title = apply_filters('widget_title', $instance['title']); $page = in_array($wppa_opt['wppa_featen_widget_linktype'], $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_featen_widget_linkpage', __a('Featured photos')); $max = $wppa_opt['wppa_featen_count']; $album = $instance['album']; $generic = $album == '-2'; if ($generic) { $album = '0'; $max += '1000'; } if ($album) { $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status`= 'featured' AND `album` = %s ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, $album), ARRAY_A); } else { $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, ARRAY_A); } $widget_content = "\n" . '<!-- WPPA+ FeaTen Widget start -->'; $maxw = $wppa_opt['wppa_featen_size']; $maxh = $maxw; $lineheight = $wppa_opt['wppa_fontsize_widget_thumb'] * 1.5; $maxh += $lineheight; if (false) { $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 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">'; if ($image) { $no_album = !$album; if ($no_album) { $tit = __a('View the featured photos', 'wppa_theme'); } else { $tit = esc_attr(wppa_qtrans(stripslashes($image['description']))); } $link = wppa_get_imglnk_a('featen', $image['id'], '', $tit, '', $no_album); $file = wppa_get_thumb_path($image['id']); $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb'); $imgstyle = $imgstyle_a['style']; $width = $imgstyle_a['width']; $height = $imgstyle_a['height']; $cursor = $imgstyle_a['cursor']; $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height); $imgevents = wppa_get_imgevents('thumb', $image['id'], true); if ($link) { $title = esc_attr(stripslashes($link['title'])); } else { $title = ''; } $album = '0'; $display = 'thumbs'; $widget_content .= wppa_get_the_widget_thumb('featen', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents); } else { // No image $widget_content .= __a('Photo not found.', 'wppa_theme'); } $widget_content .= "\n" . '</div>'; $count++; if ($count == $wppa_opt['wppa_featen_count']) { break; } } } else { $widget_content .= 'There are no featured photos (yet).'; } $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ FeaTen Widget end -->'; echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; }
function _wppa_sidebar_page_options() { global $wpdb; $options_error = false; if (isset($_GET['walbum'])) { $walbum = wppa_walbum_sanitize($_GET['walbum']); wppa_update_option('wppa_widget_album', $walbum); } if (isset($_POST['wppa-set-submit'])) { check_admin_referer('$wppa_nonce', WPPA_NONCE); if (isset($_POST['wppa-widgettitle'])) { wppa_update_option('wppa_widgettitle', $_POST['wppa-widgettitle']); } if (isset($_POST['wppa-potd-align'])) { wppa_update_option('wppa_potd_align', $_POST['wppa-potd-align']); } if (isset($_POST['wppa-widget-albums'])) { wppa_update_option('wppa_widget_album', wppa_walbum_sanitize($_POST['wppa-widget-albums'])); } if (isset($_POST['wppa-widget-photo'])) { wppa_update_option('wppa_widget_photo', $_POST['wppa-widget-photo']); } if (isset($_POST['wppa-widget-method'])) { wppa_update_option('wppa_widget_method', $_POST['wppa-widget-method']); } if (isset($_POST['wppa-widget-period'])) { wppa_update_option('wppa_widget_period', $_POST['wppa-widget-period']); } if (isset($_POST['wppa-widget-subtitle'])) { wppa_update_option('wppa_widget_subtitle', $_POST['wppa-widget-subtitle']); } if (isset($_POST['wppa-widget-linkpage'])) { wppa_update_option('wppa_widget_linkpage', $_POST['wppa-widget-linkpage']); } if (isset($_POST['wppa-widget-linkurl'])) { wppa_update_option('wppa_widget_linkurl', $_POST['wppa-widget-linkurl']); } if (isset($_POST['wppa-widget-linktitle'])) { wppa_update_option('wppa_widget_linktitle', $_POST['wppa-widget-linktitle']); } if (isset($_POST['wppa-widget-linktype'])) { wppa_update_option('wppa_widget_linktype', $_POST['wppa-widget-linktype']); } if (wppa_check_numeric($_POST['wppa-potd-widget-width'], '100', __('Widget Photo Width.'))) { wppa_update_option('wppa_potd_widget_width', $_POST['wppa-potd-widget-width']); } else { $options_error = true; } if (!$options_error) { wppa_update_message(__('Changes Saved. Don\'t forget to activate the widget!', 'wppa')); } } wppa_initialize_runtime('force'); ?> <div class="wrap"> <?php $iconurl = WPPA_URL . '/images/settings32.png'; ?> <div id="icon-album" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> <br /> </div> <h2><?php _e('Photo of the Day Widget Settings', 'wppa'); ?> </h2> <form action="<?php echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day'); ?> " method="post"> <?php wp_nonce_field('$wppa_nonce', WPPA_NONCE); ?> <table class="form-table wppa-table wppa-photo-table"> <tbody> <tr valign="top"> <th scope="row"> <label ><?php _e('Widget Title:', 'wppa'); ?> </label> </th> <td> <input type="text" name="wppa-widgettitle" id="wppa-widgettitle" value="<?php echo wppa_opt('widgettitle'); ?> " /> <span class="description"><br/><?php _e('Enter/modify the title for the widget. This is a default and can be overriden at widget activation.', 'wppa'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"> <label ><?php _e('Widget Photo Width:', 'wppa'); ?> </label> </th> <td> <input type="text" name="wppa-potd-widget-width" id="wppa-potd-widget-width" value="<?php echo wppa_opt('potd_widget_width'); ?> " style="width: 50px;" /> <?php _e('pixels.', 'wppa'); echo ' '; _e('Horizontal alignment:', 'wppa'); ?> <select name="wppa-potd-align" id="wppa-potd-align"> <?php $ali = wppa_opt('potd_align'); ?> <?php $sel = 'selected="selected"'; ?> <option value="none" <?php if ($ali == 'none') { echo $sel; } ?> ><?php _e('--- none ---', 'wppa'); ?> </option> <option value="left" <?php if ($ali == 'left') { echo $sel; } ?> ><?php _e('left', 'wppa'); ?> </option> <option value="center" <?php if ($ali == 'center') { echo $sel; } ?> ><?php _e('center', 'wppa'); ?> </option> <option value="right" <?php if ($ali == 'right') { echo $sel; } ?> ><?php _e('right', 'wppa'); ?> </option> </select> <span class="description"><br/><?php _e('Enter the desired display width and alignment of the photo in the sidebar.', 'wppa'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"> <label ><?php _e('Use album(s):', 'wppa'); ?> </label> </th> <td> <script type="text/javascript"> /* <![CDATA[ */ function wppaCheckWa() { document.getElementById('wppa-spin').style.visibility = 'visible'; document.getElementById('wppa-upd').style.visibility = 'hidden'; var album = document.getElementById('wppa-wa').value; if ( album != 'all' && album != 'sep' && album != 'all-sep' && album != 'topten' && album != 'clr' ) album = document.getElementById('wppa-was').value + ',' + album; var url = "<?php echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day'); ?> &walbum=" + album; document.location.href = url; } /* ]]> */ </script> <?php _e('Select:', 'wppa'); ?> <select name="wppa-widget-album" id="wppa-wa" onchange="wppaCheckWa()" ><?php echo wppa_walbum_select(wppa_opt('widget_album')); ?> </select> <img id="wppa-spin" src="<?php echo wppa_get_imgdir(); ?> wpspin.gif" style="visibility:hidden;"/> <?php _e('Or Edit:', 'wppa'); ?> <input type="text" name="wppa-widget-albums" id="wppa-was" value="<?php echo wppa_opt('widget_album'); ?> " /> <input class="button-primary" name="wppa-upd" id="wppa-upd" value="<?php _e('Update thumbnails', 'wppa'); ?> " onclick="wppaCheckWa()" /> <span class="description"><br/> <?php _e('Select or edit the album(s) you want to use the photos of for the widget.', 'wppa'); ?> <br /> <?php _e('If you want a <b>- special -</b> selection or get rid of it, you may need to use <b>- start over -</b> first.', 'wppa'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"> <label ><?php _e('Display method:', 'wppa'); ?> </label> </th> <td> <?php $sel = 'selected="selected"'; ?> <?php $method = wppa_opt('widget_method'); ?> <select name="wppa-widget-method" id="wppa-wm" onchange="wppaCheckWidgetMethod()" > <option value="1" <?php if ($method == '1') { echo $sel; } ?> ><?php _e('Fixed photo', 'wppa'); ?> </option> <option value="2" <?php if ($method == '2') { echo $sel; } ?> ><?php _e('Random', 'wppa'); ?> </option> <option value="3" <?php if ($method == '3') { echo $sel; } ?> ><?php _e('Last upload', 'wppa'); ?> </option> <option value="4" <?php if ($method == '4') { echo $sel; } ?> ><?php _e('Change every', 'wppa'); ?> </option> </select> <?php $period = wppa_opt('widget_period'); ?> <select name="wppa-widget-period" id="wppa-wp" > <option value="0" <?php if ($period == '0') { echo $sel; } ?> ><?php _e('pageview.', 'wppa'); ?> </option> <option value="1" <?php if ($period == '1') { echo $sel; } ?> ><?php _e('hour.', 'wppa'); ?> </option> <option value="24" <?php if ($period == '24') { echo $sel; } ?> ><?php _e('day.', 'wppa'); ?> </option> <option value="168" <?php if ($period == '168') { echo $sel; } ?> ><?php _e('week.', 'wppa'); ?> </option> <option value="736" <?php if ($period == '736') { echo $sel; } ?> ><?php _e('month.', 'wppa'); ?> </option> <option value="day-of-week" <?php if ($period == 'day-of-week') { echo $sel; } ?> ><?php _e('day of week is order#', 'wppa'); ?> </option> <option value="day-of-month" <?php if ($period == 'day-of-month') { echo $sel; } ?> ><?php _e('day of month is order#', 'wppa'); ?> </option> </select> <span class="description"><br/><?php _e('Select how the widget should display.', 'wppa'); ?> </span> </td> </tr> <?php $linktype = wppa_opt('widget_linktype'); if ($linktype != 'custom') { ?> <tr> <th scope="row"> <label ><?php _e('Link to:', 'wppa'); ?> </label> </th> <td> <?php _e('Links are set on the <b>Photo Albums -> Settings</b> screen.', 'wppa'); ?> </td> </tr> <?php } else { ?> <tr class="wppa-wlu" > <th scope="row"> <label ><?php _e('Link to:', 'wppa'); ?> </label> </th> <td> <?php _e('Title:', 'wppa'); ?> <input type="text" name="wppa-widget-linktitle" id="wppa-widget-linktitle" value="<?php echo wppa_opt('widget_linktitle'); ?> "style="width:20%" /> <?php _e('Url:', 'wppa'); ?> <input type="text" name="wppa-widget-linkurl" id="wppa-widget-linkurl" value="<?php echo wppa_opt('widget_linkurl'); ?> " style="width:50%" /> <span class="description"><br/><?php _e('Enter the title and the url. Do\'nt forget the HTTP://', 'wppa'); ?> </span> </td> </tr> <?php } ?> <!--<script type="text/javascript">wppaCheckWidgetLink()</script>--> <tr> <th scope="row"> <label ><?php _e('Subtitle:', 'wppa'); ?> </label> </th> <td> <?php $subtit = wppa_opt('widget_subtitle'); ?> <select name="wppa-widget-subtitle" id="wppa-st" onchange="wppaCheckWidgetSubtitle()" > <option value="none" <?php if ($subtit == 'none') { echo $sel; } ?> ><?php _e('--- none ---', 'wppa'); ?> </option> <option value="name" <?php if ($subtit == 'name') { echo $sel; } ?> ><?php _e('Photo Name', 'wppa'); ?> </option> <option value="desc" <?php if ($subtit == 'desc') { echo $sel; } ?> ><?php _e('Description', 'wppa'); ?> </option> <option value="owner" <?php if ($subtit == 'owner') { echo $sel; } ?> ><?php _e('Owner', 'wppa'); ?> </option> </select> <span class="description"><br/><?php _e('Select the content of the subtitle.', 'wppa'); ?> </span> </td> </tr> </tbody> </table> <p> <input type="submit" class="button-primary" name="wppa-set-submit" value="<?php _e('Save Changes', 'wppa'); ?> " /> </p> <?php $alb = wppa_opt('widget_album'); $photos = wppa_get_widgetphotos($alb); if (empty($photos)) { echo '<p>' . __('No photos yet in this album.', 'wppa') . '</p>'; } else { $curid = wppa_opt('widget_photo'); $wi = wppa_get_minisize() + 24; $hi = $wi + 48; // Process photos foreach ($photos as $photo) { $id = $photo['id']; // Open container div echo '<div' . ' class="photoselect"' . ' style="' . 'width:' . wppa_opt('widget_width') . 'px;' . 'height:' . $hi . 'px;' . 'overflow:hidden;' . '" >'; // The image if a video if (wppa_is_video($id)) { echo wppa_get_video_html(array('id' => $id, 'style' => 'width:' . wppa_opt('widget_width') . 'px;')); } else { echo '<img' . ' src=" ' . wppa_fix_poster_ext(wppa_get_thumb_url($id), $id) . '"' . ' style="' . 'width:' . wppa_opt('widget_width') . 'px;' . '"' . ' alt="' . $photo['name'] . '" />'; // Audio ? if (wppa_has_audio($id)) { echo wppa_get_audio_html(array('id' => $id, 'style' => 'width:' . wppa_opt('widget_width') . 'px;' . 'position:relative;' . 'bottom:' . (wppa_get_audio_control_height() + 4) . 'px;')); } } ?> <input type="radio" name="wppa-widget-photo" id="wppa-widget-photo<?php echo $id; ?> " value="<?php echo $id; ?> " <?php if ($id == $curid) { echo 'checked="checked"'; } ?> /> <div class="clear"></div> <h4 style="position: absolute; top:<?php echo $wi - 12; ?> px; font-size:11px; overflow:hidden;"><?php echo wppa_qtrans(stripslashes($photo['name'])); ?> </h4> <h6 style="position: absolute; top:<?php echo $wi + 6; ?> px; font-size:9px; line-height:10px;"><?php echo wppa_qtrans(stripslashes($photo['description'])); ?> </h6> <h5 style="position: absolute; top:<?php echo $wi + 24; ?> px; font-size:9px; line-height:10px;"><?php echo '(#' . $photo['p_order'] . ')'; ?> </h5> </div><?php } echo '<div class="clear"></div>'; } ?> <script type="text/javascript">wppaCheckWidgetMethod();</script> <script type="text/javascript">wppaCheckWidgetSubtitle();</script> <br /> <p> <input type="submit" class="button-primary" name="wppa-set-submit" value="<?php _e('Save Changes', 'wppa'); ?> " /> </p> </form> </div> <?php }
/** @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'] = 'topten'; $wppa['mocc']++; extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'mean_rating', 'title' => '', 'album' => '', 'display' => 'thumbs', 'meanrat' => 'yes', 'ratcount' => 'yes', 'viewcount' => 'yes', 'includesubs' => 'yes', 'showowner' => 'no', 'showalbum' => 'no')); $widget_title = apply_filters('widget_title', $instance['title']); $page = in_array($wppa_opt['wppa_topten_widget_linktype'], $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_topten_widget_linkpage', __a('Top Ten Photos')); $albumlinkpage = wppa_get_the_landing_page('wppa_topten_widget_album_linkpage', __a('Top Ten Photo album')); $max = $wppa_opt['wppa_topten_count']; $album = $instance['album']; switch ($instance['sortby']) { case 'mean_rating': $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC'; break; case 'rating_count': $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC'; break; case 'views': $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC'; break; } $display = $instance['display']; $meanrat = $instance['meanrat'] == 'yes'; $ratcount = $instance['ratcount'] == 'yes'; $viewcount = $instance['viewcount'] == 'yes'; $includesubs = $instance['includesubs'] == 'yes'; $albenum = ''; $showowner = $instance['showowner'] == 'yes'; $showalbum = $instance['showalbum'] == 'yes'; if ($album) { if ($album == '-2') { $album = '0'; } if ($includesubs) { $albenum = wppa_alb_to_enum_children($album); $albenum = wppa_expand_enum($albenum); $album = str_replace('.', ',', $albenum); } $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` IN (" . $album . ") ORDER BY " . $sortby . " LIMIT " . $max, ARRAY_A); //wppa_log('dbg', "SELECT * FROM `".WPPA_PHOTOS."` WHERE `album` IN (".$album.") ORDER BY " . $sortby . " LIMIT " . $max); } else { $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` ORDER BY " . $sortby . " LIMIT " . $max, ARRAY_A); } $widget_content = "\n" . '<!-- WPPA+ TopTen Widget start -->'; $maxw = $wppa_opt['wppa_topten_size']; $maxh = $maxw; $lineheight = $wppa_opt['wppa_fontsize_widget_thumb'] * 1.5; $maxh += $lineheight; if ($meanrat) { $maxh += $lineheight; } if ($ratcount) { $maxh += $lineheight; } if ($viewcount) { $maxh += $lineheight; } if ($showowner) { $maxh += $lineheight; } if ($showalbum) { $maxh += $lineheight; } if ($thumbs) { foreach ($thumbs as $image) { global $thumb; $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 = __a('View the top rated photos', 'wppa_theme'); } else { $tit = esc_attr(wppa_qtrans(stripslashes($image['description']))); } $compressed_albumenum = wppa_compress_enum($albenum); $link = wppa_get_imglnk_a('topten', $image['id'], '', $tit, '', $no_album, $compressed_albumenum); $file = wppa_get_thumb_path($image['id']); $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb'); $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('topten', $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;">'; // Display (owner) ? if ($showowner) { $widget_content .= '<div>(' . $image['owner'] . ')</div>'; } // Display (album) ? if ($showalbum) { $href = wppa_convert_to_pretty(wppa_get_album_url($image['album'], $albumlinkpage, 'content', '1')); $widget_content .= '<div>(<a href="' . $href . '" >' . wppa_get_album_name($image['album']) . '</a>)</div>'; } $rating = wppa_get_rating_by_id($image['id']); switch ($instance['sortby']) { case 'mean_rating': if ($meanrat == 'yes') { $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>'; } if ($ratcount == 'yes') { $widget_content .= '<div>' . sprintf(__a('%s Votes'), wppa_get_rating_count_by_id($image['id'])) . '</div>'; } if ($viewcount == 'yes' && $image['views']) { $widget_content .= '<div>' . sprintf(__a('Views: %s times', 'wppa_theme'), $image['views']) . '</div>'; } break; case 'rating_count': if ($ratcount == 'yes') { $widget_content .= '<div>' . sprintf(__a('%s Votes'), wppa_get_rating_count_by_id($image['id'])) . '</div>'; } if ($meanrat == 'yes') { $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>'; } if ($viewcount == 'yes' && $image['views']) { $widget_content .= '<div>' . sprintf(__a('Views: %s times', 'wppa_theme'), $image['views']) . '</div>'; } break; case 'views': if ($viewcount == 'yes' && $image['views']) { $widget_content .= '<div>' . sprintf(__a('Views: %s times', 'wppa_theme'), $image['views']) . '</div>'; } if ($meanrat == 'yes') { $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>'; } if ($ratcount == 'yes') { $widget_content .= '<div>' . sprintf(__a('%s Votes'), wppa_get_rating_count_by_id($image['id'])) . '</div>'; } break; } $widget_content .= '</div>'; } else { // No image $widget_content .= __a('Photo not found.', 'wppa_theme'); } $widget_content .= "\n" . '</div>'; } } else { $widget_content .= 'There are no rated photos (yet).'; } $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ TopTen Widget end -->'; echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; }
function wppa_get_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '') { global $wppa; global $wpdb; // make sure the photo data ia available $thumb = wppa_cache_thumb($id); if (!$thumb) { return false; } // Is it a video? $is_video = wppa_is_video($id, true); // Photo Specific Overrule? if ($wich == 'sphoto' && wppa_switch('wppa_sphoto_overrule') || $wich == 'mphoto' && wppa_switch('wppa_mphoto_overrule') || $wich == 'thumb' && wppa_switch('wppa_thumb_overrule') || $wich == 'topten' && wppa_switch('wppa_topten_overrule') || $wich == 'featen' && wppa_switch('wppa_featen_overrule') || $wich == 'lasten' && wppa_switch('wppa_lasten_overrule') || $wich == 'sswidget' && wppa_switch('wppa_sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('wppa_potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('wppa_coverimg_overrule') || $wich == 'comten' && wppa_switch('wppa_comment_overrule') || $wich == 'slideshow' && wppa_switch('wppa_slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('wppa_thumbnail_widget_overrule')) { // Look for a photo specific link if ($thumb) { // If it is there... if ($thumb['linkurl']) { // Use it. It superceeds other settings $result['url'] = esc_attr($thumb['linkurl']); $result['title'] = esc_attr(wppa_qtrans(stripslashes($thumb['linktitle']))); $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = ''; $result['target'] = $thumb['linktarget']; return $result; } } } $result['target'] = '_self'; $result['title'] = ''; $result['onclick'] = ''; switch ($wich) { case 'sphoto': $type = wppa_opt('wppa_sphoto_linktype'); $page = wppa_opt('wppa_sphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_sphoto_blank')) { $result['target'] = '_blank'; } break; case 'mphoto': $type = wppa_opt('wppa_mphoto_linktype'); $page = wppa_opt('wppa_mphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_mphoto_blank')) { $result['target'] = '_blank'; } break; case 'thumb': $type = wppa_opt('wppa_thumb_linktype'); $page = wppa_opt('wppa_thumb_linkpage'); if (wppa_switch('wppa_thumb_blank')) { $result['target'] = '_blank'; } break; case 'topten': $type = wppa_opt('wppa_topten_widget_linktype'); $page = wppa_opt('wppa_topten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_topten_blank')) { $result['target'] = '_blank'; } break; case 'featen': $type = wppa_opt('wppa_featen_widget_linktype'); $page = wppa_opt('wppa_featen_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_featen_blank')) { $result['target'] = '_blank'; } break; case 'lasten': $type = wppa_opt('wppa_lasten_widget_linktype'); $page = wppa_opt('wppa_lasten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_lasten_blank')) { $result['target'] = '_blank'; } break; case 'comten': $type = wppa_opt('wppa_comment_widget_linktype'); $page = wppa_opt('wppa_comment_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_comment_blank')) { $result['target'] = '_blank'; } break; case 'sswidget': $type = wppa_opt('wppa_slideonly_widget_linktype'); $page = wppa_opt('wppa_slideonly_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_sswidget_blank')) { $result['target'] = '_blank'; } $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } break; case 'potdwidget': $type = wppa_opt('wppa_widget_linktype'); $page = wppa_opt('wppa_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_potd_blank')) { $result['target'] = '_blank'; } break; case 'coverimg': $type = wppa_opt('wppa_coverimg_linktype'); $page = wppa_opt('wppa_coverimg_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_coverimg_blank')) { $result['target'] = '_blank'; } if ($type == 'slideshowstartatimage') { $result['url'] = wppa_get_slideshow_url($album, $page, $id); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'tnwidget': $type = wppa_opt('wppa_thumbnail_widget_linktype'); $page = wppa_opt('wppa_thumbnail_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_thumbnail_widget_blank')) { $result['target'] = '_blank'; } break; case 'slideshow': $type = wppa_opt('wppa_slideshow_linktype'); //''; $page = wppa_opt('wppa_slideshow_linkpage'); $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } if ($type == 'thumbs') { $result['url'] = wppa_get_ss_to_tn_link($page, $id); $result['title'] = __a('View thumbnails'); $result['is_url'] = true; $result['is_lightbox'] = false; if (wppa_switch('wppa_slideshow_blank')) { $result['target'] = '_blank'; } return $result; } if ($type == 'none') { return; } // Continue for 'single' break; case 'albwidget': $type = wppa_opt('wppa_album_widget_linktype'); $page = wppa_opt('wppa_album_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('wppa_album_widget_blank')) { $result['target'] = '_blank'; } break; default: return false; break; } if (!$album) { $album = wppa('start_album'); } if ($album == '' && !wppa('is_upldr')) { /**/ $album = wppa_get_album_id_by_photo_id($id); } if (is_numeric($album)) { $album_name = wppa_get_album_name($album); } else { $album_name = ''; } if (!$album) { $album = '0'; } if ($wich == 'comten') { $album = '0'; } if (wppa('is_tag')) { $album = '0'; } if (wppa('supersearch')) { $album = '0'; } // if ( wppa( 'is_upldr' ) ) $album = '0'; // probeersel upldr parent if ($id) { $photo_name = wppa_get_photo_name($id); } else { $photo_name = ''; } $photo_name_js = esc_js($photo_name); $photo_name = esc_attr($photo_name); if ($id) { $photo_desc = esc_attr(wppa_get_photo_desc($id)); } else { $photo_desc = ''; } $title = __($photo_name); $result['onclick'] = ''; // Init switch ($type) { case 'none': // No link at all return false; break; case 'file': // The plain file if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); reset($is_video); $result['url'] = str_replace('xxx', current($is_video), $result['url']); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'lightbox': case 'lightboxsingle': if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] ); } else { if (wppa_switch('wppa_lb_hres')) { $result['url'] = wppa_get_hires_url($id); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = true; $result['url'] = wppa_fix_poster_ext($result['url'], $id); return $result; case 'widget': // Defined at widget activation $result['url'] = wppa('in_widget_linkurl'); $result['title'] = esc_attr(wppa('in_widget_linktitle')); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'album': // The albums thumbnails // The albums thumbnails case 'content': // For album widget switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; // $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; //$album_name;//'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'thumbalbum': $album = $thumb['album']; $album_name = wppa_get_album_name($album); switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'photo': // This means: The fullsize photo in a slideshow // This means: The fullsize photo in a slideshow case 'slphoto': // This means: The single photo in the style of a slideshow if ($type == 'slphoto') { $si = '&wppa-single=1'; } else { $si = ''; } switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'single': switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'same': $result['url'] = $lnk; $result['title'] = $tit; $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = $onc; return $result; break; case 'fullpopup': if ($is_video) { // A video can not be printed or downloaded $result['url'] = esc_attr('alert( "' . esc_js(__a('A video can not be printed or downloaded')) . '" )'); } else { $wid = wppa_get_photox($id); $hig = wppa_get_photoy($id); /* $imgsize = getimagesize( wppa_get_photo_path( $id ) ); if ( $imgsize ) { $wid = $imgsize['0']; $hig = $imgsize['1']; } else { $wid = '0'; $hig = '0'; } */ $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id); $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )'); } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = false; return $result; break; case 'custom': if ($wich == 'potdwidget') { $result['url'] = wppa_opt('wppa_widget_linkurl'); $result['title'] = wppa_opt('wppa_widget_linktitle'); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'slide': // for album widget $result['url'] = wppa_get_permalink(wppa_opt('wppa_album_widget_linkpage')) . 'wppa-album=' . $album . '&slide'; $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'autopage': if (!wppa_switch('wppa_auto_page')) { wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force'); $result['url'] = ''; } else { $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id)); } $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'plainpage': $result['url'] = get_permalink($page); $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page)); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; default: wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red'); return false; break; } if ($type != 'thumbalbum') { if (wppa('supersearch')) { $result['url'] .= '&wppa-supersearch=' . urlencode(wppa('supersearch')); } if (wppa('src') && !wppa('is_related') && !wppa('in_widget')) { $result['url'] .= '&wppa-searchstring=' . urlencode(wppa('searchstring')); } if ($wich == 'topten') { $result['url'] .= '&wppa-topten=' . wppa_opt('wppa_topten_count'); } elseif (wppa('is_topten')) { $result['url'] .= '&wppa-topten=' . wppa('topten_count'); } if ($wich == 'lasten') { $result['url'] .= '&wppa-lasten=' . wppa_opt('wppa_lasten_count'); } elseif (wppa('is_lasten')) { $result['url'] .= '&wppa-lasten=' . wppa('lasten_count'); } if ($wich == 'comten') { $result['url'] .= '&wppa-comten=' . wppa_opt('wppa_comten_count'); } elseif (wppa('is_comten')) { $result['url'] .= '&wppa-comten=' . wppa('comten_count'); } if ($wich == 'featen') { $result['url'] .= '&wppa-featen=' . wppa_opt('wppa_featen_count'); } elseif (wppa('is_featen')) { $result['url'] .= '&wppa-featen=' . wppa('featen_count'); } if (wppa('is_related')) { $result['url'] .= '&wppa-rel=' . wppa('is_related') . '&wppa-relcount=' . wppa('related_count'); } elseif (wppa('is_tag')) { $result['url'] .= '&wppa-tag=' . wppa('is_tag'); } if (wppa('is_upldr')) { $result['url'] .= '&wppa-upldr=' . wppa('is_upldr'); } } if ($page != '0') { // on a different page $occur = '1'; $w = ''; } else { // on the same page, post or widget $occur = wppa('in_widget') ? wppa('widget_occur') : wppa('occur'); $w = wppa('in_widget') ? 'w' : ''; } $result['url'] .= '&wppa-' . $w . 'occur=' . $occur; $result['url'] = wppa_convert_to_pretty($result['url']); if ($result['title'] == '') { $result['title'] = $tit; } // If still nothing, try arg return $result; }
function wppa_album_cover_view_link($albumid, $has_content, $photocount, $albumcount, $mincount, $href_content, $target, $onclick_content) { global $wppa; $album = wppa_cache_album($albumid); if (wppa_switch('wppa_show_viewlink')) { $wppa['out'] .= wppa_nltab('+') . '<div class="wppa-box-text wppa-black wppa-info wppa-viewlink">'; if ($has_content) { // Fake photocount to prevent link to empty page if (wppa_opt('wppa_thumbtype') == 'none') { $photocount = '0'; } // Still has content if ($photocount > $mincount || $albumcount) { // Get treecount data if (wppa_switch('wppa_show_treecount')) { $treecount = wppa_treecount_a($albumid); } else { $treecount = false; } if ($href_content == '#') { $wppa['out'] .= wppa_nltab('+') . '<a onclick="' . $onclick_content . '" title="' . __a('View the album') . ' ' . esc_attr(stripslashes(wppa_qtrans($album['name']))) . '" style="' . __wcs('wppa-box-text-nocolor') . '" >'; } else { $wppa['out'] .= wppa_nltab('+') . '<a href="' . $href_content . '" target="' . $target . '" onclick="' . $onclick_content . '" title="' . __a('View the album') . ' ' . esc_attr(stripslashes(wppa_qtrans($album['name']))) . '" style="' . __wcs('wppa-box-text-nocolor') . '" >'; } /**/ $text = __a('View'); if ($albumcount) { if ($albumcount == '1') { $text .= ' 1 ' . __a('album'); } else { $text .= ' ' . $albumcount . ' ' . __a('albums'); } if ($treecount) { if ($treecount['albums'] > $albumcount) { $text .= ' (' . $treecount['albums'] . ')'; } } } if ($photocount > $mincount && $albumcount) { $text .= ' ' . __a('and'); } if ($photocount > $mincount || $treecount) { if ($photocount <= $mincount) { $photocount = '0'; } if ($photocount == '1') { $text .= ' 1 ' . __a('photo'); } elseif ($photocount) { $text .= ' ' . $photocount . ' ' . __a('photos'); } if ($treecount) { if ($treecount['photos'] > $photocount) { if (!$photocount) { $text .= ', ' . __a('photos'); } $text .= ' (' . $treecount['photos'] . ')'; } } } $wppa['out'] .= str_replace(' ', ' ', $text); /**/ $wppa['out'] .= wppa_nltab('-') . '</a>'; } } else { $wppa['out'] .= ' '; } $wppa['out'] .= wppa_nltab('-') . '</div>'; } }
/** @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_do_albumlist($parent, $nestinglevel, $albums, $seq) { global $wpdb; $alt = true; foreach (array_keys($seq) as $s) { // Obey the global sequence $album = $albums[$s]; if ($album['a_parent'] == $parent) { if (wppa_have_access($album)) { $counts = wppa_treecount_a($album['id']); $pendcount = $counts['pendphotos']; $schedulecount = $counts['scheduledphotos']; $haschildren = wppa_have_accessable_children($album); $class = ''; if ($parent != '0' && $parent != '-1') { $class .= 'wppa-alb-on-' . $parent . ' '; $par = $parent; while ($par != '0' && $par != '-1') { $class .= 'wppa-alb-off-' . $par . ' '; $par = wppa_get_parentalbumid($par); } } if ($alt) { $class .= ' alternate'; } $style = ''; if ($pendcount) { $style .= 'background-color:#ffdddd; '; } // if ( $haschildren ) $style .= 'font-weight:bold; '; if ($parent != '0' && $parent != '-1') { $style .= 'display:none; '; } $onclickon = 'jQuery(\'.wppa-alb-on-' . $album['id'] . '\').css(\'display\',\'\'); jQuery(\'#alb-arrow-on-' . $album['id'] . '\').css(\'display\',\'none\'); jQuery(\'#alb-arrow-off-' . $album['id'] . '\').css(\'display\',\'\');'; $onclickoff = 'jQuery(\'.wppa-alb-off-' . $album['id'] . '\').css(\'display\',\'none\'); jQuery(\'#alb-arrow-on-' . $album['id'] . '\').css(\'display\',\'\'); jQuery(\'#alb-arrow-off-' . $album['id'] . '\').css(\'display\',\'none\'); checkArrows();'; $indent = $nestinglevel; if ($indent > '5') { $indent = 5; } ?> <tr class="<?php echo $class; ?> " style="<?php echo $style; ?> " > <?php $i = 0; while ($i < $indent) { echo '<td style="padding:2px;" ></td>'; $i++; } ?> <td style="padding:2px; text-align:center;" ><?php if ($haschildren) { ?> <img id="alb-arrow-off-<?php echo $album['id']; ?> " class="alb-arrow-off" style="height:16px; display:none;" src="<?php echo wppa_get_imgdir() . 'backarrow.gif'; ?> " onclick="<?php echo $onclickoff; ?> " title="<?php _e('Collapse subalbums', 'wppa'); ?> " /> <img id="alb-arrow-on-<?php echo $album['id']; ?> " class="alb-arrow-on" style="height:16px;" src="<?php echo wppa_get_imgdir() . 'arrow.gif'; ?> " onclick="<?php echo $onclickon; ?> " title="<?php _e('Expand subalbums', 'wppa'); ?> " /> <?php } ?> </td> <td style="padding:2px;" ><?php echo $album['id']; ?> </td> <?php $i = $indent; while ($i < 5) { echo '<td style="padding:2px;" ></td>'; $i++; } ?> <td><?php echo esc_attr(wppa_qtrans(stripslashes($album['name']))); ?> </td> <td><small><?php echo esc_attr(wppa_qtrans(stripslashes($album['description']))); ?> </small></td> <?php if (current_user_can('administrator')) { ?> <td><?php echo $album['owner']; ?> </td> <?php } ?> <td><?php echo $album['a_order']; ?> </td> <td><?php echo wppa_get_album_name($album['a_parent'], 'extended'); ?> </td> <?php $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album['id']); ?> <?php $na = $counts['selfalbums']; ?> <?php $np = $counts['selfphotos']; ?> <?php $nm = $counts['pendphotos']; ?> <?php $ns = $counts['scheduledphotos']; ?> <td><?php echo $na . '/' . $np . '/' . $nm . '/' . $ns; ?> </td> <?php if ($album['owner'] != '--- public ---' || wppa_user_is('administrator')) { ?> <?php $url = wppa_ea_url($album['id']); ?> <td><a href="<?php echo $url; ?> " class="wppaedit"><?php _e('Edit', 'wppa'); ?> </a></td> <td><a href="<?php echo $url . '&quick'; ?> " class="wppaedit"><?php _e('Quick', 'wppa'); ?> </a></td> <td><a href="<?php echo $url . '&bulk#manage-photos'; ?> " class="wppaedit"><?php _e('Bulk', 'wppa'); ?> </a></td> <td><a href="<?php echo $url . '&seq'; ?> " class="wppaedit"><?php _e('Seq', 'wppa'); ?> </a></td> <?php $url = wppa_ea_url($album['id'], 'del'); ?> <td><a href="<?php echo $url; ?> " class="wppadelete"><?php _e('Delete', 'wppa'); ?> </a></td> <?php if (wppa_can_create_album()) { $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=new&parent_id=' . $album['id']); $onc = 'if (confirm(\'' . __('Are you sure you want to create a subalbum?', 'wppa') . '\')) document.location=\'' . $url . '\';'; echo '<td><a onclick="' . $onc . '" class="wppacreate">' . __('Create', 'wppa') . '</a></td>'; } } else { ?> <td></td><td></td><?php if (wppa_can_create_album()) { echo '<td></td'; } ?> <?php } ?> </tr> <?php if ($alt == '') { $alt = ' class="alternate" '; } else { $alt = ''; } if ($haschildren) { wppa_do_albumlist($album['id'], $nestinglevel + '1', $albums, $seq); } } } } }
function _wppa_page_export() { global $wpdb; // Export Photos admin page // Do the export if requested if (isset($_POST['wppa-export-submit'])) { check_admin_referer('$wppa_nonce', WPPA_NONCE); wppa_export_photos(); } ?> <div class="wrap"> <?php $iconurl = WPPA_URL . '/images/album32.png'; ?> <div id="icon-camera" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> </div> <?php $iconurl = WPPA_URL . '/images/arrow32.png'; ?> <div id="icon-arrow" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> </div> <?php $iconurl = WPPA_URL . '/images/disk32.png'; ?> <div id="icon-disk" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> <br /> </div> <h2><?php _e('Export Photos', 'wppa'); ?> </h2><br /> <form action="<?php echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_export_photos'); ?> " method="post"> <?php wp_nonce_field('$wppa_nonce', WPPA_NONCE); ?> <?php echo sprintf(__('Photos will be exported to: <b>%s</b>.', 'wppa'), WPPA_DEPOT); ?> <h2><?php _e('Export photos from album <span style="font-size:12px;">(Including Album information)</span>:', 'wppa'); ?> </h2> <?php $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` " . wppa_get_album_order(), ARRAY_A); $high = '0'; ?> <table class="form-table albumtable"> <thead> </thead> <tbody> <tr> <?php $ct = 0; foreach ($albums as $album) { $line = ' ' . $album['id'] . ': ' . wppa_qtrans(stripslashes($album['name'])); if ($album['id'] > $high) { $high = $album['id']; } ?> <td> <input type="checkbox" name="album-<?php echo $album['id']; ?> " /> <?php echo $line; ?> </td> <?php if ($ct == 4) { // Wrap to newline echo '</tr><tr>'; $ct = 0; } else { $ct++; } } ?> </tr> </tbody> </table> <input type="hidden" name="high" value="<?php echo $high; ?> " /> <p> <input type="submit" class="button-primary" name="wppa-export-submit" value="<?php _e('Export', 'wppa'); ?> " /> </p> </form> </div> <?php }