function wppa_get_imagey($id, $key = 'photo') { if (wppa_is_video($id)) { $result = wppa_get_videoy($id); } elseif ($key == 'thumb') { $result = wppa_get_thumby($id); } else { $result = wppa_get_photoy($id); } return $result; }
function wppa_get_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '') { global $wpdb; // make sure the photo data ia available $thumb = wppa_cache_thumb($id); if (!$thumb) { return false; } // Is it a video? $is_video = wppa_is_video($id, true); // Photo Specific Overrule? if ($wich == 'sphoto' && wppa_switch('sphoto_overrule') || $wich == 'mphoto' && wppa_switch('mphoto_overrule') || $wich == 'thumb' && wppa_switch('thumb_overrule') || $wich == 'topten' && wppa_switch('topten_overrule') || $wich == 'featen' && wppa_switch('featen_overrule') || $wich == 'lasten' && wppa_switch('lasten_overrule') || $wich == 'sswidget' && wppa_switch('sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('coverimg_overrule') || $wich == 'comten' && wppa_switch('comment_overrule') || $wich == 'slideshow' && wppa_switch('slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('thumbnail_widget_overrule')) { // Look for a photo specific link if ($thumb) { // If it is there... if ($thumb['linkurl']) { // Use it. It superceeds other settings $result['url'] = esc_attr($thumb['linkurl']); $result['title'] = esc_attr(__(stripslashes($thumb['linktitle']))); $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = ''; $result['target'] = $thumb['linktarget']; return $result; } } } $result['target'] = '_self'; $result['title'] = ''; $result['onclick'] = ''; switch ($wich) { case 'sphoto': $type = wppa_opt('sphoto_linktype'); $page = wppa_opt('sphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sphoto_blank')) { $result['target'] = '_blank'; } break; case 'mphoto': $type = wppa_opt('mphoto_linktype'); $page = wppa_opt('mphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('mphoto_blank')) { $result['target'] = '_blank'; } break; case 'thumb': $type = wppa_opt('thumb_linktype'); $page = wppa_opt('thumb_linkpage'); if (wppa_switch('thumb_blank')) { $result['target'] = '_blank'; } break; case 'topten': $type = wppa_opt('topten_widget_linktype'); $page = wppa_opt('topten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('topten_blank')) { $result['target'] = '_blank'; } break; case 'featen': $type = wppa_opt('featen_widget_linktype'); $page = wppa_opt('featen_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('featen_blank')) { $result['target'] = '_blank'; } break; case 'lasten': $type = wppa_opt('lasten_widget_linktype'); $page = wppa_opt('lasten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('lasten_blank')) { $result['target'] = '_blank'; } break; case 'comten': $type = wppa_opt('comment_widget_linktype'); $page = wppa_opt('comment_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('comment_blank')) { $result['target'] = '_blank'; } break; case 'sswidget': $type = wppa_opt('slideonly_widget_linktype'); $page = wppa_opt('slideonly_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sswidget_blank')) { $result['target'] = '_blank'; } $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } break; case 'potdwidget': $type = wppa_opt('widget_linktype'); $page = wppa_opt('widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('potd_blank')) { $result['target'] = '_blank'; } break; case 'coverimg': $type = wppa_opt('coverimg_linktype'); $page = wppa_opt('coverimg_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('coverimg_blank')) { $result['target'] = '_blank'; } if ($type == 'slideshowstartatimage') { $result['url'] = wppa_get_slideshow_url($album, $page, $id); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'tnwidget': $type = wppa_opt('thumbnail_widget_linktype'); $page = wppa_opt('thumbnail_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('thumbnail_widget_blank')) { $result['target'] = '_blank'; } break; case 'slideshow': $type = wppa_opt('slideshow_linktype'); //''; $page = wppa_opt('slideshow_linkpage'); $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } if ($type == 'thumbs') { $result['url'] = wppa_get_ss_to_tn_link($page, $id); $result['title'] = __('View thumbnails', 'wp-photo-album-plus'); $result['is_url'] = true; $result['is_lightbox'] = false; if (wppa_switch('slideshow_blank')) { $result['target'] = '_blank'; } return $result; } if ($type == 'none') { return; } // Continue for 'single' break; case 'albwidget': $type = wppa_opt('album_widget_linktype'); $page = wppa_opt('album_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('album_widget_blank')) { $result['target'] = '_blank'; } break; default: return false; break; } if (!$album) { $album = wppa('start_album'); } if ($album == '' && !wppa('is_upldr')) { /**/ $album = wppa_get_album_id_by_photo_id($id); } if (is_numeric($album)) { $album_name = wppa_get_album_name($album); } else { $album_name = ''; } if (!$album) { $album = '0'; } if ($wich == 'comten') { $album = '0'; } if (wppa('is_tag')) { $album = '0'; } if (wppa('supersearch')) { $album = '0'; } if (wppa('calendar')) { $album = wppa('start_album') ? wppa('start_album') : '0'; } // if ( wppa( 'is_upldr' ) ) $album = '0'; // probeersel upldr parent if ($id) { $photo_name = wppa_get_photo_name($id); } else { $photo_name = ''; } $photo_name_js = esc_js($photo_name); $photo_name = esc_attr($photo_name); if ($id) { $photo_desc = esc_attr(wppa_get_photo_desc($id)); } else { $photo_desc = ''; } $title = __($photo_name, 'wp-photo-album-plus'); $result['onclick'] = ''; // Init switch ($type) { case 'none': // No link at all return false; break; case 'file': // The plain file if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); reset($is_video); $result['url'] = str_replace('xxx', current($is_video), $result['url']); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'lightbox': case 'lightboxsingle': if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] ); } else { if (wppa_switch('lb_hres')) { $result['url'] = wppa_get_hires_url($id); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = true; $result['url'] = wppa_fix_poster_ext($result['url'], $id); return $result; case 'widget': // Defined at widget activation $result['url'] = wppa('in_widget_linkurl'); $result['title'] = esc_attr(wppa('in_widget_linktitle')); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'album': // The albums thumbnails // The albums thumbnails case 'content': // For album widget switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; // $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; //$album_name;//'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'thumbalbum': $album = $thumb['album']; $album_name = wppa_get_album_name($album); switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'photo': // This means: The fullsize photo in a slideshow // This means: The fullsize photo in a slideshow case 'slphoto': // This means: The single photo in the style of a slideshow if ($type == 'slphoto') { $si = '&wppa-single=1'; } else { $si = ''; } switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'single': switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'same': $result['url'] = $lnk; $result['title'] = $tit; $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = $onc; return $result; break; case 'fullpopup': if ($is_video) { // A video can not be printed or downloaded $result['url'] = esc_attr('alert( "' . esc_js(__('A video can not be printed or downloaded', 'wp-photo-album-plus')) . '" )'); } else { $wid = wppa_get_photox($id); $hig = wppa_get_photoy($id); /* $imgsize = getimagesize( wppa_get_photo_path( $id ) ); if ( $imgsize ) { $wid = $imgsize['0']; $hig = $imgsize['1']; } else { $wid = '0'; $hig = '0'; } */ $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id); $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )'); } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = false; return $result; break; case 'custom': if ($wich == 'potdwidget') { $result['url'] = wppa_opt('widget_linkurl'); $result['title'] = wppa_opt('widget_linktitle'); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'slide': // for album widget $result['url'] = wppa_get_permalink(wppa_opt('album_widget_linkpage')) . 'wppa-album=' . $album . '&slide'; $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'autopage': if (!wppa_switch('auto_page')) { wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force'); $result['url'] = ''; } else { $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id)); } $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'plainpage': $result['url'] = get_permalink($page); $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page)); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; default: wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red'); return false; break; } if ($type != 'thumbalbum') { if (wppa('calendar')) { $result['url'] .= '&wppa-calendar=' . wppa('calendar') . '&wppa-caldate=' . wppa('caldate'); } if (wppa('supersearch')) { $result['url'] .= '&wppa-supersearch=' . urlencode(wppa('supersearch')); } if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) { $result['url'] .= '&wppa-searchstring=' . urlencode(wppa('searchstring')); } if ($wich == 'topten') { $result['url'] .= '&wppa-topten=' . wppa_opt('topten_count'); } elseif (wppa('is_topten')) { $result['url'] .= '&wppa-topten=' . wppa('topten_count'); } if ($wich == 'lasten') { $result['url'] .= '&wppa-lasten=' . wppa_opt('lasten_count'); } elseif (wppa('is_lasten')) { $result['url'] .= '&wppa-lasten=' . wppa('lasten_count'); } if ($wich == 'comten') { $result['url'] .= '&wppa-comten=' . wppa_opt('comten_count'); } elseif (wppa('is_comten')) { $result['url'] .= '&wppa-comten=' . wppa('comten_count'); } if ($wich == 'featen') { $result['url'] .= '&wppa-featen=' . wppa_opt('featen_count'); } elseif (wppa('is_featen')) { $result['url'] .= '&wppa-featen=' . wppa('featen_count'); } if (wppa('is_related')) { $result['url'] .= '&wppa-rel=' . wppa('is_related') . '&wppa-relcount=' . wppa('related_count'); } elseif (wppa('is_tag')) { $result['url'] .= '&wppa-tag=' . wppa('is_tag'); } if (wppa('is_upldr')) { $result['url'] .= '&wppa-upldr=' . wppa('is_upldr'); } if (wppa('is_inverse')) { $result['url'] .= '&wppa-inv=1'; } } if ($page != '0') { // on a different page $occur = '1'; $w = ''; } else { // on the same page, post or widget $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur'); $w = wppa_in_widget() ? 'w' : ''; } $result['url'] .= '&wppa-' . $w . 'occur=' . $occur; $result['url'] = wppa_convert_to_pretty($result['url']); if ($result['title'] == '') { $result['title'] = $tit; } // If still nothing, try arg return $result; }
function wppa_add_metatags() { global $wpdb; // Share info for sm that uses og $id = wppa_get_get('photo'); if (!wppa_photo_exists($id)) { $id = false; } if ($id) { // SM may not accept images from the cloud. wppa('for_sm', true); $imgurl = wppa_get_photo_url($id); wppa('for_sm', false); if (wppa_is_video($id)) { $imgurl = wppa_fix_poster_ext($imgurl, $id); } } else { $imgurl = ''; } if ($id) { if (wppa_switch('og_tags_on')) { $thumb = wppa_cache_thumb($id); if ($thumb) { $title = wppa_get_photo_name($id); $desc = wppa_get_og_desc($id); $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $site = get_bloginfo('name'); $mime = wppa_get_mime_type($id); echo ' <!-- WPPA+ Og Share data --> <meta property="og:site_name" content="' . esc_attr(sanitize_text_field($site)) . '" /> <meta property="og:type" content="article" /> <meta property="og:url" content="' . $url . '" /> <meta property="og:title" content="' . esc_attr(sanitize_text_field($title)) . '" />'; if ($mime) { echo ' <meta property="og:image" content="' . esc_url(sanitize_text_field($imgurl)) . '" /> <meta property="og:image:type" content="' . $mime . '" /> <meta property="og:image:width" content="' . wppa_get_photox($id) . '" /> <meta property="og:image:height" content="' . wppa_get_photoy($id) . '" />'; } if ($desc) { echo ' <meta property="og:description" content="' . esc_attr(sanitize_text_field($desc)) . '" />'; } echo ' <!-- WPPA+ End Og Share data --> '; } } if (wppa_switch('share_twitter') && wppa_opt('twitter_account')) { $thumb = wppa_cache_thumb($id); // Twitter wants at least 280px in width, and at least 150px in height if ($thumb) { $x = wppa_get_photo_item($id, 'photox'); $y = wppa_get_photo_item($id, 'photoy'); } if ($thumb && $x >= 280 && $y >= 150) { $title = wppa_get_photo_name($id); $desc = wppa_get_og_desc($id); $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $site = get_bloginfo('name'); echo ' <!-- WPPA+ Twitter Share data --> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="' . wppa_opt('twitter_account') . '"> <meta name="twitter:creator" content="' . wppa_opt('twitter_account') . '"> <meta name="twitter:title" content="' . esc_attr(sanitize_text_field($title)) . '"> <meta name="twitter:description" content="' . esc_attr(sanitize_text_field($desc)) . '"> <meta name="twitter:image" content="' . esc_url(sanitize_text_field($imgurl)) . '"> <!-- WPPA+ End Twitter Share data --> '; } elseif ($thumb && $x >= 120 && $y >= 120) { $title = wppa_get_photo_name($id); $desc = wppa_get_og_desc($id); $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $site = get_bloginfo('name'); echo ' <!-- WPPA+ Twitter Share data --> <meta name="twitter:card" content="summary"> <meta name="twitter:site" content="' . wppa_opt('twitter_account') . '"> <meta name="twitter:title" content="' . esc_attr(sanitize_text_field($title)) . '"> <meta name="twitter:description" content="' . esc_attr(sanitize_text_field($desc)) . '"> <meta name="twitter:image" content="' . esc_url(sanitize_text_field($imgurl)) . '"> <!-- WPPA+ End Twitter Share data --> '; } } } // To make sure we are on a page that contains at least [wppa] we check for Get var 'wppa-album'. // This also narrows the selection of featured photos to those that exist in the current album. $done = array(); $album = ''; if (isset($_REQUEST['album'])) { $album = $_REQUEST['album']; } elseif (isset($_REQUEST['wppa-album'])) { $album = $_REQUEST['wppa-album']; } $album = strip_tags($album); if (strlen($album == 12)) { $album = wppa_get_get('album'); } if ($album) { if (wppa_switch('meta_page')) { $photos = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND `status` = 'featured'", $album), ARRAY_A); wppa_cache_photo('add', $photos); if ($photos) { echo "\n<!-- WPPA+ BEGIN Featured photos on this page -->"; foreach ($photos as $photo) { $id = $photo['id']; $content = esc_attr(sanitize_text_field(wppa_get_keywords($id))); if ($content && !in_array($content, $done)) { echo ' <meta name="keywords" content="' . $content . '" >'; $done[] = $content; } } echo "\n<!-- WPPA+ END Featured photos on this page -->\n"; } } } elseif (wppa_switch('meta_all')) { $photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured'", ARRAY_A); wppa_cache_photo('add', $photos); if ($photos) { echo "\n<!-- WPPA+ BEGIN Featured photos on this site -->"; foreach ($photos as $photo) { $thumb = $photo; // Set to global to reduce queries when getting the name $id = $photo['id']; $content = esc_attr(sanitize_text_field(wppa_get_keywords($id))); if ($content && !in_array($content, $done)) { echo ' <meta name="keywords" content="' . $content . '" >'; $done[] = $content; } } echo "\n<!-- WPPA+ END Featured photos on this site -->\n"; } } // Facebook Admin and App if ((wppa_switch('share_on') || wppa_switch('share_on_widget')) && (wppa_switch('facebook_comments') || wppa_switch('facebook_like') || wppa_switch('share_facebook'))) { echo "\n<!-- WPPA+ BEGIN Facebook meta tags -->"; if (wppa_opt('facebook_admin_id')) { echo "\n\t<meta property=\"fb:admins\" content=\"" . wppa_opt('facebook_admin_id') . "\" />"; } if (wppa_opt('facebook_app_id')) { echo "\n\t<meta property=\"fb:app_id\" content=\"" . wppa_opt('facebook_app_id') . "\" />"; } if ($imgurl) { echo ' <link rel="image_src" href="' . esc_url($imgurl) . '" />'; } echo ' <!-- WPPA+ END Facebook meta tags --> '; } }
function wppa_get_audio_body($id, $for_lb = false, $w = '0', $h = '0') { // Audio enabled? if (!wppa_switch('enable_audio')) { return ''; } $is_audio = wppa_has_audio($id, true); // Not a audio? no go if (!$is_audio) { return ''; } // See what file types are present extract(wp_parse_args($is_audio, array('mp3' => false, 'wav' => false, 'ogg' => false))); // Collect other data $width = $w ? $w : wppa_get_photox($id); $height = $h ? $h : wppa_get_photoy($id); $source = wppa_get_photo_url($id); $source = substr($source, 0, strrpos($source, '.')); $class = $for_lb ? ' class="wppa-overlay-img"' : ''; $is_opera = strpos($_SERVER["HTTP_USER_AGENT"], 'OPR'); $is_ie = strpos($_SERVER["HTTP_USER_AGENT"], 'Trident'); $is_safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari'); wppa_dbg_msg('Mp3:' . $mp3 . ', Opera:' . $is_opera . ', Ie:' . $is_ie . ', Saf:' . $is_safari); // Assume the browser supports html5 $ext = ''; if ($is_ie) { if ($mp3) { $ext = 'mp3'; } } elseif ($is_safari) { if ($mp3) { $ext = 'mp3'; } elseif ($wav) { $ext = 'wav'; } } else { if ($mp3) { $ext = 'mp3'; } elseif ($wav) { $ext = 'wav'; } elseif ($ogg) { $ext = 'ogg'; } } if ($ext) { $mime = str_replace('mp3', 'mpeg', 'audio/' . $ext); $result = '<source src="' . $source . '.' . $ext . '" type="' . $mime . '">'; } $result .= esc_js(__('There is no filetype available for your browser, or your browser does not support html5 audio', 'wp-photo-album-plus')); return $result; }
function wppa_get_slide_frame_style() { $fs = wppa_opt('fullsize'); $cs = wppa_opt('colwidth'); if ($cs == 'auto') { $cs = $fs; wppa('auto_colwidth', true); } $result = ''; $gfs = is_numeric(wppa('fullsize')) && wppa('fullsize') > '1' ? wppa('fullsize') : $fs; $gfh = floor($gfs * wppa_opt('maxheight') / wppa_opt('fullsize')); if (wppa_in_widget() == 'ss' && wppa('in_widget_frame_height') > '0') { $gfh = wppa('in_widget_frame_height'); } // for bbb: wppa('slideframewidth', $gfs); wppa('slideframeheight', $gfh); if (wppa('portrait_only')) { $result = 'width: ' . $gfs . 'px;'; // No height } else { if (wppa_page('oneofone')) { $h = floor($gfs * wppa_get_photoy(wppa('single_photo')) / wppa_get_photox(wppa('single_photo'))); $result .= 'height: ' . $h . 'px;'; } elseif (wppa('auto_colwidth')) { $result .= ' height: ' . $gfh . 'px;'; } elseif (wppa('ss_widget_valign') != '' && wppa('ss_widget_valign') != 'fit') { $result .= ' height: ' . $gfh . 'px;'; } elseif (wppa_opt('fullvalign') == 'default') { $result .= 'min-height: ' . $gfh . 'px;'; } else { $result .= 'height: ' . $gfh . 'px;'; } $result .= 'width: ' . $gfs . 'px;'; } $hor = wppa_opt('fullhalign'); if ($gfs == $fs) { if ($fs != $cs) { switch ($hor) { case 'left': $result .= 'margin-left: 0px;'; break; case 'center': $result .= 'margin-left: ' . floor(($cs - $fs) / 2) . 'px;'; break; case 'right': $result .= 'margin-left: ' . ($cs - $fs) . 'px;'; break; } } } // Margin bottom if (wppa_opt('box_spacing')) { $result .= 'margin-bottom: ' . wppa_opt('box_spacing') . 'px;'; } return $result; }
function wppa_bestof_html($args, $widget = true) { // Copletify args $args = wp_parse_args((array) $args, array('page' => '0', 'count' => '1', 'sortby' => 'maxratingcount', 'display' => 'photo', 'period' => 'thisweek', 'maxratings' => 'yes', 'meanrat' => 'yes', 'ratcount' => 'yes', 'linktype' => 'none', 'size' => wppa_opt('widget_width'), 'fontsize' => wppa_opt('fontsize_widget_thumb'), 'lineheight' => wppa_opt('fontsize_widget_thumb') * 1.5, 'height' => '200')); // Make args into seperate vars extract($args); // Validate args if (!in_array($sortby, array('maxratingcount', 'meanrating', 'ratingcount'))) { wppa_dbg_msg('Invalid arg sortby "' . $sortby . '" must be "maxratingcount", "meanrating" or "ratingcount"', 'red', 'force'); } if (!in_array($display, array('photo', 'owner'))) { wppa_dbg_msg('Invalid arg display "' . $display . '" must be "photo" or "owner"', 'red', 'force'); } if (!in_array($period, array('lastweek', 'thisweek', 'lastmonth', 'thismonth', 'lastyear', 'thisyear'))) { wppa_dbg_msg('Invalid arg period "' . $period . '" must be "lastweek", "thisweek", "lastmonth", "thismonth", "lastyear" or "thisyear"', 'red', 'force'); } if (!$widget) { $size = $height; } $result = ''; $data = wppa_get_the_bestof($count, $period, $sortby, $display); if ($display == 'photo') { if (is_array($data)) { foreach (array_keys($data) as $id) { $thumb = wppa_cache_thumb($id); if ($thumb) { $imgsize = array(wppa_get_photox($id), wppa_get_photoy($id)); if ($widget) { $maxw = $size; $maxh = round($maxw * $imgsize['1'] / $imgsize['0']); } else { $maxh = $size; $maxw = round($maxh * $imgsize['0'] / $imgsize['1']); } $totalh = $maxh + $lineheight; if ($maxratings == 'yes') { $totalh += $lineheight; } if ($meanrat == 'yes') { $totalh += $lineheight; } if ($ratcount == 'yes') { $totalh += $lineheight; } if ($widget) { $clear = 'clear:both; '; } else { $clear = ''; } $result .= "\n" . '<div' . ' class="wppa-widget"' . ' style="' . $clear . 'width:' . $maxw . 'px; height:' . $totalh . 'px; margin:4px; display:inline; text-align:center; float:left;"' . ' >'; // The medal if at the top $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top')); // The link if any if ($linktype != 'none') { switch ($linktype) { case 'owneralbums': $href = wppa_get_permalink($page) . 'wppa-cover=1&wppa-owner=' . $thumb['owner'] . '&wppa-occur=1'; $title = __('See the authors albums', 'wp-photo-album-plus'); break; case 'ownerphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-owner=' . $thumb['owner'] . '&photos-only&wppa-occur=1'; $title = __('See the authors photos', 'wp-photo-album-plus'); break; case 'upldrphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-upldr=' . $thumb['owner'] . '&wppa-occur=1'; $title = __('See all the authors photos', 'wp-photo-album-plus'); break; } $result .= '<a href="' . wppa_convert_to_pretty($href) . '" title="' . $title . '" >'; } // The image $result .= '<img' . ' style="height:' . $maxh . 'px; width:' . $maxw . 'px;"' . ' src="' . wppa_fix_poster_ext(wppa_get_photo_url($id, '', $maxw, $maxh), $id) . '"' . ' ' . wppa_get_imgalt($id) . ' />'; // The /link if ($linktype != 'none') { $result .= '</a>'; } // The medal if near the bottom $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot')); // The subtitles $result .= "\n\t" . '<div style="font-size:' . $fontsize . 'px; line-height:' . $lineheight . 'px; position:absolute; width:' . $maxw . 'px; ">'; $result .= sprintf(__('Photo by: %s', 'wp-photo-album-plus'), $data[$id]['user']) . '<br />'; if ($maxratings == 'yes') { $n = $data[$id]['maxratingcount']; $result .= sprintf(_n('%d max rating', '%d max ratings', $n, 'wp-photo-album-plus'), $n) . '<br />'; } if ($ratcount == 'yes') { $n = $data[$id]['ratingcount']; $result .= sprintf(_n('%d vote', '%d votes', 'wp-photo-album-plus'), $n) . '<br />'; } if ($meanrat == 'yes') { $m = $data[$id]['meanrating']; $result .= sprintf(__('Rating: %4.2f.', 'wp-photo-album-plus'), $m) . '<br />'; } $result .= '</div>'; $result .= '<div style="clear:both" ></div>'; $result .= "\n" . '</div>'; } else { // No image $result .= '<div>' . sprintf(__('Photo %s not found.', 'wp-photo-album-plus'), $id) . '</div>'; } } } else { $result .= $data; // No array, print message } } else { // Display = owner if (is_array($data)) { $result .= '<ul>'; foreach (array_keys($data) as $author) { $result .= '<li>'; // The link if any if ($linktype != 'none') { switch ($linktype) { case 'owneralbums': $href = wppa_get_permalink($page) . 'wppa-cover=1&wppa-owner=' . $data[$author]['owner'] . '&wppa-occur=1'; $title = __('See the authors albums', 'wp-photo-album-plus'); break; case 'ownerphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-owner=' . $data[$author]['owner'] . '&photos-only&wppa-occur=1'; $title = __('See the authors photos', 'wp-photo-album-plus'); break; case 'upldrphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-upldr=' . $data[$author]['owner'] . '&wppa-occur=1'; $title = __('See all the authors photos', 'wp-photo-album-plus'); break; } $result .= '<a href="' . $href . '" title="' . $title . '" >'; } // The name $result .= $author; // The /link if ($linktype != 'none') { $result .= '</a>'; } $result .= '<br/>'; // The subtitles $result .= "\n" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px; ">'; if ($maxratings == 'yes') { $n = $data[$author]['maxratingcount']; $result .= sprintf(_n('%d max rating', '%d max ratings', $n, 'wp-photo-album-plus'), $n) . '<br />'; } if ($ratcount == 'yes') { $n = $data[$author]['ratingcount']; $result .= sprintf(_n('%d vote', '%d votes', 'wp-photo-album-plus'), $n) . '<br />'; } if ($meanrat == 'yes') { $m = $data[$author]['meanrating']; $result .= sprintf(__('Mean value: %4.2f.', 'wp-photo-album-plus'), $m) . '<br />'; } $result .= '</div>'; $result .= '</li>'; } $result .= '</ul>'; } else { $result .= $data; // No array, print message } } return $result; }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; global $wppa; global $thumb; require_once dirname(__FILE__) . '/wppa-links.php'; require_once dirname(__FILE__) . '/wppa-styles.php'; require_once dirname(__FILE__) . '/wppa-functions.php'; require_once dirname(__FILE__) . '/wppa-thumbnails.php'; require_once dirname(__FILE__) . '/wppa-boxes-html.php'; require_once dirname(__FILE__) . '/wppa-slideshow.php'; wppa_initialize_runtime(); $wppa['in_widget'] = 'alb'; $wppa['mocc']++; extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'parent' => 'none', 'name' => 'no', 'skip' => 'yes')); $widget_title = apply_filters('widget_title', $instance['title']); $page = in_array(wppa_opt('wppa_album_widget_linktype'), $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_album_widget_linkpage', __a('Photo Albums')); $max = wppa_opt('wppa_album_widget_count'); if (!$max) { $max = '10'; } $parent = $instance['parent']; $name = $instance['name']; $skip = $instance['skip']; if (is_numeric($parent)) { $albums = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_ALBUMS . '` WHERE `a_parent` = %s ' . wppa_get_album_order($parent), $parent), ARRAY_A); } else { switch ($parent) { case 'all': $albums = $wpdb->get_results('SELECT * FROM `' . WPPA_ALBUMS . '` ' . wppa_get_album_order(), ARRAY_A); break; case 'last': $albums = $wpdb->get_results('SELECT * FROM `' . WPPA_ALBUMS . '` ORDER BY `timestamp` DESC', ARRAY_A); break; default: wppa_dbg_msg('Error, unimplemented album selection: ' . $parent . ' in Album widget.', 'red', true); } } $widget_content = "\n" . '<!-- WPPA+ album Widget start -->'; $maxw = wppa_opt('wppa_album_widget_size'); $maxh = $maxw; if ($name == 'yes') { $maxh += 18; } $count = 0; if ($albums) { foreach ($albums as $album) { if ($count < $max) { global $thumb; $imageid = wppa_get_coverphoto_id($album['id']); $image = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $imageid), ARRAY_A); $imgcount = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ' . WPPA_PHOTOS . ' WHERE `album` = %s', $album['id'])); $subalbumcount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s", $album['id'])); $thumb = $image; // Make the HTML for current picture if ($image && ($imgcount > wppa_opt('wppa_min_thumbs') || $subalbumcount)) { $link = wppa_get_imglnk_a('albwidget', $image['id']); $file = wppa_get_thumb_path($image['id']); $imgevents = wppa_get_imgevents('thumb', $image['id'], true); $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'albthumb'); $imgstyle = $imgstyle_a['style']; $width = $imgstyle_a['width']; $height = $imgstyle_a['height']; $cursor = $imgstyle_a['cursor']; if (wppa_switch('wppa_show_albwidget_tooltip')) { $title = esc_attr(strip_tags(wppa_get_album_desc($album['id']))); } else { $title = ''; } $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height); } else { $link = ''; $file = ''; $imgevents = ''; $imgstyle = 'width:' . $maxw . ';height:' . $maxh . ';'; $width = $maxw; $height = $maxw; // !! $cursor = 'default'; $title = sprintf(__a('Upload at least %d photos to this album!', 'wppa_theme'), wppa_opt('wppa_min_thumbs') - $imgcount + 1); if ($imageid) { // The 'empty album has a cover image $file = wppa_get_thumb_path($image['id']); $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'albthumb'); $imgstyle = $imgstyle_a['style']; $width = $imgstyle_a['width']; $height = $imgstyle_a['height']; $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height); } else { $imgurl = wppa_get_imgdir() . 'album32.png'; } } $imgurl = wppa_fix_poster_ext($imgurl, $image['id']); if ($imgcount > wppa_opt('wppa_min_thumbs') || $skip == 'no') { $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">'; if ($link) { if ($link['is_url']) { // Is a href $widget_content .= "\n\t" . '<a href="' . $link['url'] . '" title="' . $title . '" target="' . $link['target'] . '" >'; if (wppa_is_video($image['id'])) { $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title)); } else { $widget_content .= "\n\t\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . ' cursor:pointer;" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >'; } $widget_content .= "\n\t" . '</a>'; } elseif ($link['is_lightbox']) { $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($album['id']), $album['id']), 'ARRAY_A'); if ($thumbs) { foreach ($thumbs as $thumb) { $title = wppa_get_lbtitle('alw', $thumb['id']); if (wppa_is_video($thumb['id'])) { $siz['0'] = wppa_get_videox($thumb['id']); $siz['1'] = wppa_get_videoy($thumb['id']); } else { // $siz = getimagesize( wppa_get_photo_path( $thumb['id'] ) ); $siz['0'] = wppa_get_photox($thumb['id']); $siz['1'] = wppa_get_photoy($thumb['id']); } $link = wppa_fix_poster_ext(wppa_get_photo_url($thumb['id'], '', $siz['0'], $siz['1']), $thumb['id']); $is_video = wppa_is_video($thumb['id']); $has_audio = wppa_has_audio($thumb['id']); $widget_content .= "\n\t" . '<a href="' . $link . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($thumb['id'])) . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($thumb['id'])) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('wppa_lightbox_name') . '[alw-' . $wppa['mocc'] . '-' . $album['id'] . ']"' . ' ' . wppa('lbtitle') . '="' . $title . '" >'; if ($thumb['id'] == $image['id']) { // the cover image if (wppa_is_video($image['id'])) { $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => $cursor, 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => wppa_zoom_in($image['id']))); } else { $widget_content .= "\n\t\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . wppa_zoom_in($image['id']) . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . $cursor . '" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >'; } } $widget_content .= "\n\t" . '</a>'; } } } else { // Is an onclick unit if (wppa_is_video($image['id'])) { $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents . ' onclick="' . $link['url'] . '"', 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title)); } else { $widget_content .= "\n\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . ' cursor:pointer;" ' . $imgevents . ' onclick="' . $link['url'] . '" ' . wppa_get_imgalt($image['id']) . ' >'; } } } else { if (wppa_is_video($image['id'])) { $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title)); } else { $widget_content .= "\n\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . '" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >'; } } if ($name == 'yes') { $widget_content .= "\n\t" . '<span style="font-size:' . wppa_opt('wppa_fontsize_widget_thumb') . 'px; min-height:100%;">' . __(stripslashes($album['name'])) . '</span>'; } $widget_content .= "\n" . '</div>'; $count++; } } } } else { $widget_content .= 'There are no albums (yet).'; } $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ thumbnail 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_the_coverphotos($albumid, $images, $srcs, $photo_pos, $photolinks, $title, $imgattrs_a, $events) { global $wpdb; if (!$images) { return; } // Find the photo frame style $photoframestyle = 'style="text-align:center; "'; // Open the coverphoto frame wppa_out('<div id="coverphoto_frame_' . $albumid . '_' . wppa('mocc') . '" class="coverphoto-frame" ' . $photoframestyle . '>'); // Process the images $n = count($images); for ($idx = '0'; $idx < $n; $idx++) { $image = $images[$idx]; $src = $srcs[$idx]; if (wppa_has_audio($image['id'])) { $src = wppa_fix_poster_ext($src, $image['id']); } $imgattr = $imgattrs_a[$idx]['style']; $imgwidth = $imgattrs_a[$idx]['width']; $imgheight = $imgattrs_a[$idx]['height']; $frmwidth = $imgwidth + '10'; // + 2 * 1 border + 2 * 4 padding $imgattr_a = $imgattrs_a[$idx]; $photolink = $photolinks[$idx]; if ($photolink) { if ($photolink['is_lightbox']) { $thumb = $image; $title = wppa_get_lbtitle('cover', $thumb['id']); if (wppa_is_video($thumb['id'])) { $siz['0'] = wppa_get_videox($thumb['id']); $siz['1'] = wppa_get_videoy($thumb['id']); } else { $siz['0'] = wppa_get_photox($thumb['id']); $siz['1'] = wppa_get_photoy($thumb['id']); } $link = wppa_get_photo_url($thumb['id'], '', $siz['0'], $siz['1']); if (wppa_has_audio($thumb['id'])) { $link = wppa_fix_poster_ext($link, $thumb['id']); } $is_video = wppa_is_video($thumb['id']); $has_audio = wppa_has_audio($thumb['id']); wppa_out('<a' . ' href="' . $link . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($thumb['id'])) . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($thumb['id'])) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[alw-' . wppa('mocc') . '-' . $albumid . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' >'); // the cover image if ($thumb['id'] == $image['id']) { if (wppa_is_video($image['id'])) { wppa_out("\n\t\t" . '<video preload="metadata" class="image wppa-img" id="i-' . $image['id'] . '-' . wppa('mocc') . '" title="' . wppa_zoom_in($image['id']) . '" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . $imgattr_a['cursor'] . '" ' . $events . '>' . wppa_get_video_body($image['id']) . '</video>'); } else { wppa_out("\n\t\t" . '<img class="image wppa-img" id="i-' . $image['id'] . '-' . wppa('mocc') . '" title="' . wppa_zoom_in($image['id']) . '" src="' . $src . '" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . $imgattr_a['cursor'] . '" ' . $events . ' ' . wppa_get_imgalt($image['id']) . '>'); } } wppa_out('</a> '); } else { // Link is NOT lightbox $href = $photolink['url'] == '#' ? '' : 'href="' . wppa_convert_to_pretty($photolink['url']) . '" '; wppa_out('<a ' . $href . 'target="' . $photolink['target'] . '" title="' . $photolink['title'] . '" onclick="' . $photolink['onclick'] . '" >'); if (wppa_is_video($image['id'])) { wppa_out('<video preload="metadata" ' . ' class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' >' . wppa_get_video_body($image['id']) . '</video>'); } else { wppa_out('<img src="' . $src . '" ' . wppa_get_imgalt($image['id']) . ' class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' />'); } wppa_out('</a> '); } } else { wppa_out('<img src="' . $src . '" ' . wppa_get_imgalt($image['id']) . ' class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' />'); } } // Close the coverphoto frame wppa_out('</div>'); }
/** @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_album_photos($album = '', $photo = '', $owner = '', $moderate = false) { global $wpdb; // Check input wppa_vfy_arg('wppa-page'); $pagesize = wppa_opt('photo_admin_pagesize'); $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1'; $skip = ($page - '1') * $pagesize; $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize; if ($album) { if ($album == 'search') { $count = wppa_get_edit_search_photos('', 'count_only'); $photos = wppa_get_edit_search_photos($limit); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring'])); } else { $counts = wppa_treecount_a($album); $count = $counts['selfphotos'] + $counts['pendphotos']; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s ' . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album); } } elseif ($photo && !$moderate) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $photo), ARRAY_A); $link = ''; } elseif ($owner) { $count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `' . WPPA_PHOTOS . '` WHERE `owner` = %s', $owner)); $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `owner` = %s ORDER BY `timestamp` DESC' . $limit, $owner), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_edit_photo'); } elseif ($moderate) { if (!current_user_can('wppa_moderate')) { wp_die(__('You do not have the rights to do this', 'wp-photo-album-plus')); } if ($photo) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $photo), ARRAY_A); $link = ''; } else { // Photos with pending comments? $cmt = $wpdb->get_results("SELECT `photo` FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'pending'", ARRAY_A); if ($cmt) { $orphotois = ''; foreach ($cmt as $c) { $orphotois .= "OR `id` = " . $c['photo'] . " "; } } else { $orphotois = ''; } $count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `' . WPPA_PHOTOS . '` WHERE `status` = %s ' . $orphotois, 'pending')); $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `status` = %s ' . $orphotois . ' ORDER BY `timestamp` DESC' . $limit, 'pending'), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_moderate_photos'); } if (empty($photos)) { if ($photo) { echo '<p>' . __('This photo is no longer awaiting moderation.', 'wp-photo-album-plus') . '</p>'; } else { echo '<p>' . __('There are no photos awaiting moderation at this time.', 'wp-photo-album-plus') . '</p>'; } if (current_user_can('administrator')) { echo '<h3>' . __('Manage all photos by timestamp', 'wp-photo-album-plus') . '</h3>'; $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "`"); $photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC" . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_moderate_photos'); } else { return; } } } else { wppa_dbg_msg('Missing required argument in wppa_album_photos() 1', 'red', 'force'); } if ($link && isset($_REQUEST['quick'])) { $link .= '&quick'; } wppa_show_search_statistics(); if (empty($photos)) { if ($photo) { echo '<div id="photoitem-' . $photo . '" class="photoitem" style="width: 99%; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 );"> <span style="color:red">' . sprintf(__('Photo %s has been removed.', 'wp-photo-album-plus'), $photo) . '</span> </div>'; } else { if (isset($_REQUEST['wppa-searchstring'])) { echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>'; } else { echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>'; } } } else { $wms = array('toplft' => __('top - left', 'wp-photo-album-plus'), 'topcen' => __('top - center', 'wp-photo-album-plus'), 'toprht' => __('top - right', 'wp-photo-album-plus'), 'cenlft' => __('center - left', 'wp-photo-album-plus'), 'cencen' => __('center - center', 'wp-photo-album-plus'), 'cenrht' => __('center - right', 'wp-photo-album-plus'), 'botlft' => __('bottom - left', 'wp-photo-album-plus'), 'botcen' => __('bottom - center', 'wp-photo-album-plus'), 'botrht' => __('bottom - right', 'wp-photo-album-plus')); $temp = wppa_get_water_file_and_pos('0'); $wmfile = isset($temp['select']) ? $temp['select'] : ''; $wmpos = isset($temp['pos']) && isset($wms[$temp['pos']]) ? $wms[$temp['pos']] : ''; wppa_admin_page_links($page, $pagesize, $count, $link); foreach ($photos as $photo) { $is_multi = wppa_is_multi($photo['id']); $is_video = wppa_is_video($photo['id']); $has_audio = wppa_has_audio($photo['id']); ?> <a id="photo_<?php echo $photo['id']; ?> " name="photo_<?php echo $photo['id']; ?> "></a> <div class="widefat wppa-table-wrap" id="photoitem-<?php echo $photo['id']; ?> " style="width:99%; position: relative;" > <!-- Left half starts here --> <div style="width:49.5%; float:left; border-right:1px solid #ccc; margin-right:0;"> <input type="hidden" id="photo-nonce-<?php echo $photo['id']; ?> " value="<?php echo wp_create_nonce('wppa_nonce_' . $photo['id']); ?> " /> <table class="wppa-table wppa-photo-table" style="width:98%" > <tbody> <!-- Preview --> <tr> <th> <label ><?php echo 'ID = ' . $photo['id'] . '. ' . __('Preview:', 'wp-photo-album-plus'); ?> </label> <br /> <?php echo sprintf(__('Album: %d<br />(%s)', 'wp-photo-album-plus'), $photo['album'], wppa_get_album_name($photo['album'])); ?> <br /><br /> <?php if (!$is_video) { ?> <?php _e('Rotate', 'wp-photo-album-plus'); ?> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo left?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rotleft', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('left', 'wp-photo-album-plus'); ?> </a> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo 180°?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rot180', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('180°', 'wp-photo-album-plus'); ?> </a> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo right?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rotright', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('right', 'wp-photo-album-plus'); ?> </a> <br /> <span style="font-size: 9px; line-height: 10px; color:#666;"> <?php if (wppa('front_edit')) { _e('If it says \'Photo rotated\', the photo is rotated.', 'wp-photo-album-plus'); } else { $refresh = '<a onclick="wppaReload()" >' . __('Refresh', 'wp-photo-album-plus') . '</a>'; echo sprintf(__('If it says \'Photo rotated\', the photo is rotated. %s the page.', 'wp-photo-album-plus'), $refresh); } ?> </span> <?php } ?> </th> <td> <?php $src = wppa_get_thumb_url($photo['id']); $big = wppa_get_photo_url($photo['id']); if ($is_video) { reset($is_video); $big = str_replace('xxx', current($is_video), $big); ?> <a href="<?php echo $big; ?> " target="_blank" title="<?php _e('Preview fullsize video', 'wp-photo-album-plus'); ?> " > <?php echo wppa_get_video_html(array('id' => $photo['id'], 'width' => '160', 'height' => '160' * wppa_get_videoy($photo['id']) / wppa_get_videox($photo['id']), 'controls' => false, 'use_thumb' => true)); ?> </a><?php } else { if ($has_audio) { $big = wppa_fix_poster_ext($big, $photo['id']); $src = wppa_fix_poster_ext($src, $photo['id']); } ?> <a href="<?php echo $big; ?> " target="_blank" title="<?php _e('Preview fullsize photo', 'wp-photo-album-plus'); ?> " > <img src="<?php echo $src; ?> " alt="<?php echo $photo['name']; ?> " style="max-width: 160px; vertical-align:middle;" /> </a><?php if ($has_audio) { $audio = wppa_get_audio_html(array('id' => $photo['id'], 'width' => '160', 'controls' => true)); ?> <br /> <?php if ($audio) { echo $audio; } else { echo '<span style="color:red;">' . __('Audio disabled', 'wp-photo-album-plus') . '</span>'; } } } ?> </td> </tr> <!-- Upload --> <tr> <th > <label><?php _e('Upload:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $timestamp = $photo['timestamp']; if ($timestamp) { echo wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $timestamp) . ' ' . __('local time', 'wp-photo-album-plus') . ' '; } if ($photo['owner']) { if (wppa_switch('photo_owner_change') && wppa_user_is('administrator')) { echo '</td></tr><tr><th><label>' . __('Owned by:', 'wp-photo-album-plus') . '</label></th><td>'; echo '<input type="text" onkeyup="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'owner\', this )" onchange="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'owner\', this )" value="' . $photo['owner'] . '" />'; } else { echo __('By:', 'wp-photo-album-plus') . ' ' . $photo['owner']; } } ?> </td> </tr> <!-- Modified --> <tr> <th> <label><?php _e('Modified:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $modified = $photo['modified']; if ($modified > $timestamp) { echo wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $modified) . ' ' . __('local time', 'wp-photo-album-plus'); } else { _e('Not modified', 'wp-photo-album-plus'); } ?> </td> </tr> <!-- EXIF Date --> <tr> <th> <label><?php _e('EXIF Date', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php if (wppa_user_is('administrator')) { echo '<input type="text" onkeyup="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'exifdtm\', this )" onchange="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'exifdtm\', this )" value="' . $photo['exifdtm'] . '" />'; } else { echo $photo['exifdtm']; } ?> </td> </tr> <!-- Rating --> <tr > <th > <label><?php _e('Rating:', 'wp-photo-album-plus'); ?> </label> </th> <td class="wppa-rating" > <?php $entries = wppa_get_rating_count_by_id($photo['id']); if ($entries) { echo __('Entries:', 'wp-photo-album-plus') . ' ' . $entries . '. ' . __('Mean value:', 'wp-photo-album-plus') . ' ' . wppa_get_rating_by_id($photo['id'], 'nolabel') . '.'; } else { _e('No ratings for this photo.', 'wp-photo-album-plus'); } $dislikes = wppa_dislike_get($photo['id']); if ($dislikes) { echo ' <span style="color:red" >' . sprintf(__('Disliked by %d visitors', 'wp-photo-album-plus'), $dislikes) . '</span>'; } $pending = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = %s AND `status` = 'pending'", $photo['id'])); if ($pending) { echo ' <span style="color:orange" >' . sprintf(__('%d pending votes.', 'wp-photo-album-plus'), $pending) . '</span>'; } ?> </td> </tr> <!-- Views --> <tr > <th > <label><?php _e('Views', 'wp-photo-album-plus'); ?> </label> </th> <td > <?php echo $photo['views']; ?> </td> </tr> <!-- P_order --> <?php if (!wppa_switch('porder_restricted') || current_user_can('administrator')) { ?> <tr > <th > <label><?php _e('Photo sort order #:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" id="porder-<?php echo $photo['id']; ?> " value="<?php echo $photo['p_order']; ?> " style="width: 50px" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'p_order', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'p_order', this )" /> </td> </tr> <?php } ?> <?php if (!isset($_REQUEST['quick'])) { ?> <?php if (!isset($album_select[$photo['album']])) { $album_select[$photo['album']] = wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $photo['album'], 'selected' => '0', 'addpleaseselect' => true)); } ?> <!-- Move --> <tr > <th > <input type="button" style="" onclick="if( document.getElementById( 'moveto-<?php echo $photo['id']; ?> ' ).value != 0 ) { if ( confirm( '<?php _e('Are you sure you want to move this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'moveto', document.getElementById( 'moveto-<?php echo $photo['id']; ?> ' ) ) } else { alert( '<?php _e('Please select an album to move the photo to first.', 'wp-photo-album-plus'); ?> ' ); return false;}" value="<?php echo esc_attr(__('Move photo to', 'wp-photo-album-plus')); ?> " /> </th> <td > <select id="moveto-<?php echo $photo['id']; ?> " style="width:100%;" ><?php echo $album_select[$photo['album']]; ?> </select> </td> </tr> <!-- Copy --> <tr > <th > <input type="button" style="" onclick="if ( document.getElementById( 'copyto-<?php echo $photo['id']; ?> ' ).value != 0 ) { if ( confirm( '<?php _e('Are you sure you want to copy this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'copyto', document.getElementById( 'copyto-<?php echo $photo['id']; ?> ' ) ) } else { alert( '<?php _e('Please select an album to copy the photo to first.', 'wp-photo-album-plus'); ?> ' ); return false;}" value="<?php echo esc_attr(__('Copy photo to', 'wp-photo-album-plus')); ?> " /> </th> <td > <select id="copyto-<?php echo $photo['id']; ?> " style="width:100%;" ><?php echo $album_select[$photo['album']]; ?> </select> </td> </tr> <?php } ?> <!-- Delete --> <?php if (!wppa('front_edit')) { ?> <tr > <th style="padding-top:0; padding-bottom:4px;"> <input type="button" style="color:red;" onclick="if ( confirm( '<?php _e('Are you sure you want to delete this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxDeletePhoto( <?php echo $photo['id']; ?> )" value="<?php echo esc_attr(__('Delete photo', 'wp-photo-album-plus')); ?> " /> </th> </tr> <?php } ?> <!-- Auto Page --> <?php if (wppa_switch('auto_page') && (current_user_can('edit_posts') || current_user_can('edit_pages'))) { ?> <tr style=="vertical-align:bottom;" > <th style="padding-top:0; padding-bottom:4px;"> <label> <?php _e('Autopage Permalink:', 'wp-photo-album-plus'); ?> </label> </th> <td > <?php echo get_permalink(wppa_get_the_auto_page($photo['id'])); ?> </td> </tr> <?php } ?> <!-- Link url --> <?php if (!wppa_switch('link_is_restricted') || current_user_can('administrator')) { ?> <tr > <th > <label><?php _e('Link url:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:60%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linkurl', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linkurl', this )" value="<?php echo stripslashes($photo['linkurl']); ?> " /> <select style="float:right;" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktarget', this )" > <option value="_self" <?php if ($photo['linktarget'] == '_self') { echo 'selected="selected"'; } ?> ><?php _e('Same tab', 'wp-photo-album-plus'); ?> </option> <option value="_blank" <?php if ($photo['linktarget'] == '_blank') { echo 'selected="selected"'; } ?> ><?php _e('New tab', 'wp-photo-album-plus'); ?> </option> </select> </td> </tr> <!-- Link title --> <tr > <th > <label><?php _e('Link title:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:97%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktitle', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktitle', this )" value="<?php echo stripslashes($photo['linktitle']); ?> " /> </td> </tr> <?php if (current_user_can('wppa_settings')) { ?> <tr style="padding-left:10px; font-size:9px; line-height:10px; color:#666;" > <td colspan="2" style="padding-top:0" > <?php _e('If you want this link to be used, check \'PS Overrule\' checkbox in table VI.', 'wp-photo-album-plus'); ?> </td> </tr> <?php } ?> <?php } ?> <!-- Alt custom field --> <?php if (wppa_opt('alt_type') == 'custom') { ?> <tr > <th > <label><?php _e('HTML Alt attribute:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:100%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'alt', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'alt', this )" value="<?php echo stripslashes($photo['alt']); ?> " /> </td> </tr> <?php } ?> </tbody> </table> </div> <!-- Right half starts here --> <div style="width:50%; float:left; border-left:1px solid #ccc; margin-left:-1px;"> <table class="wppa-table wppa-photo-table" > <tbody> <!-- Filename --> <tr> <th> <label><?php _e('Filename:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php echo $photo['filename']; if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { ?> <input type="button" onclick="jQuery( '#re-up-<?php echo $photo['id']; ?> ' ).css( 'display', '' );" value="<?php _e('Update file', 'wp-photo-album-plus'); ?> " /> <?php } ?> </td> </tr> <?php if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { ?> <tr id="re-up-<?php echo $photo['id']; ?> " style="display:none" > <th> </th> <td> <form id="wppa-re-up-form-<?php echo $photo['id']; ?> " onsubmit="wppaReUpload( event,<?php echo $photo['id']; ?> , '<?php echo $photo['filename']; ?> ' )" > <input type="file" id="wppa-re-up-file-<?php echo $photo['id']; ?> " /> <input type="submit" id="wppa-re-up-butn-<?php echo $photo['id']; ?> " value="<?php _e('Upload', 'wp-photo-album-plus'); ?> " /> </form> </td> </tr> <?php } ?> <!--- Video sizes --> <?php if ($is_video) { ?> <tr> <th> <label><?php _e('Video size:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <tr> <td> <?php _e('Width:', 'wp-photo-album-plus'); ?> </td> <td> <input style="width:50px;margin:0 4px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videox', this ); " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videox', this ); " value="<?php echo $photo['videox']; ?> " /><?php echo sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_width')); ?> </td> </tr> <tr> <td> <?php _e('Height:', 'wp-photo-album-plus'); ?> </td> <td> <input style="width:50px;margin:0 4px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videoy', this ); " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videoy', this ); " value="<?php echo $photo['videoy']; ?> " /><?php echo sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_height')); ?> </td> </tr> </table> </td> </tr> <tr> <th> <label><?php _e('Formats:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <?php foreach ($is_video as $fmt) { echo '<tr>' . '<td>' . $fmt . '</td>' . '<td>' . __('Filesize:', 'wp-photo-album-plus') . '</td>' . '<td>' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($photo['id']))) . '</td>' . '</tr>'; } ?> </table> </td> </tr> <?php } ?> <!-- Audio --> <?php if ($has_audio) { ?> <tr> <th> <label><?php _e('Formats:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <?php foreach ($has_audio as $fmt) { echo '<tr>' . '<td>' . $fmt . '</td>' . '<td>' . __('Filesize:', 'wp-photo-album-plus') . '</td>' . '<td>' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($photo['id']))) . '</td>' . '</tr>'; } ?> </table> </td> </tr> <?php } ?> <!-- Filesizes --> <tr> <th> <label><?php $is_video || $has_audio ? _e('Poster:', 'wp-photo-album-plus') : _e('Photo sizes:', 'wp-photo-album-plus'); ?> </label> </th> <td> <table class="wppa-subtable" > <tr> <td> <?php _e('Source file:', 'wp-photo-album-plus'); ?> </td> <?php $sp = wppa_get_source_path($photo['id']); if (is_file($sp)) { $ima = getimagesize($sp); ?> <td> <?php echo $ima['0'] . ' x ' . $ima['1'] . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($sp); ?> </td> <td> <a style="cursor:pointer; font-weight:bold;" title="<?php _e('Remake display file and thumbnail file', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'remake', this )"><?php _e('Remake files', 'wp-photo-album-plus'); ?> </a> </td> <?php } else { ?> <td> <span style="color:orange;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <td> </td> <?php } ?> </tr> <tr> <td> <?php _e('Display file:', 'wp-photo-album-plus'); ?> </td> <?php $dp = wppa_fix_poster_ext(wppa_get_photo_path($photo['id']), $photo['id']); if (is_file($dp)) { ?> <td> <?php echo floor(wppa_get_photox($photo['id'])) . ' x ' . floor(wppa_get_photoy($photo['id'])) . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($dp); ?> </td> <td> </td> <?php } else { ?> <td> <span style="color:red;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <td> </td> <?php } ?> </tr> <tr> <td> <?php _e('Thumbnail file:', 'wp-photo-album-plus'); ?> </td> <?php $tp = wppa_fix_poster_ext(wppa_get_thumb_path($photo['id']), $photo['id']); if (is_file($tp)) { ?> <td> <?php echo floor(wppa_get_thumbx($photo['id'])) . ' x ' . floor(wppa_get_thumby($photo['id'])) . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($tp); ?> </td> <?php } else { ?> <td> <span style="color:red;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <?php } ?> <td> <a style="cursor:pointer; font-weight:bold;" title="<?php _e('Remake thumbnail file', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'remakethumb', this )"><?php _e('Remake', 'wp-photo-album-plus'); ?> </a> </td> </tr> </table> </td> </tr> <!-- Stereo --> <?php if (wppa_switch('enable_stereo')) { ?> <tr> <th> <label><?php _e('Stereophoto:', 'wp-photo-album-plus'); ?> </label> </th> <td> <select id="stereo-<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'stereo', this )" > <option value="0" <?php if ($photo['stereo'] == '0') { echo 'selected="selected" '; } ?> ><?php _e('no stereo image or ready anaglyph', 'wp-photo-album-plus'); ?> </option> <option value="1" <?php if ($photo['stereo'] == '1') { echo 'selected="selected" '; } ?> ><?php _e('Left - right stereo image', 'wp-photo-album-plus'); ?> </option> <option value="-1" <?php if ($photo['stereo'] == '-1') { echo 'selected="selected" '; } ?> ><?php _e('Right - left stereo image', 'wp-photo-album-plus'); ?> </option> <select> <td> </tr> <tr> <th> <label><?php _e('Images:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $files = glob(WPPA_UPLOAD_PATH . '/stereo/' . $photo['id'] . '-*.*'); if (!empty($files)) { sort($files); $c = 0; echo '<table><tbody>'; foreach ($files as $file) { if (!$c) { echo '<tr>'; } if (is_file($file)) { echo '<td style="padding:0;" ><a href="' . str_replace(WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $file) . '" target="_blank" >' . basename($file) . '</a></td>'; } if (strpos(basename($file), '_flat')) { $c++; } $c = ($c + 1) % 2; if (!$c) { echo '</tr>'; } } if ($c) { echo '<td style="padding:0;" ></td></tr>'; } echo '</tbody></table>'; } ?> </td> </tr> <?php } ?> <!-- Location --> <?php if ($photo['location'] || wppa_switch('geo_edit')) { ?> <tr> <th> <label><?php _e('Location:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $loc = $photo['location'] ? $photo['location'] : '///'; $geo = explode('/', $loc); echo $geo['0'] . ' ' . $geo['1'] . ' '; if (wppa_switch('geo_edit')) { ?> <?php _e('Lat:', 'wp-photo-album-plus'); ?> <input type="text" style="width:100px;" id="lat-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lat', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lat', this );" value="<?php echo $geo['2']; ?> " /> <?php _e('Lon:', 'wp-photo-album-plus'); ?> <input type="text" style="width:100px;" id="lon-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lon', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lon', this );" value="<?php echo $geo['3']; ?> " /> <?php if (!wppa('front_edit')) { ?> <span class="description"><br /><?php _e('Refresh the page after changing to see the degrees being updated', 'wp-photo-album-plus'); ?> </span> <?php } ?> <?php } ?> </td> </tr> <?php } ?> <!-- Name --> <tr > <th > <label><?php _e('Photoname:', 'wp-photo-album-plus'); ?> </label> </th> <?php if (wppa_switch('use_wp_editor')) { ?> <td> <input type="text" style="width:100%;" id="pname-<?php echo $photo['id']; ?> " value="<?php echo esc_attr(stripslashes($photo['name'])); ?> " /> <input type="button" class="button-secundary" value="<?php _e('Update Photo name', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', document.getElementById( 'pname-<?php echo $photo['id']; ?> ' ) );" /> </td> <?php } else { ?> <td> <input type="text" style="width:100%;" id="pname-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', this );" value="<?php echo esc_attr(stripslashes($photo['name'])); ?> " /> </td> <?php } ?> </tr> <!-- Description --> <?php if (!wppa_switch('desc_is_restricted') || wppa_user_is('administrator')) { ?> <tr> <th> <label><?php _e('Description:', 'wp-photo-album-plus'); ?> </label> </th> <?php if (wppa_switch('use_wp_editor')) { ?> <td> <?php $alfaid = wppa_alfa_id($photo['id']); // $quicktags_settings = array( 'buttons' => 'strong,em,link,block,ins,ul,ol,li,code,close' ); wp_editor(stripslashes($photo['description']), 'wppaphotodesc' . $alfaid, array('wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => true)); //, 'quicktags' => $quicktags_settings ) ); ?> <input type="button" class="button-secundary" value="<?php _e('Update Photo description', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', document.getElementById( 'wppaphotodesc'+'<?php echo $alfaid; ?> ' ), false, '<?php echo $alfaid; ?> ' )" /> <img id="wppa-photo-spin-<?php echo $photo['id']; ?> " src="<?php echo wppa_get_imgdir() . 'wpspin.gif'; ?> " style="visibility:hidden" /> </td> <?php } else { ?> <td> <textarea style="width: 100%; height:120px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', this )" ><?php echo stripslashes($photo['description']); ?> </textarea> </td> <?php } ?> </tr> <?php } else { ?> <tr> <th> <label><?php _e('Description:', 'wp-photo-album-plus'); ?> </label> </th> <td> <div style="width: 100%; height:120px; overflow:auto;" ><?php echo stripslashes($photo['description']); ?> </div> </td> </tr> <?php } ?> <!-- Custom --> <?php if (wppa_switch('custom_fields')) { $custom = wppa_get_photo_item($photo['id'], 'custom'); if ($custom) { $custom_data = unserialize($custom); } else { $custom_data = array('', '', '', '', '', '', '', '', '', ''); } foreach (array_keys($custom_data) as $key) { if (wppa_opt('custom_caption_' . $key)) { ?> <tr> <th> <label><?php echo wppa_opt('custom_caption_' . $key) . ':<br /><small>(w#cc' . $key . ')</small>'; ?> </label> </th> <td> <?php echo '<small>(w#cd' . $key . ')</small>'; ?> <input type="text" style="width:85%; float:right;" id="pname-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'custom_<?php echo $key; ?> ', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'custom_<?php echo $key; ?> ', this );" value="<?php echo esc_attr(stripslashes($custom_data[$key])); ?> " /> </td> </tr> <?php } } } ?> <!-- Tags --> <tr style="vertical-align:middle;" > <th > <label ><?php _e('Tags:', 'wp-photo-album-plus'); ?> </label> <span class="description" > <br /> </span> </th> <td > <input id="tags-<?php echo $photo['id']; ?> " type="text" style="width:100%;" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'tags', this )" value="<?php echo stripslashes(trim($photo['tags'], ',')); ?> " /> <span class="description" > <?php _e('Separate tags with commas.', 'wp-photo-album-plus'); ?> <?php _e('Examples:', 'wp-photo-album-plus'); ?> <select onchange="wppaAddTag( this.value, 'tags-<?php echo $photo['id']; ?> ' ); wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'tags', document.getElementById( 'tags-<?php echo $photo['id']; ?> ' ) )" > <?php $taglist = wppa_get_taglist(); if (is_array($taglist)) { echo '<option value="" >' . __('- select -', 'wp-photo-album-plus') . '</option>'; foreach ($taglist as $tag) { echo '<option value="' . $tag['tag'] . '" >' . $tag['tag'] . '</option>'; } } else { echo '<option value="0" >' . __('No tags yet', 'wp-photo-album-plus') . '</option>'; } ?> </select> <?php _e('Select to add', 'wp-photo-album-plus'); ?> </span> </td> </tr> <!-- Status --> <tr style="vertical-align:middle;" > <th> <label ><?php _e('Status:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php if ((current_user_can('wppa_admin') || current_user_can('wppa_moderate')) && !isset($_REQUEST['quick'])) { ?> <table> <tr> <td> <select id="status-<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'status', this ); wppaPhotoStatusChange( <?php echo $photo['id']; ?> ); "> <option value="pending" <?php if ($photo['status'] == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('Pending', 'wp-photo-album-plus'); ?> </option> <option value="publish" <?php if ($photo['status'] == 'publish') { echo 'selected="selected"'; } ?> ><?php _e('Publish', 'wp-photo-album-plus'); ?> </option> <?php if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) { $dis = ' disabled'; } else { $dis = ''; } ?> <option value="featured" <?php if ($photo['status'] == 'featured') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Featured', 'wp-photo-album-plus'); ?> </option> <option value="gold" <?php if ($photo['status'] == 'gold') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Gold', 'wp-photo-album-plus'); ?> </option> <option value="silver" <?php if ($photo['status'] == 'silver') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Silver', 'wp-photo-album-plus'); ?> </option> <option value="bronze" <?php if ($photo['status'] == 'bronze') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Bronze', 'wp-photo-album-plus'); ?> </option> <option value="scheduled" <?php if ($photo['status'] == 'scheduled') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Scheduled', 'wp-photo-album-plus'); ?> </option> <option value="private" <?php if ($photo['status'] == 'private') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Private', 'wp-photo-album-plus'); ?> </option> </select> </td> <td class="wppa-datetime-<?php echo $photo['id']; ?> " > <?php echo wppa_get_date_time_select_html('photo', $photo['id'], true); ?> </td> </tr> </table> <?php } else { ?> <input type="hidden" id="status-<?php echo $photo['id']; ?> " value="<?php echo $photo['status']; ?> " /> <table> <tr> <td> <?php if ($photo['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'publish') { _e('Publish', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'featured') { _e('Featured', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'gold') { _e('Gold', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'silver') { _e('Silver', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'bronze') { _e('Bronze', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'scheduled') { _e('Scheduled', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'private') { _e('Private', 'wp-photo-album-plus'); } ?> </td> <td class="wppa-datetime-<?php echo $photo['id']; ?> " > <?php echo wppa_get_date_time_select_html('photo', $photo['id'], false); ?> </td> </tr> </table> <?php } ?> <span id="psdesc-<?php echo $photo['id']; ?> " class="description" style="display:none;" ><?php _e('Note: Featured photos should have a descriptive name; a name a search engine will look for!', 'wp-photo-album-plus'); ?> </span> </td> </tr> <!-- Watermark --> <?php if (!$is_video || is_file(wppa_fix_poster_ext(wppa_get_photo_path($photo['id']), $photo['id']))) { ?> <tr style="vertical-align:middle;" > <th > <label><?php _e('Watermark:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $user = wppa_get_user(); if (wppa_switch('watermark_on')) { if (wppa_switch('watermark_user') || current_user_can('wppa_settings')) { echo __('File:', 'wppa', 'wp-photo-album-plus') . ' '; ?> <select id="wmfsel_<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'wppa_watermark_file_<?php echo $user; ?> ', this );" > <?php echo wppa_watermark_file_select(); ?> </select> <?php echo '<br />' . __('Pos:', 'wp-photo-album-plus') . ' '; ?> <select id="wmpsel_<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'wppa_watermark_pos_<?php echo $user; ?> ', this );" > <?php echo wppa_watermark_pos_select(); ?> </select> <input type="button" class="button-secundary" value="<?php _e('Apply watermark', 'wp-photo-album-plus'); ?> " onclick="if ( confirm( '<?php echo esc_js(__('Are you sure? Once applied it can not be removed!', 'wp-photo-album-plus')) . '\\n\\n' . esc_js(__('And I do not know if there is already a watermark on this photo', 'wp-photo-album-plus')); ?> ' ) ) wppaAjaxApplyWatermark( <?php echo $photo['id']; ?> , document.getElementById( 'wmfsel_<?php echo $photo['id']; ?> ' ).value, document.getElementById( 'wmpsel_<?php echo $photo['id']; ?> ' ).value )" /> <?php } else { echo __('File:', 'wppa', 'wp-photo-album-plus') . ' ' . __($wmfile, 'wp-photo-album-plus'); if ($wmfile != '--- none ---') { echo ' ' . __('Pos:', 'wp-photo-album-plus') . ' ' . $wmpos; } } ?> <img id="wppa-water-spin-<?php echo $photo['id']; ?> " src="<?php echo wppa_get_imgdir() . 'wpspin.gif'; ?> " style="visibility:hidden" /><?php } else { _e('Not configured', 'wp-photo-album-plus'); } ?> </td> </tr> <?php } ?> <!-- Remark --> <tr style="vertical-align: middle;" > <th > <label style="color:#070"><?php _e('Remark:', 'wp-photo-album-plus'); ?> </label> </th> <td id="photostatus-<?php echo $photo['id']; ?> " style="padding-left:10px; width: 400px;"> <?php if (wppa_is_video($photo['id'])) { echo sprintf(__('Video %s is not modified yet', 'wp-photo-album-plus'), $photo['id']); } else { echo sprintf(__('Photo %s is not modified yet', 'wp-photo-album-plus'), $photo['id']); } ?> </td> </tr> </tbody> </table> <script type="text/javascript">wppaPhotoStatusChange( <?php echo $photo['id']; ?> )</script> </div> <div style="clear:both;"></div> <?php if (!isset($_REQUEST['quick'])) { ?> <div class="wppa-links" > <table style="width:100%" > <tbody> <?php if (current_user_can('edit_posts') || current_user_can('edit_pages')) { ?> <tr> <td><?php _e('Single image shortcode', 'wp-photo-album-plus'); ?> :</td> <td><?php echo esc_js('[wppa type="photo" photo="' . $photo['id'] . '" size="' . wppa_opt('fullsize') . '"][/wppa]'); ?> </td> </tr> <?php } ?> <?php if (is_file(wppa_get_source_path($photo['id']))) { ?> <tr> <td><?php _e('Permalink', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_source_pl($photo['id']); ?> </td> </tr> <?php } ?> <tr> <td><?php _e('Hi resolution url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_hires_url($photo['id']); ?> </td> </tr> <?php if (is_file(wppa_get_photo_path($photo['id']))) { ?> <tr> <td><?php _e('Display file url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_lores_url($photo['id']); ?> </td> </tr> <?php } ?> <?php if (is_file(wppa_get_thumb_path($photo['id']))) { ?> <tr> <td><?php _e('Thumbnail file url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_tnres_url($photo['id']); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php } ?> </div> <!-- Comments --> <?php $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s ORDER BY `timestamp` DESC", $photo['id']), ARRAY_A); if ($comments) { ?> <div class="widefat" style="width:99%; font-size:11px;" > <table class="wppa-table widefat wppa-setting-table" > <thead> <tr style="font-weight:bold;" > <td style="padding:0 4px;" >#</td> <td style="padding:0 4px;" >User</td> <td style="padding:0 4px;" >Time since</td> <td style="padding:0 4px;" >Status</td> <td style="padding:0 4px;" >Comment</td> </tr> </thead> <tbody> <?php foreach ($comments as $comment) { echo ' <tr> <td style="padding:0 4px;" >' . $comment['id'] . '</td> <td style="padding:0 4px;" >' . $comment['user'] . '</td> <td style="padding:0 4px;" >' . wppa_get_time_since($comment['timestamp']) . '</td>'; if (current_user_can('wppa_comments') || current_user_can('wppa_moderate') || wppa_get_user() == $photo['owner'] && wppa_switch('owner_moderate_comment')) { $p = $comment['status'] == 'pending' ? 'selected="selected" ' : ''; $a = $comment['status'] == 'approved' ? 'selected="selected" ' : ''; $s = $comment['status'] == 'spam' ? 'selected="selected" ' : ''; $t = $comment['status'] == 'trash' ? 'selected="selected" ' : ''; echo ' <td style="padding:0 4px;" > <select style="height: 20px; font-size: 11px; padding:0;" onchange="wppaAjaxUpdateCommentStatus( ' . $photo['id'] . ', ' . $comment['id'] . ', this.value )" > <option value="pending" ' . $p . '>' . __('Pending', 'wp-photo-album-plus') . '</option> <option value="approved" ' . $a . '>' . __('Approved', 'wp-photo-album-plus') . '</option> <option value="spam" ' . $s . '>' . __('Spam', 'wp-photo-album-plus') . '</option> <option value="trash" ' . $t . '>' . __('Trash', 'wp-photo-album-plus') . '</option> </select > </td> '; } else { echo '<td style="padding:0 4px;" >'; if ($comment['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'approved') { _e('Approved', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'spam') { _e('Spam', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'trash') { _e('Trash', 'wp-photo-album-plus'); } echo '</td>'; } echo '<td style="padding:0 4px;" >' . $comment['comment'] . '</td> </tr> '; } ?> </tbody> </table> </div> <?php } ?> <!-- </div> --> <div style="clear:both;margin-top:7px;"></div> <?php } /* foreach photo */ wppa_admin_page_links($page, $pagesize, $count, $link); } /* photos not empty */ }
function wppa_album_photos($album = '', $photo = '', $owner = '', $moderate = false) { global $wpdb; // Check input wppa_vfy_arg('wppa-page'); $pagesize = wppa_opt('photo_admin_pagesize'); $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1'; $skip = ($page - '1') * $pagesize; $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize; // Edit the photos in a specific album if ($album) { // Special album case: search (see last album line in album table) if ($album == 'search') { $count = wppa_get_edit_search_photos('', 'count_only'); $photos = wppa_get_edit_search_photos($limit); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_admin_menu' . '&tab=edit' . '&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring'])); } else { $counts = wppa_treecount_a($album); $count = $counts['selfphotos'] + $counts['pendphotos']; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` = %s " . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_admin_menu' . '&tab=edit' . '&edit_id=' . $album); } } elseif ($photo && !$moderate) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `id` = %s", $photo), ARRAY_A); $link = ''; } elseif ($owner) { $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `owner` = %s", $owner)); $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `owner` = %s " . "ORDER BY `timestamp` DESC " . $limit, $owner), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_edit_photo'); } elseif ($moderate) { // Can i moderate? if (!current_user_can('wppa_moderate')) { wp_die(__('You do not have the rights to do this', 'wp-photo-album-plus')); } // Moderate a single photo if ($photo) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `id` = %s", $photo), ARRAY_A); $link = ''; } else { $cmt = $wpdb->get_results("SELECT `photo` " . "FROM `" . WPPA_COMMENTS . "` " . "WHERE `status` = 'pending' " . "OR `status` = 'spam'", ARRAY_A); if ($cmt) { $orphotois = ''; foreach ($cmt as $c) { $orphotois .= "OR `id` = " . $c['photo'] . " "; } } else { $orphotois = ''; } $count = $wpdb->get_var("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` = 'pending' " . $orphotois); $photos = $wpdb->get_results("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` = 'pending' " . $orphotois . " " . "ORDER BY `timestamp` DESC " . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_moderate_photos'); } // No photos to moderate if (empty($photos)) { // Single photo moderate requested if ($photo) { echo '<p>' . __('This photo is no longer awaiting moderation.', 'wp-photo-album-plus') . '</p>'; } else { echo '<p>' . __('There are no photos awaiting moderation at this time.', 'wp-photo-album-plus') . '</p>'; } // If i am admin, i can edit all photos here, sorted by timestamp desc if (wppa_user_is('administrator')) { echo '<h3>' . __('Manage all photos by timestamp', 'wp-photo-album-plus') . '</h3>'; $count = $wpdb->get_var("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "`"); $photos = $wpdb->get_results("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "ORDER BY `timestamp` DESC" . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_moderate_photos'); } else { return; } } } else { wppa_dbg_msg('Missing required argument in wppa_album_photos() 1', 'red', 'force'); return; } // Quick edit skips a few time consuming settings like copy and move to other album $quick = isset($_REQUEST['quick']); if ($link && $quick) { $link .= '&quick'; } // In case it is a seaerch and edit, show the search statistics wppa_show_search_statistics(); // If no photos selected produce apprpriate message and quit if (empty($photos)) { // A specific photo requested if ($photo) { echo '<div id="photoitem-' . $photo . '" class="photoitem" style="width:100%; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 );">' . '<span style="color:red">' . sprintf(__('Photo %s has been removed.', 'wp-photo-album-plus'), $photo) . '</span>' . '</div>'; } else { // Search if (isset($_REQUEST['wppa-searchstring'])) { echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>'; } else { echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>'; } } return; } else { // Local js functions placed here as long as there is not yet a possibility to translate texts in js files ?> <script> function wppaTryMove( id, video ) { var query; if ( ! jQuery( '#target-' + id ).val() ) { alert( '<?php echo esc_js(__('Please select an album to move to first.', 'wp-photo-album-plus')); ?> ' ); return false; } if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to move this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to move this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'moveto', document.getElementById( 'target-' + id ) ); } } function wppaTryCopy( id, video ) { var query; if ( ! jQuery( '#target-' + id ).val() ) { alert( '<?php echo esc_js(__('Please select an album to copy to first.', 'wp-photo-album-plus')); ?> ' ); return false; } if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to copy this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to copy this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'copyto', document.getElementById( 'target-' + id ) ); } } function wppaTryDelete( id, video ) { var query; if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to delete this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to delete this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxDeletePhoto( id ) } } function wppaTryRotLeft( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo left?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rotleft', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryRot180( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo 180°?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rot180', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryRotRight( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo right?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rotright', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryFlip( id ) { var query = '<?php echo esc_js(__('Are you sure you want to flip this photo?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'flip', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryWatermark( id ) { var wmFile = jQuery( '#wmfsel_' + id ).val(); if ( wmFile == '--- none ---' ) { alert( '<?php echo esc_js(__('No watermark selected', 'wp-photo-album-plus')); ?> ' ); return; } var query = '<?php echo esc_js(__('Are you sure? Once applied it can not be removed!', 'wp-photo-album-plus')); ?> '; query += '\n'; query += '<?php echo esc_js(__('And I do not know if there is already a watermark on this photo', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxApplyWatermark( id, document.getElementById( 'wmfsel_' + id ).value, document.getElementById( 'wmpsel_' + id ).value ); } } </script> <?php // Get the current watermark file settings $wms = array('toplft' => __('top - left', 'wp-photo-album-plus'), 'topcen' => __('top - center', 'wp-photo-album-plus'), 'toprht' => __('top - right', 'wp-photo-album-plus'), 'cenlft' => __('center - left', 'wp-photo-album-plus'), 'cencen' => __('center - center', 'wp-photo-album-plus'), 'cenrht' => __('center - right', 'wp-photo-album-plus'), 'botlft' => __('bottom - left', 'wp-photo-album-plus'), 'botcen' => __('bottom - center', 'wp-photo-album-plus'), 'botrht' => __('bottom - right', 'wp-photo-album-plus')); $temp = wppa_get_water_file_and_pos('0'); $wmfile = isset($temp['select']) ? $temp['select'] : ''; $wmpos = isset($temp['pos']) && isset($wms[$temp['pos']]) ? $wms[$temp['pos']] : ''; $mvt = esc_attr(__('Move video', 'wp-photo-album-plus')); $mpt = esc_attr(__('Move photo', 'wp-photo-album-plus')); $cvt = esc_attr(__('Copy video', 'wp-photo-album-plus')); $cpt = esc_attr(__('Copy photo', 'wp-photo-album-plus')); // Display the pagelinks wppa_admin_page_links($page, $pagesize, $count, $link); // Display all photos foreach ($photos as $photo) { // We may not use extract(), so we do something like it here manually, hence controlled. $id = $photo['id']; $timestamp = $photo['timestamp']; $modified = $photo['modified']; $owner = $photo['owner']; $crypt = $photo['crypt']; $album = $photo['album']; $name = stripslashes($photo['name']); $description = stripslashes($photo['description']); $exifdtm = $photo['exifdtm']; $views = $photo['views']; $clicks = $photo['clicks']; $p_order = $photo['p_order']; $linktarget = $photo['linktarget']; $linkurl = $photo['linkurl']; $linktitle = stripslashes($photo['linktitle']); $alt = stripslashes($photo['alt']); $filename = $photo['filename']; $videox = $photo['videox']; $videoy = $photo['videoy']; $location = $photo['location']; $status = $photo['status']; $tags = trim(stripslashes($photo['tags']), ','); $stereo = $photo['stereo']; // See if item is a multimedia item $is_multi = wppa_is_multi($id); $is_video = wppa_is_video($id); // returns array of extensions $b_is_video = empty($is_video) ? 0 : 1; // boolean $has_audio = wppa_has_audio($id); // returns array of extensions $b_has_audio = empty($has_audio) ? 0 : 1; // boolean // Various usefull vars $owner_editable = wppa_switch('photo_owner_change') && wppa_user_is('administrator'); $sortby_orderno = wppa_get_album_item($album, 'p_order_by') == '1' || wppa_get_album_item($album, 'p_order_by') == '-1'; echo "\n" . '<a id="photo_' . $id . '" ></a>'; echo '<div' . ' id="photoitem-' . $id . '"' . ' class="wppa-table-wrap"' . ' style="width:100%;position:relative;"' . ' >'; echo '<input' . ' type="hidden"' . ' id="photo-nonce-' . $id . '"' . ' value="' . wp_create_nonce('wppa_nonce_' . $id) . '"' . ' />'; echo "\n" . '<!-- Section 1 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>'; // -- Preview thumbnail --- echo '<tr>' . '<td>'; $src = wppa_get_thumb_url($id); $big = wppa_get_photo_url($id); if ($is_video) { reset($is_video); $big = str_replace('xxx', current($is_video), $big); echo '<a' . ' href="' . $big . '"' . ' target="_blank"' . ' title="' . esc_attr(__('Preview fullsize video', 'wp-photo-album-plus')) . '"' . ' >' . wppa_get_video_html(array('id' => $id, 'tagid' => 'video-' . $id, 'width' => '160', 'height' => '160' * wppa_get_videoy($id) / wppa_get_videox($id), 'controls' => false, 'use_thumb' => true)) . '</a>'; } else { if ($has_audio) { $big = wppa_fix_poster_ext($big, $id); $src = wppa_fix_poster_ext($src, $id); } echo '<a' . ' href="' . $big . '"' . ' target="_blank"' . ' title="' . esc_attr(__('Preview fullsize photo', 'wp-photo-album-plus')) . '"' . ' >' . '<img' . ' src="' . $src . '"' . ' alt="' . esc_attr($name) . '"' . ' style="max-width: 160px; vertical-align:middle;"' . ' />' . '</a>'; if ($has_audio) { $audio = wppa_get_audio_html(array('id' => $id, 'tagid' => 'audio-' . $id, 'width' => '160', 'controls' => true)); echo '<br />' . ($audio ? $audio : '<span style="color:red;">' . __('Audio disabled', 'wp-photo-album-plus') . '</span>'); } } echo '</td>'; echo '<td>' . 'ID = ' . $id . '. ' . __('Crypt:', 'wp-photo-album-plus') . ' ' . $crypt . '. ' . __('Filename:', 'wp-photo-album-plus') . ' ' . $filename . '. ' . __('Upload:', 'wp-photo-album-plus') . ' ' . wppa_local_date('', $timestamp) . ' ' . __('local time', 'wp-photo-album-plus') . '. ' . ($owner_editable ? '' : __('By:', 'wp-photo-album-plus') . ' ' . $owner); if ($owner_editable) { echo __('Owned by:', 'wp-photo-album-plus') . '<input' . ' type="text"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'owner\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'owner\', this )"' . ' value="' . $owner . '"' . ' />'; } echo ' ' . sprintf(__('Album: %d (%s).', 'wp-photo-album-plus'), $album, wppa_get_album_name($album)); // Modified if ($modified > $timestamp) { echo ' ' . __('Modified:', 'wp-photo-album-plus') . ' ' . wppa_local_date('', $modified) . ' ' . __('local time', 'wp-photo-album-plus'); } else { echo ' ' . __('Not modified', 'wp-photo-album-plus'); } echo '. ' . __('EXIF Date:', 'wp-photo-album-plus'); if (wppa_user_is('administrator')) { // Admin may edit exif date echo '<input' . ' type="text"' . ' style="width:125px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'exifdtm\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'exifdtm\', this )"' . ' value="' . $exifdtm . '"' . ' />'; } else { echo $exifdtm . '.'; } echo ' '; // Location if ($photo['location'] || wppa_switch('geo_edit')) { echo __('Location:', 'wp-photo-album-plus') . ' '; $loc = $location ? $location : '///'; $geo = explode('/', $loc); echo $geo['0'] . ' ' . $geo['1'] . '. '; if (wppa_switch('geo_edit')) { echo __('Lat:', 'wp-photo-album-plus') . '<input' . ' type="text"' . ' style="width:100px;"' . ' id="lat-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'lat\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'lat\', this );"' . ' value="' . $geo['2'] . '"' . ' />' . __('Lon:', 'wp-photo-album-plus') . '<input type="text"' . ' style="width:100px;"' . ' id="lon-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'lon\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'lon\', this );"' . ' value="' . $geo['3'] . '"' . ' />'; } } // Changeable p_order echo __('Photo sort order #:', 'wp-photo-album-plus'); if ($sortby_orderno && (!wppa_switch('porder_restricted') || wppa_user_is('administrator'))) { echo '<input' . ' type="text"' . ' id="porder-' . $id . '"' . ' value="' . $p_order . '"' . ' style="width:30px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'p_order\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'p_order\', this )"' . ' />' . ' '; } else { echo $p_order . '. '; } // Rating $entries = wppa_get_rating_count_by_id($id); if ($entries) { if (wppa_opt('rating_display_type') == 'likes') { echo __('Likes:', 'wp-photo-album-plus') . ' ' . $entries . '. '; } else { echo __('Rating:', 'wp-photo-album-plus') . ' ' . __('Entries:', 'wp-photo-album-plus') . ' ' . $entries . ', ' . __('Mean value:', 'wp-photo-album-plus') . ' ' . wppa_get_rating_by_id($id, 'nolabel') . '. '; } } else { echo __('No ratings for this photo.', 'wp-photo-album-plus') . ' '; } $dislikes = wppa_dislike_get($id); if ($dislikes) { echo '<span style="color:red" >' . sprintf(__('Disliked by %d visitors', 'wp-photo-album-plus'), $dislikes) . '. ' . '</span>'; } $pending = wppa_pendrat_get($id); if ($pending) { echo '<span style="color:orange" >' . sprintf(__('%d pending votes.', 'wp-photo-album-plus'), $pending) . ' ' . '</span>'; } // Views if (wppa_switch('track_viewcounts')) { echo __('Views', 'wp-photo-album-plus') . ': ' . $views . '. '; } // Clicks if (wppa_switch('track_clickcounts')) { echo __('Clicks', 'wp-photo-album-plus') . ': ' . $clicks . '. '; } // Status echo '<br />' . __('Status:', 'wp-photo-album-plus') . ' '; if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) { if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) { $dis = ' disabled="disabled"'; } else { $dis = ''; } $sel = ' selected="selected"'; echo '<select' . ' id="status-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'status\', this ); wppaPhotoStatusChange( ' . $id . ' );"' . ' >' . '<option value="pending"' . ($status == 'pending' ? $sel : '') . ' >' . __('Pending', 'wp-photo-album-plus') . '</option>' . '<option value="publish"' . ($status == 'publish' ? $sel : '') . ' >' . __('Publish', 'wp-photo-album-plus') . '</option>' . '<option value="featured"' . ($status == 'featured' ? $sel : '') . $dis . ' >' . __('Featured', 'wp-photo-album-plus') . '</option>' . '<option value="gold"' . ($status == 'gold' ? $sel : '') . $dis . ' >' . __('Gold', 'wp-photo-album-plus') . '</option>' . '<option value="silver"' . ($status == 'silver' ? $sel : '') . $dis . ' >' . __('Silver', 'wp-photo-album-plus') . '</option>' . '<option value="bronze"' . ($status == 'bronze' ? $sel : '') . $dis . ' >' . __('Bronze', 'wp-photo-album-plus') . '</option>' . '<option value="scheduled"' . ($status == 'scheduled' ? $sel : '') . $dis . ' >' . __('Scheduled', 'wp-photo-album-plus') . '</option>' . '<option value="private"' . ($status == 'private' ? $sel : '') . $dis . ' >' . __('Private', 'wp-photo-album-plus') . '</option>' . '</select>' . wppa_get_date_time_select_html('photo', $id, true); } else { echo '<input' . ' type="hidden"' . ' id="status-' . $id . '"' . ' value="' . $status . '"' . ' />'; if ($status == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($status == 'publish') { _e('Publish', 'wp-photo-album-plus'); } elseif ($status == 'featured') { _e('Featured', 'wp-photo-album-plus'); } elseif ($status == 'gold') { _e('Gold', 'wp-photo-album-plus'); } elseif ($status == 'silver') { _e('Silver', 'wp-photo-album-plus'); } elseif ($status == 'bronze') { _e('Bronze', 'wp-photo-album-plus'); } elseif ($status == 'scheduled') { _e('Scheduled', 'wp-photo-album-plus'); } elseif ($status == 'private') { _e('Private', 'wp-photo-album-plus'); } echo wppa_get_date_time_select_html('photo', $id, false) . '<span id="psdesc-' . $id . '" class="description" style="display:none;" >' . __('Note: Featured photos should have a descriptive name; a name a search engine will look for!', 'wp-photo-album-plus') . '</span>'; } echo ' '; // Update status field echo __('Remark:', 'wp-photo-album-plus') . ' ' . '<span' . ' id="photostatus-' . $id . '"' . ' style="font-weight:bold;color:#00AA00;"' . ' >' . ($is_video ? sprintf(__('Video %s is not modified yet', 'wp-photo-album-plus'), $id) : sprintf(__('Photo %s is not modified yet', 'wp-photo-album-plus'), $id)) . '</span>'; // New Line echo '<br />'; // --- Available files --- echo __('Available files:', 'wp-photo-album-plus') . ' '; // Source echo __('Source file:', 'wp-photo-album-plus') . ' '; $sp = wppa_get_source_path($id); if (is_file($sp)) { $ima = getimagesize($sp); echo $ima['0'] . ' x ' . $ima['1'] . ' px, ' . wppa_get_filesize($sp) . '. '; } else { echo __('Unavailable', 'wp-photo-album-plus') . '. '; } // Display echo ($is_video || $has_audio ? __('Poster file:', 'wp-photo-album-plus') : __('Display file:', 'wp-photo-album-plus')) . ' '; $dp = wppa_fix_poster_ext(wppa_get_photo_path($id), $id); if (is_file($dp)) { echo floor(wppa_get_photox($id)) . ' x ' . floor(wppa_get_photoy($id)) . ' px, ' . wppa_get_filesize($dp) . '. '; } else { echo '<span style="color:red;" >' . __('Unavailable', 'wp-photo-album-plus') . '. ' . '</span>'; } // Thumbnail if (!$is_video) { echo __('Thumbnail file:', 'wp-photo-album-plus') . ' '; $tp = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id); if (is_file($tp)) { echo floor(wppa_get_thumbx($id)) . ' x ' . floor(wppa_get_thumby($id)) . ' px, ' . wppa_get_filesize($tp) . '. '; } else { echo '<span style="color:red;" >' . __('Unavailable', 'wp-photo-album-plus') . '. ' . '</span>'; } } // New line echo '<br />'; // Video if ($b_is_video) { echo __('Video size:', 'wp-photo-album-plus') . ' ' . __('Width:', 'wp-photo-album-plus') . '<input' . ' style="width:50px;margin:0 4px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'videox\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'videox\', this )"' . ' value="' . $videox . '"' . ' />' . sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_width')) . __('Height:', 'wp-photo-album-plus') . '<input' . ' style="width:50px;margin:0 4px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'videoy\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'videoy\', this )"' . ' value="' . $videoy . '"' . ' />' . sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_height')) . ' ' . __('Formats:', 'wp-photo-album-plus') . ' '; $c = 0; foreach ($is_video as $fmt) { echo $fmt . ' ' . __('Filesize:', 'wp-photo-album-plus') . ' ' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($id))); $c++; if ($c == count($is_video)) { echo '. '; } else { echo ', '; } } } // Audio if ($b_has_audio) { echo __('Formats:', 'wp-photo-album-plus') . ' '; $c = 0; foreach ($has_audio as $fmt) { echo $fmt . ' ' . __('Filesize:', 'wp-photo-album-plus') . ' ' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($id))); $c++; if ($c == count($is_video)) { echo '. '; } else { echo ', '; } } } echo '</td>' . '</tr>' . '</tbody>' . '</table>'; echo "\n" . '<!-- Section 2 -->'; if (wppa_switch('enable_stereo') && !$is_multi || (!$is_multi || is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id)))) { echo '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>' . '<tr>' . '<td>'; // Stereo if (wppa_switch('enable_stereo') && !$is_multi) { echo __('Stereophoto:', 'wp-photo-album-plus') . ' ' . '<select' . ' id="stereo-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'stereo\', this )"' . ' >' . '<option value="0"' . ($stereo == '0' ? ' selected="selected"' : '') . ' >' . __('no stereo image or ready anaglyph', 'wp-photo-album-plus') . '</option>' . '<option value="1"' . ($stereo == '1' ? ' selected="selected"' : '') . ' >' . __('Left - right stereo image', 'wp-photo-album-plus') . '</option>' . '<option value="-1"' . ($stereo == '-1' ? ' selected="selected"' : '') . ' >' . __('Right - left stereo image', 'wp-photo-album-plus') . '</option>' . '</select>' . ' '; __('Images:', 'wp-photo-album-plus') . ' '; $files = glob(WPPA_UPLOAD_PATH . '/stereo/' . $id . '-*.*'); $c = 0; if (!empty($files)) { sort($files); foreach ($files as $file) { echo '<a href="' . str_replace(WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $file) . '" target="_blank" >' . basename($file) . '</a>'; $c++; if ($c == count($files)) { echo '. '; } else { echo ', '; } } } } // Watermark if (!$is_multi || is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id))) { echo __('Watermark:', 'wp-photo-album-plus') . ' '; if (wppa_switch('watermark_on')) { $user = wppa_get_user(); if (wppa_switch('watermark_user') || current_user_can('wppa_settings')) { echo '<select' . ' id="wmfsel_' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'wppa_watermark_file_' . $user . '\', this );"' . ' >' . wppa_watermark_file_select() . '</select>' . __('Pos:', 'wp-photo-album-plus') . ' ' . '<select' . ' id="wmpsel_' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'wppa_watermark_pos_' . $user . '\', this );"' . ' >' . wppa_watermark_pos_select() . '</select>' . '<input' . ' type="button"' . ' class="button-secundary"' . ' value="' . esc_attr(__('Apply watermark', 'wp-photo-album-plus')) . '"' . ' onclick="wppaTryWatermark( ' . $id . ' )"' . ' />'; } else { echo __('File:', 'wp-photo-album-plus') . ' ' . __($wmfile, 'wp-photo-album-plus') . ' '; if ($wmfile != '--- none ---') { echo __('Pos:', 'wp-photo-album-plus') . ' ' . $wmpos; } } echo '<img' . ' id="wppa-water-spin-' . $id . '"' . ' src="' . wppa_get_imgdir() . 'spinner.gif' . '"' . ' alt="Spin"' . ' style="visibility:hidden"' . ' />'; } else { echo __('Not configured', 'wp-photo-album-plus'); } echo ' '; } echo '</td>' . '</tr>' . '</tbody>' . '</table>'; } echo "\n" . '<!-- Section 3 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>' . '<tr>' . '<td>'; // --- Actions --- // Rotate if (!$b_is_video) { echo '<input' . ' type="button"' . ' onclick="wppaTryRotLeft( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate left', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryRot180( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate 180°', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryRotRight( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate right', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryFlip( ' . $id . ' )"' . ' value="' . esc_attr(__('Flip', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Remake displayfiles if (!$is_video) { echo '<input' . ' type="button"' . ' title="' . esc_attr(__('Remake display file and thumbnail file', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'remake\', this, ' . (wppa('front_edit') ? 'false' : 'true') . ' )"' . ' value="' . esc_attr(__('Remake files', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Remake thumbnail if (!$is_video) { echo '<input' . ' type="button"' . ' title=' . esc_attr(__('Remake thumbnail file', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'remakethumb\', this, ' . (wppa('front_edit') ? 'false' : 'true') . ' )"' . ' value="' . esc_attr(__('Remake thumbnail file', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Move/copy if (!$quick) { $max = wppa_opt('photo_admin_max_albums'); if (!$max || wppa_get_total_album_count() < $max) { // If not done yet, get the album options html with the current album excluded if (!isset($album_select[$album])) { $album_select[$album] = wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $album, 'selected' => '0', 'addpleaseselect' => true)); } echo __('Target album for copy/move:', 'wp-photo-album-plus') . '<select' . ' id="target-' . $id . '"' . ' >' . $album_select[$album] . '</select>'; } else { echo __('Target album for copy/move:', 'wp-photo-album-plus') . '<input' . ' id="target-' . $id . '"' . ' type="number"' . ' style="height:20px;"' . ' placeholder="' . __('Album id', 'wp-photo-album-plus') . '"' . ' />'; } echo ' '; echo '<input' . ' type="button"' . ' onclick="wppaTryMove( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? $mvt : $mpt) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryCopy( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? $cvt : $cpt) . '"' . ' />' . ' '; } // Delete if (!wppa('front_edit')) { echo '<input' . ' type="button"' . ' style="color:red;"' . ' onclick="wppaTryDelete( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? esc_attr(__('Delete video', 'wp-photo-album-plus')) : esc_attr(__('Delete photo', 'wp-photo-album-plus'))) . '"' . ' />' . ' '; } // Re-upload if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { echo '<input' . ' type="button"' . ' onclick="jQuery( \'#re-up-' . $id . '\' ).css( \'display\', \'inline-block\' )"' . ' value="' . esc_attr(__('Re-upload file', 'wp-photo-album-plus')) . '"' . ' />' . '<div id="re-up-' . $id . '" style="display:none" >' . '<form' . ' id="wppa-re-up-form-' . $id . '"' . ' onsubmit="wppaReUpload( event, ' . $id . ', \'' . $filename . '\' )"' . ' >' . '<input' . ' type="file"' . ' id="wppa-re-up-file-' . $id . '"' . ' />' . '<input' . ' type="submit"' . ' id="wppa-re-up-butn-' . $id . '"' . ' value="' . esc_attr(__('Upload', 'wp-photo-album-plus')) . '"' . ' />' . '</form>' . '</div>'; } // Refresh /* if ( ! wppa( 'front_edit' ) ) { echo '<input' . ' type="button"' . ' onclick="wppaReload( \'#photo_' . $id . '\')"' . ' value="' . esc_attr( __( 'Refresh page', 'wp-photo-album-plus' ) ) . '"' . ' />'; } */ echo '</td>' . '</tr>' . '</tbody>' . '</table>'; echo "\n" . '<!-- Section 4 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>'; // Name echo '<tr>' . '<td>' . __('Photoname:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' id="pname-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'name\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'name\', this );"' . ' value="' . esc_attr(stripslashes($name)) . '"' . ' />' . '</td>' . '<td>' . '</td>' . '</tr>'; // Description if (!wppa_switch('desc_is_restricted') || wppa_user_is('administrator')) { echo '<tr>' . '<td>' . __('Description:', 'wp-photo-album-plus') . '</td>'; if (wppa_switch('use_wp_editor')) { $alfaid = wppa_alfa_id($id); echo '<td>'; wp_editor($description, 'wppaphotodesc' . $alfaid, array('wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => true)); echo '</td>' . '<td>' . '<input' . ' type="button"' . ' class="button-secundary"' . ' value="' . esc_attr(__('Update Photo description', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', document.getElementById( \'wppaphotodesc' . $alfaid . '\' ), false, \'' . $alfaid . '\' )"' . ' />' . '<img' . ' id="wppa-photo-spin-' . $id . '"' . ' src="' . wppa_get_imgdir() . 'spinner.gif"' . ' style="visibility:hidden"' . ' />' . '</td>'; } else { echo '<td>' . '<textarea' . ' style="width:100%;height:60px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' . ' >' . $description . '</textarea>' . '</td>' . '<td>' . '</td>'; } echo '</tr>'; } else { echo '<tr>' . '<td>' . __('Description:', 'wp-photo-album-plus') . '</td>' . '<td>' . $description . '</td>' . '<td>' . '</td>' . '</tr>'; } // Tags echo '<tr>' . '<td>' . __('Tags:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' id="tags-' . $id . '"' . ' type="text"' . ' style="width:100%;"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'tags\', this )"' . ' value="' . $tags . '"' . ' />' . '<br />' . '<span class="description" >' . __('Separate tags with commas.', 'wp-photo-album-plus') . '</span>' . '</td>' . '<td>' . '<select' . ' onchange="wppaAddTag( this.value, \'tags-' . $id . '\' ); wppaAjaxUpdatePhoto( ' . $id . ', \'tags\', document.getElementById( \'tags-' . $id . '\' ) )"' . ' >'; $taglist = wppa_get_taglist(); if (is_array($taglist)) { echo '<option value="" >' . __('- select -', 'wp-photo-album-plus') . '</option>'; foreach ($taglist as $tag) { echo '<option value="' . $tag['tag'] . '" >' . $tag['tag'] . '</option>'; } } else { echo '<option value="0" >' . __('No tags yet', 'wp-photo-album-plus') . '</option>'; } echo '</select>' . '<br />' . '<span class="description" >' . __('Select to add', 'wp-photo-album-plus') . '</span>' . '</td>' . '</tr>'; // Custom if (wppa_switch('custom_fields')) { $custom = wppa_get_photo_item($photo['id'], 'custom'); if ($custom) { $custom_data = unserialize($custom); } else { $custom_data = array('', '', '', '', '', '', '', '', '', ''); } foreach (array_keys($custom_data) as $key) { if (wppa_opt('custom_caption_' . $key)) { echo '<tr>' . '<td>' . apply_filters('translate_text', wppa_opt('custom_caption_' . $key)) . '<small style="float:right" >' . '(w#cc' . $key . ')' . '</small>:' . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' id="custom_' . $key . '-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'custom_' . $key . '\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'custom_' . $key . '\', this );"' . ' value="' . esc_attr(stripslashes($custom_data[$key])) . '"' . '/>' . '</td>' . '<td>' . '<small>(w#cd' . $key . ')</small>' . '</td> ' . '</tr>'; } } } // -- Auto Page -- if (wppa_switch('auto_page') && (current_user_can('edit_posts') || current_user_can('edit_pages'))) { $appl = get_permalink(wppa_get_the_auto_page($id)); echo '<tr>' . '<td>' . __('Autopage Permalink:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<a href="' . $appl . '" target="_blank" >' . $appl . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // -- Link url -- if (!wppa_switch('link_is_restricted') || wppa_user_is('administrator')) { echo '<tr>' . '<td>' . __('Photo specific link url:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' id="pislink-' . $id . '"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'linkurl\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linkurl\', this )"' . ' value="' . esc_attr($linkurl) . '"' . ' />' . '</td>' . '<td>' . '<select' . ' id="pistarget-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linktarget\', this )"' . ' >' . '<option' . ' value="_self"' . ($linktarget == '_self' ? ' selected="selected"' : '') . ' >' . __('Same tab', 'wp-photo-album-plus') . '</option>' . '<option' . ' value="_blank"' . ($linktarget == '_blank' ? ' selected="selected"' : '') . ' >' . __('New tab', 'wp-photo-album-plus') . '</option>' . '</select>' . '<input' . ' type="button"' . ' onclick="window.open( jQuery( \'#pislink-' . $id . '\' ).val(), jQuery( \'#pistarget-' . $id . '\' ).val() );"' . ' value="' . __('Tryit!', 'wp-photo-album-plus') . '"' . ' />' . '</td>' . '</tr>'; // -- Link title -- echo '<tr>' . '<td>' . __('Photo specific link title:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'linktitle\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linktitle\', this )"' . ' value="' . esc_attr($linktitle) . '"' . ' />'; if (current_user_can('wppa_settings')) { echo '<br />' . '<span class="description" >' . __('If you want this link to be used, check \'PS Overrule\' checkbox in table VI.', 'wp-photo-album-plus') . '</span>'; } echo '</td>' . '<td>' . '</td>' . '</tr>'; } // -- Custom ALT field -- if (wppa_opt('alt_type') == 'custom') { echo '<tr>' . '<td>' . __('HTML Alt attribute:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'alt\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'alt\', this )"' . ' value="' . esc_attr($alt) . '"' . ' />' . '</td>' . '<td>' . '</td>' . '</tr>'; } // If Quick, skip the following items for speed and space if (!$quick) { // Shortcode if (current_user_can('edit_posts') || current_user_can('edit_pages')) { echo '<tr>' . '<td>' . __('Single image shortcode', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '[wppa type="photo" photo="' . $id . '"][/wppa]' . '</td>' . '<td>' . '<small>' . sprintf(__('See %s The documentation %s for more shortcode options.', 'wp-photo-album-plus'), '<a href="http://wppa.nl/shortcode-reference/" target="_blank" >', '</a>') . '</small>' . '</td>' . '</tr>'; } // Source permalink if (is_file(wppa_get_source_path($id))) { $spl = wppa_get_source_pl($id); echo '<tr>' . '<td>' . __('Permalink', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $spl . '" target="_blank" >' . $spl . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // High resolution url $hru = wppa_get_hires_url($id); echo '<tr>' . '<td>' . __('Hi resolution url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $hru . '" target="_blank" >' . $hru . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; // Display file if (is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id))) { $lru = wppa_fix_poster_ext(wppa_get_lores_url($id), $id); echo '<tr>' . '<td>' . __('Display file url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $lru . '" target="_blank" >' . $lru . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // Thumbnail if (is_file(wppa_fix_poster_ext(wppa_get_thumb_path($id), $id))) { $tnu = wppa_fix_poster_ext(wppa_get_tnres_url($id), $id); echo '<tr>' . '<td>' . __('Thumbnail file url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $tnu . '" target="_blank" >' . $tnu . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } } echo '</tbody>' . '</table>'; echo "\n" . '<!-- Section 5 -->'; // Comments $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s ORDER BY `timestamp` DESC", $id), ARRAY_A); if ($comments && !$quick) { echo '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<thead>' . '<tr style="font-weight:bold;" >' . '<td style="padding:0 4px;" >#</td>' . '<td style="padding:0 4px;" >User</td>' . '<td style="padding:0 4px;" >Time since</td>' . '<td style="padding:0 4px;" >Status</td>' . '<td style="padding:0 4px;" >Comment</td>' . '</tr>' . '</thead>' . '<tbody>'; foreach ($comments as $comment) { echo ' <tr id="com-tr-' . $comment['id'] . '" > <td style="padding:0 4px;" >' . $comment['id'] . '</td> <td style="padding:0 4px;" >' . $comment['user'] . '</td> <td style="padding:0 4px;" >' . wppa_get_time_since($comment['timestamp']) . '</td>'; if (current_user_can('wppa_comments') || current_user_can('wppa_moderate') || wppa_get_user() == $photo['owner'] && wppa_switch('owner_moderate_comment')) { $p = $comment['status'] == 'pending' ? 'selected="selected" ' : ''; $a = $comment['status'] == 'approved' ? 'selected="selected" ' : ''; $s = $comment['status'] == 'spam' ? 'selected="selected" ' : ''; $t = $comment['status'] == 'trash' ? 'selected="selected" ' : ''; echo '<td style="padding:0 4px;" >' . '<select' . ' id="com-stat-' . $comment['id'] . '"' . ' style=""' . ' onchange="wppaAjaxUpdateCommentStatus( ' . $id . ', ' . $comment['id'] . ', this.value );wppaSetComBgCol(' . $comment['id'] . ');"' . ' >' . '<option value="pending" ' . $p . '>' . __('Pending', 'wp-photo-album-plus') . '</option>' . '<option value="approved" ' . $a . '>' . __('Approved', 'wp-photo-album-plus') . '</option>' . '<option value="spam" ' . $s . '>' . __('Spam', 'wp-photo-album-plus') . '</option>' . '<option value="trash" ' . $t . '>' . __('Trash', 'wp-photo-album-plus') . '</option>' . '</select >' . '</td>'; } else { echo '<td style="padding:0 4px;" >'; if ($comment['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'approved') { _e('Approved', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'spam') { _e('Spam', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'trash') { _e('Trash', 'wp-photo-album-plus'); } echo '</td>'; } echo '<td style="padding:0 4px;" >' . $comment['comment'] . '</td> </tr>' . '<script>wppaSetComBgCol(' . $comment['id'] . ')</script>'; } echo '</tbody>' . '</table>'; } echo '<script>wppaPhotoStatusChange( ' . $id . ' )</script>' . '<div style="clear:both;"></div>' . '</div>' . '<div style="clear:both;margin-top:7px;"></div>'; } /* foreach photo */ wppa_admin_page_links($page, $pagesize, $count, $link); } /* photos not empty */ }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; global $wppa; $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; }