Added in Excerpt functionality. Requires a database update see update-b2posts-for-excerpt.sql

Note: quicktags are BROKEN with this commit.


git-svn-id: http://svn.automattic.com/wordpress/trunk@12 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
mikelittle 2003-04-24 01:04:42 +00:00
parent 68c30393e1
commit b1a28736a7
8 changed files with 234 additions and 109 deletions

View File

@ -47,27 +47,24 @@ switch($action) {
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td<?php
if ($action != "editcomment") {
// this is for everything but comment editing
?>>
<table height="60" align="left" cellpadding="0" cellspacing="0">
<td height="60" width="190">
<label for="title"><b>Title :</b></label><br />
<input type="text" name="post_title" size="20" tabindex="1" style="width: 170px;" value="<?php echo $edited_post_title; ?>" id="title" />
</td>
<td>
<label for="category"><b>Category :</b></label><br /><?php dropdown_categories(); ?>
</td>
</table>
<?php
<?php if ($action != "editcomment") {
// this is for everything but comment editing
?> <td>
<table height="60" align="left" cellpadding="0" cellspacing="0">
<td height="60" width="190">
<label for="title"><b>Title :</b></label><br />
<input type="text" name="post_title" size="20" tabindex="1" style="width: 170px;" value="<?php echo $edited_post_title; ?>" id="title" />
</td>
<td>
<label for="category"><b>Category :</b></label><br /><?php dropdown_categories(); ?>
</td>
</table>
<?php
} else {
// this is for comment editing
?> colspan="2">&nbsp;</td>
?> <td colspan="2">&nbsp;</td>
</tr>
<tr>
@ -81,8 +78,8 @@ if ($action != "editcomment") {
<label for="URL"><b>URL :</b></label><br />
<input type="text" name="newcomment_author_url" size="20" value="<?php echo format_to_edit($commentdata["comment_author_url"]) ?>" tabindex="3" id="URL" />
<?php
}
} // end else comment editing
?>
</td>
@ -91,6 +88,20 @@ if ($action != "editcomment") {
<td colspan="<?php echo $colspan; ?>">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<td valign="bottom">
<?php
if ($action != 'editcomment') {
echo '<label for="excerpt"><b>Excerpt :</b></label>';
} else {
echo '<br /><label for="content"><b>Comment :</b></label>';
}
?>
</td>
<td valign="bottom" align="right">&nbsp;</td>
</table>
<textarea rows="3" cols="40" style="width:100%" name="excerpt" tabindex="4" wrap="virtual" id="content"><?php echo $excerpt ?></textarea><br />
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<?php
if ($action != 'editcomment') {
echo '<label for="content"><b>Post :</b></label>';
@ -120,8 +131,7 @@ echo " checked" ?> tabindex="7" id="autobr" /><label for="autobr"> Auto-BR (conv
<?php if ($use_spellchecker) { ?>
<!--<input type = "button" value = "Spell Check" onclick="var f=document.forms[0]; doSpell( 'en', f.post_content, '<?php echo $spellchecker_url ?>/sproxy.cgi', true);" class="search" tabindex="5" />-->
<input type="button" value="Spellcheck" onclick="DoSpell
('post','content','');" class="search" tabindex="9"/>
<input type="button" value="Spellcheck" onclick="DoSpell('post','content','');" class="search" tabindex="9"/>
<?php } ?>
<?php if ( ($use_fileupload) && ($user_level >= $fileupload_minlevel) && ((ereg(" ".$user_login." ", $fileupload_allowedusers)) || (trim($fileupload_allowedusers)=="")) ) { ?>
@ -145,4 +155,4 @@ if ($user_level > 4) {
</tr>
</table>
<?php echo $tablebottom ?>
</form>
</form>

View File

@ -36,62 +36,81 @@ if ($previousXstart < 0) {
?>
<table width="100%">
<tr>
<td valign="top" width="200">
Show posts: </td>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<td colspan="2" align="center"><!-- show next/previous X posts -->
<form name="previousXposts" method="get"><?php
<tr>
<td valign="top" width="200">
Show posts:
</td>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="2" align="center"><!-- show next/previous X posts -->
<form name="previousXposts" method="get">
<?php
if ($previousXstart > 0) {
?>
<input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
<input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
<input type="submit" name="submitprevious" class="search" value="< <?php echo $posts ?>" /><?php
<input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
<input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
<input type="submit" name="submitprevious" class="search" value="< <?php echo $posts ?>" />
<?php
}
?></form></td><td><form name="nextXposts" method="get">
<input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
<input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
<input type="submit" name="submitnext" class="search" value="<?php echo $posts ?> >" /></form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="200"><!-- show X first/last posts -->
<form name="showXfirstlastposts" method="get">
<input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
<select name="order">&nbsp;<option value="DESC" <?php
?>
</form>
</td>
<td>
<form name="nextXposts" method="get">
<input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
<input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
<input type="submit" name="submitnext" class="search" value="<?php echo $posts ?> >" />
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="200"><!-- show X first/last posts -->
<form name="showXfirstlastposts" method="get">
<input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
<?php
if (!isset($order))
$order="DESC";
$order="DESC";
$i = $order;
if ($i == "DESC")
echo " selected";
?>>last posts</option>
<option value="ASC" <?php
$besp_selected = "selected";
?>
<select name="order">&nbsp;
<option value="DESC" "<?= $besp_selected ?>">last posts</option>
<?php
$besp_selected = "";
if ($i == "ASC")
echo " selected";
?>>first posts</option>
</select>&nbsp;<input type="submit" name="submitfirstlast" class="search" value="OK" />
</form>
</td>
<td valign="top"><!-- show post X to post X -->
<form name="showXfirstlastposts" method="get">
<input type="text" name="poststart" value="<?php echo $poststart ?>" style="width:40px;" /?>&nbsp;to&nbsp;<input type="text" name="postend" value="<?php echo $postend ?>" style="width:40px;" /?>&nbsp;<select name="order">
<option value="DESC" <?php
$besp_selected = "selected";
?>
<option value="ASC" "<?= $besp_selected?>">first posts</option>
</select>&nbsp;
<input type="submit" name="submitfirstlast" class="search" value="OK" />
</form>
</td>
<td valign="top"><!-- show post X to post X -->
<form name="showXfirstlastposts" method="get">
<input type="text" name="poststart" value="<?php echo $poststart ?>" style="width:40px;" /?>&nbsp;to&nbsp;<input type="text" name="postend" value="<?php echo $postend ?>" style="width:40px;" /?>&nbsp;
<select name="order">
<?php
$besp_selected = "";
$i = $order;
if ($i == "DESC")
echo " selected";
?>>from the end</option>
<option value="ASC" <?php
$besp_selected = "selected";
?>
<option value="DESC" "<?= $besp_selected ?>">from the end</option>
<?php
$besp_selected = "";
if ($i == "ASC")
echo " selected";
?>>from the start</option>
</select>&nbsp;<input type="submit" name="submitXtoX" class="search" value="OK" /></form>
</td>
</tr>
$besp_selected = "selected";
?> <option value="ASC" "<?= $besp_selected ?>">from the start</option>
</select>&nbsp;
<input type="submit" name="submitXtoX" class="search" value="OK" />
</form>
</td>
</tr>
</table>
<?php echo $tablebottom ?>
@ -238,11 +257,19 @@ echo " selected";
<?php
if ($safe_mode)
echo "<xmp>";
the_excerpt();
echo '<br />';
if ($safe_mode)
echo "</xmp>";
?>
<?php
if ($safe_mode)
echo "<xmp>";
the_content();
if ($safe_mode)
echo "</xmp>";
?>
</p>
</p>
<?php
// comments
@ -322,33 +349,38 @@ echo " selected";
<br />
<?php echo $tabletop ?>
<table width="100%">
<tr>
<td valign="top" width="200">
Show posts: </td>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<td colspan="2" align="center"><!-- show next/previous X posts -->
<form name="previousXposts" method="get"><?php
<tr>
<td valign="top" width="200">Show posts: </td>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td colspan="2" align="center"><!-- show next/previous X posts -->
<form name="previousXposts" method="get"><?php
if ($previousXstart > -1) {
?>
<input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
<input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
<input type="submit" name="submitprevious" class="search" value="< Previous <?php echo $posts ?>" /><?php
<input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
<input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
<input type="submit" name="submitprevious" class="search" value="< Previous <?php echo $posts ?>" /><?php
}
?></form></td><td><form name="nextXposts" method="get">
<input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
<input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
<input type="submit" name="submitnext" class="search" value="Next <?php echo $posts ?> >" /></form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="200"><!-- show X first/last posts -->
<form name="showXfirstlastposts" method="get">
<input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
<select name="order">&nbsp;<option value="DESC" <?php
?>
</form>
</td>
<td>
<form name="nextXposts" method="get">
<input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
<input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
<input type="submit" name="submitnext" class="search" value="Next <?php echo $posts ?> >" />
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="200"><!-- show X first/last posts -->
<form name="showXfirstlastposts" method="get">
<input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
<select name="order">&nbsp;<option value="DESC" <?php
$i = $order;
if ($i == "DESC")
echo " selected";
@ -357,13 +389,13 @@ echo " selected";
if ($i == "ASC")
echo " selected";
?>>first posts</option>
</select>&nbsp;<input type="submit" name="submitfirstlast" class="search" value="OK" />
</form>
</td>
<td valign="top"><!-- show post X to post X -->
<form name="showXfirstlastposts" method="get">
<input type="text" name="poststart" value="<?php echo $poststart ?>" style="width:40px;" /?>&nbsp;to&nbsp;<input type="text" name="postend" value="<?php echo $postend ?>" style="width:40px;" /?>&nbsp;<select name="order">
<option value="DESC" <?php
</select>&nbsp;<input type="submit" name="submitfirstlast" class="search" value="OK" />
</form>
</td>
<td valign="top"><!-- show post X to post X -->
<form name="showXfirstlastposts" method="get">
<input type="text" name="poststart" value="<?php echo $poststart ?>" style="width:40px;" /?>&nbsp;to&nbsp;<input type="text" name="postend" value="<?php echo $postend ?>" style="width:40px;" /?>&nbsp;<select name="order">
<option value="DESC" <?php
$i = $order;
if ($i == "DESC")
echo " selected";
@ -372,9 +404,9 @@ echo " selected";
if ($i == "ASC")
echo " selected";
?>>from the start</option>
</select>&nbsp;<input type="submit" name="submitXtoX" class="search" value="OK" /></form>
</td>
</tr>
</table>
</select>&nbsp;<input type="submit" name="submitXtoX" class="search" value="OK" />
</form>
</td>
</tr>
</table>
<?php echo $tablebottom ?>

View File

@ -518,6 +518,7 @@ function get_postdata($postid) {
'Author_ID' => $myrow->post_author,
'Date' => $myrow->post_date,
'Content' => $myrow->post_content,
'Excerpt' => $myrow->post_excerpt,
'Title' => $myrow->post_title,
'Category' => $myrow->post_category,
);
@ -534,6 +535,7 @@ function get_postdata2($postid=0) { // less flexible, but saves mysql queries
'Author_ID' => $row->post_author,
'Date' => $row->post_date,
'Content' => $row->post_content,
'Excerpt' => $row->post_excerpt,
'Title' => $row->post_title,
'Category' => $row->post_category,
# 'Notify' => $row->post_notifycomments,

View File

@ -370,6 +370,72 @@ function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file
return($output);
}
function the_excerpt() {
$excerpt = get_the_excerpt();
$excerpt = convert_bbcode($excerpt);
$excerpt = convert_gmcode($excerpt);
$excerpt = convert_smilies($excerpt);
$excerpt = convert_chars($excerpt, 'html');
$excerpt = apply_filters('the_excerpt', $excerpt);
echo $excerpt;
}
function the_excerpt_rss($cut = 0, $encode_html = 0) {
$excerpt = get_the_excerpt();
$excerpt = convert_bbcode($excerpt);
$excerpt = convert_gmcode($excerpt);
$excerpt = convert_chars($excerpt, 'unicode');
if ($cut && !$encode_html) {
$encode_html = 2;
}
if ($encode_html == 1) {
$excerpt = htmlspecialchars($excerpt);
$cut = 0;
} elseif ($encode_html == 0) {
$excerpt = make_url_footnote($excerpt);
} elseif ($encode_html == 2) {
$excerpt = strip_tags($excerpt);
}
if ($cut) {
$blah = explode(' ', $excerpt);
if (count($blah) > $cut) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '...' : '';
$excerpt = $excerpt;
}
echo $excerpt;
}
function the_excerpt_unicode() {
$excerpt = get_the_excerpt();
$excerpt = convert_bbcode($excerpt);
$excerpt = convert_gmcode($excerpt);
$excerpt = convert_smilies($excerpt);
$excerpt = convert_chars($excerpt, 'unicode');
$excerpt = apply_filters('the_excerpt_unicode', $excerpt);
echo $excerpt;
}
function get_the_excerpt() {
global $id,$postdata;
global $HTTP_SERVER_VARS, $preview;
$output = '';
$output = $postdata['Excerpt'];
if ($preview) { // preview fix for javascript bug with foreign languages
$output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);
}
return($output);
}
function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') {
global $id,$page,$numpages,$multipage,$more;
global $pagenow;
@ -1123,6 +1189,7 @@ function start_b2() {
'Author_ID' => $HTTP_GET_VARS['preview_userid'],
'Date' => $HTTP_GET_VARS['preview_date'],
'Content' => $HTTP_GET_VARS['preview_content'],
'Excerpt' => $HTTP_GET_VARS['preview_excerpt'],
'Title' => $HTTP_GET_VARS['preview_title'],
'Category' => $HTTP_GET_VARS['preview_category'],
'Notify' => 1,

View File

@ -19,7 +19,7 @@ if (!get_magic_quotes_gpc()) {
$HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS);
}
$b2varstoreset = array('action','safe_mode','withcomments','c','posts','poststart','postend','content','edited_post_title','comment_error','profile', 'trackback_url');
$b2varstoreset = array('action','safe_mode','withcomments','c','posts','poststart','postend','content','edited_post_title','comment_error','profile', 'trackback_url', 'excerpt');
for ($i=0; $i<count($b2varstoreset); $i += 1) {
$b2var = $b2varstoreset[$i];
if (!isset($$b2var)) {
@ -46,6 +46,8 @@ case 'post':
$post_pingback = intval($HTTP_POST_VARS["post_pingback"]);
$content = balanceTags($HTTP_POST_VARS["content"]);
$content = format_to_post($content);
$excerpt = balanceTags($HTTP_POST_VARS["excerpt"]);
$excerpt = format_to_post($excerpt);
$post_title = addslashes($HTTP_POST_VARS["post_title"]);
$post_category = intval($HTTP_POST_VARS["post_category"]);
@ -68,7 +70,7 @@ case 'post':
$now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600)));
}
$query = "INSERT INTO $tableposts (ID, post_author, post_date, post_content, post_title, post_category) VALUES ('0','$user_ID','$now','$content','".$post_title."','".$post_category."')";
$query = "INSERT INTO $tableposts (ID, post_author, post_date, post_content, post_title, post_category, post_excerpt) VALUES ('0','$user_ID','$now','$content','".$post_title."','".$post_category."','".$excerpt."')";
$result = mysql_query($query) or mysql_oops($query);
$post_ID = mysql_insert_id();
@ -128,6 +130,8 @@ case "edit":
$content = $postdata["Content"];
$content = format_to_edit($content);
$excerpt = $postdata["Excerpt"];
$excerpt = format_to_edit($excerpt);
$edited_post_title = format_to_edit($postdata["Title"]);
echo $blankline;
@ -159,6 +163,8 @@ case "editpost":
$post_autobr = intval($HTTP_POST_VARS["post_autobr"]);
$content = balanceTags($HTTP_POST_VARS["content"]);
$content = format_to_post($content);
$excerpt = balanceTags($HTTP_POST_VARS["excerpt"]);
$excerpt = format_to_post($excerpt);
$post_title = addslashes($HTTP_POST_VARS["post_title"]);
if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) {
@ -177,7 +183,7 @@ case "editpost":
$datemodif = "";
}
$query = "UPDATE $tableposts SET post_content=\"$content\", post_title=\"$post_title\", post_category=\"$post_category\"".$datemodif." WHERE ID=$post_ID";
$query = "UPDATE $tableposts SET post_content=\"$content\", post_excerpt=\"$excerpt\", post_title=\"$post_title\", post_category=\"$post_category\"".$datemodif." WHERE ID=$post_ID";
$result = mysql_query($query) or mysql_oops($query);
if (isset($sleep_after_edit) && $sleep_after_edit > 0) {

View File

@ -36,6 +36,9 @@
</h3>
<div class="storyContent">
<div class="storyExcerpt">
<?php the_excerpt(); ?>
</div>
<?php the_content(); ?>
<div class="feedback">

View File

@ -63,6 +63,10 @@ p, .storyContent {
#content>.storyContent {margin:0px;}
#content>.storyContent+.storyContent {text-indent:30px;}
.storyExcerpt {
font:12px/18px verdana, arial, helvetica, sans-serif;
font-weight: bold;
}
a {
color:#09c;

View File

@ -0,0 +1 @@
alter table b2posts add column post_excerpt text NOT NULL;