| Conditions | 19 |
| Paths | 2400 |
| Total Lines | 94 |
| Code Lines | 65 |
| 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 |
||
| 174 | public function show_replacements() |
||
| 175 | { |
||
| 176 | $GLOBALS['egw_info']['flags']['app_header'] = lang('infolog').' - '.lang('Replacements for inserting entries into documents'); |
||
| 177 | $GLOBALS['egw_info']['flags']['nonavbar'] = false; |
||
| 178 | echo $GLOBALS['egw']->framework->header(); |
||
| 179 | |||
| 180 | echo "<table width='90%' align='center'>\n"; |
||
| 181 | echo '<tr><td colspan="4"><h3>'.lang('Infolog fields:')."</h3></td></tr>"; |
||
| 182 | |||
| 183 | $n = 0; |
||
| 184 | $tracking = new infolog_tracking($this->bo); |
||
| 185 | $fields = array('info_id' => lang('Infolog ID'), 'pm_id' => lang('Project ID'), 'project' => lang('Project name')) + $tracking->field2label + array('info_sum_timesheets' => lang('Used time')); |
||
| 186 | Api\Translation::add_app('projectmanager'); |
||
| 187 | foreach($fields as $name => $label) |
||
| 188 | { |
||
| 189 | if (in_array($name,array('custom'))) continue; // dont show them |
||
| 190 | |||
| 191 | if (in_array($name,array('info_subject', 'info_des')) && $n&1) // main values, which should be in the first column |
||
| 192 | { |
||
| 193 | echo "</tr>\n"; |
||
| 194 | $n++; |
||
| 195 | } |
||
| 196 | if (!($n&1)) echo '<tr>'; |
||
| 197 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
||
| 198 | if ($n&1) echo "</tr>\n"; |
||
| 199 | $n++; |
||
| 200 | } |
||
| 201 | |||
| 202 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
||
| 203 | $contact_custom = false; |
||
| 204 | foreach($this->bo->customfields as $name => $field) |
||
| 205 | { |
||
| 206 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label'].($field['type'] == 'select-account' ? '*':'')."</td></tr>\n"; |
||
| 207 | if($field['type'] == 'select-account') $contact_custom = true; |
||
| 208 | } |
||
| 209 | if($contact_custom) |
||
| 210 | { |
||
| 211 | echo '<tr><td /><td colspan="3">* '.lang('Addressbook placeholders available'). '</td></tr>'; |
||
| 212 | } |
||
| 213 | |||
| 214 | echo '<tr><td colspan="4"><h3>'.lang('Parent').":</h3></td></tr>"; |
||
| 215 | echo '<tr><td>{{info_id_parent/info_subject}}</td><td colspan="3">'.lang('All other %1 fields are valid',lang('infolog'))."</td></tr>\n"; |
||
| 216 | |||
| 217 | echo '<tr><td colspan="4"><h3>'.lang('Contact fields').':</h3></td></tr>'; |
||
| 218 | $i = 0; |
||
| 219 | foreach($this->contacts->contact_fields as $name => $label) |
||
| 220 | { |
||
| 221 | if (in_array($name,array('tid','label','geo'))) continue; // dont show them, as they are not used in the UI atm. |
||
| 222 | |||
| 223 | if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) // main values, which should be in the first column |
||
| 224 | { |
||
| 225 | echo "</tr>\n"; |
||
| 226 | $i++; |
||
| 227 | } |
||
| 228 | if (!($i&1)) echo '<tr>'; |
||
| 229 | echo '<td>{{info_contact/'.$name.'}}</td><td>'.$label.'</td>'; |
||
| 230 | if ($i&1) echo "</tr>\n"; |
||
| 231 | $i++; |
||
| 232 | } |
||
| 233 | |||
| 234 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
||
| 235 | foreach($this->contacts->customfields as $name => $field) |
||
| 236 | { |
||
| 237 | echo '<tr><td>{{info_contact/#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
||
| 238 | } |
||
| 239 | |||
| 240 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
||
| 241 | foreach(array( |
||
| 242 | 'link' => lang('HTML link to the current record'), |
||
| 243 | 'links' => lang('Titles of any entries linked to the current record, excluding attached files'), |
||
| 244 | 'attachments' => lang('List of files linked to the current record'), |
||
| 245 | 'links_attachments' => lang('Links and attached files'), |
||
| 246 | 'links/[appname]' => lang('Links to specified application. Example: {{links/infolog}}'), |
||
| 247 | 'links/href' => lang('Links wrapped in an HREF tag with download link'), |
||
| 248 | 'links/link' => lang('Download url for links'), |
||
| 249 | 'date' => lang('Date'), |
||
| 250 | 'user/n_fn' => lang('Name of current user, all other contact fields are valid too'), |
||
| 251 | 'user/account_lid' => lang('Username'), |
||
| 252 | 'pagerepeat' => lang('For serial letter use this tag. Put the content, you want to repeat between two Tags.'), |
||
| 253 | 'label' => lang('Use this tag for addresslabels. Put the content, you want to repeat, between two tags.'), |
||
| 254 | 'labelplacement' => lang('Tag to mark positions for address labels'), |
||
| 255 | 'IF fieldname' => lang('Example {{IF n_prefix~Mr~Hello Mr.~Hello Ms.}} - search the field "n_prefix", for "Mr", if found, write Hello Mr., else write Hello Ms.'), |
||
| 256 | 'NELF' => lang('Example {{NELF role}} - if field role is not empty, you will get a new line with the value of field role'), |
||
| 257 | 'NENVLF' => lang('Example {{NENVLF role}} - if field role is not empty, set a LF without any value of the field'), |
||
| 258 | 'LETTERPREFIX' => lang('Example {{LETTERPREFIX}} - Gives a letter prefix without double spaces, if the title is emty for example'), |
||
| 259 | 'LETTERPREFIXCUSTOM' => lang('Example {{LETTERPREFIXCUSTOM n_prefix title n_family}} - Example: Mr Dr. James Miller'), |
||
| 260 | ) as $name => $label) |
||
| 261 | { |
||
| 262 | echo '<tr><td>{{'.$name.'}}</td><td colspan="3">'.$label."</td></tr>\n"; |
||
| 263 | } |
||
| 264 | |||
| 265 | echo "</table>\n"; |
||
| 266 | |||
| 267 | echo $GLOBALS['egw']->framework->footer(); |
||
| 268 | } |
||
| 270 |