Conditions | 8 |
Paths | 6 |
Total Lines | 118 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 5 | ||
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 |
||
42 | function main() |
||
43 | { |
||
44 | global $BE_USER, $LANG, $BACK_PATH; |
||
45 | |||
46 | // popup Object |
||
47 | $this->popup = GeneralUtility::makeInstance('FRUIT\\Popup\\Popup'); |
||
48 | |||
49 | // Draw the header. |
||
50 | $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); |
||
51 | $this->doc->backPath = $BACK_PATH; |
||
52 | $this->doc->form = '<form action="" method="post" name="wiz_form" style="margin: 5px;">'; |
||
53 | |||
54 | // JavaScript |
||
55 | $this->doc->JScode = ' |
||
56 | <script language="javascript" type="text/javascript"> |
||
57 | function setElementValue(elName,elValue) { |
||
58 | if (parent.opener && parent.opener.setFormValueFromBrowseWin) { |
||
59 | var checkbox = true; |
||
60 | if(elValue == "") checkbox = false; |
||
61 | |||
62 | var selector = \'[data-formengine-input-name="\'+elName+\'"]\'; |
||
63 | parent.opener.TYPO3.jQuery(selector).value = elValue; |
||
64 | parent.opener.TBE_EDITOR.fieldChanged("pages",' . $_GET['P']['uid'] . ',elName,"data[pages][' . $_GET['P']['uid'] . ']["+elName+"]"); |
||
65 | |||
66 | // setFormValueFromBrowseWin?? |
||
67 | parent.opener.focus(); |
||
68 | parent.close(); |
||
69 | } else { |
||
70 | alert("Error - reference to main window is not set properly!"); |
||
71 | parent.opener.focus(); |
||
72 | parent.close(); |
||
73 | } |
||
74 | return false; |
||
75 | } |
||
76 | |||
77 | function removePopup(){ |
||
78 | return setElementValue(\'' . $_GET['P']['field'] . '\',""); |
||
79 | } |
||
80 | |||
81 | function sendForm(){ |
||
82 | var value = ""; |
||
83 | |||
84 | value += document.forms["wiz_form"].elements["width"].value; |
||
85 | value += "x"; |
||
86 | value += document.forms["wiz_form"].elements["height"].value; |
||
87 | value += ":"; |
||
88 | |||
89 | value += "dependent="+document.forms["wiz_form"].elements["dependent"].value; |
||
90 | |||
91 | value += ","; |
||
92 | value += "location="+document.forms["wiz_form"].elements["location"].value; |
||
93 | |||
94 | value += ","; |
||
95 | value += "menubar="+document.forms["wiz_form"].elements["menubar"].value; |
||
96 | |||
97 | value += ","; |
||
98 | value += "resizable="+document.forms["wiz_form"].elements["resizable"].value; |
||
99 | |||
100 | value += ","; |
||
101 | value += "scrollbars="+document.forms["wiz_form"].elements["scrollbars"].value; |
||
102 | |||
103 | value += ","; |
||
104 | value += "status="+document.forms["wiz_form"].elements["status"].value; |
||
105 | |||
106 | value += ","; |
||
107 | value += "toolbar="+document.forms["wiz_form"].elements["toolbar"].value; |
||
108 | |||
109 | value += ","; |
||
110 | value += "left="+document.forms["wiz_form"].elements["left"].value; |
||
111 | |||
112 | value += ","; |
||
113 | value += "top="+document.forms["wiz_form"].elements["top"].value; |
||
114 | |||
115 | if(document.forms["wiz_form"].elements["once_per_session"] != undefined) { |
||
116 | value += ","; |
||
117 | value += "once_per_session="+document.forms["wiz_form"].elements["once_per_session"].value; |
||
118 | |||
119 | value += ","; |
||
120 | value += "once_per_link="+document.forms["wiz_form"].elements["once_per_link"].value; |
||
121 | |||
122 | value += ","; |
||
123 | value += "center="+document.forms["wiz_form"].elements["center"].value; |
||
124 | |||
125 | value += ","; |
||
126 | value += "maximize="+document.forms["wiz_form"].elements["maximize"].value; |
||
127 | |||
128 | value += ","; |
||
129 | value += "popunder="+document.forms["wiz_form"].elements["popunder"].value; |
||
130 | } |
||
131 | |||
132 | return setElementValue(\'' . $_GET['P']['field'] . '\',value); |
||
133 | } |
||
134 | </script>'; |
||
135 | |||
136 | |||
137 | $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause); |
||
138 | $access = is_array($this->pageinfo) ? 1 : 0; |
||
139 | if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id)) { |
||
140 | if ($BE_USER->user['admin'] && !$this->id) { |
||
141 | $this->pageinfo = [ |
||
142 | 'title' => '[root-level]', |
||
143 | 'uid' => 0, |
||
144 | 'pid' => 0 |
||
145 | ]; |
||
146 | } |
||
147 | |||
148 | $this->content .= $this->doc->startPage($this->getLabel('title')); |
||
149 | $this->content .= $this->doc->header($this->getLabel('title')); |
||
150 | $this->content .= $this->doc->spacer(5); |
||
151 | $this->content .= $this->doc->divider(5); |
||
152 | |||
153 | // CSS |
||
154 | $this->content .= '<style type="text/css"> table td { padding: 2px; width: 100px; } table td input, table td select { width: 90px; } </style>'; |
||
155 | |||
156 | // Render content: |
||
157 | $this->moduleContent(); |
||
158 | } |
||
159 | } |
||
160 | |||
237 | $SOBE->printContent(); |