function wppa_albums($id = '', $type = '', $size = '', $align = '') { global $wppa_lang; global $wppa_locale; global $wpdb; global $thumbs; global $wppa_session; // Diagnostics wppa_dbg_msg('Entering wppa_albums'); wppa_dbg_msg('Lang=' . $wppa_lang . ', Locale=' . $wppa_locale . ', Ajax=' . wppa('ajax')); wppa_dbg_msg('$wppa_session = ' . serialize($wppa_session)); // List content filters // Data struct: $wp_filter[$tag][$priority][$idx] = array( 'function' => $function_to_add, 'accepted_args' => $accepted_args ); if (wppa('debug') && wppa('mocc') == '0') { global $wp_filter; wppa_dbg_msg('Start content filters', 'green'); foreach (array_keys($wp_filter['the_content']) as $key) { foreach (array_keys($wp_filter['the_content'][$key]) as $key2) { $func = is_array($wp_filter['the_content'][$key][$key2]['function']) ? serialize($wp_filter['the_content'][$key][$key2]['function']) : $wp_filter['the_content'][$key][$key2]['function']; wppa_dbg_msg('Pri:' . $key . ', func: ' . $func . ', args: ' . $wp_filter['the_content'][$key][$key2]['accepted_args']); } } wppa_dbg_msg('End content filters', 'green'); } // Process a user upload request, if any. Do it here: it may affect this occurences display wppa_user_upload(); // Test for scheduled publications wppa_publish_scheduled(); // First calculate the occurance if (wppa('ajax')) { if (wppa_get_get('moccur')) { wppa('mocc', wppa_get_get('moccur')); if (!is_numeric(wppa('mocc'))) { wp_die('Security check failure 1'); } } else { wppa('mocc', '1'); } wppa('fullsize', wppa_get_get('wppa-size', wppa_get_container_width())); if (wppa_get_get('occur')) { wppa('occur', wppa_get_get('occur')); if (!is_numeric(wppa('occur'))) { wp_die('Security check failure 2'); } } if (wppa_get_get('woccur')) { wppa('widget_occur', wppa_get_get('woccur')); wppa('in_widget', true); if (!is_numeric(wppa('widget_occur'))) { wp_die('Security check failure 3'); } } } else { wppa('mocc', wppa('mocc') + '1'); if (wppa_in_widget()) { wppa('widget_occur', wppa('widget_occur') + '1'); } else { wppa('occur', wppa('occur') + '1'); } } // Set wppa( 'src' ) = true and wppa( 'searchstring' ) if this occurrance processes a search request. wppa_test_for_search(); // There are 3 ways to get here: // in order of priority: // 1. The given query string applies to this invocation ( occurrance ) // This invocation requires the ignorance of the filter results and the interpretation of the querystring. if ((wppa_get_get('occur') || wppa_get_get('woccur')) && (wppa_in_widget() && wppa('widget_occur') == wppa_get_get('woccur') || !wppa_in_widget() && wppa('occur') == wppa_get_get('occur')) && !wppa('is_autopage')) { // Process query string wppa_out(wppa_dbg_msg('Querystring applied', 'brown', false, true)); wppa('start_album', wppa_get_get('album')); wppa('is_cover', wppa_get_get('cover')); wppa('is_slide', wppa_get_get('slide') || wppa_get_get('album') !== false && wppa_get_get('photo')); if (wppa('is_slide')) { wppa('start_photo', wppa_get_get('photo')); // Start a slideshow here } else { wppa('single_photo', wppa_get_get('photo')); // Photo is the single photoid } wppa('is_single', wppa_get_get('single')); // Is a one image slideshow wppa('topten_count', wppa_force_numeric_else(wppa_get_get('topten'), wppa_opt('topten_count'))); wppa('is_topten', wppa('topten_count') != '0'); wppa('lasten_count', wppa_force_numeric_else(wppa_get_get('lasten'), wppa_opt('lasten_count'))); wppa('is_lasten', wppa('lasten_count') != '0'); wppa('comten_count', wppa_force_numeric_else(wppa_get_get('comten'), wppa_opt('comten_count'))); wppa('is_comten', wppa('comten_count') != '0'); wppa('featen_count', wppa_force_numeric_else(wppa_get_get('featen'), wppa_opt('featen_count'))); wppa('is_featen', wppa('featen_count') != '0'); wppa('albums_only', wppa_get_get('albums-only')); wppa('photos_only', wppa_get_get('photos-only')); wppa('related_count', wppa_force_numeric_else(wppa_get_get('relcount'), wppa_opt('related_count'))); wppa('is_related', wppa_get_get('rel')); if (wppa('is_related') == 'tags') { wppa('is_tag', wppa_get_related_data()); if (wppa('related_count') == '0') { wppa('related_count', wppa_opt('related_count')); } } else { wppa('is_tag', trim(strip_tags(wppa_get_get('tag')), ',;')); } if (wppa('is_related') == 'desc') { wppa('src', true); if (wppa('related_count') == '0') { wppa('related_count', wppa_opt('related_count')); } wppa('searchstring', str_replace(';', ',', wppa_get_related_data())); wppa('photos_only', true); } if (wppa('is_tag')) { wppa_dbg_msg('Is Tag: ' . wppa('is_tag')); } else { wppa_dbg_msg('Is NOT Tag'); } wppa('page', wppa_get_get('page')); if (wppa_get_get('superview')) { $wppa_session['superview'] = wppa('is_slide') ? 'slide' : 'thumbs'; $wppa_session['superalbum'] = wppa('start_album'); wppa_save_session(); wppa('photos_only', true); } wppa('is_upldr', wppa_get_get('upldr')); if (wppa('is_upldr')) { wppa('photos_only', true); } wppa('is_owner', wppa_get_get('owner')); if (wppa('is_owner')) { $albs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `owner` = %s ", wppa('is_owner')), ARRAY_A); wppa_dbg_q('Q-Main-1'); wppa_cache_album('add', $albs); $id = ''; if ($albs) { foreach ($albs as $alb) { $id .= $alb['id'] . '.'; } } $id = rtrim($id, '.'); wppa('start_album', $id); } wppa('supersearch', strip_tags(wppa_get_get('supersearch'))); $wppa_session['supersearch'] = wppa('supersearch'); wppa_save_session(); if (wppa('supersearch')) { $ss_info = explode(',', wppa('supersearch')); if ($ss_info['0'] == 'a') { wppa('albums_only', true); } else { wppa('photos_only', true); } } wppa('calendar', strip_tags(wppa_get_get('calendar'))); wppa('caldate', strip_tags(wppa_get_get('caldate'))); wppa('is_inverse', wppa_get_get('inv')); } elseif ($id != '' || $type != '' || $size != '' || $align != '') { // Do NOT Set internal defaults here, they may be set before the call // Interprete function args if ($type == 'album') { } elseif ($type == 'cover') { wppa('is_cover', true); } elseif ($type == 'slide') { wppa('is_slide', true); } elseif ($type == 'slideonly') { wppa('is_slideonly', true); } if ($type == 'photo' || $type == 'mphoto' || $type == 'slphoto') { // Any type of single photo? id given is photo id if ($id) { wppa('single_photo', $id); } } else { // Not single photo: id given is album id if ($id) { wppa('start_album', $id); } } } else { if (wppa('bestof')) { $args = wppa('bestof_args'); wppa_bestof_box($args); $out = wppa('out'); wppa_reset_occurrance(); return $out; } elseif (wppa('is_landing') && !wppa('src')) { wppa_dbg_msg('Nothing to do...'); wppa_reset_occurrance(); return ''; // Do nothing on a landing page without a querystring while it is also not a search operation } elseif (wppa('is_autopage')) { $photo = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . WPPA_PHOTOS . "` WHERE `page_id` = %d LIMIT 1", get_the_ID())); wppa('single_photo', $photo); wppa_dbg_q('Q-main-2'); if (!wppa('single_photo')) { wppa_dbg_msg('No photo found for page ' . get_the_ID(), 'red', 'force'); wppa_reset_occurrance(); return ''; // Give up } $type = wppa_opt('auto_page_type'); switch ($type) { case 'photo': break; case 'mphoto': wppa('is_mphoto', true); break; case 'slphoto': wppa('is_slide', true); wppa('start_photo', wppa('single_photo')); wppa('is_single', true); break; default: wppa_dbg_msg('Unimplemented type autopage display: ' . $type, 'red', 'force'); } } } // Convert any keywords and / or names to numbers // Search for album keyword if (wppa('start_album') && !wppa_is_int(wppa('start_album'))) { if (substr(wppa('start_album'), 0, 1) == '#') { // Keyword $keyword = wppa('start_album'); if (strpos($keyword, ',')) { $keyword = substr($keyword, 0, strpos($keyword, ',')); } switch ($keyword) { // ( substr( wppa( 'start_album'], 0, 5 ) ) { case '#last': // Last upload $id = wppa_get_youngest_album_id(); if (wppa('is_cover')) { // To make sure the ordering sequence is ok. $temp = explode(',', wppa('start_album')); if (isset($temp['1'])) { wppa('last_albums_parent', $temp['1']); } else { wppa('last_albums_parent', '0'); } if (isset($temp['2'])) { wppa('last_albums', $temp['2']); } else { wppa('last_albums', false); } } else { // Ordering seq is not important, convert to album enum $temp = explode(',', wppa('start_album')); if (isset($temp['1'])) { $parent = wppa_album_name_to_number($temp['1']); } else { $parent = '0'; } if ($parent === false) { return; } if (isset($temp['2'])) { $limit = $temp['2']; } else { $limit = false; } if ($limit) { if ($parent) { if ($limit) { $q = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", $parent, $limit); } else { $q = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s ORDER BY `timestamp` DESC", $parent); } } else { if ($limit) { $q = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC LIMIT %d", $limit); } else { $q = "SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC"; } } $albs = $wpdb->get_results($q, ARRAY_A); wppa_dbg_q('Q-main-3'); wppa_cache_album('add', $albs); if (is_array($albs)) { foreach (array_keys($albs) as $key) { $albs[$key] = $albs[$key]['id']; } } $id = implode('.', $albs); } } break; case '#topten': $temp = explode(',', wppa('start_album')); $id = isset($temp[1]) ? $temp[1] : '0'; wppa('topten_count', isset($temp[2]) ? $temp[2] : wppa_opt('topten_count')); wppa('is_topten', true); if (wppa('is_cover')) { wppa_dbg_msg('A topten album has no cover. ' . wppa('start_album'), 'red', 'force'); wppa_reset_occurrance(); return; // Give up this occurence } break; case '#lasten': $temp = explode(',', wppa('start_album')); $id = isset($temp[1]) ? $temp[1] : '0'; wppa('lasten_count', isset($temp[2]) ? $temp[2] : wppa_opt('lasten_count')); wppa('is_lasten', true); if (wppa('is_cover')) { wppa_dbg_msg('A lasten album has no cover. ' . wppa('start_album'), 'red', 'force'); wppa_reset_occurrance(); return; // Give up this occurence } break; case '#comten': $temp = explode(',', wppa('start_album')); $id = isset($temp[1]) ? $temp[1] : '0'; wppa('comten_count', isset($temp[2]) ? $temp[2] : wppa_opt('comten_count')); wppa('is_comten', true); if (wppa('is_cover')) { wppa_dbg_msg('A comten album has no cover. ' . wppa('start_album'), 'red', 'force'); wppa_reset_occurrance(); return; // Give up this occurence } break; case '#featen': $temp = explode(',', wppa('start_album')); $id = isset($temp[1]) ? $temp[1] : '0'; wppa('featen_count', isset($temp[2]) ? $temp[2] : wppa_opt('featen_count')); wppa('is_featen', true); if (wppa('is_cover')) { wppa_dbg_msg('A featen album has no cover. ' . wppa('start_album'), 'red', 'force'); wppa_reset_occurrance(); return; // Give up this occurence } break; case '#related': $temp = explode(',', wppa('start_album')); $type = isset($temp[1]) ? $temp[1] : 'tags'; // tags is default type wppa('related_count', isset($temp[2]) ? $temp[2] : wppa_opt('related_count')); wppa('is_related', $type); $data = wppa_get_related_data(); if ($type == 'tags') { wppa('is_tag', $data); } if ($type == 'desc') { wppa('src', true); wppa('searchstring', str_replace(';', ',', $data)); wppa('photos_only', true); } wppa('photos_only', true); $id = '0'; break; case '#tags': wppa('is_tag', wppa_sanitize_tags(substr(wppa('start_album'), 6), true)); $id = '0'; wppa('photos_only', true); break; case '#cat': $temp = explode(',', wppa('start_album')); $cat = isset($temp[1]) ? $temp[1] : ''; $cat = trim(wppa_sanitize_tags($cat), ','); wppa('is_cat', $cat); if (!$cat) { wppa_dbg_msg('Missing cat #cat album spec: ' . wppa('start_album'), 'red', 'force'); wppa_reset_occurrance(); return; // Forget this occurrance } $albs = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "`", ARRAY_A); wppa_dbg_q('Q-main-4'); wppa_cache_album('add', $albs); $id = ''; if ($albs) { foreach ($albs as $alb) { $temp = explode(',', $alb['cats']); if (in_array($cat, $temp)) { $id .= $alb['id'] . '.'; } } } $id = rtrim($id, '.'); break; case '#owner': $temp = explode(',', wppa('start_album')); $owner = isset($temp[1]) ? $temp[1] : ''; if ($owner == '#me') { if (is_user_logged_in()) { $owner = wppa_get_user(); } else { // User not logged in, ignore shortcode wppa_reset_occurrance(); return; // Forget this occurrance } } if (!$owner) { wppa_dbg_msg('Missing owner in #owner album spec: ' . wppa('start_album'), 'red', 'force'); wppa_reset_occurrance(); return; // Forget this occurrance } $parent = isset($temp[2]) ? wppa_album_name_to_number($temp[2]) : '0'; if ($parent === false) { return; } if (!$parent) { $parent = '-1.0'; } if ($parent) { // Valid parent spec $parent_arr = explode('.', wppa_expand_enum($parent)); $id = wppa_alb_to_enum_children($parent); // Verify all albums are owned by $owner and are directly under a parent album $id = wppa_expand_enum($id); $albs = explode('.', $id); if ($albs) { foreach (array_keys($albs) as $idx) { if (wppa_get_album_item($albs[$idx], 'owner') != $owner || !in_array(wppa_get_album_item($albs[$idx], 'a_parent'), $parent_arr)) { unset($albs[$idx]); } } } $id = implode('.', $albs); if (!$id) { $id = '-9'; // Force nothing found // wppa_reset_occurrance(); // return; // No children found } } wppa('is_owner', $owner); break; case '#upldr': $temp = explode(',', wppa('start_album')); $owner = isset($temp[1]) ? $temp[1] : ''; if ($owner == '#me') { if (is_user_logged_in()) { $owner = wppa_get_user(); } else { // User not logged in, ignore shortcode wppa_reset_occurrance(); return; // Forget this occurrance } } if (!$owner) { wppa_dbg_msg('Missing owner in #upldr album spec: ' . wppa('start_album'), 'red', 'force'); wppa_reset_occurrance(); return; // Forget this occurrance } $parent = isset($temp[2]) ? wppa_album_name_to_number($temp[2]) : '0'; if ($parent === false) { return; } // parent specified but not a valid value if ($parent) { // Valid parent spec $id = wppa_alb_to_enum_children(wppa_expand_enum($parent)); if (!$id) { wppa_reset_occurrance(); return; // No children found } } else { // No parent spec $id = '0'; } wppa('is_upldr', $owner); wppa('photos_only', true); break; case '#all': $id = '-2'; break; default: wppa_dbg_msg('Unrecognized album keyword found: ' . wppa('start_album'), 'red', 'force'); wppa_reset_occurrance(); return; // Forget this occurrance } wppa('start_album', $id); } } // See if the album id is a name and convert it if possible wppa('start_album', wppa_album_name_to_number(wppa('start_album'))); if (wppa('start_album') === false) { wppa_reset_occurrance(); return; } // Also for parents wppa('last_albums_parent', wppa_album_name_to_number(wppa('last_albums_parent'))); if (wppa('last_albums_parent') === false) { wppa_reset_occurrance(); return; } // Check if album is valid if (strpos(wppa('start_album'), '.') !== false) { // Album may be enum if (!wppa_series_to_array(wppa('start_album'))) { // Syntax error wppa_reset_occurrance(); return; } } elseif (wppa('start_album') && !is_numeric(wppa('start_album'))) { wppa_stx_err('Unrecognized Album identification found: ' . wppa('start_album')); wppa_reset_occurrance(); return; // Forget this occurrance } elseif (wppa('start_album') > '0') { // -2 is #all if (!wppa_album_exists(wppa('start_album'))) { wppa_stx_err('Album does not exist: ' . wppa('start_album')); wppa_reset_occurrance(); return; // Forget this occurrance } } // See if the photo id is a keyword and convert it if possible if (wppa('single_photo') && !is_numeric(wppa('single_photo'))) { if (substr(wppa('single_photo'), 0, 1) == '#') { // Keyword switch (wppa('single_photo')) { case '#potd': // Photo of the day $t = wppa_get_potd(); if (is_array($t)) { $id = $t['id']; } else { $id = '0'; } break; case '#last': // Last upload $id = wppa_get_youngest_photo_id(); break; default: wppa_dbg_msg('Unrecognized photo keyword found: ' . wppa('single_photo'), 'red', 'force'); wppa_reset_occurrance(); return; // Forget this occurrance } wppa('single_photo', $id); } } // See if the photo id is a name and convert it if possible if (wppa('single_photo') && !is_numeric(wppa('single_photo'))) { if (substr(wppa('single_photo'), 0, 1) == '$') { // Name $id = wppa_get_photo_id_by_name(substr(wppa('single_photo'), 1)); if ($id > '0') { wppa('single_photo', $id); } else { wppa_dbg_msg('Photo name not found: ' . wppa('single_photo'), 'red', 'force'); wppa_reset_occurrance(); return; // Forget this occurrance } } } // Size and align if (is_numeric($size)) { wppa('fullsize', $size); } elseif ($size == 'auto') { wppa('auto_colwidth', true); } if ($align == 'left' || $align == 'center' || $align == 'right') { wppa('align', $align); } // Empty related shortcode? if (wppa('is_related')) { $thumbs = wppa_get_thumbs(); if (empty($thumbs)) { wppa_errorbox(__('No related photos found.', 'wp-photo-album-plus')); $result = wppa('out'); wppa_reset_occurrance(); // Forget this occurrance return $result; } } // Subsearch or rootsearch? if (wppa('occur') == '1' && $wppa_session['has_searchbox'] && !wppa('in_widget')) { // Is it a search now? if (wppa('src')) { // Is the subsearch box checked? wppa('is_subsearch', wppa_get_get('subsearch') || wppa_get_post('subsearch')); // Is the rootsearch box checked? wppa('is_rootsearch', wppa_get_get('rootsearch') || wppa_get_post('rootsearch')); // No rootsearch, forget previous root if (!wppa('is_rootsearch')) { $wppa_session['search_root'] = '0'; wppa_save_session(); } } else { // Find new potential searchroot if (isset($_REQUEST['wppa-searchroot'])) { wppa('start_album', strval(intval($_REQUEST['wppa-searchroot']))); } // Update session with new searchroot $wppa_session['search_root'] = wppa('start_album'); wppa_save_session(); } // Update searchroot in search boxes $rt = $wppa_session['search_root']; if (!$rt) { $rt = '0'; } // must be non-empty string wppa_add('src_script', 'jQuery(document).ready(function(){wppaUpdateSearchRoot( \'' . esc_js(wppa_display_root($rt)) . '\', ' . $rt . ' )});'); // If not search forget previous results if (!wppa('src')) { $wppa_session['use_searchstring'] = ''; $wppa_session['display_searchstring'] = ''; wppa_save_session(); wppa_add('src_script', "\n" . 'jQuery(document).ready(function(){wppaClearSubsearch()});'); } else { // Enable subbox wppa_add('src_script', 'jQuery(document).ready(function(){wppaEnableSubsearch()});'); } } // Is it url? if (wppa('is_url')) { if (wppa_photo_exists(wppa('single_photo'))) { wppa_out(wppa_get_hires_url(wppa('single_photo'))); } else { wppa_dbg_msg(sprintf('Photo %s not found', wppa('single_photo')), 'red', 'force'); } } elseif (wppa('is_stereobox')) { wppa_stereo_box(); } elseif (wppa('is_searchbox')) { wppa_search_box('', wppa('may_sub'), wppa('may_root')); } elseif (wppa('is_superviewbox')) { wppa_superview_box(wppa('start_album')); } elseif (wppa('is_multitagbox')) { wppa_multitag_box(wppa('tagcols'), wppa('taglist')); } elseif (wppa('is_tagcloudbox')) { wppa_tagcloud_box(wppa('taglist'), wppa_opt('tagcloud_min'), wppa_opt('tagcloud_max')); } elseif (wppa('is_upload')) { wppa_upload_box(); } elseif (wppa('is_supersearch')) { wppa_supersearch_box(); } elseif (wppa('is_mphoto') == '1') { if (wppa('is_autopage')) { wppa_auto_page_links('top'); } wppa_mphoto(); if (wppa('is_autopage')) { wppa_auto_page_links('bottom'); } } elseif (wppa_page('oneofone')) { if (wppa('is_autopage')) { wppa_auto_page_links('top'); } wppa_sphoto(); if (wppa('is_autopage')) { wppa_auto_page_links('bottom'); } } elseif (wppa('is_calendar')) { wppa_calendar_box(); } else { if (function_exists('wppa_theme')) { if (wppa('is_autopage')) { wppa_auto_page_links('top'); } wppa_theme(); // Call the theme module if (wppa('is_autopage')) { wppa_auto_page_links('bottom'); } } else { wppa_out('<span style="color:red">ERROR: Missing function wppa_theme(), check the installation of WPPA+. Remove customized wppa_theme.php</span>'); } global $wppa_version; $expected_version = '6-3-14-000'; if ($wppa_version != $expected_version) { wppa_dbg_msg('WARNING: customized wppa-theme.php is out of rev. Expected version: ' . $expected_version . ' found: ' . $wppa_version, 'red'); } } // Done $out = str_replace('w#location', wppa('geo'), wppa('out')); // Reset wppa_reset_occurrance(); return $out; }
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 }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; global $wppa; $wppa['in_widget'] = 'potd'; $wppa['mocc']++; 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); $widget_title = apply_filters('widget_title', $instance['title']); // get the photo ($image) $image = wppa_get_potd(); // Make the HTML for current picture $widget_content = "\n" . '<!-- WPPA+ Photo of the day Widget start -->'; $ali = wppa_opt('wppa_potd_align'); if ($ali != 'none') { $align = 'text-align:' . $ali . ';'; } else { $align = ''; } $widget_content .= "\n" . '<div class="wppa-widget-photo" style="' . $align . ' padding-top:2px; ">'; if ($image) { $id = $image['id']; $w = wppa_opt('wppa_potd_widget_width'); $ratio = wppa_get_photoy($id) / wppa_get_photox($id); $h = round($w * $ratio); $usethumb = wppa_use_thumb_file($id, wppa_opt('wppa_widget_width'), '0'); $imgurl = wppa_fix_poster_ext($usethumb ? wppa_get_thumb_url($id, '', $w, $h) : wppa_get_photo_url($id, '', $w, $h), $id); $name = wppa_get_photo_name($id); $page = in_array(wppa_opt('wppa_widget_linktype'), $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_widget_linkpage', __a('Photo of the day')); $link = wppa_get_imglnk_a('potdwidget', $id); $is_video = wppa_is_video($id); $has_audio = wppa_has_audio($id); if ($link['is_lightbox']) { $lightbox = ($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') . '"'; } else { $lightbox = ''; } if ($link) { if ($link['is_lightbox']) { $cursor = ' cursor:url(' . wppa_get_imgdir() . wppa_opt('wppa_magnifier') . '),pointer;'; $title = wppa_zoom_in($id); $ltitle = wppa_get_lbtitle('potd', $id); } else { $cursor = ' cursor:pointer;'; $title = $link['title']; $ltitle = $title; } } else { $cursor = ' cursor:default;'; $title = esc_attr(stripslashes(__($image['name']))); } // The medal if on top $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top')); // The link, if any if ($link) { $widget_content .= "\n\t" . '<a href = "' . $link['url'] . '" target="' . $link['target'] . '" ' . $lightbox . ' ' . wppa('lbtitle') . '="' . $ltitle . '">'; } // The image if (wppa_is_video($id)) { $widget_content .= "\n\t\t" . wppa_get_video_html(array('id' => $id, 'width' => wppa_opt('wppa_potd_widget_width'), 'title' => $title, 'controls' => wppa_opt('widget_linktype') == 'none', 'cursor' => $cursor)); } else { $widget_content .= '<img' . ' src="' . $imgurl . '"' . ' style="width: ' . wppa_opt('wppa_potd_widget_width') . 'px;' . $cursor . '"' . ' ' . wppa_get_imgalt($id) . ($title ? 'title="' . $title . '"' : '') . '/ >'; } // Close the link if ($link) { $widget_content .= "\n\t" . '</a>'; } // The medal if at the bottom $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot')); // Audio if (wppa_has_audio($id)) { $widget_content .= wppa_get_audio_html(array('id' => $id, 'width' => wppa_opt('wppa_potd_widget_width'), 'controls' => true)); } } else { // No image $widget_content .= __a('Photo not found.', 'wppa_theme'); } $widget_content .= "\n" . '</div>'; // Add subtitle, if any switch (wppa_opt('wppa_widget_subtitle')) { case 'none': break; case 'name': if ($image && $image['name'] != '') { $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_name($id) . '</div>'; } break; case 'desc': if ($image && $image['description'] != '') { $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_desc($id) . '</div>'; } break; case 'owner': if ($image) { $owner = $image['owner']; $user = get_user_by('login', $owner); $owner = $user->display_name; $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . __a('By:') . ' ' . $owner . '</div>'; } } $widget_content .= "\n" . '<!-- WPPA+ Photo of the day Widget end -->'; echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; $wppa['in_widget'] = false; }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; wppa('in_widget', 'potd'); wppa_bump_mocc(); 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); $widget_title = apply_filters('widget_title', $instance['title']); // get the photo ($image) $image = wppa_get_potd(); // Make the HTML for current picture $widget_content = "\n" . '<!-- WPPA+ Photo of the day Widget start -->'; $ali = wppa_opt('potd_align'); if ($ali != 'none') { $align = 'text-align:' . $ali . ';'; } else { $align = ''; } $widget_content .= "\n" . '<div class="wppa-widget-photo" style="' . $align . ' padding-top:2px;position:relative;" >'; if ($image) { $id = $image['id']; $w = wppa_opt('potd_widget_width'); $ratio = wppa_get_photoy($id) / wppa_get_photox($id); $h = round($w * $ratio); $usethumb = wppa_use_thumb_file($id, wppa_opt('potd_widget_width'), '0'); $imgurl = wppa_fix_poster_ext($usethumb ? wppa_get_thumb_url($id, '', $w, $h) : wppa_get_photo_url($id, '', $w, $h), $id); $name = wppa_get_photo_name($id); $page = in_array(wppa_opt('potd_linktype'), wppa('links_no_page')) && !wppa_switch('potd_counter') ? '' : wppa_get_the_landing_page('potd_linkpage', __('Photo of the day', 'wp-photo-album-plus')); $link = wppa_get_imglnk_a('potdwidget', $id); $is_video = wppa_is_video($id); $has_audio = wppa_has_audio($id); if ($link['is_lightbox']) { $lightbox = ($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') . '"' . ' data-alt="' . esc_attr(wppa_get_imgalt($id, true)) . '"'; } else { $lightbox = ''; } if ($link) { if ($link['is_lightbox']) { $cursor = ' cursor:url(' . wppa_get_imgdir() . wppa_opt('magnifier') . '),pointer;'; $title = wppa_zoom_in($id); $ltitle = wppa_get_lbtitle('potd', $id); } else { $cursor = ' cursor:pointer;'; $title = $link['title']; $ltitle = $title; } } else { $cursor = ' cursor:default;'; $title = esc_attr(stripslashes(__($image['name'], 'wp-photo-album-plus'))); } // The medal if on top $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top')); // The link, if any if ($link) { $widget_content .= "\n\t" . '<a href = "' . $link['url'] . '" target="' . $link['target'] . '" ' . $lightbox . ' ' . wppa('lbtitle') . '="' . $ltitle . '">'; } // The image if (wppa_is_video($id)) { $widget_content .= "\n\t\t" . wppa_get_video_html(array('id' => $id, 'width' => wppa_opt('potd_widget_width'), 'title' => $title, 'controls' => wppa_opt('potd_linktype') == 'none', 'cursor' => $cursor)); } else { $widget_content .= '<img' . ' src="' . $imgurl . '"' . ' style="width: ' . wppa_opt('potd_widget_width') . 'px;' . $cursor . '"' . ' ' . wppa_get_imgalt($id) . ($title ? 'title="' . $title . '"' : '') . ' />'; } // Close the link if ($link) { $widget_content .= '</a>'; } // The medal if at the bottom $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot')); // The counter if (wppa_switch('potd_counter')) { // If we want this $alb = wppa_get_photo_item($id, 'album'); $c = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = " . $alb) - 1; if ($c > 0) { if (wppa_opt('potd_counter_link') == 'thumbs') { $lnk = wppa_get_album_url($alb, $page, 'thumbs', '1'); } elseif (wppa_opt('potd_counter_link') == 'slide') { $lnk = wppa_get_slideshow_url($alb, $page, $id, '1'); } elseif (wppa_opt('potd_counter_link') == 'single') { $lnk = wppa_encrypt_url(get_permalink($page) . '?occur=1&photo=' . $id); // wppa_get_image_page_url_by_id( $id, true, false, $page ); } else { wppa_log('Err', 'Unimplemented counter link type in wppa-potd-widget: ' . wppa_opt('potd_counter_link')); } $widget_content .= '<a href="' . $lnk . '" >' . '<div style="font-size:12px;position:absolute;right:4px;bottom:4px;" >+' . $c . '</div>' . '</a>'; } } // Audio if (wppa_has_audio($id)) { $widget_content .= wppa_get_audio_html(array('id' => $id, 'width' => wppa_opt('potd_widget_width'), 'controls' => true)); } } else { // No image $widget_content .= __('Photo not found', 'wp-photo-album-plus'); } $widget_content .= "\n" . '</div>'; // Add subtitle, if any if ($image) { switch (wppa_opt('potd_subtitle')) { case 'none': break; case 'name': $widget_content .= '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_name($id) . '</div>'; break; case 'desc': $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_desc($id) . '</div>'; break; case 'owner': $owner = $image['owner']; $user = get_user_by('login', $owner); $owner = $user->display_name; $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . __('By:', 'wp-photo-album-plus') . ' ' . $owner . '</div>'; break; default: wppa_log('Err', 'Unimplemented potd_subtitle found in wppa-potd-widget: ' . wppa_opt('potd_subtitle')); } } $widget_content .= '<div style="clear:both;" ></div>'; $widget_content .= "\n" . '<!-- WPPA+ Photo of the day 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_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>'; }