Static pages. Take 1.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-08-10 05:35:59 +00:00
parent 9fe8ff24e2
commit ea16450f63
10 changed files with 108 additions and 18 deletions

View File

@ -93,6 +93,7 @@ case 'edit':
?>
<ul id="adminmenu2">
<li><a href="edit.php"><?php _e('Posts') ?></a></li>
<li><a href="edit-pages.php"><?php _e('Pages') ?></a></li>
<li><a href="categories.php" class="current"><?php _e('Categories') ?></a></li>
<li><a href="edit-comments.php"><?php _e('Comments') ?></a></li>
<li class="last"><a href="moderation.php"><?php _e('Awaiting Moderation') ?></a></li>
@ -153,6 +154,7 @@ $messages[3] = __('Category updated.');
?>
<ul id="adminmenu2">
<li><a href="edit.php"><?php _e('Posts') ?></a></li>
<li><a href="edit-pages.php"><?php _e('Pages') ?></a></li>
<li><a class="current"><?php _e('Categories') ?></a></li>
<li><a href="edit-comments.php"><?php _e('Comments') ?></a></li>
<li><a href="moderation.php"><?php _e('Awaiting Moderation') ?></a></li>

View File

@ -9,6 +9,7 @@ else $mode = $_GET['mode'];
?>
<ul id="adminmenu2">
<li><a href="edit.php"><?php _e('Posts') ?></a></li>
<li><a href="edit-pages.php"><?php _e('Pages') ?></a></li>
<li><a href="categories.php"><?php _e('Categories') ?></a></li>
<li><a href="edit-comments.php" class="current"><?php _e('Comments') ?></a></li>
<li><a href="moderation.php"><?php _e('Awaiting Moderation') ?></a></li>

View File

@ -7,6 +7,7 @@ require_once('admin-header.php');
?>
<ul id="adminmenu2">
<li><a href="edit.php" class="current"><?php _e('Posts') ?></a></li>
<li><a href="edit-pages.php"><?php _e('Pages') ?></a></li>
<li><a href="categories.php"><?php _e('Categories') ?></a></li>
<li><a href="edit-comments.php"><?php _e('Comments') ?></a></li>
<li><a href="moderation.php"><?php _e('Awaiting Moderation') ?></a></li>

View File

@ -99,6 +99,7 @@ default:
?>
<ul id="adminmenu2">
<li><a href="edit.php"> <?php _e('Posts') ?></a></li>
<li><a href="edit-pages.php"><?php _e('Pages') ?></a></li>
<li><a href="categories.php"><?php _e('Categories') ?></a></li>
<li><a href="edit-comments.php"> <?php _e('Comments') ?></a></li>
<li><a href="moderation.php" class="current"><?php _e('Awaiting Moderation') ?></a></li>

View File

@ -107,7 +107,7 @@ case 'post':
if ('' != $_POST['saveasprivate']) $post_status = 'private';
if ('' != $_POST['publish']) $post_status = 'publish';
if ('' != $_POST['advanced']) $post_status = 'draft';
if ('' != $_POST['savepage']) $post_status = 'static';
if((get_settings('use_geo_positions')) && (strlen($latstr) > 2) && (strlen($lonstr) > 2) ) {
$postquery ="INSERT INTO $wpdb->posts
@ -143,6 +143,9 @@ case 'post':
if ( '' != $_POST['advanced'] || isset($_POST['save']) )
$location = "post.php?action=edit&post=$post_ID";
if ( '' != $_POST['savepage'] )
$location = "post.php?action=createpage";
header("Location: $location"); // Send user on their way while we keep working
@ -233,7 +236,11 @@ case 'edit':
$pinged = $postdata->pinged;
$post_name = $postdata->post_name;
include('edit-form-advanced.php');
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'");
?>
@ -712,6 +719,36 @@ case 'editedcomment':
do_action('edit_comment', $comment_ID);
break;
case 'createpage':
$standalone = 0;
$title = __('Create New Page');
require_once ('./admin-header.php');
if ($user_level > 0) {
$action = 'post';
get_currentuserinfo();
//set defaults
$post_status = 'static';
$comment_status = get_settings('default_comment_status');
$ping_status = get_settings('default_ping_status');
$post_pingback = get_settings('default_pingback_flag');
$default_post_cat = get_settings('default_post_category');
include('edit-page-form.php');
} else {
?>
<div class="wrap">
<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_settings('admin_email')); ?>
</p>
</div>
<?php
}
break;
default:
$standalone = 0;
$title = __('Create New Post');

