function b_wp_recent_posts_show($options, $wp_num = "")
 {
     $no_posts = empty($options[0]) ? 10 : $options[0];
     $cat_date = empty($options[1]) ? 0 : $options[1];
     $show_rss_icon = empty($options[2]) ? 0 : $options[2];
     $show_rdf_icon = empty($options[3]) ? 0 : $options[3];
     $show_rss2_icon = empty($options[4]) ? 0 : $options[4];
     $show_atom_icon = empty($options[5]) ? 0 : $options[5];
     $rss_num = empty($options[6]) ? "" : $options[6];
     $category = empty($options[7]) ? "all" : $options[7];
     $new_flg = empty($options[8]) ? 0 : $options[8];
     //	echo "$wp_num:$cat_date";
     global $xoopsDB;
     global $wpdb, $siteurl, $wp_id, $wp_inblock, $use_cache, $wp_mod, $wp_base;
     $id = 1;
     $use_cache = 1;
     if ($wp_num == "") {
         $wp_id = $wp_num;
         $wp_inblock = 1;
         require dirname(__FILE__) . '/../wp-config.php';
         $wp_inblock = 0;
     }
     if (empty($category) || $category == 'all' || $category == '0') {
         $whichcat = '';
         $join = '';
         $cat_param = '';
     } else {
         $join = " LEFT JOIN {$wpdb->post2cat[$wp_id]} ON ({$wpdb->posts[$wp_id]}.ID = {$wpdb->post2cat[$wp_id]}.post_id) ";
         $whichcat = ' AND (category_id = ' . $category . ')';
         $cat_param = 'cat=' . $category;
     }
     $now = date('Y-m-d H:i:s', time() + get_settings('time_difference') * 3600);
     $request = "SELECT * FROM " . $xoopsDB->prefix("wp{$wp_num}_posts") . $join . " WHERE post_status = 'publish' ";
     $request .= " AND post_date <= '" . $now . "'" . $whichcat;
     $request .= " ORDER BY post_date DESC LIMIT 0, {$no_posts}";
     $lposts = $wpdb->get_results($request);
     $date = "";
     $pdate = "";
     ob_start();
     block_style_get($wp_num);
     $output = ob_get_contents();
     ob_end_clean();
     $output .= "<div id='wpRecentPost'>";
     if ($lposts) {
         if (!$cat_date) {
             $output .= "<ul class='wpBlockList'>\n";
         } else {
             $output .= "<ul class='wpBlockDateList'>\n";
         }
         foreach ($lposts as $lpost) {
             if ($cat_date) {
                 $date = mysql2date("Y-n-j", $lpost->post_date);
                 if ($date != $pdate) {
                     if ($pdate != "") {
                         $output .= "</ul>\n";
                     }
                     $output .= "<li><span id=\"postDate\">" . $date . "</span></li>\n<ul class=\"children\">\n";
                     $pdate = $date;
                 }
             }
             $newstr = "";
             if ($new_flg) {
                 $m = $lpost->post_date;
                 $elapse = time() + get_settings('time_difference') * 3600 - mktime(substr($m, 11, 2), substr($m, 14, 2), substr($m, 17, 2), substr($m, 5, 2), substr($m, 8, 2), substr($m, 0, 4));
                 if ($elapse < 1 * 60 * 60 * 24) {
                     $newstr = ' <span class="new1">New!</span>';
                 } else {
                     if ($elapse < 7 * 60 * 60 * 24) {
                         $newstr = ' <span class="new2">New</span>';
                     } else {
                         $newstr = '';
                     }
                 }
             }
             $post_title = stripslashes($lpost->post_title);
             if (trim($post_title) == "") {
                 $post_title = _WP_POST_NOTITLE;
             }
             $permalink = get_permalink($lpost->ID);
             $output .= '<li><span class="post-title"><a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . $post_title . '">' . $post_title . '</a></span>' . $newstr . '<br />';
             $output .= "</li>\n";
         }
         $output .= "</ul>\n";
         if ($cat_date) {
             $output .= "</ul>\n";
         }
     }
     if ($show_rss_icon || $show_rdf_icon || $show_rss2_icon || $show_atom_icon) {
         $output .= '<hr width="100%" />';
     }
     $feed_param = $rss_num ? "?num=" . $rss_num : "";
     /*
     		if ($feed_param != "") {
     			$feed_param .= $cat_param ? "&".$cat_param : "";
     		} else {
     			$feed_param = $cat_param ? "?".$cat_param : "";
     		}
     */
     if (empty($category) || $category == 'all' || $category == '0') {
         if ($show_rss_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_bloginfo('rss_url') . $feed_param . '"><img src="' . XOOPS_URL . '/modules/wordpress' . $wp_num . '/wp-images/rss.gif" /></a></div>';
         }
         if ($show_rdf_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_bloginfo('rdf_url') . $feed_param . '"><img src="' . XOOPS_URL . '/modules/wordpress' . $wp_num . '/wp-images/rdf.gif" /></a></div>';
         }
         if ($show_rss2_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_bloginfo('rss2_url') . $feed_param . '"><img src="' . XOOPS_URL . '/modules/wordpress' . $wp_num . '/wp-images/rss2.gif" /></a></div>';
         }
         if ($show_atom_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_bloginfo('atom_url') . $feed_param . '"><img src="' . XOOPS_URL . '/modules/wordpress' . $wp_num . '/wp-images/atom.gif" /></a></div>';
         }
     } else {
         if ($show_rss_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_category_rss_link(false, $category, "", 'rss') . $feed_param . '"><img src="' . XOOPS_URL . '/modules/wordpress' . $wp_num . '/wp-images/rss.gif" /></a></div>';
         }
         if ($show_rdf_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_category_rss_link(false, $category, "", 'rdf') . $feed_param . '"><img src="' . XOOPS_URL . '/modules/wordpress' . $wp_num . '/wp-images/rss.gif" /></a></div>';
         }
         if ($show_rss2_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_category_rss_link(false, $category, "", 'rss2') . $feed_param . '"><img src="' . XOOPS_URL . '/modules/wordpress' . $wp_num . '/wp-images/rss.gif" /></a></div>';
         }
         if ($show_atom_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_category_rss_link(false, $category, "", 'atom') . $feed_param . '"><img src="' . XOOPS_URL . '/modules/wordpress' . $wp_num . '/wp-images/rss.gif" /></a></div>';
         }
     }
     $output .= "</div>";
     $block['content'] = $output;
     return $block;
 }
