Use modified get_links_list

git-svn-id: http://svn.automattic.com/wordpress/trunk@678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-01-01 22:13:06 +00:00
parent a392bb19d3
commit 253f684253
2 changed files with 10 additions and 25 deletions

View File

@ -67,11 +67,7 @@ require_once('wp-blog-header.php');
<div id="menu"> <div id="menu">
<ul> <ul>
<li>Links: <?php get_links_list(); ?>
<ul>
<?php get_links(-1, '<li>', '</li>', '', 0, '_updated', 0, 0, -1, -1)?>
</ul>
</li>
<li>Categories: <li>Categories:
<ul> <ul>
<?php list_cats(0, 'All', 'name'); ?> <?php list_cats(0, 'All', 'name'); ?>

View File

@ -514,7 +514,7 @@ function links_popup_script($text = 'Links', $width=400, $height=400,
* order (default 'name') - Sort link categories by 'name' or 'id' * order (default 'name') - Sort link categories by 'name' or 'id'
* hide_if_empty (default true) - Supress listing empty link categories * hide_if_empty (default true) - Supress listing empty link categories
*/ */
function get_links_list($order = 'name', $hide_if_empty = true) { function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
global $tablelinkcategories, $tablelinks, $wpdb; global $tablelinkcategories, $tablelinks, $wpdb;
$order = strtolower($order); $order = strtolower($order);
@ -526,37 +526,29 @@ function get_links_list($order = 'name', $hide_if_empty = true) {
} }
// if 'name' wasn't specified, assume 'id': // if 'name' wasn't specified, assume 'id':
$cat_order = ('name' == $order)?'cat_name':'cat_id'; $cat_order = ('name' == $order) ? 'cat_name' : 'cat_id';
if ($hide_if_empty) {
$extra_join = "LEFT JOIN $tablelinks ON link_category = cat_id";
$group_by_having = 'GROUP BY cat_id HAVING count(link_id) > 0';
}
// Fetch the link category data as an array of hashes // Fetch the link category data as an array of hashes
$cats = $wpdb->get_results("SELECT cat_id, cat_name, show_images, $cats = $wpdb->get_results("SELECT DISTINCT link_category, cat_name, show_images,
show_description, show_rating, show_updated, sort_order, sort_desc, list_limit show_description, show_rating, show_updated, sort_order, sort_desc, list_limit
FROM $tablelinkcategories $extra_join FROM `$tablelinks` LEFT JOIN `$tablelinkcategories` ON (link_category = cat_id)
$group_by_having WHERE link_visible = 'Y'
ORDER BY $cat_order $direction ",ARRAY_A); ORDER BY $cat_order $direction ", ARRAY_A);
// Display each category // Display each category
if ($cats) { if ($cats) {
// Start the unordered list
echo "<ul>\n";
foreach ($cats as $cat) { foreach ($cats as $cat) {
// Handle each category. // Handle each category.
// First, fix the sort_order info // First, fix the sort_order info
$orderby = $cat['sort_order']; $orderby = $cat['sort_order'];
$orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby; $orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
// Display the category name // Display the category name
echo '<li>' . stripslashes($cat['cat_name']) . "\n<ul>\n"; echo ' <li>' . stripslashes($cat['cat_name']) . "\n\t<ul>\n";
// Call get_links() with all the appropriate params // Call get_links() with all the appropriate params
get_links($cat['cat_id'], get_links($cat['link_category'],
'<li>',"</li>","\n", '<li>',"</li>","\n",
bool_from_yn($cat['show_images']), bool_from_yn($cat['show_images']),
$orderby, $orderby,
@ -566,11 +558,8 @@ function get_links_list($order = 'name', $hide_if_empty = true) {
bool_from_yn($cat['show_updated'])); bool_from_yn($cat['show_updated']));
// Close the last category // Close the last category
echo "</ul>\n</li>\n"; echo "\n\t</ul>\n</li>\n";
} }
// Close out our category list.
echo "</ul>\n";
} }
} }