[wp-cvs] wordpress/wp-admin admin-functions.php, 1.45, 1.46 edit-page-form.php, 1.5, 1.6 edit-pages.php, 1.3, 1.4 options-permalink.php, 1.43, 1.44 post.php, 1.88, 1.89 upgrade-schema.php, 1.11, 1.12

Ryan Boren rboren at users.sourceforge.net
Wed Oct 6 02:18:39 UTC 2004


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

Modified Files:
	admin-functions.php edit-page-form.php edit-pages.php 
	options-permalink.php post.php upgrade-schema.php 
Log Message:
Page/subpage URIs.

Index: edit-page-form.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/edit-page-form.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** edit-page-form.php	5 Oct 2004 08:27:13 -0000	1.5
--- edit-page-form.php	6 Oct 2004 02:18:37 -0000	1.6
***************
*** 53,57 ****
  	  <div><select name="parent_id">
  		<option value='0'>Main Page (no parent)</option>
! 			<?php parent_dropdown(); ?>
          </select>
  	  </div>
--- 53,57 ----
  	  <div><select name="parent_id">
  		<option value='0'>Main Page (no parent)</option>
! 			<?php parent_dropdown($post_parent); ?>
          </select>
  	  </div>

Index: admin-functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/admin-functions.php,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** admin-functions.php	5 Oct 2004 08:27:12 -0000	1.45
--- admin-functions.php	6 Oct 2004 02:18:37 -0000	1.46
***************
*** 486,489 ****
--- 486,537 ----
  }
  
+ function save_mod_rewrite_rules() {
+ 	global $is_apache;
+ 	$home = get_settings('home');
+ 	if ( $home != '' && $home != get_settings('siteurl') ) {
+ 		$home_path = parse_url($home);
+ 		$home_path = $home_root['path'];
+ 		$root = str_replace($_SERVER["PHP_SELF"], '', $_SERVER["PATH_TRANSLATED"]);
+ 		$home_path = $root . $home_path . "/";
+ 	} else {
+ 		$home_path = ABSPATH;
+ 	}
+ 
+ 	if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
+ 		$writable = true;
+ 	else
+ 		$writable = false;
+ 
+ 	$permalink_structure = get_settings('permalink_structure');
+ 
+ 	if ( strstr($permalink_structure, 'index.php') ) // If they're using 
+ 		$usingpi = true;
+ 	else
+ 		$usingpi = false;
+ 
+ 	if ( $writable && !$usingpi && $is_apache ) {
+ 		$rules = explode("\n", mod_rewrite_rules($permalink_structure));
+ 		insert_with_markers($home_path.'.htaccess', 'WordPress', $rules);
+ 	}
+ }
+ 
+ function generate_page_rewrite_rules() {
+ 	global $wpdb;
+ 	$posts = $wpdb->get_results("SELECT ID, post_name FROM $wpdb->posts WHERE post_status = 'static'");
+ 
+ 	$page_rewrite_rules = array();
+ 
+ 	foreach ($posts as $post) {
+ 		// URI => page name
+ 		$uri = get_page_uri($post->ID);
+ 
+ 		$page_rewrite_rules[$uri] = $post->post_name;
+ 	}
+ 
+ 	update_option('page_uris', $page_rewrite_rules);
+ 
+ 	save_mod_rewrite_rules();
+ }
+ 
  function the_quicktags () {
  // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP
***************
*** 708,712 ****
  }
  
! function parent_dropdown($parent = 0, $level = 0) {
  	global $wpdb;
  	$items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order");
--- 756,760 ----
  }
  
! function parent_dropdown($default = 0, $parent = 0, $level = 0) {
  	global $wpdb;
  	$items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order");
***************
*** 714,718 ****
  		foreach ($items as $item) {
  			$pad = str_repeat('&nbsp;', $level * 3);
! 			if ($item->ID == $current)
  				$current = ' selected="selected"';
  			else
--- 762,766 ----
  		foreach ($items as $item) {
  			$pad = str_repeat('&nbsp;', $level * 3);
! 			if ($item->ID == $default)
  				$current = ' selected="selected"';
  			else
***************
*** 720,724 ****
  
  			echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</a></option>";
! 				parent_dropdown($item->ID, $level + 1);
  		}
  	} else {
--- 768,772 ----
  
  			echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</a></option>";
! 			parent_dropdown($default, $item->ID, $level + 1);
  		}
  	} else {

Index: options-permalink.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/options-permalink.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** options-permalink.php	18 Sep 2004 05:49:10 -0000	1.43
--- options-permalink.php	6 Oct 2004 02:18:37 -0000	1.44
***************
*** 32,35 ****
--- 32,37 ----
  }
  
