| Conditions | 21 |
| Paths | 1190 |
| Total Lines | 92 |
| Code Lines | 51 |
| 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 |
||
| 48 | function displayList($layout_def) |
||
| 49 | { |
||
| 50 | global $focus; |
||
| 51 | |||
| 52 | $module = ''; |
||
| 53 | $record = ''; |
||
| 54 | |||
| 55 | if(isset($layout_def['varname'])) |
||
| 56 | { |
||
| 57 | $key = strtoupper($layout_def['varname']); |
||
| 58 | } |
||
| 59 | else |
||
| 60 | { |
||
| 61 | $key = $this->_get_column_alias($layout_def); |
||
| 62 | $key = strtoupper($key); |
||
| 63 | } |
||
| 64 | if (empty($layout_def['fields'][$key])) { |
||
| 65 | return ""; |
||
| 66 | } else { |
||
| 67 | $value = $layout_def['fields'][$key]; |
||
| 68 | } |
||
| 69 | |||
| 70 | |||
| 71 | if(empty($layout_def['target_record_key'])) |
||
| 72 | { |
||
| 73 | $record = $layout_def['fields']['ID']; |
||
| 74 | } |
||
| 75 | else |
||
| 76 | { |
||
| 77 | $record_key = strtoupper($layout_def['target_record_key']); |
||
| 78 | $record = $layout_def['fields'][$record_key]; |
||
| 79 | } |
||
| 80 | |||
| 81 | if(!empty($layout_def['target_module_key'])) { |
||
| 82 | if (!empty($layout_def['fields'][strtoupper($layout_def['target_module_key'])])) { |
||
| 83 | $module=$layout_def['fields'][strtoupper($layout_def['target_module_key'])]; |
||
| 84 | } |
||
| 85 | } |
||
| 86 | |||
| 87 | if (empty($module)) { |
||
| 88 | if(empty($layout_def['target_module'])) |
||
| 89 | { |
||
| 90 | $module = $layout_def['module']; |
||
| 91 | } |
||
| 92 | else |
||
| 93 | { |
||
| 94 | $module = $layout_def['target_module']; |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | //links to email module now need additional information. |
||
| 99 | //this is to resolve the information about the target of the emails. necessitated by feature that allow |
||
| 100 | //only on email record for the whole campaign. |
||
| 101 | $parent=''; |
||
| 102 | if (!empty($layout_def['parent_info'])) { |
||
| 103 | if (!empty($focus)){ |
||
| 104 | $parent="&parent_id=".$focus->id; |
||
| 105 | $parent.="&parent_module=".$focus->module_dir; |
||
| 106 | } |
||
| 107 | } else { |
||
| 108 | if(!empty($layout_def['parent_id'])) { |
||
| 109 | if (isset($layout_def['fields'][strtoupper($layout_def['parent_id'])])) { |
||
| 110 | $parent.="&parent_id=".$layout_def['fields'][strtoupper($layout_def['parent_id'])]; |
||
| 111 | } |
||
| 112 | } |
||
| 113 | if(!empty($layout_def['parent_module'])) { |
||
| 114 | if (isset($layout_def['fields'][strtoupper($layout_def['parent_module'])])) { |
||
| 115 | $parent.="&parent_module=".$layout_def['fields'][strtoupper($layout_def['parent_module'])]; |
||
| 116 | } |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | $action = 'DetailView'; |
||
| 121 | $value = $layout_def['fields'][$key]; |
||
| 122 | global $current_user; |
||
| 123 | if( !empty($record) && |
||
| 124 | ($layout_def['DetailView'] && !$layout_def['owner_module'] |
||
| 125 | || $layout_def['DetailView'] && !ACLController::moduleSupportsACL($layout_def['owner_module']) |
||
| 126 | || ACLController::checkAccess($layout_def['owner_module'], 'view', $layout_def['owner_id'] == $current_user->id))) |
||
| 127 | { |
||
| 128 | $link = ajaxLink("index.php?module=$module&action=$action&record={$record}{$parent}"); |
||
| 129 | if ($module == 'EAPM') |
||
| 130 | { |
||
| 131 | $link = "index.php?module=$module&action=$action&record={$record}{$parent}"; |
||
| 132 | } |
||
| 133 | return '<a href="' . $link . '" >'."$value</a>"; |
||
| 134 | |||
| 135 | }else{ |
||
| 136 | return $value; |
||
| 137 | } |
||
| 138 | |||
| 139 | } |
||
| 140 | } |
||
| 142 | ?> |