[wp-cvs] wordpress/wp-includes template-functions-links.php, 1.14, 1.15 template-functions-post.php, 1.24, 1.25

Matthew Mullenweg saxmatt at users.sourceforge.net
Wed Jun 2 02:44:46 CDT 2004


Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29288/wp-includes

Modified Files:
	template-functions-links.php template-functions-post.php 
Log Message:
Fix for strange slash nav errors for paged nice links, and validation fixes.

Index: template-functions-links.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-links.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** template-functions-links.php	2 Jun 2004 07:14:03 -0000	1.14
--- template-functions-links.php	2 Jun 2004 07:44:43 -0000	1.15
***************
*** 228,230 ****
--- 228,425 ----
  }
  
+ // Navigation links
+ 
+ function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
+     global $id, $post, $wpdb;
+     global $p, $posts, $posts_per_page, $s, $single;
+     global $querystring_start, $querystring_equal, $querystring_separator;
+ 
+     if(($p) || ($posts_per_page == 1) || 1 == $single) {
+ 
+         $current_post_date = $post->post_date;
+         $current_category = $post->post_category;
+ 
+         $sqlcat = '';
+         if ($in_same_cat != 'no') {
+             $sqlcat = " AND post_category = '$current_category' ";
+         }
+ 
+         $sql_exclude_cats = '';
+         if (!empty($excluded_categories)) {
+             $blah = explode('and', $excluded_categories);
+             foreach($blah as $category) {
+                 $category = intval($category);
+                 $sql_exclude_cats .= " AND post_category != $category";
+             }
+         }
+ 
+         $limitprev--;
+         $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1");
+         if ($lastpost) {
+             $string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous;
+             if ($title == 'yes') {
+                 $string .= wptexturize(stripslashes($lastpost->post_title));
+             }
+             $string .= '</a>';
+             $format = str_replace('%', $string, $format);
+             echo $format;
+         }
+     }
+ }
+ 
+ function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
+     global $posts_per_page, $post, $wpdb, $single;
+     if(1 == $posts_per_page || 1 == $single) {
+ 
+         $current_post_date = $post->post_date;
+         $current_category = $post->post_category;
+ 
+         $sqlcat = '';
+         if ($in_same_cat != 'no') {
+             $sqlcat = " AND post_category='$current_category' ";
+         }
+ 
+         $sql_exclude_cats = '';
+         if (!empty($excluded_categories)) {
+             $blah = explode('and', $excluded_categories);
+             foreach($blah as $category) {
+                 $category = intval($category);
+                 $sql_exclude_cats .= " AND post_category != $category";
+             }
+         }
+ 
+         $now = current_time('mysql');
+ 
+         $limitnext--;
+ 
+         $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT $limitnext,1");
+         if ($nextpost) {
+             $string = '<a href="'.get_permalink($nextpost->ID).'">'.$next;
+             if ($title=='yes') {
+                 $string .= wptexturize(stripslashes($nextpost->post_title));
+             }
+             $string .= '</a>';
+             $format = str_replace('%', $string, $format);
+             echo $format;
+         }
+     }
+ }
+ 
+ function get_pagenum_link($pagenum = 1){
+    $qstr = $_SERVER['REQUEST_URI'];
+ 
+    $page_querystring = "paged"; 
+    $page_modstring = "page/";
+    $page_modregex = "page/?";
+ 
+    // if we already have a QUERY style page string
+    if( stristr( $qstr, $page_querystring ) ) {
+        $replacement = "$page_querystring=$pagenum";
+       $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr);
+    // if we already have a mod_rewrite style page string
+    } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ){
+       $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr);
+ 
+    // if we don't have a page string at all ...
+    // lets see what sort of URL we have...
+    } else {
+       // we need to know the way queries are being written
+       global $querystring_start, $querystring_equal, $querystring_separator;
+       // if there's a querystring_start (a "?" usually), it's deffinitely not mod_rewritten
+       if ( stristr( $qstr, $querystring_start ) ){
+          // so append the query string (using &, since we already have ?)
+          $qstr .=  $querystring_separator.$page_querystring.$querystring_equal.$pagenum;
+          // otherwise, it could be rewritten, OR just the default index ...
+       } elseif( '' != get_settings('permalink_structure')) {
+          $qstr = preg_replace('|(.*)/[^/]*|', '$1/', $qstr).$page_modstring.$pagenum;
+       } else {
+          $qstr = get_settings('blogfilename') . $querystring_start.$page_querystring.$querystring_equal.$pagenum;
+       }
+    }
+ 
+    $home_root = str_replace('http://', '', trim(get_settings('home')));
+    $home_root = preg_replace('|/+|i', '/', $home_root);
+    $qstr = str_replace($home_root . '/', '', $qstr);
+    $qstr = preg_replace('|^/+|', '', $qstr);
+    return preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', trailingslashit(get_settings('home')).$qstr);
+ }
+ 
+ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
+     global $p, $paged, $what_to_show, $pagenow;
+     global $querystring_start, $querystring_equal, $querystring_separator;
+ 
+      if (empty($p) && ($what_to_show == 'paged')) {
+          if (!$paged) $paged = 1;
+          $nextpage = intval($paged) + 1;
+          if (!$max_page || $max_page >= $nextpage) {
+              echo get_pagenum_link($nextpage);
+          }         
+      }
+ }
+ 
+ function next_posts_link($label='Next Page &raquo;', $max_page=0) {
+     global $p, $paged, $result, $request, $posts_per_page, $what_to_show, $wpdb;
+     if ($what_to_show == 'paged') {
+         if (!$max_page) {
+             $nxt_request = $request;
+             //if the query includes a limit clause, call it again without that
+             //limit clause!
+             if ($pos = strpos(strtoupper($request), 'LIMIT')) {
+                 $nxt_request = substr($request, 0, $pos);
+             }
+             $nxt_result = $wpdb->query($nxt_request);
+             $numposts = $wpdb->num_rows;
+             $max_page = ceil($numposts / $posts_per_page);
+         }
+         if (!$paged)
+             $paged = 1;
+         $nextpage = intval($paged) + 1;
+         if (empty($p) && (empty($paged) || $nextpage <= $max_page)) {
+             echo '<a href="';
+             next_posts($max_page);
+             echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
+         }
+     }
+ }
+ 
+ 
+ function previous_posts() { // original by cfactor at cooltux.org
+     global $_SERVER, $p, $paged, $what_to_show, $pagenow;
+     global $querystring_start, $querystring_equal, $querystring_separator;
+ 
+      if (empty($p) && ($what_to_show == 'paged')) {
+          $nextpage = intval($paged) - 1;
+          if ($nextpage < 1) $nextpage = 1;
+          echo get_pagenum_link($nextpage);
+      }
+ }
+ 
+ function previous_posts_link($label='&laquo; Previous Page') {
+     global $p, $paged, $what_to_show;
+     if (empty($p)  && ($paged > 1) && ($what_to_show == 'paged')) {
+         echo '<a href="';
+         previous_posts();
+         echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
+     }
+ }
+ 
+ function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
+     global $p, $what_to_show, $request, $posts_per_page, $wpdb;
+     if (empty($p) && ($what_to_show == 'paged')) {
+         $nxt_request = $request;
+         if ($pos = strpos(strtoupper($request), 'LIMIT')) {
+             $nxt_request = substr($request, 0, $pos);
+         }
+         $nxt_result = $wpdb->query($nxt_request);
+         $numposts = $wpdb->num_rows;
+         $max_page = ceil($numposts / $posts_per_page);
+         if ($max_page > 1) {
+             previous_posts_link($prelabel);
+             echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $sep);
+             next_posts_link($nxtlabel, $max_page);
+         }
+     }
+ }
+ 
+ 
  ?>
