Conditions | 56 |
Paths | > 20000 |
Total Lines | 197 |
Code Lines | 142 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
76 | public static function printFamilyParents(Family $family, $sosa = 0, $label = '', $parid = '', $gparid = '', $show_full = 1) |
||
77 | { |
||
78 | if ($show_full) { |
||
79 | $pbheight = Theme::theme()->parameter('chart-box-y') + 14; |
||
80 | } else { |
||
81 | $pbheight = Theme::theme()->parameter('compact-chart-box-y') + 14; |
||
82 | } |
||
83 | |||
84 | $husb = $family->getHusband(); |
||
85 | if ($husb) { |
||
86 | echo '<a name="', $husb->getXref(), '"></a>'; |
||
87 | } else { |
||
88 | $husb = new Individual('M', "0 @M@ INDI\n1 SEX M", null, $family->getTree()); |
||
89 | } |
||
90 | $wife = $family->getWife(); |
||
91 | if ($wife) { |
||
92 | echo '<a name="', $wife->getXref(), '"></a>'; |
||
93 | } else { |
||
94 | $wife = new Individual('F', "0 @F@ INDI\n1 SEX F", null, $family->getTree()); |
||
95 | } |
||
96 | |||
97 | if ($sosa) { |
||
98 | echo '<p class="name_head">', $family->getFullName(), '</p>'; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * husband side |
||
103 | */ |
||
104 | echo '<table cellspacing="0" cellpadding="0" border="0"><tr><td rowspan="2">'; |
||
105 | echo '<table border="0"><tr>'; |
||
106 | |||
107 | if ($parid) { |
||
108 | if ($husb->getXref() == $parid) { |
||
109 | self::printSosaNumber($label); |
||
110 | } else { |
||
111 | self::printSosaNumber($label, '', 'blank'); |
||
112 | } |
||
113 | } elseif ($sosa) { |
||
114 | self::printSosaNumber($sosa * 2); |
||
115 | } |
||
116 | if ($husb->isPendingAddtion()) { |
||
117 | echo '<td class="facts_value new">'; |
||
118 | } elseif ($husb->isPendingDeletion()) { |
||
119 | echo '<td class="facts_value old">'; |
||
120 | } else { |
||
121 | echo '<td>'; |
||
122 | } |
||
123 | FunctionsPrint::printPedigreePerson($husb, $show_full); |
||
124 | echo '</td></tr></table>'; |
||
125 | echo '</td>'; |
||
126 | // husband’s parents |
||
127 | $hfam = $husb->getPrimaryChildFamily(); |
||
128 | if ($hfam) { |
||
129 | // remove the|| test for $sosa |
||
130 | echo '<td rowspan="2"><img src="' . Theme::theme()->parameter('image-hline') . '"></td><td rowspan="2"><img src="' . Theme::theme()->parameter('image-vline') . '" width="3" height="' . ($pbheight + 9) . '"></td>'; |
||
131 | echo '<td><img class="line5" src="' . Theme::theme()->parameter('image-hline') . '"></td><td>'; |
||
132 | // husband’s father |
||
133 | if ($hfam && $hfam->getHusband()) { |
||
134 | echo '<table border="0"><tr>'; |
||
135 | if ($sosa > 0) { |
||
136 | self::printSosaNumber($sosa * 4, $hfam->getHusband()->getXref(), 'down'); |
||
137 | } |
||
138 | if (!empty($gparid) && $hfam->getHusband()->getXref() == $gparid) { |
||
139 | self::printSosaNumber(trim(substr($label, 0, -3), '.') . '.'); |
||
140 | } |
||
141 | echo '<td>'; |
||
142 | FunctionsPrint::printPedigreePerson($hfam->getHusband(), $show_full); |
||
143 | echo '</td></tr></table>'; |
||
144 | } elseif ($hfam && !$hfam->getHusband()) { |
||
145 | // Empty box for grandfather |
||
146 | echo '<table border="0"><tr>'; |
||
147 | echo '<td>'; |
||
148 | FunctionsPrint::printPedigreePerson($hfam->getHusband(), $show_full); |
||
149 | echo '</td></tr></table>'; |
||
150 | } |
||
151 | echo '</td>'; |
||
152 | } |
||
153 | if ($hfam && ($sosa != -1)) { |
||
154 | echo '<td rowspan="2">'; |
||
155 | self::printUrlArrow(($sosa == 0 ? '?famid=' . $hfam->getXref() . '&ged=' . $hfam->getTree()->getNameUrl() : '#' . $hfam->getXref()), $hfam->getXref(), 1); |
||
156 | echo '</td>'; |
||
157 | } |
||
158 | if ($hfam) { |
||
159 | // husband’s mother |
||
160 | echo '</tr><tr><td><img src="' . Theme::theme()->parameter('image-hline') . '"></td><td>'; |
||
161 | if ($hfam && $hfam->getWife()) { |
||
162 | echo '<table border=\'0\'><tr>'; |
||
163 | if ($sosa > 0) { |
||
164 | self::printSosaNumber($sosa * 4 + 1, $hfam->getWife()->getXref(), 'down'); |
||
165 | } |
||
166 | if (!empty($gparid) && $hfam->getWife()->getXref() == $gparid) { |
||
167 | self::printSosaNumber(trim(substr($label, 0, -3), '.') . '.'); |
||
168 | } |
||
169 | echo '<td>'; |
||
170 | FunctionsPrint::printPedigreePerson($hfam->getWife(), $show_full); |
||
171 | echo '</td></tr></table>'; |
||
172 | } elseif ($hfam && !$hfam->getWife()) { |
||
173 | // Empty box for grandmother |
||
174 | echo '<table border="0"><tr>'; |
||
175 | echo '<td>'; |
||
176 | FunctionsPrint::printPedigreePerson($hfam->getWife(), $show_full); |
||
177 | echo '</td></tr></table>'; |
||
178 | } |
||
179 | echo '</td>'; |
||
180 | } |
||
181 | echo '</tr></table>'; |
||
182 | if ($sosa && $family->canShow()) { |
||
183 | foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) { |
||
184 | echo '<a href="', $family->getHtmlUrl(), '" class="details1">'; |
||
185 | echo str_repeat(' ', 10); |
||
186 | echo $fact->summary(); |
||
187 | echo '</a>'; |
||
188 | } |
||
189 | } else { |
||
190 | echo '<br>'; |
||
191 | } |
||
192 | |||
193 | /** |
||
194 | * wife side |
||
195 | */ |
||
196 | echo '<table cellspacing="0" cellpadding="0" border="0"><tr><td rowspan="2">'; |
||
197 | echo '<table><tr>'; |
||
198 | if ($parid) { |
||
199 | if ($wife->getXref() == $parid) { |
||
200 | self::printSosaNumber($label); |
||
201 | } else { |
||
202 | self::printSosaNumber($label, '', 'blank'); |
||
203 | } |
||
204 | } elseif ($sosa) { |
||
205 | self::printSosaNumber($sosa * 2 + 1); |
||
206 | } |
||
207 | if ($wife->isPendingAddtion()) { |
||
208 | echo '<td class="facts_value new">'; |
||
209 | } elseif ($wife->isPendingDeletion()) { |
||
210 | echo '<td class="facts_value old">'; |
||
211 | } else { |
||
212 | echo '<td>'; |
||
213 | } |
||
214 | FunctionsPrint::printPedigreePerson($wife, $show_full); |
||
215 | echo '</td></tr></table>'; |
||
216 | echo '</td>'; |
||
217 | // wife’s parents |
||
218 | $hfam = $wife->getPrimaryChildFamily(); |
||
219 | |||
220 | if ($hfam) { |
||
221 | echo '<td rowspan="2"><img src="' . Theme::theme()->parameter('image-hline') . '"></td><td rowspan="2"><img src="' . Theme::theme()->parameter('image-vline') . '" width="3" height="' . ($pbheight + 9) . '"></td>'; |
||
222 | echo '<td><img class="line5" src="' . Theme::theme()->parameter('image-hline') . '"></td><td>'; |
||
223 | // wife’s father |
||
224 | if ($hfam && $hfam->getHusband()) { |
||
225 | echo '<table><tr>'; |
||
226 | if ($sosa > 0) { |
||
227 | self::printSosaNumber($sosa * 4 + 2, $hfam->getHusband()->getXref(), 'down'); |
||
228 | } |
||
229 | if (!empty($gparid) && $hfam->getHusband()->getXref() == $gparid) { |
||
230 | self::printSosaNumber(trim(substr($label, 0, -3), '.') . '.'); |
||
231 | } |
||
232 | echo '<td>'; |
||
233 | FunctionsPrint::printPedigreePerson($hfam->getHusband(), $show_full); |
||
234 | echo '</td></tr></table>'; |
||
235 | } elseif ($hfam && !$hfam->getHusband()) { |
||
236 | // Empty box for grandfather |
||
237 | echo '<table border="0"><tr>'; |
||
238 | echo '<td>'; |
||
239 | FunctionsPrint::printPedigreePerson($hfam->getHusband(), $show_full); |
||
240 | echo '</td></tr></table>'; |
||
241 | } |
||
242 | echo '</td>'; |
||
243 | } |
||
244 | if ($hfam && ($sosa != -1)) { |
||
245 | echo '<td rowspan="2">'; |
||
246 | self::printUrlArrow(($sosa == 0 ? '?famid=' . $hfam->getXref() . '&ged=' . $hfam->getTree()->getNameUrl() : '#' . $hfam->getXref()), $hfam->getXref(), 1); |
||
247 | echo '</td>'; |
||
248 | } |
||
249 | if ($hfam) { |
||
250 | // wife’s mother |
||
251 | echo '</tr><tr><td><img src="' . Theme::theme()->parameter('image-hline') . '"></td><td>'; |
||
252 | if ($hfam && $hfam->getWife()) { |
||
253 | echo '<table><tr>'; |
||
254 | if ($sosa > 0) { |
||
255 | self::printSosaNumber($sosa * 4 + 3, $hfam->getWife()->getXref(), 'down'); |
||
256 | } |
||
257 | if (!empty($gparid) && $hfam->getWife()->getXref() == $gparid) { |
||
258 | self::printSosaNumber(trim(substr($label, 0, -3), '.') . '.'); |
||
259 | } |
||
260 | echo '<td>'; |
||
261 | FunctionsPrint::printPedigreePerson($hfam->getWife(), $show_full); |
||
262 | echo '</td></tr></table>'; |
||
263 | } elseif ($hfam && !$hfam->getWife()) { |
||
264 | // Empty box for grandmother |
||
265 | echo '<table border="0"><tr>'; |
||
266 | echo '<td>'; |
||
267 | FunctionsPrint::printPedigreePerson($hfam->getWife(), $show_full); |
||
268 | echo '</td></tr></table>'; |
||
269 | } |
||
270 | echo '</td>'; |
||
271 | } |
||
272 | echo '</tr></table>'; |
||
273 | } |
||
558 |