Example #2
0
    ?>
            
				<?php 
    if (is_category()) {
        ?>
                <span class="archive_header"><span class="fl cat"><?php 
        _e('Archive', 'woothemes');
        ?>
 | <?php 
        echo single_cat_title();
        ?>
</span> <span class="fr catrss"><?php 
        $cat_obj = $wp_query->get_queried_object();
        $cat_id = $cat_obj->cat_ID;
        echo '<a href="';
        get_category_rss_link(true, $cat, '');
        echo '">' . __('RSS feed for this section', 'woothemes') . '</a>';
        ?>
</span></span>        
            
                <?php 
    } elseif (is_day()) {
        ?>
                <span class="archive_header"><?php 
        _e('Archive', 'woothemes');
        ?>
 | <?php 
        the_time(get_option('date_format'));
        ?>
</span>
    
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children = FALSE, $child_of = 0, $categories = 0, $recurse = 0, $feed = '', $feed_image = '', $exclude = '', $hierarchical = FALSE)
{
    global $wpdb, $category_posts;
    // Optiondates now works
    if ('' == $file) {
        $file = get_settings('home') . '/';
    }
    $exclusions = '';
    if (!empty($exclude)) {
        $excats = preg_split('/[\\s,]+/', $exclude);
        if (count($excats)) {
            foreach ($excats as $excat) {
                $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
            }
        }
    }
    $exclusions = apply_filters('list_cats_exclusions', $exclusions);
    if (intval($categories) == 0) {
        $sort_column = 'cat_' . $sort_column;
        $query = "\n\t\t\tSELECT cat_ID, cat_name, category_nicename, category_description, category_parent\n\t\t\tFROM {$wpdb->categories}\n\t\t\tWHERE cat_ID > 0 {$exclusions}\n\t\t\tORDER BY {$sort_column} {$sort_order}";
        $categories = $wpdb->get_results($query);
    }
    if (!count($category_posts)) {
        $now = current_time('mysql', 1);
        $cat_counts = $wpdb->get_results("\tSELECT cat_ID,\n\t\tCOUNT({$wpdb->post2cat}.post_id) AS cat_count\n\t\tFROM {$wpdb->categories}\n\t\tINNER JOIN {$wpdb->post2cat} ON (cat_ID = category_id)\n\t\tINNER JOIN {$wpdb->posts} ON (ID = post_id)\n\t\tWHERE post_status = 'publish'\n\t\tAND post_date_gmt < '{$now}' {$exclusions}\n\t\tGROUP BY category_id");
        if (!empty($cat_counts)) {
            foreach ($cat_counts as $cat_count) {
                if (1 != intval($hide_empty) || $cat_count > 0) {
                    $category_posts["{$cat_count->cat_ID}"] = $cat_count->cat_count;
                }
            }
        }
    }
    if ($optiondates) {
        $cat_dates = $wpdb->get_results("\tSELECT category_id,\n\t\tUNIX_TIMESTAMP( MAX(post_date) ) AS ts\n\t\tFROM {$wpdb->posts}, {$wpdb->post2cat}\n\t\tWHERE post_status = 'publish' AND post_id = ID {$exclusions}\n\t\tGROUP BY category_id");
        foreach ($cat_dates as $cat_date) {
            $category_timestamp["{$cat_date->category_id}"] = $cat_date->ts;
        }
    }
    $num_found = 0;
    $thelist = "";
    foreach ($categories as $category) {
        if ((intval($hide_empty) == 0 || isset($category_posts["{$category->cat_ID}"])) && (!$hierarchical || $category->category_parent == $child_of)) {
            $num_found++;
            $link = '<a href="' . get_category_link($category->cat_ID) . '" ';
            if ($use_desc_for_title == 0 || empty($category->category_description)) {
                $link .= 'title="' . sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
            } else {
                $link .= 'title="' . wp_specialchars(apply_filters('category_description', $category->category_description, $category)) . '"';
            }
            $link .= '>';
            $link .= apply_filters('list_cats', $category->cat_name, $category) . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . $feed . '"';
                    $alt = ' alt="' . $feed . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src='{$feed_image}' {$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if (intval($optioncount) == 1) {
                $link .= ' (' . intval($category_posts["{$category->cat_ID}"]) . ')';
            }
            if ($optiondates) {
                if ($optiondates == 1) {
                    $optiondates = 'Y-m-d';
                }
                $link .= ' ' . gmdate($optiondates, $category_timestamp["{$category->cat_ID}"]);
            }
            if ($list) {
                $thelist .= "\t<li>{$link}\n";
            } else {
                $thelist .= "\t{$link}<br />\n";
            }
            if ($hierarchical && $children) {
                $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical);
            }
            if ($list) {
                $thelist .= "</li>\n";
            }
        }
    }
    if (!$num_found && !$child_of) {
        if ($list) {
            $before = '<li>';
            $after = '</li>';
        }
        echo $before . __("No categories") . $after . "\n";
        return;
    }
    if ($list && $child_of && $num_found && $recurse) {
        $pre = "\t\t<ul class='children'>";
        $post = "\t\t</ul>\n";
    } else {
        $pre = $post = '';
    }
    $thelist = $pre . $thelist . $post;
    if ($recurse) {
        return $thelist;
    }
    echo apply_filters('list_cats', $thelist);
}
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) {
	global $wpdb, $wp_query;
	// Optiondates now works
	if ( '' == $file )
		$file = get_settings('home') . '/';

	$exclusions = '';
	if ( !empty($exclude) ) {
		$excats = preg_split('/[\s,]+/',$exclude);
		if ( count($excats) ) {
			foreach ( $excats as $excat ) {
				$exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
			}
		}
	}

	$exclusions = apply_filters('list_cats_exclusions', $exclusions );

	if ( intval($categories) == 0 ) {
		$sort_column = 'cat_'.$sort_column;

		$query = "
			SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, category_count
			FROM $wpdb->categories
			WHERE cat_ID > 0 $exclusions
			ORDER BY $sort_column $sort_order";

		$categories = $wpdb->get_results($query);
	}

	if ( $optiondates ) {
		$cat_dates = $wpdb->get_results("	SELECT category_id,
		UNIX_TIMESTAMP( MAX(post_date) ) AS ts
		FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
		WHERE post_status = 'publish' AND post_id = ID $exclusions
		GROUP BY category_id");
		foreach ( $cat_dates as $cat_date ) {
			$category_timestamp["$cat_date->category_id"] = $cat_date->ts;
		}
	}

	$num_found=0;
	$thelist = "";

	foreach ( (array) $categories as $category ) {
		if ( ( intval($hide_empty) == 0 || $category->category_count) && (!$hierarchical || $category->category_parent == $child_of) ) {
			$num_found++;
			$link = '<a href="'.get_category_link($category->cat_ID).'" ';
			if ( $use_desc_for_title == 0 || empty($category->category_description) )
				$link .= 'title="'. sprintf(__("View all posts filed under %s"), attribute_escape($category->cat_name)) . '"';
			else
				$link .= 'title="' . attribute_escape(apply_filters('category_description',$category->category_description,$category)) . '"';
			$link .= '>';
			$link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';

			if ( (! empty($feed_image)) || (! empty($feed)) ) {

				$link .= ' ';

				if ( empty($feed_image) )
					$link .= '(';

				$link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';

				if ( !empty($feed) ) {
					$title = ' title="' . $feed . '"';
					$alt = ' alt="' . $feed . '"';
					$name = $feed;
					$link .= $title;
				}

				$link .= '>';

				if ( !empty($feed_image) )
					$link .= "<img src='$feed_image' $alt$title" . ' />';
				else
					$link .= $name;

				$link .= '</a>';

				if (empty($feed_image))
					$link .= ')';
			}

			if ( intval($optioncount) == 1 )
				$link .= ' ('.intval($category->category_count).')';

			if ( $optiondates ) {
				if ( $optiondates == 1 )
					$optiondates = 'Y-m-d';
				$link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]);
			}

			if ( $list ) {
				$thelist .= "\t<li";
				if (($category->cat_ID == $wp_query->get_queried_object_id()) && is_category()) {
					$thelist .=  ' class="current-cat"';
				}
				$thelist .= ">$link\n";
			} else {
				$thelist .= "\t$link<br />\n";
			}

			if ($hierarchical && $children)
				$thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical);
			if ($list)
				$thelist .= "</li>\n";
		}
	}
	if ( !$num_found && !$child_of ) {
		if ( $list ) {
			$before = '<li>';
			$after = '</li>';
		}
		echo $before . __("No categories") . $after . "\n";
		return;
	}
	if ( $list && $child_of && $num_found && $recurse ) {
		$pre = "\t\t<ul class='children'>";
		$post = "\t\t</ul>\n";
	} else {
		$pre = $post = '';
	}
	$thelist = $pre . $thelist . $post;
	if ( $recurse )
		return $thelist;
	echo apply_filters('list_cats', $thelist);
}
Example #5
0
function wswwpx_list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children = FALSE, $child_of = 0, $categories = 0, $recurse = 0, $feed = '', $feed_image = '', $exclude = '', $hierarchical = FALSE, $cut_desc = '')
{
    global $wpdb, $category_posts, $wp_query, $myLastCat;
    $myLastCat = $current_cat;
    //	Added for folding functionality... fix for permalink compatibility and modified after further suggestion from Laurence O.
    if (is_category()) {
        $current_cat = $wp_query->get_queried_object_id();
        $all_ancestors = _wswwpx_category_get_ancestor_ids($current_cat);
    } elseif (is_single()) {
        //
        //	Default to zero for all other cases.
        //$current_cat = $myLastCat;
        //	$category->cat_ID = $myLastCat;
        $all_ancestors = _wswwpx_category_get_ancestor_ids($myLastCat);
    } else {
        //
        //	Default to zero for all other cases.
        //$current_cat = $myLastCat;
        //	$category->cat_ID = $myLastCat;
        $all_ancestors[] = 0;
    }
    /*//	Old version... replaced by above for greater compatibility with WP CORE
    		if (isset($_GET['category_name'])) {
    			$all_ancestors = _wswwpx_category_get_ancestor_ids($_GET['category_name']);
    		} else if (isset($_GET['cat'])) {
    			$all_ancestors = _wswwpx_category_get_ancestor_ids($_GET['cat']);
    		} else {
    			//
    			//	Default to zero for all other cases.
    			//
    			$all_ancestors[] = 0;
    		} */
    //	End add
    // Optiondates now works
    if ('' == $file) {
        $file = get_settings('home') . '/';
    }
    $exclusions = '';
    if (!empty($exclude)) {
        $excats = preg_split('/[\\s,]+/', $exclude);
        if (count($excats)) {
            foreach ($excats as $excat) {
                $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
            }
        }
    }
    $exclusions = apply_filters('list_cats_exclusions', $exclusions);
    if (intval($categories) == 0) {
        $sort_column = 'cat_' . $sort_column;
        $query = "\r\n   \t\t\tSELECT cat_ID, cat_name, category_nicename, category_description, category_parent\r\n   \t\t\tFROM {$wpdb->categories}\r\n   \t\t\tWHERE cat_ID > 0 {$exclusions}\r\n   \t\t\tORDER BY {$sort_column} {$sort_order}";
        $categories = $wpdb->get_results($query);
    }
    if (!count($category_posts)) {
        $now = current_time('mysql', 1);
        $cat_counts = $wpdb->get_results("\tSELECT cat_ID,\r\n   \t\tCOUNT({$wpdb->post2cat}.post_id) AS cat_count\r\n   \t\tFROM {$wpdb->categories} \r\n   \t\tINNER JOIN {$wpdb->post2cat} ON (cat_ID = category_id)\r\n   \t\tINNER JOIN {$wpdb->posts} ON (ID = post_id)\r\n   \t\tWHERE post_status = 'publish'\r\n   \t\tAND post_date_gmt < '{$now}' {$exclusions}\r\n   \t\tGROUP BY category_id");
        if (!empty($cat_counts)) {
            foreach ($cat_counts as $cat_count) {
                if (1 != intval($hide_empty) || $cat_count > 0) {
                    $category_posts["{$cat_count->cat_ID}"] = $cat_count->cat_count;
                }
            }
        }
    }
    if ($optiondates) {
        $cat_dates = $wpdb->get_results("\tSELECT category_id,\r\n   \t\tUNIX_TIMESTAMP( MAX(post_date) ) AS ts\r\n   \t\tFROM {$wpdb->posts}, {$wpdb->post2cat}\r\n   \t\tWHERE post_status = 'publish' AND post_id = ID {$exclusions}\r\n   \t\tGROUP BY category_id");
        foreach ($cat_dates as $cat_date) {
            $category_timestamp["{$cat_date->category_id}"] = $cat_date->ts;
        }
    }
    $num_found = 0;
    $thelist = "";
    foreach ($categories as $category) {
        if ((intval($hide_empty) == 0 || isset($category_posts["{$category->cat_ID}"])) && (!$hierarchical || $category->category_parent == $child_of)) {
            $num_found++;
            $link = '<a href="' . get_category_link($category->cat_ID) . '" ';
            if ($use_desc_for_title == 0 || empty($category->category_description)) {
                $link .= 'title="' . sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
            } else {
                //
                //	WSW change to allow for truncated descriptions within link titles.
                //
                //   				$link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category)) . '"';
                $link .= 'title="' . wp_specialchars(wswwpx_category_description($category, $cut_desc, 0)) . '"';
            }
            $link .= '>';
            $link .= apply_filters('list_cats', $category->cat_name, $category) . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . $feed . '"';
                    $alt = ' alt="' . $feed . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src='{$feed_image}' {$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if (intval($optioncount) == 1) {
                $link .= ' (' . intval($category_posts["{$category->cat_ID}"]) . ')';
            }
            if ($optiondates) {
                if ($optiondates == 1) {
                    $optiondates = 'Y-m-d';
                }
                $link .= ' ' . gmdate($optiondates, $category_timestamp["{$category->cat_ID}"]);
            }
            if ($list) {
                $css_class = 'page_item';
                /////////////
                //if(!empty ($childs))  $category_posts["$category->cat_ID"]
                if ($current_cat == $category->cat_ID) {
                    $css_class .= ' current_page_item';
                    //	setcookie("wpLastCategory", $current_cat);
                } else {
                    if (in_array($category->cat_ID, $all_ancestors)) {
                        $css_class .= ' current_page_ancestor';
                    }
                }
                //////////////
                $thelist .= "<li class=\"" . $css_class . "\" >{$link}";
                //added class by Georg Leciejewski
            } else {
                $thelist .= "{$link}<br />\n";
            }
            //	Extra 'if' added for folding functionality recursion um children anzuhängen
            if (in_array($category->cat_ID, $all_ancestors)) {
                if ($hierarchical && $children) {
                    $thelist .= wswwpx_list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical);
                }
            }
            //	End add
            if ($list) {
                $thelist .= "</li>\n";
            }
        }
    }
    if (!$num_found && !$child_of) {
        if ($list) {
            $before = '<li>';
            $after = '</li>';
        }
        echo $before . __("No categories") . $after . "\n";
        return;
    }
    if ($list && $child_of && $num_found && $recurse) {
        $pre = "\n<ul>\n";
        // changed from childeren to class current_page_item georg leciejewski
        $post = "</ul>\n";
    } else {
        $pre = $post = '';
    }
    $thelist = $pre . $thelist . $post;
    if ($recurse) {
        return $thelist;
    }
    echo apply_filters('list_cats', $thelist);
}
 function _b_wp_recent_posts_show($options, $wp_num = "")
 {
     $no_posts = empty($options[0]) ? 10 : $options[0];
     $cat_date = empty($options[1]) ? 0 : $options[1];
     $show_rss_icon = empty($options[2]) ? 0 : $options[2];
     $show_rdf_icon = empty($options[3]) ? 0 : $options[3];
     $show_rss2_icon = empty($options[4]) ? 0 : $options[4];
     $show_atom_icon = empty($options[5]) ? 0 : $options[5];
     $rss_num = empty($options[6]) ? "" : $options[6];
     $category = intval(empty($options[7]) ? "all" : $options[7]);
     $new_flg = empty($options[8]) ? 0 : $options[8];
     $tpl_file = empty($options[9]) ? 'wp_recent_posts.html' : $options[9];
     $new1_span = 1 * 60 * 60 * 24;
     $new2_span = 7 * 60 * 60 * 24;
     if (empty($category) || $category == 'all' || $category == '0') {
         $whichcat = '';
         $join = '';
         $cat_param = '';
     } else {
         $join = ' LEFT JOIN ' . wp_table('post2cat') . ' ON (' . wp_table('posts') . '.ID = ' . wp_table('post2cat') . '.post_id) ';
         $whichcat = ' AND (category_id = ' . $category . ')';
         $cat_param = 'cat=' . $category;
     }
     $now = current_time('mysql');
     $request = 'SELECT * FROM ' . wp_table('posts') . $join . ' WHERE post_status = \'publish\'';
     $request .= ' AND post_date <= \'' . $now . '\'' . $whichcat;
     $request .= ' ORDER BY post_date DESC LIMIT 0, ' . $no_posts;
     $lposts = $GLOBALS['wpdb']->get_results($request);
     $date = "";
     $pdate = "";
     $block['style'] = block_style_get(false);
     $block['divid'] = 'wpRecentPost' . $wp_num . '_' . $category;
     $block['cat_date'] = $cat_date;
     $block['records'] = array();
     if ($lposts) {
         foreach ($lposts as $lpost) {
             if ($cat_date) {
                 $date = mysql2date('Y-n-j', $lpost->post_date);
                 if ($date != $pdate) {
                     $_record['date'] = $date;
                     $_record['pdate'] = $pdate;
                     $pdate = $date;
                 } else {
                     $_record['date'] = '';
                 }
             }
             $_record['new'] = 0;
             $_record['newstr'] = '';
             if ($new_flg) {
                 $m = $lpost->post_date;
                 $elapse = current_time('timestamp') - mktime(substr($m, 11, 2), substr($m, 14, 2), substr($m, 17, 2), substr($m, 5, 2), substr($m, 8, 2), substr($m, 0, 4));
                 if ($elapse < $new1_span) {
                     $_record['new'] = 1;
                     $_record['newstr'] = ' <span class="new1">New!</span>';
                 } else {
                     if ($elapse < $new2_span) {
                         $_record['new'] = 2;
                         $_record['newstr'] = ' <span class="new2">New</span>';
                     } else {
                         $_record['new'] = 0;
                         $_record['newstr'] = '';
                     }
                 }
             }
             $_record['post_title'] = htmlspecialchars($lpost->post_title);
             $_record['post_author'] = htmlspecialchars(get_author_name($lpost->post_author));
             if (trim($_record['post_title']) == '') {
                 $_record['post_title'] = _WP_POST_NOTITLE;
             }
             $_record['permalink'] = get_permalink($lpost->ID);
             $block['records'][] = $_record;
         }
     }
     $feed_param = $rss_num ? "?num=" . $rss_num : "";
     $block['feed_icons'] = array();
     if (empty($category) || $category == 'all' || $category == '0') {
         if ($show_rss_icon) {
             $block['feed_icons'][] = array('url' => get_bloginfo('rss_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss.gif', 'alt' => 'rss');
         }
         if ($show_rdf_icon) {
             $block['feed_icons'][] = array('url' => get_bloginfo('rdf_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rdf.gif', 'alt' => 'rdf');
         }
         if ($show_rss2_icon) {
             $block['feed_icons'][] = array('url' => get_bloginfo('rss2_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss2.gif', 'alt' => 'rss2');
         }
         if ($show_atom_icon) {
             $block['feed_icons'][] = array('url' => get_bloginfo('atom_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/atom.gif', 'alt' => 'atom');
         }
     } else {
         if ($show_rss_icon) {
             $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rss') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss.gif', 'alt' => 'rss');
         }
         if ($show_rdf_icon) {
             $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rdf') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rdf.gif', 'alt' => 'rdf');
         }
         if ($show_rss2_icon) {
             $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rss2') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss2.gif', 'alt' => 'rss2');
         }
         if ($show_atom_icon) {
             $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'atom') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/atom.gif', 'alt' => 'atom');
         }
     }
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     if (!$_wpTpl->tpl_exists($tpl_file)) {
         $tpl_file = 'wp_recent_posts.html';
     }
     $block['content'] = $_wpTpl->fetch($tpl_file);
     return $block;
 }
 function _b_wp_recent_posts_show($options, $wp_num = "")
 {
     $no_posts = empty($options[0]) ? 10 : $options[0];
     $cat_date = empty($options[1]) ? 0 : $options[1];
     $show_rss_icon = empty($options[2]) ? 0 : $options[2];
     $show_rdf_icon = empty($options[3]) ? 0 : $options[3];
     $show_rss2_icon = empty($options[4]) ? 0 : $options[4];
     $show_atom_icon = empty($options[5]) ? 0 : $options[5];
     $rss_num = empty($options[6]) ? "" : $options[6];
     $category = intval(empty($options[7]) ? "all" : $options[7]);
     $new_flg = empty($options[8]) ? 0 : $options[8];
     global $wpdb;
     if (empty($category) || $category == 'all' || $category == '0') {
         $whichcat = '';
         $join = '';
         $cat_param = '';
     } else {
         $join = ' LEFT JOIN ' . wp_table('post2cat') . ' ON (' . wp_table('posts') . '.ID = ' . wp_table('post2cat') . '.post_id) ';
         $whichcat = ' AND (category_id = ' . $category . ')';
         $cat_param = 'cat=' . $category;
     }
     $now = date('Y-m-d H:i:s', time() + get_settings('time_difference') * 3600);
     $request = 'SELECT * FROM ' . wp_table('posts') . $join . ' WHERE post_status = \'publish\'';
     $request .= ' AND post_date <= \'' . $now . '\'' . $whichcat;
     $request .= ' ORDER BY post_date DESC LIMIT 0, ' . $no_posts;
     $lposts = $wpdb->get_results($request);
     $date = "";
     $pdate = "";
     ob_start();
     block_style_get();
     $output = ob_get_contents();
     ob_end_clean();
     $output .= '<div class="wpRecentPost">';
     if ($lposts) {
         if (!$cat_date) {
             $output .= '<ul class="wpBlockList">' . "\n";
         } else {
             $output .= '<ul class="wpBlockDateList">' . "\n";
         }
         foreach ($lposts as $lpost) {
             if ($cat_date) {
                 $date = mysql2date('Y-n-j', $lpost->post_date);
                 if ($date != $pdate) {
                     if ($pdate != "") {
                         $output .= '</ul></li>' . "\n";
                     }
                     $output .= '<li><span class="postDate">' . $date . '</span>' . "\n" . '<ul class="children">' . "\n";
                     $pdate = $date;
                 }
             }
             $newstr = "";
             if ($new_flg) {
                 $m = $lpost->post_date;
                 $elapse = time() + get_settings('time_difference') * 3600 - mktime(substr($m, 11, 2), substr($m, 14, 2), substr($m, 17, 2), substr($m, 5, 2), substr($m, 8, 2), substr($m, 0, 4));
                 if ($elapse < 1 * 60 * 60 * 24) {
                     $newstr = ' <span class="new1">New!</span>';
                 } else {
                     if ($elapse < 7 * 60 * 60 * 24) {
                         $newstr = ' <span class="new2">New</span>';
                     } else {
                         $newstr = '';
                     }
                 }
             }
             $post_title = stripslashes($lpost->post_title);
             if (trim($post_title) == "") {
                 $post_title = _WP_POST_NOTITLE;
             }
             $permalink = get_permalink($lpost->ID);
             $output .= '<li><span class="post-title"><a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . $post_title . '">' . $post_title . '</a></span>' . $newstr . '<br />';
             $output .= '</li>' . "\n";
         }
         $output .= '</ul>' . "\n";
         if ($cat_date) {
             $output .= '</li></ul>' . "\n";
         }
     }
     if ($show_rss_icon || $show_rdf_icon || $show_rss2_icon || $show_atom_icon) {
         $output .= '<hr width="100%" />';
     }
     $feed_param = $rss_num ? "?num=" . $rss_num : "";
     if (empty($category) || $category == 'all' || $category == '0') {
         if ($show_rss_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_bloginfo('rss_url') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rss.gif" alt="rss" /></a></div>';
         }
         if ($show_rdf_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_bloginfo('rdf_url') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rdf.gif"  alt="rdf" /></a></div>';
         }
         if ($show_rss2_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_bloginfo('rss2_url') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rss2.gif" alt="rss2" /></a></div>';
         }
         if ($show_atom_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_bloginfo('atom_url') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/atom.gif" alt="atom" /></a></div>';
         }
     } else {
         if ($show_rss_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_category_rss_link(false, $category, "", 'rss') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rss.gif" alt="rss"  /></a></div>';
         }
         if ($show_rdf_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_category_rss_link(false, $category, "", 'rdf') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rdf.gif" alt="rdf"  /></a></div>';
         }
         if ($show_rss2_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_category_rss_link(false, $category, "", 'rss2') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rss2.gif" alt="rss2"  /></a></div>';
         }
         if ($show_atom_icon) {
             $output .= '<div style="text-align:right">&nbsp;<a href="' . get_category_rss_link(false, $category, "", 'atom') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/atom.gif"  alt="atom" /></a></div>';
         }
     }
     $output .= "</div>";
     $block['content'] = $output;
     return $block;
 }
	function mw_getCategories($args) {

		global $wpdb;

		$this->escape($args);

		$blog_ID     = $args[0];
		$user_login  = $args[1];
		$user_pass   = $args[2];

		if (!$this->login_pass_ok($user_login, $user_pass)) {
			return $this->error;
		}

		$categories_struct = array();

		// FIXME: can we avoid using direct SQL there?
		if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {
			foreach ($cats as $cat) {
				$struct['categoryId'] = $cat['cat_ID'];
				$struct['description'] = $cat['cat_name'];
				$struct['categoryName'] = $cat['cat_name'];
				$struct['htmlUrl'] = wp_specialchars(get_category_link($cat['cat_ID']));
				$struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name']));

				$categories_struct[] = $struct;
			}
		}

		return $categories_struct;
	}
