Beispiel #1
0
 /**
  * BEARバッジ表示
  *
  * <pre>
  * エラー状態を表し、__bearページにリンクするデバック時に
  * 画面右上に現れる「BEARバッジ」を表示します。
  *
  * ページの状態によって色が変わります。
  * </pre>
  * <ur>
  * <li>赤 Fatal, PEARエラーなど</li>
  * <li>黄 Warningレベルのエラーはあり</li>
  * <li>青 noticeは出てる</li>
  * <li>緑 noticeも出てない</li>
  * </url>
  *
  * @return string
  */
 public static function onOutpuHtmlDebug($html)
 {
     $ua = BEAR::dependency('BEAR_Agent')->getUa();
     $hasResource = BEAR::factory('BEAR_Ro_Debug')->hasResourceDebug();
     $app = BEAR::get('app');
     if (!$app['core']['debug']) {
         return;
     }
     // エラー統計
     $errorFgColor = "white";
     $errors = Panda::getAllErrors();
     $errorStat = Panda::getErrorStat();
     $errorMsg = implode("\n", $errors);
     if ($errorStat & E_ERROR || $errorStat & E_USER_ERROR || $errorStat & E_RECOVERABLE_ERROR) {
         $errorBgColor = "red";
         $errorMsg = "Fatal Error: {$errorMsg}";
         $bear = "BEAR - Error";
     } elseif ($errorStat & E_WARNING || $errorStat & E_USER_WARNING) {
         $errorBgColor = "yellow";
         $errorFgColor = "black";
         $errorMsg = "WARNING: {$errorMsg}";
         $bear = "BEAR - Warning";
     } elseif ($errorStat & E_NOTICE || $errorStat & E_USER_NOTICE) {
         $errorBgColor = "#2D41D7";
         $errorMsg = "NOTICE: {$errorMsg}";
         $bear = "BEAR";
     } else {
         $errorBgColor = "green";
         $errorMsg = "{$errorMsg}";
         $bear = "BEAR";
     }
     // デバック情報表示HTML
     // bear.jsを使用する場合はbear_debuggingがtrueになる
     if (file_exists(_BEAR_APP_HOME . '/htdocs/__edit')) {
         $editHtml = '<a href="/__edit/?id=@@@log_id@@@"';
         $editHtml .= ' class="bear_page_edit" style="padding:5px 3px 3px 3px;background-color: gray';
         $editHtml .= ';color:white; font:bold 8pt Verdana;';
         $editHtml .= 'border: 1px solid #dddddd">EDIT</a>';
     } else {
         $editHtml = '';
     }
     // リソースBoxリンク
     $color = "blue";
     $res = array();
     if (!isset($_GET['_resource'])) {
         $mode = 'box';
         $title = "Resource Box";
         $color = "grey";
     } elseif ($_GET['_resource'] == 'box') {
         $mode = 'body';
         $title = "Resource Body";
     } elseif ($_GET['_resource'] == 'body') {
         $mode = 'html';
         $title = "Resource HTML";
     } else {
         $mode = false;
         $title = "No Resource Box";
     }
     $currentMode = isset($_GET['_resource']) ? $_GET['_resource'] : 'none';
     $res = $mode ? array('_resource' => $mode) : array();
     unset($_GET['_resource']);
     $resourceBoxUrl = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) . '?' . http_build_query(array_merge($_GET, $res));
     $budgeHtml = '<div id="bear_badge">';
     $budgeHtml .= $editHtml;
     if ($hasResource === true) {
         $budgeHtml .= '<a href="' . $resourceBoxUrl . '" class="bear_resource_' . $currentMode . '" title="' . $title . '">RES</a>';
     }
     $budgeHtml .= '<a href="/__bear/?id=@@@log_id@@@" class="bear_badge" title="';
     $budgeHtml .= $errorMsg . '" style="background-color:' . $errorBgColor;
     $budgeHtml .= ';color:' . $errorFgColor . ';';
     $budgeHtml .= '">' . $bear . '</a><a href="?_bearinfo" class="bear_info">i</a></div>';
     $budgeHtml = str_replace('</body>', "{$budgeHtml}" . '<link rel="stylesheet" href="/__bear/css/debug.css" type="text/css">' . "</body>", $html);
     return $budgeHtml;
 }