| Conditions | 20 |
| Paths | 1248 |
| Total Lines | 96 |
| Code Lines | 56 |
| Lines | 0 |
| Ratio | 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 |
||
| 51 | function SubpanelQuickEdit($module, $view='QuickEdit', $proccessOverride = false){ |
||
| 52 | //treat quickedit and quickcreate views as the same |
||
| 53 | if($view == 'QuickEdit') {$view = 'QuickCreate';} |
||
| 54 | |||
| 55 | // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php |
||
| 56 | $base = 'modules/' . $module . '/metadata/'; |
||
| 57 | $source = 'custom/' . $base . strtolower($view) . 'defs.php'; |
||
| 58 | if (!file_exists( $source)) |
||
| 59 | { |
||
| 60 | $source = $base . strtolower($view) . 'defs.php'; |
||
| 61 | if (!file_exists($source)) |
||
| 62 | { |
||
| 63 | //if our view does not exist default to EditView |
||
| 64 | $view = 'EditView'; |
||
| 65 | $source = 'custom/' . $base . 'editviewdefs.php'; |
||
| 66 | if (!file_exists($source)) |
||
| 67 | { |
||
| 68 | $source = $base . 'editviewdefs.php'; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | |||
| 74 | $this->ev = new EditView(); |
||
| 75 | $this->ev->view = $view; |
||
| 76 | $this->ev->ss = new Sugar_Smarty(); |
||
| 77 | $_REQUEST['return_action'] = 'SubPanelViewer'; |
||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | //retrieve bean if id or record is passed in |
||
| 82 | if (isset($_REQUEST['record']) || isset($_REQUEST['id'])){ |
||
| 83 | global $beanList; |
||
| 84 | $bean = $beanList[$module]; |
||
| 85 | $this->ev->focus = new $bean(); |
||
| 86 | |||
| 87 | if (isset($_REQUEST['record']) && empty($_REQUEST['id'])){ |
||
| 88 | $_REQUEST['id'] = $_REQUEST['record']; |
||
| 89 | } |
||
| 90 | $this->ev->focus->retrieve($_REQUEST['record']); |
||
| 91 | //call setup with focus passed in |
||
| 92 | $this->ev->setup($module, $this->ev->focus, $source); |
||
| 93 | }else{ |
||
| 94 | //no id, call setup on new bean |
||
| 95 | $this->ev->setup($module, null, $source); |
||
| 96 | } |
||
| 97 | |||
| 98 | $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl'; |
||
| 99 | $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl'; |
||
| 100 | $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM'); |
||
| 101 | $this->ev->defs['templateMeta']['form']['hideAudit'] = true; |
||
| 102 | |||
| 103 | |||
| 104 | $viewEditSource = 'modules/'.$module.'/views/view.edit.php'; |
||
| 105 | if (file_exists('custom/'. $viewEditSource)) { |
||
| 106 | $viewEditSource = 'custom/'. $viewEditSource; |
||
| 107 | } |
||
| 108 | |||
| 109 | if(file_exists($viewEditSource) && !$proccessOverride) { |
||
| 110 | include($viewEditSource); |
||
| 111 | $c = $module . 'ViewEdit'; |
||
| 112 | |||
| 113 | $customClass = 'Custom' . $c; |
||
| 114 | if(class_exists($customClass)) { |
||
| 115 | $c = $customClass; |
||
| 116 | } |
||
| 117 | |||
| 118 | if(class_exists($c)) { |
||
| 119 | $view = new $c; |
||
| 120 | if($view->useForSubpanel) { |
||
| 121 | $this->defaultProcess = false; |
||
| 122 | |||
| 123 | //Check if we should use the module's QuickCreate.tpl file. |
||
| 124 | if($view->useModuleQuickCreateTemplate && file_exists('modules/'.$module.'/tpls/QuickCreate.tpl')) { |
||
| 125 | $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/'.$module.'/tpls/QuickCreate.tpl'; |
||
| 126 | } |
||
| 127 | |||
| 128 | $view->ev = & $this->ev; |
||
| 129 | $view->ss = & $this->ev->ss; |
||
| 130 | $class = $GLOBALS['beanList'][$module]; |
||
| 131 | if(!empty($GLOBALS['beanFiles'][$class])){ |
||
| 132 | require_once($GLOBALS['beanFiles'][$class]); |
||
| 133 | $bean = new $class(); |
||
| 134 | $view->bean = $bean; |
||
| 135 | } |
||
| 136 | $this->ev->formName = 'form_Subpanel'.$this->ev->view .'_'.$module; |
||
| 137 | $view->showTitle = false; // Do not show title since this is for subpanel |
||
| 138 | $view->display(); |
||
| 139 | } |
||
| 140 | } |
||
| 141 | } //if |
||
| 142 | |||
| 143 | if($this->defaultProcess && !$proccessOverride) { |
||
| 144 | $this->process($module); |
||
| 145 | } |
||
| 146 | } |
||
| 147 | |||
| 156 |