diff --git a/src/Plugin/Block/TYPProfileDetail.php b/src/Plugin/Block/TYPProfileDetail.php new file mode 100644 --- /dev/null +++ b/src/Plugin/Block/TYPProfileDetail.php @@ -0,0 +1,133 @@ +getRequestUri(); + $s = explode("/",$url); + $bid = end($s); + $data = self::$data = \Drupal::service("typ.search")->getProfile($bid ,AUTO); + $temp = array(); + if(!empty($data['paymentmethod'])){ + $temp['paymentmethod'] = $data['paymentmethod']; + } + if(!empty($data['atmosphere'])){ + $temp['atmosphere'] = $data['atmosphere']; + } + if(!empty($data['standard'])){ + $temp['standard'] = $data['standard']; + } + if(!empty($data['amentity'])){ + $temp['amentity'] = $data['amentity']; + } + if(!empty($data['rating'])){ + $temp['rating'] = $data['rating']; + } + if(!empty($data['duration'])){ + $temp['duration'] = $data['duration']; + } + if(!empty($data['landmark'])){ + $temp['landmark'] = $data['landmark']; + } + self::$datashow = $temp; + if($data['customertype'] != 'FL' && !empty($temp)){ + return AccessResult::allowed(); + }else{ + return AccessResult::forbidden(); + } + } + + public function build(){ + $result = self::$datashow; + $html = ''; + $star = ' '; + $star_empty = ' '; + + if(!empty($result['landmark'])){ + $html .= '
' . t('Landmark') . ':
+' . $result['landmark'] . '
'; + } + if(!empty($result['paymentmethod'])) { + $html .= '' . t('Payment') . ':
+' . $result['paymentmethod'] . '
'; + } + if(!empty($result['rating'])) { + $num = intval(substr($result['rating'],0,1)); + $rateing = ''; + for($i=1;$i<=5;$i++){ + if($i<=$num){ + $rateing .= $star; + }else{ + $rateing .= $star_empty; + } + } + $html .= '' . t('Rating') .': '.$rateing.'
'; + } + if(!empty($result['standard'])){ + $html .= ''.t('Standard').':
+'.$result['standard'].'
'; + } + if(!empty($result['atmosphere'])){ + $html .= ''.t('Atmosphere').':
+'.$result['atmosphere'].'
'; + } + if(empty($result['duration'])){ + if(!empty($result['amentity'])) { + $result['duration'] = $result['amentity']; + } + } + if(!empty($result['duration'])){ + $html .= ''.t('Facilities').':
+'.$result['duration'].'
'; + } + $data = '";var_export($result);exit; + $build = array(); + + $build[] = array( + '#markup' => $data, + ); + $build['#attached']['library'] = array( + 'typ_profile/profile_share' + ); + + return $build; + } +} \ No newline at end of file