Page MenuHomePhabricator

No OneTemporary

diff --git a/src/Plugin/Block/TYPProfileDetail.php b/src/Plugin/Block/TYPProfileDetail.php
--- a/src/Plugin/Block/TYPProfileDetail.php
+++ b/src/Plugin/Block/TYPProfileDetail.php
@@ -1,133 +1,137 @@
<?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_search\Service\TYPSearchService;
use Drupal\typ_legacy\Serivee;
use Drupal\Core\Access\AccessResult;
/**
* Provides a 'Search form' block.
*
* @Block(
* id = "typ_profile_detail_more",
* admin_label = @Translation("Profile Detail more"),
* category = @Translation("TYP")
* )
*/
class TYPProfileDetail extends BlockBase
{
+ public function getCacheMaxAge() {
+ return 0; // NOCACHE!
+ }
+
static $data;
static $result;
static $datashow;
public function blockAccess(\Drupal\Core\Session\AccountInterface $account) {
$url = \Drupal::request()->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 = '<span class="glyphicon glyphicon-star" aria-hidden="true"></span>&nbsp;';
$star_empty = '<span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span>&nbsp;';
if(!empty($result['landmark'])){
$html .= '<p class="orange_font">' . t('Landmark') . ':</p>
<p class="gray_font">' . $result['landmark'] . '</p>';
}
if(!empty($result['paymentmethod'])) {
$html .= '<p class="orange_font">' . t('Payment') . ':</p>
<p class="gray_font">' . $result['paymentmethod'] . '</p>';
}
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 .= '<p class="orange_font">' . t('Rating') .': &nbsp;&nbsp;'.$rateing.'</p>';
}
if(!empty($result['standard'])){
$html .= '<p class="orange_font">'.t('Standard').':</p>
<p class="gray_font">'.$result['standard'].'</p>';
}
if(!empty($result['atmosphere'])){
$html .= '<p class="orange_font">'.t('Atmosphere').':</p>
<p class="gray_font">'.$result['atmosphere'].'</p>';
}
if(empty($result['duration'])){
if(!empty($result['amentity'])) {
$result['duration'] = $result['amentity'];
}
}
if(!empty($result['duration'])){
$html .= '<p class="orange_font">'.t('Facilities').':</p>
<p class="gray_font">'.$result['duration'].'</p>';
}
$data = '<div class="col-xs-12 col-md-12 col-lg-12 text-left profile_share_title">
'.t('More details').'
</div>
<div class="col-xs-12 col-md-12 col-lg-12 form-inline text-left profile_share" style="padding:10px 10px 10px 6px;">
<div class="col-xs-12 col-md-12 col-lg-12">'.
$html
.'</div>
</div>';
if(empty($result) || is_null($result)){
$data = '';
}
// echo "<PRE>";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
diff --git a/src/Plugin/Block/TYPProfileFacebook.php b/src/Plugin/Block/TYPProfileFacebook.php
--- a/src/Plugin/Block/TYPProfileFacebook.php
+++ b/src/Plugin/Block/TYPProfileFacebook.php
@@ -1,57 +1,61 @@
<?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_search\Service\TYPSearchService;
use Drupal\typ_legacy\Serivee;
/**
* Provides a 'Search form' block.
*
* @Block(
* id = "typ_profile_share_facebook",
* admin_label = @Translation("Profile facebook"),
* category = @Translation("TYP")
* )
*/
class TYPProfileFacebook extends BlockBase
{
protected $data;
protected $result;
+ public function getCacheMaxAge() {
+ return 0; // NOCACHE!
+ }
+
public function build(){
$url = \Drupal::request()->getRequestUri();
$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);
$facebook = '';
if($this->data['customertype'] == 'FL' || $this->data['customertype'] == '' || $this->result['accounting_status'] == '1' || $this->data['hide'] == '1' || $this->data['accounting_status'] == '1'){
$facebook = format_string('<div class="text-center"><div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/th_TH/sdk.js#xfbml=1&version=v2.4";
fjs.parentNode.insertBefore(js, fjs);
}(document, \'script\', \'facebook-jssdk\'));</script>
<div class="fb-page" data-href="https://www.facebook.com/ThailandYellowPages" data-width="350" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true" data-show-posts="false"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/ThailandYellowPages"><a href="https://www.facebook.com/ThailandYellowPages">Thailand YellowPages</a></blockquote></div></div></div>');
}
$build = array();
$build[] = array(
'#markup' => $facebook,
);
return $build;
}
}
\ No newline at end of file
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 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='.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; 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>'), ); $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\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='.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; 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>'), ); $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, 9:41 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
213587

Event Timeline