Ejemplo n.º 1
0
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $before_widget;
     global $post;
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             echo '<div class="hd"><h4 class="xt-bd-l"><span><a href="' . get_permalink() . '">' . get_the_title() . '</a>&nbsp;&nbsp;&nbsp;&nbsp;<small>' . get_the_date() . '</small></span></h4></div><div class="bd">';
             echo '<div class="row-fluid">';
             the_content();
             $items = get_post_meta($post->ID, 'xt_items', true);
             if (!empty($items)) {
                 $itemsHtml = '';
                 foreach ($items as $item) {
                     if (!empty($item['pic'])) {
                         $_url = xt_jump_url(array('id' => get_the_share_key($item['key']), 'type' => $item['type'], 'share' => $item['guid']));
                         $itemsHtml .= '<li>
                                             <a class="thumbnail" rel="nofollow" target="_blank" href="' . $_url . '" title="' . $item['title'] . '">' . xt_write_pic(base64_encode(xt_pic_url($item['pic'], 160, $item['type'])), $item['title'], 0, 0, '', '', false) . '</a>
                                              <div class="caption">
                                                 <div class="desc"><a rel="nofollow" target="_blank" href="' . $_url . '" class="permalink">' . $item['title'] . '</a></div>
                                             </div>
                                           </li>';
                     }
                 }
                 if (!empty($itemsHtml)) {
                     echo '<div class="span12"><h4>推荐的宝贝</h4><ul class="thumbnails">' . $itemsHtml . '</ul></div>';
                 }
             }
             comments_template('xt-daogou_comments.php', true);
             echo '</div></div>';
         }
     }
     echo $after_widget;
 }
Ejemplo n.º 2
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('xt_widget_title', empty($instance['title']) ? '分享' : $instance['title'], $instance, $this->id_base);
        $style = isset($instance['style']) ? $instance['style'] : 'MZ';
        $sortby = empty($instance['sortby']) ? 'newest' : $instance['sortby'];
        $cid = empty($instance['cid']) ? '' : $instance['cid'];
        $row = isset($instance['row']) ? intval($instance['row']) : 1;
        $tagPicCount = $style == 'MZ' ? 10 : $row * 6;
        $tagCount = $style == 'MZ' ? 20 : 28;
        $query_tags = query_tags(array('cid' => $cid, 'tag_per_page' => $tagPicCount + $tagCount));
        $tags = $query_tags['tags'];
        $shares = xt_shareandtags($cid, array_slice($tags, 0, $tagPicCount), $sortby);
        $count = count($shares);
        if ($style == 'MZ') {
            echo str_replace('clearfix', 'xt-widget-shareandtags-mz clearfix', $before_widget);
            ?>
            <div class="hd"><h4 <?php 
            echo !empty($title) ? '' : 'style="display:none;"';
            ?>
><span><?php 
            echo $title;
            ?>
</span></h4></div>
            <div class="bd">
                <div class="clearfix">
                    <div class="xt-big xt-img-box">
                        <?php 
            if ($count > 0) {
                $_share = $shares[0]['share'];
                $_tag = $shares[0]['tag'];
                if (!empty($_share)) {
                    ?>
                                <a href="<?php 
                    echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                    ?>
" target="_blank" title="<?php 
                    echo $_share->title;
                    ?>
"><?php 
                    xt_write_pic(base64_encode(get_the_share_picurl(200, $_share)), $_share->title);
                    ?>
<span><?php 
                    echo $_tag;
                    ?>
</span></a>
                                <?php 
                } else {
                    ?>
                                <a href="<?php 
                    echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                    ?>
" target="_blank"><span><?php 
                    echo $_tag;
                    ?>
</span></a>
                                <?php 
                }
            }
            ?>
                    </div>
                    <div class="xt-small">
                        <?php 
            if ($count > 1) {
                $length = $count > 7 ? 7 : $count;
                for ($i = 1; $i < $length; $i++) {
                    $_share = $shares[$i]['share'];
                    $_tag = $shares[$i]['tag'];
                    if (!empty($_share)) {
                        ?>
                                    <div class="xt-img-box"><a href="<?php 
                        echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                        ?>
" target="_blank" title="<?php 
                        echo $_share->title;
                        ?>
"><?php 
                        xt_write_pic(base64_encode(get_the_share_picurl(160, $_share)), $_share->title);
                        ?>
<span><?php 
                        echo $_tag;
                        ?>
</span></a></div>
                                    <?php 
                    } else {
                        ?>
                                    <div class="xt-img-box"><a href="<?php 
                        echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                        ?>
" target="_blank"><span><?php 
                        echo $_tag;
                        ?>
</span></a></div>
                                    <?php 
                    }
                }
            }
            ?>
                    </div>
                    <div class="xt-big xt-img-box">
                        <?php 
            if ($count > 7) {
                $_share = $shares[7]['share'];
                $_tag = $shares[7]['tag'];
                if (!empty($_share)) {
                    ?>
                                <a href="<?php 
                    echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                    ?>
" target="_blank" title="<?php 
                    echo $_share->title;
                    ?>
"><?php 
                    xt_write_pic(base64_encode(get_the_share_picurl(200, $_share)), $_share->title);
                    ?>
<span><?php 
                    echo $_tag;
                    ?>
</span></a>
                                <?php 
                } else {
                    ?>
                                <a href="<?php 
                    echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                    ?>
" target="_blank"><span><?php 
                    echo $_tag;
                    ?>
</span></a>
                                <?php 
                }
            }
            ?>
                    </div>
                    <div class="xt-small xt-last">
                        <?php 
            if ($count > 8) {
                for ($i = 8; $i < $count; $i++) {
                    $_share = $shares[$i]['share'];
                    $_tag = $shares[$i]['tag'];
                    if (!empty($_share)) {
                        ?>
                                    <div class="xt-img-box"><a href="<?php 
                        echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                        ?>
" target="_blank" title="<?php 
                        echo $_share->title;
                        ?>
"><?php 
                        xt_write_pic(base64_encode(get_the_share_picurl(160, $_share)), $_share->title);
                        ?>
<span><?php 
                        echo $_tag;
                        ?>
</span></a></div>
                                    <?php 
                    } else {
                        ?>
                                    <div class="xt-img-box"><a href="<?php 
                        echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                        ?>
" target="_blank"><span><?php 
                        echo $_tag;
                        ?>
</span></a></div>
                                    <?php 
                    }
                }
            }
            ?>
                    </div>
                </div>
                <?php 
            if (count($tags) > $tagPicCount) {
                $tags = array_slice($tags, $tagPicCount, $tagCount);
                $tagsList = array_chunk($tags, 5);
                ?>
                    <div class="xt-tags clearfix">
                        <?php 
                foreach ($tagsList as $_tags) {
                    if (!empty($_tags)) {
                        $_count = 0;
                        foreach ($_tags as $_tag) {
                            echo '<a ' . ($_count == 0 ? 'class="xt-first"' : 'class="text-gray"') . ' href="' . xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag->title)) . '" target="_blank">' . $_tag->title . '</a>';
                            $_count++;
                        }
                    }
                }
                ?>
                    </div>
                    <?php 
            }
            ?>

            </div>
            <?php 
        } else {
            echo $before_widget;
            ?>
            <div class="hd xt-bd-radius-top"><h4 class="xt-bd-l" <?php 
            echo !empty($title) ? '' : 'style="display:none;"';
            ?>
><span><?php 
            echo $title;
            ?>
</span></h4></div>
            <div class="bd xt-bd-radius-bottom">
                <?php 
            if (!empty($shares)) {
                $_count = 0;
                ?>
                    <ul class="thumbnails">
                        <?php 
                if (!empty($shares)) {
                    foreach ($shares as $__share) {
                        $_share = $__share['share'];
                        $_tag = $__share['tag'];
                        if (!empty($_share)) {
                            ?>
                                    <li><a class="thumbnail" href="<?php 
                            echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                            ?>
" target="_blank" title="<?php 
                            echo $_share->title;
                            ?>
"><?php 
                            xt_write_pic(base64_encode(get_the_share_picurl(200, $_share)), $_share->title);
                            ?>
<span><?php 
                            echo $_tag;
                            ?>
</span></a></li>
                                    <?php 
                        } else {
                            ?>
                                    <li><a class="thumbnail" href="<?php 
                            echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag));
                            ?>
" target="_blank"><span><?php 
                            echo $_tag;
                            ?>
</span></a></li>
                                    <?php 
                        }
                    }
                }
                ?>
	
                    </ul>
                <?php 
            }
            ?>
                <?php 
            if (count($tags) > $tagPicCount) {
                $tags = array_slice($tags, $tagPicCount - 1, $tagCount);
                ?>
                    <div class="clearfix" style="position:relative;">
                        <?php 
                $chunks = array_chunk($tags, 7);
                foreach ($chunks as $chunk) {
                    $_tag0 = (array) $chunk[0];
                    ?>
                            <dl class="dl-horizontal pull-left">
                                <dt>
                                <a target="_blank" class="text-success" href="<?php 
                    echo xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag0['title']));
                    ?>
