Exemple #1
0
 /**
  * デバック用にリソースを表示
  *
  * <pre>
  * テンプレート付リソースの時、リソースの詳細情報が画面上に表示されます。
  * デバックモード時に_resourceクエリーを付加すれば有効になります。
  *
  * _resource=html リソーステンプレート適用されたHTML表示
  * _resource=body リソースのBodyをprinta形式で表示
  * </pre>
  *
  * @param BEAR_Ro $ro リソースオブジェクト
  *
  * @return string
  */
 public function getResourceToString(BEAR_Ro $ro)
 {
     self::$_hasResourceDebug = true;
     $config = $ro->getConfig();
     $chainLinks = $ro->getHeader('_linked');
     $resourceHtml = $ro->getHtml();
     if (!isset($_GET['_resource'])) {
         return $resourceHtml;
     }
     $body = $ro->getBody();
     if (isset($_GET['_resource'])) {
         if ($_GET['_resource'] === 'html') {
             $renderer = new Text_Highlighter_Renderer_Html(array('tabsize' => 4));
             $hlHtml = Text_Highlighter::factory("HTML");
             $hlHtml->setRenderer($renderer);
             if ($resourceHtml == '') {
                 $resourceHtml = '<span class="hl-all">(*Empty String)</span>';
             } else {
                 $resourceHtml = '<span class="hl-all">' . $hlHtml->highlight($resourceHtml) . '</span>';
             }
         } elseif ($_GET['_resource'] === 'body') {
             $resourceHtml = print_a($body, 'return:1');
             $logs = $ro->getHeader('_log');
             foreach ((array) $logs as $logKey => $logVal) {
                 $resourceHtml .= '<div class="bear-resource-info-label">' . $logKey . '</div>';
                 $resourceHtml .= is_scalar($logVal) ? $logVal : print_a($logVal, 'return:1');
             }
         }
     }
     //class editor
     if (class_exists($config['class'], false)) {
         $classEditorLink = $this->_getClassEditorLink($config['class'], $config['uri']);
     } else {
         $classEditorLink = $config['uri'];
     }
     $labelUri = "{$config['uri']}";
     $labelUri = $classEditorLink;
     $labelVaules = $config['values'] ? '?' . http_build_query($config['values']) : '';
     if ($chainLinks) {
         $linkLabels = array();
         foreach ($chainLinks as $links) {
             $linkLabels[] .= count($links) > 1 ? implode(':', $links) : $links[0];
         }
         $linkLabel .= '_link=' . implode(',', $linkLabels);
     }
     $result = '<div class="bear-resource-template">';
     $result .= '<div class="bear-resource-label">' . $labelUri;
     $result .= '<span class="bear-resource-values">' . $labelVaules . '</span>';
     $result .= '<span class="bear-resource-links">' . $linkLabel . '</span>';
     $result .= '' . " + (" . '';
     $result .= '<span><a border="0" title="' . $config['options']['template'] . '" href="/__panda/edit/?file=';
     $result .= _BEAR_APP_HOME . $this->_config['path'] . 'elements/' . $config['options']['template'] . '.tpl' . '">';
     $result .= $config['options']['template'] . '</a>)</span>';
     $result .= '</div>' . $resourceHtml . '</div>';
     return $result;
 }
Exemple #2
0
 /**
  * リソースヘッダーを取得(アイテム)
  *
  * リソースリクエストを行いその結果のヘッダーを返します。
  *
  * @return array
  */
 public function getHeader($headerKey)
 {
     $this->_doRequest();
     $result = $this->_ro->getHeader($headerKey);
     return $result;
 }