function wppa_get_potd() { global $wpdb; $image = ''; switch (wppa_opt('widget_method')) { case '1': // Fixed photo $id = wppa_opt('widget_photo'); if ($id != '') { $image = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s LIMIT 0,1", $id), ARRAY_A); wppa_dbg_q('Q-Potd'); wppa_cache_photo('add', $image); } break; case '2': // Random $album = wppa_opt('widget_album'); if ($album == 'topten') { $images = wppa_get_widgetphotos($album); if (count($images) > 1) { // Select a random first from the current selection $idx = rand(0, count($images) - 1); $image = $images[$idx]; } } elseif ($album != '') { $images = wppa_get_widgetphotos($album, "ORDER BY RAND() LIMIT 0,1"); $image = $images[0]; } break; case '3': // Last upload $album = wppa_opt('widget_album'); if ($album == 'topten') { $images = wppa_get_widgetphotos($album); if ($images) { // fid last uploaded image in the $images pool $temp = 0; foreach ($images as $img) { if ($img['timestamp'] > $temp) { $temp = $img['timestamp']; $image = $img; } } } } elseif ($album != '') { $images = wppa_get_widgetphotos($album, "ORDER BY timestamp DESC LIMIT 0,1"); $image = $images[0]; } break; case '4': // Change every $album = wppa_opt('widget_album'); if ($album != '') { $per = wppa_opt('widget_period'); $photos = wppa_get_widgetphotos($album); if ($per == '0') { if ($photos) { $image = $photos[rand(0, count($photos) - 1)]; } else { $image = ''; } } elseif ($per == 'day-of-week') { $image = ''; if ($photos) { $d = date_i18n("w"); $d -= get_option('wppa_potd_offset', '0'); while ($d < '1') { $d += '7'; } foreach ($photos as $img) { if ($img['p_order'] == $d) { $image = $img; } } } } elseif ($per == 'day-of-month') { $image = ''; if ($photos) { $d = strval(intval(date_i18n("d"))); $d -= get_option('wppa_potd_offset', '0'); while ($d < '1') { $d += '31'; } foreach ($photos as $img) { if ($img['p_order'] == $d) { $image = $img; } } } } elseif ($per == 'day-of-year') { $image = ''; if ($photos) { $d = strval(intval(date_i18n("z"))); $d -= get_option('wppa_potd_offset', '0'); while ($d < '0') { $d += '366'; } foreach ($photos as $img) { if ($img['p_order'] == $d) { $image = $img; } } } } else { $u = date_i18n("U"); // Seconds since 1-1-1970, local $u /= 3600; // hours since $u = floor($u); $u /= $per; $u = floor($u); // Find the right photo out of the photos found by wppa_get_widgetphotos(), // based on the Change every { any timeperiod } algorithm. if ($photos) { $p = count($photos); $idn = fmod($u, $p); // If from topten,... if ($album == 'topten') { // Do a re-read of the same to order by rand, reproduceable // This can not be done by wppa_get_widgetphotos(), // it does already ORDER BY for the top selection criterium. // So we save the ids, and do a SELECT WHERE id IN ( array of found ids ) ORDER BY RAND( seed ) $ids = array(); foreach ($photos as $photo) { $ids[] = $photo['id']; } $photos = $wpdb->get_results("SELECT `id`, `p_order` " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `id` IN (" . implode(',', $ids) . ") " . "ORDER BY RAND(" . $idn . ")", ARRAY_A); } else { $photos = wppa_get_widgetphotos($album, " ORDER BY RAND(" . $idn . ")"); } // Image found $image = $photos[$idn]; } else { $image = ''; } } } else { $image = ''; } break; default: $image = ''; } if ($image) { $image = wppa_cache_photo($image['id']); } return $image; }
function wppa_get_potd() { global $wpdb; global $thumb; $image = ''; switch (wppa_opt('wppa_widget_method')) { case '1': // Fixed photo $id = wppa_opt('wppa_widget_photo'); if ($id != '') { $image = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s LIMIT 0,1", $id), ARRAY_A); wppa_dbg_q('Q-Potd'); wppa_cache_photo('add', $image); } break; case '2': // Random $album = wppa_opt('wppa_widget_album'); if ($album == 'topten') { $images = wppa_get_widgetphotos($album); if (count($images) > 1) { // Select a random first from the current selection $idx = rand(0, count($images) - 1); $image = $images[$idx]; } } elseif ($album != '') { $images = wppa_get_widgetphotos($album, "ORDER BY RAND() LIMIT 0,1"); $image = $images[0]; } break; case '3': // Last upload $album = wppa_opt('wppa_widget_album'); if ($album == 'topten') { $images = wppa_get_widgetphotos($album); if ($images) { // fid last uploaded image in the $images pool $temp = 0; foreach ($images as $img) { if ($img['timestamp'] > $temp) { $temp = $img['timestamp']; $image = $img; } } } } elseif ($album != '') { $images = wppa_get_widgetphotos($album, "ORDER BY timestamp DESC LIMIT 0,1"); $image = $images[0]; } break; case '4': // Change every $album = wppa_opt('wppa_widget_album'); if ($album != '') { $per = wppa_opt('wppa_widget_period'); $photos = wppa_get_widgetphotos($album); if ($per == '0') { if ($photos) { $image = $photos[rand(0, count($photos) - 1)]; } else { $image = ''; } } elseif ($per == 'day-of-week') { $image = ''; if ($photos) { $d = wppa_local_date('w'); if (!$d) { $d = '7'; } foreach ($photos as $img) { if ($img['p_order'] == $d) { $image = $img; } } } } elseif ($per == 'day-of-month') { $image = ''; if ($photos) { $d = wppa_local_date('d'); if (substr($d, '0', '1') == '0') { $d = substr($d, '1'); } foreach ($photos as $img) { if ($img['p_order'] == $d) { $image = $img; } } } } else { $u = date("U"); // Seconds since 1-1-1970 $u /= 3600; // hours since $u = floor($u); $u /= $per; $u = floor($u); if ($photos) { $p = count($photos); $idn = fmod($u, $p); $image = $photos[$idn]; } else { $image = ''; } } } else { $image = ''; } break; default: $image = ''; } $thumb = $image; return $image; }
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 }
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($_REQUEST['wppa-set-submit'])) { if (!wp_verify_nonce($_REQUEST['wppa-update-check'], 'wppa-update-check')) { echo 'Trying:' . $_REQUEST['wppa-update-check']; } 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($_REQUEST['wppa-widget-period'])) { wppa_update_option('wppa_widget_period', $_REQUEST['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 (isset($_POST['wppa-widget-status-filter'])) { wppa_update_option('wppa_widget_status_filter', $_POST['wppa-widget-status-filter']); } if (isset($_POST['wppa-potd-offset'])) { wppa_update_option('wppa_potd_offset', $_POST['wppa-potd-offset']); } if (isset($_POST['wppa-potd-widget-width'])) { if (wppa_check_numeric($_POST['wppa-potd-widget-width'], '100', __('Widget Photo Width.', 'wp-photo-album-plus'))) { wppa_update_option('wppa_potd_widget_width', $_POST['wppa-potd-widget-width']); } else { $options_error = true; } } if (!$options_error && isset($_POST['wppa-set-submit'])) { wppa_update_message(__('Changes Saved. Don\'t forget to activate the widget!', 'wp-photo-album-plus')); } } 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', 'wp-photo-album-plus'); ?> </h2> <?php $action_url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day'); ?> <form action="<?php echo $action_url; ?> " method="post"> <?php echo wp_nonce_field('wppa-update-check', 'wppa-update-check'); ?> <table class="form-table wppa-table wppa-photo-table"> <tbody> <tr valign="top"> <th scope="row"> <label ><?php _e('Widget Title:', 'wp-photo-album-plus'); ?> </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.', 'wp-photo-album-plus'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"> <label ><?php _e('Widget Photo Width:', 'wp-photo-album-plus'); ?> </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.', 'wp-photo-album-plus'); echo ' '; _e('Horizontal alignment:', 'wp-photo-album-plus'); ?> <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 ---', 'wp-photo-album-plus'); ?> </option> <option value="left" <?php if ($ali == 'left') { echo $sel; } ?> ><?php _e('left', 'wp-photo-album-plus'); ?> </option> <option value="center" <?php if ($ali == 'center') { echo $sel; } ?> ><?php _e('center', 'wp-photo-album-plus'); ?> </option> <option value="right" <?php if ($ali == 'right') { echo $sel; } ?> ><?php _e('right', 'wp-photo-album-plus'); ?> </option> </select> <span class="description"><br/><?php _e('Enter the desired display width and alignment of the photo in the sidebar.', 'wp-photo-album-plus'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"> <label ><?php _e('Use album(s):', 'wp-photo-album-plus'); ?> </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:', 'wp-photo-album-plus'); ?> <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:', 'wp-photo-album-plus'); ?> <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', 'wp-photo-album-plus'); ?> " onclick="wppaCheckWa()" /> <span class="description"><br/> <?php _e('Select or edit the album(s) you want to use the photos of for the widget.', 'wp-photo-album-plus'); ?> <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.', 'wp-photo-album-plus'); ?> </span> </td> </tr> <!-- Status filter --> <tr valign="top" > <th scope="row" > <label ><?php _e('Status filter:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $sel = 'selected="selected"'; ?> <?php $filter = wppa_opt('widget_status_filter'); ?> <select name="wppa-widget-status-filter" > <option value="" <?php if ($filter == 'none') { echo $sel; } ?> ><?php _e('- none -', 'wp-photo-album-plus'); ?> </option> <option value="publish" <?php if ($filter == 'publish') { echo $sel; } ?> ><?php _e('Publish', 'wp-photo-album-plus'); ?> </option> <option value="featured" <?php if ($filter == 'featured') { echo $sel; } ?> ><?php _e('Featured', 'wp-photo-album-plus'); ?> </option> <option value="gold" <?php if ($filter == 'gold') { echo $sel; } ?> ><?php _e('Gold', 'wp-photo-album-plus'); ?> </option> <option value="silver" <?php if ($filter == 'silver') { echo $sel; } ?> ><?php _e('Silver', 'wp-photo-album-plus'); ?> </option> <option value="bronze" <?php if ($filter == 'bronze') { echo $sel; } ?> ><?php _e('Bronze', 'wp-photo-album-plus'); ?> </option> <option value="anymedal" <?php if ($filter == 'anymedal') { echo $sel; } ?> ><?php _e('Any medal', 'wp-photo-album-plus'); ?> </option> </select> </td> </tr> <tr valign="top" > <th scope="row"> <label ><?php _e('Display method:', 'wp-photo-album-plus'); ?> </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', 'wp-photo-album-plus'); ?> </option> <option value="2" <?php if ($method == '2') { echo $sel; } ?> ><?php _e('Random', 'wp-photo-album-plus'); ?> </option> <option value="3" <?php if ($method == '3') { echo $sel; } ?> ><?php _e('Last upload', 'wp-photo-album-plus'); ?> </option> <option value="4" <?php if ($method == '4') { echo $sel; } ?> ><?php _e('Change every', 'wp-photo-album-plus'); ?> </option> </select> <?php $period = wppa_opt('widget_period'); $text = esc_attr(__('The page will now be reloaded', 'wp-photo-album-plus')); $onchange = esc_attr('alert(\'' . $text . '\');wppaPotdChangePeriod()'); ?> <script type="text/javascript" > function wppaPotdChangePeriod() { var url = '<?php echo $action_url; ?> '; url += '&wppa-set-submit=1'; url += '&wppa-update-check='+jQuery('#wppa-update-check').val(); url += '&wppa-widget-period='+jQuery('#wppa-wp').val(); document.location.href = url; } </script> <select name="wppa-widget-period" id="wppa-wp" onchange="<?php echo $onchange; ?> " > <option value="0" <?php if ($period == '0') { echo $sel; } ?> ><?php _e('pageview.', 'wp-photo-album-plus'); ?> </option> <option value="1" <?php if ($period == '1') { echo $sel; } ?> ><?php _e('hour.', 'wp-photo-album-plus'); ?> </option> <option value="24" <?php if ($period == '24') { echo $sel; } ?> ><?php _e('day.', 'wp-photo-album-plus'); ?> </option> <option value="168" <?php if ($period == '168') { echo $sel; } ?> ><?php _e('week.', 'wp-photo-album-plus'); ?> </option> <option value="736" <?php if ($period == '736') { echo $sel; } ?> ><?php _e('month.', 'wp-photo-album-plus'); ?> </option> <option value="day-of-week" <?php if ($period == 'day-of-week') { echo $sel; } ?> ><?php _e('day of week is order#', 'wp-photo-album-plus'); ?> </option> <option value="day-of-month" <?php if ($period == 'day-of-month') { echo $sel; } ?> ><?php _e('day of month is order#', 'wp-photo-album-plus'); ?> </option> <option value="day-of-year" <?php if ($period == 'day-of-year') { echo $sel; } ?> ><?php _e('day of year is order#', 'wp-photo-album-plus'); ?> </option> </select> <span class="description"><br/><?php _e('Select how the widget should display.', 'wp-photo-album-plus'); ?> </span> <div class="wppa-order" > <?php if (substr(wppa_opt('widget_period'), 0, 7) == 'day-of-') { switch (substr(wppa_opt('widget_period'), 7)) { case 'week': $n_days = '7'; $date_key = 'w'; break; case 'month': $n_days = '31'; $date_key = 'd'; break; case 'year': $n_days = '366'; $date_key = 'z'; break; } while (get_option('wppa_potd_offset', '0') > $n_days) { update_option('wppa_potd_offset', get_option('wppa_potd_offset') - $n_days); } echo sprintf(__('Current day# = %s, offset =', 'wp-photo-album-plus'), date_i18n($date_key)) . ' '; echo '<select name="wppa-potd-offset" >'; $day = '0'; while ($day < $n_days) { echo '<option value="' . $day . '" ' . (get_option('wppa_potd_offset', '0') == $day ? 'selected="selected"' : '') . ' >' . $day . '</option>'; $day++; } echo '</select>'; $photo_order = date_i18n($date_key) - get_option('wppa_potd_offset', '0'); while ($photo_order < '1') { $photo_order += $n_days; } echo '. ' . sprintf(__('Todays photo order# = %s.', 'wp-photo-album-plus'), $photo_order); $photo = wppa_get_potd(); if ($photo) { echo ' <img src="' . wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']) . '" style="width:100px;" />'; } else { echo ' ' . __('Not found.', 'wp-photo-album-plus'); } } ?> </div> </td> </tr> <?php $linktype = wppa_opt('widget_linktype'); if ($linktype != 'custom') { ?> <tr> <th scope="row"> <label ><?php _e('Link to:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php _e('Links are set on the <b>Photo Albums -> Settings</b> screen.', 'wp-photo-album-plus'); ?> </td> </tr> <?php } else { ?> <tr class="wppa-wlu" > <th scope="row"> <label ><?php _e('Link to:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php _e('Title:', 'wp-photo-album-plus'); ?> <input type="text" name="wppa-widget-linktitle" id="wppa-widget-linktitle" value="<?php echo wppa_opt('widget_linktitle'); ?> "style="width:20%" /> <?php _e('Url:', 'wp-photo-album-plus'); ?> <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://', 'wp-photo-album-plus'); ?> </span> </td> </tr> <?php } ?> <!--<script type="text/javascript">wppaCheckWidgetLink()</script>--> <tr> <th scope="row"> <label ><?php _e('Subtitle:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $subtit = wppa_opt('widget_subtitle'); ?> <select name="wppa-widget-subtitle" id="wppa-st" > <option value="none" <?php if ($subtit == 'none') { echo $sel; } ?> ><?php _e('--- none ---', 'wp-photo-album-plus'); ?> </option> <option value="name" <?php if ($subtit == 'name') { echo $sel; } ?> ><?php _e('Photo Name', 'wp-photo-album-plus'); ?> </option> <option value="desc" <?php if ($subtit == 'desc') { echo $sel; } ?> ><?php _e('Description', 'wp-photo-album-plus'); ?> </option> <option value="owner" <?php if ($subtit == 'owner') { echo $sel; } ?> ><?php _e('Owner', 'wp-photo-album-plus'); ?> </option> </select> <span class="description"><br/><?php _e('Select the content of the subtitle.', 'wp-photo-album-plus'); ?> </span> </td> </tr> </tbody> </table> <p> <input type="submit" class="button-primary" name="wppa-set-submit" value="<?php _e('Save Changes', 'wp-photo-album-plus'); ?> " /> </p> <?php $alb = wppa_opt('widget_album'); $opt = wppa_is_int($alb) ? ' ' . wppa_get_photo_order($alb) . ' ' : ''; $photos = wppa_get_widgetphotos($alb, $opt); if (empty($photos)) { echo '<p>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</p>'; } else { $curid = wppa_opt('widget_photo'); // Process photos foreach ($photos as $photo) { $id = $photo['id']; // Open container div echo '<div' . ' class="photoselect"' . ' style="' . 'width:180px;' . 'height:300px;' . '" >'; // Open image container div echo '<div' . ' style="' . 'width:180px;' . 'height:135px;' . 'overflow:hidden;' . 'text-align:center;' . '" >'; // The image if a video if (wppa_is_video($id)) { echo wppa_get_video_html(array('id' => $id, 'style' => 'width:180px;')); } else { echo '<img' . ' src=" ' . wppa_fix_poster_ext(wppa_get_thumb_url($id), $id) . '"' . ' style="' . 'max-width:180px;' . 'max-height:135px;' . 'margin:auto;' . '"' . ' alt="' . esc_attr(wppa_get_photo_name($photo['id'])) . '" />'; // Audio ? if (wppa_has_audio($id)) { echo wppa_get_audio_html(array('id' => $id, 'style' => 'width:180px;' . 'position:relative;' . 'bottom:' . (wppa_get_audio_control_height() + 4) . 'px;')); } } // Close image container div echo '</div>'; ?> <div style="clear:both;width:100%;margin:3px 0;" > <div style="font-size:9px; line-height:10px;float:left;"><?php echo '(#' . $photo['p_order'] . ')'; ?> </div> <input style="float:right;" 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> <div style="clear:both;overflow:auto;height:150px" > <div style="font-size:11px; overflow:hidden;"><?php echo wppa_get_photo_name($photo['id']); ?> </div> <div style="font-size:9px; line-height:10px;"><?php echo wppa_get_photo_desc($photo['id']); ?> </div> </div> </div> <?php } echo '<div class="clear"></div>'; } ?> <script type="text/javascript">wppaCheckWidgetMethod();</script> <br /> <p> <input type="submit" class="button-primary" name="wppa-set-submit" value="<?php _e('Save Changes', 'wp-photo-album-plus'); ?> " /> </p> </form> </div> <?php }
function _wppa_sidebar_page_options() { global $wpdb; global $wppa_defaults; wppa_set_defaults(); $onch = 'myReload()'; // Handle spinner js and declare functions echo '<script type="text/javascript" >' . 'var didsome=false;' . 'jQuery(document).ready(function() {' . 'jQuery(\'#wppa-spinner\').css(\'display\', \'none\');' . '});' . 'function myReload() {' . 'jQuery(\'#wppa-spinner\').css(\'display\', \'block\');' . '_wppaRefreshAfter = true;' . '};' . 'function wppaSetFixed(id) {' . 'if (jQuery(\'#wppa-widget-photo-\' + id).attr(\'checked\') == \'checked\' ) {' . '_wppaRefreshAfter = true;' . 'wppaAjaxUpdateOptionValue(\'potd_photo\', id);' . '}' . '};' . '</script>'; // The spinner echo '<img' . ' id="wppa-spinner"' . ' style="position:fixed;top:50%;left:50%;z-index:1000;margin-top:-33px;margin-left:-33px;display:block;"' . ' src="' . wppa_get_imgdir('loader.gif') . '"' . '/>'; // Open wrapper echo '<div class="wrap">'; // The settings icon echo '<img src="' . wppa_get_imgdir('settings32.png') . '" />'; // The Page title echo '<h1 style="display:inline;" >' . __('Photo of the Day (Widget) Settings', 'wp-photo-album-plus') . '</h1>' . __('Changes are updated immediately. The page will reload if required.', 'wp-photo-album-plus') . '<br /> '; // The nonce wp_nonce_field('wppa-nonce', 'wppa-nonce'); // The settings table echo '<table class="widefat wppa-table wppa-setting-table">'; // The header echo '<thead style="font-weight: bold; " class="wppa_table_1">' . '<tr>' . '<td>' . __('#', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Name', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Description', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Setting', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Help', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</thead>'; // Open the table body echo '<tbody class="wppa_table" >'; $name = __('Widget Title:', 'wp-photo-album-plus'); $desc = __('The title of the widget.', 'wp-photo-album-plus'); $help = esc_js(__('Enter/modify the title for the widget. This is a default and can be overriden at widget activation.', 'wp-photo-album-plus')); $slug = 'wppa_potd_title'; $html = wppa_input($slug, '85%'); wppa_setting($slug, '1', $name, $desc, $html, $help); $name = __('Widget Photo Width:', 'wp-photo-album-plus'); $desc = __('Enter the desired display width of the photo in the sidebar.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_widget_width'; $html = wppa_input($slug, '40px', '', __('pixels wide', 'wp-photo-album-plus')); wppa_setting($slug, '2', $name, $desc, $html, $help); $name = __('Horizontal alignment:', 'wp-photo-album-plus'); $desc = __('Enter the desired display alignment of the photo in the sidebar.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_align'; $opts = array(__('--- none ---', 'wp-photo-album-plus'), __('left', 'wp-photo-album-plus'), __('center', 'wp-photo-album-plus'), __('right', 'wp-photo-album-plus')); $vals = array('none', 'left', 'center', 'right'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '3', $name, $desc, $html, $help); $linktype = wppa_opt('potd_linktype'); if ($linktype == 'custom') { $name = __('Link to:', 'wp-photo-album-plus'); $desc = __('Enter the url. Do\'nt forget the HTTP://', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_linkurl'; $html = wppa_input($slug, '85%'); wppa_setting($slug, '4', $name, $desc, $html, $help); $name = __('Link Title:', 'wp-photo-album-plus'); $desc = __('The balloon text when hovering over the photo.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_linktitle'; $html = wppa_input($slug, '85%'); wppa_setting($slug, '4a', $name, $desc, $html, $help); } else { $name = __('Link to:', 'wp-photo-album-plus'); $desc = __('Links are set on the <b>Photo Albums -> Settings</b> screen.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_linkurl'; $html = ''; wppa_setting($slug, '4', $name, $desc, $html, $help); } $name = __('Subtitle:', 'wp-photo-album-plus'); $desc = __('Select the content of the subtitle.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_subtitle'; $opts = array(__('--- none ---', 'wp-photo-album-plus'), __('Photo Name', 'wp-photo-album-plus'), __('Description', 'wp-photo-album-plus'), __('Owner', 'wp-photo-album-plus')); $vals = array('none', 'name', 'desc', 'owner'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '5', $name, $desc, $html, $help); $name = __('Counter:', 'wp-photo-album-plus'); $desc = __('Display a counter of other photos in the album.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_counter'; $html = wppa_checkbox($slug); wppa_setting($slug, '6', $name, $desc, $html, $help); $name = __('Link to:', 'wp-photo-album-plus'); $desc = __('The counter links to.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_counter_link'; $opts = array(__('thumbnails', 'wp-photo-album-plus'), __('slideshow', 'wp-photo-album-plus'), __('single image', 'wp-photo-album-plus')); $vals = array('thumbs', 'slide', 'single'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '7', $name, $desc, $html, $help); $name = __('Type of album(s) to use:', 'wp-photo-album-plus'); $desc = __('Select physical or virtual.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_album_type'; $opts = array(__('physical albums', 'wp-photo-album-plus'), __('virtual albums', 'wp-photo-album-plus')); $vals = array('physical', 'virtual'); $html = wppa_select($slug, $opts, $vals, $onch); wppa_setting($slug, '8', $name, $desc, $html, $help); $name = __('Albums to use:', 'wp-photo-album-plus'); $desc = __('Select the albums to use for the photo of the day.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_album'; if (get_option('wppa_potd_album_type') == 'physical') { $html = '<select' . ' id="wppa_potd_album"' . ' name="wppa_potd_album"' . ' style="float:left; max-width: 100%;"' . ' multiple="multiple"' . ' onchange="didsome=true;wppaAjaxUpdateOptionValue(\'potd_album\', this, true)"' . ' onmouseout="if(didsome)document.location.reload(true);"' . ' size="10"' . ' >' . wppa_album_select_a(array('path' => true, 'optionclass' => 'potd_album', 'selected' => get_option('wppa_potd_album'))) . '</select>' . '<img id="img_potd_album" class="" src="' . wppa_get_imgdir() . 'star.ico" title="' . __('Setting unmodified', 'wp-photo-album-plus') . '" style="padding:0 4px; float:left; height:16px; width:16px;" />'; wppa_setting($slug, '9', $name, $desc, $html, $help); } else { $desc = __('Select the albums to use for the photo of the day.', 'wp-photo-album-plus'); $opts = array(__('- all albums -', 'wp-photo-album-plus'), __('- all -separate- albums -', 'wp-photo-album-plus'), __('- all albums except -separate-', 'wp-photo-album-plus'), __('- top rated photos -', 'wp-photo-album-plus')); $vals = array('all', 'sep', 'all-sep', 'topten'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '9', $name, $desc, $html, $help); } if (get_option('wppa_potd_album_type') == 'physical') { $name = __('Include (grand)children:', 'wp-photo-album-plus'); $desc = __('Include the photos of all sub albums?', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_include_subs'; $html = wppa_checkbox($slug, $onch); wppa_setting($slug, '9a', $name, $desc, $html, $help); $name = __('Inverse selection:', 'wp-photo-album-plus'); $desc = __('Use any album, except the selection made above.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_inverse'; $html = wppa_checkbox($slug, $onch); wppa_setting($slug, '9b', $name, $desc, $html, $help); } $name = __('Status filter:', 'wp-photo-album-plus'); $desc = __('Use only photos with a certain status.', 'wp-photo-album-plus'); $help = esc_js(__('Select - none - if you want no filtering on status.', 'wp-photo-album-plus')); $slug = 'wppa_potd_status_filter'; $opts = array(__('- none -', 'wp-photo-album-plus'), __('Publish', 'wp-photo-album-plus'), __('Featured', 'wp-photo-album-plus'), __('Gold', 'wp-photo-album-plus'), __('Silver', 'wp-photo-album-plus'), __('Bronze', 'wp-photo-album-plus'), __('Any medal', 'wp-photo-album-plus')); $vals = array('none', 'publish', 'featured', 'gold', 'silver', 'bronze', 'anymedal'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '10', $name, $desc, $html, $help); $name = __('Display method:', 'wp-photo-album-plus'); $desc = __('Select the way a photo will be selected.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_method'; $opts = array(__('Fixed photo', 'wp-photo-album-plus'), __('Random', 'wp-photo-album-plus'), __('Last upload', 'wp-photo-album-plus'), __('Change every', 'wp-photo-album-plus')); $vals = array('1', '2', '3', '4'); $html = wppa_select($slug, $opts, $vals, $onch); wppa_setting($slug, '11', $name, $desc, $html, $help); if (get_option('wppa_potd_method') == '4') { // Change every $name = __('Change every period:', 'wp-photo-album-plus'); $desc = __('The time period a certain photo is used.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_period'; $opts = array(__('pageview.', 'wp-photo-album-plus'), __('hour.', 'wp-photo-album-plus'), __('day.', 'wp-photo-album-plus'), __('week.', 'wp-photo-album-plus'), __('month.', 'wp-photo-album-plus'), __('day of week is order#', 'wp-photo-album-plus'), __('day of month is order#', 'wp-photo-album-plus'), __('day of year is order#', 'wp-photo-album-plus')); $vals = array('0', '1', '24', '168', '736', 'day-of-week', 'day-of-month', 'day-of-year'); $html = wppa_select($slug, $opts, $vals, $onch); wppa_setting($slug, '11a', $name, $desc, $html, $help); $wppa_widget_period = get_option('wppa_potd_period'); if (substr($wppa_widget_period, 0, 7) == 'day-of-') { switch (substr($wppa_widget_period, 7)) { case 'week': $n_days = '7'; $date_key = 'w'; break; case 'month': $n_days = '31'; $date_key = 'd'; break; case 'year': $n_days = '366'; $date_key = 'z'; break; } while (get_option('wppa_potd_offset', '0') > $n_days) { update_option('wppa_potd_offset', get_option('wppa_potd_offset') - $n_days); } while (get_option('wppa_potd_offset', '0') < '0') { update_option('wppa_potd_offset', get_option('wppa_potd_offset') + $n_days); } $name = __('Day offset:', 'wp-photo-album-plus'); $desc = __('The difference between daynumber and photo order number.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_offset'; $opts = array(); $day = '0'; while ($day < $n_days) { $opts[] = $day; $day++; } $vals = $opts; $html = '<span style="float:left;" >' . sprintf(__('Current day# = %s, offset =', 'wp-photo-album-plus'), wppa_local_date($date_key)) . '</span> ' . wppa_select($slug, $opts, $vals, $onch); $photo_order = wppa_local_date($date_key) - get_option('wppa_potd_offset', '0'); while ($photo_order < '0') { $photo_order += $n_days; } $html .= sprintf(__('Todays photo order# = %s.', 'wp-photo-album-plus'), $photo_order); wppa_setting($slug, '11b', $name, $desc, $html, $help); } } $name = __('Preview', 'wp-photo-album-plus'); $desc = __('Current "photo of the day":', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_photo'; $photo = wppa_get_potd(); if ($photo) { $html = '<div style="display:inline-block;width:25%;text-align:center;vertical-align:middle;">' . '<img src="' . wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']) . '" />' . '</div>' . '<div style="display:inline-block;width:75%;text-align:center;vertical-align:middle;" >' . __('Album', 'wp-photo-album-plus') . ': ' . wppa_get_album_name($photo['album']) . '<br />' . __('Uploader', 'wp-photo-album-plus') . ': ' . $photo['owner'] . '</div>'; } else { $html = __('Not found.', 'wp-photo-album-plus'); } wppa_setting($slug, '12', $name, $desc, $html, $help); $name = __('Show selection', 'wp-photo-album-plus'); $desc = __('Show the photos in the current selection.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_preview'; $html = wppa_checkbox($slug, $onch); wppa_setting($slug, '13', $name, $desc, $html, $help); // Cose table body echo '</tbody>'; // Table footer echo '<tfoot style="font-weight: bold;" >' . '<tr>' . '<td>' . __('#', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Name', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Description', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Setting', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Help', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</tfoot>' . '</table>'; // Diagnostic // echo // 'Diagnostic: wppa_potd_album = ' . get_option( 'wppa_potd_album' ) . ' wppa_potd_photo = ' . get_option( 'wppa_potd_photo' ); // Status star must be here for js echo '<img' . ' id="img_potd_photo"' . ' src="' . wppa_get_imgdir('star.ico') . '" style="height:12px;display:none;"' . ' />'; // The potd photo pool echo '<table class="widefat wppa-table wppa-setting-table" >'; // Table header echo '<thead>' . '<tr>' . '<td>' . __('Photos in the current selection', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</thead>'; // Table body if (wppa_switch('potd_preview')) { echo '<tbody>' . '<tr>' . '<td>'; // Get the photos $alb = wppa_opt('potd_album'); $opt = wppa_is_int($alb) ? ' ' . wppa_get_photo_order($alb) . ' ' : ''; $photos = wppa_get_widgetphotos($alb, $opt); // Count them $cnt = count($photos); // Find current $curid = wppa_opt('potd_photo'); // See if we do this if (empty($photos)) { _e('No photos in the selection', 'wp-photo-album-plus'); } elseif ($cnt > '5000') { echo sprintf(__('There are too many photos in the selection to show a preview ( %d )', 'wp-photo-album-plus'), $cnt); } else { // Yes, display the pool foreach ($photos as $photo) { $id = $photo['id']; // Open container div echo '<div' . ' class="photoselect"' . ' style="' . 'width:180px;' . 'height:300px;' . '" >'; // Open image container div echo '<div' . ' style="' . 'width:180px;' . 'height:135px;' . 'overflow:hidden;' . 'text-align:center;' . '" >'; // The image if a video if (wppa_is_video($id)) { echo wppa_get_video_html(array('id' => $id, 'style' => 'width:180px;')); } else { echo '<img' . ' src=" ' . wppa_fix_poster_ext(wppa_get_thumb_url($id), $id) . '"' . ' style="' . 'max-width:180px;' . 'max-height:135px;' . 'margin:auto;' . '"' . ' alt="' . esc_attr(wppa_get_photo_name($id)) . '" />'; // Audio ? if (wppa_has_audio($id)) { echo wppa_get_audio_html(array('id' => $id, 'style' => 'width:180px;' . 'position:relative;' . 'bottom:' . (wppa_get_audio_control_height() + 4) . 'px;')); } } // Close image container div echo '</div>'; // The order# and select radio box echo '<div style="clear:both;width:100%;margin:3px 0;position:relative;top:5px;" >' . '<div style="font-size:9px; line-height:10px;float:left;">(#' . $photo['p_order'] . ')</div>'; if (get_option('wppa_potd_method') == '1') { // Only if fixed photo echo '<input' . ' style="float:right;"' . ' type="radio"' . ' name="wppa-widget-photo"' . ' id="wppa-widget-photo-' . $id . '"' . ' value="' . $id . '"' . ($id == $curid ? 'checked="checked"' : '') . ' onchange="wppaSetFixed(' . $id . ');"' . ' />'; } echo '</div>'; // The name/desc boxecho echo '<div style="clear:both;overflow:hidden;height:150px;position:relative;top:10px;" >' . '<div style="font-size:11px; overflow:hidden;">' . wppa_get_photo_name($id) . '</div>' . '<div style="font-size:9px; line-height:10px;">' . wppa_get_photo_desc($id) . '</div>' . '</div>'; // Close container echo '</div>'; } echo '<div class="clear"></div>'; } // Close the table echo '</td>' . '</tr>' . '</tbody>'; } echo '</table>'; // Close wrap echo '</div>'; }