diff options
author | carlgmathisen <> | 2009-07-20 11:53:36 +0000 |
---|---|---|
committer | carlgmathisen <> | 2009-07-20 11:53:36 +0000 |
commit | 5aaf2cecb4e365c5503c3167535303d3300a6b6d (patch) | |
tree | 21eecd93d26047b1367c19716b5b68da4fe6b332 | |
parent | 975bad9be0777a28326291f0d8fcae41d788200c (diff) |
#183 - Add property CssClass to TBrowserLog otuput and hide inline CSS
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | framework/Util/TLogRouter.php | 87 |
2 files changed, 79 insertions, 9 deletions
@@ -14,6 +14,7 @@ ENH: TAssetManager: introduce protected property "Published" to allow subclasses ENH: TFirePhpLogRoute: bypass to TBrowserLogRoute if headers already sent / php.ini (output_buffering=Off, implicit_flush=On) (Yves) EHN: Performance optimization in PradoBase::createComponent() (Yves) EHN: Add property TPage.EnableStateCompression and related modifications in TPageStateFormatter since it is unnecessary to compress clientstate if TCachePageStatePersister/TSessionPageStatePersister is used (Yves) +ENH: Add property CssClass to TBrowserLog otuput and hide inline CSS (Carl) Version 3.1.5 May 24, 2009 BUG: Issue#55 - TPropertyAccess.get and has don't recognize magic getter __get (Yves) diff --git a/framework/Util/TLogRouter.php b/framework/Util/TLogRouter.php index 64a241fb..3c022690 100644 --- a/framework/Util/TLogRouter.php +++ b/framework/Util/TLogRouter.php @@ -604,6 +604,11 @@ class TEmailLogRoute extends TLogRoute */
class TBrowserLogRoute extends TLogRoute
{
+ /**
+ * @var string css class for indentifying the table structure in the dom tree
+ */
+ private $_cssClass=null;
+
public function processLogs($logs)
{
if(empty($logs) || $this->getApplication()->getMode()==='Performance') return;
@@ -628,10 +633,43 @@ class TBrowserLogRoute extends TLogRoute }
$response->write($this->renderFooter());
}
+
+ /**
+ * @param string the css class of the control
+ */
+ public function setCssClass($value)
+ {
+ $this->_cssClass = TPropertyValue::ensureString($value);
+ }
+
+ /**
+ * @return string the css class of the control
+ */
+ public function getCssClass()
+ {
+ return TPropertyValue::ensureString($this->_cssClass);
+ }
protected function renderHeader()
{
- $string = <<<EOD
+ $string = '';
+ if($className=$this->getCssClass())
+ {
+ $string = <<<EOD
+<table class="$className">
+ <tr class="header">
+ <th colspan="5">
+ Application Log
+ </th>
+ </tr><tr class="description">
+ <th> </th>
+ <th>Category</th><th>Message</th><th>Time Spent (s)</th><th>Cumulated Time Spent (s)</th>
+ </tr>
+EOD;
+ }
+ else
+ {
+ $string = <<<EOD
<table cellspacing="0" cellpadding="2" border="0" width="100%" style="table-layout:auto">
<tr>
<th style="background-color: black; color:white;" colspan="5">
@@ -642,18 +680,36 @@ class TBrowserLogRoute extends TLogRoute <th style="width: auto">Category</th><th style="width: auto">Message</th><th style="width: 120px">Time Spent (s)</th><th style="width: 150px">Cumulated Time Spent (s)</th>
</tr>
EOD;
+ }
return $string;
}
protected function renderMessage($log, $info)
{
- $bgcolor = $info['even'] ? "#fff" : "#eee";
+ $string = '';
$total = sprintf('%0.6f', $info['total']);
$delta = sprintf('%0.6f', $info['delta']);
- $color = $this->getColorLevel($log[1]);
$msg = preg_replace('/\(line[^\)]+\)$/','',$log[0]); //remove line number info
$msg = THttpUtility::htmlEncode($msg);
- $string = <<<EOD
+ if($this->getCssClass())
+ {
+ $colorCssClass = $log[1];
+ $messageCssClass = $info['even'] ? 'even' : 'odd';
+ $string = <<<EOD
+ <tr class="message level$colorCssClass $messageCssClass">
+ <td class="code"> </td>
+ <td class="category">{$log[2]}</td>
+ <td class="message">{$msg}</td>
+ <td class="time">{$delta}</td>
+ <td class="cumulatedtime">{$total}</td>
+ </tr>
+EOD;
+ }
+ else
+ {
+ $bgcolor = $info['even'] ? "#fff" : "#eee";
+ $color = $this->getColorLevel($log[1]);
+ $string = <<<EOD
<tr style="background-color: {$bgcolor}; color:#000">
<td style="border:1px solid silver;background-color: $color;"> </td>
<td>{$log[2]}</td>
@@ -662,6 +718,7 @@ EOD; <td style="text-align:center">{$total}</td>
</tr>
EOD;
+ }
return $string;
}
@@ -682,13 +739,25 @@ EOD; protected function renderFooter()
{
- $string = "<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">";
- foreach(self::$_levelValues as $name => $level)
+ $string = '';
+ if($this->getCssClass())
{
- $string .= "<span style=\"color:white; border:1px solid white; background-color:".$this->getColorLevel($level);
- $string .= ";margin: 0.5em; padding:0.01em;\">".strtoupper($name)."</span>";
+ $string .= '<tr class="footer"><td colspan="5">';
+ foreach(self::$_levelValues as $name => $level)
+ {
+ $string .= '<span class="level'.$level.'">'.strtoupper($name)."</span>";
+ }
+ }
+ else
+ {
+ $string .= "<tr><td colspan=\"5\" style=\"text-align:center; background-color:black; border-top: 1px solid #ccc; padding:0.2em;\">";
+ foreach(self::$_levelValues as $name => $level)
+ {
+ $string .= "<span style=\"color:white; border:1px solid white; background-color:".$this->getColorLevel($level);
+ $string .= ";margin: 0.5em; padding:0.01em;\">".strtoupper($name)."</span>";
+ }
}
- $string .= "</td></tr></table>";
+ $string .= '</td></tr></table>';
return $string;
}
}
|