--- lib/MT/App.pm~	Thu May 29 02:31:53 2003
+++ lib/MT/App.pm	Fri Aug 22 03:46:45 2003
@@ -52,6 +52,9 @@
 sub send_http_header {
     my $app = shift;
     my($type) = @_;
+    if ($ENV{'HTTP_CONTENT_TYPE'}){
+      $type= $ENV{'HTTP_CONTENT_TYPE'};
+    }
     $type ||= 'text/html';
     if (my $charset = $app->{charset}) {
         $type .= "; charset=$charset"
@@ -185,7 +188,7 @@
     my($error) = @_;
     my $tmpl;
     $error = encode_html($error);
-    $error =~ s!(http://\S+)!<a href="$1" target="_blank">$1</a>!g;
+    $error =~ s!(http://\S+)!<a href="$1">$1</a>!g;
     $tmpl = $app->load_tmpl('error.tmpl') or
         return "Can't load error template; got error '" . $app->errstr .
                "'. Giving up. Original error was <pre>$error</pre>";

--- lib/MT/Template/Context.pm.orig	Tue Jan 13 20:41:05 2004
+++ lib/MT/Template/Context.pm	Wed Jan 14 21:09:34 2004
@@ -863,7 +863,7 @@
     my $show_email = 1 unless exists $args->{show_email};
     my $show_url = 1 unless exists $args->{show_url};
     if ($show_url && $a->url) {
-        return sprintf qq(<a target="_blank" href="%s">%s</a>), $a->url, $name;
+        return sprintf qq(<a href="%s">%s</a>), $a->url, $name;
     } elsif ($show_email && $a->email) {
         my $str = "mailto:" . $a->email;
         $str = spam_protect($str) if $args->{'spam_protect'};
@@ -1186,7 +1186,7 @@
 	my $cgi_path = MT::ConfigMgr->instance->CGIPath;
 	$cgi_path =~ s#([^/])$#$1/#;
 	my $comment_script = MT::ConfigMgr->instance->CommentScript;
-	return sprintf(qq(<a target="_blank" href="%s%s?__mode=red&u=%s">%s</a>),
+	return sprintf(qq(<a href="%s%s?__mode=red&amp;u=%s">%s</a>),
 		       $cgi_path, $comment_script, $url, $name);
     } elsif ($show_email && $c->email) {
         my $email = remove_html($c->email);
--- schemas/mysql.dump.orig	Wed Feb  5 19:00:42 2003
+++ schemas/mysql.dump	Thu May 29 14:54:57 2003
@@ -80,12 +80,16 @@
     comment_email varchar(75),
     comment_url varchar(255),
     comment_text text,
+    comment_subject text,
+    comment_parent_id integer,
+    comment_convert_breaks varchar(30),
     comment_created_on datetime not null,
     comment_modified_on timestamp not null,
     comment_created_by integer,
     comment_modified_by integer,
     index (comment_created_on),
     index (comment_entry_id),
+    index (comment_parent_id),
     index (comment_blog_id)
 );
 
@@ -192,6 +196,7 @@
     template_linked_file varchar(255),
     template_linked_file_mtime varchar(10),
     template_linked_file_size mediumint,
+    template_rebuild_type text,
     unique (template_blog_id, template_name),
     index (template_type)
 );

--- lib/MT/App/CMS.pm.orig	Sat Apr  5 13:26:01 2003
+++ lib/MT/App/CMS.pm	Wed May 14 12:15:55 2003
@@ -525,6 +525,12 @@
                 $param{has_rebuild} = $obj->type eq 'index';
                 $param{rebuild_me} = defined $obj->rebuild_me ?
                     $obj->rebuild_me : 1;
+                ##
+                # sean willson - http://www.seanwillson.com/
+                #
+                $param{rebuild_type} = defined $obj->rebuild_type ? $obj->rebuild_type : 'EnCo';
+                $param{'rebuild_type_'.$param{rebuild_type}} = 1;
+                ##
             } elsif ($type eq 'blog') {
                 $blog_id = $obj->id;
                 my $at = $obj->archive_type;
@@ -677,6 +683,12 @@
                 $param{has_outfile} = $q->param('type') eq 'index';
                 $param{has_rebuild} = $q->param('type') eq 'index';
                 $param{rebuild_me} = 1;
+                ##
+                # sean willson - http://www.seanwillson.com/
+                #
+                $param{rebuild_type} = 'EnCo';
+                $param{'rebuild_type_enco'} = 1;
+                ##
             } elsif ($type eq 'blog') {
                 $param{server_offset_0} = 1;
             }
@@ -1150,6 +1162,12 @@
                 @$ref = sort { $a->{name} cmp $b->{name} } @$ref;
                 for my $i (0..$#$ref) {
                     $ref->[$i]{is_odd} = $i % 2 ? 0 : 1;
+                    ##
+                    # sean willson - http://www.seanwillson.com/
+                    #
+                    $ref->[$i]{rebuild_type} = defined $ref->[$i]{rebuild_type} ? $ref->[$i]{rebuild_type} : 'EnCo';
+                    $ref->[$i]{'rebuild_type_'.$ref->[$i]{rebuild_type}} = 1;
+                    ##
                 }
             }
             $param{object_index_loop} = \@index_data;
@@ -2150,10 +2168,29 @@
     $ctx->stash('entry', $entry);
     $ctx->stash('blog', $blog);
     my $build = MT::Builder->new;
+    $ctx->stash('blog_id', $blog_id);
     my $preview_code = <<'HTML';
-<p><b><$MTEntryTitle$></b></p>
-<$MTEntryBody$>
-<$MTEntryMore$>
+<MTValidate>
+<$MTInclude module="DTD"$>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Your Comment</title>
+</head>
+<body>
+<h3 class="title"><$MTEntryTitle smarty_pants="2"$></h3>
+
+<$MTEntryBody smarty_pants="2" process_tags="1"$>
+<$MTEntryMore smarty_pants="2" process_tags="1"$>
+</body>
+</html>
+</MTValidate>
+
+<MTValidateIfValid>
+<h3 class="title"><$MTEntryTitle smarty_pants="2"$></h3>
+
+<$MTEntryBody smarty_pants="2"$>
+<$MTEntryMore smarty_pants="2"$>
+</MTValidateIfValid>
 HTML
     my $tokens = $build->compile($ctx, $preview_code)
         or return $app->error($app->translate(
@@ -2291,14 +2328,25 @@
     } elsif ($type eq 'index') {
         return $app->error($app->translate("Permission denied."))
             unless $perms->can_rebuild;
-        $app->rebuild_indexes( BlogID => $blog_id ) or return;
+        ##
+        # sean willson - http://www.seanwillson.com/
+        # added a rebuild type parameter so that it would only rebuild
+        # the indexes that i designated appropriate.
+        #
+        $app->rebuild_indexes( BlogID => $blog_id, RebuildType => 'In' ) or return;
+        ##
     } elsif ($type =~ /^index-(\d+)$/) {
         return $app->error($app->translate("Permission denied."))
             unless $perms->can_rebuild;
         my $tmpl_id = $1;
         require MT::Template;
         $tmpl_saved = MT::Template->load($tmpl_id);
-        $app->rebuild_indexes( BlogID => $blog_id, Template => $tmpl_saved,
+        ##
+        # sean willson - http://www.seanwillson.com/
+        # added a rebuild type parameter so that it would only rebuild
+        # the indexes that i designated appropriate.
+        #
+        $app->rebuild_indexes( BlogID => $blog_id, Template => $tmpl_saved, RebuildType => 'In',
                                Force => 1 )
             or return;
         $order = "index template '" . $tmpl_saved->name . "'";
--- lib/MT/App/Comments.pm.orig	Mon Feb 24 11:16:12 2003
+++ lib/MT/App/Comments.pm	Wed May 14 12:21:57 2003
@@ -106,9 +106,15 @@
     $comment->subject($q->param('subject'));
     $comment->parent_id($q->param('parent_id'));
     $comment->save;
-    $app->rebuild_indexes( Blog => $blog )
+    ##
+    # sean willson - http://www.seanwillson.com/
+    # added a rebuild type parameter so that it would only rebuild
+    # the indexes that i designated appropriate.
+    #
+    $app->rebuild_indexes( Blog => $blog, RebuildType => 'Co' )
         or return $app->error($app->translate(
             "Rebuild failed: [_1]", $app->errstr));
+    ##
     $app->rebuild_entry( Entry => $entry )
         or return $app->error($app->translate(
             "Rebuild failed: [_1]", $app->errstr));

--- tmpl/cms/edit_template.tmpl.orig	Mon Feb 24 11:15:19 2003
+++ tmpl/cms/edit_template.tmpl	Wed May 14 12:27:08 2003
@@ -150,12 +150,33 @@
 	</TMPL_IF>
 
 	<TMPL_IF NAME=HAS_REBUILD>
+  
+  <!--
 	<tr>
 	<td valign="top"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="1" height="12"></td>
 	</tr>
 
 	<tr>
 	<td valign="top"><input type="checkbox" name="rebuild_me" value="1"<TMPL_IF NAME=REBUILD_ME> checked</TMPL_IF>>&nbsp;<font class="title"><MT_TRANS phrase="Rebuild this template automatically when rebuilding index templates"> <a href="#" onclick="openManual('item_rebuild_this_template_automatically')">(?)</a></td>
+	</tr>
+  -->
+  
+  <tr>
+	<td valign="top"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="1" height="12"></td>
+	</tr>
+
+	<tr>
+	<td valign="top"><font class="title"><MT_TRANS phrase="Rebuild Type"></font><br>
+  <select name="rebuild_type">
+  <option value="Ne" <TMPL_IF NAME=REBUILD_TYPE_NE>selected="selected"</TMPL_IF>><MT_TRANS phrase="Never"></option>
+  <option value="En" <TMPL_IF NAME=REBUILD_TYPE_EN>selected="selected"</TMPL_IF>><MT_TRANS phrase="Entry"></option>
+  <option value="Co" <TMPL_IF NAME=REBUILD_TYPE_CO>selected="selected"</TMPL_IF>><MT_TRANS phrase="Comment"></option>
+  <option value="Tb" <TMPL_IF NAME=REBUILD_TYPE_TB>selected="selected"</TMPL_IF>><MT_TRANS phrase="Trackback"></option>
+  <option value="EnCo" <TMPL_IF NAME=REBUILD_TYPE_ENCO>selected="selected"</TMPL_IF>><MT_TRANS phrase="Entry, Comment *"></option>
+  <option value="EnTb" <TMPL_IF NAME=REBUILD_TYPE_ENTB>selected="selected"</TMPL_IF>><MT_TRANS phrase="Entry, Trackback"></option>
+  <option value="CoTb" <TMPL_IF NAME=REBUILD_TYPE_COTB>selected="selected"</TMPL_IF>><MT_TRANS phrase="Comment, Trackback"></option>
+  <option value="All" <TMPL_IF NAME=REBUILD_TYPE_ALL>selected="selected"</TMPL_IF>><MT_TRANS phrase="All"></option>
+  </select></td>
 	</tr>
 	</TMPL_IF>
 

--- tmpl/cms/list_template.tmpl.orig	Mon Feb 24 11:15:19 2003
+++ tmpl/cms/list_template.tmpl	Wed May 14 12:29:43 2003
@@ -149,16 +149,21 @@
 			<tr>
 			<td width="205"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="205" height="1"></td>
 			<td width="177"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="177" height="1"></td>
+      <!--
 	 		<td width="45"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="45" height="1"></td>
+      -->
+      <td width="120"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="120" height="1"></td>
 	 		<td width="45"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="45" height="1"></td>
 	 		</tr>
 			 		
 			<tr>
 			<td width="205" valign="top" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Template Name"></font></td>
 			<td width="177" valign="top" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Output File"></font></td>
+      <!--
 			<td width="45" valign="top" align="center" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Rebuild?"></font></td>
+      -->
+      <td width="120" valign="top" align="center" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Rebuild Type"></font></td>
 	 		<td width="45" valign="top" align="center" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Delete"></font></td>
-				    
 			<tr>
 			<td valign="top"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="1" height="1"></td>
 			</tr>
@@ -167,7 +172,10 @@
 			<tr>
 			<td width="205" valign="top" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><a href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=view&_type=template&id=<TMPL_VAR NAME=ID>&blog_id=<TMPL_VAR NAME=BLOG_ID>"><TMPL_VAR NAME=NAME></a><br></font></td>
 			<td width="177" valign="top" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><TMPL_VAR NAME=OUTFILE></font></td>
+      <!-- 
 	 		<td width="45" valign="top" align="center" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><TMPL_IF NAME=REBUILD_ME><MT_TRANS phrase="Yes"><TMPL_ELSE><MT_TRANS phrase="No"></TMPL_IF></font></td>
+      -->
+      <td width="120" valign="top" align="center" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><TMPL_IF NAME=REBUILD_TYPE_NE><MT_TRANS phrase="Never"></TMPL_IF><TMPL_IF NAME=REBUILD_TYPE_ALL><MT_TRANS phrase="All"></TMPL_IF><TMPL_IF NAME=REBUILD_TYPE_EN><MT_TRANS phrase="Entry"></TMPL_IF><TMPL_IF NAME=REBUILD_TYPE_CO><MT_TRANS phrase="Comment"></TMPL_IF><TMPL_IF NAME=REBUILD_TYPE_TB><MT_TRANS phrase="Trackback"></TMPL_IF><TMPL_IF NAME=REBUILD_TYPE_ENCO><MT_TRANS phrase="Entry, Comment *"></TMPL_IF><TMPL_IF NAME=REBUILD_TYPE_ENTB><MT_TRANS phrase="Entry, Trackback"></TMPL_IF><TMPL_IF NAME=REBUILD_TYPE_COTB><MT_TRANS phrase="Comment, Trackback"></TMPL_IF></font></td>
 	 		<td width="45" valign="top" align="center" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><input type="checkbox" name="id" value="<TMPL_VAR NAME=ID>"></td>
 	 		</tr>
 			</TMPL_LOOP>

--- lib/MT.pm.orig	Fri Mar  7 16:28:37 2003
+++ lib/MT.pm	Wed May 14 12:32:49 2003
@@ -175,7 +175,13 @@
         }
     }
     unless ($param{NoIndexes}) {
-        $mt->rebuild_indexes( Blog => $blog ) or return;
+        ##
+        # sean willson - http://www.seanwillson.com/
+        # added a rebuild type parameter so that it would only rebuild
+        # the indexes that i designated appropriate.
+        #
+        $mt->rebuild_indexes( Blog => $blog, RebuildType => 'In' ) or return;
+        ##
     }
     1;
 }
@@ -234,7 +240,14 @@
     }
 
     ## Rebuild all indexes, in case this entry is on an index.
-    $mt->rebuild_indexes( Blog => $blog ) or return;
+    
+    ##
+    # sean willson - http://www.seanwillson.com/
+    # added a rebuild type parameter so that it would only rebuild
+    # the indexes that i designated appropriate.
+    #
+    $mt->rebuild_indexes( Blog => $blog, RebuildType => 'En' ) or return;
+    ##
 
     ## Rebuild previous and next daily, weekly, and monthly archives;
     ## adding a new entry could cause changes to the intra-archive
@@ -460,8 +473,28 @@
         ## before that time, the rebuild_me flag will be undefined. But
         ## we assume that these templates should be rebuilt, since that
         ## was the previous behavior.
-        next if !$param{Force} &&
-                defined $tmpl->rebuild_me && !$tmpl->rebuild_me;
+        
+        ##
+        # sean willson - http://www.seanwillson.com/
+        # commented this code out because the new rebuild type code overrides this.
+        #
+        #next if !$param{Force} &&
+        #        defined $tmpl->rebuild_me && !$tmpl->rebuild_me;
+        ##
+        
+        ##
+        # sean willson - http://www.seanwillson.com/
+        # made it so that it doesn't rebuild unless it is supposed to.
+        #
+        my $tmplRebuildType = defined $tmpl->rebuild_type ? $tmpl->rebuild_type : 'EnCo';
+        my $rebuildType = $param{RebuildType};
+        
+        next if ((! $param{Force}) && ($tmplRebuildType =~ /ne/gi));
+        
+        next if ((! $param{Force}) &&
+                 ($rebuildType !~ /in/gi) &&
+                 ($tmplRebuildType !~ /$rebuildType|all/gi));
+        ##
 
         my $ctx = MT::Template::Context->new;
         my $html = $tmpl->build($ctx);

--- lib/MT/Template.pm.orig	Mon Feb 24 11:15:19 2003
+++ lib/MT/Template.pm	Wed May 14 12:35:49 2003
@@ -25,7 +25,7 @@
     columns => [
         'id', 'blog_id', 'name', 'type', 'outfile', 'text',
         'linked_file', 'linked_file_mtime', 'linked_file_size',
-        'rebuild_me',
+        'rebuild_me','rebuild_type',
     ],
     indexes => {
         blog_id => 1,

--- lib/MT/App/Trackback.pm.orig	Wed May 14 11:46:58 2003
+++ lib/MT/App/Trackback.pm	Wed May 14 12:39:27 2003
@@ -197,10 +197,15 @@
     }
     require MT::Blog;
     my $blog = MT::Blog->load($blog_id);
-    $app->rebuild_indexes( Blog => $blog )
+    ##
+    # sean willson - http://www.seanwillson.com/
+    # added a rebuild type parameter so that it would only rebuild
+    # the indexes that i designated appropriate.
+    #
+    $app->rebuild_indexes( Blog => $blog, RebuildType => 'Tb' )
         or return $app->_response(Error =>
             $app->translate("Rebuild failed: [_1]", $app->errstr));
-
+    ##
     if ($app->{cfg}->GenerateTrackBackRSS) {
         ## Now generate RSS feed for this trackback item.
         my $rss = _generate_rss($tb, 10);
@@ -213,6 +218,16 @@
                 $fmgr->errstr));
     }
 
+    ##
+    # sean willson - http://www.seanwillson.com/
+    # added because i wanted to rebuild an entry after a trackback was submitted
+    # automatically. i added it after the previous block because i wasn't sure
+    # if the entry was going to need the trackback rss entry.
+    #
+    $app->rebuild_entry( Entry => $entry )
+        or return $app->error($app->translate(
+            "Rebuild failed: [_1]", $app->errstr)) if ($entry);
+    ##
     if ($blog->email_new_pings) {
         require MT::Mail;
         my($author, $subj, $body);
