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
00031 class PageBodyRecommend extends PageSectionBase {
00032
00034 protected $view;
00035
00037 private $items;
00038
00040 private $pagination;
00041
00043 private $errorMessage;
00044
00053 public function __construct($paginationFile,$itemViewFile,$maxPages,$response, $is_mobile=false) {
00054 $itemView = $this->loadFile($itemViewFile);
00055
00056 if (gettype($response) != "object") {
00057 $this->items = null;
00058
00059 switch ($response) {
00060 case VCSDBDriverBase::STATUS_HTTP_CONNECTION_FAILURE:
00061 $this->errorMessage = VCSDBSAMPLE_HTTP_FAILURE;
00062 break;
00063 case VCSDBDriverBase::STATUS_XML_PARSE_ERROR:
00064 $this->errorMessage = VCSDBSAMPLE_XML_PARSE_ERROR;
00065 break;
00066 case VCSDBDriverBase::STATUS_DATA_STRUCTURAL_ERROR:
00067 $this->errorMessage = VCSDBSAMPLE_DATA_STRUCT_ERROR;
00068 break;
00069 case VCSDBDriverBase::STATUS_NO_PARAMETER_ERROR:
00070 $this->errorMessage = "";
00071 break;
00072 default:
00073 $this->errorMessage = VCSDBSAMPLE_UNKNOWN_EROR;
00074 }
00075 } else {
00076 $this->items = FormattedItem::getItems($itemView,$response);
00077 }
00078
00079 }
00080
00081 function render($show_container=true) {
00082 $output = '';
00083
00084 if (gettype($this->items) == "array") {
00085 if (count($this->items) > 0 ) {
00086 error_log("count ".count($this->items));
00087
00088 if ($show_container) {
00089 $output .= '<table class="results"><tr>';
00090 }
00091
00092 foreach ($this->items as $item) {
00093 $output .= $item->toString();
00094 }
00095
00096 if ($show_container) {
00097 $output .= '</tr></table>';
00098 }
00099
00100 } else {
00101 $output .= VCSDBSAMPLE_NO_RESULTS;
00102 }
00103 } else {
00104 $output .= $this->errorMessage;
00105 }
00106
00107 return $output;
00108 }
00109
00113 public function show($show_container=true) {
00114 print $this->render($show_container);
00115 }
00116 }
00117 ?>