From e20c83647f90d81423f2b09d69ff069e570b1dc1 Mon Sep 17 00:00:00 2001 From: arzynik Date: Fri, 15 Nov 2013 18:51:53 -0800 Subject: [PATCH] fixes #2073 --- include/library/Crunchbutton/Restaurant.php | 24 +++++++++++ .../Crunchbutton/Restaurant/Comment.php | 25 +++++++++++ include/library/Crunchbutton/User.php | 8 ++++ .../default/seven/frontend/restaurant.phtml | 12 +++++- www/assets/css/seven.css | 42 +++++++++++++++++++ 5 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 include/library/Crunchbutton/Restaurant/Comment.php diff --git a/include/library/Crunchbutton/Restaurant.php b/include/library/Crunchbutton/Restaurant.php index 3c264c392..4dd477c2b 100644 --- a/include/library/Crunchbutton/Restaurant.php +++ b/include/library/Crunchbutton/Restaurant.php @@ -1160,6 +1160,23 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { foreach ( $ignore as $property => $val ) { unset( $out[ $property ] ); } + + $comment = $this->comment(); + + if ($comment->id_restaurant_comment) { + $auths = $comment->user()->auths(); + foreach ($auths as $auth) { + if ($auth->type == 'facebook') { + $id = $auth->auth; + break; + } + } + $out['comment'] = [ + 'content' => $comment->content, + 'user' => $comment->user()->get(0)->name(), + 'fb' => $id + ]; + } return $out; } @@ -1493,6 +1510,13 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { WHERE txt IS NOT NULL"; return Admin::q( $query ); } + + public function comment() { + if (!isset($this->_comment)) { + $this->_comment = Restaurant_Comment::q('select * from restaurant_comment where top=1 && id_restaurant='.$this->id_restaurant.''); + } + return $this->_comment; + } public function save() { if (!$this->timezone) { diff --git a/include/library/Crunchbutton/Restaurant/Comment.php b/include/library/Crunchbutton/Restaurant/Comment.php new file mode 100644 index 000000000..f97a52b3b --- /dev/null +++ b/include/library/Crunchbutton/Restaurant/Comment.php @@ -0,0 +1,25 @@ +table('restaurant_comment') + ->idVar('id_restaurant_comment') + ->load($id); + } + + public function user() { + if (!isset($this->_user)) { + $this->_user = User::o($this->id_user); + } + return $this->_user; + } + + public function restaurant() { + if (!isset($this->_restaurant)) { + $this->_restaurant = Restaurant::o($this->id_restaurant); + } + return $this->_restaurant; + } +} \ No newline at end of file diff --git a/include/library/Crunchbutton/User.php b/include/library/Crunchbutton/User.php index 6676040b6..830913c26 100644 --- a/include/library/Crunchbutton/User.php +++ b/include/library/Crunchbutton/User.php @@ -2,6 +2,14 @@ class Crunchbutton_User extends Cana_Table { + public function name() { + if (!isset($this->_name)) { + $name = explode(' ',$this->name); + $this->_name = $name[0]; + } + return $this->_name; + } + public function byPhone($phone) { $phone = preg_replace('/[^0-9]/i','',$phone); return User::q('select * from user where phone="'.$phone.'" order by id_user desc limit 1'); diff --git a/include/views/default/seven/frontend/restaurant.phtml b/include/views/default/seven/frontend/restaurant.phtml index 6af7a640d..063101506 100644 --- a/include/views/default/seven/frontend/restaurant.phtml +++ b/include/views/default/seven/frontend/restaurant.phtml @@ -17,11 +17,21 @@

{{restaurant.name}}

{{restaurant.message || restaurant.short_description}}

+
+
+
+
+
+
+

{{restaurant.comment.user}} says

+

{{restaurant.comment.content}}

+
+
+
${{Math.round(credit.value)}}
gift card
-
diff --git a/www/assets/css/seven.css b/www/assets/css/seven.css index a6bd795e6..23c8168a4 100644 --- a/www/assets/css/seven.css +++ b/www/assets/css/seven.css @@ -1336,6 +1336,48 @@ p { -webkit-transform: translateZ(0); } +.restaurant-comment { + margin-top: -11em; + position: absolute; + background: rgba(0,0,0,.5); + border-radius: 4px; + padding: .5em .6em .5em .6em; + margin-left: .8em; + margin-right: .8em; +} +.restaurant-comment-wrap { + display: table-row; +} + +.restaurant-comment-image { + display: table-cell; + vertical-align: top; +} +.restaurant-comment-image-img { + background-size: 100% !important; + height: 3.6em; + width: 3.6em; +} +.restaurant-comment-content { + font-size: .8em; + display: table-cell; + color: #fff; + padding-left: 1em; + vertical-align: top; +} +.restaurant-comment-content h4 { + margin-top: -.3em; + text-transform: uppercase; + line-height: 1.5em; +} +.restaurant-comment-content p { + line-height: 1.3em; +} + + + + + .restaurant-name { color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.6);