-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiHomefinderAdminEmailDisplay.php
More file actions
223 lines (197 loc) · 7.46 KB
/
iHomefinderAdminEmailDisplay.php
File metadata and controls
223 lines (197 loc) · 7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
if( !class_exists('IHomefinderAdminEmailDisplay')) {
/**
*
* This class has methods to support creating forms to set templates, custom url patterns and
* titles for iHomefinder Virtual Pages.
*
* @author ihomefinder
*/
class IHomefinderAdminEmailDisplay {
//Only possible values for
const EMAIL_DISPLAY_TYPE_DEFAULT_VALUE="ihf-email-display-type-default";
const EMAIL_DISPLAY_TYPE_CUSTOM_IMAGES_VALUE="ihf-email-display-type-custom-images";
const EMAIL_DISPLAY_TYPE_CUSTOM_HTML_VALUE="ihf-email-display-type-custom-hi";
private static $instance ;
private function __construct(){
}
public static function getInstance(){
if( !isset(self::$instance)){
self::$instance = new IHomefinderAdminEmailDisplay();
}
return self::$instance;
}
public function includeDefaultDisplay(){
$result=false;
$result=$this->getDefaultLogo();
return $result ;
}
public function getDefaultLogo(){
$defaultLogo=false;
if(function_exists('get_option_tree')){
$defaultLogo=get_option_tree('office_logo');
}
return $defaultLogo;
}
private function basicEmailHeader( $agentPhoto, $logo, $name, $company, $address1, $address2, $phone ){
$logoSize=getimagesize($logo);
$logoHeight=$logoSize[1];
$emailHeader="<table width='650' border='0' cellpadding='2' cellspacing='0' bgcolor='#9b9b9b'><tr><td>";
$emailHeader.="<table width='100%' border='0' cellpadding='0' cellspacing='0' bgcolor='#ffffff'><tr>";
$emailHeader .="<td>";
if($agentPhoto ){
$agentPhotoSize=getimagesize($agentPhoto);
$agentPhotoHeight=$agentPhotoSize[1];
if( $agentPhotoHeight > 142 ){
$emailHeader .= "<img src='" . $agentPhoto . "' height='142px'/>";
}
else{
$emailHeader .= "<img src='" . $agentPhoto . "'/>";
}
}
$emailHeader .= "</td>";
$emailHeader .="<td>";
$emailHeader .="<font face='Arial, Helvetica, sans-serif'>";
if($name ){
$emailHeader .= "<b>" . $name . "</b><br/>";
}
if($company ){
$emailHeader .= "<b>" . $company . "</b><br/><br/>";
}
if( $address1 ){
$emailHeader .= $address1 . "<br/>";
}
if( $address2 ){
$emailHeader .= $address2 . "<br/>";
}
if( $phone ){
$emailHeader .= $phone . "<br/>";
}
$emailHeader .="</font>";
$emailHeader .="</td>";
$emailHeader .="<td align='right'>";
if($logo ){
$logoSize=getimagesize($logo);
$logoHeight=$logoSize[1];
if( $logoHeight > 142 ){
$emailHeader .= "<img src='" . $logo . "' height='142px'/>";
}
else{
$emailHeader .= "<img src='" . $logo . "'/>";
}
}
$emailHeader .= "</td>";
$emailHeader .="</tr></table>";
$emailHeader .="</td></tr>";
$emailHeader .="<tr><td>";
$emailHeader .="<table width='100%' bgcolor='#ffffff'><tr><td>";
return $emailHeader;
}
private function basicEmailFooter( $agentPhoto, $logo, $name, $company, $address1, $address2, $phone ){
$emailFooter="</td></tr></table>";
$emailFooter .="</td></tr><tr><td>";
$emailFooter .="<table width='100%' cellpadding='10' cellspacing='0' border='0' bgcolor='#dedede'><tr>";
$emailFooter .="<td align='right'>";
$emailFooter .="<font face='Arial, Helvetica, sans-serif'>";
if($name ){
$emailFooter .= "<b>" . $name . "</b><br/>";
}
if($company ){
$emailFooter .= "<b>" . $company . "</b><br/><br/>";
}
if( $address1 ){
$emailFooter .= $address1 . "<br/>";
}
if( $address2 ){
$emailFooter .= $address2 . "<br/>";
}
if( $phone ){
$emailFooter .= $phone . "<br/>";
}
$emailFooter .="</font>";
$emailFooter .="</td>";
$emailFooter .="</tr></table>";
$emailFooter .="</td></tr></table>";
return $emailFooter;
}
public function setHeaderAndFooter(){
$emailHeader=$this->buildHeader();
$emailFooter=$this->buildFooter();
update_option( IHomefinderConstants::EMAIL_HEADER_OPTION, $emailHeader );
update_option( IHomefinderConstants::EMAIL_FOOTER_OPTION, $emailFooter ) ;
}
public function getHeader(){
$emailHeader=get_option(IHomefinderConstants::EMAIL_HEADER_OPTION);
return $emailHeader ;
}
public function getFooter(){
$emailFooter=get_option(IHomefinderConstants::EMAIL_FOOTER_OPTION);
return $emailFooter;
}
public function buildHeader(){
$header="";
$displayTypeValue=get_option(IHomefinderConstants::EMAIL_DISPLAY_TYPE_OPTION );
if( !$displayTypeValue){
$displayTypeValue=IHomefinderAdminEmailDisplay::EMAIL_DISPLAY_TYPE_DEFAULT_VALUE;
}
switch ( $displayTypeValue ) {
case IHomefinderAdminEmailDisplay::EMAIL_DISPLAY_TYPE_CUSTOM_IMAGES_VALUE:
$agentPhoto=get_option(IHomefinderConstants::EMAIL_PHOTO_OPTION);
$logo=get_option(IHomefinderConstants::EMAIL_LOGO_OPTION);
$name=get_option(IHomefinderConstants::EMAIL_NAME_OPTION);
$company=get_option(IHomefinderConstants::EMAIL_COMPANY_OPTION);
$address1=get_option(IHomefinderConstants::EMAIL_ADDRESS_LINE1_OPTION);
$address2=get_option(IHomefinderConstants::EMAIL_ADDRESS_LINE2_OPTION);
$phone=get_option(IHomefinderConstants::EMAIL_PHONE_OPTION);
$header=$this->basicEmailHeader($agentPhoto, $logo, $name, $company, $address1, $address2, $phone);
break;
case IHomefinderAdminEmailDisplay::EMAIL_DISPLAY_TYPE_CUSTOM_HTML_VALUE:
$header=get_option(IHomefinderConstants::EMAIL_HEADER_OPTION);
break;
case IHomefinderAdminEmailDisplay::EMAIL_DISPLAY_TYPE_DEFAULT_VALUE:
//Use the agent photo and office logo that were previoulsy uploaded
$agentPhoto=get_option(IHomefinderConstants::AGENT_PHOTO_OPTION);
$logo=$this->getDefaultLogo();
$header=$this->basicEmailHeader($agentPhoto, $logo);
break;
default:
$header="";
break;
}
return $header;
}
public function buildFooter(){
$footer="";
$displayTypeValue=get_option(IHomefinderConstants::EMAIL_DISPLAY_TYPE_OPTION );
if( !$displayTypeValue){
$displayTypeValue=IHomefinderAdminEmailDisplay::EMAIL_DISPLAY_TYPE_DEFAULT_VALUE;
}
switch ( $displayTypeValue ) {
case IHomefinderAdminEmailDisplay::EMAIL_DISPLAY_TYPE_CUSTOM_IMAGES_VALUE:
$agentPhoto=get_option(IHomefinderConstants::EMAIL_PHOTO_OPTION);
$logo=get_option(IHomefinderConstants::EMAIL_LOGO_OPTION);
$name=get_option(IHomefinderConstants::EMAIL_NAME_OPTION);
$company=get_option(IHomefinderConstants::EMAIL_COMPANY_OPTION);
$address1=get_option(IHomefinderConstants::EMAIL_ADDRESS_LINE1_OPTION);
$address2=get_option(IHomefinderConstants::EMAIL_ADDRESS_LINE2_OPTION);
$phone=get_option(IHomefinderConstants::EMAIL_PHONE_OPTION);
$footer=$this->basicEmailFooter($agentPhoto, $logo, $name, $company, $address1, $address2, $phone);
break;
case IHomefinderAdminEmailDisplay::EMAIL_DISPLAY_TYPE_CUSTOM_HTML_VALUE:
$footer=get_option(IHomefinderConstants::EMAIL_FOOTER_OPTION);
break;
case IHomefinderAdminEmailDisplay::EMAIL_DISPLAY_TYPE_DEFAULT_VALUE:
//Use the agent photo and office logo that were previoulsy uploaded
$agentPhoto=get_option(IHomefinderConstants::AGENT_PHOTO_OPTION);
$logo=$this->getDefaultLogo();
$footer=$this->basicEmailFooter($agentPhoto, $logo);
break;
default:
$footer="";
break;
}
return $footer;
}
}//end class
}//end if class exists
?>