Beispiel #1
0
<style type="text/css">
    .widefat tbody th.check-column{padding-bottom:2px;}.inline-edit-row .error{color:red;}
</style>
<?php 
$_catalogs = xt_catalogs_share(true);
$cid = isset($_GET['cid']) ? intval($_GET['cid']) : 0;
$s = isset($_GET['s']) ? urldecode($_GET['s']) : '';
$_result = query_tags(array('tag_per_page' => 50, 'page' => isset($_GET['paged']) ? intval($_GET['paged']) : 1, 'cid' => $cid, 's' => $s));
$_tags = $_result['tags'];
?>
<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 id="col-container" class="clear">
    <div id="col-right">
        <div class="tablenav top">
            <!--<div class="alignleft actions">
                <select name="action">
                    <option value="-1" selected="selected">批量操作</option>
                    <option value="delete">删除</option>
                </select>
                <input type="submit" name="" id="post-query-submit" class="button" value="应用">
            </div>-->
    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;
    }
Beispiel #3
0
/**
 * @version 0.1
 * @since 0.1
 */
function gettagnm($id)
{
    $q = query_tags($id);
    return $q['name'];
}
Beispiel #4
0
function xt_catalogs_share($force = false)
{
    $result = array();
    if (!$force) {
        $result = get_option(XT_OPTION_CATALOG_SHARE);
    }
    if (empty($result)) {
        $result = xt_root_catalogs_share();
        if (!empty($result)) {
            foreach ($result as &$root) {
                $childs = query_catalogs(array('nopage' => true, 'sortOrder' => 'count', 'parent' => $root->id));
                if (!empty($childs['catalogs'])) {
                    $_childIds = array();
                    foreach ($childs['catalogs'] as $child) {
                        $tags = query_tags(array('page' => 1, 'tag_per_page' => 12, 'cid' => $child->id));
                        if (!empty($tags['tags'])) {
                            $child->tags = $tags['tags'];
                        } else {
                            $child->tags = array();
                        }
                        $_childIds[] = $child->id;
                    }
                    if (empty($root->children)) {
                        $root->children = implode(',', $_childIds);
                        global $wpdb;
                        $wpdb->update(XT_TABLE_CATALOG, array('children' => implode(',', $_childIds)), array('id' => $root->id));
                    }
                }
                $root->child = $childs;
            }
        }
        update_option(XT_OPTION_CATALOG_SHARE, $result);
    }
    return $result;
}
    $terms_tag = array();
    $terms_select = 0;
    $terms_parent = 0;
    $terms_tag_parent = 0;
    $tag_select = isset($xt_share_param['s']) ? $xt_share_param['s'] : '';
    if (!empty($xt_catalog)) {
        //指定了分类
        $terms_tag_parent = $xt_catalog->id;
        $terms_select = $xt_catalog->id;
        $terms_parent = $xt_catalog->parent;
        $terms_sub = $terms = xt_catalogs_share_sub($terms_select);
    }
    //catalog
    $terms = xt_catalogs_share_sub($terms_parent);
    //tag
    $query_tags = query_tags(array('cid' => $terms_select));
    $terms_tag = $query_tags['tags'];
    if (!empty($terms)) {
        ?>
<div class="span3 xt-share xt-share-catalog">
	<div class="thumbnail">
		<div class="caption">
		<?php 
        echo '<a href="' . xt_get_shares_search_url(array_merge($xt_share_param, array('cid' => $terms_parent, 's' => '', 'sortOrder' => '', 'price' => '', 'page' => 1))) . '" ' . ($terms_select == 0 ? ' class="label label-tag active"' : 'class="label label-tag"') . '>全部</a>';
        foreach ($terms as $term) {
            if ($term->is_front) {
                echo '<a href="' . xt_get_shares_search_url(array_merge($xt_share_param, array('cid' => $term->id, 's' => '', 'sortOrder' => '', 'price' => '', 'page' => 1))) . '"' . ($terms_select == $term->id ? ' class="label label-tag active"' : 'class="label label-tag"') . '>' . $term->title . '</a>';
            }
        }
        if (!empty($terms_sub)) {
            echo '<div class="clearfix"><h4>分类</h4>';