performance indicators

This commit is contained in:
JT Smith 2005-09-09 19:57:58 +00:00
parent 0dd6b7b660
commit 283839a077
4 changed files with 27 additions and 9 deletions

View file

@ -17,6 +17,7 @@ package WebGUI::Asset::Template;
use HTML::Template;
use strict;
use WebGUI::Asset;
use WebGUI::ErrorHandler;
use WebGUI::HTTP;
use WebGUI::Session;
use WebGUI::SQL;

View file

@ -16,6 +16,7 @@ package WebGUI::Asset::Wobject::Layout;
use strict;
use WebGUI::Asset::Wobject;
use WebGUI::ErrorHandler;
use WebGUI::Icon;
use WebGUI::Session;
use WebGUI::Utility;
@ -149,6 +150,7 @@ sub view {
$numPositions = $j if $template =~ m/position${j}\_loop/;
}
my @found;
my $showPerformance = WebGUI::ErrorHandler::canShowPerformanceIndicators();
foreach my $position (@positions) {
my @assets = split(",",$position);
foreach my $asset (@assets) {
@ -156,15 +158,18 @@ sub view {
if ($asset eq $child->getId) {
unless (isIn($asset,@hidden) || !($child->canView)) {
WebGUI::Style::setRawHeadTags($child->getExtraHeadTags);
my $t = [Time::HiRes::gettimeofday()] if ($showPerformance);
my $view = $child->view;
$view .= "Asset:".Time::HiRes::tv_interval($t) if ($showPerformance);
if ($i > $numPositions) {
push(@{$vars{"position1_loop"}},{
id=>$child->getId,
content=>$child->view
content=>$view
});
} else {
push(@{$vars{"position".$i."_loop"}},{
id=>$child->getId,
content=>$child->view
content=>$view
});
}
}
@ -177,10 +182,15 @@ sub view {
# deal with unplaced children
foreach my $child (@{$children}) {
unless (isIn($child->getId, @found)||isIn($child->getId,@hidden)) {
push(@{$vars{"position1_loop"}},{
id=>$child->getId,
content=>$child->view
}) if $child->canView;
if ($child->canView) {
my $t = [Time::HiRes::gettimeofday()] if ($showPerformance);
my $view = $child->view;
$view .= "Asset:".Time::HiRes::tv_interval($t) if ($showPerformance);
push(@{$vars{"position1_loop"}},{
id=>$child->getId,
content=>$view
});
}
}
}
$vars{showAdmin} = ($session{var}{adminOn} && $self->canEdit);

View file

@ -91,7 +91,7 @@ sub canShowDebug {
(
$WebGUI::Session::session{setting}{showDebug}
) && (
$WebGUI::Session::session{setting}{debugIp} =~ /^$WebGUI::Session::session{env}{REMOTE_ADDR}/ ||
$WebGUI::Session::session{env}{REMOTE_ADDR} =~ /^$WebGUI::Session::session{setting}{debugIp}/ ||
$WebGUI::Session::session{setting}{debugIp} eq ""
)
);
@ -106,11 +106,13 @@ Returns true if the user meets the conditions to see performance indicators and
=cut
sub canShowPerformanceIndicators {
my $mask = $WebGUI::Session::session{setting}{debugIp};
my $ip = $WebGUI::Session::session{env}{REMOTE_ADDR};
return (
(
$WebGUI::Session::session{setting}{showPerformanceIndicators}
) && (
$WebGUI::Session::session{setting}{debugIp} =~ /^$session{env}{REMOTE_ADDR}/ ||
$ip =~ /^$mask/ ||
$WebGUI::Session::session{setting}{debugIp} eq ""
)
);

View file

@ -11,18 +11,23 @@ package WebGUI::Macro::AssetProxy;
#-------------------------------------------------------------------
use strict;
use Time::HiRes;
use WebGUI::Asset;
use WebGUI::ErrorHandler;
use WebGUI::Macro;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my ($url) = WebGUI::Macro::getParams(shift);
my $t = [Time::HiRes::gettimeofday()] if (WebGUI::ErrorHandler::canShowPerformanceIndicators());
my $asset = WebGUI::Asset->newByUrl($url);
#Sorry, you cannot proxy the notfound page.
if (defined $asset && $asset->getId ne $session{setting}{notFoundPage}) {
$asset->toggleToolbar;
return $asset->canView ? $asset->view : undef;
my $output = $asset->canView ? $asset->view : undef;
$output .= "AssetProxy:".Time::HiRes::tv_interval($t) if (WebGUI::ErrorHandler::canShowPerformanceIndicators());
return $output;
} else {
return "Invalid Asset URL";
}