View File

@ -50,7 +50,7 @@ if ( !empty( $_SERVER['PATH_INFO'] ) ) {
}
}
$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name');
$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];

View File

@ -454,11 +454,16 @@ class WP_Query {
$distinct = 'DISTINCT';
}
$where .= ' AND (post_status = "publish"';
if ('' != $q['static']) {
$where .= ' AND (post_status = "static"';
} else {
$where .= ' AND (post_status = "publish"';
}
// Get private posts
if (isset($user_ID) && ('' != intval($user_ID)))
$where .= " OR post_author = $user_ID AND post_status != 'draft')";
$where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
else
$where .= ')';

View File

@ -1175,6 +1175,24 @@ function preg_index($number, $matches = '') {
return "$match_prefix$number$match_suffix";
}
function page_permastruct() {
$permalink_structure = get_settings('permalink_structure');
if (empty($permalink_structure)) {
return '';
}
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
$index = get_settings('blogfilename');
$prefix = '';
if (preg_match('#^/*' . $index . '#', $front)) {
$prefix = $index . '/';
}
return '/' . $prefix . 'site/%pagename%';
}
function generate_rewrite_rules($permalink_structure = '', $matches = '') {
$rewritecode =
array(
@ -1187,7 +1205,8 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') {
'%postname%',
'%post_id%',
'%category%',
'%author%'
'%author%',
'%pagename%'
);
$rewritereplace =
@ -1201,7 +1220,8 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') {
'([_0-9a-z-]+)',
'([0-9]+)',
'([/_0-9a-z-]+)',
'([_0-9a-z-]+)'
'([_0-9a-z-]+)',
'([_0-9a-z-]+)',
);
$queryreplace =
@ -1215,7 +1235,8 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') {
'name=',
'p=',
'category_name=',
'author_name='
'author_name=',
'static=1&name=',
);
$feedregex = '(feed|rdf|rss|rss2|atom)/?$';
@ -1355,8 +1376,12 @@ function rewrite_rules($matches = '', $permalink_structure = '') {
$author_structure = $front . 'author/%author%';
$author_rewrite = generate_rewrite_rules($author_structure, $matches);
// Site static pages
$page_structure = $prefix . 'site/%pagename%';
$page_rewrite = generate_rewrite_rules($page_structure, $matches);
// Put them together.
$rewrite = $site_rewrite + $category_rewrite + $author_rewrite;
$rewrite = $site_rewrite + $page_rewrite + $category_rewrite + $author_rewrite;
// Add on archive rewrite rules if needed.
if ($doarchive) {
@ -1464,8 +1489,10 @@ function update_post_caches($posts) {
FROM $wpdb->categories, $wpdb->post2cat, $wpdb->posts
WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
foreach ($dogs as $catt) {
$category_cache[$catt->ID][] = $catt;
if (!empty($dogs)) {
foreach ($dogs as $catt) {
$category_cache[$catt->ID][] = $catt;
}
}
// Do the same for comment numbers

View File

@ -64,6 +64,11 @@ function get_category_rss_link($echo = false, $category_id, $category_nicename)
function the_category($seperator = '', $parents='') {
$categories = get_the_category();
if (empty($categories)) {
_e('Uncategorized');
return;
}
$thelist = '';
if ('' == $seperator) {
$thelist .= '<ul class="post-categories">';

View File

@ -39,16 +39,23 @@ function get_permalink($id=false) {
'%second%',
'%postname%',
'%post_id%',
'%category%'
'%category%',
'%pagename%'
);
if ($id) {
$idpost = $wpdb->get_row("SELECT ID, post_date, post_name FROM $wpdb->posts WHERE ID = $id");
$idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status FROM $wpdb->posts WHERE ID = $id");
} else {
$idpost = $post;
}
if ('' != get_settings('permalink_structure')) {
$permalink = get_settings('permalink_structure');
if ('' != $permalink) {
if ($idpost->post_status == 'static') {
$permalink = page_permastruct();
}
$unixtime = strtotime($idpost->post_date);
$cats = get_the_category($idpost->ID);
@ -63,11 +70,15 @@ function get_permalink($id=false) {
date('s', $unixtime),
$idpost->post_name,
$idpost->ID,
$category
$category,
$idpost->post_name,
);
return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink);
} else { // if they're not using the fancy permalink option
return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID;
$permalink = get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID;
if ($idpost->post_status == 'static') {
$permalink .= $querystring_separator . "static=1";
}
}
}