function widget($args, $instance) { extract($args); $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); if (empty($title)) { $title = '精彩推荐'; } $count = intval($instance['count']); $smallCount = intval(isset($instance['smallCount']) ? $instance['smallCount'] : 3); global $xt, $xt_user; if (isset($xt->is_share) && $xt->is_share && !empty($xt_user)) { query_albums(array('page' => 1, 'album_per_page' => $count, 'user_id' => $xt_user->ID)); if (xt_have_albums()) { echo $before_widget; echo '<div class="hd"><h4 class="xt-bd-l" ' . (!empty($title) ? '' : 'style="display:none;"') . '><span>' . $title . '</span></h4></div>'; echo '<div class="thumbnails thumbnails-span3 clearfix">'; while (xt_have_albums()) { xt_the_album(); get_the_album_template_small(0, '', false, $smallCount ? $smallCount : 3); } echo '<div class="clearfix"></div></div>'; echo $after_widget; } } }
function widget($args, $instance) { extract($args); $title = apply_filters('xt_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $dataType = $instance['dataType']; $user_id = intval($instance['user_id']); $count = intval($instance['count']); $cid = isset($instance['cid']) ? intval($instance['cid']) : 0; $ids = apply_filters('xt_filter_ids', $instance['ids']); if ($dataType == 'cid' && !empty($cid)) { query_albums(array('page' => 1, 'album_per_page' => $count, 'cid' => $cid)); } elseif ($dataType == 'ids' && !empty($ids)) { query_albums(array('no_found_rows' => 1, 'album__in' => explode(',', $ids))); } elseif ($dataType == 'user_id' && $user_id > 0) { query_albums(array('page' => 1, 'album_per_page' => $count, 'user_id' => $user_id)); } echo $before_widget; echo '<div class="hd"><h4 class="xt-bd-l" style="' . (empty($title) ? 'display:none' : '') . '"><span>' . $title . '</span></h4></div><div class="bd">'; echo '<div class="thumbnails thumbnails-span3 clearfix">'; if (xt_have_albums()) { while (xt_have_albums()) { xt_the_album(); get_the_album_template_small(0, '', true); } } echo '</div>'; echo '<div class="clearfix"></div></div>'; echo $after_widget; }
function xt_ajax_search_albums() { global $xt; $xt->is_albums = false; $xt_album_param = $_GET; if (isset($xt_album_param['s_index'])) { $xt->is_albums = true; if ($xt_album_param['page'] > $xt_album_param['s_index'] + 4) { exit('no more'); } } unset($xt_album_param['action']); query_albums($xt_album_param); $_isScroll = isset($xt_album_param['isScroll']) && "false" == $xt_album_param['isScroll'] ? false : true; $_isCatalog = isset($xt_album_param['isCatalog']) && "false" == $xt_album_param['isCatalog'] ? false : true; get_the_album_container($xt_album_param, $_isCatalog, true, $_isScroll); exit; }
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); } } }
function xt_get_album_popup($user_id, $id, $pic, $title, $albums = array()) { ?> <div id="X_Album-Popup" class="row-fluid" style="position:absolute;width:520px;"> <h4 style="margin-top:0px;"><?php echo $title; ?> </h4> <div class="span12" style="margin-left:0px;"> <div style="float: left;width: 160px;height: 160px;overflow: hidden;"> <img width="160" src="<?php echo $pic; ?> "> </div> <div style="float: left;padding-left: 10px;width: 350px;height:230px;position: relative;"> <ul class="nav nav-pills" style="margin-bottom:10px;"> <li class="dropdown active" style="width:348px"> <a class="dropdown-toggle" id="X_Album-Popup-Album-Selected" data-toggle="dropdown"><b class="caret" style="float:right;"></b></a> <ul class="dropdown-menu" id="X_Album-Popup-Albums" style="width:348px;max-height: 300px;overflow-x: hidden;overflow-y: auto;z-index:1100"> <?php query_albums(array('user_id' => $user_id, 'no_found_rows' => 1)); global $xt_album; $_count = 0; while (xt_have_albums()) { xt_the_album(); echo "<li><a data-value=\"{$xt_album->id}\" href=\"javascript:;\">{$xt_album->title}</a></li>"; $_count++; } if ($_count == 0) { global $wpdb; $user = wp_get_current_user(); if (empty($user->display_name)) { $user->display_name = $user->user_login; } $user_name = $wpdb->escape($user->display_name); echo '<li><a data-value="0" href=\\"javascript:;\\">' . $user_name . '的分享</a></li>'; } ?> <li class="divider"></li> <div id="X_Album-Create-Msg" class="alert alert-block alert-error fade in hide" style="margin:0 auto;padding:2px;width:310px;"></div> <div class="input-append clearfix" style="padding: 3px 15px;"> <input id="X_Album-Create-Input" maxlength="20" type="text" value="" style="width:250px;" placeholder="创建一个专辑"> <input class="btn btn-primary" id="X_Album-Create-Btn" data-loading-text="创建中..." value="创建" type="button"> </div> </ul> </li> </ul> <textarea id="X_Album-Share-Content" class="input-xlarge" style="height:68px;width:330px;" placeholder="写点什么,评论一下"></textarea> <input value="确定" data-loading-text="分享中..." class="btn btn-primary" id="X_Album-Submit-Btn" data-id="<?php echo $id; ?> " type="button"> </div> </div> </div> <script type="text/javascript"> jQuery(function($) { var li = $('#X_Album-Popup-Albums li:first'); var a = li.find('a'); $('#X_Album-Popup-Album-Selected').attr('data-value',a.attr('data-value')).html(a.text()+'<b class="caret" style="float:right;"></b>').dropdown(); $('#X_Album-Create-Input').click(function(e){ e.stopPropagation(); }); li.remove(); $('#X_Album-Popup-Albums li a').click(function(){ $('#X_Album-Popup-Album-Selected').attr('data-value',$(this).attr('data-value')).html($(this).text()+'<b class="caret" style="float:right;"></b>'); }); // 创建专辑 $('#X_Album-Create-Btn').click(function(e) { e.stopPropagation(); if (!XT.userId) { XT_openLogin($(this).attr('data-url')); return true; } var msg = $('#X_Album-Create-Msg'); msg.html('').hide(); var title = $.trim($('#X_Album-Create-Input').val()); if (!title) { msg.html('请输入专辑名称!').show(); $('#X_Album-Create-Input').focus(); return true; } var reg_title = /[\$|&|#|\|"| |]/.test(title); if (reg_title) { msg.html('专辑名称含有非法字符!').show(); $('#X_Album-Create-Input').focus(); return false; } if(XTTOOL.getMsgLength(title,30) < 0){ msg.html('专辑名称不能超过30字!').show(); $('#X_Album-Create-Input').focus(); return false; } msg.html('正在创建...').show(); $('#X_Album-Create-Btn').addClass('disabled'); XT.albumAdd(title, '', function(response) { if (typeof(response) == 'string') { msg.html(response).show(); $('#X_Album-Create-Input').focus(); $('#X_Album-Create-Btn').removeClass('disabled'); return false; } if (response.code > 0) { if (response.code == 2000) { msg.show().html("哎呀,这个名称已经有人使用了,请换个名称吧!"); } else { msg.show().html(response.msg); } $('#X_Album-Create-Btn').removeClass('disabled'); } else { if (response.result == 0) { msg.show().html("创建专辑失败"); $('#X_Album-Create-Btn').removeClass('disabled'); return false; } $('#X_Album-Create-Input').val(''); $('#X_Album-Popup-Albums').prepend('<li><a data-value="'+response.result+'" href="javascript:;">'+title+'</a></li>'); $('#X_Album-Popup-Album-Selected').attr('data-value',response.result).html(title+'<b class="caret" style="float:right;"></b>').click(); msg.hide().html(""); $('#X_Album-Create-Btn').removeClass('disabled'); } }, function(request, error, status) { msg.show().html("创建专辑失败"); $('#X_Album-Create-Input').focus(); $('#X_Album-Create-Btn').removeClass('disabled'); }); }); }); </script> <?php }
<?php $_catalogs = xt_catalogs_album(true); $cid = isset($_GET['cid']) ? intval($_GET['cid']) : 0; $s = isset($_GET['s']) ? urldecode($_GET['s']) : ''; $_result = query_albums(array('album_per_page' => 50, 'page' => isset($_GET['paged']) ? intval($_GET['paged']) : 1, 'cid' => $cid, 's' => $s)); $_albums = $_result['albums']; ?> <div class="clear" style="margin-top:10px;"> <p class="search-box"> <label class="screen-reader-text" for="filter-search-input">搜索专辑:</label> <input type="search" id="filter-search-input" name="s" value="<?php echo $s; ?> "> <input type="button" name="" id="filter-search-submit" class="button" value="搜索专辑"> </p> </div> <div class="tablenav top"> <div class="alignleft actions"> <select name="cat" id="filter-cat" class="postform"> <option value="0" <?php echo $cid == 0 ? 'selected' : ''; ?> >全部</option> <option value="-1" <?php echo $cid == -1 ? 'selected' : ''; ?> >未分类</option> <?php if (!empty($_catalogs)) {