Code purtification from Mark J. fixes #3060

git-svn-id: http://svn.automattic.com/wordpress/trunk@4108 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-08-22 09:24:31 +00:00
parent b8025e74a8
commit 424159c96d
1 changed files with 70 additions and 97 deletions

View File

@ -78,60 +78,50 @@ function get_links($category = -1,
$orderby = substr($orderby, 1);
}
if ($category == -1) { //get_bookmarks uses '' to signify all categories
if ( $category == -1 ) //get_bookmarks uses '' to signify all categories
$category = '';
}
$results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit");
if (!$results) {
if ( !$results )
return;
}
$output = '';
foreach ($results as $row) {
if (!isset($row->recently_updated)) $row->recently_updated = false;
foreach ( (array) $results as $row ) {
if ( !isset($row->recently_updated) )
$row->recently_updated = false;
$output .= $before;
if ($show_updated && $row->recently_updated) {
if ( $show_updated && $row->recently_updated )
$output .= get_settings('links_recently_updated_prepend');
}
$the_link = '#';
if ( !empty($row->link_url) )
$the_link = wp_specialchars($row->link_url);
$rel = $row->link_rel;
if ($rel != '') {
if ( '' != $rel )
$rel = ' rel="' . $rel . '"';
}
$desc = wp_specialchars($row->link_description, ENT_QUOTES);
$name = wp_specialchars($row->link_name, ENT_QUOTES);
$title = $desc;
if ($show_updated) {
if (substr($row->link_updated_f, 0, 2) != '00') {
if ( $show_updated )
if (substr($row->link_updated_f, 0, 2) != '00')
$title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) . ')';
}
}
if ('' != $title) {
if ( '' != $title )
$title = ' title="' . $title . '"';
}
$alt = ' alt="' . $name . '"';
$target = $row->link_target;
if ('' != $target) {
if ( '' != $target )
$target = ' target="' . $target . '"';
}
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
if (($row->link_image != null) && $show_images) {
if (strstr($row->link_image, 'http'))
if ( $row->link_image != null && $show_images ) {
if ( strpos($row->link_image, 'http') !== false )
$output .= "<img src=\"$row->link_image\" $alt $title />";
else // If it's a relative path
$output .= "<img src=\"" . get_settings('siteurl') . "$row->link_image\" $alt $title />";
@ -141,21 +131,18 @@ function get_links($category = -1,
$output .= '</a>';
if ($show_updated && $row->recently_updated) {
if ( $show_updated && $row->recently_updated )
$output .= get_settings('links_recently_updated_append');
}
if ($show_description && ($desc != '')) {
if ( $show_description && '' != $desc )
$output .= $between . $desc;
}
$output .= "$after\n";
} // end while
if ($echo) {
echo $output;
} else {
if ( !$echo )
return $output;
}
echo $output;
}
function get_linkrating($link) {
@ -194,21 +181,15 @@ function get_linkcatname($id = 0) {
** file (default linkspopup.php) - the page to open in the popup window
** count (default true) - the number of links in the db
*/
function links_popup_script($text = 'Links', $width=400, $height=400,
$file='links.all.php', $count = true) {
if ($count == true) {
$counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
}
function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {
if ( $count )
$counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links");
$javascript = "<a href=\"#\" " .
" onclick=\"javascript:window.open('$file?popup=1', '_blank', " .
"'width=$width,height=$height,scrollbars=yes,status=no'); " .
" return false\">";
$javascript = "<a href=\"#\" onclick=\"javascript:window.open('$file?popup=1', '_blank', 'width=$width,height=$height,scrollbars=yes,status=no'); return false\">";
$javascript .= $text;
if ($count == true) {
if ( $count )
$javascript .= " ($counts)";
}
$javascript .= "</a>\n\n";
echo $javascript;
@ -233,25 +214,25 @@ function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
// Handle link category sorting
$direction = 'ASC';
if (substr($order,0,1) == '_') {
if ( '_' == substr($order,0,1) ) {
$direction = 'DESC';
$order = substr($order,1);
}
if (!isset($direction)) $direction = '';
if ( !isset($direction) )
$direction = '';
$cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0");
// Display each category
if ( $cats ) {
foreach ($cats as $cat) {
foreach ( (array) $cats as $cat ) {
// Handle each category.
// Display the category name
echo ' <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n";
// Call get_links() with all the appropriate params
get_links($cat->cat_ID,
'<li>',"</li>","\n", true, 'name', false);
get_links($cat->cat_ID, '<li>', "</li>", "\n", true, 'name', false);
// Close the last category
echo "\n\t</ul>\n</li>\n";
@ -271,46 +252,41 @@ function _walk_bookmarks($bookmarks, $args = '' ) {
extract($r);
foreach ( (array) $bookmarks as $bookmark ) {
if (!isset($bookmark->recently_updated)) $bookmark->recently_updated = false;
if ( !isset($bookmark->recently_updated) )
$bookmark->recently_updated = false;
$output .= $before;
if ($show_updated && $bookmark->recently_updated) {
if ( $show_updated && $bookmark->recently_updated )
$output .= get_settings('links_recently_updated_prepend');
}
$the_link = '#';
if ( !empty($bookmark->link_url) )
$the_link = wp_specialchars($bookmark->link_url);
$rel = $bookmark->link_rel;
if ($rel != '') {
if ( '' != $rel )
$rel = ' rel="' . $rel . '"';
}
$desc = wp_specialchars($bookmark->link_description, ENT_QUOTES);
$name = wp_specialchars($bookmark->link_name, ENT_QUOTES);
$title = $desc;
if ($show_updated) {
if (substr($bookmark->link_updated_f, 0, 2) != '00') {
if ( $show_updated )
if ( '00' != substr($bookmark->link_updated_f, 0, 2) )
$title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $bookmark->link_updated_f + (get_settings('gmt_offset') * 3600)) . ')';
}
}
if ('' != $title) {
if ( '' != $title )
$title = ' title="' . $title . '"';
}
$alt = ' alt="' . $name . '"';
$target = $bookmark->link_target;
if ('' != $target) {
if ( '' != $target )
$target = ' target="' . $target . '"';
}
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
if (($bookmark->link_image != null) && $show_images) {
if (strstr($bookmark->link_image, 'http'))
if ( $bookmark->link_image != null && $show_images ) {
if ( strpos($bookmark->link_image, 'http') !== false )
$output .= "<img src=\"$bookmark->link_image\" $alt $title />";
else // If it's a relative path
$output .= "<img src=\"" . get_settings('siteurl') . "$bookmark->link_image\" $alt $title />";
@ -320,13 +296,11 @@ function _walk_bookmarks($bookmarks, $args = '' ) {
$output .= '</a>';
if ($show_updated && $bookmark->recently_updated) {
if ( $show_updated && $bookmark->recently_updated )
$output .= get_settings('links_recently_updated_append');
}
if ($show_description && ($desc != '')) {
if ( $show_description && '' != $desc )
$output .= $between . $desc;
}
$output .= "$after\n";
} // end while
@ -369,10 +343,9 @@ function wp_list_bookmarks($args = '') {
}
}
if ($echo)
echo $output;
if ( !$echo )
return $output;
echo $output;
}
?>