function wppa_add_admin() { global $wp_roles; global $wpdb; // Make sure admin has access rights if (current_user_can('administrator')) { $wp_roles->add_cap('administrator', 'wppa_admin'); $wp_roles->add_cap('administrator', 'wppa_upload'); $wp_roles->add_cap('administrator', 'wppa_import'); $wp_roles->add_cap('administrator', 'wppa_moderate'); $wp_roles->add_cap('administrator', 'wppa_export'); $wp_roles->add_cap('administrator', 'wppa_settings'); $wp_roles->add_cap('administrator', 'wppa_potd'); $wp_roles->add_cap('administrator', 'wppa_comments'); $wp_roles->add_cap('administrator', 'wppa_help'); } // See if there are comments pending moderation $com_pending = ''; $com_pending_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'pending'"); if ($com_pending_count) { $com_pending = '<span class="update-plugins"><span class="plugin-count">' . $com_pending_count . '</span></span>'; } // See if there are uploads pending moderation $upl_pending = ''; $upl_pending_count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'pending'"); if ($upl_pending_count) { $upl_pending = '<span class="update-plugins"><span class="plugin-count">' . $upl_pending_count . '</span></span>'; } // Compute total pending moderation $tot_pending = ''; $tot_pending_count = '0'; if (current_user_can('wppa_comments') || current_user_can('wppa_moderate')) { $tot_pending_count += $com_pending_count; } if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) { $tot_pending_count += $upl_pending_count; } if ($tot_pending_count) { $tot_pending = '<span class="update-plugins"><span class="plugin-count">' . '<b>' . $tot_pending_count . '</b>' . '</span></span>'; } $icon_url = WPPA_URL . '/images/camera16.png'; // page_title menu_title capability menu_slug function icon_url position add_menu_page('WP Photo Album', __('Photo Albums', 'wppa') . $tot_pending, 'wppa_admin', 'wppa_admin_menu', 'wppa_admin', $icon_url); //,'10' ); // parent_slug page_title menu_title capability menu_slug function add_submenu_page('wppa_admin_menu', __('Album Admin', 'wppa'), __('Album Admin', 'wppa') . $upl_pending, 'wppa_admin', 'wppa_admin_menu', 'wppa_admin'); add_submenu_page('wppa_admin_menu', __('Upload Photos', 'wppa'), __('Upload Photos', 'wppa'), 'wppa_upload', 'wppa_upload_photos', 'wppa_page_upload'); // Uploader without album admin rights, but when the upload_edit switch set, may edit his own photos if (!current_user_can('wppa_admin') && wppa_switch('wppa_upload_edit')) { add_submenu_page('wppa_admin_menu', __('Edit Photos', 'wppa'), __('Edit Photos', 'wppa'), 'wppa_upload', 'wppa_edit_photo', 'wppa_edit_photo'); } add_submenu_page('wppa_admin_menu', __('Import Photos', 'wppa'), __('Import Photos', 'wppa'), 'wppa_import', 'wppa_import_photos', 'wppa_page_import'); add_submenu_page('wppa_admin_menu', __('Moderate Photos', 'wppa'), __('Moderate Photos', 'wppa') . $tot_pending, 'wppa_moderate', 'wppa_moderate_photos', 'wppa_page_moderate'); add_submenu_page('wppa_admin_menu', __('Export Photos', 'wppa'), __('Export Photos', 'wppa'), 'wppa_export', 'wppa_export_photos', 'wppa_page_export'); add_submenu_page('wppa_admin_menu', __('Settings', 'wppa'), __('Settings', 'wppa'), 'wppa_settings', 'wppa_options', 'wppa_page_options'); add_submenu_page('wppa_admin_menu', __('Photo of the day Widget', 'wppa'), __('Photo of the day', 'wppa'), 'wppa_potd', 'wppa_photo_of_the_day', 'wppa_sidebar_page_options'); add_submenu_page('wppa_admin_menu', __('Manage comments', 'wppa'), __('Comments', 'wppa') . $com_pending, 'wppa_comments', 'wppa_manage_comments', 'wppa_comment_admin'); add_submenu_page('wppa_admin_menu', __('Help & Info', 'wppa'), __('Help & Info', 'wppa'), 'wppa_help', 'wppa_help', 'wppa_page_help'); }
function filter_mce_plugin($plugins) { // this plugin file will work the magic of our button if (wppa_switch('wppa_use_scripts_in_tinymce')) { $file = 'wppa-tinymce-scripts.js'; } else { $file = 'wppa-tinymce-shortcodes.js'; } $plugins['wppagallery'] = plugin_dir_url(__FILE__) . $file; return $plugins; }
function wppa_create_wppa_htaccess_($filename) { $file = fopen($filename, 'wb'); if ($file) { // Make it if (wppa_switch('wppa_cre_uploads_htaccess')) { fwrite($file, '<IfModule mod_rewrite.c>'); fwrite($file, "\n" . 'RewriteEngine Off'); fwrite($file, "\n" . '</IfModule>'); fclose($file); } else { fclose($file); @unlink($filename); } } }
/** @see WP_Widget::form */ function form($instance) { global $wppa_opt; //Defaults $instance = wp_parse_args((array) $instance, array('title' => __('Last Ten Photos', 'wp-photo-album-plus'), 'album' => '0', 'albumenum' => '', 'timesince' => 'yes', 'display' => 'thumbs', 'includesubs' => 'no')); $widget_title = apply_filters('widget_title', $instance['title']); $album = $instance['album']; $album_enum = $instance['albumenum']; $timesince = $instance['timesince']; $display = $instance['display']; $subs = $instance['includesubs']; ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $widget_title; ?> " /> </p> <p><label for="<?php echo $this->get_field_id('album'); ?> "><?php _e('Album:', 'wp-photo-album-plus'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('album'); ?> " name="<?php echo $this->get_field_name('album'); ?> " > <?php echo wppa_album_select_a(array('selected' => $album, 'addall' => true, 'addmultiple' => true, 'addnumbers' => true, 'path' => wppa_switch('hier_albsel'))); ?> </select> </p> <p id="wppa-albums-enum" style="display:block;" ><label for="<?php echo $this->get_field_id('albumenum'); ?> "><?php _e('Albums:', 'wp-photo-album-plus'); ?> </label> <small style="color:blue;" ><br /><?php _e('Select --- multiple see below --- in the Album selection box. Then enter album numbers seperated by commas', 'wp-photo-album-plus'); ?> </small> <input class="widefat" id="<?php echo $this->get_field_id('albumenum'); ?> " name="<?php echo $this->get_field_name('albumenum'); ?> " type="text" value="<?php echo $album_enum; ?> " /> </p> <p> <?php _e('Include subalbums:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('includesubs'); ?> " name="<?php echo $this->get_field_name('includesubs'); ?> "> <option value="no" <?php if ($subs == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($subs == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes', 'wp-photo-album-plus'); ?> </option> </select> </p> <p> <?php _e('Display:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('display'); ?> " name="<?php echo $this->get_field_name('display'); ?> "> <option value="thumbs" <?php if ($display == 'thumbs') { echo 'selected="selected"'; } ?> ><?php _e('thumbnail images', 'wp-photo-album-plus'); ?> </option> <option value="names" <?php if ($display == 'names') { echo 'selected="selected"'; } ?> ><?php _e('photo names', 'wp-photo-album-plus'); ?> </option> </select> </p> <p> <?php _e('Show time since:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('timesince'); ?> " name="<?php echo $this->get_field_name('timesince'); ?> "> <option value="no" <?php if ($timesince == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no.', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($timesince == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes.', 'wp-photo-album-plus'); ?> </option> </select> </p> <p><?php _e('You can set the sizes in this widget in the <b>Photo Albums -> Settings</b> admin page.', 'wp-photo-album-plus'); ?> </p> <?php }
function wppa_create_thumbnail($id, $use_source = true) { // Find file to make thumbnail from $source_path = wppa_fix_poster_ext(wppa_get_source_path($id), $id); // Use source if requested and available if ($use_source) { if (!wppa_switch('watermark_thumbs') && is_file($source_path)) { $file = $source_path; // Use sourcefile } else { $file = wppa_fix_poster_ext(wppa_get_photo_path($id), $id); // Use photofile } // Non standard orientation files: never use source $orient = wppa_get_exif_orientation($file); if ($orient > '1') { $file = wppa_fix_poster_ext(wppa_get_photo_path($id), $id); // Use photofile } } else { $file = wppa_fix_poster_ext(wppa_get_photo_path($id), $id); // Use photofile } // Max side $max_side = wppa_get_minisize(); // Check file if (!file_exists($file)) { return false; } // No file, fail $img_attr = getimagesize($file); if (!$img_attr) { return false; } // Not an image, fail // Retrieve aspect $asp_attr = explode(':', wppa_opt('thumb_aspect')); // Get output path $thumbpath = wppa_get_thumb_path($id); if (wppa_get_ext($thumbpath) == 'xxx') { // Video poster $thumbpath = wppa_strip_ext($thumbpath) . '.jpg'; } // Source size $src_size_w = $img_attr[0]; $src_size_h = $img_attr[1]; // Temp convert width if stereo if (wppa_get_photo_item($id, 'stereo')) { $src_size_w /= 2; } // Mime type and thumb type $mime = $img_attr[2]; $type = $asp_attr[2]; // Source native aspect $src_asp = $src_size_h / $src_size_w; // Required aspect if ($type == 'none') { $dst_asp = $src_asp; } else { $dst_asp = $asp_attr[0] / $asp_attr[1]; } // Convert back width if stereo if (wppa_get_photo_item($id, 'stereo')) { $src_size_w *= 2; } // Create the source image switch ($mime) { // mime type case 1: // gif $temp = @imagecreatefromgif($file); if ($temp) { $src = imagecreatetruecolor($src_size_w, $src_size_h); imagecopy($src, $temp, 0, 0, 0, 0, $src_size_w, $src_size_h); 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 creating thmbnail'); return true; } // Compute the destination image size if ($dst_asp < 1.0) { // Landscape $dst_size_w = $max_side; $dst_size_h = round($max_side * $dst_asp); } else { // Portrait $dst_size_w = round($max_side / $dst_asp); $dst_size_h = $max_side; } // Create the ( empty ) destination image $dst = imagecreatetruecolor($dst_size_w, $dst_size_h); if ($mime == 3) { // Png, save transparancy imagealphablending($dst, false); imagesavealpha($dst, true); } // Fill with the required color $c = trim(strtolower(wppa_opt('bgcolor_thumbnail'))); if ($c != '#000000') { $r = hexdec(substr($c, 1, 2)); $g = hexdec(substr($c, 3, 2)); $b = hexdec(substr($c, 5, 2)); $color = imagecolorallocate($dst, $r, $g, $b); if ($color === false) { wppa_log('Err', 'Unable to set background color to: ' . $r . ', ' . $g . ', ' . $b . ' in wppa_create_thumbnail'); } else { imagefilledrectangle($dst, 0, 0, $dst_size_w, $dst_size_h, $color); } } // Switch on what we have to do switch ($type) { case 'none': // Use aspect from fullsize image $src_x = 0; $src_y = 0; $src_w = $src_size_w; $src_h = $src_size_h; $dst_x = 0; $dst_y = 0; $dst_w = $dst_size_w; $dst_h = $dst_size_h; break; case 'clip': // Clip image to given aspect ratio if ($src_asp < $dst_asp) { // Source image more landscape than destination $dst_x = 0; $dst_y = 0; $dst_w = $dst_size_w; $dst_h = $dst_size_h; $src_x = round(($src_size_w - $src_size_h / $dst_asp) / 2); $src_y = 0; $src_w = round($src_size_h / $dst_asp); $src_h = $src_size_h; } else { $dst_x = 0; $dst_y = 0; $dst_w = $dst_size_w; $dst_h = $dst_size_h; $src_x = 0; $src_y = round(($src_size_h - $src_size_w * $dst_asp) / 2); $src_w = $src_size_w; $src_h = round($src_size_w * $dst_asp); } break; case 'padd': // Padd image to given aspect ratio if ($src_asp < $dst_asp) { // Source image more landscape than destination $dst_x = 0; $dst_y = round(($dst_size_h - $dst_size_w * $src_asp) / 2); $dst_w = $dst_size_w; $dst_h = round($dst_size_w * $src_asp); $src_x = 0; $src_y = 0; $src_w = $src_size_w; $src_h = $src_size_h; } else { $dst_x = round(($dst_size_w - $dst_size_h / $src_asp) / 2); $dst_y = 0; $dst_w = round($dst_size_h / $src_asp); $dst_h = $dst_size_h; $src_x = 0; $src_y = 0; $src_w = $src_size_w; $src_h = $src_size_h; } break; default: // Not implemented return false; } // Copy left half if stereo if (wppa_get_photo_item($id, 'stereo')) { $src_w /= 2; } // Do the copy imagecopyresampled($dst, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); // Save the thumb $thumbpath = wppa_strip_ext($thumbpath); switch ($mime) { // mime type case 1: $full_thumbpath = $thumbpath . '.gif'; imagegif($dst, $full_thumbpath); break; case 2: $full_thumbpath = $thumbpath . '.jpg'; imagejpeg($dst, $full_thumbpath, wppa_opt('jpeg_quality')); break; case 3: $full_thumbpath = $thumbpath . '.png'; imagepng($dst, $full_thumbpath, 6); break; } // Cleanup imagedestroy($src); imagedestroy($dst); // Make sure file is accessable wppa_chmod($full_thumbpath); // Optimize wppa_optimize_image_file($full_thumbpath); // Compute and save sizes wppa_get_thumbx($id, 'force'); // forces recalc x and y return true; }
function wppa_get_album_desc($id) { if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_album_desc( ' . $id . ' )', 'red'); } $album = wppa_cache_album($id); $desc = $album['description']; // Raw data if (!$desc) { return ''; } // No content, need no filtering $desc = stripslashes($desc); // Unescape $desc = __($desc); // qTranslate $desc = wppa_html($desc); // Enable html $desc = balanceTags($desc, true); // Balance tags if (strpos($desc, 'w#') !== false) { // Is there any 'w#' ? // Keywords $keywords = array('name', 'owner', 'id', 'views'); foreach ($keywords as $keyword) { $replacement = __(trim(stripslashes($album[$keyword]))); if ($replacement == '') { $replacement = '‹' . __a('none', 'wppa') . '›'; } $desc = str_replace('w#' . $keyword, $replacement, $desc); } // Timestamps $timestamps = array('timestamp', 'modified'); // Identical, there is only timestamp, but it acts as modified foreach ($timestamps as $timestamp) { if ($album['timestamp']) { $desc = str_replace('w#' . $timestamp, wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $album['timestamp']), $desc); } else { $desc = str_replace('w#' . $timestamp, '‹' . __a('unknown') . '›', $desc); } } } // To prevent recursive rendering of scripts or shortcodes: $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc); if (wppa_switch('wppa_allow_foreign_shortcodes_general')) { $desc = do_shortcode($desc); } else { $desc = strip_shortcodes($desc); } // Convert links and mailto: $desc = make_clickable($desc); // CMTooltipGlossary on board? $desc = wppa_filter_glossary($desc); return $desc; }
function wppa_get_medal_html_a($args) { // Completize args $args = wp_parse_args((array) $args, array('id' => '0', 'size' => 'M', 'where' => '')); // Validate args if ($args['id'] == '0') { return ''; } // Missing required id if (!in_array($args['size'], array('S', 'M', 'L', 'XL'))) { return ''; } // Missing or not implemented size spec if (!in_array($args['where'], array('top', 'bot'))) { return ''; } // Missing or not implemented where // Do it here? if (strpos(wppa_opt('medal_position'), $args['where']) === false) { return ''; } // No // Get rquired photo and config data $id = $args['id']; $new = wppa_is_photo_new($id); $mod = wppa_is_photo_modified($id); $status = wppa_get_photo_item($id, 'status'); $medal = in_array($status, array('gold', 'silver', 'bronze')) ? $status : ''; // Have a medal to show? if (!$new && !$medal && !$mod) { return ''; // No } // Init local vars $result = ''; $color = wppa_opt('medal_color'); $left = strpos(wppa_opt('medal_position'), 'left') !== false; $ctop = strpos(wppa_opt('medal_position'), 'top') === false ? '-32' : '0'; $sizes = array('S' => '16', 'M' => '20', 'L' => '24', 'XL' => '32'); $nsizes = array('S' => '14', 'M' => '16', 'L' => '20', 'XL' => '24'); $fsizes = array('S' => '9', 'M' => '10', 'L' => '14', 'XL' => '20'); $smargs = array('S' => '4', 'M' => '5', 'L' => '6', 'XL' => '8'); $lmargs = array('S' => '22', 'M' => '28', 'L' => '36', 'XL' => '48'); $tops = array('S' => '8', 'M' => '8', 'L' => '6', 'XL' => '0'); $ntops = array('S' => '10', 'M' => '10', 'L' => '8', 'XL' => '0'); $titles = array('gold' => __('Gold medal', 'wp-photo-album-plus'), 'silver' => __('Silver medal', 'wp-photo-album-plus'), 'bronze' => __('Bronze medal', 'wp-photo-album-plus')); $size = $sizes[$args['size']]; $nsize = $nsizes[$args['size']]; $fsize = $fsizes[$args['size']]; $smarg = $smargs[$args['size']]; $lmarg = $lmargs[$args['size']]; $top = $tops[$args['size']]; $ntop = $ntops[$args['size']]; $title = $medal ? esc_attr($titles[$medal]) : ''; $sstyle = $left ? 'left:' . $smarg . 'px;' : 'right:' . $smarg . 'px;'; $lstyle = $left ? 'left:' . $lmarg . 'px;' : 'right:' . $lmarg . 'px;'; // The medal container $result .= '<div style="position:relative;top:' . $ctop . 'px;z-index:10;">'; // The medal if ($medal) { $result .= '<img' . ' src="' . WPPA_URL . '/images/medal_' . $medal . '_' . $color . '.png"' . ' title="' . $title . '"' . ' alt="' . $title . '"' . ' style="' . $sstyle . 'top:4px;' . 'position:absolute;' . 'border:none;' . 'margin:0;' . 'padding:0;' . 'box-shadow:none;' . 'height:' . $size . 'px;' . 'top:' . $top . 'px;' . '"' . ' />'; } // Is there a new or modified indicator to display? if ($new) { $type = 'new'; } elseif ($mod) { $type = 'mod'; } else { $type = ''; } // Style adjustment if only a new/modified without a real medal if (!$medal) { $lstyle = $sstyle; } $do_image = !wppa_switch('wppa_new_mod_label_is_text'); // Yes there is one to display if ($type) { if ($do_image) { $result .= '<img' . ' src="' . wppa_opt($type . '_label_url') . '"' . ' title="' . esc_attr(__('New', 'wp-photo-album-plus')) . '"' . ' alt="' . esc_attr(__('New', 'wp-photo-album-plus')) . '"' . ' class="wppa-thumbnew"' . ' style="' . $lstyle . 'top:' . $ntop . 'px;' . 'position:absolute;' . 'border:none;' . 'margin:0;' . 'padding:0;' . 'box-shadow:none;' . 'height:' . $nsize . 'px;' . '"' . ' />'; } else { $result .= '<div' . ' style="' . $lstyle . 'position:absolute;' . 'top:' . $ntop . 'px;' . 'box-sizing:border-box;' . 'float:' . ($left ? 'left;' : 'right;') . 'font-size:' . $fsize . 'px;' . 'line-height:' . $fsize . 'px;' . 'font-family:\'Arial Black\', Gadget, sans-serif;' . 'border-radius:2px;' . 'border-width:1px;' . 'border-style:solid;' . 'padding:1px;' . wppa_get_text_medal_color_style($type) . '"' . ' >' . ' ' . __(wppa_opt($type . '_label_text')) . ' ' . '</div>'; } } // Close container $result .= '</div>'; 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', '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_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; }
function wppa_backend_upload_mail($id, $alb, $name) { $owner = wppa_get_user(); if ($owner == 'admin') { return; } // Admin does not send mails to himself if (wppa_switch('upload_backend_notify')) { $to = get_bloginfo('admin_email'); $subj = sprintf(__('New photo uploaded: %s', 'wp-photo-album-plus'), wppa_sanitize_file_name($name)); $cont['0'] = sprintf(__('User %1$s uploaded photo %2$s into album %3$s', 'wp-photo-album-plus'), $owner, $id, wppa_get_album_name($alb)); if (wppa_switch('upload_moderate') && !current_user_can('wppa_admin')) { $cont['1'] = __('This upload requires moderation', 'wp-photo-album-plus'); $cont['2'] = '<a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Moderate manage photo', 'wp-photo-album-plus') . '</a>'; } else { $cont['1'] = __('Details:', 'wp-photo-album-plus'); $cont['1'] .= ' <a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Manage photo', 'wp-photo-album-plus') . '</a>'; } wppa_send_mail($to, $subj, $cont, $id); } }
function form($instance) { global $wppa_opt; $instance = wp_parse_args((array) $instance, array('title' => __('Upload Photos', 'wppa'), 'album' => '0')); $title = $instance['title']; $album = $instance['album']; ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'wppa'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /></p> <p><label for="<?php echo $this->get_field_id('album'); ?> "><?php _e('Album:', 'wppa'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('album'); ?> " name="<?php echo $this->get_field_name('album'); ?> " > <?php echo wppa_album_select_a(array('path' => wppa_switch('wppa_hier_albsel'), 'selected' => $album, 'addselbox' => true)); ?> </select> <?php }
function wppa_bcitem($value = '', $href = '', $title = '', $class = '', $ajax = '') { static $sep; // Convert url to pretty $href = wppa_convert_to_pretty($href); // Has content? if (!$value) { return; } // No content if ($href) { wppa_out('<a' . ($ajax && wppa_switch('allow_ajax') ? ' onclick="wppaDoAjaxRender(' . wppa('mocc') . ', \'' . $ajax . '\', \'' . $href . '\' );"' : ' href="' . $href . '"') . ' class="wppa-nav-text ' . $class . '"' . ' style="' . __wcs('wppa-nav-text') . '"' . ' title="' . esc_attr($title) . '" >' . $value . '</a>'); } else { // No link, its the last item wppa_out('<span' . ' id="bc-pname-' . wppa('mocc') . '"' . ' class="wppa-nav-text ' . $class . '"' . ' style="' . ($title ? 'cursor:pointer;' : '') . __wcs('wppa-nav-text') . '"' . ' title="' . esc_attr($title) . '"' . ' >' . $value . '</span>'); return; } // Add seperator if (!$sep) { // Compute the seperator $temp = wppa_opt('bc_separator'); switch ($temp) { case 'url': $size = wppa_opt('fontsize_nav'); if ($size == '') { $size = '12'; } $style = 'height:' . $size . 'px;'; $sep = ' ' . '<img' . ' src="' . wppa_opt('bc_url') . '"' . ' class="no-shadow"' . ' style="' . $style . '"' . ' />' . ' '; break; case 'txt': $sep = ' ' . html_entity_decode(stripslashes(wppa_opt('bc_txt')), ENT_QUOTES) . ' '; break; default: $sep = ' &' . $temp . '; '; } } wppa_out('<span' . ' class="wppa-nav-text ' . $class . '"' . ' style="' . __wcs('wppa-nav-text') . '"' . ' >' . $sep . '</span>'); }
function wppa_recuperate($id) { global $thumb; global $wpdb; wppa_cache_thumb($id); $iptcfix = false; $exiffix = false; $file = wppa_get_source_path($id); if (!is_file($file)) { $file = wppa_get_photo_path($id); } if (is_file($file)) { // Not a dir $attr = getimagesize($file, $info); if (is_array($attr)) { // Is a picturefile if ($attr[2] == IMAGETYPE_JPEG) { // Is a jpg if (wppa_switch('wppa_save_iptc')) { // Save iptc if (isset($info["APP13"])) { // There is IPTC data $is_iptc = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_IPTC . "` WHERE `photo` = %s", $id)); if (!$is_iptc) { // No IPTC yet and there is: Recuperate wppa_import_iptc($id, $info, 'nodelete'); $iptcfix = true; } } } if (wppa_switch('wppa_save_exif')) { // Save exif $image_type = exif_imagetype($file); if ($image_type == IMAGETYPE_JPEG) { // EXIF supported by server $is_exif = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_EXIF . "` WHERE `photo`=%s", $id)); if (!$is_exif) { // No EXIF yet $exif = @exif_read_data($file, 'EXIF'); //@ if (is_array($exif)) { // There is exif data present wppa_import_exif($id, $file, 'nodelete'); $exiffix = true; } } } } } } } return array('iptcfix' => $iptcfix, 'exiffix' => $exiffix); }
/** @see WP_Widget::form */ function form($instance) { global $wpdb; //Defaults $instance = wp_parse_args((array) $instance, array('title' => __('Search Photos', 'wp-photo-album-plus'), 'label' => '', 'root' => false, 'sub' => false, 'album' => '', 'landingpage' => '')); $title = $instance['title']; $label = $instance['label']; $root = $instance['root']; $sub = $instance['sub']; $album = $instance['album']; $landingpage = $instance['landingpage']; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "> <?php _e('Title:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $title; ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('label'); ?> "> <?php _e('Text:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('label'); ?> " name="<?php echo $this->get_field_name('label'); ?> " type="text" value="<?php echo esc_attr($label); ?> " /> </p> <small><?php _e('Enter optional text that will appear before the input box. This may contain HTML so you can change font size and color.', 'wp-photo-album-plus'); ?> </small> <p> <input type="checkbox" <?php if ($root) { echo 'checked="checked"'; } ?> id="<?php echo $this->get_field_id('root'); ?> " name="<?php echo $this->get_field_name('root'); ?> " /> <label for="<?php echo $this->get_field_id('root'); ?> "> <?php _e('Enable rootsearch', 'wp-photo-album-plus'); ?> </label> </p> <p> <small> <?php _e('If you want the search to be limited to a specific album and its (grand)children, select the album here.', 'wp-photo-album-plus'); ?> <br /> <?php _e('If you select an album here, it will overrule the previous checkbox using the album as a \'fixed\' root.', 'wp-photo-album-plus'); ?> </small> <select id="<?php echo $this->get_field_id('album'); ?> " name="<?php echo $this->get_field_name('album'); ?> " style="max-width:100%" > <?php echo wppa_album_select_a(array('selected' => $album, 'addblank' => true, 'sort' => true, 'path' => true)); ?> </select> </p> <p> <input type="checkbox" <?php if ($sub) { echo 'checked="checked"'; } ?> id="<?php echo $this->get_field_id('sub'); ?> " name="<?php echo $this->get_field_name('sub'); ?> " /> <label for="<?php echo $this->get_field_id('sub'); ?> "> <?php _e('Enable subsearch', 'wp-photo-album-plus'); ?> </label> </p> <p> <label for="<?php echo $this->get_field_id('landingpage'); ?> " > <?php _e('Landing page', 'wp-photo-album-plus'); echo ': ' . $landingpage; ?> </label> <select id="<?php echo $this->get_field_id('landingpage'); ?> " name="<?php echo $this->get_field_name('landingpage'); ?> " style="max-width:100%" > <?php // First option $selected = $landingpage == '0' ? ' selected="selected"' : ''; ?> <option value="0" <?php echo $selected; ?> > <?php _e('--- Default ---', 'wp-photo-album-plus'); ?> </option> <?php // Pages if any $query = "SELECT ID, post_title, post_content, post_parent " . "FROM " . $wpdb->posts . " " . "WHERE post_type = 'page' AND post_status = 'publish' " . "ORDER BY post_title ASC"; $pages = $wpdb->get_results($query, ARRAY_A); if ($pages) { // Add parents optionally OR translate only if (wppa_switch('hier_pagesel')) { $pages = wppa_add_parents($pages); } else { foreach (array_keys($pages) as $index) { $pages[$index]['post_title'] = __(stripslashes($pages[$index]['post_title'])); } } // Sort alpahbetically $pages = wppa_array_sort($pages, 'post_title'); // Display option foreach ($pages as $page) { $selected = $page['ID'] == $landingpage ? ' selected="selected"' : ''; $d = strpos($page['post_content'], '[wppa') === false && strpos($page['post_content'], '%%wppa%%') === false; $disabled = $d ? ' disabled="disabled"' : ''; ?> <option value="<?php echo $page['ID']; ?> "<?php echo $selected; echo $disabled; ?> > <?php _e($page['post_title']); ?> </option> <?php } } ?> </select> </p> <p> <small> <?php _e('The default page will be created automaticly', 'wp-photo-album-plus'); ?> </small> </p> <?php }
/** @see WP_Widget::form */ function form($instance) { //Defaults $instance = wp_parse_args((array) $instance, array('title' => __('Thumbnail Photos', 'wp-photo-album-plus'), 'link' => '', 'linktitle' => '', 'album' => '0', 'name' => 'no', 'display' => 'thumbs', 'sortby' => wppa_get_photo_order('0'), 'limit' => wppa_opt('thumbnail_widget_count'))); $album = $instance['album']; $name = $instance['name']; $widget_title = $instance['title']; $widget_link = $instance['link']; $link_title = $instance['linktitle']; $display = $instance['display']; $sortby = $instance['sortby']; $limit = $instance['limit']; ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $widget_title; ?> " /></p> <p><label for="<?php echo $this->get_field_id('link'); ?> "><?php _e('Link from the title:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('link'); ?> " name="<?php echo $this->get_field_name('link'); ?> " type="text" value="<?php echo $widget_link; ?> " /></p> <p><label for="<?php echo $this->get_field_id('link'); ?> "><?php _e('Link Title ( tooltip ):', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('linktitle'); ?> " name="<?php echo $this->get_field_name('linktitle'); ?> " type="text" value="<?php echo $widget_link; ?> " /></p> <p><label for="<?php echo $this->get_field_id('album'); ?> "><?php _e('Album:', 'wp-photo-album-plus'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('album'); ?> " name="<?php echo $this->get_field_name('album'); ?> " > <?php echo wppa_album_select_a(array('selected' => $album, 'addseparate' => true, 'addall' => true, 'path' => wppa_switch('wppa_hier_albsel'))); ?> </select> </p> <p> <?php _e('Sort by:', 'wp-photo-album-plus'); ?> <select class="widefat" id="<?php echo $this->get_field_id('sortby'); ?> " name="<?php echo $this->get_field_name('sortby'); ?> "> <option value="" <?php if ($sortby == '') { echo 'selected="selected"'; } ?> ><?php _e('--- none ---', 'wp-photo-album-plus'); ?> </option> <option value="ORDER BY `p_order`" <?php if ($sortby == 'ORDER BY `p_order`') { echo 'selected="selected"'; } ?> ><?php _e('Order #', 'wp-photo-album-plus'); ?> </option> <option value="ORDER BY `name`" <?php if ($sortby == 'ORDER BY `name`') { echo 'selected="selected"'; } ?> ><?php _e('Name', 'wp-photo-album-plus'); ?> </option> <option value="ORDER BY RAND()" <?php if ($sortby == 'ORDER BY RAND()') { echo 'selected="selected"'; } ?> ><?php _e('Random', 'wp-photo-album-plus'); ?> </option> <option value="ORDER BY `mean_rating` DESC" <?php if ($sortby == 'ORDER BY `mean_rating` DESC') { echo 'selected="selected"'; } ?> ><?php _e('Rating mean value desc', 'wp-photo-album-plus'); ?> </option> <option value="ORDER BY `rating_count` DESC" <?php if ($sortby == 'ORDER BY `rating_count` DESC') { echo 'selected="selected"'; } ?> ><?php _e('Number of votes desc', 'wp-photo-album-plus'); ?> </option> <option value="ORDER BY `timestamp` DESC" <?php if ($sortby == 'ORDER BY `timestamp` DESC') { echo 'selected="selected"'; } ?> ><?php _e('Timestamp desc', 'wp-photo-album-plus'); ?> </option> </select> </p> <p> <?php _e('Max number:', 'wp-photo-album-plus'); ?> <input id="<?php echo $this->get_field_id('limit'); ?> " name="<?php echo $this->get_field_name('limit'); ?> " value="<?php echo $limit; ?> "> </p> <p> <?php _e('Display:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('display'); ?> " name="<?php echo $this->get_field_name('display'); ?> "> <option value="thumbs" <?php if ($display == 'thumbs') { echo 'selected="selected"'; } ?> ><?php _e('thumbnail images', 'wp-photo-album-plus'); ?> </option> <option value="names" <?php if ($display == 'names') { echo 'selected="selected"'; } ?> ><?php _e('photo names', 'wp-photo-album-plus'); ?> </option> </select> </p> <p> <?php _e('Show photo names <small>under thumbnails only</small>:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('name'); ?> " name="<?php echo $this->get_field_name('name'); ?> "> <option value="no" <?php if ($name == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no.', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($name == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes.', 'wp-photo-album-plus'); ?> </option> </select> </p> <p><?php _e('You can set the sizes in this widget in the <b>Photo Albums -> Settings</b> admin page.', 'wp-photo-album-plus'); ?> </p> <?php }
function wppa_get_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '') { global $wpdb; // make sure the photo data ia available $thumb = wppa_cache_thumb($id); if (!$thumb) { return false; } // Is it a video? $is_video = wppa_is_video($id, true); // Photo Specific Overrule? if ($wich == 'sphoto' && wppa_switch('sphoto_overrule') || $wich == 'mphoto' && wppa_switch('mphoto_overrule') || $wich == 'thumb' && wppa_switch('thumb_overrule') || $wich == 'topten' && wppa_switch('topten_overrule') || $wich == 'featen' && wppa_switch('featen_overrule') || $wich == 'lasten' && wppa_switch('lasten_overrule') || $wich == 'sswidget' && wppa_switch('sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('coverimg_overrule') || $wich == 'comten' && wppa_switch('comment_overrule') || $wich == 'slideshow' && wppa_switch('slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('thumbnail_widget_overrule')) { // Look for a photo specific link if ($thumb) { // If it is there... if ($thumb['linkurl']) { // Use it. It superceeds other settings $result['url'] = esc_attr($thumb['linkurl']); $result['title'] = esc_attr(__(stripslashes($thumb['linktitle']))); $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = ''; $result['target'] = $thumb['linktarget']; return $result; } } } $result['target'] = '_self'; $result['title'] = ''; $result['onclick'] = ''; switch ($wich) { case 'sphoto': $type = wppa_opt('sphoto_linktype'); $page = wppa_opt('sphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sphoto_blank')) { $result['target'] = '_blank'; } break; case 'mphoto': $type = wppa_opt('mphoto_linktype'); $page = wppa_opt('mphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('mphoto_blank')) { $result['target'] = '_blank'; } break; case 'thumb': $type = wppa_opt('thumb_linktype'); $page = wppa_opt('thumb_linkpage'); if (wppa_switch('thumb_blank')) { $result['target'] = '_blank'; } break; case 'topten': $type = wppa_opt('topten_widget_linktype'); $page = wppa_opt('topten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('topten_blank')) { $result['target'] = '_blank'; } break; case 'featen': $type = wppa_opt('featen_widget_linktype'); $page = wppa_opt('featen_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('featen_blank')) { $result['target'] = '_blank'; } break; case 'lasten': $type = wppa_opt('lasten_widget_linktype'); $page = wppa_opt('lasten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('lasten_blank')) { $result['target'] = '_blank'; } break; case 'comten': $type = wppa_opt('comment_widget_linktype'); $page = wppa_opt('comment_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('comment_blank')) { $result['target'] = '_blank'; } break; case 'sswidget': $type = wppa_opt('slideonly_widget_linktype'); $page = wppa_opt('slideonly_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sswidget_blank')) { $result['target'] = '_blank'; } $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } break; case 'potdwidget': $type = wppa_opt('widget_linktype'); $page = wppa_opt('widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('potd_blank')) { $result['target'] = '_blank'; } break; case 'coverimg': $type = wppa_opt('coverimg_linktype'); $page = wppa_opt('coverimg_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('coverimg_blank')) { $result['target'] = '_blank'; } if ($type == 'slideshowstartatimage') { $result['url'] = wppa_get_slideshow_url($album, $page, $id); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'tnwidget': $type = wppa_opt('thumbnail_widget_linktype'); $page = wppa_opt('thumbnail_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('thumbnail_widget_blank')) { $result['target'] = '_blank'; } break; case 'slideshow': $type = wppa_opt('slideshow_linktype'); //''; $page = wppa_opt('slideshow_linkpage'); $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } if ($type == 'thumbs') { $result['url'] = wppa_get_ss_to_tn_link($page, $id); $result['title'] = __('View thumbnails', 'wp-photo-album-plus'); $result['is_url'] = true; $result['is_lightbox'] = false; if (wppa_switch('slideshow_blank')) { $result['target'] = '_blank'; } return $result; } if ($type == 'none') { return; } // Continue for 'single' break; case 'albwidget': $type = wppa_opt('album_widget_linktype'); $page = wppa_opt('album_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('album_widget_blank')) { $result['target'] = '_blank'; } break; default: return false; break; } if (!$album) { $album = wppa('start_album'); } if ($album == '' && !wppa('is_upldr')) { /**/ $album = wppa_get_album_id_by_photo_id($id); } if (is_numeric($album)) { $album_name = wppa_get_album_name($album); } else { $album_name = ''; } if (!$album) { $album = '0'; } if ($wich == 'comten') { $album = '0'; } if (wppa('is_tag')) { $album = '0'; } if (wppa('supersearch')) { $album = '0'; } if (wppa('calendar')) { $album = wppa('start_album') ? wppa('start_album') : '0'; } // if ( wppa( 'is_upldr' ) ) $album = '0'; // probeersel upldr parent if ($id) { $photo_name = wppa_get_photo_name($id); } else { $photo_name = ''; } $photo_name_js = esc_js($photo_name); $photo_name = esc_attr($photo_name); if ($id) { $photo_desc = esc_attr(wppa_get_photo_desc($id)); } else { $photo_desc = ''; } $title = __($photo_name, 'wp-photo-album-plus'); $result['onclick'] = ''; // Init switch ($type) { case 'none': // No link at all return false; break; case 'file': // The plain file if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); reset($is_video); $result['url'] = str_replace('xxx', current($is_video), $result['url']); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'lightbox': case 'lightboxsingle': if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] ); } else { if (wppa_switch('lb_hres')) { $result['url'] = wppa_get_hires_url($id); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = true; $result['url'] = wppa_fix_poster_ext($result['url'], $id); return $result; case 'widget': // Defined at widget activation $result['url'] = wppa('in_widget_linkurl'); $result['title'] = esc_attr(wppa('in_widget_linktitle')); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'album': // The albums thumbnails // The albums thumbnails case 'content': // For album widget switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; // $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; //$album_name;//'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'thumbalbum': $album = $thumb['album']; $album_name = wppa_get_album_name($album); switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'photo': // This means: The fullsize photo in a slideshow // This means: The fullsize photo in a slideshow case 'slphoto': // This means: The single photo in the style of a slideshow if ($type == 'slphoto') { $si = '&wppa-single=1'; } else { $si = ''; } switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'single': switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'same': $result['url'] = $lnk; $result['title'] = $tit; $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = $onc; return $result; break; case 'fullpopup': if ($is_video) { // A video can not be printed or downloaded $result['url'] = esc_attr('alert( "' . esc_js(__('A video can not be printed or downloaded', 'wp-photo-album-plus')) . '" )'); } else { $wid = wppa_get_photox($id); $hig = wppa_get_photoy($id); /* $imgsize = getimagesize( wppa_get_photo_path( $id ) ); if ( $imgsize ) { $wid = $imgsize['0']; $hig = $imgsize['1']; } else { $wid = '0'; $hig = '0'; } */ $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id); $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )'); } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = false; return $result; break; case 'custom': if ($wich == 'potdwidget') { $result['url'] = wppa_opt('widget_linkurl'); $result['title'] = wppa_opt('widget_linktitle'); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'slide': // for album widget $result['url'] = wppa_get_permalink(wppa_opt('album_widget_linkpage')) . 'wppa-album=' . $album . '&slide'; $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'autopage': if (!wppa_switch('auto_page')) { wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force'); $result['url'] = ''; } else { $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id)); } $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'plainpage': $result['url'] = get_permalink($page); $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page)); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; default: wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red'); return false; break; } if ($type != 'thumbalbum') { if (wppa('calendar')) { $result['url'] .= '&wppa-calendar=' . wppa('calendar') . '&wppa-caldate=' . wppa('caldate'); } if (wppa('supersearch')) { $result['url'] .= '&wppa-supersearch=' . urlencode(wppa('supersearch')); } if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) { $result['url'] .= '&wppa-searchstring=' . urlencode(wppa('searchstring')); } if ($wich == 'topten') { $result['url'] .= '&wppa-topten=' . wppa_opt('topten_count'); } elseif (wppa('is_topten')) { $result['url'] .= '&wppa-topten=' . wppa('topten_count'); } if ($wich == 'lasten') { $result['url'] .= '&wppa-lasten=' . wppa_opt('lasten_count'); } elseif (wppa('is_lasten')) { $result['url'] .= '&wppa-lasten=' . wppa('lasten_count'); } if ($wich == 'comten') { $result['url'] .= '&wppa-comten=' . wppa_opt('comten_count'); } elseif (wppa('is_comten')) { $result['url'] .= '&wppa-comten=' . wppa('comten_count'); } if ($wich == 'featen') { $result['url'] .= '&wppa-featen=' . wppa_opt('featen_count'); } elseif (wppa('is_featen')) { $result['url'] .= '&wppa-featen=' . wppa('featen_count'); } if (wppa('is_related')) { $result['url'] .= '&wppa-rel=' . wppa('is_related') . '&wppa-relcount=' . wppa('related_count'); } elseif (wppa('is_tag')) { $result['url'] .= '&wppa-tag=' . wppa('is_tag'); } if (wppa('is_upldr')) { $result['url'] .= '&wppa-upldr=' . wppa('is_upldr'); } if (wppa('is_inverse')) { $result['url'] .= '&wppa-inv=1'; } } if ($page != '0') { // on a different page $occur = '1'; $w = ''; } else { // on the same page, post or widget $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur'); $w = wppa_in_widget() ? 'w' : ''; } $result['url'] .= '&wppa-' . $w . 'occur=' . $occur; $result['url'] = wppa_convert_to_pretty($result['url']); if ($result['title'] == '') { $result['title'] = $tit; } // If still nothing, try arg return $result; }
/** @see WP_Widget::form */ function form($instance) { //Defaults $instance = wp_parse_args((array) $instance, array('title' => __('Sidebar Slideshow', 'wp-photo-album-plus'), '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 = esc_attr($instance['title']); $album = $instance['album']; $width = $instance['width']; $height = $instance['height']; $ponly = $instance['ponly']; $linkurl = $instance['linkurl']; $linktitle = $instance['linktitle']; $supertext = $instance['supertext']; $subtext = $instance['subtext']; $valign = $instance['valign']; $timeout = $instance['timeout']; $film = $instance['film']; $browse = $instance['browse']; $name = $instance['name']; $numbar = $instance['numbar']; $desc = $instance['desc']; ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $title; ?> " /></p> <p><label for="<?php echo $this->get_field_id('album'); ?> "><?php _e('Album:', 'wp-photo-album-plus'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('album'); ?> " name="<?php echo $this->get_field_name('album'); ?> "><?php echo '<option value="-2">' . __('--- all ---', 'wp-photo-album-plus') . '</option>' . wppa_album_select_a(array('selected' => $album, 'path' => wppa_switch('wppa_hier_albsel'))); ?> </select></p> <p><?php _e('Enter the width and optionally the height of the area wherein the slides will appear. If you specify a 0 for the height, it will be calculated. The value for the height will be ignored if you set the vertical alignment to \'fit\'.', 'wp-photo-album-plus'); ?> </p> <p><label for="<?php echo $this->get_field_id('width'); ?> "><?php _e('Width:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" style="width:15%;" id="<?php echo $this->get_field_id('width'); ?> " name="<?php echo $this->get_field_name('width'); ?> " type="text" value="<?php echo $width; ?> " /> <?php _e('pixels.', 'wp-photo-album-plus'); ?> <label for="<?php echo $this->get_field_id('height'); ?> "><?php _e('Height:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" style="width:15%;" id="<?php echo $this->get_field_id('height'); ?> " name="<?php echo $this->get_field_name('height'); ?> " type="text" value="<?php echo $height; ?> " /> <?php _e('pixels.', 'wp-photo-album-plus'); ?> </p> <p> <?php _e('Portrait only:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('ponly'); ?> " name="<?php echo $this->get_field_name('ponly'); ?> "> <option value="no" <?php if ($ponly == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no.', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($ponly == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes.', 'wp-photo-album-plus'); ?> </option> </select> <?php _e('Set to \'yes\' if there are only portrait images in the album and you want the photos to fill the full width of the widget.<br/>Set to \'no\' otherwise.', 'wp-photo-album-plus'); ?> <?php _e('If set to \'yes\', Vertical alignment will be forced to \'fit\'.', 'wp-photo-album-plus'); ?> </p> <p> <?php _e('Vertical alignment:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('valign'); ?> " name="<?php echo $this->get_field_name('valign'); ?> "> <option value="top" <?php if ($valign == 'top') { echo ' selected '; } ?> ><?php _e('top', 'wp-photo-album-plus'); ?> </option> <option value="center" <?php if ($valign == 'center') { echo ' selected '; } ?> ><?php _e('center', 'wp-photo-album-plus'); ?> </option> <option value="bottom" <?php if ($valign == 'bottom') { echo ' selected '; } ?> ><?php _e('bottom', 'wp-photo-album-plus'); ?> </option> <option value="fit" <?php if ($valign == 'fit') { echo ' selected '; } ?> ><?php _e('fit', 'wp-photo-album-plus'); ?> </option> </select><br/><?php _e('Set the desired vertical alignment method.', 'wp-photo-album-plus'); ?> </p> <p><label for="<?php echo $this->get_field_id('timeout'); ?> "><?php _e('Slideshow timeout:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" style="width:15%;" id="<?php echo $this->get_field_id('timeout'); ?> " name="<?php echo $this->get_field_name('timeout'); ?> " type="text" value="<?php echo $timeout; ?> " /> <?php _e('sec.', 'wp-photo-album-plus'); ?> </p> <p><label for="<?php echo $this->get_field_id('linkurl'); ?> "><?php _e('Link to:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('linkurl'); ?> " name="<?php echo $this->get_field_name('linkurl'); ?> " type="text" value="<?php echo $linkurl; ?> " /></p> <p> <?php _e('Show name:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('name'); ?> " name="<?php echo $this->get_field_name('name'); ?> "> <option value="no" <?php if ($name == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no.', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($name == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes.', 'wp-photo-album-plus'); ?> </option> </select> </p> <p> <?php _e('Show description:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('desc'); ?> " name="<?php echo $this->get_field_name('desc'); ?> "> <option value="no" <?php if ($desc == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no.', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($desc == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes.', 'wp-photo-album-plus'); ?> </option> </select> </p> <p> <?php _e('Show filmstrip:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('film'); ?> " name="<?php echo $this->get_field_name('film'); ?> "> <option value="no" <?php if ($film == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no.', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($film == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes.', 'wp-photo-album-plus'); ?> </option> </select> </p> <p> <?php _e('Show browsebar:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('browse'); ?> " name="<?php echo $this->get_field_name('browse'); ?> "> <option value="no" <?php if ($browse == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no.', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($browse == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes.', 'wp-photo-album-plus'); ?> </option> </select> </p> <p> <?php _e('Show numbar:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('numbar'); ?> " name="<?php echo $this->get_field_name('numbar'); ?> "> <option value="no" <?php if ($numbar == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no.', 'wp-photo-album-plus'); ?> </option> <option value="yes" <?php if ($numbar == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes.', 'wp-photo-album-plus'); ?> </option> </select> </p> <p><span style="color:blue"><small><?php _e('The following text fields support qTranslate', 'wp-photo-album-plus'); ?> </small></span></p> <p><label for="<?php echo $this->get_field_id('linktitle'); ?> "><?php _e('Tooltip text:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('linktitle'); ?> " name="<?php echo $this->get_field_name('linktitle'); ?> " type="text" value="<?php echo $linktitle; ?> " /></p> <p><label for="<?php echo $this->get_field_id('supertext'); ?> "><?php _e('Text above photos:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('supertext'); ?> " name="<?php echo $this->get_field_name('supertext'); ?> " type="text" value="<?php echo $supertext; ?> " /></p> <p><label for="<?php echo $this->get_field_id('subtext'); ?> "><?php _e('Text below photos:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('subtext'); ?> " name="<?php echo $this->get_field_name('subtext'); ?> " type="text" value="<?php echo $subtext; ?> " /></p> <?php }
function wppa_zoom_in($id) { if ($id === false) { return ''; } if (wppa_switch('show_zoomin')) { if (wppa_opt('magnifier')) { return __('Zoom in', 'wp-photo-album-plus'); } else { return esc_attr(stripslashes(wppa_get_photo_name($id))); } } else { return ''; } }
function wppa_make_tinymce_dialog() { global $wpdb; // Prepare albuminfo $albums = $wpdb->get_results("SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC", ARRAY_A); if (wppa_switch('hier_albsel')) { $albums = wppa_add_paths($albums); $albums = wppa_array_sort($albums, 'name'); } // Prepare photoinfo $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT 100", ARRAY_A); // Get Tags/cats $tags = wppa_get_taglist(); $cats = wppa_get_catlist(); // Make the html $result = '<div id="wppagallery-form">' . '<style type="text/css">' . '#wppagallery-table tr, #wppagallery-table th, #wppagallery-table td {' . 'padding: 2px; 0;' . '}' . '</style>' . '<table id="wppagallery-table" class="form-table">' . '<tr >' . '<th><label for="wppagallery-top-type">' . __('Type of WPPA display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-top-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a display type', 'wp-photo-album-plus') . ' --</option>' . '<option value="galerytype" style="color:#070" >' . __('A gallery with covers and/or thumbnails', 'wp-photo-album-plus') . '</option>' . '<option value="slidestype" style="color:#070" >' . __('A slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="singletype" style="color:#070" >' . __('A single image', 'wp-photo-album-plus') . '</option>' . '<option value="searchtype" style="color:#070" >' . __('A search/selection box', 'wp-photo-album-plus') . '</option>' . '<option value="misceltype" style="color:#070" >' . __('An other box type', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-galery-type-tr" style="display:none;" >' . '<th><label for="wppagallery-galery-type">' . __('Type of gallery display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-galery-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a gallery type', 'wp-photo-album-plus') . ' --</option>' . '<option value="cover" style="color:#070" >' . __('The cover(s) of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="content" style="color:#070" >' . __('The content of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="covers" style="color:#070" >' . __('The covers of the subalbums of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="thumbs" style="color:#070" >' . __('The thumbnails of specific album(s)', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-slides-type-tr" style="display:none;" >' . '<th><label for="wppagallery-slides-type">' . __('Type of slideshow:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-slides-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a slideshow type', 'wp-photo-album-plus') . ' --</option>' . '<option value="slide" style="color:#070" >' . __('A fully featured slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="slideonly" style="color:#070" >' . __('A slideshow without supporting boxes', 'wp-photo-album-plus') . '</option>' . '<option value="slideonlyf" style="color:#070" >' . __('A slideshow with a filmstrip only', 'wp-photo-album-plus') . '</option>' . '<option value="filmonly" style="color:#070" >' . __('A filmstrip only', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-single-type-tr" style="display:none;" >' . '<th><label for="wppagallery-single-type">' . __('Type of single image:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-single-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a single image type', 'wp-photo-album-plus') . ' --</option>' . '<option value="photo" style="color:#070" >' . __('A plain single photo', 'wp-photo-album-plus') . '</option>' . '<option value="mphoto" style="color:#070" >' . __('A single photo with caption', 'wp-photo-album-plus') . '</option>' . '<option value="slphoto" style="color:#070" >' . __('A single photo in the style of a slideshow', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-search-type-tr" style="display:none;" >' . '<th><label for="wppagallery-search-type">' . __('Type of search:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-search-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a search type', 'wp-photo-album-plus') . ' --</option>' . '<option value="search" style="color:#070" >' . __('A search box', 'wp-photo-album-plus') . '</option>' . '<option value="supersearch" style="color:#070" >' . __('A supersearch box', 'wp-photo-album-plus') . '</option>' . '<option value="tagcloud" style="color:#070" >' . __('A tagcloud box', 'wp-photo-album-plus') . '</option>' . '<option value="multitag" style="color:#070" >' . __('A multitag box', 'wp-photo-album-plus') . '</option>' . '<option value="superview" style="color:#070" >' . __('A superview box', 'wp-photo-album-plus') . '</option>' . '<option value="calendar" style="color:#070" >' . __('A calendar box', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-miscel-type-tr" style="display:none;" >' . '<th><label for="wppagallery-miscel-type">' . __('Type miscellaneous:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-miscel-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a miscellaneous display', 'wp-photo-album-plus') . ' --</option>' . '<option value="generic">' . __('A generic albums display', 'wp-photo-album-plus') . '</option>' . '<option value="upload">' . __('An upload box', 'wp-photo-album-plus') . '</option>' . '<option value="landing">' . __('A landing page shortcode', 'wp-photo-album-plus') . '</option>' . '<option value="stereo">' . __('A 3D stereo settings box', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-type-tr" style="display:none;" >' . '<th><label for="wppagallery-album-type">' . __('Kind of selection:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a type of selection to be used', 'wp-photo-album-plus') . ' --</option>' . '<option value="real">' . __('One or more wppa+ albums', 'wp-photo-album-plus') . '</option>' . '<option value="virtual">' . __('A special selection', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-virt-tr" style="display:none;" >' . '<th><label for="wppagallery-album-virt">' . __('The selection to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-virt" name="album" class="wppagallery-album" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a virtual album', 'wp-photo-album-plus') . ' --</option>' . '<option value="#last" >' . __('The most recently modified album', 'wp-photo-album-plus') . '</option>' . '<option value="#topten" >' . __('The top rated photos', 'wp-photo-album-plus') . '</option>' . '<option value="#lasten" >' . __('The most recently uploaded photos', 'wp-photo-album-plus') . '</option>' . '<option value="#featen" >' . __('A random selection of featured photos', 'wp-photo-album-plus') . '</option>' . '<option value="#comten" >' . __('The most recently commented photos', 'wp-photo-album-plus') . '</option>' . '<option value="#tags" >' . __('Photos that have certain tags', 'wp-photo-album-plus') . '</option>' . '<option value="#cat" >' . __('Albums tagged with a certain category', 'wp-photo-album-plus') . '</option>' . '<option value="#owner" >' . __('Photos in albums owned by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#upldr" >' . __('Photos uploaded by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#all" >' . __('All photos in the system', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-virt-cover-tr" style="display:none;" >' . '<th><label for="wppagallery-album-virt-cover">' . __('The selection to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-virt-cover" name="album" class="wppagallery-album" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a virtual album', 'wp-photo-album-plus') . ' --</option>' . '<option value="#last" >' . __('The most recently modified album', 'wp-photo-album-plus') . '</option>' . '<option value="#owner" >' . __('Albums owned by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#cat" >' . __('Albums tagged with a certain category', 'wp-photo-album-plus') . '</option>' . '<option value="#all" >' . __('All albums in the system', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-real-tr" style="display:none;" >' . '<th><label for="wppagallery-album-real">' . __('The Album(s) to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-real" style="max-width:400px;" name="album" multiple="multiple" onchange="wppaGalleryEvaluate()">'; if ($albums) { // Please select $result .= '<option id="wppagallery-album-0" value="0" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select one or more albums', 'wp-photo-album-plus') . ' --</option>'; // All standard albums foreach ($albums as $album) { $id = $album['id']; $result .= '<option class="wppagallery-album-r" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>'; } } else { $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>'; } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-realopt-tr" style="display:none;" >' . '<th><label for="wppagallery-album-realopt">' . __('The Album(s) to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-realopt" style="max-width:400px;" name="album" multiple="multiple" onchange="wppaGalleryEvaluate()">'; if ($albums) { // Please select $result .= '<option id="wppagallery-album-0" class="wppagallery-album-ropt" value="0" selected="selected" style="color:#070" >-- ' . __('All albums', 'wp-photo-album-plus') . ' --</option>'; // All standard albums foreach ($albums as $album) { $id = $album['id']; $result .= '<option class="wppagallery-album-ropt" style="color:#070" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>'; } } else { $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>'; } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-owner-tr" style="display:none" >' . '<th><label for="wppagallery-owner">' . __('The album owner:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-owner" name="owner" class="wppagallery-owner" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a user', 'wp-photo-album-plus') . ' --</option>' . '<option value="#me" >-- ' . __('The logged in visitor', 'wp-photo-album-plus') . ' --</option>'; $users = wppa_get_users(); if ($users) { foreach ($users as $user) { $result .= '<option value="' . $user['user_login'] . '" >' . $user['display_name'] . '</option>'; } } else { // Too many $result .= '<option value="xxx" >-- ' . __('Too many users, edit manually', 'wp-photo-album-plus') . ' --</option>'; } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-owner-parent-tr" style="display:none;" >' . '<th><label for="wppagallery-owner-parent">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-owner-parent" style="color:#070;max-width:400px;" name="parentalbum" multiple="multiple" onchange="wppaGalleryEvaluate()">'; if ($albums) { // Please select $result .= '<option value="" selected="selected" >-- ' . __('No parent specification', 'wp-photo-album-plus') . ' --</option>'; // Generic $result .= '<option value="0" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>'; // All standard albums foreach ($albums as $album) { $id = $album['id']; $result .= '<option class="wppagallery-album-p" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>'; } } else { $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>'; } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-parent-tr" style="display:none;" >' . '<th><label for="wppagallery-album-parent">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-parent-parent" style="color:#070;max-width:400px;" name="parentalbum" onchange="wppaGalleryEvaluate()">'; if ($albums) { // Please select $result .= '<option id="wppagallery-album-0" value="0" selected="selected" style="color:#700" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>'; // All standard albums foreach ($albums as $album) { $id = $album['id']; $result .= '<option class="wppagallery-album" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>'; } } else { $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>'; } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-count-tr" style="display:none;" >' . '<th><label for="wppagallery-album-count">' . __('Max Albums:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-album-count" type="text" style="color:#070;" value="1" onchange="wppaGalleryEvaluate()" />' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-count-tr" style="display:none;" >' . '<th><label for="wppagallery-photo-count">' . __('Max Photos:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-photo-count" type="text" style="color:#070;" value="1" onchange="wppaGalleryEvaluate()" />' . '</td>' . '</tr>' . '<tr id="wppagallery-albumcat-tr" style="display:none;" >' . '<th><label for="wppagallery-albumcat">' . __('The cat the albums should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-albumcat" style="color:#700;" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >' . __('--- please select category ---', 'wp-photo-album-plus') . '</option>'; if ($cats) { foreach (array_keys($cats) as $cat) { $result .= '<option value="' . $cat . '" >' . $cat . '</option>'; } } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-tr" style="display:none;" >' . '<th><label for="wppagallery-photo" class="wppagallery-photo" >' . __('The Photo to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-photo" name="photo" class="wppagallery-photo" onchange="wppaGalleryEvaluate()" >'; if ($photos) { // Please select $result .= '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a photo', 'wp-photo-album-plus') . ' --</option>'; // Most recent 100 photos foreach ($photos as $photo) { $name = stripslashes(__($photo['name'], 'wp-photo-album-plus')); if (strlen($name) > '50') { $name = substr($name, '0', '50') . '...'; } if (get_option('wppa_file_system') == 'flat') { $result .= '<option value="' . wppa_fix_poster_ext($photo['id'] . '.' . $photo['ext'], $photo['id']) . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>'; } else { $result .= '<option value="' . wppa_fix_poster_ext(wppa_expand_id($photo['id']) . '.' . $photo['ext'], $photo['id']) . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>'; } } $result .= '<option value="#last" >-- ' . __('The most recently uploaded photo', 'wp-photo-album-plus') . ' --</option>' . '<option value="#potd" >-- ' . __('The photo of the day', 'wp-photo-album-plus') . ' --</option>'; } else { $result .= '<option value="0" >' . __('There are no photos yet', 'wp-photo-album-plus') . '</option>'; } $result .= '</select>' . '<br />' . '<small style="display:none;" class="wppagallery-photo" >' . __('Specify the photo to be used', 'wp-photo-album-plus') . '<br />' . __('You can select from a maximum of 100 most recently added photos', 'wp-photo-album-plus') . '<br />' . '</small>' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-preview-tr" style="display:none;" >' . '<th><label for="wppagallery-photo-preview" >' . __('Preview image:', 'wp-photo-album-plus') . '</label></th>' . '<td id="wppagallery-photo-preview" style="text-align:center;" >' . '</td >' . '</tr>' . '<tr id="wppagallery-phototags-tr" style="display:none;" >' . '<th><label for="wppagallery-phototags">' . __('The tags the photos should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-phototags" style="color:#700;" multiple="multiple" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >' . __('--- please select tag(s) ---', 'wp-photo-album-plus') . '</option>'; if ($tags) { foreach (array_keys($tags) as $tag) { $result .= '<option class="wppagallery-phototags" value="' . $tag . '" >' . $tag . '</option>'; } } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-search-tr" style="display:none;" >' . '<th><label>' . __('Additional features:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-sub" type="checkbox" name="sub" onchange="wppaGalleryEvaluate()"/>' . __('Enable Subsearch', 'wp-photo-album-plus') . ' ' . '<input id="wppagallery-root" type="checkbox" name="root" onchange="wppaGalleryEvaluate()"/>' . __('Enable Rootsearch', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr id="wppagallery-taglist-tr" style="display:none;" >' . '<th><label>' . __('Additional features:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-alltags" type="checkbox" checked="checked" name="alltags" onchange="wppaGalleryEvaluate()"/>' . __('Enable all tags', 'wp-photo-album-plus') . ' ' . '<select id="wppagallery-seltags" style="color:#070; display:none;" name="seltags" multiple="multiple" onchange="wppaGalleryEvaluate()">'; if ($tags) { '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select the tags to show', 'wp-photo-album-plus') . ' --</option>'; foreach (array_keys($tags) as $tag) { $result .= '<option class="wppagallery-taglist-tags" value="' . $tag . '"style="color:#700" >' . $tag . '</option>'; } } else { '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('There are no tags', 'wp-photo-album-plus') . ' --</option>'; } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-super-tr" style="display:none;" >' . '<th><label for="wppagallery-album-super">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-super-parent" style="color:#070;max-width:400px;" name="parentalbum" onchange="wppaGalleryEvaluate()">'; if ($albums) { // Please select $result .= '<option value="" selected="selected" style="color:#700" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>'; // All standard albums foreach ($albums as $album) { $id = $album['id']; $result .= '<option class="wppagallery-album" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>'; } } else { $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>'; } $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-calendar-tr" style="display:none;" >' . '<th><label for="wppagallery-calendar">' . __('Calendar type:', 'wp-photo-album-plus') . '</lable></th>' . '<td>' . '<select id="wppagallery-calendar-type" style="color:#070;max-width:400px;" onchange="wppaGalleryEvaluate()" >' . '<option value="exifdtm" >' . __('By EXIF date', 'wp-photo-album-plus') . '</option>' . '<option value="timestamp" >' . __('By date of upload', 'wp-photo-album-plus') . '</option>' . '<option value="modified" >' . __('By date last modified', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<input type="checkbox" id="wppagallery-calendar-reverse" onchange="wppaGalleryEvaluate()" >' . __('Last date first', 'wp-photo-album-plus') . ' ' . '<input type="checkbox" id="wppagallery-calendar-allopen" onchange="wppaGalleryEvaluate()" >' . __('Initially display all', 'wppw', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-size">' . __('The size of the display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input type="text" id="wppagallery-size" value="" style="color:#070;" onchange="wppaGalleryEvaluate();"/>' . '<br />' . '<small>' . __('Specify the horizontal size in pixels or <span style="color:blue" >auto</span>.', 'wp-photo-album-plus') . ' ' . __('A value less than <span style="color:blue" >100</span> will automaticly be interpreted as a <span style="color:blue" >percentage</span> of the available space.', 'wp-photo-album-plus') . '<br />' . __('Leave this blank for default size', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-align">' . __('Horizontal alignment:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-align" name="align" style="color:#070;" onchange="wppaGalleryEvaluate();">' . '<option value="none" >' . __('--- none ---', 'wp-photo-album-plus') . '</option>' . '<option value="left" >' . __('left', 'wp-photo-album-plus') . '</option>' . '<option value="center" >' . __('center', 'wp-photo-album-plus') . '</option>' . '<option value="right" >' . __('right', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the alignment to be used or --- none ---', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '</table>' . '<div id="wppagallery-shortcode-preview-container" >' . '<input type="text" id="wppagallery-shortcode-preview" style="background-color:#ddd; width:100%; height:26px;" value="[wppa]Any comment[/wppa]" />' . '</div>' . '<div><small>' . __('This is a preview of the shortcode that is being generated. You may edit the comment', 'wp-photo-album-plus') . '</small></div>' . '<p class="submit">' . '<input type="button" id="wppagallery-submit" class="button-primary" value="' . __('Insert Gallery', 'wp-photo-album-plus') . '" name="submit" /> ' . '<input type="button" id="wppagallery-submit-notok" class="button-secundary" value="' . __('insert Gallery', 'wp-photo-album-plus') . '" onclick="alert(\'' . esc_js(__('Please complete the shortcode specs', 'wp-photo-album-plus')) . '\')" /> ' . '</p>' . '</div>' . '<script type="text/javascript" >wppaGalleryEvaluate();</script>'; return $result; }
function wppa_abs_walktree($root, $source) { static $void_dirs; $result = ''; // Init void dirs if (!$void_dirs) { $void_dirs = array('.', '..', 'wp-admin', 'wp-includes', 'themes', 'upgrade', 'plugins', 'languages', 'wppa', wppa_switch('allow_import_source') ? '' : 'wppa-source'); } // If currently in selected dir, set selected $sel = $root == $source ? ' selected="selected"' : ''; // Set disabled if there are no files inside $n_files = count(glob($root . '/*')); $n_dirs = count(glob($root . '/*', GLOB_ONLYDIR)); $dis = $n_files == $n_dirs ? ' disabled="disabled"' : ''; // Check for (sub)depot $my_depot = __('--- My depot --- ', 'wp-photo-album-plus'); $display = str_replace(WPPA_DEPOT_PATH, $my_depot, $root); if (strpos($display, $my_depot) !== false) { $dis = ''; } // Check for ngg gallery dir $ngg_opts = get_option('ngg_options', false); if ($ngg_opts) { $ngg_gal = __('--- Ngg Galleries --- ', 'wp-photo-album-plus'); $display = str_replace(rtrim($ngg_opts['gallerypath'], '/'), $ngg_gal, $display); $pos = strpos($display, $ngg_gal); if ($pos) { $display = substr($display, $pos); } } // Remove ABSPATH from display string $display = str_replace(ABSPATH, '', $display); // Output the selecion if not in the wp dir if ($root . '/' != ABSPATH) { $result .= '<option' . ' value="' . $root . '"' . $sel . $dis . ' data-nfiles="' . $n_files . '"' . ' data-ndirs="' . $n_dirs . '"' . ' >' . $display . '</option>'; } // See if subdirs exist $dirs = glob($root . '/*', GLOB_ONLYDIR); // Go deeper if not in a list of void disnames if ($dirs) { foreach ($dirs as $path) { $dir = basename($path); if (!in_array($dir, $void_dirs)) { $newroot = $root . '/' . $dir; $result .= wppa_abs_walktree($newroot, $source); } } } return $result; }
function _wppa_comment_admin() { global $wpdb; $continue = true; // Check input wppa_vfy_arg('tab', true); wppa_vfy_arg('edit_id'); wppa_vfy_arg('wppa-page'); wppa_vfy_arg('commentid'); wppa_vfy_arg('delete_id'); if (isset($_GET['tab'])) { if ($_GET['tab'] == 'edit') { $id = $_GET['edit_id']; $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_COMMENTS . " WHERE id = %s LIMIT 1", $id), ARRAY_A); if ($comment) { ?> <div class="wrap"> <?php $iconurl = WPPA_URL . '/img/comment.png'; ?> <div id="icon-album" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> <br /> </div> <h2><?php _e('Photo Albums -> Edit Comment', 'wp-photo-album-plus'); ?> </h2> <?php $action = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments'); if (isset($_GET['wppa-page'])) { $action .= '&compage=' . strval(intval($_GET['wppa-page'])); } if (isset($_GET['commentid'])) { $action .= '&commentid=' . strval(intval($_GET['commentid'])); } ?> <form action="<?php echo $action; ?> " method="post"> <?php wp_nonce_field('$wppa_nonce', WPPA_NONCE); ?> <input type="hidden" name="edit_comment" value="<?php echo $comment['id']; ?> " /> <table class="form-table albumtable"> <tbody> <tr style="vertical-align:top" > <th> <?php $photo = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_PHOTOS . " WHERE id = %s", $comment['photo']), "ARRAY_A"); ?> <?php $url = wppa_fix_poster_ext(wppa_get_thumb_url($comment['photo']), $comment['photo']); ?> <img src="<?php echo $url; ?> " /> </th> <td> <?php echo __($photo['name']) . '<br/><br/>' . __(stripslashes($photo['description'])); ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('Photo:', 'wp-photo-album-plus'); ?> </label></th> <td><?php echo $comment['photo']; ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('Album:', 'wp-photo-album-plus'); ?> </label></th> <td><?php echo wppa_get_album_name($photo['album']); ?> </td> </tr> <tr> <th scope="row"><label ><?php _e('User:'******'wp-photo-album-plus'); ?> </label></th> <td><input style="width:300px;" type="text" name="user" value="<?php echo $comment['user']; ?> " /></td> </tr> <tr> <th scope="row"><label ><?php _e('Email:', 'wp-photo-album-plus'); ?> </label></th> <td><input style="width:300px;" type="text" name="email" value="<?php echo $comment['email']; ?> " /></td> </tr> <tr> <th scope="row"><label><?php _e('Comment:', 'wp-photo-album-plus'); ?> </label></th> <td><textarea style="width:300px; height:150px;" name="comment"><?php echo esc_textarea(stripslashes($comment['comment'])); ?> </textarea></td> </tr> </tbody> </table> <p> <input type="submit" class="button-primary" name="wppa_submit" value="<?php _e('Save Changes', 'wp-photo-album-plus'); ?> " /> </p> </form> <?php } $continue = false; } if ($_GET['tab'] == 'delete') { $id = strval(intval($_GET['delete_id'])); $photo = $wpdb->get_var($wpdb->prepare("SELECT `photo` FROM `" . WPPA_COMMENTS . "` WHERE `id` = %s", $id)); $iret = $wpdb->query($wpdb->prepare("DELETE FROM `" . WPPA_COMMENTS . "` WHERE `id` = %s LIMIT 1", $id)); if ($iret !== false) { if (wppa_switch('search_comments')) { wppa_index_update('photo', $photo); } wppa_update_message(__('Comment deleted', 'wp-photo-album-plus')); } else { wppa_error_message('Error deleting comment'); } $continue = true; } } if ($continue) { // Update anything or do bulkaction if (isset($_POST['wppa_submit'])) { // Security check check_admin_referer('$wppa_nonce', WPPA_NONCE); // Updates $iret = true; if (isset($_POST['wppa_comadmin_show'])) { wppa_update_option('wppa_comadmin_show', $_POST['wppa_comadmin_show']); } if (isset($_POST['wppa_comadmin_linkpage'])) { wppa_update_option('wppa_comadmin_linkpage', $_POST['wppa_comadmin_linkpage']); } if (isset($_POST['wppa_comadmin_order'])) { wppa_update_option('wppa_comadmin_order', $_POST['wppa_comadmin_order']); } if (isset($_POST['edit_comment'])) { $iret = wppa_edit_comment($_POST['edit_comment']); } // Bulk actions if (isset($_POST['bulkaction'])) { switch ($_POST['bulkaction']) { case 'approveall': $coms_to_proc = $wpdb->get_results("SELECT `id` FROM `" . WPPA_COMMENTS . "` WHERE status = 'pending'", ARRAY_A); $query = "UPDATE " . WPPA_COMMENTS . " SET status = 'approved' WHERE status = 'pending'"; if ($wpdb->query($query) === false) { wppa_error_message(__('Could not bulk update status', 'wp-photo-album-plus')); $iret = false; } else { if ($coms_to_proc) { foreach ($coms_to_proc as $item) { wppa_send_comment_approved_email($item['id']); } } $iret = true; } break; case 'spamall': $query = "UPDATE " . WPPA_COMMENTS . " SET status = 'spam' WHERE status = 'pending'"; if ($wpdb->query($query) === false) { wppa_error_message(__('Could not bulk update status', 'wp-photo-album-plus')); $iret = false; } else { $iret = true; } break; case 'delspam': $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status = 'spam'"; if ($wpdb->query($query) === false) { wppa_error_message(__('Could not bulk delete spam', 'wp-photo-album-plus')); $iret = false; } break; } } if ($iret) { wppa_update_message(__('Changes Saved', 'wp-photo-album-plus')); } // Clear (super)cache wppa_clear_cache(); } // Submit // Delete trash $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status = 'trash'"; $wpdb->query($query); // Initialize normal display $wppa_comadmin_linkpage = get_option('wppa_comadmin_linkpage', '0'); if ($wppa_comadmin_linkpage) { $exists = $wpdb->get_var("SELECT `post_title` FROM `" . $wpdb->posts . "` WHERE `ID` = " . $wppa_comadmin_linkpage); if (!$exists) { $wppa_comadmin_linkpage = '0'; update_option('wppa_comadmin_linkpage', '0'); } } $moderating = isset($_REQUEST['commentid']); ?> <div class="wrap"> <?php $iconurl = WPPA_URL . '/img/comment.png'; ?> <div id="icon-album" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> <br /> </div> <h2> <?php if ($moderating) { _e('Photo Albums -> Moderate Comment', 'wp-photo-album-plus'); } else { _e('Photo Albums -> Comment admin', 'wp-photo-album-plus'); } ?> </h2> <?php if (!wppa_switch('show_comments')) { _e('<h3>The Comment system is not activated</h3><p>To activate: check Table II item 18 on the <b>Photo Albums -> Settings</b> screen and press <b>Save Changes</b>', 'wp-photo-album-plus'); } ?> <?php if (!$moderating) { ?> <!-- Statistics --> <table> <tbody> <tr> <td><h3 style="margin:0; color:#777777;"><?php _e('Total:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "`"); echo $count; ?> </h3></td> </tr> <tr> <td><h3 style="margin:0; color:green;"><?php _e('Approved:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'approved'"); echo $count; ?> </h3></td> </tr> <tr> <td><h3 style="margin:0; color:#e66f00;"><?php _e('Pending:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'pending'"); echo $count; ?> </h3></td> </tr> <tr> <td><h3 style="margin:0; color:red;"><?php _e('Spam:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'spam'"); echo $count; ?> </h3></td> </tr> <?php if (wppa_opt('spam_maxage') != 'none') { ?> <tr> <td><h3 style="margin:0; color:red;"><?php _e('Auto deleted spam:', 'wp-photo-album-plus'); ?> </h3></td> <td><h3 style="margin:0;"><?php echo get_option('wppa_spam_auto_delcount', '0'); ?> </h3></td> </tr> <?php } ?> </tbody> </table> <!-- end statistics --> <!-- Settings --> <div style="border:1px solid #ccc; padding:4px; margin:4px 0" > <h3><?php _e('Settings', 'wp-photo-album-plus'); ?> </h3> <form action="<?php echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments'); ?> " method="post"> <p> <?php wp_nonce_field('$wppa_nonce', WPPA_NONCE); _e('Linkpage:', 'wp-photo-album-plus'); ?> <select name="wppa_comadmin_linkpage"> <option value="0" <?php if ($wppa_comadmin_linkpage == '0') { echo 'selected="selected"'; } ?> disabled="disabled" ><?php _e('--- Please select a page ---', 'wp-photo-album-plus'); ?> </option> <?php $query = "SELECT `ID`, `post_title`, `post_content` FROM `" . $wpdb->posts . "` WHERE `post_type` = 'page' AND `post_status` = 'publish' ORDER BY `post_title` ASC"; $pages = $wpdb->get_results($query, ARRAY_A); if ($pages) { foreach ($pages as $page) { if (stripos($page['post_content'], '%%wppa%%') !== false || stripos($page['post_content'], '[wppa') !== false) { if ($wppa_comadmin_linkpage == $page['ID']) { $sel = 'selected="selected"'; } else { $sel = ''; } echo '<option value="' . $page['ID'] . '" ' . $sel . '>' . __($page['post_title'], 'wp-photo-album-plus') . '</option>'; } } } ?> </select> <?php _e('You can see the photo and all its comments on the selected page by clicking on the thumbnail image', 'wp-photo-album-plus'); ?> </p> <?php $comment_show = wppa_opt('comadmin_show'); ?> <p> <?php _e('Display status:', 'wp-photo-album-plus'); ?> <select name="wppa_comadmin_show"> <option value="all" <?php if ($comment_show == 'all') { echo 'selected="selected"'; } ?> ><?php _e('all', 'wp-photo-album-plus'); ?> </option> <option value="pending" <?php if ($comment_show == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('pending', 'wp-photo-album-plus'); ?> </option> <option value="approved" <?php if ($comment_show == 'approved') { echo 'selected="selected"'; } ?> ><?php _e('approved', 'wp-photo-album-plus'); ?> </option> <option value="spam" <?php if ($comment_show == 'spam') { echo 'selected="selected"'; } ?> ><?php _e('spam', 'wp-photo-album-plus'); ?> </option> </select> <?php $comment_order = wppa_opt('comadmin_order'); ?> <?php _e('Display order:', 'wp-photo-album-plus'); ?> <select name="wppa_comadmin_order"> <option value="timestamp" <?php if ($comment_order == 'timestamp') { echo 'selected="selected"'; } ?> ><?php _e('timestamp', 'wp-photo-album-plus'); ?> </option> <option value="photo" <?php if ($comment_order == 'photo') { echo 'selected="selected"'; } ?> ><?php _e('photo', 'wp-photo-album-plus'); ?> </option> </select> <?php _e('Bulk action:', 'wp-photo-album-plus'); ?> <select name="bulkaction"> <option value=""><?php ?> </option> <option value="approveall"><?php _e('Approve all pending', 'wp-photo-album-plus'); ?> </option> <option value="spamall"><?php _e('Move all pending to spam', 'wp-photo-album-plus'); ?> </option> <option value="delspam"><?php _e('Delete all spam', 'wp-photo-album-plus'); ?> </option> </select> <input type="submit" class="button-primary" name="wppa_submit" value="<?php _e('Save Settings / Perform bulk action', 'wp-photo-album-plus'); ?> " /> </p> </form> </div> <!-- End Settings --> <?php } if ($moderating) { $pagesize = '1'; $where = " WHERE `id` = '" . $_REQUEST['commentid'] . "'"; $order = ''; $curpage = '1'; $limit = ''; } else { $pagsize = wppa_opt('comment_admin_pagesize'); $where = $comment_show == 'all' ? '' : " WHERE `status` = '" . $comment_show . "'"; $order = " ORDER BY `" . $comment_order . "`"; if ($comment_order == 'timestamp') { $order .= " DESC"; } if (isset($_GET['wppa-page'])) { $curpage = strval(intval($_GET['wppa-page'])); $offset = (strval(intval($_GET['wppa-page'])) - 1) * $pagsize; $limit = " LIMIT " . $offset . "," . $pagsize; } else { $limit = ' LIMIT 0,' . $pagsize; $curpage = '1'; } if ($pagsize == '0') { $limit = ''; } // Paginating is off $nitems = $wpdb->get_var("SELECT COUNT(*) FROM " . WPPA_COMMENTS . $where); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments'); wppa_admin_page_links($curpage, $pagsize, $nitems, $link); } ?> <table class="widefat"> <thead style="font-weight: bold" class=""> <tr> <th scope="col"><?php _e('Photo', 'wp-photo-album-plus'); ?> <br /> <?php _e('(Album)', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('#', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('IP', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('User', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Email', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Time since', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Comment', 'wp-photo-album-plus'); ?> </th> <th scope="col" style="width: 130px;" ><?php _e('Status', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Edit', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Delete', 'wp-photo-album-plus'); ?> </th> </tr> </thead> <tbody class="wppa_table_1"> <?php $comments = $wpdb->get_results("SELECT * FROM `" . WPPA_COMMENTS . "`" . $where . $order . $limit, ARRAY_A); if ($comments) { foreach ($comments as $com) { ?> <tr> <?php $photo = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_PHOTOS . " WHERE id = %s", $com['photo']), 'ARRAY_A'); if ($photo) { $alb = $photo['album']; $pname = __($photo['name'], 'wp-photo-album-plus'); $albname = '(' . wppa_get_album_name($alb) . ')'; } else { $alb = ''; $pname = ''; $albname = ''; } if ($wppa_comadmin_linkpage == '0') { ?> <td style="text-align:center"> <img src="<?php echo wppa_fix_poster_ext(wppa_get_thumb_url($com['photo']), $com['photo']); ?> " style="max-height:64px;max-width:64px;" /> <br /> <?php echo $albname; ?> </td><?php } else { $url = get_page_link($wppa_comadmin_linkpage); if (strpos($url, '?')) { $url .= '&'; } else { $url .= '?'; } $url .= 'wppa-album=' . $alb . '&wppa-photo=' . $com['photo'] . '&wppa-occur=1'; ?> <td style="text-align:center"> <a href="<?php echo $url; ?> " target="_blank"> <img title="<?php _e('Click to see the fullsize photo and all comments', 'wp-photo-album-plus'); ?> " src="<?php echo wppa_fix_poster_ext(wppa_get_thumb_url($com['photo']), $com['photo']); ?> " style="max-height:64px;max-width:64px;" /> </a> <br /> <?php echo $albname; ?> </td><?php } ?> <td><?php echo $com['photo']; ?> </td> <td><?php echo $com['ip']; ?> </td> <td><?php echo $com['user']; ?> </td> <td><?php if ($com['email']) { $subject = str_replace(' ', '%20', sprintf(__('Reply to your comment on photo: %s on %s', 'wp-photo-album-plus'), $pname, get_bloginfo('name'))); echo '<a href="mailto:' . $com['email'] . '?Subject=' . $subject . '" title="' . __('Reply', 'wp-photo-album-plus') . '" >' . $com['email'] . '</a>'; } else { echo $com['email']; } ?> </td> <td><?php echo wppa_get_time_since($com['timestamp']); ?> </td> <td><?php echo stripslashes($com['comment']); ?> </td> <td> <input type="hidden" id="photo-nonce-<?php echo $com['photo']; ?> " value="<?php echo wp_create_nonce('wppa_nonce_' . $com['photo']); ?> " /> <select name="status['<?php echo $com['id']; ?> ']" onchange="jQuery('#wppa-comment-spin-<?php echo $com['id']; ?> ').css('visibility', 'visible'); wppaAjaxUpdateCommentStatus(<?php echo $com['photo']; ?> , <?php echo $com['id']; ?> , this.value)"> <option value="pending" <?php if ($com['status'] == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('Pending', 'wp-photo-album-plus'); ?> </option> <option value="approved" <?php if ($com['status'] == 'approved') { echo 'selected="selected"'; } ?> ><?php _e('Approved', 'wp-photo-album-plus'); ?> </option> <option value="spam" <?php if ($com['status'] == 'spam') { echo 'selected="selected"'; } ?> ><?php _e('Spam', 'wp-photo-album-plus'); ?> </option> </select> <img id="wppa-comment-spin-<?php echo $com['id']; ?> " src="<?php echo wppa_get_imgdir() . 'spinner.gif'; ?> " style="visibility:hidden" /> </td> <?php $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments&tab=edit&edit_id=' . $com['id']); if (isset($_GET['wppa-page'])) { $url .= '&compage=' . strval(intval($_GET['wppa-page'])); } if (isset($_GET['commentid'])) { $url .= '&commentid=' . strval(intval($_GET['commentid'])); } ?> <?php $delurl = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments&tab=delete&delete_id=' . $com['id']); ?> <td style="color:green; cursor:pointer;" onclick="document.location='<?php echo $url; ?> '"><b><?php _e('Edit', 'wp-photo-album-plus'); ?> </b></td> <td style="color:red; cursor:pointer;" onclick="if (confirm('<?php _e('Are you sure you want to delete this comment?', 'wp-photo-album-plus'); ?> ')) document.location = '<?php echo $delurl; ?> ';"><b><?php _e('Delete', 'wp-photo-album-plus'); ?> </b></td> </tr> <?php } } ?> </tbody> <tfoot style="font-weight: bold" class=""> <tr> <th scope="col"><?php _e('Photo', 'wp-photo-album-plus'); ?> <br /> <?php _e('(Album)', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('#', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('IP', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('User', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Email', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Time since', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Comment', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Status', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Edit', 'wp-photo-album-plus'); ?> </th> <th scope="col"><?php _e('Delete', 'wp-photo-album-plus'); ?> </th> </tr> </tfoot> </table> <?php if (!$moderating) { wppa_admin_page_links($curpage, $pagsize, $nitems, $link); } ?> </form> </div> <?php } }
function wppa_wppa_on_page() { global $wppa_first_id; // Feature enabled? if (!wppa_switch('js_css_optional')) { return true; } // Init $ID = get_the_ID(); // Remember the first ID if (!$wppa_first_id) { if ($ID) { $wppa_first_id = $ID; } } // Look up $pages = wppa_index_string_to_array(get_option('wppa_on_pages_list')); $result = in_array($ID, $pages); return $result; }
/** @see WP_Widget::form */ function form($instance) { //Defaults $instance = wp_parse_args((array) $instance, array('sortby' => 'mean_rating', 'title' => __('Top Ten Photos', 'wp-photo-album-plus'), 'album' => '0', 'display' => 'thumbs', 'meanrat' => 'yes', 'ratcount' => 'yes', 'viewcount' => 'yes', 'includesubs' => 'yes', 'medalsonly' => 'no', 'showowner' => 'no', 'showalbum' => 'no')); $widget_title = apply_filters('widget_title', $instance['title']); $sortby = $instance['sortby']; $album = $instance['album']; $display = $instance['display']; $meanrat = $instance['meanrat']; $ratcount = $instance['ratcount']; $viewcount = $instance['viewcount']; $includesubs = $instance['includesubs']; $medalsonly = $instance['medalsonly']; $showowner = $instance['showowner']; $showalbum = $instance['showalbum']; ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'wp-photo-album-plus'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $widget_title; ?> " /> </p> <p><label for="<?php echo $this->get_field_id('album'); ?> "><?php _e('Album:', 'wp-photo-album-plus'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('album'); ?> " name="<?php echo $this->get_field_name('album'); ?> " > <?php echo wppa_album_select_a(array('selected' => $album, 'addall' => true, 'addowner' => true, 'path' => wppa_switch('hier_albsel'))); ?> </select> </p> <p> <?php _e('Display:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('display'); ?> " name="<?php echo $this->get_field_name('display'); ?> "> <option value="thumbs" <?php if ($display == 'thumbs') { echo 'selected="selected"'; } ?> ><?php _e('thumbnail images', 'wp-photo-album-plus'); ?> </option> <option value="names" <?php if ($display == 'names') { echo 'selected="selected"'; } ?> ><?php _e('photo names', 'wp-photo-album-plus'); ?> </option> </select> </p> <p><label for="<?php echo $this->get_field_id('sortby'); ?> "><?php _e('Sort by:', 'wp-photo-album-plus'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('sortby'); ?> " name="<?php echo $this->get_field_name('sortby'); ?> " > <option value="mean_rating" <?php if ($instance['sortby'] == 'mean_rating') { echo 'selected="selected"'; } ?> ><?php _e('Mean value', 'wp-photo-album-plus'); ?> </option> <option value="rating_count" <?php if ($instance['sortby'] == 'rating_count') { echo 'selected="selected"'; } ?> ><?php _e('Number of votes', 'wp-photo-album-plus'); ?> </option> <option value="views" <?php if ($instance['sortby'] == 'views') { echo 'selected="selected"'; } ?> ><?php _e('Number of views', 'wp-photo-album-plus'); ?> </option> </select> </p> <p><label for="<?php echo $this->get_field_id('includesubs'); ?> "><?php _e('Include sub albums:', 'wp-photo-album-plus'); ?> </label> <select id="<?php echo $this->get_field_id('includesubs'); ?> " name="<?php echo $this->get_field_name('includesubs'); ?> " > <option value="yes" <?php if ($includesubs == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes', 'wp-photo-album-plus'); ?> </option> <option value="no" <?php if ($includesubs == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no', 'wp-photo-album-plus'); ?> </option> </select> </p> <p><label for="<?php echo $this->get_field_id('medalsonly'); ?> "><?php _e('Only with medals:', 'wp-photo-album-plus'); ?> </label> <select id="<?php echo $this->get_field_id('medalsonly'); ?> " name="<?php echo $this->get_field_name('medalsonly'); ?> " > <option value="yes" <?php if ($medalsonly == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes', 'wp-photo-album-plus'); ?> </option> <option value="no" <?php if ($medalsonly == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no', 'wp-photo-album-plus'); ?> </option> </select> </p> <p><label ><?php _e('Subtitle:', 'wp-photo-album-plus'); ?> </label> <br /><?php _e('Show owner:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('showowner'); ?> " name="<?php echo $this->get_field_name('showowner'); ?> " > <option value="yes" <?php if ($showowner == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes', 'wp-photo-album-plus'); ?> </option> <option value="no" <?php if ($showowner == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no', 'wp-photo-album-plus'); ?> </option> </select> <br /><?php _e('Show album:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('showalbum'); ?> " name="<?php echo $this->get_field_name('showalbum'); ?> " > <option value="yes" <?php if ($showalbum == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes', 'wp-photo-album-plus'); ?> </option> <option value="no" <?php if ($showalbum == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no', 'wp-photo-album-plus'); ?> </option> </select> <br /><?php _e('Mean rating:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('meanrat'); ?> " name="<?php echo $this->get_field_name('meanrat'); ?> " > <option value="yes" <?php if ($meanrat == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes', 'wp-photo-album-plus'); ?> </option> <option value="no" <?php if ($meanrat == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no', 'wp-photo-album-plus'); ?> </option> </select> <br /><?php _e('Rating count:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('ratcount'); ?> " name="<?php echo $this->get_field_name('ratcount'); ?> " > <option value="yes" <?php if ($ratcount == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes', 'wp-photo-album-plus'); ?> </option> <option value="no" <?php if ($ratcount == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no', 'wp-photo-album-plus'); ?> </option> </select> <br /><?php _e('View count:', 'wp-photo-album-plus'); ?> <select id="<?php echo $this->get_field_id('viewcount'); ?> " name="<?php echo $this->get_field_name('viewcount'); ?> " > <option value="yes" <?php if ($viewcount == 'yes') { echo 'selected="selected"'; } ?> ><?php _e('yes', 'wp-photo-album-plus'); ?> </option> <option value="no" <?php if ($viewcount == 'no') { echo 'selected="selected"'; } ?> ><?php _e('no', 'wp-photo-album-plus'); ?> </option> </select> </p> <p><?php _e('You can set the sizes in this widget in the <b>Photo Albums -> Settings</b> admin page.', 'wp-photo-album-plus'); ?> </p> <?php }
function wppa_album_select_a($args) { global $wpdb; $args = wp_parse_args($args, array('exclude' => '', 'selected' => '', 'disabled' => '', 'addpleaseselect' => false, 'addnone' => false, 'addall' => false, 'addgeneric' => false, 'addblank' => false, 'addselected' => false, 'addseparate' => false, 'addselbox' => false, 'disableancestors' => false, 'checkaccess' => false, 'checkowner' => false, 'checkupload' => false, 'addmultiple' => false, 'addnumbers' => false, 'path' => false, 'root' => false, 'content' => false, 'sort' => true)); // Provide default selection if no selected given if ($args['selected'] === '') { $args['selected'] = wppa_get_last_album(); } // See if selection is valid if ($args['selected'] == $args['exclude'] || $args['checkupload'] && !wppa_allow_uploads($args['selected']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $args['selected'])) { $args['selected'] = '0'; } $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` " . wppa_get_album_order($args['root']), ARRAY_A); // Add to secondary cache if ($albums) { wppa_cache_album('add', $albums); } if ($albums) { // Filter for root if ($args['root']) { $root = $args['root']; switch ($root) { // case '0': all, will be skipped as it returns false in 'if ( $args['root'] )' case '-2': // Generic only foreach (array_keys($albums) as $albidx) { if (wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; case '-1': // Separate only foreach (array_keys($albums) as $albidx) { if (!wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; default: foreach (array_keys($albums) as $albidx) { if (!wppa_is_ancestor($root, $albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; } } // Filter for must have content if ($args['content']) { foreach (array_keys($albums) as $albidx) { if (wppa_get_photo_count($albums[$albidx]['id']) <= wppa_get_mincount()) { unset($albums[$albidx]); } } } // Add paths if ($args['path']) { $albums = wppa_add_paths($albums); } else { foreach (array_keys($albums) as $index) { $albums[$index]['name'] = __(stripslashes($albums[$index]['name'])); } } // Sort if ($args['sort']) { $albums = wppa_array_sort($albums, 'name'); } } // Output $result = ''; $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addpleaseselect']) { $result .= '<option value="0" disabled="disabled" ' . $selected . ' >' . (is_admin() ? __('- select an album -', 'wppa') : __a('- select an album -')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addnone']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- none ---', 'wppa') : __a('--- none ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- all ---', 'wppa') : __a('--- all ---')) . '</option>'; } $selected = $args['selected'] == '-2' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="-2"' . $selected . ' >' . (is_admin() ? __('--- generic ---', 'wppa') : __a('--- generic ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addblank']) { $result .= '<option value="0"' . $selected . ' >' . '</option>'; } $selected = $args['selected'] == '-99' ? ' selected="selected"' : ''; if ($args['addmultiple']) { $result .= '<option value="-99"' . $selected . ' >' . (is_admin() ? __('--- multiple see below ---', 'wppa') : __a('--- multiple see below ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addselbox']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- a selection box ---', 'wppa') : __a('--- a selection box ---')) . '</option>'; } if ($albums) { foreach ($albums as $album) { if ($args['disabled'] == $album['id'] || $args['exclude'] == $album['id'] || $args['checkupload'] && !wppa_allow_uploads($album['id']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $album['id'])) { $disabled = ' disabled="disabled"'; } else { $disabled = ''; } if ($args['selected'] == $album['id'] && !$disabled) { $selected = ' selected="selected"'; } else { $selected = ''; } $ok = true; // Assume this will be in the list if ($args['checkaccess'] && !wppa_have_access($album['id'])) { $ok = false; } if ($args['checkowner'] && wppa_switch('upload_owner_only')) { // Need to check if ($album['owner'] != wppa_get_user() && $album['owner'] != '--- public ---') { // Not 'mine' if (!wppa_user_is('administrator')) { // No admin $ok = false; } } } if ($selected && $args['addselected']) { $ok = true; } if ($ok) { if ($args['addnumbers']) { $number = ' ( ' . $album['id'] . ' )'; } else { $number = ''; } $result .= '<option value="' . $album['id'] . '" ' . $selected . $disabled . '>' . $album['name'] . $number . '</option>'; } } } $selected = $args['selected'] == '-1' ? ' selected="selected"' : ''; if ($args['addseparate']) { $result .= '<option value="-1"' . $selected . '>' . (is_admin() ? __('--- separate ---', 'wppa') : __a('--- separate ---')) . '</option>'; } return $result; }
function wppa_share($opt = '') { if (is_feed()) { return; } $do_it = false; if ($opt != 'optional') { $do_it = true; } if (!wppa('is_slideonly')) { if (wppa_switch('share_on') && !wppa_in_widget()) { $do_it = true; } if (wppa_switch('share_on_widget') && wppa_in_widget()) { $do_it = true; } } if ($do_it) { wppa_out('<div' . ' id="wppa-share-' . wppa('mocc') . '"' . ' class="wppa-box wppa-box-text wppa-share"' . ' style="text-align: center; ' . __wcs('wppa-box') . __wcs('wppa-box-text') . __wcs('wppa-share') . '"' . ' >' . '</div>'); } }
function wppa_maintenance_messages() { if (!current_user_can('wppa_settings')) { return; } if (get_option('wppa_remake_index_photos_status') || get_option('wppa_index_need_remake', 'no') == 'yes') { wppa_error_message(__('</strong>The photo index table needs to be rebuilt. Please run <b>Photo Albums -> Settings</b> admin page <b>Table VIII-A9</b><strong>', 'wppa')); update_option('wppa_remake_index_photos_status', 'required'); } if (get_option('wppa_remake_index_albums_status') || get_option('wppa_index_need_remake', 'no') == 'yes') { wppa_error_message(__('</strong>The album index table needs to be rebuilt. Please run <b>Photo Albums -> Settings</b> admin page <b>Table VIII-A8</b><strong>', 'wppa')); update_option('wppa_remake_index_albums_status', 'required'); } if (wppa_switch('wppa_rating_on') && get_option('wppa_rerate_status')) { wppa_error_message(__('</strong>The avarage ratings need to be recalculated. Please run <b>Photo Albums -> Settings</b> admin page <b>Table VIII-A5</b><strong>', 'wppa')); } }
function __wcs($class) { global $wppa; if (!wppa_switch('wppa_inline_css')) { return ''; // No inline styles } $opt = ''; $result = ''; switch ($class) { case 'wppa-box': $opt = wppa_opt('wppa_bwidth'); if ($opt > '0') { $result .= 'border-style: solid; border-width:' . $opt . 'px; '; } $opt = wppa_opt('wppa_bradius'); if ($opt > '0') { $result .= 'border-radius:' . $opt . 'px; '; $result .= '-moz-border-radius:' . $opt . 'px; '; $result .= '-khtml-border-radius:' . $opt . 'px; '; $result .= '-webkit-border-radius:' . $opt . 'px; '; } $opt = wppa_opt('wppa_box_spacing'); if ($opt != '') { $result .= 'margin-bottom:' . $opt . 'px; '; } break; case 'wppa-mini-box': $opt = wppa_opt('wppa_bwidth'); if ($opt > '0') { $opt = floor(($opt + 2) / 3); $result .= 'border-style: solid; border-width:' . $opt . 'px; '; } $opt = wppa_opt('wppa_bradius'); if ($opt > '0') { $opt = floor(($opt + 2) / 3); $result .= 'border-radius:' . $opt . 'px; '; $result .= '-moz-border-radius:' . $opt . 'px; '; $result .= '-khtml-border-radius:' . $opt . 'px; '; $result .= '-webkit-border-radius:' . $opt . 'px; '; } break; case 'wppa-cover-box': $opt = wppa_opt('wppa_cover_minheight'); if ($opt) { $result .= 'min-height:' . $opt . 'px; '; } break; case 'wppa-cover-text-frame': $opt = wppa_opt('wppa_head_and_text_frame_height'); if ($opt) { $result .= 'min-height:' . $opt . 'px; '; } break; case 'wppa-thumb-text': $opt = wppa_opt('wppa_fontfamily_thumb'); if ($opt) { $result .= 'font-family:' . $opt . '; '; } $opt = wppa_opt('wppa_fontsize_thumb'); if ($opt) { $ls = floor($opt * 1.29); $result .= 'font-size:' . $opt . 'px; line-height:' . $ls . 'px; '; } $opt = wppa_opt('wppa_fontcolor_thumb'); if ($opt) { $result .= 'color:' . $opt . '; '; } $opt = wppa_opt('wppa_fontweight_thumb'); if ($opt) { $result .= 'font-weight:' . $opt . '; '; } break; case 'wppa-box-text': $opt = wppa_opt('wppa_fontcolor_box'); if ($opt) { $result .= 'color:' . $opt . '; '; } case 'wppa-box-text-nocolor': $opt = wppa_opt('wppa_fontfamily_box'); if ($opt) { $result .= 'font-family:' . $opt . '; '; } $opt = wppa_opt('wppa_fontsize_box'); if ($opt) { $result .= 'font-size:' . $opt . 'px; '; } $opt = wppa_opt('wppa_fontweight_box'); if ($opt) { $result .= 'font-weight:' . $opt . '; '; } break; case 'wppa-comments': $opt = wppa_opt('wppa_bgcolor_com'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_com'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-iptc': $opt = wppa_opt('wppa_bgcolor_iptc'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_iptc'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-exif': $opt = wppa_opt('wppa_bgcolor_exif'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_exif'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-share': $opt = wppa_opt('wppa_bgcolor_share'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_share'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-name-desc': $opt = wppa_opt('wppa_bgcolor_namedesc'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_namedesc'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-nav': $opt = wppa_opt('wppa_bgcolor_nav'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_nav'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-nav-text': $opt = wppa_opt('wppa_fontfamily_nav'); if ($opt) { $result .= 'font-family:' . $opt . '; '; } $opt = wppa_opt('wppa_fontsize_nav'); if ($opt) { $result .= 'font-size:' . $opt . 'px; '; } $opt = wppa_opt('wppa_fontcolor_nav'); if ($opt) { $result .= 'color:' . $opt . '; '; } $opt = wppa_opt('wppa_fontweight_nav'); if ($opt) { $result .= 'font-weight:' . $opt . '; '; } break; case 'wppa-even': $opt = wppa_opt('wppa_bgcolor_even'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_even'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-alt': $opt = wppa_opt('wppa_bgcolor_alt'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_alt'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-img': $opt = wppa_opt('wppa_bgcolor_img'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } break; case 'wppa-title': $opt = wppa_opt('wppa_fontfamily_title'); if ($opt) { $result .= 'font-family:' . $opt . '; '; } $opt = wppa_opt('wppa_fontsize_title'); if ($opt) { $result .= 'font-size:' . $opt . 'px; '; } $opt = wppa_opt('wppa_fontcolor_title'); if ($opt) { $result .= 'color:' . $opt . '; '; } $opt = wppa_opt('wppa_fontweight_title'); if ($opt) { $result .= 'font-weight:' . $opt . '; '; } break; case 'wppa-fulldesc': $opt = wppa_opt('wppa_fontfamily_fulldesc'); if ($opt) { $result .= 'font-family:' . $opt . '; '; } $opt = wppa_opt('wppa_fontsize_fulldesc'); if ($opt) { $result .= 'font-size:' . $opt . 'px; '; } $opt = wppa_opt('wppa_fontcolor_fulldesc'); if ($opt) { $result .= 'color:' . $opt . '; '; } $opt = wppa_opt('wppa_fontweight_fulldesc'); if ($opt) { $result .= 'font-weight:' . $opt . '; '; } break; case 'wppa-fulltitle': $opt = wppa_opt('wppa_fontfamily_fulltitle'); if ($opt) { $result .= 'font-family:' . $opt . '; '; } $opt = wppa_opt('wppa_fontsize_fulltitle'); if ($opt) { $result .= 'font-size:' . $opt . 'px; '; } $opt = wppa_opt('wppa_fontcolor_fulltitle'); if ($opt) { $result .= 'color:' . $opt . '; '; } $opt = wppa_opt('wppa_fontweight_fulltitle'); if ($opt) { $result .= 'font-weight:' . $opt . '; '; } break; case 'wppa-custom': $opt = wppa_opt('wppa_bgcolor_cus'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_cus'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-upload': $opt = wppa_opt('wppa_bgcolor_upload'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_upload'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-multitag': $opt = wppa_opt('wppa_bgcolor_multitag'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_multitag'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-bestof': $opt = wppa_opt('wppa_bgcolor_bestof'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_bestof'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-tagcloud': $opt = wppa_opt('wppa_bgcolor_tagcloud'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_tagcloud'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-superview': $opt = wppa_opt('wppa_bgcolor_superview'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_superview'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-search': $opt = wppa_opt('wppa_bgcolor_search'); if ($opt) { $result .= 'background-color:' . $opt . '; '; } $opt = wppa_opt('wppa_bcolor_search'); if ($opt) { $result .= 'border-color:' . $opt . '; '; } break; case 'wppa-black': // $opt = wppa_opt( 'wppa_black' ); // if ( $opt ) $result .= 'color:' . $opt . '; '; // break; break; case 'wppa-arrow': $opt = wppa_opt('wppa_arrow_color'); if ($opt) { $result .= 'color:' . $opt . '; '; } break; case 'wppa-td': $result .= 'padding: 3px 2px 3px 0; border: 0'; break; default: wppa_dbg_msg('Unexpected error in __wcs, unknown class: ' . $class, 'red'); wppa_log('Err', 'Unexpected error in __wcs, unknown class: ' . $class); } return $result; }
function wppa_make_tinymce_dialog() { global $wpdb; $result = '<div id="wppagallery-form">' . '<div style="height:158px; background-color:#eee; overflow:auto; margin-top:10px;" >' . '<div id="wppagallery-album-preview" style="text-align:center;font-size:48px; line-height:21px; color:#fff;" class="wppagallery-album" ><br /><br /><br />' . __('Album Preview', 'wp-photo-album-plus') . '<br /><span style="font-size:12px; color:#777" ><br/>' . __('A maximum of 100 photos can be previewd', 'wp-photo-album-plus') . '</span></div>' . '<div id="wppagallery-photo-preview" style="text-align:center;font-size:48px; line-height:21px; color:#fff; display:none;" class="wppagallery-photo" ><br /><br /><br />' . __('Photo Preview', 'wp-photo-album-plus') . '</div>' . '</div>' . '<table id="wppagallery-table" class="form-table">' . '<tr>' . '<th><label for="wppagallery-type">' . __('Type of Gallery display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-type" name="type" onchange="wppaGalleryTypeChange(this.value)">' . '<option value="cover">' . __('The cover of an album', 'wp-photo-album-plus') . '</option>' . '<option value="album">' . __('The sub-albums and/or thumbnails in an album', 'wp-photo-album-plus') . '</option>' . '<option value="slide">' . __('A slideshow of the photos in an album', 'wp-photo-album-plus') . '</option>' . '<option value="slideonly">' . __('A slideshow without supporting boxes', 'wp-photo-album-plus') . '</option>' . '<option value="slideonlyf">' . __('A slideshow with a filmstrip only', 'wp-photo-album-plus') . '</option>' . '<option value="photo">' . __('A single photo', 'wp-photo-album-plus') . '</option>' . '<option value="mphoto">' . __('A single photo with caption', 'wp-photo-album-plus') . '</option>' . '<option value="slphoto">' . __('A single photo in the style of a slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="generic">' . __('A generic albums display', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the type of gallery', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-help" style="display:none;" >' . '<th><label for="wppagallery-album" class="wppagallery-help" >' . __('Explanation:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . __('Use this gallerytype to display all the top-level album covers.', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr class="wppagallery-album" >' . '<th><label for="wppagallery-album" class="wppagallery-album" >' . __('The Album to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album" name="album" style=width:270px;" class="wppagallery-album" onchange="wppaGalleryAlbumChange(this.value); wppaTinyMceAlbumPreview(this.value)">'; $albums = $wpdb->get_results("SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC", ARRAY_A); if ($albums) { if (wppa_switch('wppa_hier_albsel')) { $albums = wppa_add_paths($albums); } else { foreach (array_keys($albums) as $index) { $albums[$index]['name'] = __(stripslashes($albums[$index]['name']), 'wp-photo-album-plus'); } } // Sort $albums = wppa_array_sort($albums, 'name'); $result .= '<option value="0" disabled="disabled" selected="selected" >' . __('Please select an album', 'wp-photo-album-plus') . '</option>'; // All standard albums foreach ($albums as $album) { $value = $album['id']; $alb = $album['id']; $photos = $wpdb->get_results($wpdb->prepare("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($alb) . " LIMIT 100", $alb), ARRAY_A); if ($photos) { foreach ($photos as $photo) { $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id']; $value .= '|' . $photo_id . '.' . $photo['ext']; } } else { $value .= '|'; } $note = ' (' . $album['id'] . ')'; if (count($photos) <= wppa_opt('min_thumbs')) { $note .= ' *'; } $result .= '<option value="' . $value . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . $note . '</option>'; } // #last $value = '#last'; $alb = $albums[0]['id']; $photos = $wpdb->get_results($wpdb->prepare("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($alb) . " LIMIT 100", $alb), ARRAY_A); if ($photos) { foreach ($photos as $photo) { $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id']; $value .= '|' . $photo_id . '.' . $photo['ext']; } } else { $value .= '|'; } $result .= '<option value="' . $value . '" >' . __('- The latest created album -', 'wp-photo-album-plus') . '</option>'; // #topten $value = '#topten'; $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `mean_rating` DESC LIMIT " . wppa_opt('topten_count'), ARRAY_A); if ($photos) { foreach ($photos as $photo) { $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id']; $value .= '|' . $photo_id . '.' . $photo['ext']; } } else { $value .= '|'; } $result .= '<option value = "' . $value . '" >' . __('--- The top rated photos ---', 'wp-photo-album-plus') . '</option>'; // #lasten $value = '#lasten'; $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT " . wppa_opt('lasten_count'), ARRAY_A); if ($photos) { foreach ($photos as $photo) { $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id']; $value .= '|' . $photo_id . '.' . $photo['ext']; } } else { $value .= '|'; } $result .= '<option value = "' . $value . '" >' . __('--- The most recently uploaded photos ---', 'wp-photo-album-plus') . '</option>'; // #featen $value = '#featen'; $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured' ORDER BY RAND() DESC LIMIT " . wppa_opt('featen_count'), ARRAY_A); if ($photos) { foreach ($photos as $photo) { $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id']; $value .= '|' . $photo_id . '.' . $photo['ext']; } } else { $value .= '|'; } $result .= '<option value = "' . $value . '" >' . __('--- A random selection of featured photos ---', 'wp-photo-album-plus') . '</option>'; // #comten $value = '#comten'; $comments = $wpdb->get_results("SELECT `id`, `photo` FROM `" . WPPA_COMMENTS . "` ORDER BY `timestamp` DESC", ARRAY_A); $photos = false; $done = array(); if ($comments) { foreach ($comments as $comment) { if (count($done) < wppa_opt('comten_count') && !in_array($comment['photo'], $done)) { $done[] = $comment['photo']; $photos[] = $wpdb->get_row("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `id` = " . $comment['photo'], ARRAY_A); } } } if ($photos) { foreach ($photos as $photo) { $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id']; $value .= '|' . $photo_id . '.' . $photo['ext']; } } else { $value .= '|'; } $result .= '<option value = "' . $value . '" >' . __('--- The most recently commented photos ---', 'wp-photo-album-plus') . '</option>'; // #tags $value = '#tags'; $result .= '<option value = "' . $value . '" >' . __('--- Photos that have certain tags ---', 'wp-photo-album-plus') . '</option>'; // #all $value = '#all'; $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` " . wppa_get_photo_order('0') . " LIMIT 100", ARRAY_A); if ($photos) { foreach ($photos as $photo) { $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id']; $value .= '|' . $photo_id . '.' . $photo['ext']; } } else { $value .= '|'; } $result .= '<option value = "' . $value . '" >' . __('--- All photos in the system ---', 'wp-photo-album-plus') . '</option>'; } else { $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>'; } $result .= '</select>' . '<input type="text" id="wppagallery-alb" name="alb" value="" style="width:50px; display:none; background-color:#ddd;" class="wppagallery-extra" title="Enter albumnumber if not systemwide" />' . '<input type="text" id="wppagallery-cnt" name="cnt" value="" style="width:50px; display:none; background-color:#ddd;" class="wppagallery-extra" title="Enter count if not default" />' . '<br />' . '<small class="wppagallery-album" >' . __('Specify the album to be used or --- A special selection of photos ---', 'wp-photo-album-plus') . '<br />' . __('In an upload box, the album is optional. When no album is specified: a selection box will be displayed of the albums the user has the right to upload.', 'wp-photo-album-plus') . '<br />' . __('* Album contains less than the minimun number of photos', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-photo" style="display:none;" >' . '<th><label for="wppagallery-photo" style="display:none;" class="wppagallery-photo" >' . __('The Photo to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-photo" name="photo" style="display:none;" class="wppagallery-photo" onchange="wppaTinyMcePhotoPreview(this.value)" >'; $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT 100", ARRAY_A); if ($photos) { $result .= '<option value="0" disabled="disabled" selected="selected" >' . __('Please select a photo', 'wp-photo-album-plus') . '</option>'; foreach ($photos as $photo) { $name = stripslashes(__($photo['name'], 'wp-photo-album-plus')); if (strlen($name) > '50') { $name = substr($name, '0', '50') . '...'; } if (get_option('wppa_file_system') == 'flat') { $result .= '<option value="' . $photo['id'] . '.' . $photo['ext'] . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>'; } else { $result .= '<option value="' . wppa_expand_id($photo['id']) . '.' . $photo['ext'] . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>'; } } $result .= '<option value="#last" >' . __('--- The most recently uploaded photo ---', 'wp-photo-album-plus') . '</option>' . '<option value="#potd" >' . __('--- The photo of the day ---', 'wp-photo-album-plus') . '</option>'; } else { $result .= '<option value="0" >' . __('There are no photos yet', 'wp-photo-album-plus') . '</option>'; } $result .= '</select>' . '<br />' . '<small style="display:none;" class="wppagallery-photo" >' . __('Specify the photo to be used', 'wp-photo-album-plus') . '<br />' . __('You can select from a maximum of 100 most recently added photos', 'wp-photo-album-plus') . '<br />' . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-tags" style="display:none;" >' . '<th><label for="wppagallery-tags">' . __('The tags the photos should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-tags" multiple="multiple">' . '<option value="" >' . __('--- please select tag(s) ---', 'wp-photo-album-plus') . '</option>'; $tags = wppa_get_taglist(); if ($tags) { foreach (array_keys($tags) as $tag) { $result .= '<option value="' . $tag . '" >' . $tag . '</option>'; } } $result .= '</select>' . '<div><input type="checkbox" id="wppagallery-andor" /> <small>' . __('If you want that the photos have all the selected tags, check this box. Leave it unchecked if the photo must have atleast only one of the selected tags', 'wp-photo-album-plus') . '</small></div>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-size">' . __('The size of the display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input type="text" id="wppagallery-size" value="" />' . '<br />' . '<small>' . __('Specify the horizontal size in pixels or <span style="color:blue" >auto</span>.', 'wp-photo-album-plus') . ' ' . __('A value less than <span style="color:blue" >100</span> will automaticly be interpreted as a <span style="color:blue" >percentage</span> of the available space.', 'wp-photo-album-plus') . '<br />' . __('Leave this blank for default size', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-align">' . __('Horizontal alignment:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-align" name="align" >' . '<option value="none" >' . __('--- none ---', 'wp-photo-album-plus') . '</option>' . '<option value="left" >' . __('left', 'wp-photo-album-plus') . '</option>' . '<option value="center" >' . __('center', 'wp-photo-album-plus') . '</option>' . '<option value="right" >' . __('right', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the alignment to be used or --- none ---', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '</table>' . '<p class="submit">' . '<input type="button" id="wppagallery-submit" class="button-primary" value="' . __('Insert Gallery', 'wp-photo-album-plus') . '" name="submit" /> ' . '</p>' . '</div>'; return $result; }
function wppa_create_wppa_init_js() { global $wppa_api_version; global $wppa_lang; global $wppa; global $wppa_init_js_data; // Init if (is_numeric(wppa_opt('wppa_fullimage_border_width'))) { $fbw = wppa_opt('wppa_fullimage_border_width') + '1'; } else { $fbw = '0'; } // Make content $content = '/* -- WPPA+ Runtime parameters /* /* Dynamicly Created on ' . date('c') . ' /* */ '; if ((WPPA_DEBUG || wppa_get_get('debug') || WP_DEBUG) && !wppa_switch('wppa_defer_javascript')) { $content .= ' /* Check if wppa.js and jQuery are present */ if (typeof(_wppaSlides) == \'undefined\') alert(\'There is a problem with your theme. The file wppa.js is not loaded when it is expected (Errloc = wppa_kickoff).\'); if (typeof(jQuery) == \'undefined\') alert(\'There is a problem with your theme. The jQuery library is not loaded when it is expected (Errloc = wppa_kickoff).\'); '; } /* This goes into wppa.js */ /* If you add something that uses an element from $wppa_opt[], */ /* or a function that uses an element from $wppa_opt[], */ /* add the optionslug to $init_js_critical[] in wppa_update_option in wppa-utils.php !!!!! */ $content .= ' wppaVersion = "' . $wppa_api_version . '"; wppaBackgroundColorImage = "' . wppa_opt('wppa_bgcolor_img') . '"; wppaPopupLinkType = "' . wppa_opt('wppa_thumb_linktype') . '"; wppaAnimationType = "' . wppa_opt('wppa_animation_type') . '"; wppaAnimationSpeed = ' . wppa_opt('wppa_animation_speed') . '; wppaThumbnailAreaDelta = ' . wppa_get_thumbnail_area_delta() . '; wppaTextFrameDelta = ' . wppa_get_textframe_delta() . '; wppaBoxDelta = ' . wppa_get_box_delta() . '; wppaSlideShowTimeOut = ' . wppa_opt('wppa_slideshow_timeout') . '; wppaPreambule = ' . wppa_get_preambule() . '; wppaFilmShowGlue = ' . (wppa_switch('wppa_film_show_glue') ? 'true' : 'false') . '; wppaSlideShow = "' . __a('Slideshow') . '"; wppaStart = "' . __a('Start') . '"; wppaStop = "' . __a('Stop') . '"; wppaSlower = "' . __a('Slower') . '"; wppaFaster = "' . __a('Faster') . '"; wppaPhoto = "' . __a('Photo') . '"; wppaOf = "' . __a('of') . '"; wppaPreviousPhoto = "' . __a('Previous photo') . '"; wppaNextPhoto = "' . __a('Next photo') . '"; wppaPrevP = "' . __a('Prev.') . '"; wppaNextP = "' . __a('Next') . '"; wppaAvgRating = "' . __a('Average rating') . '"; wppaMyRating = "' . __a('My rating') . '"; wppaAvgRat = "' . __a('Avg.') . '"; wppaMyRat = "' . __a('Mine') . '"; wppaDislikeMsg = "' . __a('You marked this image as inappropriate.') . '"; wppaShowDislikeCount = ' . (wppa_switch('wppa_dislike_show_count') ? 'true' : 'false') . '; wppaNoDislikes = "' . __a('No dislikes') . '"; wppa1Dislike = "' . __a('1 dislike') . '"; wppaDislikes = "' . __a('dislikes') . '"; wppaIncludingMine = "' . __a('including mine') . '"; wppaMiniTreshold = ' . (wppa_opt('wppa_mini_treshold') ? wppa_opt('wppa_mini_treshold') : '0') . '; wppaRatingOnce = ' . (wppa_switch('wppa_rating_change') || wppa_switch('wppa_rating_multi') ? 'false' : 'true') . '; wppaPleaseName = "' . __a('Please enter your name') . '"; wppaPleaseEmail = "' . __a('Please enter a valid email address') . '"; wppaPleaseComment = "' . __a('Please enter a comment') . '"; wppaHideWhenEmpty = ' . (wppa_switch('wppa_hide_when_empty') ? 'true' : 'false') . '; wppaBGcolorNumbar = "' . wppa_opt('wppa_bgcolor_numbar') . '"; wppaBcolorNumbar = "' . wppa_opt('wppa_bcolor_numbar') . '"; wppaBGcolorNumbarActive = "' . wppa_opt('wppa_bgcolor_numbar_active') . '"; wppaBcolorNumbarActive = "' . wppa_opt('wppa_bcolor_numbar_active') . '"; wppaFontFamilyNumbar = "' . wppa_opt('wppa_fontfamily_numbar') . '"; wppaFontSizeNumbar = "' . wppa_opt('wppa_fontsize_numbar') . 'px"; wppaFontColorNumbar = "' . wppa_opt('wppa_fontcolor_numbar') . '"; wppaFontWeightNumbar = "' . wppa_opt('wppa_fontweight_numbar') . '"; wppaFontFamilyNumbarActive = "' . wppa_opt('wppa_fontfamily_numbar_active') . '"; wppaFontSizeNumbarActive = "' . wppa_opt('wppa_fontsize_numbar_active') . 'px"; wppaFontColorNumbarActive = "' . wppa_opt('wppa_fontcolor_numbar_active') . '"; wppaFontWeightNumbarActive = "' . wppa_opt('wppa_fontweight_numbar_active') . '"; wppaNumbarMax = "' . wppa_opt('wppa_numbar_max') . '"; wppaLang = "' . $wppa_lang . '"; wppaNextOnCallback = ' . (wppa_switch('wppa_next_on_callback') ? 'true' : 'false') . '; wppaStarOpacity = ' . wppa_opt('wppa_star_opacity') / '100' . '; wppaSlideWrap = ' . (wppa_switch('wppa_slide_wrap') ? 'true' : 'false') . '; wppaEmailRequired = ' . (wppa_switch('wppa_comment_email_required') ? 'true' : 'false') . '; wppaSlideBorderWidth = ' . $fbw . '; wppaAllowAjax = ' . (wppa_switch('wppa_allow_ajax') ? 'true' : 'false') . '; wppaUsePhotoNamesInUrls = ' . (wppa_switch('wppa_use_photo_names_in_urls') ? 'true' : 'false') . '; wppaThumbTargetBlank = ' . (wppa_switch('wppa_thumb_blank') ? 'true' : 'false') . '; wppaRatingMax = ' . wppa_opt('wppa_rating_max') . '; wppaRatingDisplayType = "' . wppa_opt('wppa_rating_display_type') . '"; wppaRatingPrec = ' . wppa_opt('wppa_rating_prec') . '; wppaStretch = ' . (wppa_switch('wppa_enlarge') ? 'true' : 'false') . '; wppaMinThumbSpace = ' . wppa_opt('wppa_tn_margin') . '; wppaThumbSpaceAuto = ' . (wppa_switch('wppa_thumb_auto') ? 'true' : 'false') . '; wppaMagnifierCursor = "' . wppa_opt('wppa_magnifier') . '"; wppaArtMonkyLink = "' . wppa_opt('wppa_art_monkey_link') . '"; wppaAutoOpenComments = ' . (wppa_switch('wppa_auto_open_comments') ? 'true' : 'false') . '; wppaUpdateAddressLine = ' . (wppa_switch('wppa_update_addressline') ? 'true' : 'false') . '; wppaFilmThumbTitle = "' . (wppa_opt('wppa_film_linktype') == 'lightbox' ? wppa_zoom_in(false) : __a('Double click to start/stop slideshow running')) . '"; wppaVoteForMe = "' . __(wppa_opt('wppa_vote_button_text')) . '"; wppaVotedForMe = "' . __(wppa_opt('wppa_voted_button_text')) . '"; wppaSlideSwipe = ' . (wppa_switch('wppa_slide_swipe') ? 'true' : 'false') . '; wppaMaxCoverWidth = ' . wppa_opt('wppa_max_cover_width') . '; wppaDownLoad = "' . __a('Download') . '"; wppaSlideToFullpopup = ' . (wppa_opt('wppa_slideshow_linktype') == 'fullpopup' ? 'true' : 'false') . '; wppaComAltSize = ' . wppa_opt('wppa_comten_alt_thumbsize') . '; wppaBumpViewCount = ' . (wppa_switch('wppa_track_viewcounts') ? 'true' : 'false') . '; wppaShareHideWhenRunning = ' . (wppa_switch('wppa_share_hide_when_running') ? 'true' : 'false') . '; wppaFotomoto = ' . (wppa_switch('wppa_fotomoto_on') ? 'true' : 'false') . '; wppaArtMonkeyButton = ' . (wppa_opt('wppa_art_monkey_display') == 'button' ? 'true' : 'false') . '; wppaFotomotoHideWhenRunning = ' . (wppa_switch('wppa_fotomoto_hide_when_running') ? 'true' : 'false') . '; wppaCommentRequiredAfterVote = ' . (wppa_switch('wppa_vote_needs_comment') ? 'true' : 'false') . '; wppaFotomotoMinWidth = ' . wppa_opt('wppa_fotomoto_min_width') . '; wppaShortQargs = ' . (wppa_switch('wppa_use_short_qargs') ? 'true' : 'false') . '; wppaOvlHires = ' . (wppa_switch('wppa_lb_hres') ? 'true' : 'false') . '; wppaSlideVideoStart = ' . (wppa_switch('start_slide_video') ? 'true' : 'false') . '; wppaSlideAudioStart = ' . (wppa_switch('start_slide_audio') ? 'true' : 'false') . '; wppaAudioHeight = ' . wppa_get_audio_control_height() . '; wppaRel = "' . (wppa_opt('lightbox_name') == 'wppa' ? 'data-rel' : 'rel') . '"; '; // Open file $file = @fopen(WPPA_PATH . '/wppa-init.' . $wppa_lang . '.js', 'wb'); if ($file) { // Write file fwrite($file, $content); // Close file fclose($file); $wppa_init_js_data = ''; } else { $wppa_init_js_data = '<script type="text/javascript"> /* Warning: file wppa-init.' . $wppa_lang . '.js could not be created */ /* The content is therefor output here */ ' . $content . ' </script> '; } }
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; } }