Example #1
0
 /**
  * Constructor
  *
  * @param BEAR_Ro $ro
  */
 public function __construct(BEAR_Ro $ro)
 {
     /* @var $ro BEAR_Ro */
     $this->code = $ro->getCode();
     $this->header = $ro->getHeaders();
     $this->body = $ro->getBody();
     $this->links = $ro->getLinks();
     $this->html = $ro->getHtml();
 }
Example #2
0
 /**
  * デバック表示描画
  *
  * @return BEAR_Ro
  * @ignore
  */
 protected function _p()
 {
     $trace = debug_backtrace();
     $trace = $trace[1];
     $place = " in <span style=\"color: gray;\">{$trace['file']}</span> on line {$trace['line']} ";
     if ($this->hasChainLink()) {
         $linkBody = $this->getLinkedBody();
     } else {
         $body = $this->getBody();
     }
     $headers = $this->_ro->getHeaders();
     $request = $headers['_request'];
     foreach ($headers as $key => $header) {
         if (substr($key, 0, 1) == '_') {
             unset($headers[$key]);
         }
     }
     $linkLabel = '';
     if ($this->_chainLink) {
         foreach ($this->_chainLink as $links) {
             $linkLabel .= '->' . (count($links) > 1 ? '(' . implode(',', $links) . ')' : $links[0]);
         }
     }
     $label = $this->_config['uri'] . $linkLabel;
     $labelField = '<fieldset style="color:#4F5155; border:1px solid black;padding:2px;width:10px;">';
     $labelField .= '<legend style="color:black;font-size:9pt;font-weight:bold;font-family:sans-serif;">' . $label . '</legend>';
     echo $labelField;
     if (isset($linkBody)) {
         print_a($linkBody);
     } else {
         $resource = array('code' => $this->getCode(), 'header' => $headers, 'body' => $this->getBody(), 'link' => $this->getLinks());
         print_a($resource);
     }
     echo '</fieldset>';
     $linkLabel = $linkLabel ? ' and link(s)' : '';
     echo "by \"{$request}\"{$linkLabel} {$place}<br /><br />";
     return $this;
 }
Example #3
0
 /**
  * データ送信
  *
  * @param int     $clientId クライアントID
  * @param string  $method   リクエストメソッド名
  * @param BEAR_Ro $ro       RO
  *
  * @return void
  */
 public function sendData($clientId, $method, BEAR_Ro $ro)
 {
     $code = $ro->getCode();
     $hearders = $ro->getHeaders();
     if (isset($hearders['broadcast'])) {
         $this->_server->broadcastData($code . PHP_EOL, array($clientId));
         $this->_server->broadcastData('Content-Type: text/php' . PHP_EOL, array($clientId));
         $type = 'X-Socket-Type: broadcast' . PHP_EOL;
         $this->_server->broadcastData($type, array($clientId));
         $this->_server->broadcastData(PHP_EOL, array($clientId));
         $data = serialize($hearders['broadcast']) . PHP_EOL;
         $this->_server->broadcastData($data, array($clientId));
     }
     $this->_server->sendData($clientId, $code . PHP_EOL);
     $this->_server->sendData($clientId, 'Content-Type: text/php' . PHP_EOL);
     $this->_server->sendData($clientId, PHP_EOL);
     $data = $ro->getBody();
     $this->_server->sendData($clientId, serialize($data) . PHP_EOL);
 }
Example #4
0
 /**
  * ページャー情報の取得
  *
  * <pre>ページャーで生成されたナビゲーションHTMLを取得します。
  * DBページャーの場合はページャー情報も取得されます
  * ['links']にナビゲーションリンクが
  * ['info']のページャー情報がはいります
  *
  * DBページャーの場合は結果がリソースオブジェクトになっているので、
  * リンクとメタ情報からページャー情報を生成しています</pre>
  *
  * @return array
  */
 public function getPager()
 {
     $links = $this->_ro->getLinks();
     $result = array('links' => $links['pager'], 'info' => $this->_ro->getHeaders());
     return $result;
 }