00001 <?php
00002
00003
00004
00005
00006
00007 require_once('PageSectionBase.php');
00008 require_once('FormattedItem.php');
00009 require_once('Pagination.php');
00010
00012 if (!defined('VCSDBSAMPLE_NO_RESULTS')) define('VCSDBSAMPLE_NO_RESULTS','検索結果がありません');
00013
00015 if (!defined('VCSDBSAMPLE_HTTP_FAILURE')) define('VCSDBSAMPLE_HTTP_FAILURE','ウェブサービスデータベースが異常な値を返しました。');
00016
00018 if (!defined('VCSDBSAMPLE_XML_PARSE_ERROR')) define('VCSDBSAMPLE_XML_PARSE_ERROR','ウェブサービスデータベースのXMLに異常があります。');
00019
00021 if (!defined('VCSDBSAMPLE_DATA_STRUCT_ERROR')) define('VCSDBSAMPLE_DATA_STRUCT_ERROR','ウェブサービスデータベースから受け取ったデータに構造上の問題があります。');
00022
00024 if (!defined('VCSDBSAMPLE_UNKNOWN_EROR')) define('VCSDBSAMPLE_UNKNOWN_EROR','不明なエラー');
00025
00026
00032 class PageBodyDetail extends PageSectionBase {
00033
00035 protected $view;
00036
00038 public $items;
00039
00041 private $pagination;
00042
00044 private $errorMessage;
00045
00052 public function __construct($itemViewFile, $response, $is_mobile=false) {
00053 $itemView = $this->loadFile($itemViewFile);
00054
00055 if (gettype($response) != "object") {
00056 $this->items = null;
00057
00058 switch ($response) {
00059 case VCSDBDriverBase::STATUS_HTTP_CONNECTION_FAILURE:
00060 $this->errorMessage = VCSDBSAMPLE_HTTP_FAILURE;
00061 break;
00062 case VCSDBDriverBase::STATUS_XML_PARSE_ERROR:
00063 $this->errorMessage = VCSDBSAMPLE_XML_PARSE_ERROR;
00064 break;
00065 case VCSDBDriverBase::STATUS_DATA_STRUCTURAL_ERROR:
00066 $this->errorMessage = VCSDBSAMPLE_DATA_STRUCT_ERROR;
00067 break;
00068 case VCSDBDriverBase::STATUS_NO_PARAMETER_ERROR:
00069 $this->errorMessage = "";
00070 break;
00071 default:
00072 $this->errorMessage = VCSDBSAMPLE_UNKNOWN_EROR;
00073 }
00074 } else {
00075 $this->items = FormattedItem::getItems($itemView,$response);
00076 }
00077 }
00078
00085 function render($show_container=true) {
00086 $output = '';
00087
00088 if (gettype($this->items) == "array") {
00089 if (count($this->items) > 0 ) {
00090 error_log("count ".count($this->items));
00091
00092
00093
00094 if ($show_container) {
00095 $output .= '<table class="results">';
00096 }
00097
00098 foreach ($this->items as $item) {
00099 $output .= $item->toString();
00100 }
00101
00102 if ($show_container) {
00103 $output .= '</table>';
00104 }
00105
00106
00107 } else {
00108 $output .= VCSDBSAMPLE_NO_RESULTS;
00109 }
00110 } else {
00111 $output .= $this->errorMessage;
00112 }
00113
00114 return $output;
00115 }
00116
00120 public function show($show_container=true) {
00121 print $this->render($show_container);
00122 }
00123 }
00124 ?>