Conditions | 1 |
Paths | 1 |
Total Lines | 136 |
Code Lines | 91 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
64 | protected function getStyles() |
||
65 | { |
||
66 | // start style tag |
||
67 | $html = ' <style type="text/css">'.PHP_EOL; |
||
68 | $html .= PHP_EOL; |
||
69 | |||
70 | // -- reset styles ---------------------------------------- |
||
71 | $html .= $this->getCssComment('--- RESET STYLES ---', ' '); |
||
72 | $html .= ' html { background-color:'. $this->backsideBackgroundColor . '; margin:0; padding:0; }'.PHP_EOL; |
||
73 | $html .= ' body, #bodyTable, #bodyCell, #bodyCell{height:100% !important; margin:0; padding:0;'; |
||
74 | $html .= ' width:100% !important; font-family:'. $this->emailBodyFont .';}'.PHP_EOL; |
||
75 | $html .= ' table{border-collapse:collapse;}'.PHP_EOL; |
||
76 | $html .= ' table[id=bodyTable] {width:100%!important;margin:auto;max-width:500px!important; color:'. $this->emailBodyColor . ';font-weight:normal;}'.PHP_EOL; |
||
77 | $html .= ' img, a img{border:0; outline:none; text-decoration:none;height:auto; line-height:100%;}'.PHP_EOL; |
||
78 | $html .= ' a {text-decoration:none !important;border-bottom: 1px solid;}'.PHP_EOL; |
||
79 | |||
80 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
81 | // todo custom COLOR !!!!!!!!!!!!!! font size ? line height ? margin ? see |
||
82 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
83 | $html .= ' h1, h2, h3, h4, h5, h6 {color:#5F5F5F; font-weight:normal; font-family:'. $this->emailBodyFont .';'.PHP_EOL; |
||
84 | $html .= ' font-size:20px; line-height:125%; text-align:Left; letter-spacing:normal;'.PHP_EOL; |
||
85 | $html .= ' margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;'.PHP_EOL; |
||
86 | $html .= ' padding-top:0;padding-bottom:10px;padding-left:0;padding-right:0;}'.PHP_EOL; |
||
87 | // custom |
||
88 | $html .= ' p {margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;'; |
||
89 | $html .= 'padding-top:0;padding-bottom:0;padding-left:0;padding-right:0;}'.PHP_EOL; |
||
90 | $html .= ' p + p {padding-top:10px;}'.PHP_EOL; |
||
91 | $html .= PHP_EOL; |
||
92 | |||
93 | // -- client specific styles ------------------------------------------- |
||
94 | $html .= $this->getCssComment('--- CLIENT-SPECIFIC STYLES ---', ' '); |
||
95 | $html .= ' .ReadMsgBody{width:100%;} .ExternalClass{width:100%;}'. $this->getCssComment(' Force Hotmail/Outlook.com to display emails at full width.'); |
||
96 | $html .= ' .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div{line-height:100%;}' . $this->getCssComment(' Force Hotmail/Outlook.com to display line heights normally.'); |
||
97 | $html .= ' table, td{mso-table-lspace:0pt; mso-table-rspace:0pt;}' . $this->getCssComment(' Remove spacing between tables in Outlook 2007 and up.'); |
||
98 | $html .= ' #outlook a{padding:0;}'. $this->getCssComment(' Force Outlook 2007 and up to provide a "view in browser" message.'); |
||
99 | $html .= ' img{-ms-interpolation-mode: bicubic;display:block;outline:none; text-decoration:none;}'. $this->getCssComment(' Force IE to smoothly render resized images.'); |
||
100 | $html .= ' body, table, td, p, a, li, blockquote{-ms-text-size-adjust:100%; -webkit-text-size-adjust:100%; font-weight:normal!important;}'. $this->getCssComment(' Prevent Windows- and Webkit-based mobile platforms from changing declared text sizes. '); |
||
101 | $html .= ' .ExternalClass td[class="ecxflexibleContainerBox"] h3 {padding-top: 10px !important;} '. $this->getCssComment(' Force hotmail to push 2-grid sub headers down'); |
||
102 | $html .= PHP_EOL; |
||
103 | |||
104 | // -- our styles -------------------------------------------------------- |
||
105 | $html .= $this->getCssComment('--- FRAMEWORK HACKS & OVERRIDES ---', ' '); |
||
106 | |||
107 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
108 | // todo custom font size ? line height ? colors .. |
||
109 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#3497D9!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
110 | $html .= ' h1{display:block;font-size:32px;font-style:normal;font-weight:200!important;line-height:100%;}'.PHP_EOL; |
||
111 | $html .= ' h2{display:block;font-size:27px;font-style:normal;font-weight:200!important;line-height:120%;}'.PHP_EOL; |
||
112 | $html .= ' h3{display:block;font-size:24px;font-style:normal;font-weight:200!important;line-height:110%;}'.PHP_EOL; |
||
113 | $html .= ' h4{display:block;font-size:22px;font-style:normal;font-weight:200!important;line-height:100%;}'.PHP_EOL; |
||
114 | $html .= ' h5{display:block;font-size:20px;font-style:normal;font-weight:200!important;line-height:110%;}'.PHP_EOL; |
||
115 | $html .= ' h6{display:block;font-size:18px;font-style:normal;font-weight:200!important;line-height:110%;}'.PHP_EOL; |
||
116 | |||
117 | $html .= ' .flexibleImage{height:auto;}'.PHP_EOL; |
||
118 | $html .= ' .linkRemoveBorder{border-bottom:0 !important;}'.PHP_EOL; |
||
119 | $html .= ' table[class=flexibleContainerCellDivider] {padding-bottom:0 !important;padding-top:0 !important;}'.PHP_EOL; |
||
120 | |||
121 | $html .= ' body, #bodyTable{background-color:'. $this->backsideBackgroundColor . ';}'.PHP_EOL; |
||
122 | $html .= ' #emailHeader{background-color:' . $this->backsideBackgroundColor . ';}'.PHP_EOL; |
||
123 | $html .= ' #emailBody{background-color:' . $this->emailBodyBackgroundColor . ';}'.PHP_EOL; |
||
124 | $html .= ' #emailFooter{background-color:' . $this->backsideBackgroundColor . ';}'.PHP_EOL; |
||
125 | $html .= ' .emailButton{background-color:#3497D9; border-collapse:separate;}'.PHP_EOL; |
||
126 | $html .= ' .buttonContent{color:#FFFFFF; font-family:Helvetica; font-size:18px; font-weight:200; line-height:100%; padding:15px; text-align:center;}'.PHP_EOL; |
||
127 | $html .= ' .buttonContent a{color:#FFFFFF; display:block; text-decoration:none!important; border:0!important;}'.PHP_EOL; |
||
128 | $html .= PHP_EOL; |
||
129 | |||
130 | |||
131 | // ------------------------------------------------------------- |
||
132 | // -- mobiles styles ------------------------------------------- |
||
133 | // ------------------------------------------------------------- |
||
134 | $html .= $this->getCssComment('--- MOBILE STYLES ---', ' '); |
||
135 | $html .= ' @media only screen and (max-width: '. strval($this->emailBodyWidth - 20) . 'px) {'.PHP_EOL; |
||
136 | $html .= PHP_EOL; |
||
137 | |||
138 | // -- client specific styles ------------------------------------------- |
||
139 | $html .= $this->getCssComment('--- CLIENT-SPECIFIC STYLES ---', ' '); |
||
140 | $html .= ' body{width:100% !important; min-width:100% !important;}'. $this->getCssComment(' Force iOS Mail to render the email at full width.'); |
||
141 | $html .= PHP_EOL; |
||
142 | |||
143 | //todo |
||
144 | $html .= $this->getCssComment('--- FRAMEWORK STYLES ---', ' '); |
||
145 | $html .= ' table[id="emailHeader"],'.PHP_EOL; |
||
146 | $html .= ' table[id="emailBody"],'.PHP_EOL; |
||
147 | $html .= ' table[id="emailFooter"],'.PHP_EOL; |
||
148 | $html .= ' table[class="flexibleContainer"],'.PHP_EOL; |
||
149 | $html .= ' td[class="flexibleContainerCell"] {width:100% !important;}'.PHP_EOL; |
||
150 | $html .= ' td[class="flexibleContainerBox"], '.PHP_EOL; |
||
151 | $html .= ' td[class="flexibleContainerBox"] table {display: block;width: 100%;text-align: left;}'.PHP_EOL; |
||
152 | |||
153 | //todo |
||
154 | |||
155 | $html .= $this->getCssComment('The following style rule makes any image classed with \'flexibleImage\'fluid' . PHP_EOL |
||
156 | . ' when the query activates. Make sure you add an inline max-width to those '. PHP_EOL |
||
157 | . ' to prevent them from blowing out.', ' '); |
||
158 | |||
159 | $html .= ' td[class="imageContent"] img {height:auto !important; width:100% !important; max-width:100% !important; }'. PHP_EOL; |
||
160 | $html .= ' img[class="flexibleImage"]{height:auto !important; width:100% !important;max-width:100% !important;}'. PHP_EOL; |
||
161 | $html .= ' img[class="flexibleImageSmall"]{height:auto !important; width:auto !important;}'. PHP_EOL; |
||
162 | |||
163 | $html .= $this->getCssComment('Create top space for every second element in a block', ' '); |
||
164 | $html .= ' table[class="flexibleContainerBoxNext"]{padding-top: 10px !important;}'. PHP_EOL; |
||
165 | |||
166 | $html .= $this->getCssComment('Make buttons in the email span the full width of their container, allowing' |
||
167 | . 'for left- or right-handed ease of use.', ' '); |
||
168 | |||
169 | $html .= ' table[class="emailButton"]{width:100% !important;}'. PHP_EOL; |
||
170 | $html .= ' td[class="buttonContent"]{padding:0 !important;}'. PHP_EOL; |
||
171 | $html .= ' td[class="buttonContent"] a{padding:15px !important;}'. PHP_EOL; |
||
172 | $html .= ' }'.PHP_EOL; |
||
173 | |||
174 | //todo more ... |
||
175 | |||
176 | // close style tag |
||
177 | $html .= ' </style>'.PHP_EOL; |
||
178 | |||
179 | // ------- conditional formatting for outlook -------------------- |
||
180 | $html .= $this->getHtmlComment('Outlook Conditional CSS. ' . PHP_EOL |
||
181 | . ' These two style blocks target Outlook 2007 & 2010 specifically, forcing' . PHP_EOL |
||
182 | . ' columns into a single vertical stack as on mobile clients. This is' . PHP_EOL |
||
183 | . ' primarily done to avoid the \'page break bug\' and is optional.' . PHP_EOL |
||
184 | . ' More information here: https://templates.mailchimp.com/development/css/outlook-conditional-css' . PHP_EOL |
||
185 | . ' ',' '); |
||
186 | |||
187 | $html .= ' <!--[if mso 12]>'.PHP_EOL; |
||
188 | $html .= ' <style type="text/css">'.PHP_EOL; |
||
189 | $html .= ' .flexibleContainer{display:block !important; width:100% !important;}'.PHP_EOL; |
||
190 | $html .= ' </style>'.PHP_EOL; |
||
191 | $html .= ' <![endif]-->'.PHP_EOL; |
||
192 | $html .= ' <!--[if mso 14]>'.PHP_EOL; |
||
193 | $html .= ' <style type="text/css">'.PHP_EOL; |
||
194 | $html .= ' .flexibleContainer{display:block !important; width:100% !important;}'.PHP_EOL; |
||
195 | $html .= ' </style>'.PHP_EOL; |
||
196 | $html .= ' <![endif]-->'.PHP_EOL; |
||
197 | |||
198 | // done |
||
199 | return $html; |
||
200 | } |
||
217 | } |