Changeset 1372 for branches/release-30/lib/MT/Builder.pm
- Timestamp:
- 02/14/08 22:31:01 (22 months ago)
- Files:
-
- 1 modified
-
branches/release-30/lib/MT/Builder.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-30/lib/MT/Builder.pm
r1174 r1372 283 283 #print STDERR syntree2str($tokens,0) unless $count++ == 1; 284 284 285 my $timer; 286 if ($MT::DebugMode & 8) { 287 $timer = MT->get_timer(); 288 } 289 285 290 if ($cond) { 286 291 my %lcond; … … 331 336 my($h, $type) = $ctx->handler_for($t->[0]); 332 337 if ($h) { 333 my $start; 334 if ($MT::DebugMode & 8) { 335 require Time::HiRes; 336 $start = [ Time::HiRes::gettimeofday() ]; 337 } 338 $timer->pause_partial if $timer; 338 339 local($ctx->{__stash}{tag}) = $t->[0]; 339 340 local($ctx->{__stash}{tokens}) = ref($tokens) ? bless $tokens, 'MT::Template::Tokens' : undef; … … 382 383 my $err = $ctx->errstr; 383 384 if (defined $err) { 384 return $build->error(MT->translate("Error in <mt :[_1]> tag: [_2]", $t->[0], $ctx->errstr));385 return $build->error(MT->translate("Error in <mt[_1]> tag: [_2]", $t->[0], $ctx->errstr)); 385 386 } 386 387 else { … … 402 403 $res .= $out 403 404 if defined $out; 404 if ($MT::DebugMode & 8) { 405 my $elapsed = Time::HiRes::tv_interval($start); 406 print STDERR "Builder: Tag [" . $t->[0] . "] - $elapsed seconds\n" if $elapsed > 0.25; 405 406 if ($timer) { 407 $timer->mark("tag_" 408 . lc($t->[0]) . args_to_string(\%args)); 407 409 } 408 410 } else { … … 417 419 } 418 420 421 sub args_to_string { 422 my ($args) = @_; 423 my $str = ''; 424 foreach my $a (keys %$args) { 425 next if $a eq '@'; 426 next unless defined $args->{$a}; 427 next if $args->{$a} eq ''; 428 $str .= ';' . $a . ':'; 429 if (ref $args->{$a} eq 'ARRAY') { 430 foreach my $aa (@{ $args->{$a} }) { 431 $aa = '...' if $aa =~ m/ /; 432 $str .= $aa . ';'; 433 } 434 chop($str); 435 } else { 436 $str .= $args->{$a} =~ m/ / ? '...' : $args->{$a}; 437 } 438 } 439 my $more_args = $args->{'@'}; 440 if ($more_args && @$more_args) { 441 foreach my $a (@$more_args) { 442 if (ref $a->[1] eq 'ARRAY') { 443 $str .= ' ' . $a->[0] . '='; 444 foreach my $aa (@{ $a->[1] }) { 445 $aa = '...' if $aa =~ m/ /; 446 $str .= $aa . ';'; 447 } 448 chop($str); 449 } else { 450 next if exists $args->{$a->[0]} 451 && ($args->{$a->[0]} eq $a->[1]); 452 next unless defined $args->[1]; 453 next if $args->[1] eq ''; 454 $str .= ';' . $a->[0] . ':'; 455 $str .= $a->[1]; 456 } 457 } 458 } 459 return $str ne '' ? '[' . substr($str,1) . ']' : ''; 460 } 419 461 1; 420 462 __END__
