Page MenuHomePhabricator

No OneTemporary

diff --git a/css/profile_freelist.css b/css/profile_freelist.css
--- a/css/profile_freelist.css
+++ b/css/profile_freelist.css
@@ -1,105 +1,165 @@
h4{
font-size: 18px !important;
}
font{
color: #333 !important;
}
/*add width*/
.typ-profile-head-left{
margin-top: 30px;
}
.breadcrumbs a, .typ-profile-head-left a{
color: #00aeef !important;
}
.breadcrumbs a:hover, .typ-profile-head-left a:hover{
color: #333333 !important;
}
/*end add*/
.region.region-breadcrumbs{
height: 30px;
}
.region-highlighted{
margin-top: 0px !important;
}
.field.field-block-content--body.field-name-body.field-type-text-with-summary.field-label-hidden{
margin-bottom: 15px;
}
.typ-profile-sidebar{
margin-left: 0px !important;
}
.typ-profile-sidebar{
width: 310px;
}
.profile_share img{
width: 90px;
height: 28px;
}
.nav-tabs > li {
padding-right: 2px;
}
.nav-tabs > li>a{
border: 1px solid #cccccc !important;
background-color: #ffcc33 !important;
color: #000000 !important;
}
.nav-tabs > li.active > a, .nav-tabs > li.active > a:focus, .nav-tabs > li.active > a:hover{
background-color: #ffffff !important;
color: #000000 !important;
border-bottom-color: #ffffff !important;
}
/*.nav-tabs>li>a{
border: 1px solid #DDDDDD !important;
color: #000000 !important;
}*/
.profile_share{
border: 1px solid #DDDDDD;
padding: 15px;
}
.profile_share_title_promotion{
background-color: #4e4e4e;
margin-bottom: 2px;
color: #f5cc22 !important;
padding: 10px;
}
a > .profile_share_title_promotion > 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: #ffcc33;
color: #000 !important;
padding: 10px;
}
.orange_font{
color: #FF9900 !important;
}
.gray_font{
color: #333 !important;
}
.detail-images > a > img{
height: 150px;
margin: 0 auto;
}
#block-relatedbusinesslisting {
- float: left;
- width: 90%;
+ float: left;
+ width: 93%;
}
@media(min-device-width : 768px){
aside.l-first {
float: left;
width: 74%;
}
}
+
+#block-relatedbusinesslisting .block-title {
+ width: 95%;
+ margin: auto;
+ line-height: 1.5;
+ padding: 5px;
+}
+
+#block-relatedbusinesslisting h2 {
+ font-size: 20px;
+}
+
+#block-relatedbusinesslisting {
+ border: 1px solid #CCC;
+}
+
+.block-title a,
+.related-business-humanname .txt-humanname {
+ color: #00aeef;
+}
+
+.related-business-humanname .txt-humanname:hover {
+ color: #333333;
+}
+
+.related-business-humanname .txt-humanname {
+ margin: 0px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.related-business-humanname .txt-proddesc {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.detail-related-business-listing {
+ border-top: 1px solid #CCC;
+ padding-top: 20px;
+ padding-bottom: 10px;
+}
+
+.detail-related-business-listing ul{
+ width: 100%;
+ margin: 0;
+ padding: 0;
+}
+
+.detail-related-business-listing li{
+ width: 50%;
+ float: left;
+ display: block;
+ padding-bottom: 10px;
+}
+
+
+
+
diff --git a/js/profile.js b/js/profile.js
--- a/js/profile.js
+++ b/js/profile.js
@@ -1,44 +1,50 @@
var url= '';
(function ($, Drupal, drupalSettings) {
$(".block-title").empty();
var lang = $(".lang").val();
var catname = $(".catname").val();
var address = $(".cat_address").val();
- var data_th = 'รายชื่อธุรกิจในหมวด "<b style="color: #DD4B39;">'+catname+'</b>" ที่อยู่ใน <b style="color: #DD4B39;">'+address+'</b>';
- var data_en = 'Business on category "<b style="color: #DD4B39;">'+catname+'</b>" at <b style="color: #DD4B39;">'+address+'</b>';
- if(lang == "th") {
+ var url = drupalSettings.path.baseUrl+"heading/"+catname;
+ var data_th = 'รายชื่อธุรกิจในหมวด "<b><a href="'+url+'" target="_blank">'+catname+'</a></b>" ที่อยู่ใน <b style="color: #DD4B39;">'+address+'</b>';
+ var data_en = 'Business on category "<b><a href="'+url+'" target="_blank">'+catname+'</a></b>" at <b style="color: #DD4B39;">'+address+'</b>';
+ /*if(lang == "th") {
$(".block-title").css({'line-height':'1.75','border':'solid 1px #ddd','border-bottom':'0','background-color':'#fff'}).append(data_th);
}else{
$(".block-title").css({'line-height':'1.75','border':'solid 1px #ddd','border-bottom':'0','background-color':'#fff'}).append(data_en);
+ }*/
+ if(lang == "th") {
+ $(".block-title").append(data_th);
+ }else{
+ $(".block-title").append(data_en);
}
})(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){
var data = jQuery(obj).attr('data-value');
var data_from = jQuery(obj).attr('data-from');
var from = data_from;
var content = data;
var link = "mailto:email@address.com"
+ "?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,335 +1,310 @@
<?php
/**
* @file
* Contains \Drupal\page_example\Controller\TableSortExampleController.
*/
/**/
namespace Drupal\typ_profile\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Database\Query;
use Drupal\Core\Url;
+use Drupal\typ_legacy\Service\TYPUtilsService;
+
/**
* Controller routines for tablesort example routes.
*/
class TYPProfileController extends ControllerBase
{
public function __construct(){
\Drupal::service('page_cache_kill_switch')->trigger();
}
- public static function FormatPhoneNumber($r){
- $p = str_replace('-','',$r);
- $num_com = '';
- $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 ) {
- if(in_array(substr($p,0,3), $codeTelephone) || substr($p,0,2) == '02'){
- $num_com = substr($p,0,1).'-'.substr($p,1,4).'-'.substr($p,5,4).'-'.substr($p,9);
- }else{
- $num_com = substr($p,0,2).'-'.substr($p,2,4).'-'.substr($p,6,4);
- }
- }else if($p != ''){
- if(in_array(substr($p,0,3), $codeTelephone) || substr($p,0,2) == '02'){
- 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,2).'-'.substr($p,2,4).'-'.substr($p,6,4);
- }
- }
- return $num_com;
- }
-
-
public function formatWorkingHour($s) {
foreach( explode(",", $s) as $p) {
$ps[] = $p;
}
return implode(", ", $ps);
}
protected $data;
protected static function insertVisit($bizid, $customerid){
// DO NOT DO THIS! THIS IS NOT PROPER PLACE.. AND TOO BIG DATA!
// VORAPOAP 1/10/2558
/*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);
$result = \Drupal::service('typ.unvservice')->loadListing($this->data['customerid']);
$address_id = "";
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
if(isset($_COOKIE['breadcrumbs'])) {
$breadcrumbs_data = $_COOKIE['breadcrumbs'];
$breadcrumbs_ex= explode(",", $breadcrumbs_data);
$breadcrumbs[$breadcrumbs_ex[0]] = $breadcrumbs_ex[0];
$breadcrumbs['data'] = $breadcrumbs_ex[1];
$breadcrumbs['businessid'] = $breadcrumbs_ex[2];
}
$data = $this->data;
if (!$data) {
throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException();
}
if($this->data['onlinepromotion']){
$promotiond_mongo = \Drupal::service("typ.profile")->_getpromotion($bizid);
$promo = iterator_to_array($promotiond_mongo);
$proid = array();
foreach ($promo as $key => $value) {
foreach ($value as $k => $val) {
if($k == 'th'){
$proid['promotion'] += $val;
}if($k == 'en'){
$proid['promotion'] += $val;
}else{
$proid['promotion'][$k] = $val;
}
}
}
// echo "<PRE>";print_r($proid);exit;
$result['address'][$data['headingcode']][$data['addressid']]['promotion'] = $proid['promotion'];
// echo "<PRE>";print_r($result);exit;
}
//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?
//(!empty($result['landingpages'][$data['headingcode']]))?$result['landingpages'][$data['headingcode']]:array();
//$type = '';
$address_id = $data['addressid'];
$type = $this->data['customertype'];
if($this->data['accounting_status'] == '1' || $this->data['hide'] == '1'){ // Check Disable Packet and Hide content
$result['customertype'] = 'FL';
$type = 'FL';
}
if( $type== 'FL' || $this->data['customertype'] == ''){
$type = 'FL';
}else{
$result_olc = \Drupal::service('typ.catalog')->listData($data['customerid']);
}
if($language == 'en'){
$base_path = '/en/';
}else{
$base_path = '/';
}
if($_GET['debug']){
echo "<pre>";
echo "<br>Service:<b style='color:red;'><u>";if($this->data['accounting_status'] == '1'){ echo "Don't have a Service";}else{ echo "Service"; } echo "</u></b>";
echo "<br>Hide:<b style='color:red;'><u>";if($this->data['hide'] == '1'){ echo "Hide"; }else{ echo "Don't Hide"; } echo "</u></b>";
echo "<br>Type:<b style='color:red;'><u>".$type."</u></b><br><br>";
var_export($this->data);
exit;
}
$pos = strpos(html_entity_decode($data['proddesc']),"<p>");
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 = '<p style="color:#333;">';
$tempdesc = $temp . $tempdesc;
}
if($type == "FL") {
$dataproddesct = iconv_substr($tempdesc,0,123,"UTF-8");
if(strlen($dataproddesct) > 123){
$dataproddesct .= '...';
}
}else{
$dataproddesct = $tempdesc;
}
$dataproddesct = str_replace("<p>","<p style='color:#333;'>",$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);
+ $data['_format']['telno'][] = TYPUtilsService::formatPhoneNumber($t);
}
}
if (!empty($data['fax'])) {
foreach ($data['fax'] as $t) {
- $data['_format']['fax'][] = $this->formatPhoneNumber($t);
+ $data['_format']['fax'][] = TYPUtilsService::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;*/
}
if(!empty($data['website'])){
$data['website_show'] = $data['website'];
$data['website'] = explode(",",$data['website']);
foreach($data['website'] as $key => $new){
$new = str_replace("http://","",$new);
$data['website'][$key] = $new;
}
}
$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('/<p[^>]*?>/','',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('/<p[^>]*?>/','',html_entity_decode($data['profile']));
}
if (!empty($data['workinghours'])) {
$data['_format']['workinghours'] = $this->formatWorkingHour($data['workinghours']);
$data['customertyp'] = $data['customertype'];
}
if(!empty($data['cityname'])){
$bangkok = array('กรุงเทพ','กรุงเทพฯ','ก.ท.ม.','กรุงเทพมหานคร','กทม','จังหวัดกรุงเทพมหานคร','จังหวัด กรุงเทพมหานคร');
if(!in_array($data['cityname'],$bangkok)){
$data['cityname'] = t('Province') .' '. $data['cityname'];
}
}
if($type == 'FL'){
$data['profile'] = strip_tags($data['profile']);
}
$data['profile'] = str_replace("<p>","<p style='color:#333;'>",$data['profile']);
$data['lang'] = $this->data['lang'];
if(!empty($promotion_data['promoimg']) && @file_exists('http://promotion.yellowpages.co.th/media/promotion/'.$promotion_data['promoimg'])){ // images from Old system
$promotion_data['baseurl'] = 'http://promotion.yellowpages.co.th/media/promotion/';
}else{
$promotion_data['baseurl'] = 'http://media.yellowpages.co.th/yellowpages/promotion/';
}
if ($_SERVER['HTTP_REFERER']) {
}
$link_url = "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$check_lang = explode("/", $link_url);
if($check_lang[1] == 'en'){
$link_url = str_replace("/en/", "/", $link_url);
}
$display[] = array(
'#theme' => 'typ_profile',
'#profile' => $data,
'#prodescription' => $dataproddesct,
'#catalog' => $olcdata,
'#type' => $type,
'#promotion' => $promotion_data,
'#breadcrumbs' => $breadcrumbs,
'#base_path' => $base_path,
'#facebook_comment' => $link_url,
);
if ($type != 'FL')
$display['#attached']['drupalSettings']['disableAds'] = TRUE;
$display['#attached']['library'] = array(
'typ_profile/profile.popup',
'typ_contrib/colorbox',
);
if($type == 'FL'){
$display['#attached']['library'] = array(
'typ_profile/profile.popup',
'typ_contrib/colorbox',
'typ_ads/ads_unit'
);
$display[] = array(
'#markup' => format_string('<div class="container-fuild" id="corner-slider"></div>',array())
);
}else{
$display['#attached']['library'] = array(
'typ_profile/profile.popup',
'typ_contrib/colorbox',
);
}
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');
+ 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');
+ 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/');
+ 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 @@
-<?php namespace Drupal\typ_profile\Plugin\Block; /** * @file * Contains \Drupal\search\Plugin\Block\SearchBlock. */ use Drupal\Core\Block\BlockBase; use Drupal\Core\Url; use Drupal\typ_legacy\Service\TYPLegacyLandingPageService; use Drupal\typ_profile\Controller\TYPProfileController; use Drupal\typ_search\Service\TYPSearchService; use Drupal\typ_legacy\Serivee; /** * Provides a 'Search form' block. * * @Block( * id = "typ_profile_share_block", * admin_label = @Translation("Profile Share"), * category = @Translation("TYP") * ) */ class TYPProfileShareBlock extends BlockBase { public function getCacheMaxAge() { return 0; // NOCACHE! } public function formatWorkingHour($s) { foreach( explode(",", $s) as $p) { $ps[] = $p; } return implode(", ", $ps); } protected $data; protected $result; public function build(){ $fullurl = 'http://'.$_SERVER[HTTP_HOST].$_SERVER['REQUEST_URI']; $url = \Drupal::request()->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']; $prodesc = $this->result['address'][$this->data['headingcode']][$this->data['addressid']][$language]['proddesc']; $telno = '';$fax = '';$workinghours = ''; if(!empty($this->result['accounting_status']) || $type == 'FL'){ $type = 'FL'; } 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 = strip_tags($this->data['humanname']).'%0A%0A'.strip_tags($prodesc).'%0A%0A'."http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; switch ($type){ case "FL": $email = $body_email; $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.''.$fullurl; $twitter = format_string(strip_tags($this->data['proddesc']), array()).$fullurl; $gplus = 'https://plus.google.com/share?url='.$fullurl; break; default: $email = $body_email; $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.''.$fullurl; $twitter = format_string(strip_tags($this->data['proddesc']), array()).$fullurl; $gplus = 'https://plus.google.com/share?url='.$fullurl; } $base_url_images = '/themes/bootstrap/typ/images/icon-service-profilepage/'.$language; header('Content-Type: text/html; charset=UTF-8'); $build = array(); $build[] = array( '#markup' => format_string('<a href="/update-business-info" target="_blank"> <div class="col-xs-12 col-md-12 col-lg-12 text-left profile_share_title_promotion"> <img src="/themes/bootstrap/typ/images/icon/typ-icon-database.png"><span>'.t('If you own this business contact here').'</span> </div></a> <a href="/promotion-result" target="_blank"> <div class="col-xs-12 col-md-12 col-lg-12 text-left profile_share_title_promotion"> <img src="/themes/bootstrap/typ/images/icon/typ-icon-allpromotion.png"><span>'.t('Total Promotion').'</span> </div></a> <div class="col-xs-12 col-md-12 col-lg-12 text-left profile_share_title"> '.t('Share this business here').' </div> <div class="col-xs-12 col-md-12 col-lg-12 form-inline text-center profile_share" style="padding:10px 10px 10px 6px;"> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href=".profile_email" data-from="'.$this->data['humanname'].'" data-value="'.$email.'" onclick="sendmail(this); return false" ><img class="profile_email img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-email1-'.$language.'.png"></a> </div> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href="#" onclick="print_content()"><img class="profile_print img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-print1-'.$language.'.png"></a> </div> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href="#" onclick="window.open(\''.$facebook.'\',\'name\',\'width=600,height=400\')" ><img class="profile_facebook img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-facebook1-'.$language.'.png"></a> </div> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href="#" data-url="'.$twitter.'" data-text="'.$this->data['humanname'].'" onclick="window.open(\'https://twitter.com/share\',\'name\',\'width=600,height=400\')" ><img class="profile_twitter img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-twitter+1-'.$language.'.png"></a> </div> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href="#" onclick="window.open(\''.$gplus.'\',\'name\',\'width=600,height=400\')" ><img class="profile_google img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-google+1-'.$language.'.png"></a> </div> </div>', array()), ); $build['#attached']['library'] = array( 'typ_profile/profile_share' ); return $build; } } ?>
\ No newline at end of file
+<?php namespace Drupal\typ_profile\Plugin\Block; /** * @file * Contains \Drupal\search\Plugin\Block\SearchBlock. */ use Drupal\Core\Block\BlockBase; use Drupal\Core\Url; use Drupal\typ_legacy\Service\TYPLegacyLandingPageService; use Drupal\typ_profile\Controller\TYPProfileController; use Drupal\typ_search\Service\TYPSearchService; use Drupal\typ_legacy\Service\TYPUtilsService; use Drupal\typ_legacy\Service; /** * Provides a 'Search form' block. * * @Block( * id = "typ_profile_share_block", * admin_label = @Translation("Profile Share"), * category = @Translation("TYP") * ) */ class TYPProfileShareBlock extends BlockBase { public function getCacheMaxAge() { return 0; // NOCACHE! } public function formatWorkingHour($s) { foreach( explode(",", $s) as $p) { $ps[] = $p; } return implode(", ", $ps); } protected $data; protected $result; public function build(){ $fullurl = 'http://'.$_SERVER[HTTP_HOST].$_SERVER['REQUEST_URI']; $url = \Drupal::request()->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']; $prodesc = $this->result['address'][$this->data['headingcode']][$this->data['addressid']][$language]['proddesc']; $telno = '';$fax = '';$workinghours = ''; if(!empty($this->result['accounting_status']) || $type == 'FL'){ $type = 'FL'; } if (!empty($this->data['telno'])) { foreach ($this->data['telno'] as $t) { $telno .= TYPUtilsService::formatPhoneNumber($t); } } if (!empty($this->data['fax'])) { foreach ($this->data['fax'] as $t) { $fax .= TYPUtilsService::formatPhoneNumber($t); } } if (!empty($this->data['workinghours'])) { $workinghours .= $this->formatWorkingHour($this->data['workinghours']); } $body_email = strip_tags($this->data['humanname']).'%0A%0A'.strip_tags($prodesc).'%0A%0A'."http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; switch ($type){ case "FL": $email = $body_email; $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.''.$fullurl; $twitter = format_string(strip_tags($this->data['proddesc']), array()).$fullurl; $gplus = 'https://plus.google.com/share?url='.$fullurl; break; default: $email = $body_email; $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.''.$fullurl; $twitter = format_string(strip_tags($this->data['proddesc']), array()).$fullurl; $gplus = 'https://plus.google.com/share?url='.$fullurl; } $base_url_images = '/themes/bootstrap/typ/images/icon-service-profilepage/'.$language; header('Content-Type: text/html; charset=UTF-8'); $build = array(); $build[] = array( '#markup' => format_string('<a href="/update-business-info" target="_blank"> <div class="col-xs-12 col-md-12 col-lg-12 text-left profile_share_title_promotion"> <img src="/themes/bootstrap/typ/images/icon/typ-icon-database.png"><span>'.t('If you own this business contact here').'</span> </div></a> <a href="/promotion-result" target="_blank"> <div class="col-xs-12 col-md-12 col-lg-12 text-left profile_share_title_promotion"> <img src="/themes/bootstrap/typ/images/icon/typ-icon-allpromotion.png"><span>'.t('Total Promotion').'</span> </div></a> <div class="col-xs-12 col-md-12 col-lg-12 text-left profile_share_title"> '.t('Share this business here').' </div> <div class="col-xs-12 col-md-12 col-lg-12 form-inline text-center profile_share" style="padding:10px 10px 10px 6px;"> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href=".profile_email" data-from="'.$this->data['humanname'].'" data-value="'.$email.'" onclick="sendmail(this); return false" ><img class="profile_email img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-email1-'.$language.'.png"></a> </div> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href="#" onclick="print_content()"><img class="profile_print img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-print1-'.$language.'.png"></a> </div> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href="#" onclick="window.open(\''.$facebook.'\',\'name\',\'width=600,height=400\')" ><img class="profile_facebook img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-facebook1-'.$language.'.png"></a> </div> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href="#" data-url="'.$twitter.'" data-text="'.$this->data['humanname'].'" onclick="window.open(\'https://twitter.com/share\',\'name\',\'width=600,height=400\')" ><img class="profile_twitter img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-twitter+1-'.$language.'.png"></a> </div> <div class="col-xs-4 col-md-4 col-lg-4" style="padding: 5px !important;"> <a href="#" onclick="window.open(\''.$gplus.'\',\'name\',\'width=600,height=400\')" ><img class="profile_google img-responsive" onmouseover="hover_share(this);" onmouseout="out_share(this);" src="'.$base_url_images.'/pf-icon-google+1-'.$language.'.png"></a> </div> </div>', array()), ); $build['#attached']['library'] = array( 'typ_profile/profile_share' ); return $build; } } ?>
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Tue, Apr 29, 4:22 AM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
213155

Event Timeline