Пример #1
0
function wppa_get_user($type = 'login')
{
    global $current_user;
    if (is_user_logged_in()) {
        get_currentuserinfo();
        switch ($type) {
            case 'login':
                return $current_user->user_login;
                break;
            case 'display':
                return $current_user->display_name;
                break;
            case 'id':
                return $current_user->ID;
                break;
            case 'firstlast':
                return $current_user->user_firstname . ' ' . $current_user->user_lastname;
                break;
            default:
                wppa_dbg_msg('Un-implemented type: ' . $type . ' in wppa_get_user()', 'red', 'force');
                return '';
        }
    } else {
        return $_SERVER['REMOTE_ADDR'];
    }
}
Пример #2
0
function wppa_get_user($type = 'login')
{
    static $current_user;
    if (!$current_user) {
        $current_user = wp_get_current_user();
    }
    if ($current_user->exists()) {
        switch ($type) {
            case 'login':
                return $current_user->user_login;
                break;
            case 'display':
                return $current_user->display_name;
                break;
            case 'id':
                return $current_user->ID;
                break;
            case 'firstlast':
                return $current_user->user_firstname . ' ' . $current_user->user_lastname;
                break;
            default:
                wppa_dbg_msg('Un-implemented type: ' . $type . ' in wppa_get_user()', 'red', 'force');
                return '';
        }
    } else {
        return $_SERVER['REMOTE_ADDR'];
    }
}
Пример #3
0
function wppa_cdn($side)
{
    // What did we specify in the settings page?
    $cdn = wppa_opt('cdn_service');
    // Check for fully configured and active
    switch ($cdn) {
        case 'cloudinary':
        case 'cloudinarymaintenance':
            if (wppa_opt('cdn_cloud_name') && wppa_opt('cdn_api_key') && wppa_opt('cdn_api_secret')) {
                if ($side == 'admin') {
                    // Admin: always return cloudinary
                    $cdn = 'cloudinary';
                } elseif ($side == 'front') {
                    // Front: NOT if in maintenance
                    if ($cdn == 'cloudinarymaintenance') {
                        $cdn = false;
                    }
                } else {
                    wppa_dbg_msg('dbg', 'Wrong arg:' . $side . ' in wppa_cdn()', 'red', 'force');
                    $cdn = false;
                }
            } else {
                wppa_dbg_msg('dbg', 'Incomplete configuration of Cloudinary', 'red', 'force');
                $cdn = false;
                // Incomplete configuration
            }
            break;
        default:
            $cdn = false;
    }
    return $cdn;
}
Пример #4
0
function wppa_microtime($txt = '')
{
    static $old;
    $new = microtime(true);
    if ($old) {
        $delta = $new - $old;
        $old = $new;
        $msg = sprintf('%s took %7.3f s.', $txt, $delta);
        wppa_dbg_msg($msg, 'green', true);
    } else {
        $old = $new;
    }
}
Пример #5
0
function wppa_import_dir_to_album($file, $parent)
{
    global $photocount;
    global $wpdb;
    global $wppa_session;
    // Session should survive the default hour
    wppa_extend_session();
    // see if album exists
    if (is_dir($file)) {
        // Check parent
        if (wppa_switch('import_parent_check')) {
            $alb = wppa_get_album_id(basename($file), $parent);
            // If parent = 0 ( top-level album ) and album not found,
            // try a 'separate' album ( i.e. parent = -1 ) with this name
            if (!$alb && $parent == '0') {
                $alb = wppa_get_album_id(basename($file), '-1');
            }
        } else {
            $alb = wppa_get_album_id(basename($file), false);
        }
        if (!$alb) {
            // Album must be created
            $name = basename($file);
            $uplim = wppa_opt('upload_limit_count') . '/' . wppa_opt('upload_limit_time');
            $alb = wppa_create_album_entry(array('name' => $name, 'a_parent' => $parent));
            if ($alb === false) {
                wppa_error_message(__('Could not create album.', 'wp-photo-album-plus') . '<br/>Query = ' . $query);
                wp_die('Sorry, cannot continue');
            } else {
                wppa_set_last_album($alb);
                wppa_flush_treecounts($alb);
                wppa_index_add('album', $alb);
                wppa_create_pl_htaccess();
                wppa_ok_message(__('Album #', 'wp-photo-album-plus') . ' ' . $alb . ' ( ' . $name . ' ) ' . __('Added.', 'wp-photo-album-plus'));
                if (wppa_switch('newpag_create') && $parent <= '0') {
                    // Create post object
                    $my_post = array('post_title' => $name, 'post_content' => str_replace('w#album', $alb, wppa_opt('newpag_content')), 'post_status' => wppa_opt('newpag_status'), 'post_type' => wppa_opt('newpag_type'));
                    // Insert the post into the database
                    $pagid = wp_insert_post($my_post);
                    if ($pagid) {
                        wppa_ok_message(sprintf(__('Page <a href="%s" target="_blank" >%s</a> created.', 'wp-photo-album-plus'), home_url() . '?page_id=' . $pagid, $name));
                        $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_ALBUMS . "` SET `cover_linkpage` = %s WHERE `id` = %s", $pagid, $alb));
                    } else {
                        wppa_error_message(__('Could not create page.', 'wp-photo-album-plus'));
                    }
                }
            }
        }
        // Now import the files
        $photofiles = glob($file . '/*');
        if ($photofiles) {
            foreach ($photofiles as $photofile) {
                if (!is_dir($photofile)) {
                    if (!isset($wppa_session[$photofile]) || !wppa_switch('keep_import_files')) {
                        if (wppa_albumphoto_exists($alb, basename($photofile))) {
                            if (!wppa_switch('keep_import_files')) {
                                wppa_warning_message('Photo ' . basename($photofile) . ' already exists in album ' . $alb . '. Removed. (2)');
                            }
                        } else {
                            $bret = wppa_insert_photo($photofile, $alb, basename($photofile));
                            $photocount++;
                        }
                        if (!wppa_switch('keep_import_files')) {
                            @unlink($photofile);
                        }
                        $wppa_session[$photofile] = true;
                    }
                    if (wppa_is_time_up($photocount)) {
                        return false;
                    }
                }
            }
        }
        // Now go deeper, process the subdirs
        $subdirs = glob($file . '/*');
        if ($subdirs) {
            foreach ($subdirs as $subdir) {
                if (is_dir($subdir)) {
                    if (basename($subdir) != '.' && basename($subdir) != '..') {
                        $bret = wppa_import_dir_to_album($subdir, $alb);
                        if (!$bret) {
                            return false;
                        }
                        // Time out
                    }
                }
            }
        }
        @rmdir($file);
        // Try to remove dir, ignore error
    } else {
        wppa_dbg_msg('Invalid file in wppa_import_dir_to_album(): ' . $file);
        return false;
    }
    return true;
}
Пример #6
0
function wppa_slide_filmstrip($opt = '')
{
    // A single image slideshow needs no navigation
    if (wppa('is_single')) {
        return;
    }
    $do_it = false;
    // Init
    if (is_feed()) {
        $do_it = true;
    } else {
        // Not a feed
        if ($opt != 'optional') {
            $do_it = true;
        } else {
            // optional
            if (wppa_switch('wppa_filmstrip')) {
                // optional and option on
                if (!wppa('is_slideonly')) {
                    $do_it = true;
                }
                // always except slideonly
            }
            if (wppa('film_on')) {
                $do_it = true;
            }
            // explicitly turned on
        }
    }
    if (!$do_it) {
        return;
    }
    // Don't do it
    $t = -microtime(true);
    $alb = wppa_get_get('album');
    $thumbs = wppa_get_thumbs();
    if (!$thumbs || count($thumbs) < 1) {
        return;
    }
    $preambule = wppa_get_preambule();
    $width = (wppa_opt('tf_width') + wppa_opt('tn_margin')) * (count($thumbs) + 2 * $preambule);
    $width += wppa_opt('tn_margin') + 2;
    $topmarg = wppa_opt('thumbsize') / 2 - 16;
    $height = wppa_opt('thumbsize') + wppa_opt('tn_margin');
    $height1 = wppa_opt('thumbsize');
    $marg = '42';
    // 32
    $fs = '24';
    $fw = '42';
    if (wppa_in_widget()) {
        $width /= 2;
        $topmarg /= 2;
        $height /= 2;
        $height1 /= 2;
        $marg = '21';
        $fs = '12';
        $fw = '21';
    }
    $conw = wppa_get_container_width();
    if ($conw < 1) {
        $conw *= 640;
    }
    $w = $conw - (2 * 6 + 2 * 42 + 2 * wppa_opt('bwidth'));
    /* 2*padding + 2*arrows + 2*border */
    if (wppa_in_widget()) {
        $w = $conw - (2 * 6 + 2 * 21 + 2 * wppa_opt('bwidth'));
    }
    /* 2*padding + 2*arrow + 2*border */
    $IE6 = 'width: ' . $w . 'px;';
    $pagsiz = round($w / (wppa_opt('thumbsize') + wppa_opt('tn_margin')));
    if (wppa_in_widget()) {
        $pagsiz = round($w / (wppa_opt('thumbsize') / 2 + wppa_opt('tn_margin') / 2));
    }
    wppa_add_js_page_data('<script type="text/javascript">');
    wppa_add_js_page_data('wppaFilmPageSize[' . wppa('mocc') . '] = ' . $pagsiz . ';');
    wppa_add_js_page_data('</script>');
    if (is_feed()) {
        wppa_out('<div style="' . __wcs('wppa-box') . __wcs('wppa-nav') . '">');
    } else {
        wppa_out('<div' . ' class="wppa-box wppa-nav"' . ' style="text-align:center; ' . __wcs('wppa-box') . __wcs('wppa-nav') . 'height:' . $height . 'px;"' . ' >' . '<div' . ' style="float:left; text-align:left; cursor:pointer; margin-top:' . $topmarg . 'px; width: ' . $fw . 'px; font-size: ' . $fs . 'px;"' . ' >' . '<a' . ' class="wppa-prev-' . wppa('mocc') . ' wppa-arrow"' . ' style="' . __wcs('wppa-arrow') . '"' . ' id="prev-film-arrow-' . wppa('mocc') . '"' . ' onclick="wppaFirst(' . wppa('mocc') . ');"' . ' title="' . __('First', 'wp-photo-album-plus') . '"' . ' >' . '&laquo;' . '</a>' . '<a' . ' class="wppa-prev-' . wppa('mocc') . ' wppa-arrow"' . ' style="' . __wcs('wppa-arrow') . '"' . ' id="prev-film-arrow-1-' . wppa('mocc') . '"' . ' onclick="wppaPrev(' . wppa('mocc') . ');"' . ' title="' . __('Previous', 'wp-photo-album-plus') . '"' . ' >' . '&lsaquo;' . '</a>' . '</div>' . '<div' . ' style="float:right; text-align:right; cursor:pointer; margin-top:' . $topmarg . 'px; width: ' . $fw . 'px; font-size: ' . $fs . 'px;"' . ' >' . '<a' . ' class="wppa-next-' . wppa('mocc') . ' wppa-arrow"' . ' style="' . __wcs('wppa-arrow') . '"' . ' id="next-film-arrow-1-' . wppa('mocc') . '"' . ' onclick="wppaNext(' . wppa('mocc') . ');"' . ' title="' . __('Next', 'wp-photo-album-plus') . '"' . ' >' . '&rsaquo;' . '</a>' . '<a' . ' class="wppa-next-' . wppa('mocc') . ' wppa-arrow"' . ' style="' . __wcs('wppa-arrow') . '"' . ' id="next-film-arrow-' . wppa('mocc') . '"' . ' onclick="wppaLast(' . wppa('mocc') . ');"' . ' title="' . __('Last', 'wp-photo-album-plus') . '"' . ' >' . '&raquo;' . '</a>' . '</div>' . '<div' . ' id="filmwindow-' . wppa('mocc') . '"' . ' class="filmwindow"' . ' style="' . $IE6 . ' position:absolute; display: block; height:' . $height . 'px; margin: 0 0 0 ' . $marg . 'px; overflow:hidden;"' . ' >' . '<div' . ' id="wppa-filmstrip-' . wppa('mocc') . '"' . ' style="height:' . $height1 . 'px; width:' . $width . 'px; max-width:' . $width . 'px;margin-left: -100px;"' . ' >');
    }
    wppa_out('<style type="text/css" scoped >' . '.thumbnail-frame { ' . wppa_get_thumb_frame_style(false, 'film') . ' }' . '.wppa-filmthumb-active { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }' . '</style>');
    $cnt = count($thumbs);
    $start = $cnt - $preambule;
    $end = $cnt;
    $idx = $start;
    // Preambule
    while ($idx < $end) {
        $glue = $cnt == $idx + 1 ? true : false;
        $ix = $idx;
        while ($ix < 0) {
            $ix += $cnt;
        }
        $thumb = $thumbs[$ix];
        wppa_do_filmthumb($thumb['id'], $ix, false, $glue);
        $idx++;
    }
    // Real thumbs
    $idx = 0;
    foreach ($thumbs as $tt) {
        $thumb = $tt;
        $glue = $cnt == $idx + 1 ? true : false;
        wppa_do_filmthumb($thumb['id'], $idx, true, $glue);
        $idx++;
    }
    // Postambule
    $start = '0';
    $end = $preambule;
    $idx = $start;
    while ($idx < $end) {
        $ix = $idx;
        while ($ix >= $cnt) {
            $ix -= $cnt;
        }
        $thumb = $thumbs[$ix];
        wppa_do_filmthumb($thumb['id'], $ix, false);
        $idx++;
    }
    if (is_feed()) {
        wppa_out('</div>');
    } else {
        wppa_out('</div>');
        wppa_out('</div>');
        wppa_out('</div>');
    }
    $t += microtime(true);
    wppa_dbg_msg('Filmstrip took ' . $t . ' seconds.');
}
Пример #7
0
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;
}
Пример #8
0
function wppa_get_widgetphotos($alb, $option = '')
{
    global $wpdb;
    $photos = false;
    $query = '';
    // Compile status clause
    switch (wppa_opt('widget_status_filter')) {
        case 'publish':
            $statusclause = " `status` = 'publish' ";
            break;
        case 'featured':
            $statusclause = " `status` = 'featured' ";
            break;
        case 'gold':
            $statusclause = " `status` = 'gold' ";
            break;
        case 'silver':
            $statusclause = " `status` = 'silver' ";
            break;
        case 'bronze':
            $statusclause = " `status` = 'bronze' ";
            break;
        case 'anymedal':
            $statusclause = " `status` IN ( 'gold', 'silver', 'bronze' ) ";
            break;
        default:
            $statusclause = " `status` <> 'scheduled' ";
            if (!is_user_logged_in()) {
                $statusclause .= " AND `status` <> 'private' ";
            }
    }
    // Is it a single album?
    if (wppa_is_int($alb)) {
        $query = $wpdb->prepare("SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . " AND " . $statusclause . $option, $alb);
    } elseif (strchr($alb, ',')) {
        $alb = trim($alb, ',');
        // Test for numeric only ( security test )
        $t = str_replace(',', '', $alb);
        if (is_numeric($t)) {
            $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN ( " . $alb . " ) " . "AND " . $statusclause . $option;
        }
    } elseif ($alb == 'all') {
        $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` " . " WHERE " . $statusclause . $option;
    } elseif ($alb == 'sep') {
        $albs = $wpdb->get_results("SELECT `id`, `a_parent` FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
        $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` WHERE ( `album` = '0' ";
        $first = true;
        foreach ($albs as $a) {
            if ($a['a_parent'] == '-1') {
                $query .= "OR `album` = '" . $a['id'] . "' ";
            }
        }
        $query .= ") AND " . $statusclause . $option;
    } elseif ($alb == 'all-sep') {
        $albs = $wpdb->get_results("SELECT `id`, `a_parent` FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
        $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` WHERE ( `album` IN ('0'";
        foreach ($albs as $a) {
            if ($a['a_parent'] != '-1') {
                $query .= ",'" . $a['id'] . "'";
            }
        }
        $query .= ") ) AND " . $statusclause . $option;
    } elseif ($alb == 'topten') {
        // Find the 'top' policy
        switch (wppa_opt('topten_sortby')) {
            case 'mean_rating':
                $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
                break;
            case 'rating_count':
                $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
                break;
            case 'views':
                $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
                break;
            default:
                wppa_error_message('Unimplemented sorting method');
                $sortby = '';
                break;
        }
        // It is assumed that status is ok for top rated photos
        $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` ORDER BY " . $sortby . " LIMIT " . wppa_opt('topten_count');
        $query .= $option;
    }
    // Do the query
    if ($query) {
        $photos = $wpdb->get_results($query, ARRAY_A);
        wppa_dbg_q('Q-Potd');
        wppa_dbg_msg('Potd query: ' . $query);
    } else {
        $photos = array();
    }
    // Ready
    return $photos;
}
Пример #9
0
function wppa_get_thumb_masonry($id)
{
    global $wpdb;
    // Init
    if (!$id) {
        wppa_dbg_msg('Please check file wppa-theme.php or any other php file that calls wppa_thumb_masonry(). Argument 1: photo id is missing!', 'red', 'force');
        die('Please check your configuration');
    }
    $result = '';
    $cont_width = wppa_get_container_width();
    $count_cols = ceil($cont_width / wppa_opt('thumbsize'));
    // Get the photo info
    $thumb = wppa_cache_thumb($id);
    // Get the album info
    $album = wppa_cache_album($thumb['album']);
    // Get photo info
    $is_video = wppa_is_video($id);
    $has_audio = wppa_has_audio($id);
    $imgsrc = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id);
    if (!wppa_is_video($id) && !is_file($imgsrc)) {
        $result .= '<div' . ' class=""' . ' style="' . 'font-size:10px;' . 'color:red;' . 'width:' . wppa_opt('thumbsize') . 'px;' . 'position:static;' . 'float:left;' . '"' . ' >' . sprintf(__('Missing thumbnail image #%s', 'wp-photo-album-plus'), $id) . '</div>';
        return $result;
    }
    $alt = $album['alt_thumbsize'] == 'yes' ? '_alt' : '';
    $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, wppa_opt('thumbsize' . $alt), 'optional', 'thumb');
    // Verical style ?
    if (wppa_opt('thumbtype') == 'masonry-v') {
        $imgwidth = wppa_opt('thumbsize');
        $imgheight = $imgwidth * wppa_get_thumbratioyx($id);
        $imgstyle = 'width:100%; height:auto; margin:0; position:relative; box-sizing:border-box;';
        $frame_h = '';
    } else {
        $imgheight = wppa_opt('thumbsize');
        $imgwidth = $imgheight * wppa_get_thumbratioxy($id);
        $imgstyle = 'height:100%;' . 'width:auto;' . 'margin:0;' . 'position:relative;' . 'box-sizing:border-box;' . '';
        $frame_h = 'height:100%; ';
    }
    // Mouseover effect?
    if (wppa_switch('use_thumb_opacity')) {
        $opac = wppa_opt('thumb_opacity');
        $imgstyle .= ' opacity:' . $opac / 100 . '; filter:alpha( opacity=' . $opac . ' );';
    }
    // Padding
    if (wppa_is_int(wppa_opt('tn_margin') / 2)) {
        $imgstyle .= ' padding:' . wppa_opt('tn_margin') / 2 . 'px;';
    } else {
        $p1 = floor(wppa_opt('tn_margin') / 2);
        $p2 = ceil(wppa_opt('tn_margin') / 2);
        $imgstyle .= ' padding:' . $p1 . 'px ' . $p2 . 'px ' . $p2 . 'px ' . $p1 . 'px;';
    }
    // Cursor
    $cursor = $imgattr_a['cursor'];
    // Popup ?
    if (wppa_switch('use_thumb_popup')) {
        // Landscape?
        if ($imgwidth > $imgheight) {
            $popwidth = wppa_opt('popupsize');
            $popheight = round($popwidth * $imgheight / $imgwidth);
        } else {
            $popheight = wppa_opt('popupsize');
            $popwidth = round($popheight * $imgwidth / $imgheight);
        }
    } else {
        $popwidth = $imgwidth;
        $popheight = $imgheight;
    }
    $imgurl = wppa_fix_poster_ext(wppa_get_thumb_url($id, '', $popwidth, $popheight), $id);
    $events = wppa_get_imgevents('thumb', $id);
    $imgalt = wppa_get_imgalt($id);
    // returns something like ' alt="Any text" '
    $title = esc_attr(wppa_get_masonry_title($id));
    // esc_attr( wppa_get_photo_name( $id ) );
    // Feed ?
    if (is_feed()) {
        $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, '100', '4', 'thumb');
        $style = $imgattr_a['style'];
        $result .= '<a href="' . get_permalink() . '">' . '<img' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $style . '"' . ' />' . '</a>';
        return;
    }
    // Get the image link
    if (wppa('is_topten')) {
        $no_album = !wppa('start_album');
        if ($no_album) {
            $tit = __('View the top rated photos', 'wp-photo-album-plus');
        } else {
            $tit = esc_attr(__(stripslashes($thumb['description'])));
        }
        $link = wppa_get_imglnk_a('thumb', $id, '', $tit, '', $no_album);
    } else {
        $link = wppa_get_imglnk_a('thumb', $id);
    }
    // voor parent uplr
    // Open the thumbframe
    // Add class wppa-mas-h-{mocc} for ie if horizontal
    $is_ie_or_chrome = strpos($_SERVER["HTTP_USER_AGENT"], 'Trident') || strpos($_SERVER["HTTP_USER_AGENT"], 'Chrome');
    $result .= '
				<div' . ' id="thumbnail_frame_masonry_' . $id . '_' . wppa('mocc') . '"' . ($is_ie_or_chrome && wppa_opt('thumbtype') == 'masonry-h' ? ' class="wppa-mas-h-' . wppa('mocc') . '"' : '') . ' style="' . $frame_h . 'position:static;' . 'float:left;' . 'font-size:12px;' . 'line-height:8px;' . 'overflow:hidden;' . 'box-sizing:content-box;' . '" >';
    // The medals
    $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top'));
    // See if ajax possible
    if ($link) {
        if ($link['is_url']) {
            // is url
            if (wppa_switch('allow_ajax') && wppa_opt('thumb_linktype') == 'photo' && wppa_opt('thumb_linkpage') == '0' && !wppa_switch('thumb_blank') && !(wppa_switch('thumb_overrule') && $thumb['linkurl']) && !wppa('is_topten') && !wppa('is_lasten') && !wppa('is_comten') && !wppa('is_featen') && !wppa('is_tag') && !wppa('is_upldr') && !wppa('src') && !wppa('supersearch') && (wppa_is_int(wppa('start_album')) || wppa('start_album') == '')) {
                // Ajax	possible
                // The a img ajax
                $p = wppa('calendar') ? '' : '&amp;wppa-photo=' . $id;
                $onclick = 'wppaDoAjaxRender( ' . wppa('mocc') . ', \'' . wppa_get_slideshow_url_ajax(wppa('start_album'), '0') . '&amp;wppa-photo=' . $id . '\', \'' . wppa_convert_to_pretty(wppa_get_slideshow_url(wppa('start_album'), '0') . $p) . '\' )';
                // old			$onclick = "wppaDoAjaxRender( ".wppa( 'mocc' ).", '".wppa_get_slideshow_url_ajax( wppa( 'start_album' ), '0' ).'&amp;wppa-photo='.$id."', '".wppa_convert_to_pretty( wppa_get_slideshow_url( wppa( 'start_album' ), '0' )."&amp;wppa-photo=".$id )."' )";
                $result .= '<a style="position:static;" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">';
                if ($is_video) {
                    //					$result .= '<video preload="metadata" onclick="'.$onclick.'" id="i-'.$id.'-'.wppa( 'mocc' ).'" '.$imgalt.' title="'.$title.'" style="'.$imgstyle.' cursor:pointer;" '.$events.' >'.wppa_get_video_body( $id ).'</video>';
                    $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => $onclick, 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true));
                } else {
                    $result .= '<img' . ' onclick="' . $onclick . '"' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />';
                }
                $result .= '</a>';
            } else {
                // non ajax
                // The a img non ajax
                $result .= '<a style="position:static;" href="' . $link['url'] . '" target="' . $link['target'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">';
                if ($is_video) {
                    //					$result .= '<video preload="metadata" id="i-'.$id.'-'.wppa( 'mocc' ).'" '.$imgalt.' title="'.$title.'" width="'.$imgwidth.'" height="'.$imgheight.'" style="'.$imgstyle.' cursor:pointer;" '.$events.' >'.wppa_get_video_body( $id ).'</video>';
                    $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true));
                } else {
                    $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . 'cursor:pointer;"' . ' ' . $events . ' />';
                }
                $result .= '</a>';
            }
        } elseif ($link['is_lightbox']) {
            // The a img
            $title = wppa_get_lbtitle('thumb', $id);
            $result .= '<a href="' . $link['url'] . '"' . ' target="' . $link['target'] . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($id)) . '"' . ' data-videonatwidth="' . wppa_get_videox($id) . '"' . ' data-videonatheight="' . wppa_get_videoy($id) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($id)) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[occ' . wppa('mocc') . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' class="thumb-img"' . ' id="x-' . $id . '-' . wppa('mocc') . '">';
            // The image
            $title = wppa_zoom_in($id);
            // Video?
            if ($is_video) {
                $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => $cursor, 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true));
            } else {
                $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' />';
            }
            $result .= '</a>';
        } else {
            // The div img
            $result .= '<div onclick="' . $link['url'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '" style="height:100%;" >';
            // Video?
            if ($is_video) {
                $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true));
            } else {
                $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . 'cursor:pointer;"' . ' ' . $events . ' />';
            }
            $result .= '</div>';
            $result .= '<script type="text/javascript">';
            $result .= '/* <![CDATA[ */';
            $result .= 'wppaPopupOnclick[' . $id . '] = "' . $link['url'] . '";';
            $result .= '/* ]]> */';
            $result .= '</script>';
        }
    } else {
        // no link
        if (wppa_switch('use_thumb_popup')) {
            $result .= '<div id="x-' . $id . '-' . wppa('mocc') . '" style="height:100%" >';
            if ($is_video) {
                $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => '', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true));
            } else {
                $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '"' . ' ' . $events . ' />';
            }
            $result .= '</div>';
        } else {
            if ($is_video) {
                //				$result .= '<video preload="metadata" '.$imgalt.' title="'.$title.'" width="'.$imgwidth.'" height="'.$imgheight.'" style="'.$imgstyle.'" '.$events.' >'.wppa_get_video_body( $id ).'</video>';
                $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => '', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true));
            } else {
                $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '" ' . $events . ' />';
            }
        }
    }
    // The audio when no popup
    if (wppa_switch('thumb_audio') && wppa_has_audio($id)) {
        $result .= '<div style="position:relative;z-index:11;">';
        //	$is_safari 	= strpos( $_SERVER["HTTP_USER_AGENT"], 'Safari' );
        //	$cont_h 	= $is_safari ? 16 : 28;
        //	$audiotop 	= $imgattr_a['height'] + $imgattr_a['margin-top'] - $cont_h;
        //			if ( ! is_file( $imgsrc ) ) { // Audio without image
        //				$audiotop 	= wppa_get_audio_control_height();
        //				$imgwidth 	= wppa_opt( 'tf_width' );
        //				$imgheight 	= wppa_get_audio_control_height();
        //			}
        $result .= wppa_get_audio_html(array('id' => $id, 'tagid' => 'a-' . $id . '-' . wppa('mocc'), 'style' => 'width:100%;position:absolute;bottom:0;margin:0;padding:' . wppa_opt('tn_margin') / 2 . 'px;left:0;border:none;z-index:10;'));
        $result .= '</div>';
    }
    // The medals
    $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot'));
    // Close the thumbframe
    $result .= '</div>';
    return $result;
}
function wppa_dbg_q($id)
{
    global $wppa;
    if (!$wppa['debug']) {
        return;
    }
    // Nothing to do here
    switch ($id) {
        case 'init':
            break;
        case 'print':
            if (!isset($wppa['queries'])) {
                return;
            }
            if (!is_array($wppa['queries'])) {
                return;
            }
            // Did nothing
            $qtot = 0;
            $gtot = 0;
            $keys = array_keys($wppa['queries']);
            sort($keys);
            $line = 'Cumulative query stats: Q=query, G=cache<br />';
            foreach ($keys as $k) {
                if (substr($k, 0, 1) == 'Q') {
                    $line .= $k . '=>' . $wppa['queries'][$k] . ', ';
                    $qtot += $wppa['queries'][$k];
                }
            }
            $line .= '<br />';
            foreach ($keys as $k) {
                if (substr($k, 0, 1) == 'G') {
                    $line .= $k . '=>' . $wppa['queries'][$k] . ', ';
                    $gtot += $wppa['queries'][$k];
                }
            }
            $line .= '<br />';
            $line .= sprintf('Total queries attempted: %d, Cash hits: %d, equals %4.2f%%, misses: %d.', $qtot + $gtot, $gtot, $gtot * 100 / ($qtot + $gtot), $qtot);
            $line .= ' 2nd level cache entries: albums: ' . wppa_cache_album('count') . ', photos: ' . wppa_cache_photo('count') . ' NQ=' . get_num_queries();
            wppa_dbg_msg($line);
            //			ob_start();
            //			print_r( $wppa['queries'] );
            //			wppa_dbg_msg( ob_get_clean() );
            break;
        default:
            if ($wppa['debug']) {
                if (!isset($wppa['queries'][$id])) {
                    $wppa['queries'][$id] = 1;
                } else {
                    $wppa['queries'][$id]++;
                }
            }
            break;
    }
}
Пример #11
0
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&amp;wppa-cover=0';
                        $result['title'] = '';
                        // $album_name;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&amp;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&amp;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 . '&amp;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 . '&amp;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 . '&amp;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 = '&amp;wppa-single=1';
            } else {
                $si = '';
            }
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=0&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&amp;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&amp;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 . '&amp;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 . '&amp;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'] .= '&amp;wppa-calendar=' . wppa('calendar') . '&amp;wppa-caldate=' . wppa('caldate');
        }
        if (wppa('supersearch')) {
            $result['url'] .= '&amp;wppa-supersearch=' . urlencode(wppa('supersearch'));
        }
        if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) {
            $result['url'] .= '&amp;wppa-searchstring=' . urlencode(wppa('searchstring'));
        }
        if ($wich == 'topten') {
            $result['url'] .= '&amp;wppa-topten=' . wppa_opt('topten_count');
        } elseif (wppa('is_topten')) {
            $result['url'] .= '&amp;wppa-topten=' . wppa('topten_count');
        }
        if ($wich == 'lasten') {
            $result['url'] .= '&amp;wppa-lasten=' . wppa_opt('lasten_count');
        } elseif (wppa('is_lasten')) {
            $result['url'] .= '&amp;wppa-lasten=' . wppa('lasten_count');
        }
        if ($wich == 'comten') {
            $result['url'] .= '&amp;wppa-comten=' . wppa_opt('comten_count');
        } elseif (wppa('is_comten')) {
            $result['url'] .= '&amp;wppa-comten=' . wppa('comten_count');
        }
        if ($wich == 'featen') {
            $result['url'] .= '&amp;wppa-featen=' . wppa_opt('featen_count');
        } elseif (wppa('is_featen')) {
            $result['url'] .= '&amp;wppa-featen=' . wppa('featen_count');
        }
        if (wppa('is_related')) {
            $result['url'] .= '&amp;wppa-rel=' . wppa('is_related') . '&amp;wppa-relcount=' . wppa('related_count');
        } elseif (wppa('is_tag')) {
            $result['url'] .= '&amp;wppa-tag=' . wppa('is_tag');
        }
        if (wppa('is_upldr')) {
            $result['url'] .= '&amp;wppa-upldr=' . wppa('is_upldr');
        }
        if (wppa('is_inverse')) {
            $result['url'] .= '&amp;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'] .= '&amp;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;
}
Пример #12
0
function wppa_bestof_html($args, $widget = true)
{
    // Copletify args
    $args = wp_parse_args((array) $args, array('page' => '0', 'count' => '1', 'sortby' => 'maxratingcount', 'display' => 'photo', 'period' => 'thisweek', 'maxratings' => 'yes', 'meanrat' => 'yes', 'ratcount' => 'yes', 'linktype' => 'none', 'size' => wppa_opt('widget_width'), 'fontsize' => wppa_opt('fontsize_widget_thumb'), 'lineheight' => wppa_opt('fontsize_widget_thumb') * 1.5, 'height' => '200'));
    // Make args into seperate vars
    extract($args);
    // Validate args
    if (!in_array($sortby, array('maxratingcount', 'meanrating', 'ratingcount'))) {
        wppa_dbg_msg('Invalid arg sortby "' . $sortby . '" must be "maxratingcount", "meanrating" or "ratingcount"', 'red', 'force');
    }
    if (!in_array($display, array('photo', 'owner'))) {
        wppa_dbg_msg('Invalid arg display "' . $display . '" must be "photo" or "owner"', 'red', 'force');
    }
    if (!in_array($period, array('lastweek', 'thisweek', 'lastmonth', 'thismonth', 'lastyear', 'thisyear'))) {
        wppa_dbg_msg('Invalid arg period "' . $period . '" must be "lastweek", "thisweek", "lastmonth", "thismonth", "lastyear" or "thisyear"', 'red', 'force');
    }
    if (!$widget) {
        $size = $height;
    }
    $result = '';
    $data = wppa_get_the_bestof($count, $period, $sortby, $display);
    if ($display == 'photo') {
        if (is_array($data)) {
            foreach (array_keys($data) as $id) {
                $thumb = wppa_cache_thumb($id);
                if ($thumb) {
                    $imgsize = array(wppa_get_photox($id), wppa_get_photoy($id));
                    if ($widget) {
                        $maxw = $size;
                        $maxh = round($maxw * $imgsize['1'] / $imgsize['0']);
                    } else {
                        $maxh = $size;
                        $maxw = round($maxh * $imgsize['0'] / $imgsize['1']);
                    }
                    $totalh = $maxh + $lineheight;
                    if ($maxratings == 'yes') {
                        $totalh += $lineheight;
                    }
                    if ($meanrat == 'yes') {
                        $totalh += $lineheight;
                    }
                    if ($ratcount == 'yes') {
                        $totalh += $lineheight;
                    }
                    if ($widget) {
                        $clear = 'clear:both; ';
                    } else {
                        $clear = '';
                    }
                    $result .= "\n" . '<div' . ' class="wppa-widget"' . ' style="' . $clear . 'width:' . $maxw . 'px; height:' . $totalh . 'px; margin:4px; display:inline; text-align:center; float:left;"' . ' >';
                    // The medal if at the top
                    $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top'));
                    // The link if any
                    if ($linktype != 'none') {
                        switch ($linktype) {
                            case 'owneralbums':
                                $href = wppa_get_permalink($page) . 'wppa-cover=1&amp;wppa-owner=' . $thumb['owner'] . '&amp;wppa-occur=1';
                                $title = __('See the authors albums', 'wp-photo-album-plus');
                                break;
                            case 'ownerphotos':
                                $href = wppa_get_permalink($page) . 'wppa-cover=0&amp;wppa-owner=' . $thumb['owner'] . '&photos-only&amp;wppa-occur=1';
                                $title = __('See the authors photos', 'wp-photo-album-plus');
                                break;
                            case 'upldrphotos':
                                $href = wppa_get_permalink($page) . 'wppa-cover=0&amp;wppa-upldr=' . $thumb['owner'] . '&amp;wppa-occur=1';
                                $title = __('See all the authors photos', 'wp-photo-album-plus');
                                break;
                        }
                        $result .= '<a href="' . wppa_convert_to_pretty($href) . '" title="' . $title . '" >';
                    }
                    // The image
                    $result .= '<img' . ' style="height:' . $maxh . 'px; width:' . $maxw . 'px;"' . ' src="' . wppa_fix_poster_ext(wppa_get_photo_url($id, '', $maxw, $maxh), $id) . '"' . ' ' . wppa_get_imgalt($id) . ' />';
                    // The /link
                    if ($linktype != 'none') {
                        $result .= '</a>';
                    }
                    // The medal if near the bottom
                    $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot'));
                    // The subtitles
                    $result .= "\n\t" . '<div style="font-size:' . $fontsize . 'px; line-height:' . $lineheight . 'px; position:absolute; width:' . $maxw . 'px; ">';
                    $result .= sprintf(__('Photo by: %s', 'wp-photo-album-plus'), $data[$id]['user']) . '<br />';
                    if ($maxratings == 'yes') {
                        $n = $data[$id]['maxratingcount'];
                        $result .= sprintf(_n('%d max rating', '%d max ratings', $n, 'wp-photo-album-plus'), $n) . '<br />';
                    }
                    if ($ratcount == 'yes') {
                        $n = $data[$id]['ratingcount'];
                        $result .= sprintf(_n('%d vote', '%d votes', 'wp-photo-album-plus'), $n) . '<br />';
                    }
                    if ($meanrat == 'yes') {
                        $m = $data[$id]['meanrating'];
                        $result .= sprintf(__('Rating: %4.2f.', 'wp-photo-album-plus'), $m) . '<br />';
                    }
                    $result .= '</div>';
                    $result .= '<div style="clear:both" ></div>';
                    $result .= "\n" . '</div>';
                } else {
                    // No image
                    $result .= '<div>' . sprintf(__('Photo %s not found.', 'wp-photo-album-plus'), $id) . '</div>';
                }
            }
        } else {
            $result .= $data;
            // No array, print message
        }
    } else {
        // Display = owner
        if (is_array($data)) {
            $result .= '<ul>';
            foreach (array_keys($data) as $author) {
                $result .= '<li>';
                // The link if any
                if ($linktype != 'none') {
                    switch ($linktype) {
                        case 'owneralbums':
                            $href = wppa_get_permalink($page) . 'wppa-cover=1&amp;wppa-owner=' . $data[$author]['owner'] . '&amp;wppa-occur=1';
                            $title = __('See the authors albums', 'wp-photo-album-plus');
                            break;
                        case 'ownerphotos':
                            $href = wppa_get_permalink($page) . 'wppa-cover=0&amp;wppa-owner=' . $data[$author]['owner'] . '&amp;photos-only&amp;wppa-occur=1';
                            $title = __('See the authors photos', 'wp-photo-album-plus');
                            break;
                        case 'upldrphotos':
                            $href = wppa_get_permalink($page) . 'wppa-cover=0&amp;wppa-upldr=' . $data[$author]['owner'] . '&amp;wppa-occur=1';
                            $title = __('See all the authors photos', 'wp-photo-album-plus');
                            break;
                    }
                    $result .= '<a href="' . $href . '" title="' . $title . '" >';
                }
                // The name
                $result .= $author;
                // The /link
                if ($linktype != 'none') {
                    $result .= '</a>';
                }
                $result .= '<br/>';
                // The subtitles
                $result .= "\n" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px; ">';
                if ($maxratings == 'yes') {
                    $n = $data[$author]['maxratingcount'];
                    $result .= sprintf(_n('%d max rating', '%d max ratings', $n, 'wp-photo-album-plus'), $n) . '<br />';
                }
                if ($ratcount == 'yes') {
                    $n = $data[$author]['ratingcount'];
                    $result .= sprintf(_n('%d vote', '%d votes', 'wp-photo-album-plus'), $n) . '<br />';
                }
                if ($meanrat == 'yes') {
                    $m = $data[$author]['meanrating'];
                    $result .= sprintf(__('Mean value: %4.2f.', 'wp-photo-album-plus'), $m) . '<br />';
                }
                $result .= '</div>';
                $result .= '</li>';
            }
            $result .= '</ul>';
        } else {
            $result .= $data;
            // No array, print message
        }
    }
    return $result;
}
Пример #13
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     global $wppa;
     global $thumb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     $wppa['in_widget'] = 'alb';
     $wppa['mocc']++;
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'parent' => 'none', 'name' => 'no', 'skip' => 'yes'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('wppa_album_widget_linktype'), $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_album_widget_linkpage', __a('Photo Albums'));
     $max = wppa_opt('wppa_album_widget_count');
     if (!$max) {
         $max = '10';
     }
     $parent = $instance['parent'];
     $name = $instance['name'];
     $skip = $instance['skip'];
     if (is_numeric($parent)) {
         $albums = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_ALBUMS . '` WHERE `a_parent` = %s ' . wppa_get_album_order($parent), $parent), ARRAY_A);
     } else {
         switch ($parent) {
             case 'all':
                 $albums = $wpdb->get_results('SELECT * FROM `' . WPPA_ALBUMS . '` ' . wppa_get_album_order(), ARRAY_A);
                 break;
             case 'last':
                 $albums = $wpdb->get_results('SELECT * FROM `' . WPPA_ALBUMS . '` ORDER BY `timestamp` DESC', ARRAY_A);
                 break;
             default:
                 wppa_dbg_msg('Error, unimplemented album selection: ' . $parent . ' in Album widget.', 'red', true);
         }
     }
     $widget_content = "\n" . '<!-- WPPA+ album Widget start -->';
     $maxw = wppa_opt('wppa_album_widget_size');
     $maxh = $maxw;
     if ($name == 'yes') {
         $maxh += 18;
     }
     $count = 0;
     if ($albums) {
         foreach ($albums as $album) {
             if ($count < $max) {
                 global $thumb;
                 $imageid = wppa_get_coverphoto_id($album['id']);
                 $image = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $imageid), ARRAY_A);
                 $imgcount = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ' . WPPA_PHOTOS . ' WHERE `album` = %s', $album['id']));
                 $subalbumcount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s", $album['id']));
                 $thumb = $image;
                 // Make the HTML for current picture
                 if ($image && ($imgcount > wppa_opt('wppa_min_thumbs') || $subalbumcount)) {
                     $link = wppa_get_imglnk_a('albwidget', $image['id']);
                     $file = wppa_get_thumb_path($image['id']);
                     $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                     $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'albthumb');
                     $imgstyle = $imgstyle_a['style'];
                     $width = $imgstyle_a['width'];
                     $height = $imgstyle_a['height'];
                     $cursor = $imgstyle_a['cursor'];
                     if (wppa_switch('wppa_show_albwidget_tooltip')) {
                         $title = esc_attr(strip_tags(wppa_get_album_desc($album['id'])));
                     } else {
                         $title = '';
                     }
                     $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height);
                 } else {
                     $link = '';
                     $file = '';
                     $imgevents = '';
                     $imgstyle = 'width:' . $maxw . ';height:' . $maxh . ';';
                     $width = $maxw;
                     $height = $maxw;
                     // !!
                     $cursor = 'default';
                     $title = sprintf(__a('Upload at least %d photos to this album!', 'wppa_theme'), wppa_opt('wppa_min_thumbs') - $imgcount + 1);
                     if ($imageid) {
                         // The 'empty album has a cover image
                         $file = wppa_get_thumb_path($image['id']);
                         $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'albthumb');
                         $imgstyle = $imgstyle_a['style'];
                         $width = $imgstyle_a['width'];
                         $height = $imgstyle_a['height'];
                         $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height);
                     } else {
                         $imgurl = wppa_get_imgdir() . 'album32.png';
                     }
                 }
                 $imgurl = wppa_fix_poster_ext($imgurl, $image['id']);
                 if ($imgcount > wppa_opt('wppa_min_thumbs') || $skip == 'no') {
                     $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
                     if ($link) {
                         if ($link['is_url']) {
                             // Is a href
                             $widget_content .= "\n\t" . '<a href="' . $link['url'] . '" title="' . $title . '" target="' . $link['target'] . '" >';
                             if (wppa_is_video($image['id'])) {
                                 $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title));
                             } else {
                                 $widget_content .= "\n\t\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . ' cursor:pointer;" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >';
                             }
                             $widget_content .= "\n\t" . '</a>';
                         } elseif ($link['is_lightbox']) {
                             $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($album['id']), $album['id']), 'ARRAY_A');
                             if ($thumbs) {
                                 foreach ($thumbs as $thumb) {
                                     $title = wppa_get_lbtitle('alw', $thumb['id']);
                                     if (wppa_is_video($thumb['id'])) {
                                         $siz['0'] = wppa_get_videox($thumb['id']);
                                         $siz['1'] = wppa_get_videoy($thumb['id']);
                                     } else {
                                         //	$siz = getimagesize( wppa_get_photo_path( $thumb['id'] ) );
                                         $siz['0'] = wppa_get_photox($thumb['id']);
                                         $siz['1'] = wppa_get_photoy($thumb['id']);
                                     }
                                     $link = wppa_fix_poster_ext(wppa_get_photo_url($thumb['id'], '', $siz['0'], $siz['1']), $thumb['id']);
                                     $is_video = wppa_is_video($thumb['id']);
                                     $has_audio = wppa_has_audio($thumb['id']);
                                     $widget_content .= "\n\t" . '<a href="' . $link . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($thumb['id'])) . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($thumb['id'])) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('wppa_lightbox_name') . '[alw-' . $wppa['mocc'] . '-' . $album['id'] . ']"' . ' ' . wppa('lbtitle') . '="' . $title . '" >';
                                     if ($thumb['id'] == $image['id']) {
                                         // the cover image
                                         if (wppa_is_video($image['id'])) {
                                             $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => $cursor, 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => wppa_zoom_in($image['id'])));
                                         } else {
                                             $widget_content .= "\n\t\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . wppa_zoom_in($image['id']) . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . $cursor . '" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >';
                                         }
                                     }
                                     $widget_content .= "\n\t" . '</a>';
                                 }
                             }
                         } else {
                             // Is an onclick unit
                             if (wppa_is_video($image['id'])) {
                                 $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents . ' onclick="' . $link['url'] . '"', 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title));
                             } else {
                                 $widget_content .= "\n\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . ' cursor:pointer;" ' . $imgevents . ' onclick="' . $link['url'] . '" ' . wppa_get_imgalt($image['id']) . ' >';
                             }
                         }
                     } else {
                         if (wppa_is_video($image['id'])) {
                             $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title));
                         } else {
                             $widget_content .= "\n\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . '" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >';
                         }
                     }
                     if ($name == 'yes') {
                         $widget_content .= "\n\t" . '<span style="font-size:' . wppa_opt('wppa_fontsize_widget_thumb') . 'px; min-height:100%;">' . __(stripslashes($album['name'])) . '</span>';
                     }
                     $widget_content .= "\n" . '</div>';
                     $count++;
                 }
             }
         }
     } else {
         $widget_content .= 'There are no albums (yet).';
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ thumbnail Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     $wppa['in_widget'] = false;
 }
