function wppa_album_select_a($args) { global $wpdb; $args = wp_parse_args($args, array('exclude' => '', 'selected' => '', 'disabled' => '', 'addpleaseselect' => false, 'addnone' => false, 'addall' => false, 'addgeneric' => false, 'addblank' => false, 'addselected' => false, 'addseparate' => false, 'addselbox' => false, 'disableancestors' => false, 'checkaccess' => false, 'checkowner' => false, 'checkupload' => false, 'addmultiple' => false, 'addnumbers' => false, 'path' => false, 'root' => false, 'content' => false, 'sort' => true)); // Provide default selection if no selected given if ($args['selected'] === '') { $args['selected'] = wppa_get_last_album(); } // See if selection is valid if ($args['selected'] == $args['exclude'] || $args['checkupload'] && !wppa_allow_uploads($args['selected']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $args['selected'])) { $args['selected'] = '0'; } $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` " . wppa_get_album_order($args['root']), ARRAY_A); // Add to secondary cache if ($albums) { wppa_cache_album('add', $albums); } if ($albums) { // Filter for root if ($args['root']) { $root = $args['root']; switch ($root) { // case '0': all, will be skipped as it returns false in 'if ( $args['root'] )' case '-2': // Generic only foreach (array_keys($albums) as $albidx) { if (wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; case '-1': // Separate only foreach (array_keys($albums) as $albidx) { if (!wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; default: foreach (array_keys($albums) as $albidx) { if (!wppa_is_ancestor($root, $albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; } } // Filter for must have content if ($args['content']) { foreach (array_keys($albums) as $albidx) { if (wppa_get_photo_count($albums[$albidx]['id']) <= wppa_get_mincount()) { unset($albums[$albidx]); } } } // Add paths if ($args['path']) { $albums = wppa_add_paths($albums); } else { foreach (array_keys($albums) as $index) { $albums[$index]['name'] = __(stripslashes($albums[$index]['name'])); } } // Sort if ($args['sort']) { $albums = wppa_array_sort($albums, 'name'); } } // Output $result = ''; $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addpleaseselect']) { $result .= '<option value="0" disabled="disabled" ' . $selected . ' >' . (is_admin() ? __('- select an album -', 'wppa') : __a('- select an album -')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addnone']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- none ---', 'wppa') : __a('--- none ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- all ---', 'wppa') : __a('--- all ---')) . '</option>'; } $selected = $args['selected'] == '-2' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="-2"' . $selected . ' >' . (is_admin() ? __('--- generic ---', 'wppa') : __a('--- generic ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addblank']) { $result .= '<option value="0"' . $selected . ' >' . '</option>'; } $selected = $args['selected'] == '-99' ? ' selected="selected"' : ''; if ($args['addmultiple']) { $result .= '<option value="-99"' . $selected . ' >' . (is_admin() ? __('--- multiple see below ---', 'wppa') : __a('--- multiple see below ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addselbox']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- a selection box ---', 'wppa') : __a('--- a selection box ---')) . '</option>'; } if ($albums) { foreach ($albums as $album) { if ($args['disabled'] == $album['id'] || $args['exclude'] == $album['id'] || $args['checkupload'] && !wppa_allow_uploads($album['id']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $album['id'])) { $disabled = ' disabled="disabled"'; } else { $disabled = ''; } if ($args['selected'] == $album['id'] && !$disabled) { $selected = ' selected="selected"'; } else { $selected = ''; } $ok = true; // Assume this will be in the list if ($args['checkaccess'] && !wppa_have_access($album['id'])) { $ok = false; } if ($args['checkowner'] && wppa_switch('upload_owner_only')) { // Need to check if ($album['owner'] != wppa_get_user() && $album['owner'] != '--- public ---') { // Not 'mine' if (!wppa_user_is('administrator')) { // No admin $ok = false; } } } if ($selected && $args['addselected']) { $ok = true; } if ($ok) { if ($args['addnumbers']) { $number = ' ( ' . $album['id'] . ' )'; } else { $number = ''; } $result .= '<option value="' . $album['id'] . '" ' . $selected . $disabled . '>' . $album['name'] . $number . '</option>'; } } } $selected = $args['selected'] == '-1' ? ' selected="selected"' : ''; if ($args['addseparate']) { $result .= '<option value="-1"' . $selected . '>' . (is_admin() ? __('--- separate ---', 'wppa') : __a('--- separate ---')) . '</option>'; } return $result; }
function wppa_is_wanted_empty($thumbs) { if (!wppa_switch('show_empty_thumblist')) { return false; } // Feature not enabled if (is_array($thumbs) && count($thumbs) > wppa_get_mincount()) { return false; } // Album is not empty if (wppa_is_virtual()) { return false; } // wanted empty only on real albums if (wppa('albums_only')) { return false; } // Explicitly no thumbs // if ( wppa_switch( 'thumbs_first' ) && wppa_get_curpage() != '1' ) return false; // Only on page 1 if thumbs first wppa('current_album', wppa('start_album')); // Make sure upload knows the album return true; }
function wppa_get_npages($type, $array) { $aps = wppa_get_pagesize('albums'); $tps = wppa_get_pagesize('thumbs'); $arraycount = is_array($array) ? count($array) : '0'; $result = '0'; if ($type == 'albums') { if ($aps != '0') { $result = ceil($arraycount / $aps); } elseif ($tps != '0') { if ($arraycount) { $result = '1'; } else { $result = '0'; } } } elseif ($type == 'thumbs') { if (wppa('is_cover') == '1') { // Cover has no thumbs: 0 pages $result = '0'; } elseif ($arraycount <= wppa_get_mincount()) { $result = '0'; } elseif ($tps != '0') { $result = ceil($arraycount / $tps); // Pag on: compute } else { $result = '1'; // Pag off: all fits on 1 } } return $result; }
function wppa_album_select_a($args) { global $wpdb; $args = wp_parse_args($args, array('exclude' => '', 'selected' => '', 'disabled' => '', 'addpleaseselect' => false, 'addnone' => false, 'addall' => false, 'addgeneric' => false, 'addblank' => false, 'addselected' => false, 'addseparate' => false, 'addselbox' => false, 'addowner' => false, 'disableancestors' => false, 'checkaccess' => false, 'checkowner' => false, 'checkupload' => false, 'addmultiple' => false, 'addnumbers' => false, 'path' => false, 'root' => false, 'content' => false, 'sort' => true, 'checkarray' => false, 'array' => array(), 'optionclass' => '')); // Provide default selection if no selected given if ($args['selected'] === '') { $args['selected'] = wppa_get_last_album(); } // See if selection is valid if ($args['selected'] == $args['exclude'] || $args['checkupload'] && !wppa_allow_uploads($args['selected']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $args['selected'])) { $args['selected'] = '0'; } // Get roughly the albums that might be in the selection if ($args['checkarray'] && !empty($args['array'])) { $albums = $wpdb->get_results("SELECT `id`, `name` " . "FROM `" . WPPA_ALBUMS . "` " . "WHERE `id` IN (" . implode(',', $args['array']) . ") " . ($args['checkowner'] && wppa_switch('upload_owner_only') && !wppa_user_is('administrator') ? "AND `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "") . wppa_get_album_order($args['root']), ARRAY_A); } else { $albums = $wpdb->get_results("SELECT `id`, `name` " . "FROM `" . WPPA_ALBUMS . "` " . ($args['checkowner'] && wppa_switch('upload_owner_only') && !wppa_user_is('administrator') ? "WHERE `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "") . wppa_get_album_order($args['root']), ARRAY_A); } /* Can not add to cache because only "SELECT * " can be added // Add to secondary cache if ( $albums ) { wppa_cache_album( 'add', $albums ); } */ if ($albums) { // Filter for root if ($args['root']) { $root = $args['root']; switch ($root) { // case '0': all, will be skipped as it returns false in 'if ( $args['root'] )' case '-2': // Generic only foreach (array_keys($albums) as $albidx) { if (wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; case '-1': // Separate only foreach (array_keys($albums) as $albidx) { if (!wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; default: foreach (array_keys($albums) as $albidx) { if (!wppa_is_ancestor($root, $albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; } } // Filter for must have content if ($args['content']) { foreach (array_keys($albums) as $albidx) { if (wppa_get_photo_count($albums[$albidx]['id']) <= wppa_get_mincount()) { unset($albums[$albidx]); } } } // Add paths if ($args['path']) { $albums = wppa_add_paths($albums); } else { foreach (array_keys($albums) as $index) { $albums[$index]['name'] = __(stripslashes($albums[$index]['name'])); } } // Sort if ($args['sort']) { $albums = wppa_array_sort($albums, 'name'); } } // Output $result = ''; $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addpleaseselect']) { $result .= '<option value="0" disabled="disabled" ' . $selected . ' >' . __('- select an album -', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addnone']) { $result .= '<option value="0"' . $selected . ' >' . __('--- none ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="0"' . $selected . ' >' . __('--- all ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '-2' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="-2"' . $selected . ' >' . __('--- generic ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '-3' ? ' selected="selected"' : ''; if ($args['addowner']) { $result .= '<option value="-3"' . $selected . ' >' . __('--- owner/public ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addblank']) { $result .= '<option value="0"' . $selected . ' >' . '</option>'; } $selected = $args['selected'] == '-99' ? ' selected="selected"' : ''; if ($args['addmultiple']) { $result .= '<option value="-99"' . $selected . ' >' . __('--- multiple see below ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addselbox']) { $result .= '<option value="0"' . $selected . ' >' . __('--- a selection box ---', 'wp-photo-album-plus') . '</option>'; } // In case multiple if (strpos($args['selected'], ',') !== false) { $selarr = explode(',', $args['selected']); } else { $selarr = array($args['selected']); } if ($albums) { foreach ($albums as $album) { if ($args['disabled'] == $album['id'] || $args['exclude'] == $album['id'] || $args['checkupload'] && !wppa_allow_uploads($album['id']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $album['id'])) { $disabled = ' disabled="disabled"'; } else { $disabled = ''; } if (in_array($album['id'], $selarr, true) && !$disabled) { $selected = ' selected="selected"'; } else { $selected = ''; } $ok = true; // Assume this will be in the list if ($args['checkaccess'] && !wppa_have_access($album['id'])) { $ok = false; } /* This is in the query now if ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) ) { // Need to check if ( $album['owner'] != wppa_get_user() && $album['owner'] != '--- public ---' ) { // Not 'mine' if ( ! wppa_user_is( 'administrator' ) ) { // No admin $ok = false; } } } */ /* This is in the query now if ( $args['checkarray'] ) { if ( ! in_array( $album['id'], $args['array'] ) ) { $ok = false; } } */ if ($selected && $args['addselected']) { $ok = true; } if ($ok) { if ($args['addnumbers']) { $number = ' ( ' . $album['id'] . ' )'; } else { $number = ''; } $result .= '<option class="' . $args['optionclass'] . '" value="' . $album['id'] . '" ' . $selected . $disabled . '>' . $album['name'] . $number . '</option>'; } } } $selected = $args['selected'] == '-1' ? ' selected="selected"' : ''; if ($args['addseparate']) { $result .= '<option value="-1"' . $selected . '>' . __('--- separate ---', 'wp-photo-album-plus') . '</option>'; } return $result; }
function wppa_the_slideshow_browse_link($photocount, $href_slideshow, $onclick_slideshow, $target) { if (wppa_switch('show_slideshowbrowselink')) { wppa_out('<div class="wppa-box-text wppa-black wppa-info wppa-slideshow-browse-link">'); if ($photocount > wppa_get_mincount()) { $label = wppa_switch('enable_slideshow') ? __('Slideshow', 'wp-photo-album-plus') : __('Browse photos', 'wp-photo-album-plus'); if ($href_slideshow == '#') { wppa_out('<a onclick="' . $onclick_slideshow . '" title="' . $label . '" style="cursor:pointer;' . __wcs('wppa-box-text-nocolor') . '" >' . $label . '</a>'); } else { wppa_out('<a href="' . $href_slideshow . '" target="' . $target . '" onclick="' . $onclick_slideshow . '" title="' . $label . '" style="cursor:pointer;' . __wcs('wppa-box-text-nocolor') . '" >' . $label . '</a>'); } } else { wppa_out(' '); } wppa_out('</div>'); } }
function wppa_theme() { global $wppa_version; $wppa_version = '4-0-0'; // The version number of this file, please change if you modify this file global $wppa; global $wppa_opt; 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'; // " wppa_container('open'); // Open container if ($wppa_show_statistics) { wppa_statistics(); } // Show statistics if set so by the page template wppa_breadcrumb('optional'); // Display breadcrumb navigation only if it is set in the settings page if (wppa_page('albums')) { // Page 'Albums' requested $albums = wppa_get_albums(); // Get the albums if ($albums) { $counter_albums = '0'; $n_album_pages = wppa_get_npages('albums', $albums); wppa_album_list('open'); // Open Albums sub-container foreach ($albums as $ta) { global $album; $album = $ta; // Loop the albums $counter_albums++; if (wppa_onpage('albums', $counter_albums, $curpage)) { $didsome = true; wppa_album_cover(); // Show the cover } // End if on page } wppa_album_list('close'); // Close Albums sub-container } // If albums if ($wppa_opt['wppa_thumbtype'] != 'none') { $thumbs = wppa_get_thumbs(); // Get the Thumbs } else { $thumbs = false; } $n_thumb_pages = wppa_get_npages('thumbs', $thumbs); // How many pages of thumbs will there be? if ($n_thumb_pages == '0') { $thumbs = false; } // No pages: no thumbs. Maybe want covers only if ($didsome && wppa_is_pagination()) { $thumbs = false; } // Pag on and didsome: pagebreak if (count($thumbs) <= wppa_get_mincount()) { $thumbs = false; } // Less than treshold value if ($thumbs) { $counter_thumbs = '0'; if (get_option('wppa_thumbtype', 'default') == 'ascovers') { // Do the thumbs As covers wppa_thumb_list('open'); // Open Thumblist sub-container foreach ($thumbs as $tt) { global $thumb; $thumb = $tt; // Loop the Thumbs $counter_thumbs++; if (wppa_onpage('thumbs', $counter_thumbs, $curpage - $n_album_pages)) { $didsome = true; wppa_thumb_ascover(); // Show Thumb as cover } // End if on page } wppa_thumb_list('close'); // Close Thumblist sub-container } else { // Do the thumbs As default wppa_thumb_area('open'); // Open Thumbarea sub-container foreach ($thumbs as $tt) { global $thumb; $thumb = $tt; // Loop the Thumbs $counter_thumbs++; if (wppa_onpage('thumbs', $counter_thumbs, $curpage - $n_album_pages)) { $didsome = true; wppa_thumb_default(); // Show Thumb as default } // End if on page } wppa_popup(); // Prepare Popup box wppa_thumb_area('close'); // Close Thumbarea sub-container } // As default } // If thumbs if (!wppa_is_pagination()) { $totpag = '1'; } else { $totpag = $n_album_pages + $n_thumb_pages; } wppa_page_links($totpag, $curpage); // Show pages navigaion bar if needed if (!$didsome && $wppa['src']) { $wppa['out'] .= '<div class="center">' . __a('No albums or photos found matching your search criteria.', 'wppa_theme') . '</div>'; } } elseif (wppa_page('oneofone')) { // Page 'Single image' requested wppa_slide_frame(); // Setup slideframe wppa_run_slidecontainer('single'); // Fill in the photo and display it } elseif (wppa_page('slide') || wppa_page('single')) { // Page 'Slideshow' or 'Single' in browsemode requested wppa_the_slideshow(); // Producs all the html required for the slideshow wppa_run_slidecontainer('slideshow'); // Fill in the photo array and display it. } // wppa_page('slide') wppa_container('close'); }
function wppa_the_slideshow_browse_link($photocount, $href_slideshow, $onclick_slideshow, $target) { global $wppa; if (wppa_switch('wppa_show_slideshowbrowselink')) { $wppa['out'] .= wppa_nltab('+') . '<div class="wppa-box-text wppa-black wppa-info wppa-slideshow-browse-link">'; if ($photocount > wppa_get_mincount()) { $label = wppa_switch('wppa_enable_slideshow') ? __a('Slideshow') : __a('Browse photos'); if ($href_slideshow == '#') { $wppa['out'] .= wppa_nltab() . '<a onclick="' . $onclick_slideshow . '" title="' . $label . '" style="' . __wcs('wppa-box-text-nocolor') . '" >' . $label . '</a>'; } else { $wppa['out'] .= wppa_nltab() . '<a href="' . $href_slideshow . '" target="' . $target . '" onclick="' . $onclick_slideshow . '" title="' . $label . '" style="' . __wcs('wppa-box-text-nocolor') . '" >' . $label . '</a>'; } } else { $wppa['out'] .= ' '; } $wppa['out'] .= wppa_nltab('-') . '</div>'; } }