diff --git a/css/profile_freelist.css b/css/profile_freelist.css --- a/css/profile_freelist.css +++ b/css/profile_freelist.css @@ -1,7 +1,38 @@ +.typ-profile-sidebar{ + width: 310px; +} .profile_share img{ - width: 75px; + width: 90px; height: 28px; } .nav-tabs > li.active > a, .nav-tabs > li.active > a:focus, .nav-tabs > li.active > a:hover{ background-color: #FFDE00 !important; + color: #000000 !important; +} +.nav-tabs>li>a{ + border: 1px solid #DDDDDD !important; + color: #898787 !important; +} +.profile_share{ + border: 1px solid #DDDDDD; + padding: 15px; +} +.profile_share_title_promotion{ + background-color: #4e4e4e; + margin-bottom: 2px; + color: #f5cc22 !important; + padding: 10px; +} +.profile_share_title_promotion > a > span{ + margin-left: 8px; + color: #f5cc22 !important; +} +.profile_share_title_promotion:hover{ + background-color: rgba(78,78,78,0.8); +} +.profile_share_title{ + margin-top: 12px; + background-color: #f5cc22; + color: #000 !important; + padding: 10px; } \ No newline at end of file diff --git a/js/profile.js b/js/profile.js --- a/js/profile.js +++ b/js/profile.js @@ -1,35 +1,35 @@ var url= ''; (function ($, Drupal, drupalSettings) { })(jQuery, Drupal, drupalSettings); function print_content(){ var printContents = jQuery("#block-bootstrap-content").html(); var originalContents = document.body.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; } function hover_share(data){ var src = data.getAttribute('src'); var hover = src.replace("1","2"); data.setAttribute('src',hover); } function out_share(data){ var src = data.getAttribute('src'); var hover = src.replace("2","1"); data.setAttribute('src',hover); } function sendmail(obj){ // Create Base64 Object var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}} var data = jQuery(obj).attr('data-value'); var data_from = jQuery(obj).attr('data-from'); - data = Base64.decode(data); - data_from = Base64.decode(data_from); + var from = Base64.decode(data_from); + var content = Base64.decode(data); console.log(content); var link = "mailto:email@address.com" - + "?subject="+data_from - + "&body="+data; + + "?subject="+from + + "&body="+content; window.location.href = link; } \ No newline at end of file diff --git a/src/Controller/TYPProfileController.php b/src/Controller/TYPProfileController.php --- a/src/Controller/TYPProfileController.php +++ b/src/Controller/TYPProfileController.php @@ -1,248 +1,228 @@ redirect(""); }*/ public function __construct(){ \Drupal::service('page_cache_kill_switch')->trigger(); } - public function formatPhoneNumber($s) { - foreach( explode(",", $s) as $p) { + public static function FormatPhoneNumber($r){ + $p = $r; $num_com = null; - $num_first = null; - $num_second = null; - $num_ex = explode("-", trim($p)); - for($i = 0; $i < count($num_ex); $i++) { - if(($i+1) < count($num_ex)) { - $num_first .= $num_ex[$i]; - } else { - $num_second .= $num_ex[$i]; - } - } - if(empty($num_first)) { - $num_first = $num_second; - $num_second = null; - } - if(strlen($num_first) == 9) { - $num_com = substr($num_first, 0, 1) . '-'. substr($num_first, 1, 4). '-'. substr($num_first, 5,4); - if(!empty($num_second)) { - $num_com .= '-'.$num_second; - } - } else { - if(strlen($num_first) < 9) { - $num_first .= $num_second; - if(strlen($num_first) == 9) { - $num_com = substr($num_first, 0, 1) . '-'. substr($num_first, 1, 4). '-'. substr($num_first, 5,4); - } elseif(strlen($num_first) == 10){ - $num_com = substr($num_first, 0, 2) . '-'. substr($num_first, 2, 4). '-'. substr($num_first, 6,7); - }else { - $num_com = substr($num_first, 0, 1) . '-'. substr($num_first, 1, 4). '-'. substr($num_first, 5,4).'-'.substr($num_first, 9,strlen($num_first)); - } - } else { - if(strlen($num_first) == 10) { - $num_com = substr($num_first, 0, 2) . '-'. substr($num_first, 2, 4). '-'. substr($num_first, 6,7); - } else { - $num_first .= $num_second; - $num_com = substr($num_first, 0, 1) . '-'. substr($num_first, 1, 4). '-'. substr($num_first, 5,4).'-'.substr($num_first, 9,strlen($num_first)); + $codeTelephone = array('032','034','035','036','037','038','039','042','043','044','045','053','054','055','056','073','074','075','076','077'); + if(strlen($p) == 9){ + $num_com = substr($p,0,1).'-'.substr($p,1,4).'-'.substr($p,5,4); + }elseif(strlen($p) == 10) { + $num_com = substr($p,0,2).'-'.substr($p,2,4).'-'.substr($p,6,4); + }elseif(strlen($p) > 9){ + $p = str_replace('-','',$r); + for($i=0;$i<=count($codeTelephone)-1;$i++){ + if(substr($p,0,3) == $codeTelephone[$i]){ + if(strlen($p) == 9){ + $num_com = substr($p,0,1).'-'.substr($p,1,4).'-'.substr($p,5,4); + }elseif(strlen($p)>9){ + $num_com = substr($p,0,1).'-'.substr($p,1,4).'-'.substr($p,5,4).'-'.substr($p,9); + } + }else{ + $num_com = substr($p,0,1).'-'.substr($p,1,4).'-'.substr($p,5,4).'-'.substr($p,9); } } } $ps[] = $num_com; - } return implode(", ", $ps); } public function formatWorkingHour($s) { foreach( explode(",", $s) as $p) { $ps[] = $p; } return implode(", ", $ps); } protected $data; protected static function insertVisit($bizid, $customerid){ db_set_active("typ_data"); $data['businessid'] = trim($bizid); $data['customerid'] = trim($customerid); $data['goodsid'] = ""; db_insert('last_visit_product')->fields($data)->execute(); db_set_active(); } public function profileTitle($bizid) { $this->data = \Drupal::service("typ.search")->getProfile($bizid ,AUTO); if (!$this->data) return ''; else return $this->data['humanname']; } public function profilePage($bizid){ $this->data = \Drupal::service("typ.search")->getProfile($bizid ,AUTO); $address_id = ""; $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $data = $this->data; if (!$data) { return $this->redirect(""); } //Insesrt visit page self::insertVisit($data['businessid'], $data['customerid']); /*if($data['landingpage'] == ""){ $address_id = $data['addressid']; } if(is_numeric($address_id)){ $result = \Drupal::service('typ.unvservice')->loadListing($data['customerid']); $rs_details = (!empty($result['address'][$data['headingcod']][$address_id]['frontviews']))?$result['address'][$headingcode][$data['headingcod']]['frontviews']:array(); } else { $result = \Drupal::service('typ.unvservice')->loadService($data['customerid']); }*/ // PLEASE COMMENT?? WHY WE LOAD PROFILE AND THEN LOAD SERVICE? $address_id = $data['addressid']; $result = \Drupal::service('typ.unvservice')->loadListing($data['customerid']); //(!empty($result['landingpages'][$data['headingcode']]))?$result['landingpages'][$data['headingcode']]:array(); //$type = ''; if($result['customertype'] == 'FL' || $result['customertype'] == ''){ $type = 'FL'; }else{ $result_olc = \Drupal::service('typ.catalog')->listData($data['customerid']); } $pos = strpos(html_entity_decode($data['proddesc']),"

"); if($pos !== false && $data['proddesc']){ $tempdesc = substr(html_entity_decode($data['proddesc']),3); }else{ $tempdesc = html_entity_decode(html_entity_decode($data['proddesc'])) ; //$tempdesc = $data['proddesc']; } if(strlen($tempdesc) != 0) { $temp = '

'; $tempdesc = $temp . $tempdesc; $type = $data['customertype']; } if($type == "FL") { $dataproddesct = iconv_substr($tempdesc,0,123,"UTF-8"); $dataproddesct .= '...'; }else{ $dataproddesct = $tempdesc; } $dataproddesct = str_replace("

","

",$dataproddesct); if($type != "FL" && !empty($result_olc)){ $olcdata = $result_olc[0]; } if (!empty($data['telno'])) { foreach ($data['telno'] as $t) { $data['_format']['telno'][] = $this->formatPhoneNumber($t); } } if (!empty($data['fax'])) { foreach ($data['fax'] as $t) { $data['_format']['fax'][] = $this->formatPhoneNumber($t); } } if($type == "FL"){ /*unset($data['_format']['telno']); $data['_format']['telno'][] = $data['_format']['telno'][0]; unset($data['fax']); $data['fax'][] = $data['fax'][0]; $exp = explode(",", $data['email']); unset($data['email']); $data['email'][] = $exp[0];*/ }else{ /*$exp = explode(",", $data['email']); $data['email'] = $exp;*/ } $thai_month_arr = array('01'=>'ม.ค.','02'=>'ก.พ.','03'=>'มี.ค.','04'=>'เม.ษ.','05'=>'พ.ค.','06'=>'มิ.ย.','07'=>'ก.ค.','08'=>'ส.ค.','09'=>'ก.ย.','10'=>'ต.ค.','11'=>'พ.ย.','12'=>'ธ.ค.'); list($year, $month,$day) = explode('-', $result['address'][$data['headingcode']][$data['addressid']]['promotion']['enddate']); $date_e = $day." ".$thai_month_arr[$month]." ".($year+543); $end_date_promotion = $result['address'][$data['headingcode']][$data['addressid']]['promotion']['enddate']; list($year, $month,$day) = explode('-', $result['address'][$data['headingcode']][$data['addressid']]['promotion']['startdate']); $date_s = $day." ".$thai_month_arr[$month]." ".($year+543); $result['address'][$data['headingcode']][$data['addressid']]['promotion']['startdate'] = $date_s; $result['address'][$data['headingcode']][$data['addressid']]['promotion']['enddate'] = $date_e; $result['address'][$data['headingcode']][$data['addressid']]['promotion']['subject'] = preg_replace('/]*?>/','

',html_entity_decode($result['address'][$data['headingcode']][$data['addressid']]['promotion']['subject'])); if(date("Y-m-d") > $end_date_promotion){ $promotion_data = ''; }else{ $promotion_data = $result['address'][$data['headingcode']][$data['addressid']]['promotion']; } if(!empty($data['profile'])){ $data['profile'] = preg_replace('/]*?>/','

