/** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     global $wppa;
     global $widget_content;
     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'] = 'bestof';
     $wppa['mocc']++;
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'count' => '1', 'sortby' => 'maxratingcount', 'display' => 'photo', 'period' => 'thisweek', 'maxratings' => 'yes', 'meanrat' => 'yes', 'ratcount' => 'yes', 'linktype' => 'none'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array($instance['linktype'], $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_bestof_widget_linkpage', __a('Best Of Photos'));
     $count = $instance['count'];
     $sortby = $instance['sortby'];
     $display = $instance['display'];
     $period = $instance['period'];
     $maxratings = $instance['maxratings'];
     $meanrat = $instance['meanrat'];
     $ratcount = $instance['ratcount'];
     $linktype = $instance['linktype'];
     $size = wppa_opt('wppa_widget_width');
     //		$data 			= wppa_get_the_bestof( $count, $period, $sortby, $display );
     $lineheight = wppa_opt('wppa_fontsize_widget_thumb') * 1.5;
     $widget_content = "\n" . '<!-- WPPA+ BestOf Widget start -->';
     $widget_content .= wppa_bestof_html(array('page' => $page, 'count' => $count, 'sortby' => $sortby, 'display' => $display, 'period' => $period, 'maxratings' => $maxratings, 'meanrat' => $meanrat, 'ratcount' => $ratcount, 'linktype' => $linktype, 'size' => $size, 'lineheight' => $lineheight));
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ BestOf Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'albnav');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'parent' => '0', 'skip' => 'yes'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = wppa_get_the_landing_page('album_navigator_widget_linkpage', __('Photo Albums', 'wp-photo-album-plus'));
     $parent = $instance['parent'];
     $skip = $instance['skip'];
     $widget_content = "\n" . '<!-- WPPA+ Album Navigator Widget start -->';
     $widget_content .= '<div style="width:100%; overflow:hidden; position:relative; left: -12px;" >';
     if ($parent == 'all') {
         $widget_content .= $this->do_album_navigator('0', $page, $skip, '');
         $widget_content .= $this->do_album_navigator('-1', $page, $skip, '');
     } elseif ($parent == 'owner') {
         $widget_content .= $this->do_album_navigator('0', $page, $skip, '', " AND ( `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ) ");
         $widget_content .= $this->do_album_navigator('-1', $page, $skip, '', " AND ( `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ) ");
     } else {
         $widget_content .= $this->do_album_navigator($parent, $page, $skip, '');
     }
     $widget_content .= '</div>';
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ Album Navigator Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     wppa('in_widget', false);
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     global $wppa_opt;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'lasten');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => '', 'albumenum' => '', 'timesince' => 'yes', 'display' => 'thumbs', 'includesubs' => 'no'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('lasten_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('lasten_widget_linkpage', __('Last Ten Uploaded Photos', 'wp-photo-album-plus'));
     $max = wppa_opt('lasten_count');
     $album = $instance['album'];
     $timesince = $instance['timesince'];
     $display = $instance['display'];
     $albumenum = $instance['albumenum'];
     $subs = $instance['includesubs'] == 'yes';
     switch ($album) {
         case '-99':
             // 'Multiple see below' is a list of id, seperated by comma's
             $album = str_replace(',', '.', $albumenum);
             if ($subs) {
                 $album = wppa_expand_enum(wppa_alb_to_enum_children($album));
             }
             $album = str_replace('.', ',', $album);
             break;
         case '0':
             // ---all---
             break;
         case '-2':
             // ---generic---
             $albs = $wpdb->get_results("SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = '0'", ARRAY_A);
             $album = '';
             foreach ($albs as $alb) {
                 $album .= '.' . $alb['id'];
             }
             $album = ltrim($album, '.');
             if ($subs) {
                 $album = wppa_expand_enum(wppa_alb_to_enum_children($album));
             }
             $album = str_replace('.', ',', $album);
             break;
         default:
             if ($subs) {
                 $album = wppa_expand_enum(wppa_alb_to_enum_children($album));
                 $album = str_replace('.', ',', $album);
             }
             break;
     }
     $album = trim($album, ',');
     // Eiter look at timestamp or at date/time modified
     $order_by = wppa_switch('lasten_use_modified') ? 'modified' : 'timestamp';
     // If you want only 'New' photos in the selection, the period must be <> 0;
     if (wppa_switch('lasten_limit_new') && wppa_opt('max_photo_newtime')) {
         $newtime = " `" . $order_by . "` >= " . (time() - wppa_opt('max_photo_newtime'));
         if ($album) {
             $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE (" . $newtime . ") AND `album` IN ( " . $album . " ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `" . $order_by . "` DESC LIMIT " . $max;
         } else {
             $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE (" . $newtime . ") AND `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `" . $order_by . "` DESC LIMIT " . $max;
         }
     } else {
         if ($album) {
             $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` IN ( " . $album . " ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `" . $order_by . "` DESC LIMIT " . $max;
         } else {
             $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `" . $order_by . "` DESC LIMIT " . $max;
         }
     }
     $thumbs = $wpdb->get_results($q, ARRAY_A);
     $widget_content = "\n" . '<!-- WPPA+ LasTen Widget start -->';
     $maxw = wppa_opt('lasten_size');
     $maxh = $maxw;
     $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
     $maxh += $lineheight;
     if ($timesince == 'yes') {
         $maxh += $lineheight;
     }
     $count = '0';
     if ($thumbs) {
         foreach ($thumbs as $image) {
             $thumb = $image;
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __('View the most recent uploaded photos', 'wp-photo-album-plus');
                 } else {
                     $tit = esc_attr(__(stripslashes($image['description'])));
                 }
                 $link = wppa_get_imglnk_a('lasten', $image['id'], '', $tit, '', $no_album, str_replace(',', '.', $album));
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ltthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 $widget_content .= wppa_get_the_widget_thumb('lasten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">';
                 if ($timesince == 'yes') {
                     $widget_content .= "\n\t" . '<div>' . wppa_get_time_since($image[$order_by]) . '</div>';
                 }
                 $widget_content .= '</div>';
             } else {
                 // No image
                 $widget_content .= __('Photo not found', 'wp-photo-album-plus');
             }
             $widget_content .= "\n" . '</div>';
             $count++;
             if ($count == wppa_opt('lasten_count')) {
                 break;
             }
         }
     } else {
         $widget_content .= __('There are no uploaded photos (yet)', 'wp-photo-album-plus');
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ LasTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     wppa('in_widget', false);
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'topten');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'mean_rating', 'title' => '', 'album' => '', 'display' => 'thumbs', 'meanrat' => 'yes', 'ratcount' => 'yes', 'viewcount' => 'yes', 'includesubs' => 'yes', 'medalsonly' => 'no', 'showowner' => 'no', 'showalbum' => 'no'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('topten_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('topten_widget_linkpage', __('Top Ten Photos', 'wp-photo-album-plus'));
     $albumlinkpage = wppa_get_the_landing_page('topten_widget_album_linkpage', __('Top Ten Photo album', 'wp-photo-album-plus'));
     $max = wppa_opt('topten_count');
     $album = $instance['album'];
     switch ($instance['sortby']) {
         case 'mean_rating':
             $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
             break;
         case 'rating_count':
             $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
             break;
         case 'views':
             $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
             break;
     }
     $display = $instance['display'];
     $meanrat = $instance['meanrat'] == 'yes';
     $ratcount = $instance['ratcount'] == 'yes';
     $viewcount = $instance['viewcount'] == 'yes';
     $includesubs = $instance['includesubs'] == 'yes';
     $albenum = '';
     $medalsonly = $instance['medalsonly'] == 'yes';
     $showowner = $instance['showowner'] == 'yes';
     $showalbum = $instance['showalbum'] == 'yes';
     wppa('medals_only', $medalsonly);
     $likes = wppa_opt('rating_display_type') == 'likes';
     // When likes only, mean rating has no meaning, chan to (rating)(like)count
     if ($likes && $instance['sortby'] == 'mean_rating') {
         $instance['sortby'] = 'rating_count';
     }
     // Album specified?
     if ($album) {
         // All albums ?
         if ($album == '-2') {
             $album = '0';
         }
         // Albums of owner is current logged in user or public?
         if ($album == '-3') {
             $temp = $wpdb->get_results("SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ORDER BY `id`", ARRAY_A);
             $album = '';
             if ($temp) {
                 foreach ($temp as $t) {
                     $album .= '.' . $t['id'];
                 }
                 $album = ltrim($album, '.');
             }
         }
         // Including subalbums?
         if ($includesubs) {
             $albenum = wppa_alb_to_enum_children($album);
             $albenum = wppa_expand_enum($albenum);
             $album = str_replace('.', ',', $albenum);
         }
         // Doit
         if ($medalsonly) {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN (" . $album . ") " . "AND `status` IN ( 'gold', 'silver', 'bronze' ) " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         } else {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN (" . $album . ") " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         }
     } else {
         if ($medalsonly) {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` IN ( 'gold', 'silver', 'bronze' ) " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         } else {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         }
     }
     $widget_content = "\n" . '<!-- WPPA+ TopTen Widget start -->';
     $maxw = wppa_opt('topten_size');
     $maxh = $maxw;
     $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
     $maxh += $lineheight;
     if ($meanrat) {
         $maxh += $lineheight;
     }
     if ($ratcount) {
         $maxh += $lineheight;
     }
     if ($viewcount) {
         $maxh += $lineheight;
     }
     if ($showowner) {
         $maxh += $lineheight;
     }
     if ($showalbum) {
         $maxh += $lineheight;
     }
     if ($thumbs) {
         foreach ($thumbs as $image) {
             $thumb = $image;
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __('View the top rated photos', 'wp-photo-album-plus');
                 } else {
                     $tit = esc_attr(__(stripslashes($image['description'])));
                 }
                 $compressed_albumenum = wppa_compress_enum($albenum);
                 $link = wppa_get_imglnk_a('topten', $image['id'], '', $tit, '', $no_album, $compressed_albumenum);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 $widget_content .= wppa_get_the_widget_thumb('topten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">';
                 // Display (owner) ?
                 if ($showowner) {
                     $widget_content .= '<div>(' . $image['owner'] . ')</div>';
                 }
                 // Display (album) ?
                 if ($showalbum) {
                     $href = wppa_convert_to_pretty(wppa_encrypt_url(wppa_get_album_url($image['album'], $albumlinkpage, 'content', '1')));
                     $widget_content .= '<div>(<a href="' . $href . '" >' . wppa_get_album_name($image['album']) . '</a>)</div>';
                 }
                 // Display the rating
                 if ($likes) {
                     $lt = wppa_get_like_title_a($image['id']);
                 }
                 switch ($instance['sortby']) {
                     case 'mean_rating':
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         break;
                     case 'rating_count':
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . ($likes ? $lt['display'] : sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n)) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         break;
                     case 'views':
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . ($likes ? $lt['display'] : sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n)) . '</div>';
                         }
                         break;
                 }
                 $widget_content .= '</div>';
             } else {
                 // No image
                 $widget_content .= __('Photo not found', 'wp-photo-album-plus');
             }
             $widget_content .= "\n" . '</div>';
         }
     } else {
         $widget_content .= __('There are no rated photos (yet)', 'wp-photo-album-plus');
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ TopTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     //wppa( 'in_widget', false );
     wppa_reset_occurrance();
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'com');
     wppa_bump_mocc();
     // Hide widget if not logged in and login required to see comments
     if (wppa_switch('comment_view_login') && !is_user_logged_in()) {
         return;
     }
     extract($args);
     $page = in_array(wppa_opt('comment_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_comment_widget_linkpage', __('Recently commented photos', 'wp-photo-album-plus'));
     $max = wppa_opt('comten_count');
     $widget_title = apply_filters('widget_title', $instance['title']);
     $photo_ids = wppa_get_comten_ids($max);
     $widget_content = "\n" . '<!-- WPPA+ Comment Widget start -->';
     $maxw = wppa_opt('comten_size');
     $maxh = $maxw + 18;
     if ($photo_ids) {
         foreach ($photo_ids as $id) {
             // Make the HTML for current comment
             $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             $image = wppa_cache_thumb($id);
             if ($image) {
                 $link = wppa_get_imglnk_a('comten', $id, '', '', true);
                 $file = wppa_get_thumb_path($id);
                 $imgstyle_a = wppa_get_imgstyle_a($id, $file, $maxw, 'center', 'comthumb');
                 $imgstyle = $imgstyle_a['style'];
                 $width = $imgstyle_a['width'];
                 $height = $imgstyle_a['height'];
                 $cursor = $imgstyle_a['cursor'];
                 $imgurl = wppa_get_thumb_url($id, '', $width, $height);
                 $imgevents = wppa_get_imgevents('thumb', $id, true);
                 $title = '';
                 $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s ORDER BY `timestamp` DESC", $id), ARRAY_A);
                 if ($comments) {
                     $first_comment = $comments['0'];
                     foreach ($comments as $comment) {
                         $title .= $comment['user'] . ' ' . __('wrote', 'wp-photo-album-plus') . ' ' . wppa_get_time_since($comment['timestamp']) . ":\n";
                         $title .= $comment['comment'] . "\n\n";
                     }
                 }
                 $title = esc_attr(strip_tags(trim($title)));
                 $album = '0';
                 $display = 'thumbs';
                 $widget_content .= wppa_get_the_widget_thumb('comten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
             } else {
                 $widget_content .= __('Photo not found.', 'wp-photo-album-plus');
             }
             $widget_content .= "\n\t" . '<span style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; cursor:pointer;" title="' . esc_attr($first_comment['comment']) . '" >' . $first_comment['user'] . '</span>';
             $widget_content .= "\n" . '</div>';
         }
     } else {
         $widget_content .= 'There are no commented photos (yet).';
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ comment Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     wppa('in_widget', false);
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => '', 'width' => wppa_opt('widget_width'), 'height' => round(wppa_opt('widget_width') * wppa_opt('maxheight') / wppa_opt('fullsize')), 'ponly' => 'no', 'linkurl' => '', 'linktitle' => '', 'subtext' => '', 'supertext' => '', 'valign' => 'center', 'timeout' => '4', 'film' => 'no', 'browse' => 'no', 'name' => 'no', 'numbar' => 'no', 'desc' => 'no'));
     $title = apply_filters('widget_title', $instance['title']);
     $album = $instance['album'];
     $width = $instance['width'];
     $height = $instance['height'];
     if ($height == '0') {
         $height = round($width * wppa_opt('maxheight') / wppa_opt('fullsize'));
     }
     $ponly = $instance['ponly'];
     $linkurl = $instance['linkurl'];
     $linktitle = $instance['linktitle'];
     $supertext = __($instance['supertext']);
     $subtext = __($instance['subtext']);
     $valign = $instance['valign'];
     $timeout = $instance['timeout'] * 1000;
     $film = $instance['film'];
     $browse = $instance['browse'];
     $name = $instance['name'];
     $numbar = $instance['numbar'];
     $desc = $instance['desc'];
     $page = in_array(wppa_opt('slideonly_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_slideonly_widget_linkpage', __('Widget landing page', 'wp-photo-album-plus'));
     if (is_numeric($album)) {
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title . $title . $after_title;
         }
         if ($linkurl != '' && wppa_opt('slideonly_widget_linktype') == 'widget') {
             wppa('in_widget_linkurl', $linkurl);
             wppa('in_widget_linktitle', __($linktitle));
         }
         if ($supertext != '') {
             echo '<div style="padding-top:2px; padding-bottom:4px; text-align:center">' . $supertext . '</div>';
         }
         echo '<div style="padding-top:2px; padding-bottom:4px;" >';
         wppa('auto_colwidth', false);
         wppa('in_widget', 'ss');
         wppa('in_widget_frame_height', $height);
         wppa('in_widget_frame_width', $width);
         wppa('in_widget_timeout', $timeout);
         wppa('portrait_only', $ponly == 'yes');
         wppa('ss_widget_valign', $valign);
         wppa('film_on', $film == 'yes');
         wppa('browse_on', $browse == 'yes');
         wppa('name_on', $name == 'yes');
         wppa('numbar_on', $numbar == 'yes');
         wppa('desc_on', $desc == 'yes');
         echo wppa_albums($album, 'slideonly', $width, 'center');
         wppa('desc_on', false);
         wppa('numbar_on', false);
         wppa('name_on', false);
         wppa('browse_on', false);
         wppa('film_on', false);
         wppa('ss_widget_valign', '');
         wppa('portrait_only', false);
         wppa('in_widget_timeout', '0');
         wppa('in_widget_frame_height', '');
         wppa('in_widget_frame_width', '');
         wppa('in_widget', false);
         wppa('fullsize', '');
         // Reset to prevent inheritage of wrong size in case widget is rendered before main column
         echo '</div>';
         if ($linkurl != '') {
             wppa('in_widget_linkurl', '');
             wppa('in_widget_linktitle', '');
         }
         if ($subtext != '') {
             echo '<div style="padding-top:2px; padding-bottom:0px; text-align:center">' . $subtext . '</div>';
         }
         echo $after_widget;
     } else {
         echo "\n" . $before_widget;
         if (!empty($widget_title)) {
             echo $before_title . $widget_title . $after_title;
         }
         echo __('No album defined (yet)', 'wp-photo-album-plus');
         echo $after_widget;
     }
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'tn');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => 'no', 'link' => '', 'linktitle' => '', 'name' => 'no', 'display' => 'thumbs', 'sortby' => wppa_get_photo_order('0'), 'limit' => wppa_opt('thumbnail_widget_count')));
     //		$widget_title 	= apply_filters('widget_title', $instance['title']);
     $widget_title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     $widget_link = $instance['link'];
     $page = in_array(wppa_opt('thumbnail_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_thumbnail_widget_linkpage', __('Thumbnail photos', 'wp-photo-album-plus'));
     $max = $instance['limit'];
     $sortby = $instance['sortby'];
     $album = $instance['album'];
     $name = $instance['name'];
     $display = $instance['display'];
     $linktitle = $instance['linktitle'];
     $generic = $album == '-2';
     if ($generic) {
         $album = '0';
         $max += '1000';
     }
     $separate = $album == '-1';
     if ($separate) {
         $album = '0';
         $max += '1000';
     }
     if ($album) {
         $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' AND `album` = %s " . $sortby . " LIMIT %d", $album, $max), 'ARRAY_A');
     } else {
         $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` <> 'pending' AND `status` <> 'scheduled'" . $sortby . " LIMIT %d", $max), 'ARRAY_A');
     }
     global $widget_content;
     $widget_content = "\n" . '<!-- WPPA+ thumbnail Widget start -->';
     $maxw = wppa_opt('thumbnail_widget_size');
     $maxh = $maxw;
     $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
     $maxh += $lineheight;
     if ($name == 'yes') {
         $maxh += $lineheight;
     }
     $count = '0';
     if ($thumbs) {
         foreach ($thumbs as $image) {
             $thumb = $image;
             if ($generic && wppa_is_separate($thumb['album'])) {
                 continue;
             }
             if ($separate && !wppa_is_separate($thumb['album'])) {
                 continue;
             }
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $link = wppa_get_imglnk_a('tnwidget', $image['id']);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'twthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 wppa_do_the_widget_thumb('thumbnail', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">';
                 if ($name == 'yes' && $display == 'thumbs') {
                     $widget_content .= "\n\t" . '<div>' . __(stripslashes($image['name']), 'wp-photo-album-plus') . '</div>';
                 }
                 $widget_content .= "\n\t" . '</div>';
             } else {
                 // No image
                 $widget_content .= __('Photo not found', 'wp-photo-album-plus');
             }
             $widget_content .= "\n" . '</div>';
             $count++;
             if ($count == $instance['limit']) {
                 break;
             }
         }
     } else {
         $widget_content .= __('There are no photos (yet)', 'wp-photo-album-plus');
     }
     $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;
         if (!empty($widget_link)) {
             echo "\n" . '<a href="' . $widget_link . '" title="' . $linktitle . '" >' . $widget_title . '</a>';
         } else {
             echo $widget_title;
         }
         echo $after_title;
     }
     echo $widget_content . $after_widget;
     wppa('in_widget', false);
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     global $wppa_opt;
     global $wppa;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => ''));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array($wppa_opt['wppa_featen_widget_linktype'], $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_featen_widget_linkpage', __a('Featured photos'));
     $max = $wppa_opt['wppa_featen_count'];
     $album = $instance['album'];
     $generic = $album == '-2';
     if ($generic) {
         $album = '0';
         $max += '1000';
     }
     if ($album) {
         $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status`= 'featured' AND `album` = %s ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, $album), ARRAY_A);
     } else {
         $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured' ORDER BY RAND(" . wppa_get_randseed() . ") DESC LIMIT " . $max, ARRAY_A);
     }
     $widget_content = "\n" . '<!-- WPPA+ FeaTen Widget start -->';
     $maxw = $wppa_opt['wppa_featen_size'];
     $maxh = $maxw;
     $lineheight = $wppa_opt['wppa_fontsize_widget_thumb'] * 1.5;
     $maxh += $lineheight;
     if (false) {
         $maxh += $lineheight;
     }
     $count = '0';
     if ($thumbs) {
         foreach ($thumbs as $image) {
             global $thumb;
             $thumb = $image;
             if ($generic && wppa_is_separate($thumb['album'])) {
                 continue;
             }
             // Make the HTML for current picture
             $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __a('View the featured photos', 'wppa_theme');
                 } else {
                     $tit = esc_attr(wppa_qtrans(stripslashes($image['description'])));
                 }
                 $link = wppa_get_imglnk_a('featen', $image['id'], '', $tit, '', $no_album);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb');
                 $imgstyle = $imgstyle_a['style'];
                 $width = $imgstyle_a['width'];
                 $height = $imgstyle_a['height'];
                 $cursor = $imgstyle_a['cursor'];
                 $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 if ($link) {
                     $title = esc_attr(stripslashes($link['title']));
                 } else {
                     $title = '';
                 }
                 $album = '0';
                 $display = 'thumbs';
                 $widget_content .= wppa_get_the_widget_thumb('featen', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
             } else {
                 // No image
                 $widget_content .= __a('Photo not found.', 'wppa_theme');
             }
             $widget_content .= "\n" . '</div>';
             $count++;
             if ($count == $wppa_opt['wppa_featen_count']) {
                 break;
             }
         }
     } else {
         $widget_content .= 'There are no featured photos (yet).';
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ FeaTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
 }
 /** @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;
 }
Example #10
0
function wppa_get_share_html($id, $key = '', $js = true)
{
    global $wppa_locale;
    $do_it = false;
    if (!wppa('is_slideonly') || $key == 'lightbox') {
        if (wppa_switch('share_on') && !wppa_in_widget()) {
            $do_it = true;
        }
        if (wppa_switch('share_on_widget') && wppa_in_widget()) {
            $do_it = true;
        }
        if (wppa_switch('share_on_lightbox')) {
            $do_it = true;
        }
    }
    if (!$do_it) {
        return '';
    }
    // The share url
    if (wppa_in_widget()) {
        if (wppa_opt('widget_sm_linktype') == 'home') {
            $share_url = home_url();
        } else {
            $share_url = get_permalink(wppa_get_the_landing_page('wppa_widget_sm_linkpage', __('Social media landing page', 'wp-photo-album-plus')));
            $alb = wppa_get_photo_item($id, 'album');
            $oc = wppa_opt('widget_sm_linkpage_oc');
            $share_url .= '?wppa-album=' . $alb . '&wppa-photo=' . $id . '&wppa-cover=0&wppa-occur=' . $oc;
            if (wppa_switch('share_single_image')) {
                $share_url .= '&wppa-single=1';
            }
        }
    } else {
        $share_url = wppa_get_image_page_url_by_id($id, wppa_switch('share_single_image'));
        $share_url = str_replace('&amp;', '&', $share_url);
    }
    // The share title
    $photo_name = wppa_get_photo_name($id);
    // The share description
    $photo_desc = wppa_html(wppa_get_photo_desc($id));
    $photo_desc = strip_shortcodes(wppa_strip_tags($photo_desc, 'all'));
    // The default description
    $site = str_replace('&amp;', __('and', 'wp-photo-album-plus'), get_bloginfo('name'));
    $see_on_site = sprintf(__('See this image on %s', 'wp-photo-album-plus'), $site);
    // The share image. Must be the fullsize image for facebook.
    // If you take the thumbnail, facebook takes a different image at random.
    $share_img = wppa_get_photo_url($id);
    // The icon size
    if (wppa_in_widget() && $key != 'lightbox' || $key == 'thumb') {
        $s = '16';
    } else {
        $s = wppa_opt('share_size');
    }
    // qr code
    if (wppa_switch('share_qr') && $key != 'thumb') {
        $src = 'http://api.qrserver.com/v1/create-qr-code/' . '?data=' . urlencode($share_url) . '&size=80x80' . '&color=' . trim(wppa_opt('qr_color'), '#') . '&bgcolor=' . trim(wppa_opt('qr_bgcolor'), '#');
        $qr = '<div style="float:left; padding:2px;" >' . '<img' . ' src="' . $src . '"' . ' title="' . esc_attr($share_url) . '"' . ' alt="' . __('QR code', 'wp-photo-album-plus') . '"' . ' />' . '</div>';
    } else {
        $qr = '';
    }
    // twitter share button
    if (wppa_switch('share_twitter')) {
        $tweet = urlencode($see_on_site) . ': ';
        $tweet_len = strlen($tweet) + '1';
        $tweet .= urlencode($share_url);
        // find first '/' after 'http( s )://' rest doesnt count for twitter chars
        $url_len = strpos($share_url, '/', 8) + 1;
        $tweet_len += $url_len > 1 ? $url_len : strlen($share_url);
        $rest_len = 140 - $tweet_len;
        if (wppa_switch('show_full_name')) {
            if ($rest_len > strlen($photo_name)) {
                $tweet .= ' ' . urlencode($photo_name);
                $rest_len -= strlen($photo_name);
                $rest_len -= '2';
            } else {
                $tweet .= ' ' . urlencode(substr($photo_name, 0, $rest_len)) . '...';
                $rest_len -= strlen(substr($photo_name, 0, $rest_len));
                $rest_len -= '5';
            }
        }
        if ($photo_desc) {
            if ($rest_len > strlen($photo_desc)) {
                $tweet .= ': ' . urlencode($photo_desc);
            } elseif ($rest_len > 8) {
                $tweet .= ': ' . urlencode(substr($photo_desc, 0, $rest_len)) . '...';
            }
        }
        $tw = '<div style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Tweet %s on Twitter', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="https://twitter.com/intent/tweet?text=' . $tweet . '"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'twitter.png"' . ' style="height:' . $s . 'px;vertical-align:top;"' . ' alt="' . esc_attr(__('Share on Twitter', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>';
    } else {
        $tw = '';
    }
    // Google
    if (wppa_switch('share_google')) {
        $go = '<div style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Share %s on Google+', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="https://plus.google.com/share?url=' . urlencode($share_url) . '"' . ' onclick="javascript:window.open( this.href, \\"\\", \\"menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600\\" );return false;"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'google.png"' . ' style="height:' . $s . 'px;vertical-align:top;"' . ' alt="' . esc_attr(__('Share on Google+', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>';
    } else {
        $go = '';
    }
    // Pinterest
    $desc = urlencode($see_on_site) . ': ' . urlencode($photo_desc);
    if (strlen($desc) > 500) {
        $desc = substr($desc, 0, 495) . '...';
    }
    if (wppa_switch('share_pinterest')) {
        $pi = '<div style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Share %s on Pinterest', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="http://pinterest.com/pin/create/button/?url=' . urlencode($share_url) . '&media=' . urlencode(str_replace('/thumbs/', '/', $share_img)) . '&description=' . $desc . '"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'pinterest.png" style="height:' . $s . 'px;vertical-align:top;"' . ' alt="' . esc_attr(__('Share on Pinterest', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>';
    } else {
        $pi = '';
    }
    // LinkedIn
    if (wppa_switch('share_linkedin') && $key != 'thumb' && $key != 'lightbox') {
        $li = '<script' . ' type="text/javascript"' . ' src="//platform.linkedin.com/in.js"' . ' >' . 'lang: ' . $wppa_locale . '</script>' . '<script' . ' type="IN/Share"' . ' data-url="' . urlencode($share_url) . '"' . ' data-counter="top"' . ' >' . '</script>';
        if ($js) {
            $li = str_replace('<', '[', $li);
        }
    } else {
        $li = '';
    }
    // Facebook
    $fb = '';
    $need_fb_init = false;
    $small = 'thumb' == $key;
    if ('lightbox' == $key) {
        if (wppa_switch('facebook_like') && wppa_switch('share_facebook')) {
            $lbs = 'max-width:62px; max-height:96px; overflow:show;';
        } else {
            $lbs = 'max-width:62px; max-height:64px; overflow:show;';
        }
    } else {
        $lbs = '';
    }
    // Share
    if (wppa_switch('share_facebook') && !wppa_switch('facebook_like')) {
        if ($small) {
            $fb .= '<div' . ' class="fb-share-button"' . ' style="float:left;"' . ' data-href="' . $share_url . '"' . ' data-type="icon"' . ' >' . '</div>';
        } else {
            $disp = wppa_opt('fb_display');
            if ('standard' == $disp) {
                $disp = 'button';
            }
            $fb .= '<div' . ' class="fb-share-button"' . ' style="float:left; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-type="' . $disp . '"' . ' >' . '</div>';
        }
        $need_fb_init = true;
    }
    // Like
    if (wppa_switch('facebook_like') && !wppa_switch('share_facebook')) {
        if ($small) {
            $fb .= '<div' . ' class="fb-like"' . ' style="float:left;"' . ' data-href="' . $share_url . '"' . ' data-layout="button"' . ' >' . '</div>';
        } else {
            $fb .= '<div' . ' class="fb-like"' . ' style="float:left; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-layout="' . wppa_opt('fb_display') . '"' . ' >' . '</div>';
        }
        $need_fb_init = true;
    }
    // Like and share
    if (wppa_switch('facebook_like') && wppa_switch('share_facebook')) {
        if ($small) {
            $fb .= '<div' . ' class="fb-like"' . ' style="float:left;"' . ' data-href="' . $share_url . '"' . ' data-layout="button"' . ' data-action="like"' . ' data-show-faces="false"' . ' data-share="true"' . ' >' . '</div>';
        } else {
            $fb .= '<div' . ' class="fb-like"' . ' style="float:left; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-layout="' . wppa_opt('fb_display') . '"' . ' data-action="like"' . ' data-show-faces="false"' . ' data-share="true"' . ' >' . '</div>';
        }
        $need_fb_init = true;
    }
    // Comments
    if (wppa_switch('facebook_comments') && !wppa_in_widget() && $key != 'thumb' && $key != 'lightbox') {
        $width = wppa('auto_colwidth') ? '100%' : wppa_get_container_width(true);
        if (wppa_switch('facebook_comments')) {
            $fb .= '<div style="color:blue;clear:both" >' . __('Comment on Facebook:', 'wp-photo-album-plus') . '</div>';
            $fb .= '<div class="fb-comments" data-href="' . $share_url . '" data-width=' . $width . '></div>';
            $need_fb_init = true;
        }
    }
    // Need init?
    if ($need_fb_init) {
        if ($js && $key != 'thumb') {
            $fb .= '[script>wppaFbInit();[/script>';
        } else {
            $fb .= '<script>wppaFbInit();</script>';
        }
    }
    return $qr . $tw . $go . $pi . $li . $fb . '<div style="clear:both"></div>';
}
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'topten');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'mean_rating', 'title' => '', 'album' => '', 'display' => 'thumbs', 'meanrat' => 'yes', 'ratcount' => 'yes', 'viewcount' => 'yes', 'includesubs' => 'yes', 'showowner' => 'no', 'showalbum' => 'no'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('topten_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_topten_widget_linkpage', __('Top Ten Photos', 'wp-photo-album-plus'));
     $albumlinkpage = wppa_get_the_landing_page('wppa_topten_widget_album_linkpage', __('Top Ten Photo album', 'wp-photo-album-plus'));
     $max = wppa_opt('topten_count');
     $album = $instance['album'];
     switch ($instance['sortby']) {
         case 'mean_rating':
             $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
             break;
         case 'rating_count':
             $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
             break;
         case 'views':
             $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
             break;
     }
     $display = $instance['display'];
     $meanrat = $instance['meanrat'] == 'yes';
     $ratcount = $instance['ratcount'] == 'yes';
     $viewcount = $instance['viewcount'] == 'yes';
     $includesubs = $instance['includesubs'] == 'yes';
     $albenum = '';
     $showowner = $instance['showowner'] == 'yes';
     $showalbum = $instance['showalbum'] == 'yes';
     if ($album) {
         if ($album == '-2') {
             $album = '0';
         }
         if ($includesubs) {
             $albenum = wppa_alb_to_enum_children($album);
             $albenum = wppa_expand_enum($albenum);
             $album = str_replace('.', ',', $albenum);
         }
         $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` IN (" . $album . ") ORDER BY " . $sortby . " LIMIT " . $max, ARRAY_A);
         //wppa_log('dbg', "SELECT * FROM `".WPPA_PHOTOS."` WHERE `album` IN (".$album.") ORDER BY " . $sortby . " LIMIT " . $max);
     } else {
         $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` ORDER BY " . $sortby . " LIMIT " . $max, ARRAY_A);
     }
     $widget_content = "\n" . '<!-- WPPA+ TopTen Widget start -->';
     $maxw = wppa_opt('topten_size');
     $maxh = $maxw;
     $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
     $maxh += $lineheight;
     if ($meanrat) {
         $maxh += $lineheight;
     }
     if ($ratcount) {
         $maxh += $lineheight;
     }
     if ($viewcount) {
         $maxh += $lineheight;
     }
     if ($showowner) {
         $maxh += $lineheight;
     }
     if ($showalbum) {
         $maxh += $lineheight;
     }
     if ($thumbs) {
         foreach ($thumbs as $image) {
             $thumb = $image;
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __('View the top rated photos', 'wp-photo-album-plus');
                 } else {
                     $tit = esc_attr(__(stripslashes($image['description'])));
                 }
                 $compressed_albumenum = wppa_compress_enum($albenum);
                 $link = wppa_get_imglnk_a('topten', $image['id'], '', $tit, '', $no_album, $compressed_albumenum);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 $widget_content .= wppa_get_the_widget_thumb('topten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">';
                 // Display (owner) ?
                 if ($showowner) {
                     $widget_content .= '<div>(' . $image['owner'] . ')</div>';
                 }
                 // Display (album) ?
                 if ($showalbum) {
                     $href = wppa_convert_to_pretty(wppa_get_album_url($image['album'], $albumlinkpage, 'content', '1'));
                     $widget_content .= '<div>(<a href="' . $href . '" >' . wppa_get_album_name($image['album']) . '</a>)</div>';
                 }
                 $rating = wppa_get_rating_by_id($image['id']);
                 switch ($instance['sortby']) {
                     case 'mean_rating':
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         break;
                     case 'rating_count':
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         break;
                     case 'views':
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         break;
                 }
                 $widget_content .= '</div>';
             } else {
                 // No image
                 $widget_content .= __('Photo not found.', 'wp-photo-album-plus');
             }
             $widget_content .= "\n" . '</div>';
         }
     } else {
         $widget_content .= 'There are no rated photos (yet).';
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ TopTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     wppa('in_widget', false);
 }
Example #12
0
    /** @see WP_Widget::widget */
    function widget($args, $instance)
    {
        global $wpdb;
        require_once dirname(__FILE__) . '/wppa-links.php';
        require_once dirname(__FILE__) . '/wppa-styles.php';
        require_once dirname(__FILE__) . '/wppa-functions.php';
        require_once dirname(__FILE__) . '/wppa-thumbnails.php';
        require_once dirname(__FILE__) . '/wppa-boxes-html.php';
        require_once dirname(__FILE__) . '/wppa-slideshow.php';
        wppa_initialize_runtime();
        wppa('in_widget', 'upldr');
        wppa_bump_mocc();
        extract($args);
        $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'name', 'ignore' => 'admin', 'parent' => ''));
        $widget_title = apply_filters('widget_title', $instance['title']);
        $page = in_array('album', wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_upldr_widget_linkpage', __('User uploaded photos', 'wp-photo-album-plus'));
        $ignorelist = explode(',', $instance['ignore']);
        $upldrcache = wppa_get_upldr_cache();
        $needupdate = false;
        $users = wppa_get_users();
        $workarr = array();
        $selalbs = str_replace('.', ',', wppa_expand_enum(wppa_alb_to_enum_children(wppa_expand_enum($instance['parent']))));
        // Make the data we need
        if ($users) {
            foreach ($users as $user) {
                if (!in_array($user['user_login'], $ignorelist)) {
                    $me = wppa_get_user();
                    if ($user['user_login'] != $me && isset($upldrcache[$this->get_widget_id()][$user['user_login']]['c'])) {
                        $photo_count = $upldrcache[$this->get_widget_id()][$user['user_login']]['c'];
                    } else {
                        if ($instance['parent']) {
                            $query = $wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND `album` IN (" . $selalbs . ") AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", $user['user_login'], $me);
                            //);
                        } else {
                            $query = $wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s )", $user['user_login'], $me);
                            //);
                        }
                        $photo_count = $wpdb->get_var($query);
                        if ($user['user_login'] != $me) {
                            $upldrcache[$this->get_widget_id()][$user['user_login']]['c'] = $photo_count;
                            $needupdate = true;
                        }
                    }
                    if ($photo_count) {
                        if ($user['user_login'] != $me && isset($upldrcache[$this->get_widget_id()][$user['user_login']]['d'])) {
                            $last_dtm = $upldrcache[$this->get_widget_id()][$user['user_login']]['d'];
                        } else {
                            if ($instance['parent']) {
                                $last_dtm = $wpdb->get_var($wpdb->prepare("SELECT `timestamp` FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND `album` IN (" . $selalbs . ") AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT 1", $user['user_login'], $me));
                            } else {
                                $last_dtm = $wpdb->get_var($wpdb->prepare("SELECT `timestamp` FROM `" . WPPA_PHOTOS . "` WHERE `owner` = %s AND ( ( `status` <> 'pending' AND `status` <> 'scheduled' ) OR `owner` = %s ) ORDER BY `timestamp` DESC LIMIT 1", $user['user_login'], $me));
                            }
                        }
                        if ($user['user_login'] != $me) {
                            $upldrcache[$this->get_widget_id()][$user['user_login']]['d'] = $last_dtm;
                            $needupdate = true;
                        }
                        $workarr[] = array('login' => $user['user_login'], 'name' => $user['display_name'], 'count' => $photo_count, 'date' => $last_dtm);
                    }
                }
            }
        } else {
            $widget_content = __('There are too many registered users in the system for this widget', 'wp-photo-album-plus');
            echo "\n" . $before_widget;
            if (!empty($widget_title)) {
                echo $before_title . $widget_title . $after_title;
            }
            echo $widget_content . $after_widget;
            return;
        }
        if ($needupdate) {
            update_option('wppa_upldr_cache', $upldrcache);
        }
        // Bring me to top
        $myline = false;
        if (is_user_logged_in()) {
            $me = wppa_get_user();
            foreach (array_keys($workarr) as $key) {
                $user = $workarr[$key];
                if ($user['login'] == $me) {
                    $myline = $workarr[$key];
                    unset($workarr[$key]);
                }
            }
        }
        // Sort workarray
        $ord = $instance['sortby'] == 'name' ? SORT_ASC : SORT_DESC;
        $workarr = wppa_array_sort($workarr, $instance['sortby'], $ord);
        // Create widget content
        $widget_content = "\n" . '<!-- WPPA+ Upldr Widget start -->';
        $widget_content .= '<div class="wppa-upldr" style="max-height:180px; overflow:auto"><table><tbody>';
        $albs = $instance['parent'] ? wppa_alb_to_enum_children(wppa_expand_enum($instance['parent'])) : '';
        $a = $albs ? wppa_trim_wppa_('&amp;wppa-album=' . $albs) : '';
        if ($myline) {
            $user = $myline;
            $widget_content .= '<tr class="wppa-user" >
									<td style="padding: 0 3px;" ><a href="' . wppa_get_upldr_link($user['login']) . $a . '" title="' . __('Photos uploaded by', 'wp-photo-album-plus') . ' ' . $user['name'] . '" ><b>' . $user['name'] . '</b></a></td>
									<td style="padding: 0 3px;" ><b>' . $user['count'] . '</b></td>
									<td style="padding: 0 3px;" ><b>' . wppa_get_time_since($user['date']) . '</b></td>
								</tr>';
        }
        foreach ($workarr as $user) {
            $widget_content .= '<tr class="wppa-user" >
									<td style="padding: 0 3px;" ><a href="' . wppa_get_upldr_link($user['login']) . $a . '" title="' . __('Photos uploaded by', 'wp-photo-album-plus') . ' ' . $user['name'] . '" >' . $user['name'] . '</a></td>
									<td style="padding: 0 3px;" >' . $user['count'] . '</td>
									<td style="padding: 0 3px;" >' . wppa_get_time_since($user['date']) . '</td>
								</tr>';
        }
        $widget_content .= '</tbody></table></div>';
        $widget_content .= '<div style="clear:both"></div>';
        $widget_content .= "\n" . '<!-- WPPA+ Upldr Widget end -->';
        // Output
        echo "\n" . $before_widget;
        if (!empty($widget_title)) {
            echo $before_title . $widget_title . $after_title;
        }
        echo $widget_content . $after_widget;
        wppa('in_widget', false);
    }
 /** @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);
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     global $wppa;
     $wppa['in_widget'] = 'potd';
     $wppa['mocc']++;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     extract($args);
     $widget_title = apply_filters('widget_title', $instance['title']);
     // get the photo  ($image)
     $image = wppa_get_potd();
     // Make the HTML for current picture
     $widget_content = "\n" . '<!-- WPPA+ Photo of the day Widget start -->';
     $ali = wppa_opt('wppa_potd_align');
     if ($ali != 'none') {
         $align = 'text-align:' . $ali . ';';
     } else {
         $align = '';
     }
     $widget_content .= "\n" . '<div class="wppa-widget-photo" style="' . $align . ' padding-top:2px; ">';
     if ($image) {
         $id = $image['id'];
         $w = wppa_opt('wppa_potd_widget_width');
         $ratio = wppa_get_photoy($id) / wppa_get_photox($id);
         $h = round($w * $ratio);
         $usethumb = wppa_use_thumb_file($id, wppa_opt('wppa_widget_width'), '0');
         $imgurl = wppa_fix_poster_ext($usethumb ? wppa_get_thumb_url($id, '', $w, $h) : wppa_get_photo_url($id, '', $w, $h), $id);
         $name = wppa_get_photo_name($id);
         $page = in_array(wppa_opt('wppa_widget_linktype'), $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_widget_linkpage', __a('Photo of the day'));
         $link = wppa_get_imglnk_a('potdwidget', $id);
         $is_video = wppa_is_video($id);
         $has_audio = wppa_has_audio($id);
         if ($link['is_lightbox']) {
             $lightbox = ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($id)) . '"' . ' data-videonatwidth="' . wppa_get_videox($id) . '"' . ' data-videonatheight="' . wppa_get_videoy($id) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($id)) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '"';
         } else {
             $lightbox = '';
         }
         if ($link) {
             if ($link['is_lightbox']) {
                 $cursor = ' cursor:url(' . wppa_get_imgdir() . wppa_opt('wppa_magnifier') . '),pointer;';
                 $title = wppa_zoom_in($id);
                 $ltitle = wppa_get_lbtitle('potd', $id);
             } else {
                 $cursor = ' cursor:pointer;';
                 $title = $link['title'];
                 $ltitle = $title;
             }
         } else {
             $cursor = ' cursor:default;';
             $title = esc_attr(stripslashes(__($image['name'])));
         }
         // The medal if on top
         $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top'));
         // The link, if any
         if ($link) {
             $widget_content .= "\n\t" . '<a href = "' . $link['url'] . '" target="' . $link['target'] . '" ' . $lightbox . ' ' . wppa('lbtitle') . '="' . $ltitle . '">';
         }
         // The image
         if (wppa_is_video($id)) {
             $widget_content .= "\n\t\t" . wppa_get_video_html(array('id' => $id, 'width' => wppa_opt('wppa_potd_widget_width'), 'title' => $title, 'controls' => wppa_opt('widget_linktype') == 'none', 'cursor' => $cursor));
         } else {
             $widget_content .= '<img' . ' src="' . $imgurl . '"' . ' style="width: ' . wppa_opt('wppa_potd_widget_width') . 'px;' . $cursor . '"' . ' ' . wppa_get_imgalt($id) . ($title ? 'title="' . $title . '"' : '') . '/ >';
         }
         // Close the link
         if ($link) {
             $widget_content .= "\n\t" . '</a>';
         }
         // The medal if at the bottom
         $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot'));
         // Audio
         if (wppa_has_audio($id)) {
             $widget_content .= wppa_get_audio_html(array('id' => $id, 'width' => wppa_opt('wppa_potd_widget_width'), 'controls' => true));
         }
     } else {
         // No image
         $widget_content .= __a('Photo not found.', 'wppa_theme');
     }
     $widget_content .= "\n" . '</div>';
     // Add subtitle, if any
     switch (wppa_opt('wppa_widget_subtitle')) {
         case 'none':
             break;
         case 'name':
             if ($image && $image['name'] != '') {
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_name($id) . '</div>';
             }
             break;
         case 'desc':
             if ($image && $image['description'] != '') {
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_desc($id) . '</div>';
             }
             break;
         case 'owner':
             if ($image) {
                 $owner = $image['owner'];
                 $user = get_user_by('login', $owner);
                 $owner = $user->display_name;
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . __a('By:') . ' ' . $owner . '</div>';
             }
     }
     $widget_content .= "\n" . '<!-- WPPA+ Photo of the day Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     $wppa['in_widget'] = false;
 }
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     global $wppa_opt;
     global $wppa;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     $wppa['in_widget'] = 'lasten';
     $wppa['mocc']++;
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'album' => '', 'albumenum' => '', 'timesince' => 'yes', 'display' => 'thumbs'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array($wppa_opt['wppa_lasten_widget_linktype'], $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_lasten_widget_linkpage', __a('Last Ten Uploaded Photos'));
     //		$page 		= $wppa_opt['wppa_lasten_widget_linkpage'];
     $max = $wppa_opt['wppa_lasten_count'];
     $album = $instance['album'];
     $timesince = $instance['timesince'];
     $display = $instance['display'];
     $albumenum = $instance['albumenum'];
     $generic = $album == '-2';
     if ($generic) {
         $album = '0';
         $max += '1000';
     }
     if ($album == '-99') {
         $album = implode("' OR `album` = '", explode(',', $albumenum));
     }
     // If you want only 'New' photos in the selection, the period must be <> 0;
     if (wppa_switch('wppa_lasten_limit_new') && wppa_opt('wppa_max_photo_newtime')) {
         $newtime = " `timestamp` >= " . (time() - wppa_opt('wppa_max_photo_newtime'));
         if ($album) {
             $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE (" . $newtime . ") AND ( `album` = '" . $album . "' ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `timestamp` DESC LIMIT " . $max;
         } else {
             $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE (" . $newtime . ") AND `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `timestamp` DESC LIMIT " . $max;
         }
     } else {
         if ($album) {
             $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE ( `album` = '" . $album . "' ) AND ( `status` <> 'pending' AND `status` <> 'scheduled' ) ORDER BY `timestamp` DESC LIMIT " . $max;
         } else {
             $q = "SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `timestamp` DESC LIMIT " . $max;
         }
     }
     // echo $q;
     $thumbs = $wpdb->get_results($q, ARRAY_A);
     $widget_content = "\n" . '<!-- WPPA+ LasTen Widget start -->';
     $maxw = $wppa_opt['wppa_lasten_size'];
     $maxh = $maxw;
     $lineheight = $wppa_opt['wppa_fontsize_widget_thumb'] * 1.5;
     $maxh += $lineheight;
     if ($timesince == 'yes') {
         $maxh += $lineheight;
     }
     $count = '0';
     if ($thumbs) {
         foreach ($thumbs as $image) {
             global $thumb;
             $thumb = $image;
             if ($generic && wppa_is_separate($thumb['album'])) {
                 continue;
             }
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __a('View the most recent uploaded photos', 'wppa_theme');
                 } else {
                     $tit = esc_attr(wppa_qtrans(stripslashes($image['description'])));
                 }
                 $link = wppa_get_imglnk_a('lasten', $image['id'], '', $tit, '', $no_album, $albumenum);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ltthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 $widget_content .= wppa_get_the_widget_thumb('lasten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . $wppa_opt['wppa_fontsize_widget_thumb'] . 'px; line-height:' . $lineheight . 'px;">';
                 if ($timesince == 'yes') {
                     $widget_content .= "\n\t" . '<div>' . wppa_get_time_since($image['timestamp']) . '</div>';
                 }
                 $widget_content .= '</div>';
             } else {
                 // No image
                 $widget_content .= __a('Photo not found.', 'wppa_theme');
             }
             $widget_content .= "\n" . '</div>';
             $count++;
             if ($count == $wppa_opt['wppa_lasten_count']) {
                 break;
             }
         }
     } else {
         $widget_content .= 'There are no uploaded photos (yet).';
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ LasTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     $wppa['in_widget'] = false;
 }
function wppa_get_multitag_html($nperline = '2', $seltags = '')
{
    global $wppa;
    $or_only = wppa_switch('tags_or_only');
    $page = wppa_get_the_landing_page('wppa_multitag_linkpage', __a('Multi Tagged photos'));
    $result = '';
    if (wppa_opt('wppa_multitag_linkpage')) {
        $hr = wppa_get_permalink($page);
        if (wppa_opt('wppa_multitag_linktype') == 'album') {
            $hr .= 'wppa-album=0&wppa-cover=0&wppa-occur=1';
        }
        if (wppa_opt('wppa_multitag_linktype') == 'slide') {
            $hr .= 'wppa-album=0&wppa-cover=0&wppa-occur=1&slide';
        }
    } else {
        return __a('Please select a multitag landing page in Table VI-C4b');
    }
    $tags = wppa_get_taglist();
    $result .= '
	<script type="text/javascript">
	function wppaProcessMultiTagRequest() {
	var any = false;
	var url="' . $hr . '&wppa-tag=";';
    if ($or_only) {
        $result .= '
		var andor = "or";';
    } else {
        $result .= '
		var andor = "and";
			if ( document.getElementById( "andoror-' . $wppa['mocc'] . '" ).checked ) andor = "or";
		var sep;';
    }
    $result .= '
	if ( andor == "and" ) sep = ","; else sep = ";";
	';
    $selarr = $seltags ? explode(',', $seltags) : array();
    if ($tags) {
        foreach ($tags as $tag) {
            if (!$seltags || in_array($tag['tag'], $selarr)) {
                $result .= '
			if ( document.getElementById( "wppa-' . str_replace(' ', '_', $tag['tag']) . '" ).checked ) {
				url+="' . str_replace(' ', '%20', $tag['tag']) . '"+sep;
				any = true;
			}';
            }
        }
    }
    $result .= '
	if ( any ) document.location = url;
	else alert ( "' . __a('Please check the tag(s) that the photos must have') . '" );
	}</script>
	';
    $qtag = wppa_get_get('tag');
    $andor = $or_only ? 'or' : 'and';
    // default
    if (strpos($qtag, ',')) {
        $querystringtags = explode(',', wppa_get_get('tag'));
    } elseif (strpos($qtag, ';')) {
        $querystringtags = explode(';', wppa_get_get('tag'));
        $andor = 'or';
    } else {
        $querystringtags = wppa_get_get('tag');
    }
    if ($tags) {
        if (!$or_only) {
            $result .= '<table class="wppa-multitag-table">' . '<tr>' . '<td>' . '<input' . ' class="radio"' . ' name="andor-' . wppa('mocc') . '"' . ' value="and"' . ' id="andorand-' . wppa('mocc') . '"' . ' type="radio"' . ($andor == 'and' ? ' checked="checked"' : '') . ' />' . '&nbsp;' . __a('And', 'wppa_theme') . '</td>' . '<td>' . '<input' . ' class="radio"' . ' name="andor-' . wppa('mocc') . '"' . ' value="or"' . ' id="andoror-' . wppa('mocc') . '"' . ' type="radio"' . ($andor == 'or' ? ' checked="checked"' : '') . ' />' . '&nbsp;' . __a('Or', 'wppa_theme') . '</td>' . '</tr>' . '</table>';
        }
        $count = '0';
        $checked = '';
        $tropen = false;
        $result .= '<table class="wppa-multitag-table">';
        foreach ($tags as $tag) {
            if (!$seltags || in_array($tag['tag'], $selarr)) {
                if ($count % $nperline == '0') {
                    $result .= '<tr>';
                    $tropen = true;
                }
                if (is_array($querystringtags)) {
                    $checked = in_array($tag['tag'], $querystringtags) ? 'checked="checked"' : '';
                }
                $result .= '<td' . ' style="' . __wis('padding-right:4px;') . '"' . ' >' . '<input' . ' type="checkbox"' . ' id="wppa-' . str_replace(' ', '_', $tag['tag']) . '"' . ' ' . $checked . ' />' . '&nbsp;' . str_replace(' ', '&nbsp;', $tag['tag']) . '</td>';
                $count++;
                if ($count % $nperline == '0') {
                    $result .= '</tr>';
                    $tropen = false;
                }
            }
        }
        if ($tropen) {
            while ($count % $nperline != '0') {
                $result .= '<td></td>';
                $count++;
            }
            $result .= '</tr>';
        }
        $result .= '</table>';
        $result .= '<input' . ' type="button"' . ' onclick="wppaProcessMultiTagRequest()"' . ' value="' . __a('Find!') . '"' . ' />';
    }
    return $result;
}