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 PageBody extends PageSectionBase {
00033
00035 protected $view;
00036
00038 private $items;
00039
00041 private $pagination;
00042
00044 private $errorMessage;
00045
00054 public function __construct($paginationFile,$itemViewFile,$maxPages,$response, $is_mobile=false) {
00055 $itemView = $this->loadFile($itemViewFile);
00056 $paginationView = $this->loadFile($paginationFile);
00057
00058 if (gettype($response) != "object") {
00059 $this->items = null;
00060
00061 switch ($response) {
00062 case VCSDBDriverBase::STATUS_HTTP_CONNECTION_FAILURE:
00063 $this->errorMessage = VCSDBSAMPLE_HTTP_FAILURE;
00064 break;
00065 case VCSDBDriverBase::STATUS_XML_PARSE_ERROR:
00066 $this->errorMessage = VCSDBSAMPLE_XML_PARSE_ERROR;
00067 break;
00068 case VCSDBDriverBase::STATUS_DATA_STRUCTURAL_ERROR:
00069 $this->errorMessage = VCSDBSAMPLE_DATA_STRUCT_ERROR;
00070 break;
00071 case VCSDBDriverBase::STATUS_NO_PARAMETER_ERROR:
00072 $this->errorMessage = "";
00073 break;
00074 default:
00075 $this->errorMessage = VCSDBSAMPLE_UNKNOWN_EROR;
00076 }
00077 } else {
00078 $this->items = FormattedItem::getItems($itemView,$response);
00079 }
00080
00081 $this->pagination = new Pagination($paginationView,$maxPages,$response, $is_mobile);
00082 }
00083
00090 function render($show_container=true) {
00091 $output = '';
00092
00093 if (gettype($this->items) == "array") {
00094 if (count($this->items) > 0 ) {
00095 error_log("count ".count($this->items));
00096
00097 $output .= $this->pagination->toString();
00098
00099 if ($show_container) {
00100 $output .= '<table class="results">';
00101 }
00102
00103 foreach ($this->items as $item) {
00104 $output .= $item->toString();
00105 }
00106
00107 if ($show_container) {
00108 $output .= '</table>';
00109 }
00110
00111 $output .= $this->pagination->toString();
00112 } else {
00113 $output .= VCSDBSAMPLE_NO_RESULTS;
00114 }
00115 } else {
00116 $output .= $this->errorMessage;
00117 }
00118
00119 return $output;
00120 }
00121
00125 public function show($show_container=true) {
00126 print $this->render($show_container);
00127 }
00128 }
00129 ?>