',html_entity_decode($data['profile'])); } if (!empty($data['workinghours'])) { $data['_format']['workinghours'] = $this->formatWorkingHour($data['workinghours']); $data['customertyp'] = $data['customertype']; } $data['profile'] = strip_tags($data['profile']); $display[] = array( '#theme' => 'typ_profile', '#profile' => $data, '#prodescription' => $dataproddesct, '#catalog' => $olcdata, '#type' => $type, '#promotion' => $promotion_data, ); if ($type != 'FL') $display['#attached']['drupalSettings']['disableAds'] = TRUE; $display['#attached']['library'] = array( 'typ_profile/profile.popup', ); return $display; } public function getTitlePromotion(){ return t('How to get promotion'); } public function getPromotion(){ $mobileDetector = \Drupal::service('krs.mobile_detect'); if($mobileDetector->isAndroidOS() == 1 ){ header('location: https://play.google.com/store/apps/details?id=com.initialive.yellowpages.act&hl=th'); exit; }if($mobileDetector->isIOS() == 1){ header('location: https://itunes.apple.com/th/app/thailand-yellowpages/id387848017?mt=8'); exit; }else{ header('location: http://m.yellowpages.co.th/mobile/typliveplus/user/'); exit; } $display[] = array( '#theme' => 'typ_promotion', ); $display['#attached']['library'] = array( 'typ_profile/profile.popup', ); return $display; } } diff --git a/src/Plugin/Block/TYPProfileShareBlock.php b/src/Plugin/Block/TYPProfileShareBlock.php --- a/src/Plugin/Block/TYPProfileShareBlock.php +++ b/src/Plugin/Block/TYPProfileShareBlock.php @@ -1,1 +1,1 @@ -getRequestUri(); $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $s = explode("/",$url); $bid = end($s); $this->data = \Drupal::service("typ.search")->getProfile($bid ,AUTO); $this->result = \Drupal::service('typ.unvservice')->loadListing($this->data['customerid'],NULL); $type = $this->result['address'][$this->data['headingcode']][$this->data['addressid']]['customertype']; $telno = '';$fax = '';$workinghours = ''; if (!empty($this->data['telno'])) { foreach ($this->data['telno'] as $t) { $telno .= $this->formatPhoneNumber($t); } } if (!empty($this->data['fax'])) { foreach ($this->data['fax'] as $t) { $fax .= $this->formatPhoneNumber($t); } } if (!empty($this->data['workinghours'])) { $workinghours .= $this->formatWorkingHour($this->data['workinghours']); } $body_email = '
'.t('Address').' '.$this->data['fulladdr'].'
'.t('Tel').' '.$telno.'
'.t('Fax').' '.$fax.'
'.t('Email').' '.$this->data['email'].'
'.t('Website').' '.$this->data['website'].'
'.t('Work-Time').' '.$workinghours.'
'.t('Link').' '.$fullurl.'
'; switch ($type){ case "FL": $email = urlencode((string)$body_email); $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.format_string($this->data['proddesc']).$fullurl; $twitter = format_string($this->data['proddesc']).$fullurl; $gplus = 'https://plus.google.com/share?url='.$fullurl; break; default: $email = urlencode((string)$body_email); $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.format_string($this->data['proddesc']).$fullurl; $twitter = format_string($this->data['proddesc']).$fullurl; $gplus = 'https://plus.google.com/share?url='.$fullurl; } $base_url_images = '/themes/bootstrap/typ/images/icon-service-profilepage/'.$language; $email = base64_encode($email); header('Content-Type: text/html; charset=UTF-8'); $build = array(); $build[] = array( '#markup' => format_string('

