/** @see WP_Widget::widget */ function widget($args, $instance) { global $widget_content; 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', 'tagcloud'); wppa_bump_mocc(); extract($args); $instance = wp_parse_args((array) $instance, array('title' => __('Photo Tags', 'wp-photo-album-plus'), 'tags' => array())); if (empty($instance['tags'])) { $instance['tags'] = array(); } $widget_title = apply_filters('widget_title', $instance['title']); // Display the widget echo $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo '<div class="wppa-tagcloud-widget" >' . wppa_get_tagcloud_html(implode(',', $instance['tags']), wppa_opt('tagcloud_min'), wppa_opt('tagcloud_max')) . '</div>'; echo '<div style="clear:both"></div>'; echo $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', 'stereo'); wppa_bump_mocc(); extract($args); $instance = wp_parse_args((array) $instance, array('title' => __('3D Stereo Settings', 'wp-photo-album-plus'))); $widget_title = apply_filters('widget_title', $instance['title']); $widget_content = "\n" . '<!-- WPPA+ stereo Widget start -->'; $widget_content .= wppa_get_stereo_html(); $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ stereo 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 $widget_content; 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('mocc', wppa('mocc') + 1); wppa('in_widget', 'search'); extract($args); $instance = wp_parse_args((array) $instance, array('title' => __('Search Photos', 'wp-photo-album-plus'), 'label' => '', 'root' => false, 'sub' => false, 'album' => '', 'landingpage' => '0')); $widget_title = apply_filters('widget_title', $instance['title']); // Display the widget echo $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo wppa_get_search_html($instance['label'], $instance['sub'], $instance['root'], $instance['album'], $instance['landingpage']); echo $after_widget; wppa('in_widget', false); }
function wppa_get_video_html($args) { extract(wp_parse_args((array) $args, array('id' => '0', 'width' => '0', 'height' => '0', 'controls' => true, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'video-' . wppa('mocc'), 'cursor' => '', 'events' => '', 'title' => '', 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => '', 'use_thumb' => false, 'autoplay' => false))); // No id? no go if (!$id) { return ''; } // Not a video? no go if (!wppa_is_video($id)) { return ''; } extract(wp_parse_args((array) wppa_is_video($id), array('mp4' => false, 'ogv' => false, 'webm' => false))); // Prepare attributes $w = $width ? ' width:' . $width . 'px;' : ''; $h = $height ? ' height:' . $height . 'px;' : ''; $t = $margin_top ? ' margin-top:' . $margin_top . 'px;' : ''; $b = $margin_bottom ? ' margin-bottom:' . $margin_bottom . 'px;' : ''; $ctrl = $controls ? ' controls' : ''; $tit = $title ? ' title="' . $title . '"' : ''; $onc = $onclick ? ' onclick="' . $onclick . '"' : ''; $cls = $class ? ' class="' . $class . '"' : ''; $style = $style ? rtrim(trim($style), ';') . ';' : ''; $play = $autoplay ? ' autoplay' : ''; // See if there is a poster image $poster_photo_path = wppa_fix_poster_ext(wppa_get_photo_path($id), $id); $poster_thumb_path = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id); $poster_photo = is_file($poster_photo_path) ? ' poster="' . wppa_fix_poster_ext(wppa_get_photo_url($id), $id) . '"' : ''; $poster_thumb = is_file($poster_thumb_path) ? ' poster="' . wppa_fix_poster_ext(wppa_get_thumb_url($id), $id) . '"' : ''; $poster = ''; // Init to none // Thumbnail? if ($use_thumb) { $poster = $poster_thumb; } else { $poster = $poster_photo; } // If the poster exists and no controls, we need no preload at all. if ($poster && !$controls) { $preload = 'none'; } // Do we have html5 video tag supported filetypes on board? if ($mp4 || $ogv || $webm) { // Assume the browser supports html5 $result = '<video id="' . $tagid . '" ' . $ctrl . $play . ' style="' . $style . $w . $h . $t . $b . $cursor . '" ' . $events . ' ' . $tit . $onc . $poster . ' preload="' . $preload . '"' . $cls . ' >'; $result .= wppa_get_video_body($id, false, $width, $height); // Close the video tag $result .= '</video>'; } // Done return $result; }
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' => '0')); $title = apply_filters('widget_title', $instance['title']); $album = $instance['album']; if (!$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %d", $album))) { $album = '0'; // Album vanished } wppa_user_upload(); // Do the upload if required wppa('in_widget', 'upload'); wppa_bump_mocc(); $mocc = wppa('mocc'); $is_responsive = wppa_opt('colwidth') == 'auto'; if ($is_responsive) { // Responsive widgetwppaAutoColumnWidth[1] = true; $js = wppa_get_responsive_widget_js_html($mocc); } else { $js = ''; } $create = wppa_get_user_create_html($album, wppa_opt('widget_width'), 'widget'); $upload = wppa_get_user_upload_html($album, wppa_opt('widget_width'), 'widget', $is_responsive); if (!$create && !$upload) { return; } // Nothing to do $text = '<div id="wppa-container-' . $mocc . '" class="wppa-upload-widget" style="margin-top:2px; margin-left:2px;" >' . $js . $create . $upload . '</div>'; echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } echo $text; echo '<div style="clear:both"></div>'; echo $after_widget; wppa('in_widget', false); }
function widget($args, $instance) { 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' => __('WPPA+ Text', 'wp-photo-album-plus'), 'text' => '', 'loggedinonly' => false)); if ($instance['loggedinonly'] && !is_user_logged_in()) { return; } $title = apply_filters('widget_title', $instance['title']); wppa('in_widget', 'gp'); wppa_bump_mocc(); // Open the widget echo $before_widget; // Title optional if (!empty($title)) { echo $before_title . $title . $after_title; } // Body $text = $instance['text']; if ($instance['filter']) { // Do wpautop BEFORE do_shortcode $text = wpautop($text); } $text = do_shortcode($text); $text = apply_filters('widget_text', $text); // If shortcode at wppa filter priority, insert result. See wppa-filter.php echo '<div class="wppa-gp-widget" style="margin-top:2px; margin-left:2px;" >' . $text . '</div>'; echo '<div style="clear:both"></div>'; // Close widget echo $after_widget; wppa('in_widget', false); wppa('fullsize', ''); // Reset to prevent inheritage of wrong size in case widget is rendered before main column }
/** @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 $widget_content; 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' => '', 'root' => '0', 'sort' => true)); $widget_title = apply_filters('widget_title', $instance['title']); $album_root = $instance['root']; $sort = $instance['sort']; wppa('in_widget', 'superview'); wppa_bump_mocc(); $widget_content = wppa_get_superview_html($album_root, $sort); wppa('in_widget', false); echo $before_widget . $before_title . $widget_title . $after_title . $widget_content . $after_widget; }
function wppa_get_audio_html($args) { // Audio enabled? if (!wppa_switch('enable_audio')) { return ''; } extract(wp_parse_args((array) $args, array('id' => '0', 'width' => '0', 'height' => '0', 'controls' => true, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'audio-' . wppa('mocc'), 'cursor' => '', 'events' => '', 'title' => '', 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => '', 'use_thumb' => false, 'autoplay' => false))); // No id? no go if (!$id) { return ''; } // Not a audio? no go if (!wppa_has_audio($id)) { return ''; } extract(wp_parse_args((array) wppa_has_audio($id), array('mp3' => false, 'wav' => false, 'ogg' => false))); // Prepare attributes $w = $width ? ' width:' . $width . 'px;' : ''; $h = $height ? ' height:' . $height . 'px;' : ''; $t = $margin_top ? ' margin-top:' . $margin_top . 'px;' : ''; $b = $margin_bottom ? ' margin-bottom:' . $margin_bottom . 'px;' : ''; $ctrl = $controls ? ' controls' : ''; $tit = $title ? ' title="' . $title . '"' : ''; $onc = $onclick ? ' onclick="' . $onclick . '"' : ''; $cls = $class ? ' class="' . $class . '"' : ''; $style = $style ? rtrim(trim($style), ';') . ';' : ''; $play = $autoplay ? ' autoplay' : ''; // Do we have html5 audio tag supported filetypes on board? if ($mp3 || $wav || $ogg) { // Assume the browser supports html5 $result = '<audio' . ' id="' . $tagid . '"' . ' data-from="wppa"' . ' ' . $ctrl . $play . ' style="' . $style . $w . $h . $t . $b . $cursor . '"' . ' ' . $events . ' ' . $tit . $onc . ' preload="' . $preload . '"' . $cls . ' >'; $result .= wppa_get_audio_body($id, false, $width, $height); // Close the audio tag $result .= '</audio>'; } // Done return $result; }
/** @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', 'bestof'); wppa_bump_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', __('Best Of Photos', 'wp-photo-album-plus')); $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('widget_width'); // $data = wppa_get_the_bestof( $count, $period, $sortby, $display ); $lineheight = wppa_opt('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; wppa('in_widget', false); }
function wppa_get_lbtitle($type, $id) { if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_lbtitle( ' . $id . ' )', 'red'); } $thumb = wppa_cache_thumb($id); $do_download = wppa_is_video($id) ? false : wppa_switch('art_monkey_on_lightbox'); $do_name = wppa_switch('ovl_' . $type . '_name') || wppa_switch('ovl_add_owner'); $do_desc = wppa_switch('ovl_' . $type . '_desc'); $do_sm = wppa_switch('share_on_lightbox'); $result = ''; if ($do_download) { if (wppa_opt('art_monkey_display') == 'button') { $result .= '<input' . ' type="button"' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer; margin-bottom:0px; max-width:500px;"' . ' class="wppa-download-button"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', ' . $id . ' );"' . ' value="' . __('Download:', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')) . '"' . ' />'; } else { $result .= '<a' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer;"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', ' . $id . ' );"' . ' >' . __('Download:', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')) . '</a>'; } } else { if ($do_name) { $result .= wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')); } } if ($do_name && $do_desc) { $result .= '<br />'; } if ($do_desc) { $result .= wppa_get_photo_desc($thumb['id']); } if (($do_name || $do_desc) && $do_sm) { $result .= '<br />'; } if ($do_sm) { $result .= wppa_get_share_html($thumb['id'], 'lightbox'); } $result = esc_attr($result); return $result; }
function wppa_do_filmthumb($id, $idx, $do_for_feed = false, $glue = false) { $thumb = wppa_cache_thumb($id); $result = ''; $src = wppa_fix_poster_ext(wppa_get_thumb_path($thumb['id']), $thumb['id']); $max_size = wppa_opt('thumbsize'); if (wppa_in_widget()) { $max_size /= 2; } $com_alt = wppa('is_comten') && wppa_switch('comten_alt_display') && !wppa_in_widget(); $imgattr_a = wppa_get_imgstyle_a($thumb['id'], $src, $max_size, 'optional', 'fthumb'); $imgstyle = $imgattr_a['style']; $imgwidth = $imgattr_a['width']; $imgheight = $imgattr_a['height']; $cursor = $imgattr_a['cursor']; $url = wppa_fix_poster_ext(wppa_get_thumb_url($thumb['id'], '', $imgwidth, $imgheight), $thumb['id']); $furl = str_replace('/thumbs', '', $url); $events = wppa_get_imgevents('film', $thumb['id'], 'nopopup', $idx); $thumbname = wppa_get_photo_name($thumb['id']); $target = wppa_switch('film_blank') || $thumb['linktarget'] == '_blank' ? 'target="_blank" ' : ''; $psotitle = $thumb['linktitle'] ? 'title="' . esc_attr($thumb['linktitle']) . '" ' : ''; $psourl = wppa_switch('film_overrule') && $thumb['linkurl'] ? 'href="' . $thumb['linkurl'] . '" ' . $target . $psotitle : ''; $imgalt = wppa_get_imgalt($thumb['id']); if (wppa_opt('film_linktype') == 'lightbox') { // $title = esc_attr( wppa_zoom_in( $thumb['id'] ) ); } else { $events .= ' onclick="wppaGotoKeepState( ' . wppa('mocc') . ', ' . $idx . ' )"'; $events .= ' ondblclick="wppaStartStop( ' . wppa('mocc') . ', -1 )"'; } if (is_feed()) { if ($do_for_feed) { $style_a = wppa_get_imgstyle_a($thumb['id'], $src, '100', '4', 'thumb'); $style = $style_a['style']; $result .= '<a href="' . get_permalink() . '">' . '<img' . ' src="' . $url . '"' . ' ' . $imgalt . ' title="' . $thumbname . '"' . ' style="' . $style . '"' . ' />' . '</a>'; } } else { // If ! $do_for_feed: pre-or post-ambule. To avoid dup id change it in that case $tmp = $do_for_feed ? 'film' : 'pre'; $style = $glue ? 'style="' . wppa_get_thumb_frame_style($glue, 'film') . '"' : ''; $result .= '<div' . ' id="' . $tmp . '_wppatnf_' . $thumb['id'] . '_' . wppa('mocc') . '"' . ' class="thumbnail-frame"' . ' ' . $style . ' >'; if ($psourl) { // True only when pso activated and data present $result .= '<a ' . $psourl . '>'; // $psourl contains url, target and title } elseif (wppa_opt('film_linktype') == 'lightbox' && $tmp == 'film') { $title = wppa_get_lbtitle('slide', $thumb['id']); $videohtml = esc_attr(wppa_get_video_body($thumb['id'])); $audiohtml = esc_attr(wppa_get_audio_body($thumb['id'])); $result .= '<a href="' . $furl . '"' . ($videohtml ? ' data-videohtml="' . $videohtml . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($audiohtml ? ' data-audiohtml="' . $audiohtml . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[occ' . wppa('mocc') . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' >'; } if ($tmp == 'pre' && wppa_opt('film_linktype') == 'lightbox') { $cursor = 'cursor:default;'; } if ($tmp == 'film' && !$com_alt && !wppa_cdn('front') && !wppa_switch('lazy_or_htmlcomp')) { $result .= '<!--'; } if (wppa_is_video($thumb['id'])) { $result .= wppa_get_video_html(array('id' => $thumb['id'], 'width' => $imgattr_a['width'], 'height' => $imgattr_a['height'], 'controls' => false, 'margin_top' => $imgattr_a['margin-top'], 'margin_bottom' => $imgattr_a['margin-bottom'], 'cursor' => $imgattr_a['cursor'], 'events' => $events, 'tagid' => 'wppa-' . $tmp . '-' . $idx . '-' . wppa('mocc'))); } else { $result .= '<img' . ' id="wppa-' . $tmp . '-' . $idx . '-' . wppa('mocc') . '"' . ' class="wppa-' . $tmp . '-' . wppa('mocc') . '"' . ' src="' . $url . '"' . ' ' . $imgalt . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' data-title="' . ($psourl ? esc_attr($thumb['linktitle']) : '') . '"' . ' />'; } if ($tmp == 'film' && !$com_alt && !wppa_cdn('front') && !wppa_switch('lazy_or_htmlcomp')) { $result .= '-->'; } if ($psourl) { // True only when pso activated and data present $result .= '</a>'; // $psourl contains url, target and title } elseif (wppa_opt('film_linktype') == 'lightbox' && $tmp == 'film') { $result .= '</a>'; } $result .= '</div>'; } wppa_out($result); }
/** @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); }
function wppa_kickoff() { global $wppa_lang; global $wppa_api_version; global $wppa_init_js_data; global $wppa_dynamic_css_data; // init.css failed? if ($wppa_dynamic_css_data) { echo $wppa_dynamic_css_data; } // init.js failed? if ($wppa_init_js_data) { echo $wppa_init_js_data; } /* Obsolete? // Patch for chrome or Edge? // Test for chrome needs also test for NOT Edge, because browser signature of Edge also reports that it is chrome(-like) if ( false && isset($_SERVER["HTTP_USER_AGENT"] ) ) { echo ' <!-- WPPA+ Kickoff --> <!-- Browser detected = '.wppa_decode_uri_component(strip_tags($_SERVER["HTTP_USER_AGENT"])).' -->'; if ( strstr($_SERVER["HTTP_USER_AGENT"], 'Chrome') && ! strstr($_SERVER["HTTP_USER_AGENT"], 'Edge') && wppa_switch( 'ovl_chrome_at_top') ) echo ' <style type="text/css"> #wppa-overlay-ic { padding-top: 5px !important; } #wppa-overlay-qt-img { top: 5px !important; } </style>'; if ( strstr($_SERVER["HTTP_USER_AGENT"], 'Edge') ) echo ' <style type="text/css"> #wppa-overlay-ic { padding-top: 0px !important; } #wppa-overlay-qt-img { top: 5px !important; } </style>'; } */ // Inline styles? if (wppa_switch('inline_css')) { echo ' <!-- WPPA+ Custom styles --> <style type="text/css" >'; if (!wppa_switch('ovl_fs_icons')) { echo '#wppa-norms-btn, #wppa-fulls-btn { display:none; }'; } echo wppa_opt('custom_style') . ' </style>'; } // Pinterest js if ((wppa_switch('share_on') || wppa_switch('share_on_widget')) && wppa_switch('share_pinterest')) { echo ' <!-- Pinterest share --> <script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>'; } if (wppa('debug')) { error_reporting(wppa('debug')); add_action('wp_footer', 'wppa_phpinfo'); add_action('wp_footer', 'wppa_errorlog'); echo ' <script type="text/javascript" > wppaDebug = true; </script>'; } wppa('rendering_enabled', true); echo ' <!-- Rendering enabled --> <!-- /WPPA Kickoff --> '; }
function wppa_is_wanted_empty($thumbs) { if (!wppa_switch('show_empty_thumblist')) { return false; } // Feature not enabled if (is_array($thumbs) && count($thumbs) > wppa_get_mincount()) { return false; } // Album is not empty if (wppa_is_virtual()) { return false; } // wanted empty only on real albums if (wppa('albums_only')) { return false; } // Explicitly no thumbs // if ( wppa_switch( 'thumbs_first' ) && wppa_get_curpage() != '1' ) return false; // Only on page 1 if thumbs first wppa('current_album', wppa('start_album')); // Make sure upload knows the album return true; }
/** @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; } }
function wppa_get_ss_to_tn_link($page = '0', $id = '0') { global $thumbs; global $thumbs_ids; // Search ? if (wppa('src') && wppa('mocc') == '1' && !wppa('is_related')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-searchstring=' . stripslashes(wppa('searchstring')); } elseif (wppa('is_upldr')) { if (wppa('start_album')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-upldr=' . wppa('is_upldr') . '&wppa-album=' . wppa('start_album'); } else { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-upldr=' . wppa('is_upldr'); } } elseif (wppa('is_topten')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-topten=' . wppa('topten_count') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_lasten')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-lasten=' . wppa('lasten_count') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_comten')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-comten=' . wppa('comten_count') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_featen')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-featen=' . wppa('featen_count') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_tag')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-tag=' . wppa('is_tag') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_cat')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-cat=' . wppa('is_cat') . '&wppa-album=' . wppa('start_album'); } else { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-album=' . wppa('start_album'); } // $id is the id. See to what page we have to go $page = '1'; $p = wppa_opt('thumb_page_size'); if ($p) { $i = '0'; foreach ($thumbs_ids as $ti) { // $thumbs_ids is setup in function wppa_prepare_slideshow_pagination() if ($id == $ti) { $page = floor($i / $p) + '1'; } $i++; } if ($page > '1') { $thumbhref .= '&wppa-page=' . $page; } } // Make sure the clicked photos thumb is highligted $thumbhref .= '&wppa-hilite=' . $id; $thumbhref = wppa_convert_to_pretty(wppa_trim_wppa_($thumbhref)); return $thumbhref; }
function wppa_get_lbtitle($type, $id) { if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_lbtitle( ' . $id . ' )', 'red'); } $thumb = wppa_cache_thumb($id); $do_download = wppa_is_video($id) ? false : wppa_switch('art_monkey_on_lightbox'); if ($type == 'xphoto') { $type = 'mphoto'; } $do_name = wppa_switch('ovl_' . $type . '_name') || wppa_switch('ovl_add_owner'); $do_desc = wppa_switch('ovl_' . $type . '_desc'); $do_sm = wppa_switch('share_on_lightbox'); $result = ''; if ($do_download) { if (wppa_opt('art_monkey_display') == 'button') { $result .= '<input' . ' type="button"' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer; margin-bottom:0px; max-width:500px;"' . ' class="wppa-download-button wppa-ovl-button"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', \'' . wppa_encrypt_photo($id) . '\' );"' . ' value="' . rtrim(__('Download', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'))) . '"' . ' />'; } else { $result .= '<a' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer;"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', \'' . wppa_encrypt_photo($id) . '\' );"' . ' >' . rtrim(__('Download', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'))) . '</a>'; } } else { if ($do_name) { $result .= wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')); } } if ($do_name && $do_desc) { $result .= '<br />'; } if ($do_desc) { $result .= wppa_get_photo_desc($thumb['id']); } if (($do_name || $do_desc) && $do_sm) { $result .= '<br />'; } if (wppa_opt('rating_max') != '1' && wppa_opt('rating_display_type') == 'graphic') { $result .= wppa_get_rating_range_html($id, true); } elseif (wppa_opt('rating_display_type') == 'likes' && wppa_switch('ovl_rating')) { $result .= wppa_get_slide_rating_vote_only('always', $id, 'is_lightbox'); } if ($do_sm) { $result .= wppa_get_share_html($thumb['id'], 'lightbox'); } if (wppa_may_user_fe_edit($id)) { if ($type == 'slide') { $parg = esc_js('\'' . wppa_encrypt_photo($id) . '\''); } else { $parg = '\'' . wppa_encrypt_photo($id) . '\''; } if (wppa_opt('upload_edit') == 'classic') { $result .= ' <input' . ' type="button"' . ' style="float:right; margin-right:6px;"' . ' class="wppa-ovl-button"' . ' onclick="' . ($type == 'slide' ? '_wppaStop( ' . wppa('mocc') . ' );' : '') . 'wppaEditPhoto( ' . wppa('mocc') . ', ' . $parg . ' );"' . ' value="' . esc_attr(__(wppa_opt('fe_edit_button'))) . '"' . ' />'; } } $result = esc_attr($result); return $result; }
/** @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); }
function wppa_errorbox($text) { wppa_out('<div' . ' id="error-' . wppa('mocc') . '"' . ' class="wppa-box wppa-box-text wppa-nav wppa-errorbox"' . ' style="text-align: center; ' . __wcs('wppa-box') . __wcs('wppa-box-text') . __wcs('wppa-nav') . '"' . ' >' . $text . '</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', '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(); }
function wppa_crumb_ancestors($alb, $to_cover) { global $wpdb; // Find parent $parent = wppa_get_parentalbumid($alb); if ($parent < '1') { return; } // No parent -> toplevel -> done. wppa_crumb_ancestors($parent, $to_cover); // Find the album specific link type ( content, slide, page or none ) $slide = wppa_get_album_title_linktype($parent) == 'slide' ? '&wppa-slide' : ''; // NOT SLIDE when there are no photos if (!wppa_get_photo_count($parent, 'use_treecounts')) { $slide = ''; } $pagid = $wpdb->get_var($wpdb->prepare("SELECT `cover_linkpage` FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent)); wppa_dbg_q('Q-bc3'); $value = wppa_get_album_name($parent); $href = wppa_get_permalink($pagid) . 'wppa-album=' . $parent . '&wppa-cover=' . $to_cover . $slide . '&wppa-occur=' . wppa('occur'); $title = __('Album:', 'wp-photo-album-plus') . ' ' . wppa_get_album_name($parent); $class = 'b20'; wppa_bcitem($value, $href, $title, $class); return; }
function wppa_add_to_cart($atts) { global $post; $thumb = wppa('current_photo'); extract(shortcode_atts(array('name' => wppa_get_photo_name($thumb['id']), 'price' => 0.01, 'qty_field' => '', 'b_title' => __('Buy now', 'wp-photo-album-plus'), 'options' => '', 'options_name' => '', 'qty_field' => '', 'fshipping' => '', 'weight' => ''), $atts)); $cart =& $_SESSION['wfcart']; // load the cart from the session $scabn_options = get_option('scabn_options'); $currency = apply_filters('scabn_display_currency_symbol', NULL); // Slideshow? if (wppa('is_slide')) { $action_url = wppa_get_slide_callback_url($thumb['id']); $item_url = $action_url . '&wppa-single=1'; $action_url = wppa_convert_to_pretty($action_url); $item_url = wppa_convert_to_pretty($item_url); } else { $action_url = wppa_get_thumb_callback_url(); if (!strpos($action_url, '&')) { $action_url = str_replace('&', '&', $action_url); } $item_url = wppa_get_slide_callback_url($thumb['id']) . '&wppa-single=1'; $action_url = wppa_convert_to_pretty($action_url); $item_url = wppa_convert_to_pretty($item_url); } $output = ' <div class="wppa-addtocart"> <form method="post" class="wppa-cartform ' . $name . '" action="' . $action_url . '"> ' . wp_nonce_field('add_to_cart', 'scabn-add', false, false) . ' <input type="hidden" value="add_item" name="action" /> <input type="hidden" class="item_url" value="' . $item_url . '" name="item_url" /> <input type="hidden" value="' . $cart->random() . '" name="randomid" /> <input type="hidden" value="' . $name . '" name="item_id" /> <input type="hidden" class="item_name" value="' . $name . '" name="item_name" /> <input type="hidden" class="item_price" value="' . $price . '" name="item_price" />'; if ($fshipping) { $output .= ' <input type="hidden" class="item_shipping" value="' . $fshipping . '" name="item_shipping" />'; } if ($weight) { $output .= ' <input type="hidden" class="item_weight" value="' . $weight . '" name="item_weight" />'; } if ($options) { if ($options_name) { $output .= $options_name . ': '; } $output .= ' <input type="hidden" value="' . $options_name . '" name="item_options_name" class="item_options_name" />'; $item_options = explode(',', $options); $output .= ' <select style="max-width:200px; margin:0" name="item_options" class="item_options" >'; foreach ($item_options as $option) { $info = explode(':', $option); if (count($info) == 1) { $output .= ' <option value="' . $info[0] . '">' . $info[0] . ' (' . $currency . number_format($price, 2) . ')</option>'; } else { $output .= ' <option value="' . $info[0] . ':' . $info[1] . '">' . $info[0] . ' (' . $currency . number_format($info[1], 2) . ')</option>'; } } $output .= ' </select>'; } else { $output .= sprintf(__('Unit Price: %s each', 'wp-photo-album-plus'), $currency . number_format($price, 2)) . ' '; } if ($qty_field) { $output .= __('Qty:', 'wp-photo-album-plus') . ' <input type="text" style="max-width:50px; margin:0;" class="item_qty" value="1" size="2" name="item_qty" />'; } else { $output .= '<input type="hidden" class="item_qty" value="1" size="2" name="item_qty" />'; } $output .= ' <input type="submit" id="' . $name . '" class="add" name="add" value="' . $b_title . '"/> </form> </div>'; return $output; }
/** @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); }
function wppa_get_photo_desc($id, $do_shortcodes = false, $do_geo = false) { // Verify args if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_photo_desc( ' . $id . ' )', 'red'); return ''; } // Get data $thumb = wppa_cache_thumb($id); $desc = $thumb['description']; // Raw data $desc = stripslashes($desc); // Unescape $desc = __($desc); // qTranslate // To prevent recursive rendering of scripts or shortcodes: $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc); // Geo if ($thumb['location'] && !wppa('in_widget') && strpos(wppa_opt('custom_content'), 'w#location') !== false && $do_geo == 'do_geo') { wppa_do_geo($id, $thumb['location']); } // Other keywords if (strpos($desc, 'w#') !== false) { // Is there any 'w#' ? // Keywords $desc = str_replace('w#albumname', wppa_get_album_name($thumb['album']), $desc); $desc = str_replace('w#albumid', $thumb['album'], $desc); $keywords = array('name', 'filename', 'owner', 'id', 'tags', 'views', 'album'); foreach ($keywords as $keyword) { $replacement = __(trim(stripslashes($thumb[$keyword]))); if ($replacement == '') { $replacement = '‹' . __a('none', 'wppa') . '›'; } $desc = str_replace('w#' . $keyword, $replacement, $desc); } $desc = str_replace('w#url', wppa_get_lores_url($id), $desc); $desc = str_replace('w#hrurl', esc_attr(wppa_get_hires_url($id)), $desc); $desc = str_replace('w#tnurl', wppa_get_tnres_url($id), $desc); $desc = str_replace('w#pl', wppa_get_source_pl($id), $desc); // Art monkey sizes if (strpos($desc, 'w#amx') !== false || strpos($desc, 'w#amy') !== false || strpos($desc, 'w#amfs') !== false) { $amxy = wppa_get_artmonkey_size_a($id); if (is_array($amxy)) { $desc = str_replace('w#amx', $amxy['x'], $desc); $desc = str_replace('w#amy', $amxy['y'], $desc); $desc = str_replace('w#amfs', $amxy['s'], $desc); } else { $desc = str_replace('w#amx', 'N.a.', $desc); $desc = str_replace('w#amy', 'N.a.', $desc); $desc = str_replace('w#amfs', 'N.a.', $desc); } } // Timestamps $timestamps = array('timestamp', 'modified'); foreach ($timestamps as $timestamp) { if ($thumb[$timestamp]) { $desc = str_replace('w#' . $timestamp, wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $thumb[$timestamp]), $desc); } else { $desc = str_replace('w#' . $timestamp, '‹' . __a('unknown') . '›', $desc); } } // Custom data fields if (wppa_switch('custom_fields')) { $custom = $thumb['custom']; $custom_data = $custom ? unserialize($custom) : array('', '', '', '', '', '', '', '', '', ''); for ($i = '0'; $i < '10'; $i++) { if (wppa_opt('custom_caption_' . $i)) { // Field defined if (wppa_switch('custom_visible_' . $i)) { // May be displayed $desc = str_replace('w#cc' . $i, __(wppa_opt('custom_caption_' . $i)) . ':', $desc); // Caption $desc = str_replace('w#cd' . $i, __(stripslashes($custom_data[$i])), $desc); // Data } else { // May not be displayed $desc = str_replace('w#cc' . $i, '', $desc); // Remove $desc = str_replace('w#cd' . $i, '', $desc); // Remove } } else { // Field not defined $desc = str_replace('w#cc' . $i, '', $desc); // Remove $desc = str_replace('w#cd' . $i, '', $desc); // Remove } } } } // Shortcodes if ($do_shortcodes) { $desc = do_shortcode($desc); } else { $desc = strip_shortcodes($desc); } // Remove shortcodes if not wanted $desc = wppa_html($desc); // Enable html $desc = balanceTags($desc, true); // Balance tags $desc = wppa_filter_iptc($desc, $id); // Render IPTC tags $desc = wppa_filter_exif($desc, $id); // Render EXIF tags $desc = make_clickable($desc); // Auto make a tags for links $desc = convert_smilies($desc); // Make smilies visible // CMTooltipGlossary on board? $desc = wppa_filter_glossary($desc); return $desc; }
function wppa_is_wppa_tree($file) { $temp = explode('/uploads/wppa/', $file); if (count($temp) === 2) { $temp[1] = wppa_expand_id(wppa_strip_ext($temp[1])) . '.' . wppa_get_ext($temp[1]); $newf = implode('/wppa/', $temp); wppa('is_wppa_tree', $newf != $file); } else { wppa('is_wppa_tree', false); } return wppa('is_wppa_tree'); }
function wppa_make_the_photo_files($file, $id, $ext) { global $wpdb; $thumb = wppa_cache_thumb($id); $src_size = @getimagesize($file, $info); // If the given file is not an image file, log error and exit if (!$src_size) { if (is_admin()) { wppa_error_message(sprintf(__('ERROR: File %s is not a valid picture file.', 'wp-photo-album-plus'), $file)); } else { wppa_alert(sprintf(__('ERROR: File %s is not a valid picture file.', 'wp-photo-album-plus'), $file)); } return false; } // Find output path photo file $newimage = wppa_get_photo_path($id); if ($ext) { $newimage = wppa_strip_ext($newimage) . '.' . strtolower($ext); } // If Resize on upload is checked if (wppa_switch('resize_on_upload')) { // Picture sizes $src_width = $src_size[0]; // Temp convert to logical width if stereo if ($thumb['stereo']) { $src_width /= 2; } $src_height = $src_size[1]; // Max sizes if (wppa_opt('resize_to') == '0') { // from fullsize $max_width = wppa_opt('fullsize'); $max_height = wppa_opt('maxheight'); } else { // from selection $screen = explode('x', wppa_opt('resize_to')); $max_width = $screen[0]; $max_height = $screen[1]; } // If orientation needs +/- 90 deg rotation, swap max x and max y $ori = wppa_get_exif_orientation($file); if ($ori >= 5 && $ori <= 8) { $t = $max_width; $max_width = $max_height; $max_height = $t; } // Is source more landscape or more portrait than max window if ($src_width / $src_height > $max_width / $max_height) { // focus on width $focus = 'W'; $need_downsize = $src_width > $max_width; } else { // focus on height $focus = 'H'; $need_downsize = $src_height > $max_height; } // Convert back to physical size if ($thumb['stereo']) { $src_width *= 2; } // Downsize required ? if ($need_downsize) { // Find mime type $mime = $src_size[2]; // Create the source image switch ($mime) { // mime type case 1: // gif $temp = @imagecreatefromgif($file); if ($temp) { $src = imagecreatetruecolor($src_width, $src_height); imagecopy($src, $temp, 0, 0, 0, 0, $src_width, $src_height); imagedestroy($temp); } else { $src = false; } break; case 2: // jpeg if (!function_exists('wppa_imagecreatefromjpeg')) { wppa_log('Error', 'Function wppa_imagecreatefromjpeg does not exist.'); } $src = @wppa_imagecreatefromjpeg($file); break; case 3: // png $src = @imagecreatefrompng($file); break; } if (!$src) { wppa_log('Error', 'Image file ' . $file . ' is corrupt while downsizing photo'); return false; } // Create the ( empty ) destination image if ($focus == 'W') { if ($thumb['stereo']) { $max_width *= 2; } $dst_width = $max_width; $dst_height = round($max_width * $src_height / $src_width); } else { $dst_height = $max_height; $dst_width = round($max_height * $src_width / $src_height); } $dst = imagecreatetruecolor($dst_width, $dst_height); // If Png, save transparancy if ($mime == 3) { imagealphablending($dst, false); imagesavealpha($dst, true); } // Do the copy imagecopyresampled($dst, $src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); // Remove source image imagedestroy($src); // Save the photo switch ($mime) { // mime type case 1: imagegif($dst, $newimage); break; case 2: imagejpeg($dst, $newimage, wppa_opt('jpeg_quality')); break; case 3: imagepng($dst, $newimage, 6); break; } // Remove destination image imagedestroy($dst); } else { // No downsize needed, picture is small enough copy($file, $newimage); } } else { copy($file, $newimage); } // File successfully created ? if (is_file($newimage)) { // Make sure file is accessable wppa_chmod($newimage); // Optimize file wppa_optimize_image_file($newimage); } else { if (is_admin()) { wppa_error_message(__('ERROR: Resized or copied image could not be created.', 'wp-photo-album-plus')); } else { wppa_alert(__('ERROR: Resized or copied image could not be created.', 'wp-photo-album-plus')); } return false; } // Process the iptc data wppa_import_iptc($id, $info); // Process the exif data wppa_import_exif($id, $file); // GPS wppa_get_coordinates($file, $id); // Set ( update ) exif date-time if available $exdt = wppa_get_exif_datetime($file); if ($exdt) { wppa_update_photo(array('id' => $id, 'exifdtm' => $exdt)); } // Check orientation wppa_orientate_image($id, wppa_get_exif_orientation($file)); // Compute and save sizes wppa_get_photox($id, 'force'); // Show progression if (is_admin() && !wppa('ajax')) { echo '.'; } // Update CDN $cdn = wppa_cdn('admin'); if ($cdn) { switch ($cdn) { case 'cloudinary': wppa_upload_to_cloudinary($id); break; default: wppa_dbg_msg('Missing upload instructions for ' . $cdn, 'red', 'force'); } } // Create stereo images wppa_create_stereo_images($id); // Create thumbnail... wppa_create_thumbnail($id); // Clear (super)cache wppa_clear_cache(); return true; }
function wppa_bump_mocc() { wppa('mocc', wppa('mocc') + 1); }
function wppa_load_footer() { global $wppa; global $wpdb; global $wppa_session; if (wppa_opt('wppa_lightbox_name') == 'wppa') { $fontsize_lightbox = wppa_opt('wppa_fontsize_lightbox') ? wppa_opt('wppa_fontsize_lightbox') : '10'; $d = wppa_switch('wppa_ovl_show_counter') ? 1 : 0; $ovlh = wppa_opt('wppa_ovl_txt_lines') == 'auto' ? 'auto' : (wppa_opt('wppa_ovl_txt_lines') + $d) * ($fontsize_lightbox + 2); $txtcol = wppa_opt('wppa_ovl_theme') == 'black' ? '#a7a7a7' : '#272727'; echo ' <!-- start WPPA+ Footer data --> <div id="wppa-overlay-bg" style="text-align:center; display:none; position:fixed; top:0; left:0; z-index:100090; width:100%; height:2048px; background-color:' . wppa_opt('wppa_ovl_bgcolor') . ';" onclick="wppaOvlOnclick(event)" >'; if (wppa_switch('ovl_show_legenda') && !wppa('is_mobile')) { echo ' <div id="wppa-ovl-legenda-1" onmouseover="jQuery(this).css(\'visibility\',\'visible\');" onmouseout="jQuery(this).css(\'visibility\',\'hidden\');" style="position:absolute; left:0; top:0; background-color:' . wppa_opt('wppa_ovl_theme') . ';color:' . $txtcol . '; visibility:visible;" > ' . __a('Press f for fullscreen.') . ' </div>'; } echo ' </div> <div id="wppa-overlay-ic" style="position:fixed; top:0; padding-top:10px; z-index:100095; opacity:1; box-shadow:none;" > </div> <img id="wppa-overlay-sp" alt="spinner" style="position:fixed; top:200px; left:200px; z-index:100100; opacity:1; visibility:hidden; box-shadow:none;" src="' . wppa_get_imgdir() . 'loading.gif" /> <script type="text/javascript">jQuery("#wppa-overlay-bg").css({height:window.innerHeight}); wppaOvlTxtHeight = "' . $ovlh . '"; wppaOvlCloseTxt = "' . __(wppa_opt('wppa_ovl_close_txt')) . '"; wppaOvlOpacity = ' . wppa_opt('wppa_ovl_opacity') / 100 . '; wppaOvlOnclickType = "' . wppa_opt('wppa_ovl_onclick') . '"; wppaOvlTheme = "' . wppa_opt('wppa_ovl_theme') . '"; wppaOvlAnimSpeed = ' . wppa_opt('wppa_ovl_anim') . '; wppaOvlSlideSpeed = ' . wppa_opt('wppa_ovl_slide') . '; wppaVer4WindowWidth = 800; wppaVer4WindowHeight = 600; wppaOvlShowCounter = ' . (wppa_switch('wppa_ovl_show_counter') ? 'true' : 'false') . '; ' . (wppa_opt('wppa_fontfamily_lightbox') ? 'wppaOvlFontFamily = "' . wppa_opt('wppa_fontfamily_lightbox') . '"' : '') . ' wppaOvlFontSize = "' . $fontsize_lightbox . '"; ' . (wppa_opt('wppa_fontcolor_lightbox') ? 'wppaOvlFontColor = "' . wppa_opt('wppa_fontcolor_lightbox') . '"' : '') . ' ' . (wppa_opt('wppa_fontweight_lightbox') ? 'wppaOvlFontWeight = "' . wppa_opt('wppa_fontweight_lightbox') . '"' : '') . ' ' . (wppa_opt('wppa_fontsize_lightbox') ? 'wppaOvlLineHeight = "' . (wppa_opt('wppa_fontsize_lightbox') + '2') . '"' : '') . ' wppaOvlFullLegenda = "' . __a('Keys: f = next mode; escape = exit; p = previous, n = next, s = start/stop, d = dismiss this notice.') . '"; wppaOvlFullLegendaSingle = "' . __a('Keys: f = next mode; escape = exit; d = dismiss this notice.') . '"; wppaOvlVideoStart = ' . (wppa_switch('ovl_video_start') ? 'true' : 'false') . '; wppaOvlAudioStart = ' . (wppa_switch('ovl_audio_start') ? 'true' : 'false') . '; wppaOvlShowLegenda = ' . (wppa_switch('ovl_show_legenda') && !wppa('is_mobile') ? 'true' : 'false') . '; wppaOvlShowStartStop = ' . (wppa_switch('ovl_show_startstop') ? 'true' : 'false') . '; </script> '; wp_nonce_field('wppa-check', 'wppa-nonce', false, true); // Nonce field for Ajax bump view counter from lightbox echo ' <script type="text/javascript">'; if (isset($wppa_session['photo'])) { foreach (array_keys($wppa_session['photo']) as $p) { echo ' wppaPhotoView[' . $p . '] = true;'; } } echo ' </script> <!-- end WPPA+ Footer data --> '; } wppa_dbg_q('print'); if ($wppa['debug']) { $plugins = get_option('active_plugins'); wppa_dbg_msg('Active Plugins'); foreach ($plugins as $plugin) { wppa_dbg_msg($plugin); } wppa_dbg_msg('End Active Plugins'); } echo ' <!-- Do user upload -->'; wppa_user_upload(); // Do the upload if required and not yet done echo ' <!-- Done user upload -->'; }
function wppa_insert_photo($file = '', $alb = '', $name = '', $desc = '', $porder = '0', $id = '0', $linkurl = '', $linktitle = '') { global $wpdb; global $warning_given_small; $album = wppa_cache_album($alb); if (!wppa_allow_uploads($alb)) { if (is_admin() && !wppa('ajax')) { wppa_error_message(sprintf(__('Album %s is full', 'wp-photo-album-plus'), wppa_get_album_name($alb))); } else { wppa_alert(sprintf(__('Album %s is full', 'wp-photo-album-plus'), wppa_get_album_name($alb))); } return false; } if ($file != '' && $alb != '') { // Get the name if not given if ($name == '') { $name = basename($file); } // Sanitize name $filename = wppa_sanitize_file_name($name); $name = wppa_sanitize_photo_name($name); // If not dups allowed and its already here, quit if (isset($_POST['wppa-nodups']) || wppa_switch('void_dups')) { $exists = wppa_file_is_in_album($filename, $alb); if ($exists) { if (isset($_POST['del-after-p'])) { unlink($file); $msg = __('Photo %s already exists in album number %s. Removed from depot.', 'wp-photo-album-plus'); } else { $msg = __('Photo %s already exists in album number %s.', 'wp-photo-album-plus'); } wppa_warning_message(sprintf($msg, $name, $alb)); return false; } } // Verify file exists if (!wppa('is_remote') && !file_exists($file)) { if (!is_dir(dirname($file))) { wppa_error_message('Error: Directory ' . dirname($file) . ' does not exist.'); return false; } if (!is_writable(dirname($file))) { wppa_error_message('Error: Directory ' . dirname($file) . ' is not writable.'); return false; } wppa_error_message('Error: File ' . $file . ' does not exist.'); return false; } // else { // wppa_ok_message( 'Good: File '.$file.' exists.' ); // } // Get and verify the size $img_size = getimagesize($file); if ($img_size) { if (wppa_check_memory_limit('', $img_size['0'], $img_size['1']) === false) { wppa_error_message(sprintf(__('ERROR: Attempt to upload a photo that is too large to process (%s).', 'wp-photo-album-plus'), $name) . wppa_check_memory_limit()); wppa('ajax_import_files_error', __('Too big', 'wp-photo-album-plus')); return false; } if (!$warning_given_small && ($img_size['0'] < wppa_get_minisize() && $img_size['1'] < wppa_get_minisize())) { wppa_warning_message(__('WARNING: You are uploading photos that are too small. Photos must be larger than the thumbnail size and larger than the coverphotosize.', 'wp-photo-album-plus')); wppa('ajax_import_files_error', __('Too small', 'wp-photo-album-plus')); $warning_given_small = true; } } else { wppa_error_message(__('ERROR: Unable to retrieve image size of', 'wp-photo-album-plus') . ' ' . $name . ' ' . __('Are you sure it is a photo?', 'wp-photo-album-plus')); wppa('ajax_import_files_error', __('No imagesize', 'wp-photo-album-plus')); return false; } // Get ext based on mimetype, regardless of ext switch ($img_size[2]) { // mime type case 1: $ext = 'gif'; break; case 2: $ext = 'jpg'; break; case 3: $ext = 'png'; break; default: wppa_error_message(__('Unsupported mime type encountered:', 'wp-photo-album-plus') . ' ' . $img_size[2] . '.'); return false; } // Get an id if not yet there if ($id == '0') { $id = wppa_nextkey(WPPA_PHOTOS); } // Get opt deflt desc if empty if ($desc == '' && wppa_switch('apply_newphoto_desc')) { $desc = stripslashes(wppa_opt('newphoto_description')); } // Reset rating $mrat = '0'; // Find ( new ) owner $owner = wppa_get_user(); // Validate album if (!is_numeric($alb) || $alb < '1') { wppa_error_message(__('Album not known while trying to add a photo', 'wp-photo-album-plus')); return false; } if (!wppa_have_access($alb)) { wppa_error_message(sprintf(__('Album %s does not exist or is not accessable while trying to add a photo', 'wp-photo-album-plus'), $alb)); return false; } $status = wppa_switch('upload_moderate') && !current_user_can('wppa_admin') ? 'pending' : 'publish'; // Add photo to db $id = wppa_create_photo_entry(array('id' => $id, 'album' => $alb, 'ext' => $ext, 'name' => $name, 'p_order' => $porder, 'description' => $desc, 'linkurl' => $linkurl, 'linktitle' => $linktitle, 'owner' => $owner, 'status' => $status, 'filename' => $filename)); if (!$id) { wppa_error_message(__('Could not insert photo.', 'wp-photo-album-plus')); } else { // Save the source wppa_save_source($file, $filename, $alb); wppa_flush_treecounts($alb); wppa_update_album(array('id' => $alb, 'modified' => time())); wppa_flush_upldr_cache('photoid', $id); } // Make the photo files if (wppa_make_the_photo_files($file, $id, $ext)) { // Repair photoname if not supplied and not standard wppa_set_default_name($id, $name); // Tags wppa_set_default_tags($id); // Index wppa_index_add('photo', $id); // and add watermark ( optionally ) to fullsize image only wppa_add_watermark($id); // also to thumbnail? if (wppa_switch('watermark_thumbs')) { wppa_create_thumbnail($id); } // Is it a default coverimage? wppa_check_coverimage($id); return $id; } } else { wppa_error_message(__('ERROR: Unknown file or album.', 'wp-photo-album-plus')); return false; } }