Пример #14
0
function wppa_get_video_body($id, $for_lb = false, $w = '0', $h = '0')
{
    $is_video = wppa_is_video($id, true);
    // Not a video? no go
    if (!$is_video) {
        return '';
    }
    // See what file types are present
    extract(wp_parse_args($is_video, array('mp4' => false, 'ogv' => false, 'webm' => false)));
    // Collect other data
    $width = $w ? $w : wppa_get_videox($id);
    $height = $h ? $h : wppa_get_videoy($id);
    $source = wppa_get_photo_url($id);
    $source = substr($source, 0, strrpos($source, '.'));
    $class = $for_lb ? ' class="wppa-overlay-img"' : '';
    $is_opera = strpos($_SERVER["HTTP_USER_AGENT"], 'OPR');
    $is_ie = strpos($_SERVER["HTTP_USER_AGENT"], 'Trident');
    $is_safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari');
    wppa_dbg_msg('Mp4:' . $mp4 . ', Opera:' . $is_opera . ', Ie:' . $is_ie . ', Saf:' . $is_safari);
    // Assume the browser supports html5
    $ext = '';
    if ($is_opera) {
        if ($ogv) {
            $ext = 'ogv';
        } elseif ($webm) {
            $ext = 'webm';
        } elseif ($mp4) {
            $ext = 'mp4';
        }
    } elseif ($is_safari || $is_ie) {
        if ($mp4) {
            $ext = 'mp4';
        }
    } else {
        if ($mp4) {
            $ext = 'mp4';
        } elseif ($webm) {
            $ext = 'webm';
        } elseif ($ogv) {
            $ext = 'ogv';
        }
    }
    if ($ext) {
        $mime = str_replace('ogv', 'ogg', 'video/' . $ext);
        $result = '<source src="' . $source . '.' . $ext . '" type="' . $mime . '">';
    }
    $result .= __a('There is no filetype available for your browser, or your browser does not support html5 video', 'wppa');
    return $result;
}
Пример #15
0
function wppa_add_watermark($id)
{
    // Init
    if (!wppa_switch('wppa_watermark_on')) {
        return false;
    }
    // Watermarks off
    //	if ( wppa_is_video( $id ) ) return false;					// Can not on a video
    // Find the watermark file and location
    $temp = wppa_get_water_file_and_pos($id);
    $waterfile = $temp['file'];
    if (!$waterfile) {
        return false;
    }
    // an error has occurred
    $waterpos = $temp['pos'];
    // default
    if (basename($waterfile) == '--- none ---') {
        return false;
        // No watermark this time
    }
    // Open the watermark file
    $watersize = @getimagesize($waterfile);
    if (!is_array($watersize)) {
        return false;
    }
    // Not a valid picture file
    $waterimage = imagecreatefrompng($waterfile);
    if (empty($waterimage) or !$waterimage) {
        wppa_dbg_msg('Watermark file ' . $waterfile . ' not found or corrupt');
        return false;
        // No image
    }
    imagealphablending($waterimage, false);
    imagesavealpha($waterimage, true);
    // Open the photo file
    $file = wppa_get_photo_path($id);
    if (wppa_is_video($id)) {
        $file = wppa_fix_poster_ext($file, $id);
    }
    if (!is_file($file)) {
        return false;
    }
    // File gone
    $photosize = getimagesize($file);
    if (!is_array($photosize)) {
        return false;
        // Not a valid photo
    }
    switch ($photosize[2]) {
        case 1:
            $tempimage = imagecreatefromgif($file);
            $photoimage = imagecreatetruecolor($photosize[0], $photosize[1]);
            imagecopy($photoimage, $tempimage, 0, 0, 0, 0, $photosize[0], $photosize[1]);
            break;
        case 2:
            $photoimage = imagecreatefromjpeg($file);
            break;
        case 3:
            $photoimage = imagecreatefrompng($file);
            break;
    }
    if (empty($photoimage) or !$photoimage) {
        return false;
    }
    // No image
    $ps_x = $photosize[0];
    $ps_y = $photosize[1];
    $ws_x = $watersize[0];
    $ws_y = $watersize[1];
    $src_x = 0;
    $src_y = 0;
    if ($ws_x > $ps_x) {
        $src_x = ($ws_x - $ps_x) / 2;
        $ws_x = $ps_x;
    }
    if ($ws_y > $ps_y) {
        $src_y = ($ws_y - $ps_y) / 2;
        $ws_y = $ps_y;
    }
    $loy = substr($waterpos, 0, 3);
    switch ($loy) {
        case 'top':
            $dest_y = 0;
            break;
        case 'cen':
            $dest_y = ($ps_y - $ws_y) / 2;
            break;
        case 'bot':
            $dest_y = $ps_y - $ws_y;
            break;
        default:
            $dest_y = 0;
            // should never get here
    }
    $lox = substr($waterpos, 3);
    switch ($lox) {
        case 'lft':
            $dest_x = 0;
            break;
        case 'cen':
            $dest_x = ($ps_x - $ws_x) / 2;
            break;
        case 'rht':
            $dest_x = $ps_x - $ws_x;
            break;
        default:
            $dest_x = 0;
            // should never get here
    }
    $opacity = strpos($waterfile, '/temp/') === false ? intval(wppa_opt('wppa_watermark_opacity')) : intval(wppa_opt('wppa_watermark_opacity_text'));
    wppa_imagecopymerge_alpha($photoimage, $waterimage, $dest_x, $dest_y, $src_x, $src_y, $ws_x, $ws_y, $opacity);
    // Save the result
    switch ($photosize[2]) {
        case 1:
            imagegif($photoimage, $file);
            break;
        case 2:
            imagejpeg($photoimage, $file, wppa_opt('wppa_jpeg_quality'));
            break;
        case 3:
            imagepng($photoimage, $file, 7);
            break;
    }
    // Cleanup
    imagedestroy($photoimage);
    imagedestroy($waterimage);
    return true;
}
function wppa_dbg_cachecounts($what)
{
    static $counters;
    // Init
    $indexes = array('albumhit', 'albummis', 'photohit', 'photomis');
    foreach ($indexes as $i) {
        if (!isset($counters[$i])) {
            $counters[$i] = 0;
        }
    }
    if (wppa('debug')) {
        switch ($what) {
            case 'albumhit':
            case 'albummis':
            case 'photohit':
            case 'photomis':
                $counters[$what]++;
                break;
            case 'print':
                if ($counters['albumhit'] + $counters['albummis'] && $counters['photohit'] + $counters['photomis']) {
                    wppa_dbg_msg('Cache usage: ' . 'Album hits: ' . $counters['albumhit'] . ', ' . 'Album misses: ' . $counters['albummis'] . ' = ' . sprintf('%6.2f', 100 * $counters['albummis'] / ($counters['albumhit'] + $counters['albummis'])) . '%; ' . 'Photo hits: ' . $counters['photohit'] . ', ' . 'Photo misses: ' . $counters['photomis'] . ' = ' . sprintf('%6.2f', 100 * $counters['photomis'] / ($counters['photohit'] + $counters['photomis'])) . '%; ');
                    wppa_dbg_msg('2nd level cache entries: ' . 'albums: ' . wppa_cache_album('count') . ', ' . 'photos: ' . wppa_cache_photo('count') . '. ' . 'NQ=' . get_num_queries());
                } else {
                    wppa_dbg_msg('Cache usage: ' . 'Album hits: ' . $counters['albumhit'] . ', ' . 'Album misses: ' . $counters['albummis'] . ', ' . 'Photo hits: ' . $counters['photohit'] . ', ' . 'Photo misses: ' . $counters['photomis'] . '.');
                }
                break;
            default:
                wppa_log('err', 'Illegal $what in wppa_dbg_cachecounts(): ' . $what);
        }
    }
}
function wppa_get_widgetphotos($alb, $option = '')
{
    global $wpdb;
    if (!$alb) {
        return false;
    }
    $photos = false;
    $query = '';
    // Compile status clause
    switch (wppa_opt('potd_status_filter')) {
        case 'publish':
            $statusclause = " `status` = 'publish' ";
            break;
        case 'featured':
            $statusclause = " `status` = 'featured' ";
            break;
        case 'gold':
            $statusclause = " `status` = 'gold' ";
            break;
        case 'silver':
            $statusclause = " `status` = 'silver' ";
            break;
        case 'bronze':
            $statusclause = " `status` = 'bronze' ";
            break;
        case 'anymedal':
            $statusclause = " `status` IN ( 'gold', 'silver', 'bronze' ) ";
            break;
        default:
            $statusclause = " `status` <> 'scheduled' ";
            if (!is_user_logged_in()) {
                $statusclause .= " AND `status` <> 'private' ";
            }
    }
    // If physical album(s) and include subalbums is active, make it an enumeration(with ',' as seperator)
    if (wppa_opt('potd_album_type') == 'physical' && wppa_switch('potd_include_subs')) {
        $alb = str_replace(',', '.', $alb);
        $alb = wppa_expand_enum(wppa_alb_to_enum_children($alb));
        $alb = str_replace('.', ',', $alb);
    }
    // If physical albums and inverse selection is active, invert selection
    if (wppa_opt('potd_album_type') == 'physical' && wppa_switch('potd_inverse')) {
        $albs = explode(',', $alb);
        $all = $wpdb->get_col("SELECT `id` FROM `" . WPPA_ALBUMS . "` ");
        $alb = implode(',', array_diff($all, $albs));
    }
    /* Now find out the final query */
    /* Physical albums */
    // Is it a single album?
    if (wppa_is_int($alb)) {
        $query = $wpdb->prepare("SELECT `id`, `p_order` " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` = %s " . "AND " . $statusclause . $option, $alb);
    } elseif (strchr($alb, ',')) {
        $alb = trim($alb, ',');
        $query = "SELECT `id`, `p_order` " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN ( " . $alb . " ) " . "AND " . $statusclause . $option;
    } elseif ($alb == 'all') {
        $query = "SELECT `id`, `p_order` " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE " . $statusclause . $option;
    } elseif ($alb == 'sep') {
        $albs = $wpdb->get_results("SELECT `id`, `a_parent` FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
        $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` WHERE ( `album` = '0' ";
        $first = true;
        foreach ($albs as $a) {
            if ($a['a_parent'] == '-1') {
                $query .= "OR `album` = '" . $a['id'] . "' ";
            }
        }
        $query .= ") AND " . $statusclause . $option;
    } elseif ($alb == 'all-sep') {
        $albs = $wpdb->get_results("SELECT `id`, `a_parent` FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
        $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` WHERE ( `album` IN ('0'";
        foreach ($albs as $a) {
            if ($a['a_parent'] != '-1') {
                $query .= ",'" . $a['id'] . "'";
            }
        }
        $query .= ") ) AND " . $statusclause . $option;
    } elseif ($alb == 'topten') {
        // Find the 'top' policy
        switch (wppa_opt('topten_sortby')) {
            case 'mean_rating':
                $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
                break;
            case 'rating_count':
                $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
                break;
            case 'views':
                $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
                break;
            default:
                wppa_error_message('Unimplemented sorting method');
                $sortby = '';
                break;
        }
        // It is assumed that status is ok for top rated photos
        $query = "SELECT `id`, `p_order` FROM `" . WPPA_PHOTOS . "` ORDER BY " . $sortby . " LIMIT " . wppa_opt('topten_count');
        $query .= $option;
    }
    // Do the query
    if ($query) {
        $photos = $wpdb->get_results($query, ARRAY_A);
        wppa_dbg_msg('Potd query: ' . $query);
    } else {
        $photos = array();
    }
    // Ready
    return $photos;
}
function wppa_index_remove($type, $id)
{
    global $wpdb;
    $iam_big = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_INDEX . "`") > '10000';
    // More than 100.000 index entries,
    if ($iam_big && $id < '100') {
        return;
    }
    // Need at least 3 digits to match
    if ($type == 'album') {
        if ($iam_big) {
            // This is not strictly correct, the may be 24..28 when searching for 26, this will be missed. However this will not lead to problems during search.
            $indexes = $wpdb->get_results("SELECT * FROM `" . WPPA_INDEX . "` WHERE `albums` LIKE '" . $id . "'", ARRAY_A);
        } else {
            // There are too many results on large systems, resulting in a 500 error, but it is strictly correct
            $indexes = $wpdb->get_results("SELECT * FROM `" . WPPA_INDEX . "` WHERE `albums` <> ''", ARRAY_A);
        }
        if ($indexes) {
            foreach ($indexes as $indexline) {
                $array = wppa_index_string_to_array($indexline['albums']);
                foreach (array_keys($array) as $k) {
                    if ($array[$k] == $id) {
                        unset($array[$k]);
                        $string = wppa_index_array_to_string($array);
                        $wpdb->query("UPDATE `" . WPPA_INDEX . "` SET `albums` = '" . $string . "' WHERE `id` = " . $indexline['id']);
                    }
                }
            }
        }
    } elseif ($type == 'photo') {
        if ($iam_big) {
            // This is not strictly correct, the may be 24..28 when searching for 26, this will be missed. However this will not lead to problems during search.
            $indexes = $wpdb->get_results("SELECT * FROM `" . WPPA_INDEX . "` WHERE `photos` LIKE '%" . $id . "%'", ARRAY_A);
        } else {
            $indexes = $wpdb->get_results("SELECT * FROM `" . WPPA_INDEX . "` WHERE `photos` <> ''", ARRAY_A);
            // There are too many results on large systems, resulting in a 500 error, but it is strictly correct
        }
        if ($indexes) {
            foreach ($indexes as $indexline) {
                $array = wppa_index_string_to_array($indexline['photos']);
                foreach (array_keys($array) as $k) {
                    if ($array[$k] == $id) {
                        unset($array[$k]);
                        $string = wppa_index_array_to_string($array);
                        $wpdb->query("UPDATE `" . WPPA_INDEX . "` SET `photos` = '" . $string . "' WHERE `id` = " . $indexline['id']);
                    }
                }
            }
        }
    } else {
        wppa_dbg_msg('Error, unimplemented type in wppa_index_remove().', 'red', 'force');
    }
    $wpdb->query("DELETE FROM `" . WPPA_INDEX . "` WHERE `albums` = '' AND `photos` = ''");
    // Cleanup empty entries
}
function wppa_update_single_photo($file, $id, $name)
{
    global $wpdb;
    $photo = $wpdb->get_row($wpdb->prepare("SELECT `id`, `name`, `ext`, `album`, `filename` FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $id), ARRAY_A);
    // Find extension
    $ext = $photo['ext'];
    if ($ext == 'xxx') {
        $ext = strtolower(wppa_get_ext($file));
        // Copy from source
        if ($ext == 'jpeg') {
            $ext = 'jpg';
        }
    }
    // Make the files
    wppa_make_the_photo_files($file, $id, $ext);
    // and add watermark ( optionally ) to fullsize image only
    wppa_add_watermark($id);
    // create new thumbnail
    wppa_create_thumbnail($id);
    // Save source
    wppa_save_source($file, $name, $photo['album']);
    // Update filename if not present. this is for backward compatibility when there were no filenames saved yet
    if (!wppa_get_photo_item($id, 'filename')) {
        wppa_update_photo(array('id' => $id, 'filename' => $name));
    }
    // Update modified timestamp
    wppa_update_modified($id);
    wppa_dbg_msg('Update single photo: ' . $name . ' in album ' . $photo['album'], 'green');
}
function wppa_set_shortcodes($xatts, $content = '')
{
    global $wppa;
    global $wppa_opt;
    $atts = shortcode_atts(array('name' => '', 'value' => ''), $xatts);
    $allowed = explode(',', wppa_opt('set_shortcodes'));
    // Valid item?
    if ($atts['name'] && !in_array($atts['name'], $allowed)) {
        wppa_dbg_msg($atts['name'] . ' is not a runtime settable configuration entity.', 'red', 'force');
    } elseif (!$atts['name']) {
        $wppa_opt = get_option('wppa_cached_options', false);
        wppa_reset_occurrance();
    } elseif (substr($atts['name'], 0, 5) == 'wppa_') {
        if (isset($wppa_opt[$atts['name']])) {
            $wppa_opt[$atts['name']] = $atts['value'];
        } else {
            wppa_dbg_msg($atts['name'] . ' is not an option value.', 'red', 'force');
        }
    } else {
        if (isset($wppa[$atts['name']])) {
            $wppa[$atts['name']] = $value;
        } else {
            wppa_dbg_msg($atts['name'] . ' is not a runtime value.', 'red', 'force');
        }
    }
}
Пример #21
0
function wppa_theme()
{
    global $wppa_version;
    $wppa_version = '6-1-15-000';
    // The version number of this file
    global $wppa;
    global $wppa_show_statistics;
    // Can be set to true by a custom page template
    $curpage = wppa_get_curpage();
    // Get the page # we are on when pagination is on, or 1
    $didsome = false;
    // Required initializations for pagination
    $n_album_pages = '0';
    // "
    $n_thumb_pages = '0';
    // "
    // Open container
    wppa_container('open');
    // Show statistics if set so by the page template
    if ($wppa_show_statistics) {
        wppa_statistics();
    }
    // Display breadcrumb navigation only if it is set in the settings page
    wppa_breadcrumb('optional');
    if (wppa_page('albums')) {
        // Page 'Albums' requested
        // Get the albums and the thumbs and the number of pages for each set
        $albums = wppa_get_albums();
        // Get the albums
        $n_album_pages = wppa_get_npages('albums', $albums);
        // Get the number of album pages
        if (wppa_opt('thumbtype') != 'none') {
            $thumbs = wppa_get_thumbs();
            // Get the Thumbs
        } else {
            $thumbs = false;
        }
        $wanted_empty = wppa_is_wanted_empty($thumbs);
        // See if we need to display an empty thumbnail area
        $n_thumb_pages = wppa_get_npages('thumbs', $thumbs);
        // Get the number of thumb pages
        if ($n_thumb_pages == '0' && !$wanted_empty) {
            $thumbs = false;
        }
        // No pages: no thumbs. Maybe want covers only
        if ($wanted_empty) {
            $n_thumb_pages = '1';
        }
        // Get total number of pages
        if (!wppa_is_pagination()) {
            $totpag = '1';
        } else {
            $totpag = $n_album_pages + $n_thumb_pages;
        }
        // Make pagelinkbar if requested on top
        if (wppa_opt('pagelink_pos') == 'top' || wppa_opt('pagelink_pos') == 'both') {
            wppa_page_links($totpag, $curpage);
        }
        // Process the albums
        if (!wppa_switch('wppa_thumbs_first')) {
            if ($albums) {
                $counter_albums = '0';
                wppa_album_list('open');
                // Open Albums sub-container
                foreach ($albums as $album) {
                    // Loop the albums
                    $counter_albums++;
                    if (wppa_onpage('albums', $counter_albums, $curpage)) {
                        wppa_album_cover($album['id']);
                        // Show the cover
                        $didsome = true;
                    }
                    // End if on page
                }
                wppa_album_list('close');
                // Close Albums sub-container
            }
            // If albums
        }
        if ($didsome && wppa_is_pagination()) {
            $thumbs = false;
        }
        // Pag on and didsome: force a pagebreak by faking no thumbs
        if (count($thumbs) <= wppa_get_mincount() && !$wanted_empty) {
            $thumbs = false;
        }
        // Less than treshold value
        if (wppa_switch('wppa_thumbs_first') && $curpage > $n_thumb_pages) {
            $thumbs = false;
        }
        // If thumbs done, do not display an empty thumbarea
        // Process the thumbs
        if ($thumbs || $wanted_empty) {
            if (!$wanted_empty || !wppa_switch('thumbs_first') || wppa_get_curpage() == '1') {
                if (!$wanted_empty || wppa_switch('thumbs_first') || wppa_get_curpage() == $totpag) {
                    // Init
                    $counter_thumbs = '0';
                    // As covers
                    if (wppa_opt('wppa_thumbtype') == 'ascovers' || wppa_opt('wppa_thumbtype') == 'ascovers-mcr') {
                        // Do the thumbs As covers
                        wppa_thumb_list('open');
                        // Open Thumblist sub-container
                        $relpage = wppa_switch('wppa_thumbs_first') ? $curpage : $curpage - $n_album_pages;
                        foreach ($thumbs as $tt) {
                            global $thumb;
                            $thumb = $tt;
                            // Loop the Thumbs
                            $counter_thumbs++;
                            if (wppa_onpage('thumbs', $counter_thumbs, $relpage)) {
                                $didsome = true;
                                wppa_thumb_ascover($thumb['id']);
                                // Show Thumb as cover
                            }
                            // End if on page
                        }
                        wppa_thumb_list('close');
                        // Close Thumblist sub-container
                    } elseif (wppa_opt('wppa_thumbtype') == 'masonry-v') {
                        // Masonry
                        // The header
                        wppa_thumb_area('open');
                        // Open Thumbarea sub-container
                        wppa_popup();
                        // Prepare Popup box
                        wppa_album_name('top');
                        // Optionally display album name
                        wppa_album_desc('top');
                        // Optionally display album description
                        // Init
                        $relpage = wppa_switch('wppa_thumbs_first') ? $curpage : $curpage - $n_album_pages;
                        $cont_width = wppa_get_container_width();
                        $count_cols = ceil($cont_width / (wppa_opt('wppa_thumbsize') + wppa_opt('wppa_tn_margin')));
                        $correction = wppa_opt('wppa_tn_margin') * ($cont_width / $count_cols) / 100;
                        // Init the table
                        wppa_out('<table class="wppa-masonry" style="margin-top:3px;" ><tbody class="wppa-masonry" ><tr class="wppa-masonry" >');
                        // Init the columns
                        $col_headers = array();
                        $col_contents = array();
                        $col_heights = array();
                        $col_widths = array();
                        for ($col = 0; $col < $count_cols; $col++) {
                            $col_headers[$col] = '';
                            $col_contents[$col] = '';
                            $col_heights[$col] = 0;
                            $col_widths[$col] = 100;
                        }
                        // Process the thumbnails
                        $col = '0';
                        if ($thumbs) {
                            foreach ($thumbs as $tt) {
                                $id = $tt['id'];
                                $counter_thumbs++;
                                if (wppa_onpage('thumbs', $counter_thumbs, $relpage)) {
                                    $col_contents[$col] .= wppa_get_thumb_masonry($id);
                                    $col_heights[$col] += ($correction + wppa_get_thumby($id)) / ($correction + wppa_get_thumbx($id)) * $col_widths[$col];
                                    $col += '1';
                                    if ($col == $count_cols) {
                                        $col = '0';
                                    }
                                    $didsome = true;
                                }
                            }
                        }
                        // Find longest column
                        $long = 0;
                        for ($col = 0; $col < $count_cols; $col++) {
                            if ($col_heights[$col] > $long) {
                                $long = $col_heights[$col];
                            }
                        }
                        // Adjust column widths to resize lengths to equal lengths
                        for ($col = 0; $col < $count_cols; $col++) {
                            if ($col_heights[$col]) {
                                $col_widths[$col] = $long / $col_heights[$col] * $col_widths[$col];
                            }
                        }
                        // Adjust column widths to total 100
                        $wide = 0;
                        for ($col = 0; $col < $count_cols; $col++) {
                            $wide += $col_widths[$col];
                        }
                        for ($col = 0; $col < $count_cols; $col++) {
                            $col_widths[$col] = $col_widths[$col] * 100 / $wide;
                        }
                        // Make column headers
                        for ($col = 0; $col < $count_cols; $col++) {
                            $col_headers[$col] = '<td style="width: ' . $col_widths[$col] . '%; vertical-align:top;" class="wppa-masonry" >';
                        }
                        // Add the columns to the output stream
                        for ($col = 0; $col < $count_cols; $col++) {
                            wppa_out($col_headers[$col]);
                            wppa_out($col_contents[$col]);
                            wppa_out('</td>');
                        }
                        // Close the table
                        wppa_out('</tr></tbody></table>');
                        // The footer
                        wppa_album_name('bottom');
                        // Optionally display album name
                        wppa_album_desc('bottom');
                        // Optionally display album description
                        wppa_thumb_area('close');
                        // Close Thumbarea sub-container
                    } elseif (wppa_opt('wppa_thumbtype') == 'masonry-h') {
                        // Masonry
                        // The header
                        wppa_thumb_area('open');
                        // Open Thumbarea sub-container
                        wppa_popup();
                        // Prepare Popup box
                        wppa_album_name('top');
                        // Optionally display album name
                        wppa_album_desc('top');
                        // Optionally display album description
                        // Init
                        $relpage = wppa_switch('wppa_thumbs_first') ? $curpage : $curpage - $n_album_pages;
                        $cont_width = wppa_get_container_width('netto');
                        $correction = wppa_opt('wppa_tn_margin');
                        // Init the table
                        wppa_out('<table class="wppa-masonry" style="margin-top:3px;" ><tbody class="wppa-masonry" >');
                        // Process the thumbnails
                        $row_content = '';
                        $row_width = 0;
                        $target_row_height = wppa_opt('wppa_thumbsize') * 0.75 + $correction;
                        $rw_count = 0;
                        $tr_count = '1';
                        $done_count = 0;
                        $last = false;
                        $max_row_height = $target_row_height * 0.8;
                        // Init keep track for last
                        if ($thumbs) {
                            foreach ($thumbs as $tt) {
                                $id = $tt['id'];
                                $counter_thumbs++;
                                if (wppa_onpage('thumbs', $counter_thumbs, $relpage)) {
                                    $row_content .= wppa_get_thumb_masonry($tt['id']);
                                    $rw_count += 1;
                                    $row_width += wppa_get_thumbratioxy($id) * ($target_row_height - $correction);
                                    $didsome = true;
                                }
                                $done_count += 1;
                                $last = $done_count == count($thumbs);
                                if ($row_width > $cont_width || $last) {
                                    $tot_marg = $rw_count * $correction;
                                    $row_height = $row_width ? ($target_row_height - $correction) * ($cont_width - '3' - $tot_marg) / $row_width + $correction : '0';
                                    if (!$last) {
                                        $max_row_height = max($max_row_height, $row_height);
                                    }
                                    if ($last && $row_height > wppa_get_thumby($id)) {
                                        $row_height = $max_row_height;
                                    }
                                    $row_height_p = $row_height / $cont_width * 100;
                                    wppa_out('<tr class="wppa-masonry" >' . '<td style="border:none;padding:0;margin:0" >' . '<div' . ' id="wppa-mas-h-' . $tr_count . '-' . wppa('mocc') . '"' . ' style="height:' . $row_height . 'px;"' . ' class="wppa-masonry"' . ' data-height-perc="' . $row_height_p . '"' . ' >');
                                    wppa_out($row_content);
                                    wppa_out('</div></td></tr>');
                                    $row_content = '';
                                    $row_width = 0;
                                    $row_height = wppa_opt('wppa_thumbsize');
                                    $rw_count = 0;
                                    $tr_count += '1';
                                }
                            }
                        }
                        wppa_out('</tbody></table>');
                        // The footer
                        wppa_album_name('bottom');
                        // Optionally display album name
                        wppa_album_desc('bottom');
                        // Optionally display album description
                        wppa_thumb_area('close');
                        // Close Thumbarea sub-container
                    } elseif (wppa_opt('wppa_thumbtype') == 'default') {
                        // Do the thumbs As default
                        // The header
                        wppa_thumb_area('open');
                        // Open Thumbarea sub-container
                        wppa_popup();
                        // Prepare Popup box
                        wppa_album_name('top');
                        // Optionally display album name
                        wppa_album_desc('top');
                        // Optionally display album description
                        // Init
                        $relpage = wppa_switch('wppa_thumbs_first') ? $curpage : $curpage - $n_album_pages;
                        // Process the thumbnails
                        if ($thumbs) {
                            foreach ($thumbs as $tt) {
                                $counter_thumbs++;
                                if (wppa_onpage('thumbs', $counter_thumbs, $relpage)) {
                                    $didsome = true;
                                    wppa_thumb_default($tt['id']);
                                    // Show Thumb as default
                                }
                                // End if on page
                            }
                        }
                        // The footer
                        wppa_album_name('bottom');
                        // Optionally display album name
                        wppa_album_desc('bottom');
                        // Optionally display album description
                        wppa_thumb_area('close');
                        // Close Thumbarea sub-container
                    } else {
                        wppa_out('Unimplemented thumbnail type');
                    }
                }
            }
        }
        // If thumbs
        if ($didsome && wppa_is_pagination()) {
            $albums = false;
        }
        // Pag on and didsome: force a pagebreak by faking no albums
        if (!wppa_is_pagination()) {
            $n_thumb_pages = '0';
        }
        // Still on page one
        // Process the albums
        if (wppa_switch('wppa_thumbs_first')) {
            if ($albums) {
                $counter_albums = '0';
                wppa_album_list('open');
                // Open Albums sub-container
                foreach ($albums as $album) {
                    // Loop the albums
                    $counter_albums++;
                    if (wppa_onpage('albums', $counter_albums, $curpage - $n_thumb_pages)) {
                        wppa_album_cover($album['id']);
                        // Show the cover
                        $didsome = true;
                    }
                    // End if on page
                }
                wppa_album_list('close');
                // Close Albums sub-container
            }
            // If albums
        }
        // Make pagelinkbar if requested on bottom
        if (wppa_opt('pagelink_pos') == 'bottom' || wppa_opt('pagelink_pos') == 'both') {
            wppa_page_links($totpag, $curpage);
        }
        // Empty results?
        if (!$didsome && !$wanted_empty) {
            if (wppa('photos_only')) {
                wppa_out(wppa_errorbox(__a('No photos found matching your search criteria.', 'wppa_theme')));
            } elseif (wppa('albums_only')) {
                wppa_out(wppa_errorbox(__a('No albums found matching your search criteria.', 'wppa_theme')));
            } else {
                wppa_out(wppa_errorbox(__a('No albums or photos found matching your search criteria.', 'wppa_theme')));
            }
        }
    } elseif (wppa_page('slide') || wppa_page('single')) {
        // Page 'Slideshow' or 'Single' in browsemode requested
        $thumbs = wppa_get_thumbs();
        wppa_dbg_msg('From theme: #thumbs=' . ($thumbs ? count($thumbs) : '0'));
        if ($thumbs) {
            wppa_the_slideshow();
            // Producs all the html required for the slideshow
            wppa_run_slidecontainer('slideshow');
            // Fill in the photo array and display it.
        } else {
            wppa_out(wppa_errorbox(__a('No photos found matching your search criteria.', 'wppa_theme')));
        }
    }
    // wppa_page( 'slide' )
    // Close container
    wppa_container('close');
}
function wppa_get_lbtitle($type, $id)
{
    if (!is_numeric($id) || $id < '1') {
        wppa_dbg_msg('Invalid arg wppa_get_lbtitle( ' . $id . ' )', 'red');
    }
    $thumb = wppa_cache_thumb($id);
    $do_download = wppa_is_video($id) ? false : wppa_switch('art_monkey_on_lightbox');
    if ($type == 'xphoto') {
        $type = 'mphoto';
    }
    $do_name = wppa_switch('ovl_' . $type . '_name') || wppa_switch('ovl_add_owner');
    $do_desc = wppa_switch('ovl_' . $type . '_desc');
    $do_sm = wppa_switch('share_on_lightbox');
    $result = '';
    if ($do_download) {
        if (wppa_opt('art_monkey_display') == 'button') {
            $result .= '<input' . ' type="button"' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer; margin-bottom:0px; max-width:500px;"' . ' class="wppa-download-button wppa-ovl-button"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', \'' . wppa_encrypt_photo($id) . '\' );"' . ' value="' . rtrim(__('Download', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'))) . '"' . ' />';
        } else {
            $result .= '<a' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer;"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', \'' . wppa_encrypt_photo($id) . '\' );"' . ' >' . rtrim(__('Download', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'))) . '</a>';
        }
    } else {
        if ($do_name) {
            $result .= wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'));
        }
    }
    if ($do_name && $do_desc) {
        $result .= '<br />';
    }
    if ($do_desc) {
        $result .= wppa_get_photo_desc($thumb['id']);
    }
    if (($do_name || $do_desc) && $do_sm) {
        $result .= '<br />';
    }
    if (wppa_opt('rating_max') != '1' && wppa_opt('rating_display_type') == 'graphic') {
        $result .= wppa_get_rating_range_html($id, true);
    } elseif (wppa_opt('rating_display_type') == 'likes' && wppa_switch('ovl_rating')) {
        $result .= wppa_get_slide_rating_vote_only('always', $id, 'is_lightbox');
    }
    if ($do_sm) {
        $result .= wppa_get_share_html($thumb['id'], 'lightbox');
    }
    if (wppa_may_user_fe_edit($id)) {
        if ($type == 'slide') {
            $parg = esc_js('\'' . wppa_encrypt_photo($id) . '\'');
        } else {
            $parg = '\'' . wppa_encrypt_photo($id) . '\'';
        }
        if (wppa_opt('upload_edit') == 'classic') {
            $result .= '
			<input' . ' type="button"' . ' style="float:right; margin-right:6px;"' . ' class="wppa-ovl-button"' . ' onclick="' . ($type == 'slide' ? '_wppaStop( ' . wppa('mocc') . ' );' : '') . 'wppaEditPhoto( ' . wppa('mocc') . ', ' . $parg . ' );"' . ' value="' . esc_attr(__(wppa_opt('fe_edit_button'))) . '"' . ' />';
        }
    }
    $result = esc_attr($result);
    return $result;
}
function wppa_load_footer()
{
    global $wpdb;
    global $wppa_session;
    echo '
		<!-- start WPPA+ Footer data -->
		';
    // Do they use our lightbox?
    if (wppa_opt('lightbox_name') == 'wppa') {
        $fontsize_lightbox = wppa_opt('fontsize_lightbox') ? wppa_opt('fontsize_lightbox') : '10';
        $d = wppa_switch('ovl_show_counter') ? 1 : 0;
        $ovlh = wppa_opt('ovl_txt_lines') == 'auto' ? 'auto' : (wppa_opt('ovl_txt_lines') + $d) * ($fontsize_lightbox + 2);
        $txtcol = wppa_opt('ovl_theme') == 'black' ? '#a7a7a7' : '#272727';
        $dark = wppa('is_mobile') ? '0.1' : '0.1';
        // The lightbox overlay background
        echo '<div' . ' id="wppa-overlay-bg"' . ' style="' . 'text-align:center;' . 'display:none;' . 'position:fixed;' . 'top:0;' . 'left:0;' . 'z-index:100090;' . 'width:100%;' . 'height:2048px;' . 'background-color:' . wppa_opt('ovl_bgcolor') . ';' . '"' . ' onclick="wppaOvlOnclick(event)"' . ' >';
        // Display legenda
        if (wppa_switch('ovl_show_legenda') && !wppa('is_mobile')) {
            echo '<div' . ' id="wppa-ovl-legenda-1"' . ' onmouseover="jQuery(this).css(\'visibility\',\'visible\');"' . ' onmouseout="jQuery(this).css(\'visibility\',\'hidden\');"' . ' style="' . 'position:absolute;' . 'left:0;' . 'top:0;' . 'background-color:' . wppa_opt('ovl_theme') . ';' . 'color:' . $txtcol . ';' . 'visibility:visible;' . '"' . ' >
					' . __('Press f for fullscreen.', 'wp-photo-album-plus') . '
				</div>';
        }
        // The 'exit' icon
        echo '<div' . ' id="wppa-exit-btn"' . ' style="height:48px;z-index:100098;position:fixed;top:0;right:0;opacity:0.75;"' . ' onclick="wppaOvlHide()"' . ' onmouseover="jQuery(this).stop().fadeTo(300,1);"' . ' onmouseout="jQuery(this).stop().fadeTo(300,' . $dark . ');"' . ' >' . wppa_get_svghtml('Exit', '48px', true, true, '0', '0', '0', '0') . '</div>' . '<script>' . 'jQuery(\'#wppa-exit-btn\').on(\'touchstart\',function(){jQuery(\'#wppa-exit-btn\').stop().fadeTo(300,1);});' . 'jQuery(\'#wppa-exit-btn\').on(\'touchend\',function(){jQuery(\'#wppa-exit-btn\').stop().fadeTo(300,' . $dark . ');});' . '</script>';
        // The 'fullscreen' icon
        echo '<div' . ' id="wppa-fulls-btn"' . ' style="height:48px;z-index:100092;position:fixed;top:0;right:48px;opacity:0.75;"' . ' onclick="wppaOvlFull()"' . ' onmouseover="jQuery(this).stop().fadeTo(300,1);"' . ' onmouseout="jQuery(this).stop().fadeTo(300,' . $dark . ');"' . ' >' . wppa_get_svghtml('Full-Screen', '48px', true, true, '0', '0', '0', '0') . '</div>' . '<script>' . 'jQuery(\'#wppa-fulls-btn\').on(\'touchstart\',function(){jQuery(\'#wppa-fulls-btn\').stop().fadeTo(300,1);});' . 'jQuery(\'#wppa-fulls-btn\').on(\'touchend\',function(){jQuery(\'#wppa-fulls-btn\').stop().fadeTo(300,' . $dark . ');});' . '</script>';
        // Close lightbox overlay background
        echo '</div>';
        // The Lightbox Image container
        echo '<div' . ' id="wppa-overlay-ic"' . ' style="' . 'position:fixed;' . 'top:50%;' . 'left:50%;' . 'z-index:100095;' . 'opacity:1;' . 'box-shadow:none;' . 'box-sizing:content-box;' . '"' . ' >' . '</div>';
        // The Spinner image
        echo '<img' . ' id="wppa-overlay-sp"' . ' alt="spinner"' . ' style="' . 'position:fixed;' . 'top:50%;' . 'margin-top:-16px;' . 'left:50%;' . 'margin-left:-16px;' . 'z-index:100100;' . 'opacity:1;' . 'visibility:hidden;' . 'box-shadow:none;' . '"' . ' src="' . wppa_get_imgdir() . 'loading.gif"' . ' />';
        // The init vars
        echo '
		<script type="text/javascript">
			jQuery("#wppa-overlay-bg").css({height:window.innerHeight});
			wppaOvlModeInitial = "' . (wppa('is_mobile') ? wppa_opt('ovl_mode_initial_mob') : wppa_opt('ovl_mode_initial')) . '";
			wppaOvlTxtHeight = "' . $ovlh . '";
			wppaOvlOpacity = ' . wppa_opt('ovl_opacity') / 100 . ';
			wppaOvlOnclickType = "' . wppa_opt('ovl_onclick') . '";
			wppaOvlTheme = "' . wppa_opt('ovl_theme') . '";
			wppaOvlAnimSpeed = ' . wppa_opt('ovl_anim') . ';
			wppaOvlSlideSpeed = ' . wppa_opt('ovl_slide') . ';
			wppaVer4WindowWidth = 800;
			wppaVer4WindowHeight = 600;
			wppaOvlShowCounter = ' . (wppa_switch('ovl_show_counter') ? 'true' : 'false') . ';
			' . (wppa_opt('fontfamily_lightbox') ? 'wppaOvlFontFamily = "' . wppa_opt('fontfamily_lightbox') . '"' : '') . '
			wppaOvlFontSize = "' . $fontsize_lightbox . '";
			' . (wppa_opt('fontcolor_lightbox') ? 'wppaOvlFontColor = "' . wppa_opt('fontcolor_lightbox') . '"' : '') . '
			' . (wppa_opt('fontweight_lightbox') ? 'wppaOvlFontWeight = "' . wppa_opt('fontweight_lightbox') . '"' : '') . '
			' . (wppa_opt('fontsize_lightbox') ? 'wppaOvlLineHeight = "' . (wppa_opt('fontsize_lightbox') + '2') . '"' : '') . '
			wppaOvlFullLegenda = "' . __('Keys: f = next mode; q,x = exit; p = previous, n = next, s = start/stop, d = dismiss this notice.', 'wp-photo-album-plus') . '";
			wppaOvlFullLegendaSingle = "' . __('Keys: f = next mode; q,x = exit; d = dismiss this notice.', 'wp-photo-album-plus') . '";
			wppaOvlVideoStart = ' . (wppa_switch('ovl_video_start') ? 'true' : 'false') . ';
			wppaOvlAudioStart = ' . (wppa_switch('ovl_audio_start') ? 'true' : 'false') . ';
			wppaOvlShowLegenda = ' . (wppa_switch('ovl_show_legenda') && !wppa('is_mobile') ? 'true' : 'false') . ';
			wppaOvlShowStartStop = ' . (wppa_switch('ovl_show_startstop') ? 'true' : 'false') . ';
			wppaToggleFullScreen = "' . __('Toggle fullscreen', 'wp-photo-album-plus') . '";
			wppaIsMobile = ' . (wppa_is_mobile() ? 'true' : 'false') . ';
		</script>
		';
    }
    // The photo views cache
    echo '
	<script type="text/javascript">';
    if (isset($wppa_session['photo'])) {
        foreach (array_keys($wppa_session['photo']) as $p) {
            echo '
				wppaPhotoView[' . $p . '] = true;';
        }
    }
    echo '
	</script>
<!-- end WPPA+ Footer data -->
';
    // Debugging, show queries
    wppa_dbg_cachecounts('print');
    // Debugging, show active plugins
    if (wppa('debug')) {
        $plugins = get_option('active_plugins');
        wppa_dbg_msg('Active Plugins');
        foreach ($plugins as $plugin) {
            wppa_dbg_msg($plugin);
        }
        wppa_dbg_msg('End Active Plugins');
    }
    echo '
<!-- Nonce for various wppa actions -->';
    // Nonce field for Ajax bump view counter from lightbox, and rating
    wp_nonce_field('wppa-check', 'wppa-nonce', false, true);
    echo '
<!-- Do user upload -->';
    // Do the upload if required and not yet done
    wppa_user_upload();
    // Done
    echo '
<!-- Done user upload -->';
}
Пример #24
0
function wppa_flush_upldr_cache($key = '', $id = '')
{
    $upldrcache = wppa_get_upldr_cache();
    foreach (array_keys($upldrcache) as $widget_id) {
        switch ($key) {
            case 'widgetid':
                if ($id == $widget_id) {
                    unset($upldrcache[$widget_id]);
                }
            case 'photoid':
                $usr = wppa_get_photo_item($id, 'owner');
                if (isset($upldrcache[$widget_id][$usr])) {
                    unset($upldrcache[$widget_id][$usr]);
                }
                break;
            case 'username':
                $usr = $id;
                if (isset($upldrcache[$widget_id][$usr])) {
                    unset($upldrcache[$widget_id][$usr]);
                }
                break;
            case 'all':
                $upldrcache = array();
                break;
            default:
                wppa_dbg_msg('Missing key in wppa_flush_upldr_cache()', 'red');
                break;
        }
    }
    update_option('wppa_upldr_cache', $upldrcache);
}
Пример #25
0
function wppa_get_photo_item($id, $item)
{
    $photo = wppa_cache_photo($id);
    if ($photo) {
        if (isset($photo[$item])) {
            return trim($photo[$item]);
        } else {
            wppa_dbg_msg('Photo item ' . $item . ' does not exist. ( get_photo_item )', 'red');
        }
    } else {
        wppa_dbg_msg('Photo ' . $id . ' does not exist. ( get_photo_item )', 'red');
    }
    return false;
}
function wppa_get_audio_body($id, $for_lb = false, $w = '0', $h = '0')
{
    // Audio enabled?
    if (!wppa_switch('enable_audio')) {
        return '';
    }
    $is_audio = wppa_has_audio($id, true);
    // Not a audio? no go
    if (!$is_audio) {
        return '';
    }
    // See what file types are present
    extract(wp_parse_args($is_audio, array('mp3' => false, 'wav' => false, 'ogg' => false)));
    // Collect other data
    $width = $w ? $w : wppa_get_photox($id);
    $height = $h ? $h : wppa_get_photoy($id);
    $source = wppa_get_photo_url($id);
    $source = substr($source, 0, strrpos($source, '.'));
    $class = $for_lb ? ' class="wppa-overlay-img"' : '';
    $is_opera = strpos($_SERVER["HTTP_USER_AGENT"], 'OPR');
    $is_ie = strpos($_SERVER["HTTP_USER_AGENT"], 'Trident');
    $is_safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari');
    wppa_dbg_msg('Mp3:' . $mp3 . ', Opera:' . $is_opera . ', Ie:' . $is_ie . ', Saf:' . $is_safari);
    // Assume the browser supports html5
    $ext = '';
    if ($is_ie) {
        if ($mp3) {
            $ext = 'mp3';
        }
    } elseif ($is_safari) {
        if ($mp3) {
            $ext = 'mp3';
        } elseif ($wav) {
            $ext = 'wav';
        }
    } else {
        if ($mp3) {
            $ext = 'mp3';
        } elseif ($wav) {
            $ext = 'wav';
        } elseif ($ogg) {
            $ext = 'ogg';
        }
    }
    if ($ext) {
        $mime = str_replace('mp3', 'mpeg', 'audio/' . $ext);
        $result = '<source src="' . $source . '.' . $ext . '" type="' . $mime . '">';
    }
    $result .= esc_js(__('There is no filetype available for your browser, or your browser does not support html5 audio', 'wp-photo-album-plus'));
    return $result;
}
function wppa_make_the_photo_files($file, $id, $ext)
{
    global $wpdb;
    $thumb = wppa_cache_thumb($id);
    $src_size = @getimagesize($file, $info);
    // If the given file is not an image file, log error and exit
    if (!$src_size) {
        if (is_admin()) {
            wppa_error_message(sprintf(__('ERROR: File %s is not a valid picture file.', 'wp-photo-album-plus'), $file));
        } else {
            wppa_alert(sprintf(__('ERROR: File %s is not a valid picture file.', 'wp-photo-album-plus'), $file));
        }
        return false;
    }
    // Find output path photo file
    $newimage = wppa_get_photo_path($id);
    if ($ext) {
        $newimage = wppa_strip_ext($newimage) . '.' . strtolower($ext);
    }
    // If Resize on upload is checked
    if (wppa_switch('resize_on_upload')) {
        // Picture sizes
        $src_width = $src_size[0];
        // Temp convert to logical width if stereo
        if ($thumb['stereo']) {
            $src_width /= 2;
        }
        $src_height = $src_size[1];
        // Max sizes
        if (wppa_opt('resize_to') == '0') {
            // from fullsize
            $max_width = wppa_opt('fullsize');
            $max_height = wppa_opt('maxheight');
        } else {
            // from selection
            $screen = explode('x', wppa_opt('resize_to'));
            $max_width = $screen[0];
            $max_height = $screen[1];
        }
        // If orientation needs +/- 90 deg rotation, swap max x and max y
        $ori = wppa_get_exif_orientation($file);
        if ($ori >= 5 && $ori <= 8) {
            $t = $max_width;
            $max_width = $max_height;
            $max_height = $t;
        }
        // Is source more landscape or more portrait than max window
        if ($src_width / $src_height > $max_width / $max_height) {
            // focus on width
            $focus = 'W';
            $need_downsize = $src_width > $max_width;
        } else {
            // focus on height
            $focus = 'H';
            $need_downsize = $src_height > $max_height;
        }
        // Convert back to physical size
        if ($thumb['stereo']) {
            $src_width *= 2;
        }
        // Downsize required ?
        if ($need_downsize) {
            // Find mime type
            $mime = $src_size[2];
            // Create the source image
            switch ($mime) {
                // mime type
                case 1:
                    // gif
                    $temp = @imagecreatefromgif($file);
                    if ($temp) {
                        $src = imagecreatetruecolor($src_width, $src_height);
                        imagecopy($src, $temp, 0, 0, 0, 0, $src_width, $src_height);
                        imagedestroy($temp);
                    } else {
                        $src = false;
                    }
                    break;
                case 2:
                    // jpeg
                    if (!function_exists('wppa_imagecreatefromjpeg')) {
                        wppa_log('Error', 'Function wppa_imagecreatefromjpeg does not exist.');
                    }
                    $src = @wppa_imagecreatefromjpeg($file);
                    break;
                case 3:
                    // png
                    $src = @imagecreatefrompng($file);
                    break;
            }
            if (!$src) {
                wppa_log('Error', 'Image file ' . $file . ' is corrupt while downsizing photo');
                return false;
            }
            // Create the ( empty ) destination image
            if ($focus == 'W') {
                if ($thumb['stereo']) {
                    $max_width *= 2;
                }
                $dst_width = $max_width;
                $dst_height = round($max_width * $src_height / $src_width);
            } else {
                $dst_height = $max_height;
                $dst_width = round($max_height * $src_width / $src_height);
            }
            $dst = imagecreatetruecolor($dst_width, $dst_height);
            // If Png, save transparancy
            if ($mime == 3) {
                imagealphablending($dst, false);
                imagesavealpha($dst, true);
            }
            // Do the copy
            imagecopyresampled($dst, $src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
            // Remove source image
            imagedestroy($src);
            // Save the photo
            switch ($mime) {
                // mime type
                case 1:
                    imagegif($dst, $newimage);
                    break;
                case 2:
                    imagejpeg($dst, $newimage, wppa_opt('jpeg_quality'));
                    break;
                case 3:
                    imagepng($dst, $newimage, 6);
                    break;
            }
            // Remove destination image
            imagedestroy($dst);
        } else {
            // No downsize needed, picture is small enough
            copy($file, $newimage);
        }
    } else {
        copy($file, $newimage);
    }
    // File successfully created ?
    if (is_file($newimage)) {
        // Make sure file is accessable
        wppa_chmod($newimage);
        // Optimize file
        wppa_optimize_image_file($newimage);
    } else {
        if (is_admin()) {
            wppa_error_message(__('ERROR: Resized or copied image could not be created.', 'wp-photo-album-plus'));
        } else {
            wppa_alert(__('ERROR: Resized or copied image could not be created.', 'wp-photo-album-plus'));
        }
        return false;
    }
    // Process the iptc data
    wppa_import_iptc($id, $info);
    // Process the exif data
    wppa_import_exif($id, $file);
    // GPS
    wppa_get_coordinates($file, $id);
    // Set ( update ) exif date-time if available
    $exdt = wppa_get_exif_datetime($file);
    if ($exdt) {
        wppa_update_photo(array('id' => $id, 'exifdtm' => $exdt));
    }
    // Check orientation
    wppa_orientate_image($id, wppa_get_exif_orientation($file));
    // Compute and save sizes
    wppa_get_photox($id, 'force');
    // Show progression
    if (is_admin() && !wppa('ajax')) {
        echo '.';
    }
    // Update CDN
    $cdn = wppa_cdn('admin');
    if ($cdn) {
        switch ($cdn) {
            case 'cloudinary':
                wppa_upload_to_cloudinary($id);
                break;
            default:
                wppa_dbg_msg('Missing upload instructions for ' . $cdn, 'red', 'force');
        }
    }
    // Create stereo images
    wppa_create_stereo_images($id);
    // Create thumbnail...
    wppa_create_thumbnail($id);
    // Clear (super)cache
    wppa_clear_cache();
    return true;
}
Пример #28
0
function wppa_breadcrumb($opt = '')
{
    global $wpdb;
    global $wppa_session;
    // See if they need us
    // Check Table II-A1 a and b
    if ($opt == 'optional') {
        $pid = wppa_get_the_page_id();
        $type = $wpdb->get_var($wpdb->prepare("SELECT `post_type` FROM `" . $wpdb->posts . "` WHERE `ID` = %s", $pid));
        wppa_dbg_q('Q-bc1');
        if ($type == 'post' && !wppa_switch('show_bread_posts')) {
            return;
            // Nothing to do here
        }
        if ($type != 'post' && !wppa_switch('show_bread_pages')) {
            return;
            // Nothing to do here
        }
    }
    // Check special cases
    if (wppa('is_single')) {
        return;
    }
    // A single image slideshow needs no navigation
    if (wppa_page('oneofone')) {
        return;
    }
    // Never at a single image page
    if (wppa('is_slideonly')) {
        return;
    }
    // Not when slideonly
    if (wppa_in_widget()) {
        return;
    }
    // Not in a widget
    if (is_feed()) {
        return;
    }
    // Not in a feed
    $thumbhref = '';
    // Any special selection has its own switch
    if (wppa('is_topten') && !wppa_switch('bc_on_topten')) {
        return;
    }
    if (wppa('is_lasten') && !wppa_switch('bc_on_lasten')) {
        return;
    }
    if (wppa('is_comten') && !wppa_switch('bc_on_comten')) {
        return;
    }
    if (wppa('is_featen') && !wppa_switch('bc_on_featen')) {
        return;
    }
    if (wppa('is_related') && !wppa_switch('bc_on_related')) {
        return;
    }
    if (wppa('is_tag') && !wppa_switch('bc_on_tag')) {
        return;
    }
    if (wppa('src') && !wppa_switch('bc_on_search')) {
        return;
    }
    // Get the album number
    $alb = wppa_is_int(wppa('start_album')) ? wppa('start_album') : '0';
    // A single album or all ( all = 0 here )
    $is_albenum = strlen(wppa('start_album')) > '0' && !wppa_is_int(wppa('start_album'));
    wppa_dbg_msg('alb=' . $alb . ', albenum=' . $is_albenum, 'green');
    $virtual = wppa_is_virtual() || wppa('last_albums');
    if (wppa('last_albums')) {
        $alb = wppa('last_albums_parent');
    }
    wppa_dbg_msg('alb=' . $alb . ', albenum=' . $is_albenum . ', l_a=' . wppa('last_albums') . ', l_a_p=' . wppa('last_albums_parent'), 'green');
    // See if the album is a 'stand alone' album
    $separate = wppa_is_separate($alb);
    // See if the album links to slides in stead of thumbnails
    $slide = wppa_get_album_title_linktype($alb) == 'slide' ? '&amp;wppa-slide' : '';
    // See if we link to covers or to contents
    $to_cover = wppa_opt('thumbtype') == 'none' ? '1' : '0';
    // Photo number?
    $photo = wppa('start_photo');
    wppa_dbg_msg('pid=' . $pid . ', type=' . $type . ', alb=' . $alb . ', sep=' . $separate . ', slide=' . $slide . ', t_c=0, ph=' . $photo, 'green');
    // Open the breadcrumb box
    wppa_out('<div' . ' id="wppa-bc-' . wppa('mocc') . '"' . ' class="wppa-nav wppa-box wppa-nav-text" ' . 'style="' . __wcs('wppa-nav') . __wcs('wppa-box') . __wcs('wppa-nav-text') . '" >');
    // Do we need Home?
    if (wppa_switch('show_home')) {
        $value = __(wppa_opt('home_text'));
        $href = wppa_dbg_url(get_bloginfo('url'));
        $title = get_bloginfo('title');
        wppa_bcitem($value, $href, $title, 'b1');
    }
    // Page ( grand )parents ?
    if ($type == 'page' && wppa_switch('show_page')) {
        wppa_crumb_page_ancestors($pid);
    }
    // Do the post/page
    if (wppa_switch('show_page')) {
        $value = __(stripslashes($wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->posts . "` WHERE `post_status` = 'publish' AND `ID` = %s LIMIT 0,1", $pid))));
        wppa_dbg_q('Q-bc2');
        $href = $alb || $virtual || $is_albenum ? wppa_get_permalink($pid, true) : '';
        $title = $type == 'post' ? __('Post:', 'wp-photo-album-plus') . ' ' . $value : __('Page:', 'wp-photo-album-plus') . ' ' . $value;
        wppa_bcitem($value, $href, $title, 'b3');
    }
    // The album ( grand ) parents if not separate
    //		if ( ! $separate ) {
    wppa_crumb_ancestors($alb, $to_cover);
    //		}
    // The album and optional placeholder for photo
    // Supersearch ?
    if (wppa('supersearch')) {
        $value = ' ';
        $ss_data = explode(',', wppa('supersearch'));
        switch ($ss_data['0']) {
            case 'a':
                $value .= ' ' . __('Albums', 'wp-photo-album-plus');
                switch ($ss_data['1']) {
                    case 'c':
                        $value .= ' ' . __('with category:', 'wp-photo-album-plus');
                        break;
                    case 'n':
                        $value .= ' ' . __('with name:', 'wp-photo-album-plus');
                        break;
                    case 't':
                        $value .= ' ' . __('with words:', 'wp-photo-album-plus');
                        break;
                }
                $value .= ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                break;
            case 'p':
                $value .= ' ' . __('Photos', 'wp-photo-album-plus');
                switch ($ss_data['1']) {
                    case 'g':
                        $value .= ' ' . __('with tag:', 'wp-photo-album-plus') . ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                        break;
                    case 'n':
                        $value .= ' ' . __('with name:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 't':
                        $ss_data['3'] = str_replace('...', '***', $ss_data['3']);
                        $value .= ' ' . __('with words:', 'wp-photo-album-plus') . ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                        $value = str_replace('***', '...', $value);
                        break;
                    case 'o':
                        $value .= ' ' . __('of owner:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 'i':
                        $label = $wpdb->get_var($wpdb->prepare("SELECT `description` FROM `" . WPPA_IPTC . "` WHERE `tag` = %s AND `photo` = '0'", str_replace('H', '#', $ss_data['2'])));
                        $label = trim($label, ':');
                        $value .= ' ' . __('with iptc tag:', 'wp-photo-album-plus') . ' <b>' . __($label, 'wp-photo-album-plus') . '</b> ' . __('with content:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 'e':
                        $label = $wpdb->get_var($wpdb->prepare("SELECT `description` FROM `" . WPPA_EXIF . "` WHERE `tag` = %s AND `photo` = '0'", str_replace('H', '#', $ss_data['2'])));
                        $label = trim($label, ':');
                        $value .= ' ' . __('with exif tag:', 'wp-photo-album-plus') . ' <b>' . __($label, 'wp-photo-album-plus') . '</b> ' . __('with content:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                }
                break;
        }
        if (wppa('is_slide')) {
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-supersearch=' . stripslashes(wppa('supersearch'));
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-supersearch=' . stripslashes(wppa('supersearch'));
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('src') && !wppa('is_related')) {
        $searchroot = $wppa_session['search_root'];
        if (!$searchroot) {
            $searchroot = '-2';
            // To get 'All albums'
        }
        $albtxt = wppa('is_rootsearch') ? ' <span style="cursor:pointer;" title="' . esc_attr(sprintf(__('Searchresults from album %s and its subalbums', 'wp-photo-album-plus'), wppa_display_root($searchroot))) . '">*</span> ' : '';
        if (wppa('is_slide')) {
            $value = __('Searchstring:', 'wp-photo-album-plus') . ' ' . (isset($wppa_session['display_searchstring']) ? $wppa_session['display_searchstring'] : stripslashes(wppa('searchstring'))) . $albtxt;
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-searchstring=' . stripslashes(str_replace(' ', '+', $wppa_session['use_searchstring']));
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-searchstring=' . stripslashes(str_replace(' ', '+', $wppa_session['use_searchstring']));
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Searchstring:', 'wp-photo-album-plus') . ' ' . (isset($wppa_session['display_searchstring']) ? $wppa_session['display_searchstring'] : stripslashes(wppa('searchstring'))) . $albtxt;
        $href = '';
        $title = isset($wppa_session['display_searchstring']) ? wppa_dss_to_title($wppa_session['display_searchstring']) : '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('calendar')) {
        if (wppa('is_slide')) {
            switch (wppa('calendar')) {
                case 'exifdtm':
                    $value = __('Photos by EXIF date', 'wp-photo-album-plus') . ': ' . wppa('caldate');
                    break;
                case 'timestamp':
                    $value = __('Photos by date of upload', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                    break;
                case 'modified':
                    $value = __('Photos by date last modified', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                    break;
            }
            $thumbhref = '#';
            $title = 'T8';
            wppa_bcitem($value, $thumbhref, $title, 'b8');
        }
        switch (wppa('calendar')) {
            case 'exifdtm':
                $value = __('Photos by EXIF date', 'wp-photo-album-plus') . ': ' . wppa('caldate');
                break;
            case 'timestamp':
                $value = __('Photos by date of upload', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                break;
            case 'modified':
                $value = __('Photos by date last modified', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                break;
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_upldr')) {
        $usr = get_user_by('login', wppa('is_upldr'));
        if ($usr) {
            $user = $usr->display_name;
        } else {
            $user = wppa('is_upldr');
        }
        if (wppa('is_slide')) {
            $value = sprintf(__('Photos by %s', 'wp-photo-album-plus'), $user);
            if (wppa('start_album')) {
                $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr') . '&amp;wppa-album=' . wppa('start_album');
                $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr') . '&amp;wppa-album=' . wppa('start_album');
            } else {
                $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr');
                $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr');
            }
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = sprintf(__('Photos by %s', 'wp-photo-album-plus'), $user);
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_topten')) {
        // TopTen
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Top rated photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-topten=' . wppa('topten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-topten=' . wppa('topten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Top rated photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_lasten')) {
        // Lasten
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            if (wppa_switch('lasten_use_modified')) {
                $value = __('Recently modified photos', 'wp-photo-album-plus');
            } else {
                $value = __('Recently uploaded photos', 'wp-photo-album-plus');
            }
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-lasten=' . wppa('lasten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-lasten=' . wppa('lasten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        if (wppa_switch('lasten_use_modified')) {
            $value = __('Recently modified photos', 'wp-photo-album-plus');
        } else {
            $value = __('Recently uploaded photos', 'wp-photo-album-plus');
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_comten')) {
        // Comten
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Recently commented photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-comten=' . wppa('comten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-comten=' . wppa('comten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Recently commented photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_featen')) {
        // Featen
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Featured photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-featen=' . wppa('featen_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-featen=' . wppa('featen_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Featured photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_related')) {
        // Related photos
        if (wppa('is_slide')) {
            $value = __('Related photos', 'wp-photo-album-plus');
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $href, $title, 'b8', $ajax);
        }
        $value = __('Related photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_tag')) {
        // Tagged photos
        if (wppa('is_slide')) {
            $value = __('Tagged photos:', 'wp-photo-album-plus') . '&nbsp;' . str_replace(';', ' ' . __('or', 'wp-photo-album-plus') . ' ', str_replace(',', ' ' . __('and', 'wp-photo-album-plus') . ' ', trim(wppa('is_tag'), ',;')));
            if (wppa_get_get('inv')) {
                $value .= ' (' . __('Inverted', 'wp-photo-album-plus') . ')';
            }
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            if (wppa('is_inverse')) {
                $thumbhref .= '&amp;wppa-inv=1';
                $thumbajax .= '&amp;wppa-inv=1';
            }
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Tagged photos:', 'wp-photo-album-plus') . '&nbsp;' . str_replace(';', ' ' . __('or', 'wp-photo-album-plus') . ' ', str_replace(',', ' ' . __('and', 'wp-photo-album-plus') . ' ', trim(wppa('is_tag'), ',;')));
        if (wppa_get_get('inv')) {
            $value .= ' (' . __('Inverted', 'wp-photo-album-plus') . ')';
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_cat')) {
        // Categorized albums
        if (wppa('is_slide')) {
            $value = __('Category:', 'wp-photo-album-plus') . '&nbsp;' . wppa('is_cat');
            //str_replace( ';', ' '.__( 'or' ).' ', str_replace( ',', ' '.__( 'and' ).' ', trim( wppa( 'is_tag' ), ',;' ) ) );
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-cat=' . wppa('is_cat') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-cat=' . wppa('is_cat') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Category:', 'wp-photo-album-plus') . '&nbsp;' . wppa('is_cat');
        //str_replace( ';', ' '.__( 'or' ).' ', str_replace( ',', ' '.__( 'and' ).' ', trim( wppa( 'is_tag' ), ',;' ) ) );
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('last_albums')) {
        // Recently modified albums( s )
        if (wppa('last_albums_parent')) {
            $value = wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Recently updated albums', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Recently updated albums', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } else {
        // Maybe a simple normal standard album???
        if (wppa('is_owner')) {
            $usr = get_user_by('login', wppa('is_owner'));
            if ($usr) {
                $dispname = $usr->display_name;
            } else {
                $dispname = wppa('is_owner');
            }
            // User deleted
            $various = sprintf(__('Various albums by %s', 'wp-photo-album-plus'), $dispname);
        } else {
            $various = __('Various albums', 'wp-photo-album-plus');
        }
        if (wppa('is_slide')) {
            $value = $is_albenum ? $various : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        $value = $is_albenum ? $various : wppa_get_album_name($alb);
        $href = '';
        $title = '';
        $class = 'b10';
        wppa_bcitem($value, $href, $title, $class);
    }
    // 'Go to thumbnail display' - icon
    if (wppa('is_slide') && !wppa('calendar')) {
        if (wppa_switch('bc_slide_thumblink')) {
            //				$pg = ( ( wppa_opt('thumb_page_size' ) == wppa_opt( 'slideshow_pagesize' ) ) && wppa_get_curpage() != '1' ) ? '&wppa-page='.wppa_get_curpage() : '';
            //				$thumbhref .= $pg;
            if ($virtual) {
                if ($thumbhref) {
                    $thumbhref = wppa_trim_wppa_($thumbhref);
                    $fs = wppa_opt('fontsize_nav');
                    if ($fs != '') {
                        $fs += 3;
                    } else {
                        $fs = '15';
                    }
                    // iconsize = fontsize+3, Default to 15
                    $imgs = 'height: ' . $fs . 'px; margin:0 0 -3px 0; padding:0; box-shadow:none;';
                    wppa_out('<a href="' . $thumbhref . '" title="' . __('Thumbnail view', 'wp-photo-album-plus') . '" class="wppa-nav-text" style="' . __wcs('wppa-nav-text') . 'float:right; cursor:pointer;" ' . 'onmouseover="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'none\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'\')" ' . 'onmouseout="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'none\')" >' . '<img id="wppa-tnv-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="' . $imgs . '" />' . '<img id="wppa-tnvh-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons_hover.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="display:none;' . $imgs . '" />' . '</a>');
                }
            } else {
                $s = wppa('src') ? '&wppa-searchstring=' . urlencode(wppa('searchstring')) : '';
                $onclick = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_album_url_ajax(wppa('start_album'), '0') . "&amp;wppa-photos-only=1" . $s . "', '" . wppa_convert_to_pretty(wppa_get_album_url(wppa('start_album'), '0') . '&wppa-photos-only=1' . $s) . "' )";
                $fs = wppa_opt('fontsize_nav');
                if ($fs != '') {
                    $fs += 3;
                } else {
                    $fs = '15';
                }
                // iconsize = fontsize+3, Default to 15
                $imgs = 'height: ' . $fs . 'px; margin:0 0 -3px 0; padding:0; box-shadow:none;';
                wppa_out('<a title="' . __('Thumbnail view', 'wp-photo-album-plus') . '" class="wppa-nav-text" style="' . __wcs('wppa-nav-text') . 'float:right; cursor:pointer;" ' . 'onclick="' . $onclick . '" ' . 'onmouseover="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'none\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'\')" ' . 'onmouseout="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'none\')" >' . '<img id="wppa-tnv-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="' . $imgs . '" />' . '<img id="wppa-tnvh-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons_hover.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="display:none;' . $imgs . '" />' . '</a>');
            }
        }
    }
    // Close the breadcrumb box
    wppa_out('<div style="clear:both;" ></div>');
    wppa_out('</div>');
}
Пример #29
0
function wppa_load_footer()
{
    global $wppa;
    global $wpdb;
    global $wppa_session;
    if (wppa_opt('wppa_lightbox_name') == 'wppa') {
        $fontsize_lightbox = wppa_opt('wppa_fontsize_lightbox') ? wppa_opt('wppa_fontsize_lightbox') : '10';
        $d = wppa_switch('wppa_ovl_show_counter') ? 1 : 0;
        $ovlh = wppa_opt('wppa_ovl_txt_lines') == 'auto' ? 'auto' : (wppa_opt('wppa_ovl_txt_lines') + $d) * ($fontsize_lightbox + 2);
        $txtcol = wppa_opt('wppa_ovl_theme') == 'black' ? '#a7a7a7' : '#272727';
        echo '
<!-- start WPPA+ Footer data -->
	<div id="wppa-overlay-bg" style="text-align:center; display:none; position:fixed; top:0; left:0; z-index:100090; width:100%; height:2048px; background-color:' . wppa_opt('wppa_ovl_bgcolor') . ';" onclick="wppaOvlOnclick(event)" >';
        if (wppa_switch('ovl_show_legenda') && !wppa('is_mobile')) {
            echo '
		<div id="wppa-ovl-legenda-1" onmouseover="jQuery(this).css(\'visibility\',\'visible\');" onmouseout="jQuery(this).css(\'visibility\',\'hidden\');" style="position:absolute; left:0; top:0; background-color:' . wppa_opt('wppa_ovl_theme') . ';color:' . $txtcol . '; visibility:visible;" >
			' . __a('Press f for fullscreen.') . '
		</div>';
        }
        echo '
	</div>
	<div id="wppa-overlay-ic" style="position:fixed; top:0; padding-top:10px; z-index:100095; opacity:1; box-shadow:none;" >
	</div>
	<img id="wppa-overlay-sp" alt="spinner" style="position:fixed; top:200px; left:200px; z-index:100100; opacity:1; visibility:hidden; box-shadow:none;" src="' . wppa_get_imgdir() . 'loading.gif" />
	<script type="text/javascript">jQuery("#wppa-overlay-bg").css({height:window.innerHeight});
		wppaOvlTxtHeight = "' . $ovlh . '";
		wppaOvlCloseTxt = "' . __(wppa_opt('wppa_ovl_close_txt')) . '";
		wppaOvlOpacity = ' . wppa_opt('wppa_ovl_opacity') / 100 . ';
		wppaOvlOnclickType = "' . wppa_opt('wppa_ovl_onclick') . '";
		wppaOvlTheme = "' . wppa_opt('wppa_ovl_theme') . '";
		wppaOvlAnimSpeed = ' . wppa_opt('wppa_ovl_anim') . ';
		wppaOvlSlideSpeed = ' . wppa_opt('wppa_ovl_slide') . ';
		wppaVer4WindowWidth = 800;
		wppaVer4WindowHeight = 600;
		wppaOvlShowCounter = ' . (wppa_switch('wppa_ovl_show_counter') ? 'true' : 'false') . ';
		' . (wppa_opt('wppa_fontfamily_lightbox') ? 'wppaOvlFontFamily = "' . wppa_opt('wppa_fontfamily_lightbox') . '"' : '') . '
		wppaOvlFontSize = "' . $fontsize_lightbox . '";
		' . (wppa_opt('wppa_fontcolor_lightbox') ? 'wppaOvlFontColor = "' . wppa_opt('wppa_fontcolor_lightbox') . '"' : '') . '
		' . (wppa_opt('wppa_fontweight_lightbox') ? 'wppaOvlFontWeight = "' . wppa_opt('wppa_fontweight_lightbox') . '"' : '') . '
		' . (wppa_opt('wppa_fontsize_lightbox') ? 'wppaOvlLineHeight = "' . (wppa_opt('wppa_fontsize_lightbox') + '2') . '"' : '') . '
		wppaOvlFullLegenda = "' . __a('Keys: f = next mode; escape = exit; p = previous, n = next, s = start/stop, d = dismiss this notice.') . '";
		wppaOvlFullLegendaSingle = "' . __a('Keys: f = next mode; escape = exit; d = dismiss this notice.') . '";
		wppaOvlVideoStart = ' . (wppa_switch('ovl_video_start') ? 'true' : 'false') . ';
		wppaOvlAudioStart = ' . (wppa_switch('ovl_audio_start') ? 'true' : 'false') . ';
		wppaOvlShowLegenda = ' . (wppa_switch('ovl_show_legenda') && !wppa('is_mobile') ? 'true' : 'false') . ';
		wppaOvlShowStartStop = ' . (wppa_switch('ovl_show_startstop') ? 'true' : 'false') . ';
	</script>
	';
        wp_nonce_field('wppa-check', 'wppa-nonce', false, true);
        // Nonce field for Ajax bump view counter from lightbox
        echo '
	<script type="text/javascript">';
        if (isset($wppa_session['photo'])) {
            foreach (array_keys($wppa_session['photo']) as $p) {
                echo '
				wppaPhotoView[' . $p . '] = true;';
            }
        }
        echo '
	</script>
<!-- end WPPA+ Footer data -->
';
    }
    wppa_dbg_q('print');
    if ($wppa['debug']) {
        $plugins = get_option('active_plugins');
        wppa_dbg_msg('Active Plugins');
        foreach ($plugins as $plugin) {
            wppa_dbg_msg($plugin);
        }
        wppa_dbg_msg('End Active Plugins');
    }
    echo '
<!-- Do user upload -->';
    wppa_user_upload();
    // Do the upload if required and not yet done
    echo '
<!-- Done user upload -->';
}
function wppa_get_lbtitle($type, $id)
{
    if (!is_numeric($id) || $id < '1') {
        wppa_dbg_msg('Invalid arg wppa_get_lbtitle( ' . $id . ' )', 'red');
    }
    $thumb = wppa_cache_thumb($id);
    $do_download = wppa_is_video($id) ? false : wppa_switch('art_monkey_on_lightbox');
    $do_name = wppa_switch('ovl_' . $type . '_name') || wppa_switch('ovl_add_owner');
    $do_desc = wppa_switch('ovl_' . $type . '_desc');
    $do_sm = wppa_switch('share_on_lightbox');
    $result = '';
    if ($do_download) {
        if (wppa_opt('art_monkey_display') == 'button') {
            $result .= '<input' . ' type="button"' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer; margin-bottom:0px; max-width:500px;"' . ' class="wppa-download-button"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', ' . $id . ' );"' . ' value="' . __('Download:', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')) . '"' . ' />';
        } else {
            $result .= '<a' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer;"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', ' . $id . ' );"' . ' >' . __('Download:', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')) . '</a>';
        }
    } else {
        if ($do_name) {
            $result .= wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'));
        }
    }
    if ($do_name && $do_desc) {
        $result .= '<br />';
    }
    if ($do_desc) {
        $result .= wppa_get_photo_desc($thumb['id']);
    }
    if (($do_name || $do_desc) && $do_sm) {
        $result .= '<br />';
    }
    if ($do_sm) {
        $result .= wppa_get_share_html($thumb['id'], 'lightbox');
    }
    $result = esc_attr($result);
    return $result;
}