\ No newline at end of file

Index: template-functions-post.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-post.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** template-functions-post.php	31 May 2004 17:22:25 -0000	1.24
--- template-functions-post.php	2 Jun 2004 07:44:43 -0000	1.25
***************
*** 274,513 ****
  }
  
- 
- function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
-     global $id, $post, $wpdb;
-     global $p, $posts, $posts_per_page, $s, $single;
-     global $querystring_start, $querystring_equal, $querystring_separator;
- 
-     if(($p) || ($posts_per_page == 1) || 1 == $single) {
- 
-         $current_post_date = $post->post_date;
-         $current_category = $post->post_category;
- 
-         $sqlcat = '';
-         if ($in_same_cat != 'no') {
-             $sqlcat = " AND post_category = '$current_category' ";
-         }
- 
-         $sql_exclude_cats = '';
-         if (!empty($excluded_categories)) {
-             $blah = explode('and', $excluded_categories);
-             foreach($blah as $category) {
-                 $category = intval($category);
-                 $sql_exclude_cats .= " AND post_category != $category";
-             }
-         }
- 
-         $limitprev--;
-         $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1");
-         if ($lastpost) {
-             $string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous;
-             if ($title == 'yes') {
-                 $string .= wptexturize(stripslashes($lastpost->post_title));
-             }
-             $string .= '</a>';
-             $format = str_replace('%', $string, $format);
-             echo $format;
-         }
-     }
- }
- 
- function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
-     global $posts_per_page, $post, $wpdb, $single;
-     if(1 == $posts_per_page || 1 == $single) {
- 
-         $current_post_date = $post->post_date;
-         $current_category = $post->post_category;
- 
-         $sqlcat = '';
-         if ($in_same_cat != 'no') {
-             $sqlcat = " AND post_category='$current_category' ";
-         }
- 
-         $sql_exclude_cats = '';
-         if (!empty($excluded_categories)) {
-             $blah = explode('and', $excluded_categories);
-             foreach($blah as $category) {
-                 $category = intval($category);
-                 $sql_exclude_cats .= " AND post_category != $category";
-             }
-         }
- 
-         $now = current_time('mysql');
- 
-         $limitnext--;
- 
-         $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT $limitnext,1");
-         if ($nextpost) {
-             $string = '<a href="'.get_permalink($nextpost->ID).'">'.$next;
-             if ($title=='yes') {
-                 $string .= wptexturize(stripslashes($nextpost->post_title));
-             }
-             $string .= '</a>';
-             $format = str_replace('%', $string, $format);
-             echo $format;
-         }
-     }
- }
- 
- function get_pagenum_link($pagenum = 1){
-    $qstr = $_SERVER['REQUEST_URI'];
- 
-    $page_querystring = "paged"; 
-    $page_modstring = "page/";
-    $page_modregex = "page/?";
- 
-    // if we already have a QUERY style page string
-    if( stristr( $qstr, $page_querystring ) ) {
-        $replacement = "$page_querystring=$pagenum";
-       $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr);
-    // if we already have a mod_rewrite style page string
-    } elseif ( preg_match( '|'.$page_modregex.'\d+|', $qstr ) ){
-       $qstr = preg_replace('|'.$page_modregex.'\d+|',"$page_modstring$pagenum",$qstr);
- 
-    // if we don't have a page string at all ...
-    // lets see what sort of URL we have...
-    } else {
-       // we need to know the way queries are being written
-       global $querystring_start, $querystring_equal, $querystring_separator;
-       // if there's a querystring_start (a "?" usually), it's deffinitely not mod_rewritten
-       if ( stristr( $qstr, $querystring_start ) ){
-          // so append the query string (using &, since we already have ?)
-          $qstr .=  $querystring_separator.$page_querystring.$querystring_equal.$pagenum;
-          // otherwise, it could be rewritten, OR just the default index ...
-       } elseif( '' != get_settings('permalink_structure')) {
-          $qstr = preg_replace('|(.*)/[^/]*|', '$1/', $qstr).$page_modstring.$pagenum;
-       } else {
-          $qstr = get_settings('blogfilename') . $querystring_start.$page_querystring.$querystring_equal.$pagenum;
-       }
-    }
- 
-    $home_root = str_replace('http://', '', trim(get_settings('home')));
-    $home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root);
-    if ('/' != substr($home_root, -1)) $home_root = $home_root . '/';
- 
-    $qstr = str_replace($home_root, '', $qstr);
-    return trailingslashit(get_settings('home')).$qstr;
- }
- 
- function next_posts($max_page = 0) { // original by cfactor at cooltux.org
-     global $p, $paged, $what_to_show, $pagenow;
-     global $querystring_start, $querystring_equal, $querystring_separator;
- //     if (empty($p) && ($what_to_show == 'paged')) {
- //         $qstr = $_SERVER['QUERY_STRING'];
- //         if (!empty($qstr)) {
- //             $qstr = preg_replace('/&paged=\d{0,}/', '', $qstr);
- //             $qstr = preg_replace('/paged=\d{0,}/', '', $qstr);
- //         } elseif (stristr($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'] )) {
- //             if ('' != $qstr = str_replace($_SERVER['SCRIPT_NAME'], '',
- //                                             $_SERVER['REQUEST_URI']) ) {
- //                 $qstr = preg_replace('/^\//', '', $qstr);
- //                 $qstr = preg_replace('/paged\/\d{0,}\//', '', $qstr);
- //                 $qstr = preg_replace('/paged\/\d{0,}/', '', $qstr);
- //                 $qstr = preg_replace('/\/$/', '', $qstr);
- //             }
- //         }
- //         if (!$paged) $paged = 1;
- //         $nextpage = intval($paged) + 1;
- //         if (!$max_page || $max_page >= $nextpage) {
- //             echo  get_settings('home') .'/'.$pagenow.$querystring_start.
- //                 ($qstr == '' ? '' : $qstr.$querystring_separator) .
- //                 'paged'.$querystring_equal.$nextpage;
- //         }
- //     }
- 
-      if (empty($p) && ($what_to_show == 'paged')) {
-          if (!$paged) $paged = 1;
-          $nextpage = intval($paged) + 1;
-          if (!$max_page || $max_page >= $nextpage) {
-              echo get_pagenum_link($nextpage);
-          }         
-      }
- }
- 
- function next_posts_link($label='Next Page &raquo;', $max_page=0) {
-     global $p, $paged, $result, $request, $posts_per_page, $what_to_show, $wpdb;
-     if ($what_to_show == 'paged') {
-         if (!$max_page) {
-             $nxt_request = $request;
-             //if the query includes a limit clause, call it again without that
-             //limit clause!
-             if ($pos = strpos(strtoupper($request), 'LIMIT')) {
-                 $nxt_request = substr($request, 0, $pos);
-             }
-             $nxt_result = $wpdb->query($nxt_request);
-             $numposts = $wpdb->num_rows;
-             $max_page = ceil($numposts / $posts_per_page);
-         }
-         if (!$paged)
-             $paged = 1;
-         $nextpage = intval($paged) + 1;
-         if (empty($p) && (empty($paged) || $nextpage <= $max_page)) {
-             echo '<a href="';
-             next_posts($max_page);
-             echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
-         }
-     }
- }
- 
- 
- function previous_posts() { // original by cfactor at cooltux.org
-     global $_SERVER, $p, $paged, $what_to_show, $pagenow;
-     global $querystring_start, $querystring_equal, $querystring_separator;
- //     if (empty($p) && ($what_to_show == 'paged')) {
- //         $qstr = $_SERVER['QUERY_STRING'];
- //         if (!empty($qstr)) {
- //             $qstr = preg_replace('/&paged=\d{0,}/', '', $qstr);
- //             $qstr = preg_replace('/paged=\d{0,}/', '', $qstr);
- //         } elseif (stristr($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'] )) {
- //             if ('' != $qstr = str_replace($_SERVER['SCRIPT_NAME'], '',
- //                                             $_SERVER['REQUEST_URI']) ) {
- //                 $qstr = preg_replace('/^\//', '', $qstr);
- //                 $qstr = preg_replace("/paged\/\d{0,}\//", '', $qstr);
- //                 $qstr = preg_replace('/paged\/\d{0,}/', '', $qstr);
- //                 $qstr = preg_replace('/\/$/', '', $qstr);
- //             }
- //         }
- //         $nextpage = intval($paged) - 1;
- //         if ($nextpage < 1) $nextpage = 1;
- //         echo  get_settings('home') .'/'.$pagenow.$querystring_start.
- //             ($qstr == '' ? '' : $qstr.$querystring_separator) .
- //             'paged'.$querystring_equal.$nextpage;
- //     }
- 
-      if (empty($p) && ($what_to_show == 'paged')) {
-          $nextpage = intval($paged) - 1;
-          if ($nextpage < 1) $nextpage = 1;
-          echo get_pagenum_link($nextpage);
-      }
- }
- 
- function previous_posts_link($label='&laquo; Previous Page') {
-     global $p, $paged, $what_to_show;
-     if (empty($p)  && ($paged > 1) && ($what_to_show == 'paged')) {
-         echo '<a href="';
-         previous_posts();
-         echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
-     }
- }
- 
- function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Next Page >>') {
-     global $p, $what_to_show, $request, $posts_per_page, $wpdb;
-     if (empty($p) && ($what_to_show == 'paged')) {
-         $nxt_request = $request;
-         if ($pos = strpos(strtoupper($request), 'LIMIT')) {
-             $nxt_request = substr($request, 0, $pos);
-         }
-         $nxt_result = $wpdb->query($nxt_request);
-         $numposts = $wpdb->num_rows;
-         $max_page = ceil($numposts / $posts_per_page);
-         if ($max_page > 1) {
-             previous_posts_link($prelabel);
-             echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $sep);
-             next_posts_link($nxtlabel, $max_page);
-         }
-     }
- }
- 
  /*
   * Post-meta: Custom per-post fields.
--- 274,277 ----




More information about the cvs mailing list