"><?php 
                    echo $_tag0['title'];
                    ?>
</a>
                                </dt>
                                <dd>
                                    <ul class="inline">
                                        <?php 
                    for ($i = 1; $i < count($chunk); $i++) {
                        $_random = rand(1, 3);
                        $_tag = (array) $chunk[$i];
                        echo '<li><a ' . ($_random == 1 ? ' class="text-default" ' : ' class="text-gray"') . 'href="' . xt_get_shares_search_url(array('cid' => $cid, 's' => $_tag['title'])) . '" target="_blank">' . $_tag['title'] . '</a></li>';
                    }
                    ?>
                                    </ul>
                                </dd>
                            </dl>
                        <?php 
                }
                ?>
                        <?php 
                if ($cid > 0) {
                    ?>
<a class="xt-widget-tag-more label-default" href="<?php 
                    echo xt_get_shares_search_url(array('cid' => $cid));
                    ?>
" target="_blank">全部<span>...</span></a><?php 
                }
                ?>
                    </div>
                <?php 
            }
            ?>
		
            </div>	
            <?php 
        }
        echo $after_widget;
    }
Ejemplo n.º 3
0
function xt_widget_template_grid_sidesmall_item_tuan($_count, $rate, $item)
{
    $_title = esc_html($item['title']);
    $_pic = $item['pic_url'];
    parse_str($item['pdt_o_url'], $params);
    $_url = isset($params['t']) ? urldecode($params['t']) : $item['pdt_o_url'];
    ?>
    <li class="media"<?php 
    echo $_count == 0 ? ' style="padding-top:0px;"' : '';
    ?>
>
        <a rel="nofollow" class="pull-left" href="<?php 
    echo $_url;
    ?>
" target="_blank">
            <?php 
    xt_write_pic(base64_encode($_pic), $_title, 0, 0, 'media-object');
    ?>
<span><i>销量:<?php 
    echo $item['bought'];
    ?>
</i></span>
        </a>
        <div class="media-body">
            <h4 class="media-heading"><a rel="nofollow" class="text-gray" href="<?php 
    echo $_url;
    ?>
" target="_blank"><?php 
    echo $_title;
    ?>
</a></h4>
            <div class="media">
                <p><span>¥</span><strong><?php 
    echo $item['cur_price'];
    ?>
</strong></p>
            </div>
        </div>
    </li>
    <?php 
}