Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1082646
TYPProfileController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
TYPProfileController.php
View Options
<?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
;
/**
* Controller routines for tablesort example routes.
*/
class
TYPProfileController
extends
ControllerBase
{
/*public function profile_redirect(){
return $this->redirect("<front>");
}*/
public
function
formatPhoneNumber
(
$s
)
{
foreach
(
explode
(
","
,
$s
)
as
$p
)
{
$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
));
}
}
}
$ps
[]
=
$num_com
;
}
return
implode
(
", "
,
$ps
);
}
public
function
formatWorkingHour
(
$s
)
{
foreach
(
explode
(
","
,
$s
)
as
$p
)
{
$ps
[]
=
$p
;
}
return
implode
(
", "
,
$ps
);
}
protected
$data
;
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
(
"<front>"
);
}
/*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'
)->
loadService
(
$data
[
'customerid'
]);
//(!empty($result['landingpages'][$data['headingcode']]))?$result['landingpages'][$data['headingcode']]:array();
//$type = '';
if
(
$result
[
'customertype'
]
==
'FL'
){
$type
=
'FL'
;
}
else
{
$result_olc
=
\Drupal
::
service
(
'typ.catalog'
)->
listData
(
$data
[
'customerid'
]);
}
$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'];
}
$temp
=
'<p style="color:#000;">'
;
$tempdesc
=
$temp
.
$tempdesc
;
$type
=
$data
[
'customertyp'
];
if
(
$type
==
"FL"
)
{
$dataproddesct
=
iconv_substr
(
$tempdesc
,
0
,
123
,
"UTF-8"
);
$dataproddesct
.=
'...'
;
}
else
{
$dataproddesct
=
$tempdesc
;
}
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;*/
}
if
(!
empty
(
$data
[
'workinghours'
]))
$data
[
'_format'
][
'workinghours'
]
=
$this
->
formatWorkingHour
(
$data
[
'workinghours'
]);
$display
[]
=
array
(
'#theme'
=>
'typ_profile'
,
'#profile'
=>
$data
,
'#prodescription'
=>
$dataproddesct
,
'#catalog'
=>
$olcdata
,
'#type'
=>
$type
);
$display
[
'#attached'
][
'drupalSettings'
][
'typ_profile'
][
'customertype'
]
=
$type
;
return
$display
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Dec 23, 8:05 AM (18 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
193534
Attached To
rPF typ_profile
Event Timeline
Log In to Comment