Changeset 4108 for trunk/wp-includes/bookmark-template.php
- Timestamp:
- 08/22/2006 09:24:31 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/bookmark-template.php
r3899 r4108 21 21 parse_str($args); 22 22 23 if ( ! isset($category))$category = -1;24 if ( ! isset($before))$before = '';25 if ( ! isset($after))$after = '<br />';26 if ( ! isset($between))$between = ' ';27 if ( ! isset($show_images))$show_images = true;28 if ( ! isset($orderby))$orderby = 'name';29 if ( ! isset($show_description)) $show_description = true;30 if ( ! isset($show_rating))$show_rating = false;31 if ( ! isset($limit))$limit = -1;32 if ( ! isset($show_updated))$show_updated = 1;33 if ( ! isset($echo))$echo = true;23 if ( !isset($category) ) $category = -1; 24 if ( !isset($before) ) $before = ''; 25 if ( !isset($after) ) $after = '<br />'; 26 if ( !isset($between) ) $between = ' '; 27 if ( !isset($show_images) ) $show_images = true; 28 if ( !isset($orderby) ) $orderby = 'name'; 29 if ( !isset($show_description) ) $show_description = true; 30 if ( !isset($show_rating) ) $show_rating = false; 31 if ( !isset($limit) ) $limit = -1; 32 if ( !isset($show_updated) ) $show_updated = 1; 33 if ( !isset($echo) ) $echo = true; 34 34 35 35 return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); … … 74 74 75 75 $order = 'ASC'; 76 if ( substr($orderby, 0, 1) == '_') {76 if ( substr($orderby, 0, 1) == '_' ) { 77 77 $order = 'DESC'; 78 78 $orderby = substr($orderby, 1); 79 79 } 80 81 if ( $category == -1) {//get_bookmarks uses '' to signify all categories80 81 if ( $category == -1 ) //get_bookmarks uses '' to signify all categories 82 82 $category = ''; 83 }84 83 85 84 $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit"); 86 85 87 if ( !$results) {86 if ( !$results ) 88 87 return; 89 }90 91 88 92 89 $output = ''; 93 90 94 foreach ($results as $row) { 95 if (!isset($row->recently_updated)) $row->recently_updated = false; 96 $output .= $before; 97 if ($show_updated && $row->recently_updated) { 91 foreach ( (array) $results as $row ) { 92 if ( !isset($row->recently_updated) ) 93 $row->recently_updated = false; 94 $output .= $before; 95 if ( $show_updated && $row->recently_updated ) 98 96 $output .= get_settings('links_recently_updated_prepend'); 99 }100 101 97 $the_link = '#'; 102 if ( !empty($row->link_url))98 if ( !empty($row->link_url) ) 103 99 $the_link = wp_specialchars($row->link_url); 104 105 100 $rel = $row->link_rel; 106 if ( $rel != '') {101 if ( '' != $rel ) 107 102 $rel = ' rel="' . $rel . '"'; 108 }109 103 110 104 $desc = wp_specialchars($row->link_description, ENT_QUOTES); … … 112 106 $title = $desc; 113 107 114 if ( $show_updated) {115 if (substr($row->link_updated_f, 0, 2) != '00') {108 if ( $show_updated ) 109 if (substr($row->link_updated_f, 0, 2) != '00') 116 110 $title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) . ')'; 117 } 118 } 119 120 if ('' != $title) { 111 112 if ( '' != $title ) 121 113 $title = ' title="' . $title . '"'; 122 }123 114 124 115 $alt = ' alt="' . $name . '"'; 125 116 126 117 $target = $row->link_target; 127 if ( '' != $target) {118 if ( '' != $target ) 128 119 $target = ' target="' . $target . '"'; 129 }130 120 131 121 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; 132 122 133 if ( ($row->link_image != null) && $show_images) {134 if ( strstr($row->link_image, 'http'))123 if ( $row->link_image != null && $show_images ) { 124 if ( strpos($row->link_image, 'http') !== false ) 135 125 $output .= "<img src=\"$row->link_image\" $alt $title />"; 136 126 else // If it's a relative path … … 142 132 $output .= '</a>'; 143 133 144 if ( $show_updated && $row->recently_updated) {134 if ( $show_updated && $row->recently_updated ) 145 135 $output .= get_settings('links_recently_updated_append'); 146 } 147 148 if ($show_description && ($desc != '')) { 136 137 if ( $show_description && '' != $desc ) 149 138 $output .= $between . $desc; 150 } 139 151 140 $output .= "$after\n"; 152 141 } // end while 153 142 154 if ($echo) { 155 echo $output; 156 } else { 143 if ( !$echo ) 157 144 return $output; 158 }145 echo $output; 159 146 } 160 147 … … 171 158 $id = (int) $id; 172 159 173 174 175 160 if ( empty($id) ) 161 return ''; 162 176 163 $cats = wp_get_link_cats($id); 177 164 … … 195 182 ** count (default true) - the number of links in the db 196 183 */ 197 function links_popup_script($text = 'Links', $width=400, $height=400, 198 $file='links.all.php', $count = true) { 199 if ($count == true) { 200 $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links"); 201 } 202 203 $javascript = "<a href=\"#\" " . 204 " onclick=\"javascript:window.open('$file?popup=1', '_blank', " . 205 "'width=$width,height=$height,scrollbars=yes,status=no'); " . 206 " return false\">"; 207 $javascript .= $text; 208 209 if ($count == true) { 210 $javascript .= " ($counts)"; 211 } 212 213 $javascript .="</a>\n\n"; 214 echo $javascript; 184 function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { 185 if ( $count ) 186 $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links"); 187 188 $javascript = "<a href=\"#\" onclick=\"javascript:window.open('$file?popup=1', '_blank', 'width=$width,height=$height,scrollbars=yes,status=no'); return false\">"; 189 $javascript .= $text; 190 191 if ( $count ) 192 $javascript .= " ($counts)"; 193 194 $javascript .= "</a>\n\n"; 195 echo $javascript; 215 196 } 216 197 … … 234 215 // Handle link category sorting 235 216 $direction = 'ASC'; 236 if ( substr($order,0,1) == '_') {217 if ( '_' == substr($order,0,1) ) { 237 218 $direction = 'DESC'; 238 219 $order = substr($order,1); 239 220 } 240 221 241 if (!isset($direction)) $direction = ''; 222 if ( !isset($direction) ) 223 $direction = ''; 242 224 243 225 $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0"); 244 226 245 227 // Display each category 246 if ( $cats) {247 foreach ( $cats as $cat) {228 if ( $cats ) { 229 foreach ( (array) $cats as $cat ) { 248 230 // Handle each category. 249 231 … … 251 233 echo ' <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n"; 252 234 // Call get_links() with all the appropriate params 253 get_links($cat->cat_ID, 254 '<li>',"</li>","\n", true, 'name', false); 235 get_links($cat->cat_ID, '<li>', "</li>", "\n", true, 'name', false); 255 236 256 237 // Close the last category … … 272 253 273 254 foreach ( (array) $bookmarks as $bookmark ) { 274 if (!isset($bookmark->recently_updated)) $bookmark->recently_updated = false; 275 $output .= $before; 276 if ($show_updated && $bookmark->recently_updated) { 255 if ( !isset($bookmark->recently_updated) ) 256 $bookmark->recently_updated = false; 257 $output .= $before; 258 if ( $show_updated && $bookmark->recently_updated ) 277 259 $output .= get_settings('links_recently_updated_prepend'); 278 }279 260 280 261 $the_link = '#'; 281 if ( !empty($bookmark->link_url))262 if ( !empty($bookmark->link_url) ) 282 263 $the_link = wp_specialchars($bookmark->link_url); 283 264 284 265 $rel = $bookmark->link_rel; 285 if ( $rel != '') {266 if ( '' != $rel ) 286 267 $rel = ' rel="' . $rel . '"'; 287 }288 268 289 269 $desc = wp_specialchars($bookmark->link_description, ENT_QUOTES); … … 291 271 $title = $desc; 292 272 293 if ( $show_updated) {294 if ( substr($bookmark->link_updated_f, 0, 2) != '00') {273 if ( $show_updated ) 274 if ( '00' != substr($bookmark->link_updated_f, 0, 2) ) 295 275 $title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $bookmark->link_updated_f + (get_settings('gmt_offset') * 3600)) . ')'; 296 } 297 } 298 299 if ('' != $title) { 276 277 if ( '' != $title ) 300 278 $title = ' title="' . $title . '"'; 301 }302 279 303 280 $alt = ' alt="' . $name . '"'; 304 281 305 282 $target = $bookmark->link_target; 306 if ( '' != $target) {283 if ( '' != $target ) 307 284 $target = ' target="' . $target . '"'; 308 }309 285 310 286 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; 311 287 312 if ( ($bookmark->link_image != null) && $show_images) {313 if ( strstr($bookmark->link_image, 'http'))288 if ( $bookmark->link_image != null && $show_images ) { 289 if ( strpos($bookmark->link_image, 'http') !== false ) 314 290 $output .= "<img src=\"$bookmark->link_image\" $alt $title />"; 315 291 else // If it's a relative path … … 321 297 $output .= '</a>'; 322 298 323 if ( $show_updated && $bookmark->recently_updated) {299 if ( $show_updated && $bookmark->recently_updated ) 324 300 $output .= get_settings('links_recently_updated_append'); 325 } 326 327 if ($show_description && ($desc != '')) { 301 302 if ( $show_description && '' != $desc ) 328 303 $output .= $between . $desc; 329 }330 304 $output .= "$after\n"; 331 305 } // end while … … 346 320 $r = array_merge($defaults, $r); 347 321 extract($r); 348 322 349 323 // TODO: The rest of it. 350 324 // If $categorize, group links by category with the category name being the 351 // title of each li, otherwise just list them with title_li as the li title. 325 // title of each li, otherwise just list them with title_li as the li title. 352 326 // If $categorize and $category or $category_name, list links for the given category 353 327 // with the category name as the title li. If not $categorize, use title_li. … … 370 344 } 371 345 372 if ($echo) 373 echo $output; 374 375 return $output; 346 if ( !$echo ) 347 return $output; 348 echo $output; 376 349 } 377 350
Note: See TracChangeset
for help on using the changeset viewer.