'), ); $build['#attached']['library'] = array( 'typ_profile/profile_share' ); return $build; } } ?> \ No newline at end of file +getRequestUri(); $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $s = explode("/",$url); $bid = end($s); $this->data = \Drupal::service("typ.search")->getProfile($bid ,AUTO); $this->result = \Drupal::service('typ.unvservice')->loadListing($this->data['customerid'],NULL); $type = $this->result['address'][$this->data['headingcode']][$this->data['addressid']]['customertype']; $telno = '';$fax = '';$workinghours = ''; if (!empty($this->data['telno'])) { foreach ($this->data['telno'] as $t) { $telno .= TYPProfileController::FormatPhoneNumber($t); } } if (!empty($this->data['fax'])) { foreach ($this->data['fax'] as $t) { $fax .= TYPProfileController::FormatPhoneNumber($t); } } if (!empty($this->data['workinghours'])) { $workinghours .= $this->formatWorkingHour($this->data['workinghours']); } $body_email = format_string('
'.t('Address').' '.$this->data['fulladdr'].'
'.t('Tel').' '.$telno.'
'.t('Fax').' '.$fax.'
'.t('Email').' '.$this->data['email'].'
'.t('Website').' '.$this->data['website'].'
'.t('Work-Time').' '.$workinghours.'
'.t('Link').' '.$fullurl.'
'); switch ($type){ case "FL": $email = $body_email; $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.format_string($this->data['proddesc']).$fullurl; $twitter = format_string($this->data['proddesc']).$fullurl; $gplus = 'https://plus.google.com/share?url='.$fullurl; break; default: $email = $body_email; $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.format_string($this->data['proddesc']).$fullurl; $twitter = format_string($this->data['proddesc']).$fullurl; $gplus = 'https://plus.google.com/share?url='.$fullurl; } $base_url_images = '/themes/bootstrap/typ/images/icon-service-profilepage/'.$language; $email = base64_encode($email); header('Content-Type: text/html; charset=UTF-8'); $build = array(); $build[] = array( '#markup' => format_string('
'.t('Share this business here').'
'), ); $build['#attached']['library'] = array( 'typ_profile/profile_share' ); return $build; } } ?> \ No newline at end of file