WordPress.org

Make WordPress Core

Changeset 12


Ignore:
Timestamp:
04/24/2003 01:04:42 AM (19 years ago)
Author:
mikelittle
Message:

Added in Excerpt functionality. Requires a database update see update-b2posts-for-excerpt.sql
Note: quicktags are BROKEN with this commit.

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2edit.form.php

    r8 r12  
    4848<table cellspacing="0" cellpadding="0" border="0" width="100%">
    4949<tr>
    50     <td<?php
    51 
    52 if ($action != "editcomment") {
    53 
    54 // this is for everything but comment editing
    55     ?>>
    56     <table height="60" align="left" cellpadding="0" cellspacing="0">
    57         <td height="60" width="190">
    58         <label for="title"><b>Title :</b></label><br />
    59         <input type="text" name="post_title" size="20" tabindex="1" style="width: 170px;" value="<?php echo $edited_post_title; ?>" id="title" />
    60         </td>
    61         <td>
    62         <label for="category"><b>Category :</b></label><br /><?php dropdown_categories(); ?>
    63         </td>
    64     </table>
    65     <?php
     50<?php if ($action != "editcomment") {
     51  // this is for everything but comment editing
     52?>  <td>
     53      <table height="60" align="left" cellpadding="0" cellspacing="0">
     54        <td height="60" width="190">
     55          <label for="title"><b>Title :</b></label><br />
     56          <input type="text" name="post_title" size="20" tabindex="1" style="width: 170px;" value="<?php echo $edited_post_title; ?>" id="title" />
     57        </td>
     58        <td>
     59          <label for="category"><b>Category :</b></label><br /><?php dropdown_categories(); ?>
     60        </td>
     61      </table>
     62  <?php
    6663
    6764} else {
    68    
     65 
    6966// this is for comment editing
    70     ?> colspan="2">&nbsp;</td>
     67?>  <td colspan="2">&nbsp;</td>
    7168</tr>
    7269
     
    8279    <input type="text" name="newcomment_author_url" size="20" value="<?php echo format_to_edit($commentdata["comment_author_url"]) ?>" tabindex="3" id="URL" />
    8380    <?php
    84    
    85 }
     81 
     82} // end else comment editing
    8683
    8784    ?>
     
    9289<table cellspacing="0" cellpadding="0" border="0" width="100%">
    9390<td valign="bottom">
     91<?php
     92if ($action != 'editcomment') {
     93  echo '<label for="excerpt"><b>Excerpt :</b></label>';
     94} else {
     95  echo '<br /><label for="content"><b>Comment :</b></label>';
     96}
     97?>
     98</td>
     99<td valign="bottom" align="right">&nbsp;</td>
     100</table>
     101
     102<textarea rows="3" cols="40" style="width:100%" name="excerpt" tabindex="4" wrap="virtual" id="content"><?php echo $excerpt ?></textarea><br />
     103<table cellspacing="0" cellpadding="0" border="0" width="100%">
     104
    94105<?php
    95106if ($action != 'editcomment') {
     
    121132<?php if ($use_spellchecker) { ?>
    122133<!--<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" />-->
    123 <input type="button" value="Spellcheck" onclick="DoSpell
    124 ('post','content','');" class="search" tabindex="9"/>
     134<input type="button" value="Spellcheck" onclick="DoSpell('post','content','');" class="search" tabindex="9"/>
    125135<?php } ?>
    126136
  • trunk/b2-include/b2edit.showposts.php

    r8 r12  
    3737
    3838<table width="100%">
    39 <tr>
    40 <td valign="top" width="200">
    41 Show posts: </td>
    42 <td>
    43 <table cellpadding="0" cellspacing="0" border="0">
    44 <td colspan="2" align="center"><!-- show next/previous X posts -->
    45 <form name="previousXposts" method="get"><?php
     39  <tr>
     40    <td valign="top" width="200">
     41      Show posts:
     42    </td>
     43    <td>
     44      <table cellpadding="0" cellspacing="0" border="0">
     45        <tr>
     46          <td colspan="2" align="center"><!-- show next/previous X posts -->
     47            <form name="previousXposts" method="get">
     48<?php
    4649if ($previousXstart > 0) {
    4750?>
    48 <input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
    49 <input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
    50 <input type="submit" name="submitprevious" class="search" value="< <?php echo $posts ?>" /><?php
    51 }
    52 ?></form></td><td><form name="nextXposts" method="get">
    53 <input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
    54 <input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
    55 <input type="submit" name="submitnext" class="search" value="<?php echo $posts ?> >" /></form>
    56 </td>
    57 </tr>
    58 </table>
    59 </td>
    60 </tr>
    61 <tr>
    62 <td valign="top" width="200"><!-- show X first/last posts -->
    63 <form name="showXfirstlastposts" method="get">
    64 <input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
    65 <select name="order">&nbsp;<option value="DESC" <?php
     51              <input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
     52              <input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
     53              <input type="submit" name="submitprevious" class="search" value="< <?php echo $posts ?>" />
     54<?php
     55}
     56?>
     57            </form>
     58          </td>
     59          <td>
     60            <form name="nextXposts" method="get">
     61              <input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
     62              <input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
     63              <input type="submit" name="submitnext" class="search" value="<?php echo $posts ?> >" />
     64            </form>
     65          </td>
     66        </tr>
     67      </table>
     68    </td>
     69  </tr>
     70  <tr>
     71    <td valign="top" width="200"><!-- show X first/last posts -->
     72      <form name="showXfirstlastposts" method="get">
     73        <input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
     74<?php
    6675if (!isset($order))
    67     $order="DESC";
     76  $order="DESC";
    6877$i = $order;
    6978if ($i == "DESC")
    70 echo " selected";
    71 ?>>last posts</option>
    72 <option value="ASC" <?php
     79 $besp_selected = "selected";
     80?>
     81        <select name="order">&nbsp;
     82          <option value="DESC" "<?= $besp_selected ?>">last posts</option>
     83<?php
     84$besp_selected = "";
    7385if ($i == "ASC")
    74 echo " selected";
    75 ?>>first posts</option>
    76 </select>&nbsp;<input type="submit" name="submitfirstlast" class="search" value="OK" />
    77 </form>
    78 </td>
    79 <td valign="top"><!-- show post X to post X -->
    80 <form name="showXfirstlastposts" method="get">
    81 <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">
    82 <option value="DESC" <?php
     86$besp_selected = "selected";
     87?>
     88          <option value="ASC" "<?= $besp_selected?>">first posts</option>
     89        </select>&nbsp;
     90        <input type="submit" name="submitfirstlast" class="search" value="OK" />
     91      </form>
     92    </td>
     93    <td valign="top"><!-- show post X to post X -->
     94      <form name="showXfirstlastposts" method="get">
     95        <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;
     96        <select name="order">
     97<?php
     98$besp_selected = "";
    8399$i = $order;
    84100if ($i == "DESC")
    85 echo " selected";
    86 ?>>from the end</option>
    87 <option value="ASC" <?php
     101  $besp_selected = "selected";
     102?>
     103          <option value="DESC" "<?= $besp_selected ?>">from the end</option>
     104<?php
     105$besp_selected = "";
    88106if ($i == "ASC")
    89 echo " selected";
    90 ?>>from the start</option>
    91 </select>&nbsp;<input type="submit" name="submitXtoX" class="search" value="OK" /></form>
    92 </td>
    93 
    94 </tr>
     107  $besp_selected = "selected";
     108?>        <option value="ASC" "<?= $besp_selected ?>">from the start</option>
     109        </select>&nbsp;
     110        <input type="submit" name="submitXtoX" class="search" value="OK" />
     111      </form>
     112    </td>
     113  </tr>
    95114</table>
    96115<?php echo $tablebottom ?>
     
    239258                if ($safe_mode)
    240259                    echo "<xmp>";
     260                the_excerpt();
     261                echo '<br />';
     262                if ($safe_mode)
     263                    echo "</xmp>";
     264                ?>
     265                <?php
     266                if ($safe_mode)
     267                    echo "<xmp>";
    241268                the_content();
    242269                if ($safe_mode)
    243270                    echo "</xmp>";
    244271                ?>
    245                 </p>
     272            </p>
    246273                <?php
    247274
     
    323350<?php echo $tabletop ?>
    324351<table width="100%">
    325 <tr>
    326 <td valign="top" width="200">
    327 Show posts: </td>
    328 <td>
    329 <table cellpadding="0" cellspacing="0" border="0">
    330 <td colspan="2" align="center"><!-- show next/previous X posts -->
    331 <form name="previousXposts" method="get"><?php
     352  <tr>
     353    <td valign="top" width="200">Show posts: </td>
     354    <td>
     355      <table cellpadding="0" cellspacing="0" border="0">
     356        <tr>
     357          <td colspan="2" align="center"><!-- show next/previous X posts -->
     358            <form name="previousXposts" method="get"><?php
    332359if ($previousXstart > -1) {
    333360?>
    334 <input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
    335 <input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
    336 <input type="submit" name="submitprevious" class="search" value="< Previous <?php echo $posts ?>" /><?php
    337 }
    338 ?></form></td><td><form name="nextXposts" method="get">
    339 <input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
    340 <input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
    341 <input type="submit" name="submitnext" class="search" value="Next <?php echo $posts ?> >" /></form>
    342 </td>
    343 </tr>
    344 </table>
    345 </td>
    346 </tr>
    347 <tr>
    348 <td valign="top" width="200"><!-- show X first/last posts -->
    349 <form name="showXfirstlastposts" method="get">
    350 <input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
    351 <select name="order">&nbsp;<option value="DESC" <?php
     361              <input type="hidden" name="poststart" value="<?php echo $previousXstart; ?>" />
     362              <input type="hidden" name="postend" value="<?php echo $previousXend; ?>" />
     363              <input type="submit" name="submitprevious" class="search" value="< Previous <?php echo $posts ?>" /><?php
     364}
     365?>
     366            </form>
     367          </td>
     368          <td>
     369            <form name="nextXposts" method="get">
     370              <input type="hidden" name="poststart" value="<?php echo $nextXstart; ?>" />
     371              <input type="hidden" name="postend" value="<?php echo $nextXend; ?>" />
     372              <input type="submit" name="submitnext" class="search" value="Next <?php echo $posts ?> >" />
     373            </form>
     374          </td>
     375        </tr>
     376      </table>
     377    </td>
     378  </tr>
     379  <tr>
     380    <td valign="top" width="200"><!-- show X first/last posts -->
     381      <form name="showXfirstlastposts" method="get">
     382        <input type="text" name="posts" value="<?php echo $posts ?>" style="width:40px;" /?>
     383        <select name="order">&nbsp;<option value="DESC" <?php
    352384$i = $order;
    353385if ($i == "DESC")
     
    358390echo " selected";
    359391?>>first posts</option>
    360 </select>&nbsp;<input type="submit" name="submitfirstlast" class="search" value="OK" />
    361 </form>
    362 </td>
    363 <td valign="top"><!-- show post X to post X -->
    364 <form name="showXfirstlastposts" method="get">
    365 <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">
    366 <option value="DESC" <?php
     392        </select>&nbsp;<input type="submit" name="submitfirstlast" class="search" value="OK" />
     393      </form>
     394    </td>
     395    <td valign="top"><!-- show post X to post X -->
     396      <form name="showXfirstlastposts" method="get">
     397        <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">
     398          <option value="DESC" <?php
    367399$i = $order;
    368400if ($i == "DESC")
     
    373405echo " selected";
    374406?>>from the start</option>
    375 </select>&nbsp;<input type="submit" name="submitXtoX" class="search" value="OK" /></form>
    376 </td>
    377 
    378 </tr>
    379 </table>
     407          </select>&nbsp;<input type="submit" name="submitXtoX" class="search" value="OK" />
     408        </form>
     409      </td>
     410    </tr>
     411  </table>
    380412<?php echo $tablebottom ?>
  • trunk/b2-include/b2functions.php

    r9 r12  
    519519            'Date' => $myrow->post_date,
    520520            'Content' => $myrow->post_content,
     521            'Excerpt' => $myrow->post_excerpt,
    521522            'Title' => $myrow->post_title,
    522523            'Category' => $myrow->post_category,
     
    535536        'Date' => $row->post_date,
    536537        'Content' => $row->post_content,
     538        'Excerpt' => $row->post_excerpt,
    537539        'Title' => $row->post_title,
    538540        'Category' => $row->post_category,
  • trunk/b2-include/b2template.functions.php

    r8 r12  
    370370    return($output);
    371371}
     372
     373function the_excerpt() {
     374    $excerpt = get_the_excerpt();
     375    $excerpt = convert_bbcode($excerpt);
     376    $excerpt = convert_gmcode($excerpt);
     377    $excerpt = convert_smilies($excerpt);
     378    $excerpt = convert_chars($excerpt, 'html');
     379    $excerpt = apply_filters('the_excerpt', $excerpt);
     380    echo $excerpt;
     381}
     382
     383function the_excerpt_rss($cut = 0, $encode_html = 0) {
     384    $excerpt = get_the_excerpt();
     385    $excerpt = convert_bbcode($excerpt);
     386    $excerpt = convert_gmcode($excerpt);
     387    $excerpt = convert_chars($excerpt, 'unicode');
     388    if ($cut && !$encode_html) {
     389        $encode_html = 2;
     390    }
     391    if ($encode_html == 1) {
     392        $excerpt = htmlspecialchars($excerpt);
     393        $cut = 0;
     394    } elseif ($encode_html == 0) {
     395        $excerpt = make_url_footnote($excerpt);
     396    } elseif ($encode_html == 2) {
     397        $excerpt = strip_tags($excerpt);
     398    }
     399    if ($cut) {
     400        $blah = explode(' ', $excerpt);
     401        if (count($blah) > $cut) {
     402            $k = $cut;
     403            $use_dotdotdot = 1;
     404        } else {
     405            $k = count($blah);
     406            $use_dotdotdot = 0;
     407        }
     408        for ($i=0; $i<$k; $i++) {
     409            $excerpt .= $blah[$i].' ';
     410        }
     411        $excerpt .= ($use_dotdotdot) ? '...' : '';
     412        $excerpt = $excerpt;
     413    }
     414    echo $excerpt;
     415}
     416function the_excerpt_unicode() {
     417    $excerpt = get_the_excerpt();
     418    $excerpt = convert_bbcode($excerpt);
     419    $excerpt = convert_gmcode($excerpt);
     420    $excerpt = convert_smilies($excerpt);
     421    $excerpt = convert_chars($excerpt, 'unicode');
     422    $excerpt = apply_filters('the_excerpt_unicode', $excerpt);
     423    echo $excerpt;
     424}
     425function get_the_excerpt() {
     426    global $id,$postdata;
     427    global $HTTP_SERVER_VARS, $preview;
     428    $output = '';
     429    $output = $postdata['Excerpt'];
     430    if ($preview) { // preview fix for javascript bug with foreign languages
     431        $output =  preg_replace('/\%u([0-9A-F]{4,4})/e',  "'&#'.base_convert('\\1',16,10).';'", $output);
     432    }
     433    return($output);
     434}
     435
     436
     437
    372438
    373439function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') {
     
    11241190            'Date' => $HTTP_GET_VARS['preview_date'],
    11251191            'Content' => $HTTP_GET_VARS['preview_content'],
     1192            'Excerpt' => $HTTP_GET_VARS['preview_excerpt'],
    11261193            'Title' => $HTTP_GET_VARS['preview_title'],
    11271194            'Category' => $HTTP_GET_VARS['preview_category'],
  • trunk/b2edit.php

    r3 r12  
    2020}
    2121
    22 $b2varstoreset = array('action','safe_mode','withcomments','c','posts','poststart','postend','content','edited_post_title','comment_error','profile', 'trackback_url');
     22$b2varstoreset = array('action','safe_mode','withcomments','c','posts','poststart','postend','content','edited_post_title','comment_error','profile', 'trackback_url', 'excerpt');
    2323for ($i=0; $i<count($b2varstoreset); $i += 1) {
    2424    $b2var = $b2varstoreset[$i];
     
    4747    $content = balanceTags($HTTP_POST_VARS["content"]);
    4848    $content = format_to_post($content);
     49    $excerpt = balanceTags($HTTP_POST_VARS["excerpt"]);
     50    $excerpt = format_to_post($excerpt);
    4951    $post_title = addslashes($HTTP_POST_VARS["post_title"]);
    5052    $post_category = intval($HTTP_POST_VARS["post_category"]);
     
    6971    }
    7072
    71     $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."')";
     73    $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."')";
    7274    $result = mysql_query($query) or mysql_oops($query);
    7375
     
    129131    $content = $postdata["Content"];
    130132    $content = format_to_edit($content);
     133    $excerpt = $postdata["Excerpt"];
     134    $excerpt = format_to_edit($excerpt);
    131135    $edited_post_title = format_to_edit($postdata["Title"]);
    132136
     
    160164    $content = balanceTags($HTTP_POST_VARS["content"]);
    161165    $content = format_to_post($content);
     166    $excerpt = balanceTags($HTTP_POST_VARS["excerpt"]);
     167    $excerpt = format_to_post($excerpt);
    162168    $post_title = addslashes($HTTP_POST_VARS["post_title"]);
    163169
     
    178184    }
    179185
    180     $query = "UPDATE $tableposts SET post_content=\"$content\", post_title=\"$post_title\", post_category=\"$post_category\"".$datemodif." WHERE ID=$post_ID";
     186    $query = "UPDATE $tableposts SET post_content=\"$content\", post_excerpt=\"$excerpt\", post_title=\"$post_title\", post_category=\"$post_category\"".$datemodif." WHERE ID=$post_ID";
    181187    $result = mysql_query($query) or mysql_oops($query);
    182188
  • trunk/index.php

    r5 r12  
    3737
    3838<div class="storyContent">
     39<div class="storyExcerpt">
     40<?php the_excerpt(); ?>
     41</div>
    3942<?php the_content(); ?>
    4043
  • trunk/layout2b.css

    r3 r12  
    6464#content>.storyContent+.storyContent {text-indent:30px;}
    6565
     66.storyExcerpt {
     67    font:12px/18px verdana, arial, helvetica, sans-serif;
     68    font-weight: bold;
     69}
    6670
    6771a {
Note: See TracChangeset for help on using the changeset viewer.