コード例 #1
0
ファイル: album_cat.php プロジェクト: GabrielAnca/icy_phoenix
$meta_content['page_title'] = $thiscat['cat_title'];
$meta_content['description'] = $lang['Album'] . ' - ' . $thiscat['cat_title'] . ' - ' . $cat_desc;
$meta_content['keywords'] = $lang['Album'] . ', ' . $thiscat['cat_title'] . ', ' . $cat_desc . ', ';
if ($album_user_id == ALBUM_PUBLIC_GALLERY) {
    if (empty($moderators_list)) {
        $moderators_list = $lang['None'];
    }
    album_read_tree($album_user_id);
    $album_nav_cat_desc = album_make_nav_tree($cat_id, 'album_cat.' . PHP_EXT, 'nav', $album_user_id);
    if ($album_nav_cat_desc != '') {
        $nav_server_url = create_server_url();
        $album_nav_cat_desc = ALBUM_NAV_ARROW . $album_nav_cat_desc;
        $breadcrumbs['address'] = ALBUM_NAV_ARROW . '<a href="' . $nav_server_url . append_sid('album.' . PHP_EXT) . '">' . $lang['Album'] . '</a>' . $album_nav_cat_desc;
    }
    if ($album_config['show_slideshow'] && $total_pics > 0) {
        $first_pic_id = album_get_first_pic_id($cat_id);
        $slideshow_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $first_pic_id . '&amp;slideshow=5'));
        $slideshow_link_full = '[<a href="' . $slideshow_link . '">' . $lang['Slideshow'] . '</a>]';
        $breadcrumbs['bottom_right_links'] = $slideshow_link_full;
    } else {
        $slideshow_link_full = '';
    }
    $template_to_parse = 'album_cat_body.tpl';
    if ($total_pics > 0) {
        album_build_picture_table($album_user_id, $cat_id, $thiscat, $auth_data, $start, $sort_method, $sort_order, $total_pics);
        // Last Comments
        if ($album_config['show_last_comments'] == 1) {
            album_build_last_comments_info($allowed_cat);
        }
        // Recent Public Pics
        if ($album_config['show_recent_in_subcats'] == 1) {
コード例 #2
0
function album_build_index($user_id, &$keys, $cur_cat_id = ALBUM_ROOT_CATEGORY, $real_level = ALBUM_ROOT_CATEGORY, $max_level = ALBUM_ROOT_CATEGORY, $newestpic = NULL)
{
    global $template, $db, $config, $album_config, $lang, $images, $user, $album_data;
    // init some variables
    $display = false;
    $moderators = '';
    $last_pic_info = '';
    $cat_total_comments = 0;
    $album_show_pic_url = 'album_showpage.' . PHP_EXT;
    // display the level
    $AH_this = isset($album_data['keys'][$cur_cat_id]) ? $album_data['keys'][$cur_cat_id] : ALBUM_ROOT_CATEGORY;
    // root level head
    if ($real_level == ALBUM_ROOT_CATEGORY || !is_array($keys)) {
        // get max inc level
        $keys = array();
        $keys = album_get_auth_keys($cur_cat_id, ALBUM_AUTH_VIEW);
        //, true, -1, -1);
        $max_level = album_get_max_depth($keys, ALBUM_AUTH_VIEW, $cur_cat_id);
        //, false);
        $newestpic = album_no_newest_pictures($album_config['new_pic_check_interval'], $album_data['id']);
    }
    // get the level
    $level = $keys['level'][$keys['keys'][$cur_cat_id]];
    // if 'top level category, then write the link to it
    if ($level == ALBUM_ROOT_CATEGORY + 1) {
        $links = '';
        $newpics_sub_link = '';
        $total_pics = 0;
        $first_pic_id = 0;
        $last_pic_id = 0;
        $sub_total_pics = 0;
        $total_comments = 0;
        // display a cat row
        $cat = $album_data['data'][$AH_this];
        $cat_id = $cat['cat_id'];
        // sub categories for current category
        $cats = array();
        // specific to the data type
        $title = album_get_object_lang($cur_cat_id, 'name');
        $desc = album_get_object_lang($cur_cat_id, 'desc');
        // get all the cat id for current cat and it's subs, $cats will hold all the ids
        album_get_sub_cat_ids($cat_id, $cats, ALBUM_AUTH_VIEW, ALBUM_INCLUDE_PARENT_ID);
        // we got the cat_id, we now need to get the value for the next sub category for this category
        for ($j = 0; $j < sizeof($album_data['sub'][$cur_cat_id]); $j++) {
            $link = '';
            // get the 'cur' for the current sub category
            $subcur = $album_data['sub'][$cur_cat_id][$j];
            // get the keys for current iterated sub level
            $subthis = $album_data['keys'][$subcur];
            if ($album_data['auth'][$subcur]['view'] == 0) {
                continue;
            }
            // get the row data for current iterated sub level
            $subdata = $album_data['data'][$subthis];
            // get the name of the category
            $subname = album_get_object_lang($subcur, 'name');
            // get the description of the category
            $subdesc = album_get_object_lang($subcur, 'desc');
            $subpgm = append_sid(album_append_uid('album_cat.' . PHP_EXT . '?cat_id=' . $album_data['id'][$subthis]));
            // the number of picture for the sub category (only one level down)
            $sub_cats = array();
            // get the all the sub category ids for this sub category
            album_get_sub_cat_ids($subcur, $sub_cats, ALBUM_AUTH_VIEW, ALBUM_INCLUDE_PARENT_ID);
            // get the number of pictures in current sub category and its sub categories
            $sub_total_pics = album_get_total_pics($sub_cats);
            $new_images_flag = false;
            for ($i = 0; $i < sizeof($sub_cats); $i++) {
                $total_new = $total_new + $newestpic[$sub_cats[$i]];
                if ($new_images_flag == false && $total_new > 0) {
                    $new_images_flag = true;
                }
            }
            // are they any pictures in the current category ?
            // then display it after the category name (only sub)
            switch (intval($sub_total_pics)) {
                case 0:
                    $sub_total_pics = sprintf($lang['Multiple_Sub_Total_Pics'], $sub_total_pics);
                    break;
                case 1:
                    $sub_total_pics = sprintf($lang['One_Sub_Total_Pics'], $sub_total_pics);
                    break;
                default:
                    $sub_total_pics = sprintf($lang['Multiple_Sub_Total_Pics'], $sub_total_pics);
            }
            if ($subname != '') {
                $total = 0;
                // calculate for all the subcats in this branch
                for ($i = 0; $i < sizeof($sub_cats); $i++) {
                    $total = $total + $newestpic[$sub_cats[$i]];
                }
                //$last_pic_id = album_get_last_pic_id($album_data['sub'][$cur_cat_id][$j]);
                $new_images_class = $total > 0 ? '-new' : '';
                $xs_new = $total > 0 ? '-new' : '';
                $slideshow_img_xs = $xs_new ? $images['icon_minipost_new'] : $images['icon_minipost'];
                $link_spacer = '<img src="' . $images['spacer'] . '" width="1" height="0" />';
                $subfolder_img = '<img src="' . $slideshow_img_xs . '" style="vertical-align: middle;" title="' . $sub_total_pics . '" alt="' . $sub_total_pics . '"/>';
                $sub_cat_separator = $i != count($sub_cats) ? ',' : '';
                //$slideshow_link = append_sid(album_append_uid("album_showpage." . PHP_EXT . "?pic_id=" . $last_pic_id . "&amp;slideshow=5"));
                $link = $link_spacer . $subfolder_img . '&nbsp;<a href="' . $subpgm . '" title="' . $subdesc . '" class="forumlink2' . $new_images_class . '"><b>' . $subname . '</b></a><b>' . $sub_cat_separator . '</b>&nbsp;';
            }
            if ($link != '') {
                $total = 0;
                // calculate for all the subcats in this branch
                for ($i = 0; $i < sizeof($sub_cats); $i++) {
                    $total = $total + $newestpic[$sub_cats[$i]];
                }
                // Mighty Gorgon - Slideshow - BEGIN
                $ss_cat_id = $album_data['sub'][$cur_cat_id][$j];
                if (album_get_total_pic_cat($ss_cat_id) > 0 && $album_config['show_slideshow']) {
                    //$xs_new = ($total > 0)  ? '-new' : '';
                    $first_pic_id = album_get_first_pic_id($cur_cat_id);
                    $last_pic_id = album_get_last_pic_id($ss_cat_id);
                    $slideshow_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $last_pic_id . '&amp;slideshow=5'));
                    $slideshow_link_full = '[<a href="' . $slideshow_link . '">' . $lang['Slideshow'] . '</a>]';
                    //$slideshow_link_full = '<a href="' . $slideshow_link . '">' . $lang['Slideshow'] . '&nbsp;' . $slideshow_img . '</a>';
                } else {
                    $slideshow_link_full = '';
                }
                // Mighty Gorgon - Slideshow - END
                if ($total > 0) {
                    $new_text = $total == 1 ? sprintf($lang['One_new_picture'], $total) : sprintf($lang['Multiple_new_pictures'], $total);
                    $newpics_sub_link = '&nbsp;<img src="' . $images['mini_new_pictures'] . '" alt="' . $new_text . '" title="' . $new_text . '">&nbsp;';
                    $link = $link . $slideshow_link_full;
                }
                if ($album_config['line_break_subcats'] == 1) {
                    $links .= $links != '' ? $link . '<br />&nbsp;' : '<br />&nbsp;' . $link . '<br />&nbsp;';
                } else {
                    $links .= $links != '' ? ', ' . $link : $link;
                }
            }
        }
        // for ....
        // is there a moderator group for this category ?
        if ($cat['cat_moderator_groups'] != '') {
            // if we got some moderators AND some sub categories,
            // then make sure the sub categories are on a new line
            if (!empty($links) && ($moderators = album_get_moderator_info($cat)) != '') {
                $moderators .= '<br />';
            }
        }
        $cat_desc = album_get_object_lang($cur_cat_id, 'desc');
        if (!empty($cat_desc) && !empty($links)) {
            $cat_desc .= '<br />';
        }
        // Mighty Gorgon - Slideshow - BEGIN
        $new_images = intval($newestpic[$cur_cat_id]) != 0 || $new_images_flag ? true : false;
        $xs_new = intval($newestpic[$cur_cat_id]) != 0 || $new_images_flag ? '-new' : '';
        if (album_get_total_pic_cat($cur_cat_id) > 0 && $album_config['show_slideshow']) {
            $first_pic_id = album_get_first_pic_id($cur_cat_id);
            $slideshow_img_xs = $xs_new ? $images['icon_newest_reply'] : $images['icon_latest_reply'];
            $slideshow_img = '<img src="' . $slideshow_img_xs . '" alt="' . $lang['Slideshow'] . '" title="' . $lang['Slideshow'] . '" />';
            $slideshow_link = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $first_pic_id . '&amp;slideshow=5'));
            $slideshow_link_full = '&nbsp;[<a href="' . $slideshow_link . '">' . $lang['Slideshow'] . '</a>]&nbsp;';
        } else {
            $slideshow_link_full = '';
        }
        // Mighty Gorgon - Slideshow - END
        if ($xs_new) {
            $cat_img = intval(sizeof($sub_cats)) > 0 ? $images['forum_sub_unread'] : ($cat_img = $images['forum_nor_unread']);
        } else {
            $cat_img = intval(sizeof($sub_cats)) > 0 ? $images['forum_sub_read'] : ($cat_img = $images['forum_nor_read']);
        }
        if ($config['url_rw'] == '1' || $config['url_rw_guests'] == '1' && $user->data['user_id'] == ANONYMOUS) {
            $cat_url = append_sid(str_replace('--', '-', make_url_friendly(album_get_object_lang($cur_cat_id, 'name')) . '-ac' . $cat_id . '.html'));
        } else {
            $cat_url = append_sid(album_append_uid('album_cat.' . PHP_EXT . '?cat_id=' . $cat_id));
        }
        // send all the data to the template, except for the sub categories links
        $template->assign_block_vars('catmain', array());
        $template->assign_block_vars('catmain.catrow', array('CAT_TITLE' => album_get_object_lang($cur_cat_id, 'name'), 'CAT_IMG' => $cat_img, 'SLIDESHOW' => $slideshow_link_full, 'CAT_DESC' => $cat_desc, 'XS_NEW' => $xs_new, 'U_VIEWCAT' => $cat_url, 'L_MODERATORS' => empty($moderators) ? '' : $lang['Moderators'] . ' :', 'MODERATORS' => $moderators));
        if (intval($newestpic[$cur_cat_id]) != 0) {
            $new_text = $newestpic[$cur_cat_id] > 1 ? sprintf($lang['Multiple_new_pictures'], $newestpic[$cur_cat_id]) : sprintf($lang['One_new_picture'], $newestpic[$cur_cat_id]);
            $xs_new = intval($newestpic[$cur_cat_id]) != 0 ? '-new' : '';
            $template->assign_block_vars('catmain.catrow.newpics', array('I_NEWEST_PICS' => $images['mini_new_pictures'], 'L_NEWEST_PICS' => $new_text));
        }
        if ($album_config['show_index_total_pics'] == 1) {
            // get the total amount of pictures for current category and its sub categories
            $template->assign_block_vars('catmain.catrow.total_pics', array('TOTAL_PICS' => album_get_total_pics($cats)));
        }
        if ($album_config['show_index_total_comments'] == 1) {
            // the total number of comments for current category and its sub categories
            $template->assign_block_vars('catmain.catrow.total_comments', array('TOTAL_COMMENTS' => album_get_comment_count($cats)));
        }
        if ($album_config['show_index_pics'] == 1) {
            $template->assign_block_vars('catmain.catrow.pics', array('PICS' => $cat['count']));
        }
        if ($album_config['show_index_comments'] == 1) {
            $cat_total_comments = album_get_comment_count($cat_id);
            $template->assign_block_vars('catmain.catrow.comments', array('COMMENTS' => empty($cat_total_comments) ? 0 : $cat_total_comments));
        }
        if ($album_config['show_index_last_comment'] == 1) {
            $last_comment_info = album_get_last_comment_info($cats);
            $template->assign_block_vars('catmain.catrow.last_comment', array('LAST_COMMENT_INFO' => empty($last_comment_info) ? $lang['No_Comment_Info'] : $last_comment_info));
        }
        if ($album_config['show_index_last_pic'] == 1) {
            // get the last picture information and the last comment information
            $last_pic_info = album_get_last_pic_info($cats, $last_pic_id);
            $template->assign_block_vars('catmain.catrow.last_pic', array('LAST_PIC_INFO' => empty($last_pic_info) ? $lang['No_Pics'] : $last_pic_info));
        }
        if ($album_config['show_index_thumb'] == 1) {
            // add the index thumbnail picture to the template
            if ($last_pic_id == 0 || $album_config['show_index_last_pic'] == 0) {
                album_get_last_pic_info($cats, $last_pic_id);
            }
            if ($album_config['fullpic_popup'] == 0) {
                $pic_url_sid = append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $last_pic_id));
                $pic_target = '_self';
            } else {
                $pic_url_sid = append_sid(album_append_uid('album_pic.' . PHP_EXT . '?pic_id=' . $last_pic_id));
                $pic_target = '_blank';
            }
            $pic_thumb_sid = append_sid(album_append_uid('album_thumbnail.' . PHP_EXT . '?pic_id=' . $last_pic_id));
            if ($album_config['show_img_no_gd'] == 1) {
                //$thumb_size = 'width="' . $album_config['thumbnail_size'] . '" height="' . $album_config['thumbnail_size'] . '"';
                $thumb_size = 'width="' . $album_config['thumbnail_size'] . '"';
            } else {
                $thumb_size = '';
            }
            if ($last_pic_id == 0) {
                $pic_url = '';
            } else {
                $pic_url = '<a href="' . $pic_url_sid . '" target="' . $pic_target . '"><img src="' . $pic_thumb_sid . '" ' . $thumb_size . ' alt="' . $lang['Last_Index_Thumbnail'] . '" title="' . $lang['Last_Index_Thumbnail'] . '" /></a>';
            }
            $template->assign_block_vars('catmain.catrow.thumb', array('LAST_PIC_URL' => $pic_url));
        }
        // add the sub category links row to the template
        if (!empty($links)) {
            if ($user_id == ALBUM_PUBLIC_GALLERY && $album_config['show_index_subcats'] == 1 || $user_id != ALBUM_PUBLIC_GALLERY && $album_config['personal_show_subcats_in_index'] == 1) {
                $template->assign_block_vars('catmain.catrow.subcat_link', array('L_LINKS' => $lang['Album_sub_categories'], 'LINKS' => $links));
            }
        }
        // something displayed, yeah baby
        $display = true;
    }
    // if ($level == 0)...
    // display sub-levels
    for ($i = 0; $i < sizeof($album_data['sub'][$cur_cat_id]); $i++) {
        if (!empty($keys['keys'][$album_data['sub'][$cur_cat_id][$i]])) {
            $subdisplay = album_build_index($user_id, $keys, $album_data['sub'][$cur_cat_id][$i], $level + 1, $max_level, $newestpic);
            if ($subdisplay) {
                $display = true;
            }
        }
    }
    return $display;
}