Example #9
0
 function mw_getCategories($args)
 {
     global $wpdb;
     $this->escape($args);
     $blog_ID = (int) $args[0];
     $user_login = $args[1];
     $user_pass = $args[2];
     if (!$this->login_pass_ok($user_login, $user_pass)) {
         return $this->error;
     }
     $categories_struct = array();
     if ($cats = get_categories('get=all')) {
         foreach ($cats as $cat) {
             $struct['categoryId'] = $cat->term_id;
             $struct['parentId'] = $cat->parent;
             $struct['description'] = $cat->name;
             $struct['categoryName'] = $cat->name;
             $struct['htmlUrl'] = wp_specialchars(get_category_link($cat->term_id));
             $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat->term_id, $cat->name));
             $categories_struct[] = $struct;
         }
     }
     return $categories_struct;
 }
 function start_el($output, $category, $depth, $args)
 {
     extract($args);
     $cat_name = attribute_escape($category->cat_name);
     $cat_name = apply_filters('list_cats', $cat_name, $category);
     $link = '<a href="' . get_category_link($category->cat_ID) . '" ';
     if ($use_desc_for_title == 0 || empty($category->category_description)) {
         $link .= 'title="' . sprintf(__('View all posts filed under %s'), $cat_name) . '"';
     } else {
         $link .= 'title="' . attribute_escape(apply_filters('category_description', $category->category_description, $category)) . '"';
     }
     $link .= '>';
     $link .= $cat_name . '</a>';
     if (!empty($feed_image) || !empty($feed)) {
         $link .= ' ';
         if (empty($feed_image)) {
             $link .= '(';
         }
         $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
         if (empty($feed)) {
             $alt = ' alt="' . sprintf(__('Feed for all posts filed under %s'), $cat_name) . '"';
         } else {
             $title = ' title="' . $feed . '"';
             $alt = ' alt="' . $feed . '"';
             $name = $feed;
             $link .= $title;
         }
         $link .= '>';
         if (empty($feed_image)) {
             $link .= $name;
         } else {
             $link .= "<img src='{$feed_image}'{$alt}{$title}" . ' />';
         }
         $link .= '</a>';
         if (empty($feed_image)) {
             $link .= ')';
         }
     }
     if (isset($show_count) && $show_count) {
         $link .= ' (' . intval($category->category_count) . ')';
     }
     if (isset($show_date) && $show_date) {
         $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
     }
     if ($current_category) {
         $_current_category = get_category($current_category);
     }
     if ('list' == $args['style']) {
         $output .= "\t<li";
         if ($current_category && $category->cat_ID == $current_category) {
             $output .= ' class="current-cat"';
         } elseif ($_current_category && $category->cat_ID == $_current_category->category_parent) {
             $output .= ' class="current-cat-parent"';
         }
         $output .= ">{$link}\n";
     } else {
         $output .= "\t{$link}<br />\n";
     }
     return $output;
 }