+ generate_page_rewrite_rules();
+ 
  if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
  	$writable = true;
***************
*** 42,49 ****
  	$usingpi = false;
  
! if ( $writable && !$usingpi && $is_apache ) {
! 	$rules = explode("\n", mod_rewrite_rules($permalink_structure));
! 	insert_with_markers($home_path.'.htaccess', 'WordPress', $rules);
! }
  ?>
  
--- 44,48 ----
  	$usingpi = false;
  
! save_mod_rewrite_rules();
  ?>
  

Index: upgrade-schema.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/upgrade-schema.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** upgrade-schema.php	5 Oct 2004 09:04:53 -0000	1.11
--- upgrade-schema.php	6 Oct 2004 02:18:37 -0000	1.12
***************
*** 212,215 ****
--- 212,216 ----
  	add_option('stylesheet', 'default');
  	add_option('comment_whitelist', 0);
+ 	add_option('page_uris');
  
  	// Delete unused options

Index: edit-pages.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/edit-pages.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** edit-pages.php	5 Oct 2004 08:27:13 -0000	1.3
--- edit-pages.php	6 Oct 2004 02:18:37 -0000	1.4
***************
*** 68,71 ****
--- 68,72 ----
  	$ping_status = get_settings('default_ping_status');
  	$post_pingback = get_settings('default_pingback_flag');
+ 	$post_parent = 0;
  
  	include('edit-page-form.php');

Index: post.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/post.php,v
retrieving revision 1.88
retrieving revision 1.89
diff -C2 -d -r1.88 -r1.89
*** post.php	5 Oct 2004 16:22:30 -0000	1.88
--- post.php	6 Oct 2004 02:18:37 -0000	1.89
***************
*** 57,60 ****
--- 57,64 ----
  		$post_status = $_POST['post_status'];
  		$post_name = $_POST['post_name'];
+ 		$post_parent = 0;
+ 		if (isset($_POST['parent_id'])) {
+ 			$post_parent = $_POST['parent_id'];
+ 		}
  
  		if (empty($post_status)) $post_status = 'draft';
***************
*** 109,115 ****
  
  	$postquery ="INSERT INTO $wpdb->posts
! 			(ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt)
  			VALUES
! 			('0', '$user_ID', '$now', '$now_gmt', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback', '$now', '$now_gmt')
  			";
  
--- 113,119 ----
  
  	$postquery ="INSERT INTO $wpdb->posts
! 			(ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent)
  			VALUES
! 			('0', '$user_ID', '$now', '$now_gmt', '$content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$trackback', '$now', '$now_gmt', '$post_parent')
  			";
  
***************
*** 195,198 ****
--- 199,206 ----
  	} // end if publish
  
+ 	if ($post_status = 'static') {
+ 		generate_page_rewrite_rules();
+ 	}
+ 
  	exit();
  	break;
***************
*** 223,232 ****
  		$pinged = $postdata->pinged;
  		$post_name = $postdata->post_name;
  
!         if ($post_status == 'static') {
!             include('edit-page-form.php');
!         } else {
!             include('edit-form-advanced.php');
!         }
  
  		$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'");
--- 231,241 ----
  		$pinged = $postdata->pinged;
  		$post_name = $postdata->post_name;
+ 		$post_parent = $postdata->post_parent;
  
! 		if ($post_status == 'static') {
! 			include('edit-page-form.php');
! 		} else {
! 			include('edit-form-advanced.php');
! 		}
  
  		$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'");
***************
*** 289,292 ****
--- 298,306 ----
  		}
  
+ 		$post_parent = 0;
+ 		if (isset($_POST['parent_id'])) {
+ 			$post_parent = $_POST['parent_id'];
+ 		}
+ 
  		if (empty($post_name)) {
  			if (! empty($post_title)) {
***************
*** 354,358 ****
  			to_ping = '$trackback',
  			post_modified = '$now',
! 			post_modified_gmt = '$now_gmt'
  		WHERE ID = $post_ID ");
  
--- 368,373 ----
  			to_ping = '$trackback',
  			post_modified = '$now',
! 			post_modified_gmt = '$now_gmt',
!       post_parent = '$post_parent'
  		WHERE ID = $post_ID ");
  
***************
*** 422,425 ****
--- 437,444 ----
  	} // end if publish
  
+ 	if ($post_status = 'static') {
+ 		generate_page_rewrite_rules();
+ 	}
+ 
  	do_action('edit_post', $post_ID);
  	exit();




More information about the cvs mailing list