Example #1
0
function get_the_share_template($user_id = 0, $delClass = '')
{
    global $xt_album;
    $cacheObj = get_the_share_cachedata();
    $_item = isset($cacheObj['item']) ? $cacheObj['item'] : array();
    $_comment = isset($cacheObj['comment']) ? $cacheObj['comment'] : array();
    $_title = get_the_share_title();
    $_url = get_the_share_url();
    $_nick = xt_get_the_user_title(get_the_share_username());
    ?>
    <div class="span3 xt-share">
        <div class="thumbnail">
            <a href="<?php 
    echo $_url;
    ?>
" title="<?php 
    echo $_title;
    ?>
" target="_blank" class="xt-share-link">
                <img src="<?php 
    the_share_picurl();
    ?>
" title="<?php 
    echo $_title;
    ?>
" alt="<?php 
    echo $_title;
    ?>
" />
                <div class="xt-img-price">¥<?php 
    the_share_price();
    ?>
</div>
                <?php 
    echo get_the_admin_tool_share(get_the_share_id());
    ?>
                <?php 
    if ($user_id) {
        the_delete_template(get_the_share_id(), $delClass == 'xt-delete-album-share' ? $xt_album->id : 1, $user_id, $delClass);
    }
    ?>
                <span class="label label-album-add" data-id="<?php 
    the_share_id();
    ?>
" data-pic="<?php 
    the_share_picurl(160);
    ?>
">加入专辑</span>	
            </a>
            <div class="caption">
                <h5><?php 
    the_share_content();
    ?>
</h5>
                <div class="clearfix">
                    <a class="badge badge-fav" title="喜欢" data-id="<?php 
    the_share_id();
    ?>
" data-type="1" data-uid="<?php 
    the_share_userid();
    ?>
"><?php 
    the_share_favcount();
    ?>
<i class="icon-heart icon-white"></i></a>
                    <a class="badge badge-comment" title="评论" href="javascript:;" data-id="<?php 
    the_share_id();
    ?>
"><?php 
    the_share_commentcount();
    ?>
<i class="icon-comment icon-white"></i></a>
                </div>
            </div>
            <ul class="media-list clearfix">
                <li class="media">
                    <a class="pull-left X_Nick" data-value="<?php 
    echo get_the_share_userid();
    ?>
" target="_blank" href="<?php 
    xt_the_user_url(get_the_share_userid());
    ?>
"><img src="<?php 
    xt_the_user_pic(get_the_share_useravatar());
    ?>
" alt="<?php 
    echo $_nick;
    ?>
"></a>
                    <div class="media-body"><p class="muted"><a class="X_Nick" data-value="<?php 
    echo get_the_share_userid();
    ?>
" target="_blank" href="<?php 
    xt_the_user_url(get_the_share_userid());
    ?>
" class="xt-rep-nick"><?php 
    echo $_nick;
    ?>
        </a>分享了:<?php 
    echo wp_trim_words(get_the_share_title(), 15);
    ?>
    </p></div>
                </li>
                <?php 
    if (xt_is_displaycomment() && !empty($_comment) && isset($_comment['comments']) && !empty($_comment['comments'])) {
        $_comments = $_comment['comments'];
        foreach ($_comments as $c) {
            ?>
                        <li class="media">
                            <a class="pull-left X_Nick" data-value="<?php 
            echo $c['user_id'];
            ?>
" target="_blank" href="<?php 
            xt_the_user_url($c['user_id']);
            ?>
"><img src="<?php 
            xt_the_user_pic($c['pic_url']);
            ?>
" alt="<?php 
            xt_the_user_title($c['nick']);
            ?>
"></a>
                            <div class="media-body"><p class="muted"><a class="X_Nick" data-value="<?php 
            echo $c['user_id'];
            ?>
" target="_blank" href="<?php 
            xt_the_user_url($c['user_id']);
            ?>
" class="xt-rep-nick"><?php 
            xt_the_user_title($c['nick']);
            ?>
        </a>:<?php 
            xt_comment_excerpt(0, $c['content']);
            ?>
    </p></div>
                        </li>
                        <?php 
        }
        if (isset($_comment['total']) && $_comment['total'] > 2) {
            echo '<li class="xt-rep-more"><a href="' . $_url . '" target="_blank" rel="nofollow"> 查看全部' . $_comment['total'] . '条评论...</a></li>';
        }
    }
    ?>
            </ul>
        </div>
    </div>
    <?php 
}
Example #2
0
function xt_screens()
{
    global $xt, $wp_query, $xt_catalog, $xt_user, $xt_album, $xt_taobao_item, $xt_template_name;
    if (xt_is_404()) {
        if (is_home()) {
            xt_clear_404();
            $xt->is_xintao = true;
            $xt->is_index = true;
            $xt_template_name = 'home';
        } elseif (is_front_page()) {
            if (is_page(xt_base()) && !isset($wp_query->query_vars['xt_action'])) {
                xt_clear_404();
                $xt->is_xintao = true;
                $xt->is_index = true;
                $xt_template_name = 'home';
            } elseif (!isset($wp_query->query_vars['xt_action'])) {
                $xt->is_xintao = false;
            }
        }
    }
    if (is_404() && !$xt->is_xintao) {
        $xt->is_xintao = true;
        xt_set_404();
    }
    if ($xt->is_xintao) {
        if (isset($_GET['invite']) && absint($_GET['invite']) > 0) {
            setcookie(XT_USER_PARENT, (string) $_GET['invite'], time() + 1296000, COOKIEPATH, COOKIE_DOMAIN);
        }
        $xt_share_param = isset($wp_query->query_vars['xt_param']) ? $wp_query->query_vars['xt_param'] : '';
        if ($xt->is_shares) {
            query_shares($xt_share_param);
            if (isset($xt_share_param['s']) && !empty($xt_share_param['s'])) {
                //设置搜索词
                $wp_query->set('s', $xt_share_param['s']);
            }
            if (absint($xt_share_param['cid']) > 0) {
                $_term = xt_get_catalog($xt_share_param['cid']);
                if (!empty($_term)) {
                    $xt_catalog = $_term;
                }
            }
        } elseif ($xt->is_albums) {
            query_albums($xt_share_param);
            if (isset($xt_share_param['s']) && !empty($xt_share_param['s'])) {
                //设置搜索词
                $wp_query->set('s', $xt_share_param['s']);
            }
        } elseif ($xt->is_share) {
            $xt_user = null;
            if (absint($xt_share_param) > 0) {
                query_shares(array('id' => absint($xt_share_param)));
                if (xt_have_shares()) {
                    xt_the_share();
                    $xt_user = new WP_User(get_the_share_userid());
                    if (!empty($xt_user) && $xt_user->ID != 0) {
                        xt_setup_single_userdata();
                    } else {
                        xt_set_404();
                    }
                } else {
                    xt_set_404();
                }
            } else {
                xt_set_404();
            }
        } elseif ($xt->is_user) {
            $xt_user = null;
            if (absint($xt_share_param) > 0) {
                $uid = absint($xt_share_param);
                $_user = wp_get_current_user();
                if ($_user->exists()) {
                    if ($_user->ID == $uid) {
                        $xt_user = $_user;
                    }
                }
                if (empty($xt_user) || $xt_user->ID == 0) {
                    $_user = new WP_User($uid);
                    if ($_user && $_user->ID != 0) {
                        $xt_user = $_user;
                    }
                }
                if (!empty($xt_user) && $xt_user->ID != 0) {
                    xt_setup_single_userdata();
                }
            }
            if (empty($xt_user) || $xt_user->ID == 0) {
                xt_set_404();
            }
        } elseif ($xt->is_account) {
            $xt_user = wp_get_current_user();
            if ($xt_user->exists()) {
                //xt_setup_single_userdata();
            } else {
                xt_set_404();
                wp_safe_redirect(site_url('wp-login.php'));
                exit;
            }
        } elseif ($xt->is_album) {
            $xt_user = null;
            $xt_album = null;
            if (absint($xt_share_param) > 0) {
                $xt_album = xt_get_album($xt_share_param);
                if (!empty($xt_album)) {
                    $_user = wp_get_current_user();
                    if ($_user->exists()) {
                        if ($_user->ID == $xt_album->user_id) {
                            $xt_user = $_user;
                        } else {
                            $xt_user = new WP_User($xt_album->user_id);
                        }
                    } else {
                        $xt_user = new WP_User($xt_album->user_id);
                    }
                    if (!empty($xt_user) && $xt_user->ID > 0) {
                        xt_setup_single_userdata();
                        //						query_albums(array (
                        //							'page' => 1,
                        //							'album_per_page' => 20,
                        //							'user_id' => $xt_album->user_id
                        //						));
                        //当前专辑所属用户的前20个专辑
                        query_shares(array('album_id' => absint($xt_share_param), 'page' => 1, 'share_per_page' => 40, 'user_id' => $xt_album->user_id));
                    }
                    //当前专辑内的宝贝
                }
                if (empty($xt_album) || empty($xt_user) || $xt_user->ID == 0) {
                    xt_set_404();
                }
            }
        } elseif ($xt->is_page) {
        } elseif ($xt->is_invite) {
            $xt_user = null;
            if (absint($xt_share_param) > 0) {
                $xt_user = new WP_User(absint($xt_share_param));
            }
            if (empty($xt_user) || $xt_user->ID == 0) {
                xt_set_404();
            } else {
                $user = wp_get_current_user();
                if (!$user->exists()) {
                    //15days
                    setcookie(XT_USER_PARENT, (string) $xt_user->ID, time() + 1296000, COOKIEPATH, COOKIE_DOMAIN);
                }
            }
        } elseif ($xt->is_taobao) {
            $xt_taobao_item = xt_taobao_item($xt_share_param, "detail_url,num_iid,title,nick,props_name,cid,pic_url,num,location,price,post_fee,express_fee,ems_fee,item_img,prop_imgs");
            if (is_wp_error($xt_taobao_item)) {
                xt_set_404();
            }
        }
        if (xt_is_404()) {
            $xt_template_name = 'error404';
        }
        if ($xt->is_login) {
            xt_load_template('xt-login', true, true);
        } elseif ($xt->is_jump) {
            xt_load_template('xt-jump', true, true);
        } elseif ($xt->is_sitemap) {
            xt_load_template('xt-sitemap', true, true);
        } else {
            xt_load_template('xt-template', true, true);
        }
    }
}