Example #11
0
	<?php 
if (is_category()) {
    ?>
	<!-- Category Feed -->
	<?php 
    if (have_posts()) {
        the_post();
        ?>
	<link rel="alternate" type="application/rss+xml" title="<?php 
        bloginfo('name');
        ?>
 <?php 
        echo $post->cat_name;
        ?>
 RSS 2.0" href="<? echo get_category_rss_link(0, $cat, $post->cat_name); ?>" />
	<?php 
    }
    rewind_posts();
    ?>
	<?php 
}
?>


	<link rel="pingback" href="<?php 
bloginfo('pingback_url');
?>
" />

	<?php 
 /**
  * Generate current post tags
  *
  * @param string $args
  * @return string
  */
 function extendedPostTags($args = '', $copyright = true)
 {
     $defaults = array('before' => __('Tags: ', 'simpletags'), 'separator' => ', ', 'after' => '<br />', 'post_id' => 0, 'no_follow' => 0, 'inc_cats' => 0, 'xformat' => __('<a href="%tag_link%" title="%tag_name%" %tag_rel%>%tag_name%</a>', 'simpletags'), 'notagtext' => __('No tag for this post.', 'simpletags'), 'number' => 0);
     // Get values in DB
     $defaults['no_follow'] = $this->options['no_follow'];
     $defaults['before'] = $this->options['tt_before'];
     $defaults['separator'] = $this->options['tt_separator'];
     $defaults['after'] = $this->options['tt_after'];
     $defaults['notagtext'] = $this->options['tt_notagstext'];
     $defaults['number'] = $this->options['tt_number'];
     $defaults['inc_cats'] = $this->options['tt_inc_cats'];
     $defaults['xformat'] = $this->options['tt_xformat'];
     if (empty($args)) {
         $args = $this->options['tt_adv_usage'];
     }
     $args = wp_parse_args($args, $defaults);
     extract($args);
     // Choose post ID
     $post_id = (int) $post_id;
     if ($post_id != 0) {
         $id = (int) $post_id;
     } else {
         global $post;
         $id = (int) $post->ID;
     }
     // Get categories ?
     $inc_cats = (int) $args['inc_cats'];
     $taxonomy = $inc_cats == 0 ? 'post_tag' : array('post_tag', 'category');
     // Get terms
     $terms = apply_filters('get_the_tags', wp_get_object_terms($id, $taxonomy));
     // If no terms, return text nothing.
     if (empty($terms)) {
         return $notagtext;
     }
     // Limit to max quantity if set
     $number = (int) $number;
     if ($number != 0) {
         $terms = $this->randomArray($terms);
         // Randomize terms
         $terms = array_slice($terms, 0, $number);
     }
     // If empty use default xformat !
     if (empty($xformat)) {
         $xformat = $defaults['xformat'];
     }
     // HTML Rel (tag/no-follow)
     $rel = '';
     global $wp_rewrite;
     $rel .= is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? 'tag' : '';
     // Tag ?
     $no_follow = (int) $no_follow;
     if ($no_follow == 1) {
         // No follow ?
         $rel .= empty($rel) ? 'nofollow' : ' nofollow';
     }
     if (!empty($rel)) {
         $rel = 'rel="' . $rel . '"';
         // Add HTML Tag
     }
     foreach ((array) $terms as $term) {
         $element_loop = $xformat;
         if ($term->taxonomy == 'post_tag') {
             // Tag
             $element_loop = str_replace('%tag_link%', clean_url(get_tag_link($term->term_id)), $element_loop);
             $element_loop = str_replace('%tag_feed%', clean_url(get_tag_feed_link($term->term_id)), $element_loop);
         } else {
             // Category
             $element_loop = str_replace('%tag_link%', clean_url(get_category_link($term->term_id)), $element_loop);
             $element_loop = str_replace('%tag_feed%', clean_url(get_category_rss_link(false, $term->term_id, '')), $element_loop);
         }
         $element_loop = str_replace('%tag_id%', $term->term_id, $element_loop);
         $element_loop = str_replace('%tag_name%', wp_specialchars($term->name), $element_loop);
         $element_loop = str_replace('%tag_rel%', $rel, $element_loop);
         $element_loop = str_replace('%tag_count%', $term->count, $element_loop);
         $element_loop = str_replace('%tag_technorati%', $this->formatLink('technorati', $term->name), $element_loop);
         $element_loop = str_replace('%tag_flickr%', $this->formatLink('flickr', $term->name), $element_loop);
         $element_loop = str_replace('%tag_delicious%', $this->formatLink('delicious', $term->name), $element_loop);
         $output[] = $element_loop;
     }
     unset($terms, $term, $element_loop);
     $output = apply_filters('the_tags', implode($separator, $output));
     if ($copyright === true) {
         return "\n\t" . '<!-- Generated by Simple Tags ' . $this->version . ' - http://wordpress.org/extend/plugins/simple-tags -->' . "\n\t" . $before . $output . $after . "\n";
     } else {
         return "\n\t" . $before . $output . $after . "\n";
     }
 }
 function start_el($output, $category, $depth, $args, $c_width, $c_height)
 {
     extract($args);
     $cat_name = attribute_escape($category->cat_name);
     $hs_link = get_category_link($category->cat_ID);
     $link2 = '<a href="' . get_category_link($category->cat_ID) . '" ';
     if ($use_desc_for_title == 0 || empty($category->category_description)) {
         $hs_text = sprintf(__('View all posts filed under %s'), $cat_name);
         $link2 .= 'title="' . sprintf(__('View all posts filed under %s'), $cat_name) . '"';
     } else {
         $link2 .= 'title="' . attribute_escape(apply_filters('category_description', $category->category_description, $category)) . '"';
     }
     $link2 .= '>';
     $link2 .= apply_filters('list_cats', $category->cat_name, $category) . '</a>';
     // Change for Highslide
     $ping = PT_URLPATH . 'images/pong.png';
     $hs_link = pt_get_effect('hs_newwindow', 'rounded-white', $hs_link, $c_width, $c_height, $category->cat_ID, $hs_text, $ping, '', '', '', __('Category', 'post-thumb') . ' ' . $cat_name);
     $link = $hs_link . ' ' . $link2;
     if (!empty($feed_image) || !empty($feed)) {
         $link .= ' ';
         if (empty($feed_image)) {
             $link .= '(';
         }
         $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '" ';
         if (empty($feed)) {
             $alt = ' alt="' . sprintf(__('Feed for all posts filed under %s'), $cat_name) . '"';
         } else {
             $title = ' title="' . $feed . '"';
             $alt = ' alt="' . $feed . '"';
             $name = $feed;
             $link .= $title;
         }
         $link .= '>';
         if (empty($feed_image)) {
             $link .= $name;
         } else {
             $link .= "<img src='{$feed_image}'{$alt}{$title}" . ' />';
         }
         $link .= '</a>';
         if (empty($feed_image)) {
             $link .= ')';
         }
     }
     if (isset($show_count) && $show_count) {
         $link .= ' (' . intval($category->category_count) . ')';
     }
     if (isset($show_date) && $show_date) {
         $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
     }
     if ($current_category) {
         $_current_category = get_category($current_category);
     }
     if ('list' == $args['style']) {
         $output .= "\t<li";
         if ($current_category && $category->cat_ID == $current_category) {
             $output .= ' class="current-cat"';
         } elseif ($_current_category && $category->cat_ID == $_current_category->category_parent) {
             $output .= ' class="current-cat-parent"';
         }
         $output .= ">{$link}\n";
     } else {
         $output .= "\t{$link}<br />\n";
     }
     return $output;
 }
    function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children = FALSE, $child_of = 0, $categoryObjects = null, $recurse = 0, $feed = '', $feed_image = '', $exclude = '', $hierarchical = FALSE, $echo = true)
    {
        $list_cats = '';
        // Optiondates now works
        if ('' == $file) {
            $file = wp_siteurl() . '/index.php';
        }
        $excludeCriteria = null;
        if (!empty($exclude)) {
            $excats = preg_split('/[\\s,]+/', $exclude);
            if (count($excats)) {
                $excludeCriteria = new CriteriaCompo();
                foreach ($excats as $excat) {
                    $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
                    $excludeCriteria->add(new Criteria('cat_ID', $excat, '!='));
                    $catc = trim(get_category_children($excat, '', ' '));
                    $catc_array = explode(' ', $catc);
                    for ($i = 0; $i < count($catc_array); $i++) {
                        $excludeCriteria->add(new Criteria('category_id', intval($catc_array[$i]), '!='));
                    }
                }
            }
        }
        $categoryHandler =& wp_handler('Category');
        if (!$categoryObjects) {
            $criteria =& new CriteriaCompo(new Criteria('cat_ID', 0, '>'));
            if ($excludeCriteria) {
                $criteria->add($excludeCriteria);
            }
            $criteria->setSort('cat_' . $sort_column);
            $criteria->setOrder($sort_order);
            $categoryObjects =& $categoryHandler->getObjects($criteria, false, 'cat_ID, cat_name, category_nicename, category_description cat_description, category_parent');
        }
        if (empty($GLOBALS['category_posts']) || !count($GLOBALS['category_posts'])) {
            $criteria =& new CriteriaCompo('post_status', 'publish');
            if ($excludeCriteria) {
                $criteria->add($excludeCriteria);
            }
            $criteria->setGroupBy('category_id');
            $joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'cat_ID', 'category_id', 'INNER');
            $joinCriteria->cascade(new XoopsJoinCriteria(wp_table('posts'), 'post_id', 'ID', 'INNER'));
            $categoryPostsObjects =& $categoryHandler->getObjects($criteria, false, 'cat_ID, COUNT(' . wp_table('post2cat') . '.post_id) AS cat_count', false, $joinCriteria);
            if ($categoryPostsObjects) {
                foreach ($categoryPostsObjects as $categoryObject) {
                    if (intval($hide_empty) != 1 || $categoryObject->getExtraVar('cat_count') > 0) {
                        $GLOBALS['category_posts'][$categoryObject->getVar('cat_ID')] = $categoryObject->getExtraVar('cat_count');
                    }
                }
            }
        }
        if (intval($optiondates) == 1) {
            $criteria =& new CriteriaCompo('post_status', 'publish');
            if ($excludeCriteria) {
                $criteria->add($excludeCriteria);
            }
            $criteria->setGroupBy('category_id');
            $joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'cat_ID', 'category_id', 'INNER');
            $joinCriteria->cascade(new XoopsJoinCriteria(wp_table('posts'), 'post_id', 'ID', 'INNER'));
            $categoryDateObjects =& $categoryHandler->getObjects($criteria, false, 'cat_ID, DAYOFMONTH(MAX(post_date)) AS lastday,
		                                                     MONTH(MAX(post_date)) AS lastmonth', false, $joinCriteria);
            foreach ($categoryDateObjects as $categoryObject) {
                $category_lastday["" . $categoryObject->getVar('cat_ID')] = $categoryObject->getExtraVar('lastday');
                $category_lastmonth["" . $categoryObject->getVar('cat_ID')] = $categoryObject->getExtraVar('lastmonth');
            }
        }
        if (intval($optionall) == 1 && !$child_of && $categoryObjects) {
            $all = apply_filters('list_cats', $all);
            $link = "<a href=\"" . $file . '?cat=all">' . $all . "</a>";
            if ($list) {
                $list_cats .= "\n\t<li>{$link}</li>";
            } else {
                $list_cats .= "\t{$link}<br />\n";
            }
        }
        $num_found = 0;
        $thelist = "";
        foreach ($categoryObjects as $categoryObject) {
            $category = $categoryObject->exportWpObject();
            $child_list = '';
            if ((!$hierarchical || $category->category_parent == $child_of) && ($children || $category->category_parent == 0)) {
                if ($hierarchical && $children) {
                    $child_list = list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categoryObjects, 1, $feed, $feed_image, $exclude, $hierarchical);
                }
                if (intval($hide_empty) == 0 || isset($GLOBALS['category_posts']["{$category->cat_ID}"]) || $child_list) {
                    $num_found++;
                    $link = '<a href="' . get_category_link(0, $category->cat_ID, $category->category_nicename) . '" ';
                    if ($use_desc_for_title == 0 || empty($category->cat_description)) {
                        $link .= 'title="' . sprintf("View all posts filed under %s", htmlspecialchars($category->cat_name)) . '"';
                    } else {
                        $link .= 'title="' . htmlspecialchars(strip_tags($category->cat_description)) . '"';
                    }
                    $link .= '>';
                    $link .= apply_filters('list_cats', $category->cat_name) . '</a>';
                    if (!empty($feed_image) || !empty($feed)) {
                        $link .= ' ';
                        if (empty($feed_image)) {
                            $link .= '(';
                        }
                        $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
                        if (!empty($feed)) {
                            $title = ' title="' . $feed . '"';
                            $alt = ' alt="' . $feed . '"';
                            $name = $feed;
                            $link .= $title;
                        }
                        $link .= '>';
                        if (!empty($feed_image)) {
                            $link .= "<img src=\"{$feed_image}\" border=\"0\"{$alt}{$title}" . ' />';
                        } else {
                            $link .= $name;
                        }
                        $link .= '</a>';
                        if (empty($feed_image)) {
                            $link .= ')';
                        }
                    }
                    if (intval($optioncount) == 1) {
                        $link .= ' (' . intval($GLOBALS['category_posts']["{$category->cat_ID}"]) . ')';
                    }
                    if (intval($optiondates) == 1) {
                        $link .= ' ' . $category_lastday["{$category->cat_ID}"] . '/' . $category_lastmonth["{$category->cat_ID}"];
                    }
                    if ($list) {
                        $thelist .= "\t<li>{$link}\n";
                    } else {
                        $thelist .= "\t{$link}<br />\n";
                    }
                    if ($hierarchical && $children) {
                        $thelist .= $child_list;
                    }
                    if ($list) {
                        $thelist .= "</li>\n";
                    }
                }
            }
        }
        if (!$num_found && !$child_of) {
            if ($list) {
                $before = '<li>';
                $after = '</li>';
            }
            return _echo($before . "No categories" . $after . "\n", $echo);
        }
        if ($list && $child_of && $num_found && $recurse) {
            $pre = "\t\t<ul class='children'>";
            $post = "\t\t</ul>\n";
        } else {
            $pre = $post = '';
        }
        $thelist = $pre . $thelist . $post;
        if ($recurse) {
            return $thelist;
        }
        $list_cats .= apply_filters('list_cats', $thelist);
        return _echo($list_cats, $echo);
    }
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children = FALSE, $child_of = 0, $categories = 0, $recurse = 0, $feed = '', $feed_image = '', $exclude = '', $hierarchical = FALSE)
{
    global $wpdb, $category_posts, $wp_id, $siteurl;
    // Optiondates now works
    if ('' == $file) {
        $file = $siteurl . '/index.php';
    }
    $exclusions = '';
    if (!empty($exclude)) {
        $excats = preg_split('/[\\s,]+/', $exclude);
        if (count($excats)) {
            foreach ($excats as $excat) {
                $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
            }
        }
    }
    if (intval($categories) == 0) {
        $sort_column = 'cat_' . $sort_column;
        $query = "\n\t\t\tSELECT cat_ID, cat_name, category_nicename, category_description cat_description, category_parent\n\t\t\tFROM {$wpdb->categories[$wp_id]}\n\t\t\tWHERE cat_ID > 0 {$exclusions}\n\t\t\tORDER BY {$sort_column} {$sort_order}";
        $categories = $wpdb->get_results($query);
    }
    if (!count($category_posts)) {
        $cat_counts = $wpdb->get_results("\tSELECT cat_ID,\n\t\tCOUNT({$wpdb->post2cat[$wp_id]}.post_id) AS cat_count\n\t\tFROM {$wpdb->categories[$wp_id]} \n\t\tINNER JOIN {$wpdb->post2cat[$wp_id]} ON (cat_ID = category_id)\n\t\tINNER JOIN {$wpdb->posts[$wp_id]} ON (ID = post_id)\n\t\tWHERE post_status = 'publish' {$exclusions}\n\t\tGROUP BY category_id");
        if (!empty($cat_counts)) {
            foreach ($cat_counts as $cat_count) {
                if (1 != intval($hide_empty) || $cat_count > 0) {
                    $category_posts["{$cat_count->cat_ID}"] = $cat_count->cat_count;
                }
            }
        }
    }
    if (intval($optiondates) == 1) {
        $cat_dates = $wpdb->get_results("\tSELECT cat_ID,\n\t\tDAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth\n\t\tFROM {$wpdb->categories[$wp_id]} \n\t\tINNER JOIN {$wpdb->post2cat[$wp_id]} ON (cat_ID = category_id)\n\t\tINNER JOIN {$wpdb->posts[$wp_id]} ON (ID = post_id)\n\t\tWHERE post_status = 'publish' {$exclusions}\n\t\tGROUP BY category_id");
        foreach ($cat_dates as $cat_date) {
            $category_lastday["{$cat_date->cat_ID}"] = $cat_date->lastday;
            $category_lastmonth["{$cat_date->cat_ID}"] = $cat_date->lastmonth;
        }
    }
    if (intval($optionall) == 1 && !$child_of && $categories) {
        $all = apply_filters('list_cats', $all);
        $link = "<a href=\"" . $file . '?cat=all">' . $all . "</a>";
        if ($list) {
            echo "\n\t<li>{$link}</li>";
        } else {
            echo "\t{$link}<br />\n";
        }
    }
    $num_found = 0;
    $thelist = "";
    foreach ($categories as $category) {
        if ((intval($hide_empty) == 0 || isset($category_posts["{$category->cat_ID}"])) && (!$hierarchical || $category->category_parent == $child_of) && ($children || $category->category_parent == 0)) {
            $num_found++;
            $link = '<a href="' . get_category_link(0, $category->cat_ID, $category->category_nicename) . '" ';
            if ($use_desc_for_title == 0 || empty($category->category_description)) {
                $link .= 'title="' . sprintf("View all posts filed under %s", htmlspecialchars($category->cat_name)) . '"';
            } else {
                $link .= 'title="' . htmlspecialchars($category->category_description) . '"';
            }
            $link .= '>';
            $link .= apply_filters('list_cats', $category->cat_name) . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . $feed . '"';
                    $alt = ' alt="' . $feed . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src=\"{$feed_image}\" border=\"0\"{$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if (intval($optioncount) == 1) {
                $link .= ' (' . intval($category_posts["{$category->cat_ID}"]) . ')';
            }
            if (intval($optiondates) == 1) {
                $link .= ' ' . $category_lastday["{$category->cat_ID}"] . '/' . $category_lastmonth["{$category->cat_ID}"];
            }
            if ($list) {
                $thelist .= "\t<li>{$link}\n";
            } else {
                $thelist .= "\t{$link}<br />\n";
            }
            if ($hierarchical && $children) {
                $thelist .= list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categories, 1, $feed, $feed_image, $exclude, $hierarchical);
            }
            if ($list) {
                $thelist .= "</li>\n";
            }
        }
    }
    if (!$num_found && !$child_of) {
        if ($list) {
            $before = '<li>';
            $after = '</li>';
        }
        echo $before . "No categories" . $after . "\n";
        return;
    }
    if ($list && $child_of && $num_found && $recurse) {
        $pre = "\t\t<ul class='children'>";
        $post = "\t\t</ul>\n";
    } else {
        $pre = $post = '';
    }
    $thelist = $pre . $thelist . $post;
    if ($recurse) {
        return $thelist;
    }
    echo apply_filters('list_cats', $thelist);
}
	/**
	 * Remplace marker by dynamic values (use for related tags, current tags and tag cloud)
	 *
	 * @param string $element_loop
	 * @param object $term
	 * @param string $rel
	 * @param integer $scale_result
	 * @param integer $scale_max
	 * @param integer $scale_min
	 * @param integer $largest
	 * @param integer $smallest
	 * @param string $unit
	 * @param string $maxcolor
	 * @param string $mincolor
	 * @return string
	 */
	function formatInternalTag( $element_loop = '', $term = null, $rel = '', $scale_result = 0, $scale_max = null, $scale_min = 0, $largest = 0, $smallest = 0, $unit = '', $maxcolor = '', $mincolor = '' ) {
		// Need term object
		if ( $term->taxonomy == 'post_tag' ) { // Tag post
			$element_loop = str_replace('%tag_link%', clean_url(get_tag_link($term->term_id)), $element_loop);
			$element_loop = str_replace('%tag_feed%', clean_url(get_tag_feed_link($term->term_id)), $element_loop);
		} else { // Category
			$element_loop = str_replace('%tag_link%', clean_url(get_category_link($term->term_id)), $element_loop);
			$element_loop = str_replace('%tag_feed%', clean_url(get_category_rss_link(false, $term->term_id, '')), $element_loop);
		}
		$element_loop = str_replace('%tag_name%', wp_specialchars( $term->name ), $element_loop);
		$element_loop = str_replace('%tag_name_attribute%', wp_specialchars(strip_tags($term->name)), $element_loop);
		$element_loop = str_replace('%tag_id%', $term->term_id, $element_loop);
		$element_loop = str_replace('%tag_count%', (int) $term->count, $element_loop);

		// Need rel
		$element_loop = str_replace('%tag_rel%', $rel, $element_loop);

		// Need max/min/scale and other :)
		if ( $scale_result !== null ) {
			$element_loop = str_replace('%tag_size%', 'font-size:'.round(($scale_result - $scale_min)*($largest-$smallest)/($scale_max - $scale_min) + $smallest, 2).$unit.';', $element_loop);
			$element_loop = str_replace('%tag_color%', 'color:'.$this->getColorByScale(round(($scale_result - $scale_min)*(100)/($scale_max - $scale_min), 2),$mincolor,$maxcolor).';', $element_loop);
			$element_loop = str_replace('%tag_scale%', $scale_result, $element_loop);
		}

		// External link
		$element_loop = str_replace('%tag_technorati%', $this->formatExternalTag( 'technorati', $term->name ), $element_loop);
		$element_loop = str_replace('%tag_flickr%', $this->formatExternalTag( 'flickr', $term->name ), $element_loop);
		$element_loop = str_replace('%tag_delicious%', $this->formatExternalTag( 'delicious', $term->name ), $element_loop);

		return $element_loop;
	}
