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%"> <table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr> <tr>
<td<?php <?php if ($action != "editcomment") {
// this is for everything but comment editing
if ($action != "editcomment") { ?> <td>
<table height="60" align="left" cellpadding="0" cellspacing="0">
// this is for everything but comment editing <td height="60" width="190">
?>> <label for="title"><b>Title :</b></label><br />
<table height="60" align="left" cellpadding="0" cellspacing="0"> <input type="text" name="post_title" size="20" tabindex="1" style="width: 170px;" value="<?php echo $edited_post_title; ?>" id="title" />
<td height="60" width="190"> </td>
<label for="title"><b>Title :</b></label><br /> <td>
<input type="text" name="post_title" size="20" tabindex="1" style="width: 170px;" value="<?php echo $edited_post_title; ?>" id="title" /> <label for="category"><b>Category :</b></label><br /><?php dropdown_categories(); ?>
</td> </td>
<td> </table>
<label for="category"><b>Category :</b></label><br /><?php dropdown_categories(); ?> <?php
</td>
</table>
<?php
} else { } else {
// this is for comment editing // this is for comment editing
?> colspan="2">&nbsp;</td> ?> <td colspan="2">&nbsp;</td>
</tr> </tr>
<tr> <tr>
@ -81,8 +78,8 @@ if ($action != "editcomment") {
<label for="URL"><b>URL :</b></label><br /> <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" /> <input type="text" name="newcomment_author_url" size="20" value="<?php echo format_to_edit($commentdata["comment_author_url"]) ?>" tabindex="3" id="URL" />
<?php <?php
} } // end else comment editing
?> ?>
</td> </td>
@ -91,6 +88,20 @@ if ($action != "editcomment") {
<td colspan="<?php echo $colspan; ?>"> <td colspan="<?php echo $colspan; ?>">
<table cellspacing="0" cellpadding="0" border="0" width="100%"> <table cellspacing="0" cellpadding="0" border="0" width="100%">
<td valign="bottom"> <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 <?php
if ($action != 'editcomment') { if ($action != 'editcomment') {
echo '<label for="content"><b>Post :</b></label>'; 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) { ?> <?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 = "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 <input type="button" value="Spellcheck" onclick="DoSpell('post','content','');" class="search" tabindex="9"/>
('post','content','');" class="search" tabindex="9"/>
<?php } ?> <?php } ?>
<?php if ( ($use_fileupload) && ($user_level >= $fileupload_minlevel) && ((ereg(" ".$user_login." ", $fileupload_allowedusers)) || (trim($fileupload_allowedusers)=="")) ) { ?> <?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> </tr>
</table> </table>
<?php echo $tablebottom ?> <?php echo $tablebottom ?>
</form> </form>

View File

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

View File

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

View File

@ -370,6 +370,72 @@ function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file
return($output); 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='') { 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 $id,$page,$numpages,$multipage,$more;
global $pagenow; global $pagenow;
@ -1123,6 +1189,7 @@ function start_b2() {
'Author_ID' => $HTTP_GET_VARS['preview_userid'], 'Author_ID' => $HTTP_GET_VARS['preview_userid'],
'Date' => $HTTP_GET_VARS['preview_date'], 'Date' => $HTTP_GET_VARS['preview_date'],
'Content' => $HTTP_GET_VARS['preview_content'], 'Content' => $HTTP_GET_VARS['preview_content'],
'Excerpt' => $HTTP_GET_VARS['preview_excerpt'],
'Title' => $HTTP_GET_VARS['preview_title'], 'Title' => $HTTP_GET_VARS['preview_title'],
'Category' => $HTTP_GET_VARS['preview_category'], 'Category' => $HTTP_GET_VARS['preview_category'],
'Notify' => 1, 'Notify' => 1,

View File

@ -19,7 +19,7 @@ if (!get_magic_quotes_gpc()) {
$HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS); $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) { for ($i=0; $i<count($b2varstoreset); $i += 1) {
$b2var = $b2varstoreset[$i]; $b2var = $b2varstoreset[$i];
if (!isset($$b2var)) { if (!isset($$b2var)) {
@ -46,6 +46,8 @@ case 'post':
$post_pingback = intval($HTTP_POST_VARS["post_pingback"]); $post_pingback = intval($HTTP_POST_VARS["post_pingback"]);
$content = balanceTags($HTTP_POST_VARS["content"]); $content = balanceTags($HTTP_POST_VARS["content"]);
$content = format_to_post($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_title = addslashes($HTTP_POST_VARS["post_title"]);
$post_category = intval($HTTP_POST_VARS["post_category"]); $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))); $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); $result = mysql_query($query) or mysql_oops($query);
$post_ID = mysql_insert_id(); $post_ID = mysql_insert_id();
@ -128,6 +130,8 @@ case "edit":
$content = $postdata["Content"]; $content = $postdata["Content"];
$content = format_to_edit($content); $content = format_to_edit($content);
$excerpt = $postdata["Excerpt"];
$excerpt = format_to_edit($excerpt);
$edited_post_title = format_to_edit($postdata["Title"]); $edited_post_title = format_to_edit($postdata["Title"]);
echo $blankline; echo $blankline;
@ -159,6 +163,8 @@ case "editpost":
$post_autobr = intval($HTTP_POST_VARS["post_autobr"]); $post_autobr = intval($HTTP_POST_VARS["post_autobr"]);
$content = balanceTags($HTTP_POST_VARS["content"]); $content = balanceTags($HTTP_POST_VARS["content"]);
$content = format_to_post($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_title = addslashes($HTTP_POST_VARS["post_title"]);
if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) { if (($user_level > 4) && (!empty($HTTP_POST_VARS["edit_date"]))) {
@ -177,7 +183,7 @@ case "editpost":
$datemodif = ""; $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); $result = mysql_query($query) or mysql_oops($query);
if (isset($sleep_after_edit) && $sleep_after_edit > 0) { if (isset($sleep_after_edit) && $sleep_after_edit > 0) {

View File

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

View File

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

View File

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