-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathreviews_ajax.php
145 lines (110 loc) · 4.67 KB
/
reviews_ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
require('rezgo/include/page_header.php');
// new instance of RezgoSite
$site = new RezgoSite();
$company = $site->getCompanyDetails();
$response = '';
// get reviews
if ($_REQUEST['action'] == 'get') {
$item_reviews = $site->getReview($_REQUEST['com'], $_REQUEST['type'], $_REQUEST['limit']);
if (strpos($_REQUEST['limit'], ',') !== false) {
$l = explode(',', $_REQUEST['limit']);
$lower_limit = $l[0];
$upper_limit = $l[1];
} else {
$lower_limit = 0;
$upper_limit = $_REQUEST['limit'];
}
$counted = 0;
$running_count = $lower_limit + 1;
if($item_reviews->total >= 1) {
foreach ($item_reviews->review as $review) {
if ($review->item != '') {
$item_link = $site->base.'/details/'.$review->com.'/'.$site->seoEncode($review->item);
}
$response .= '<div class="rezgo-review-container" data-num="'.$running_count.'" data-trans="'.$review->booking.'">';
for($n=1; $n<=5; $n++) {
$response .= '<i class="rezgo-star fa fa-star'.(($review->rating >= $n) ? ' rezgo-star-full' : '-o rezgo-star-empty').'"></i>';
}
$review_date = (int) $review->date;
if (strpos($company->time_format, '-') === false) {
$review_date += (int) $company->time_format * 3600;
} else {
$review_date -= (int) $company->time_format * 3600;
}
$response .= '
<strong>'. $review->title .'</strong>
'. ($_REQUEST['com'] == 'all' ? ' <span class="rezgo-review-item-name">( reviewing <a href="'.$item_link.'">'.$review->item.'</a> )</span>' : '') . '
<br />
<span class="rezgo-memo">
'. ($review->name != '' ? ' by '. $review->name : '') . '
'. ($review->country != '' ? ' from '. $site->countryName($review->country) : '') . '
on '. date((string) $company->date_format, $review_date) . '
</span><br />
<div class="rezgo-review-body" style="max-height:'.($_REQUEST['view'] == 'list' ? '320' : '110').'px; overflow:hidden;">'. nl2br($review->body); //
if ($review->response && !$site->isVendor()) {
$response_date = (int) $review->response->date;
if (strpos($company->time_format, '-') === false) {
$response_date += (int) $company->time_format * 3600;
} else {
$response_date -= (int) $company->time_format * 3600;
}
$response .= '
<div class="clearfix"> </div>
<span class="rezgo-memo">Response by '.$company->company_name.' on '. date((string) $company->date_format, $response_date) .'</span><br />
<blockquote>'. nl2br($review->response->body) .'</blockquote>'; //
}
$response .= '
</div>
</div>
<div class="clearfix rezgo-review-break"> </div>
';
$counted++;
$running_count++;
}
}
if ( $counted > 0 ) {
$response .= '
<script>
$(\'.rezgo-review-body\').readmore({
speed: 500,
collapsedHeight: '.($_REQUEST['view'] == 'list' ? '180' : '110').',
moreLink: \'<a href="#" class="btn btn-xs rezgo-review-readmore"><i class="fa fa-chevron-down"></i> Read More</a>\',
lessLink: \'<a href="#" class="btn btn-xs rezgo-review-readmore"><i class="fa fa-chevron-up"></i> Read Less</a>\'
});
</script>
';
// link to full review list
if ($_REQUEST['view'] == 'details' && $_REQUEST['total'] > 5) {
$response .= '
<span id="rezgo-view-all-reviews">
<a href="'.$site->base.'/reviews/item/'.$_REQUEST['com'].'" target="_parent" class="btn btn-primary">View '.($_REQUEST['total'] - $_REQUEST['limit']).' more reviews for this item</a>
</span>
';
}
// show the next page
if ($_REQUEST['view'] == 'list' && ($counted == $upper_limit) && $running_count <= $_REQUEST['total']) {
$response .= '
<div id="rezgo-more-reviews-btn">
<span class="rezgo-load-more-wrap">
<button class="btn btn-block rezgo-review-load-more" id="rezgo-load-more-reviews"><i class="fa fa-chevron-down"></i> Load More Reviews</button>
</span>
</div>
';
}
} else {
if ($lower_limit == 0) {
$response .= '<p class="lead">There are no reviews to show at this time. Please check back later.</p>';
} else {
$response .= '<p class="rezgo-review-container">There are no more reviews available. Please check back later.</p>';
}
} // end if (counted)
}
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
// ajax response if we requested this page correctly
echo $response;
} else {
// if, for some reason, the ajax form submit failed, then we want to handle the user anyway
die ('Something went wrong getting reviews.');
}
?>