Example #17
0
    function display($args)
    {
        $categories = explode(',', $this->categories);
        extract($args);
        echo $before_widget;
        if ($this->title) {
            echo $before_title . $this->title . $after_title;
        }
        $this->recent_posts_in_category($categories, false, $this->limit);
        ?>
		<div class="info">
			<small><a title="<?php 
        _e('Subscribe to this!', 'guangzhou');
        ?>
" href="<?php 
        get_category_rss_link(true, $categories[0], '');
        ?>
">[<?php 
        _e('more', 'guangzhou');
        ?>
]</a></small>
		</div>
		<?php 
        echo $after_widget;
    }
Example #18
0
 function mw_getCategories($args)
 {
     global $wpdb;
     $this->escape($args);
     $blog_ID = (int) $args[0];
     $user_login = $args[1];
     $user_pass = $args[2];
     if (!$this->login_pass_ok($user_login, $user_pass)) {
         return $this->error;
     }
     set_current_user(0, $user_login);
     if (!current_user_can('edit_posts')) {
         return new IXR_Error(401, __('Sorry, you must be able to edit posts on this blog in order to view categories.'));
     }
     do_action('xmlrpc_call', 'metaWeblog.getCategories');
     $categories_struct = array();
     if ($cats = get_categories('get=all')) {
         foreach ($cats as $cat) {
             $struct['categoryId'] = $cat->term_id;
             $struct['parentId'] = $cat->parent;
             $struct['description'] = $cat->name;
             $struct['categoryName'] = $cat->name;
             $struct['htmlUrl'] = wp_specialchars(get_category_link($cat->term_id));
             $struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat->term_id, $cat->name));
             $categories_struct[] = $struct;
         }
     }
     return $categories_struct;
 }
