コード例 #1
0
ファイル: category_tree.php プロジェクト: gblok/rsc
function catGetMenuCategoryList($cats)
{
    $arr = array();
    $cats_tree = array();
    foreach ($cats as $cat => $val) {
        $level = (int) $val['level'];
        $parentID = (int) $val['parent'];
        $categoryID = (int) $val['categoryID'];
        $subcount = (int) $val['subcount'];
        //        $uri = (int) $val['uri'];
        if ($level === 0) {
            $arr[$categoryID] = $val;
        }
        if ($level === 1) {
            if ($subcount > 0) {
                $val['sub'] = get_sub_cat($cats, $categoryID, 2);
            }
            $arr[$parentID]['sub'][] = $val;
        }
    }
    foreach ($arr as $cat => $val) {
        $cats_tree[] = $val;
    }
    return $cats_tree;
}
コード例 #2
0
ファイル: superslider-menu-list.php プロジェクト: hewu/blogwp
function ssm_list_categories($number)
{
    global $wpdb, $options;
    $options = get_option('ssMenu_widget_options');
    extract($options[$number]);
    // check for exclusion or inclusion of categories
    $inExclusions = array();
    //echo 'the inExclude : '.$inExclude.'.<br />';
    //echo 'the inExcludeCats : '.$inExcludeCats.'.<br />';
    if (!empty($inExclude) && !empty($inExcludeCats)) {
        $exterms = preg_split('/[,]+/', $inExcludeCats);
        if ($inExclude == 'include') {
            $in = 'IN';
        } else {
            $in = 'NOT IN';
        }
        if (count($exterms)) {
            foreach ($exterms as $exterm) {
                if (empty($inExclusions)) {
                    $inExclusions = "'" . sanitize_title($exterm) . "'";
                } else {
                    $inExclusions .= ", '" . sanitize_title($exterm) . "' ";
                }
            }
        }
    }
    //echo 'the inExclusions : '.$inExclusions.'.<br />';
    $isPage = '';
    if (!$showPages) {
        $isPage = "AND {$wpdb->posts}.post_type='post'";
    }
    if (empty($inExclusions)) {
        $inExcludeQuery = "''";
    } else {
        $inExcludeQuery = "AND {$wpdb->terms}.term_id {$in} ({$inExclusions})";
    }
    if ($catSort == 'catName') {
        $catSortColumn = "ORDER BY {$wpdb->terms}.name";
    } elseif ($catSort == 'catId') {
        $catSortColumn = "ORDER BY {$wpdb->terms}.term_id";
    } elseif ($catSort == 'catSlug') {
        $catSortColumn = "ORDER BY {$wpdb->terms}.slug";
    } elseif ($catSort == 'catOrder') {
        $catSortColumn = "ORDER BY {$wpdb->terms}.term_order";
    } elseif ($catSort == 'catCount') {
        $catSortColumn = "ORDER BY {$wpdb->term_taxonomy}.count";
    }
    if ($postSort == 'postDate') {
        $postSortColumn = "ORDER BY {$wpdb->posts}.post_date";
    } elseif ($postSort == 'postId') {
        $postSortColumn = "ORDER BY {$wpdb->posts}.id";
    } elseif ($postSort == 'postTitle') {
        $postSortColumn = "ORDER BY {$wpdb->posts}.post_title";
    } elseif ($postSort == 'postComment') {
        $postSortColumn = "ORDER BY {$wpdb->posts}.comment_count";
    }
    $catquery = "SELECT {$wpdb->term_taxonomy}.count as 'count',\n\t\t\t{$wpdb->terms}.term_id, {$wpdb->terms}.name, {$wpdb->terms}.slug,\n\t\t\t{$wpdb->term_taxonomy}.parent, {$wpdb->term_taxonomy}.description FROM\n\t\t\t{$wpdb->terms}, {$wpdb->term_taxonomy} WHERE {$wpdb->terms}.term_id =\n\t\t\t{$wpdb->term_taxonomy}.term_id AND {$wpdb->terms}.name != 'Blogroll' AND\n\t\t\t{$wpdb->term_taxonomy}.taxonomy = 'category' {$inExcludeQuery} {$catSortColumn}\n\t\t\t{$catSortOrder}";
    $postquery = "SELECT {$wpdb->terms}.term_id, {$wpdb->terms}.name,\n\t\t\t{$wpdb->terms}.slug, {$wpdb->term_taxonomy}.count, {$wpdb->posts}.id,\n\t\t\t{$wpdb->posts}.post_title, {$wpdb->posts}.post_name,\n\t\t\tdate({$wpdb->posts}.post_date) as 'date' FROM {$wpdb->posts}, {$wpdb->terms},\n\t\t\t{$wpdb->term_taxonomy}, {$wpdb->term_relationships}  WHERE {$wpdb->posts}.id =\n\t\t\t{$wpdb->term_relationships}.object_id AND {$wpdb->posts}.post_status='publish'\n\t\t\tAND {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id AND\n\t\t\t{$wpdb->term_relationships}.term_taxonomy_id =\n\t\t\t{$wpdb->term_taxonomy}.term_taxonomy_id AND {$wpdb->term_taxonomy}.taxonomy =\n\t\t\t'category' {$isPage} {$postSortColumn} {$postSortOrder}";
    /* changing to use only one query 
     * don't forget to exclude pages if so desired
     */
    $categories = $wpdb->get_results($catquery);
    $posts = $wpdb->get_results($postquery);
    //echo 'the catquery is :<br />'.$catquery.'.<br />';
    /*
    echo 'the categories are :<br />';
    var_dump($categories);
    echo '___________________.<br />';
    */
    $grandChildren = array();
    $children = array();
    $parents = array();
    $grandParents = array();
    $subCatPosts = array();
    $mycats = $categories;
    // let's remove any empty categories if showEmptyCat is set to no
    foreach ($categories as $cat) {
        if ($cat->count == 0 && $showEmptyCat == 'no') {
            $key = array_search($cat, $categories);
            unset($categories[$key]);
        }
        if ($cat->parent == '0') {
            array_push($grandParents, $cat->term_id);
            $key = array_search($cat, $categories);
            unset($categories[$key]);
        }
        if ($cat->parent != '0') {
            array_push($parents, $cat->term_id);
        }
    }
    foreach ($categories as $cat) {
        if (in_array($cat->parent, $parents)) {
            array_push($children, $cat->term_id);
        }
    }
    foreach ($categories as $cat) {
        if (in_array($cat->parent, $children)) {
            array_push($grandChildren, $cat->term_id);
        }
    }
    $categories = $mycats;
    // knock total number of posts to work with down to a max of 1000
    $totalPostCount = count($posts);
    if ($totalPostCount > 1000) {
        $posts = array_slice($posts, 0, 1000);
    }
    // start the html structure
    echo '<div id="ssMenuHolder"><div id="ssMenuList">';
    foreach ($categories as $cat) {
        if ($cat->parent == 0) {
            $subCatPostCount = 0;
            $subCatCount = 0;
            $myposts = array();
            $subCatPosts = array();
            // get the sub cats and their posts
            list($subCatLinks, $subCatCount, $subCatPostCount, $subCatPosts) = get_sub_cat($cat, $categories, $posts, $subCatCount, $subCatPostCount, $number, $grandParents, $parents, $children, $grandChildren);
            //$cat, $categories, $posts, $subCatCount, $subCatPostCount, $number, $grandParents, $parents, $children, $grandChildren
            $theCount = $cat->count + $subCatPostCount;
            print "\n<div class='ssmToggleBar ssm_" . $cat->slug . "'><span class='subsym show_1'>&nbsp;</span>";
            $link = make_cat_link($cat, $tipText, $useDescription);
            if ($showPostCount == 'yes') {
                $link .= ' <span class="postCount">(' . $theCount . ')</span>';
            }
            $link .= add_feedlink($catfeed, $cat) . '</div>';
            print $link;
            print '<div class="showme_1 ssm_' . $cat->slug . '"><div class="linkList">';
            // Now print out the post info
            if (!is_array($subCatPosts)) {
                $subCatPosts = array();
            }
            foreach ($posts as $post) {
                if ($post->term_id == $cat->term_id && !in_array($post->id, $subCatPosts)) {
                    array_push($myposts, $post);
                }
            }
            $postsincat = count($myposts);
            if ($postsincat > $limitPosts) {
                $moreposts = 1;
            }
            $myposts = array_slice($myposts, 0, $limitPosts);
            foreach ($myposts as $post) {
                echo " <span class='ssMenuPost'><a href='" . get_permalink($post->id) . "'>" . strip_tags($post->post_title) . "</a></span>\n";
            }
            if ($moreposts == 1 && $showMorePosts == 'yes' && $postsincat > $limitPosts) {
                echo '<span class="ssMenuPost ssMore"><a href="' . get_category_link($cat->term_id) . '">' . $moretext . ' ' . $cat->name . '</a></span>';
            }
            // list the sub cats and their posts
            echo $subCatLinks;
            if ($subCatCount = 1) {
                echo "</div><!-- ending second level with sub cats -->\n ";
            }
            echo "</div><!-- ending first level category -->\n";
        }
        // end if theCount>0
    }
    echo "\n</div></div><!-- closeing the superslider-menu plugin -->\n";
}
コード例 #3
0
function list_categories($posts, $categories, $parents, $options)
{
    /* returns a list of categories, and optionally subcategories and posts,
      which can be collapsed or expanded with javascript */
    global $collapsCatItems, $wpdb, $options, $wp_query, $autoExpand, $postsToExclude, $totalCatPostCount, $thisCatID, $cur_terms, $thisPost, $wp_rewrite, $catlink, $postsInCat;
    extract($options);
    $cur_terms = array();
    if (is_single()) {
        $tmp_terms = wp_get_object_terms($wp_query->post->ID, $taxonomy);
        foreach ($tmp_terms as $tmp_cat) {
            $cur_terms[] = $tmp_cat->term_id;
        }
        $thisPost = $wp_query->post->ID;
        foreach ($categories as $cat) {
            if (!empty($cur_terms) && in_array($cat->term_id, $cur_terms)) {
                checkCurrentCat($cat, $categories);
            }
        }
    }
    if (is_archive()) {
        $thisCatID = $wp_query->get_queried_object_id();
        $thisCat = get_term($thisCatID, $taxonomy);
        checkCurrentCat($thisCat, $categories);
    }
    $catlink = $wp_rewrite->get_category_permastruct();
    foreach ($categories as $cat) {
        $totalCatPostCount = 0;
        if ($inExclude == 'include' && !empty($includeCatArray)) {
            if (!in_array($cat->term_id, $includeCatArray) && !in_array($cat->post_parent, $includeCatArray)) {
                continue;
            } else {
            }
        }
        if ($cat->parent != 0) {
            continue;
        }
        if (is_archive() && $cat->term_id == $thisCatID) {
            $self = " self";
        } else {
            $self = "";
        }
        if (in_array($cat->slug, $autoExpand)) {
            $parent = " parent";
        } else {
            $parent = "";
        }
        $rssLink = addFeedLink($catfeed, $cat);
        $subCatPostCount = 0;
        $subCatCount = 0;
        list($subCatLinks, $subCatCount, $subCatPostCount) = get_sub_cat($cat, $categories, $parents, $posts, $subCatCount, $subCatPostCount, $expanded, 0);
        list($subCatPostCount2, $posttext2) = getSubPosts($postsInCat[$cat->term_id], $cat, $showPosts, $theID);
        $theCount = $subCatPostCount2 + $totalCatPostCount;
        if ($theCount > 0 || $showEmptyCat) {
            $expanded = 'none';
            $theID = 'collapsCat-' . $cat->term_id . ":{$number}";
            if ((in_array($cat->name, $autoExpand) || in_array($cat->slug, $autoExpand)) && $expandCatPost || $useCookies && $_COOKIE[$theID] == 1) {
                $expanded = 'block';
            }
            if ($showPosts || $subCatPostCount > 0 || $showEmptyCat) {
                if ($expanded == 'block') {
                    $show = 'collapse';
                    $symbol = $collapseSym;
                } else {
                    $show = 'expand';
                    $symbol = $expandSym;
                }
                $span = "      <li class='collapsing categories expandable" . $self . $parent . "'>" . "<span class='collapsing categories {$show}'>" . "<span class='sym'>{$symbol}</span>";
            } else {
                $span = "      <li class='collapsing categories item" . $self . "'>";
            }
            $link = getCollapsCatLink($cat, $catlink);
            if (empty($cat->description)) {
                $link .= 'title="' . sprintf(__("View all posts filed under %s", 'collapsing-categories'), wp_specialchars(apply_filters('single_cat_title', $cat->name))) . '"';
            } else {
                $link .= 'title="' . wp_specialchars(apply_filters('description', $cat->description, $cat)) . '"';
            }
            $link .= '>';
            if ($linkToCat == 'yes') {
                $link .= apply_filters('single_cat_title', $cat->name) . '</a>';
                if ($showPosts || $subCatPostCount > 0) {
                    $span .= '</span>';
                }
            } else {
                if ($showPosts || $subCatPostCount > 0) {
                    $link .= apply_filters('single_cat_title', $cat->name) . '</a></span>';
                } else {
                    // don't include the triangles if posts are not shown and there
                    // are no more subcategories
                    $link .= apply_filters('single_cat_title', $cat->name) . '</a>';
                    $span = "      <li class='collapsing categories item'>";
                }
            }
            // Now print out the post info
            $posttext = '';
            if (!empty($postsInCat[$cat->term_id])) {
                list($subCatPostCount, $posttext) = getSubPosts($posts, $cat, $collapsCatItems, $showPosts);
            }
            if ($showPostCount) {
                $link .= ' (' . $theCount . ')';
            }
            $link .= $rssLink;
            if ($theCount < 1 && !$showEmptyCat) {
                $link = '';
                $span = '';
            }
            if ($showTopLevel) {
                $collapsCatText .= $span . $link;
                if ($subCatPostCount > 0 || $showPosts) {
                    $collapsCatText .= "\n     <div id='{$theID}'" . " style=\"display:{$expanded}\">\n";
                }
            }
            if ($showPosts) {
                if ($subCatPostCount > 0 && $subCatLinks != '' && $addMisc) {
                    $posttext = miscPosts($cat, $catlink, $subCatPostCount2, $posttext);
                }
            }
            /* we only actually add the posts if it is expanded. Otherwise we add
               the posts dynamically to the dom from a javascript array 
               However, we can't have an empty ul, so we create one emtpy li here */
            if ($postsBeforeCats) {
                $text = $posttext . $subCatLinks;
            } else {
                $text = $subCatLinks . $posttext;
            }
            if ($theID != '' && !$collapsCatItems[$theID]) {
                $collapsCatItems[$theID] = "<ul>{$text}</ul>";
            }
            if ($expanded != 'block' && $showTopLevel && $showPosts) {
                $posttext = '';
            }
            if ($postsBeforeCats) {
                $text = $posttext . $subCatLinks;
            } else {
                $text = $subCatLinks . $posttext;
            }
            if ($text != '') {
                $collapsCatText .= "<ul>{$text}</ul>";
            }
            if ($showTopLevel) {
                if ($subCatPostCount > 0 || $showPosts) {
                    $collapsCatText .= "        </div>\n";
                }
                $collapsCatText .= "      </li> <!-- ending category -->\n";
            }
        }
        // end if theCount>0
    }
    return array($collapsCatText, $postsInCat);
}
コード例 #4
0
ファイル: left_side.php プロジェクト: asimriaz85/elaxy
	<section class="search-ad" >

    <!--<img src="images/web_protection-128.png" />-->

    <br />

  <div class="clear"></div>

    <?php 