Example #19
0
		<h4><?php _e('Meta'); ?></h4>
		<ul>
			<?php wp_register(); ?>
			<li><?php wp_loginout(); ?></li>
			<?php wp_meta(); ?>
		</ul>
		<?php } ?>
	</div>
	<?php } ?>
	
	<?php /* Category Meta */ if ( is_category() ) { ?>
	<div class="box">
		<h4><?php _e('Category: '); ?><?php single_cat_title('', 'display'); ?></h4>
		<p><?php echo category_description(); ?></p>
		<p><?php _e('Also available:') ?>
		<br /><a rel="nofollow" href="<? echo get_category_rss_link(0, $cat, $post->cat_name); ?>" title="<?php _e('RSS 2.0') ?>"><?php _e('RSS Feed for entries in this category') ?></a>.</p>
	</div>
	<?php } ?>

	<?php /* Archive Meta */ if ( is_page("archives") ) { ?>
	<div class="box">
		<h4><?php _e('Archives') ?></h4>
		<p><?php _e('You are viewing the archives for ') ?> <?php bloginfo('name'); ?>.</p>
		<?php
		$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
		if (0 < $numposts) $numposts = number_format($numposts); 
		
		$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
		if (0 < $numcomms) $numcomms = number_format($numcomms);
		
		$numcats = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy where taxonomy='category'");