if (isset($sub_cat_id)) {
    $select_par = "SELECT parent_off,name,id FROM categories WHERE id='" . $sub_cat_id . "' order by name asc";
    $run_par = mysql_query($select_par);
    $fetch_par = mysql_fetch_array($run_par);
    $parent_d = $fetch_par['parent_off'];
    $name = ucfirst($fetch_par['name']);
    $safid = get_sub_cat($sub_cat_id);
    //$tipids=get_sub_cat();
    $select_tips = "SELECT * FROM safity_tipds WHERE cat_id IN (" . $safid . ")";
    $run_tips = mysql_query($select_tips);
    $num_rows = mysql_num_rows($run_tips);
    $fetch_tips = mysql_fetch_array($run_tips);
    if ($num_rows > 0) {
        ?>

    

    <div style="color:#FFF; font-size:16px; margin-bottom:15px;"><?php 
        echo $name . " " . "Safity Tips";
        ?>
</div>
コード例 #5
0
ファイル: artic_function.php プロジェクト: GHubgenius/qbbj
function get_all_cat($fid)
{
    global $db, $pre;
    $query = $db->query("SELECT * FROM {$pre}sort WHERE fup=0");
    while ($rs = $db->fetch_array($query)) {
        $listdb[] = $rs;
    }
    foreach ($listdb as $key => $row) {
        $curpid = get_parent_id($fid);
        $pid = get_parent_id($row['fid']);
        $ishighlight = $curpid == $pid ? 1 : 0;
        $arr[$key] = array('pid' => $pid, 'fid' => $row['fid'], 'name' => $row['name'], 'sid' => get_sub_cat($row['fid']), 'ishighlight' => $ishighlight);
    }
    return $arr;
}
コード例 #6
0
<div id="contant_area">

  <?php 
$df = 'main_cat_id';
$urlids = get_sub_cat($sub_cat_id);
function get_lan_lat($postcode = '')
{
    $postcode = str_replace(" ", "+", $postcode);
    $url = "http://maps.googleapis.com/maps/api/geocode/xml?address=" . $postcode . "+UK&sensor=false";
    $result = simplexml_load_file($url);
    if (!empty($result->result->geometry->location)) {
        $lat = get_object_vars($result->result->geometry->location);
    } else {
        $lat = array(0, 0);
    }
    return $lat;
}
// end of function
function get_top($id)
{
    do {
        $query = mysql_query("select * from categories where id={$id}");
        $rs = mysql_fetch_array($query);
        $arr[] = $rs['id'] . '|' . $rs['name'] . '|' . $rs['cat_url'];
        $id = $rs['parent_off'];
    } while ($rs != 0);
    krsort($arr);
    // end($arr);
    foreach ($arr as $key => $list) {
        $ex = explode("|", $list);
        $ex[0] . "<br>";
コード例 #7
0
ファイル: test.php プロジェクト: asimriaz85/elaxy
                // get all the sub cats of current id
                $ids = get_sub_cat($res1['id']);
                // end of getting all sub cats
                $sqlcount = "select count(id) from  `postcode_location` WHERE main_cat_id IN (" . $ids . ")";
                $rscount = mysql_query($sqlcount);
                $rescount = mysql_fetch_array($rscount);
                // end cout
                echo '<li><a style="margin-left:10px;" href="test.php?url=' . $res1['cat_url'] . '">' . $res1['name'] . ' id = ' . $res1['id'] . '</a> (' . $rescount[0] . ') </li>';
            }
            echo '</ul></li>';
        }
    }
} else {
    echo '<ul>';
    foreach ($main as $key => $m) {
        $ids = get_sub_cat($key);
        $sqlcount = "select count(id) from  `postcode_location` WHERE main_cat_id IN (" . $ids . ")";
        $rscount = mysql_query($sqlcount);
        $rescount = mysql_fetch_array($rscount);
        echo '<li>' . $m . '(' . $rescount[0] . ') </li>';
    }
    echo '</ul>';
}
function get_sub_cat($id = 0)
{
    $ids = $id;
    // Add this line to the function
    $res_ids[] = $ids;
    do {
        $subsql = "select id from `categories` where parent_off IN (" . $ids . ") ";
        $subrs = mysql_query($subsql);
コード例 #8
0
ファイル: functions.php プロジェクト: nmpetkov/ZphpBB2
function get_cat($cat_id)
{
    global $db;
    // phpBB 2.0.9
    $category_rows = array();
    //
    if ($cat_id <= 0) {
        $cat_id = -1;
    }
    if ($cat_id > 0) {
        $sql = "SELECT * FROM " . CATEGORIES_TABLE . " WHERE cat_id={$cat_id}";
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not query this categories', '', __LINE__, __FILE__, $sql);
        }
        if (!($row = $db->sql_fetchrow($result))) {
            $cat_id = -1;
        }
    }
    //
    // no cat selected : get all
    if ($cat_id <= 0) {
        //-- v 1.0.5
        $sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order";
        //--
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
        }
        while ($row = $db->sql_fetchrow($result)) {
            $category_rows[] = $row;
        }
    }
    //
    // a cat selected : get it and its sub-cats
    if ($cat_id > 0) {
        // add the current one
        $catrow[] = $row;
        // get sub-cats
        $catrow = get_sub_cat($cat_id, $catrow);
        // get cats
        //-- v 1.0.5
        $sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order";
        //--
        if (!($result = $db->sql_query($sql))) {
            message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
        }
        while ($row = $db->sql_fetchrow($result)) {
            $found = false;
            for ($i = 0; $i < count($catrow) && !$found; $i++) {
                $found = $row['cat_id'] == $catrow[$i]['cat_id'];
            }
            if ($found) {
                $category_rows[] = $row;
            }
        }
    }
    return $category_rows;
}
コード例 #9
0
echo get_aktiv_layout_data(layout_path);
?>
images/dicpic.jpg"></div>
<div id="cat_item_right">
<a href="<?php 
echo $page_url . "/" . $get_cat['alias'];
?>
/2.html" class="link"><strong><?php 
echo $get_cat['titel'];
?>
</strong></a> (<?php 
echo $alllinksincat;
?>
)<br />
<div id="prew_sub_cats"><?php 
echo get_sub_cat($get_cat_id);
?>
...</div></div>
</div>
<?
echo $tab_br;
}
?>
</div>

<br clear="left"><br>

<div id="cont_box">
<?php 
echo $p_content;
?>