Conditions | 14 |
Paths | 240 |
Total Lines | 86 |
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 |
||
120 | protected function setPagination($iCrtPgNo, $inRecPrPg, $iAllRec, $bKpFlPg = true) |
||
121 | { |
||
122 | $sReturn = null; |
||
123 | $iRecPrPg = min($inRecPrPg, $iAllRec); |
||
124 | $iStartingPageRecord = $this->setStartingPageRecord($iCrtPgNo, $iRecPrPg, $iAllRec, $bKpFlPg); |
||
125 | $sReturn .= '<span style="float:left;font-size:smaller;margin-top:1px; margin-right:1px;">' |
||
126 | . $this->setStringIntoTag($iAllRec, 'b') |
||
127 | . $this->lclMsgCmn('i18n_RecordsAvailableNowDisplaying') |
||
128 | . $this->setStringIntoTag(($iStartingPageRecord + 1), 'b') |
||
129 | . ' - ' . $this->setStringIntoTag(min($iAllRec, ($iStartingPageRecord + $iRecPrPg)), 'b') |
||
130 | . ' </span>'; |
||
131 | switch ($iCrtPgNo) { |
||
132 | case 'first': |
||
133 | $iCrtPgNo = ceil(($iStartingPageRecord + 1 ) / $iRecPrPg); |
||
134 | break; |
||
135 | case 'last': |
||
136 | $iCrtPgNo = ceil($iAllRec / $iRecPrPg); |
||
137 | break; |
||
138 | } |
||
139 | $sReturn .= '<span style="float:right;font-size:smaller;margin-top:1px; margin-right:1px;">'; |
||
140 | $iNumberOfPages = ceil($iAllRec / $iRecPrPg); |
||
141 | $sAdditionalArguments = ''; |
||
142 | if (isset($_GET)) { |
||
143 | if ($_GET != ['page' => $_GET['page']]) { |
||
144 | $sAdditionalArguments = '&' |
||
145 | . $this->setArrayToStringForUrl('&', $_GET, ['page', 'action', 'server_action']); |
||
146 | } |
||
147 | if (!is_null($this->tCmnSuperGlobals->get('page'))) { |
||
148 | $iCrtPgNo = $this->tCmnSuperGlobals->get('page'); |
||
149 | } |
||
150 | } |
||
151 | if ($iCrtPgNo != 1) { |
||
152 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Previous'), 'a', [ |
||
153 | 'href' => ('?page=' . ($iCrtPgNo - 1 ) . $sAdditionalArguments ), |
||
154 | 'class' => 'pagination' |
||
155 | ]); |
||
156 | } else { |
||
157 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Previous'), 'span', [ |
||
158 | 'class' => 'pagination_inactive' |
||
159 | ]); |
||
160 | } |
||
161 | $pages2display = []; |
||
162 | for ($counter = 1; $counter <= $iNumberOfPages; $counter++) { |
||
163 | $pages2display[$counter] = $counter; |
||
164 | } |
||
165 | $sReturn .= '<span class="pagination"><form method="get" action="' |
||
166 | . $this->tCmnSuperGlobals->getScriptName() . '">'; |
||
167 | $sReturn .= $this->setArrayToSelect($pages2display, $this->tCmnSuperGlobals->get('page'), 'page', [ |
||
168 | 'size' => 1, |
||
169 | 'autosubmit', |
||
170 | 'id_no' => mt_rand() |
||
171 | ]); |
||
172 | if (isset($_GET)) { |
||
173 | foreach ($_GET as $key => $value) { |
||
174 | if ($key != 'page') { |
||
175 | if (is_array($value)) { |
||
176 | foreach ($value as $value2) { |
||
177 | $sReturn .= $this->setStringIntoShortTag('input', [ |
||
178 | 'type' => 'hidden', |
||
179 | 'name' => $key . '[]', |
||
180 | 'value' => $value2, |
||
181 | ]); |
||
182 | } |
||
183 | } else { |
||
184 | $sReturn .= $this->setStringIntoShortTag('input', [ |
||
185 | 'type' => 'hidden', |
||
186 | 'name' => $key, |
||
187 | 'value' => $value, |
||
188 | ]); |
||
189 | } |
||
190 | } |
||
191 | } |
||
192 | } |
||
193 | $sReturn .= '</form></span>'; |
||
194 | if ($iCrtPgNo != $iNumberOfPages) { |
||
195 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Next'), 'a', [ |
||
196 | 'href' => ('?page=' . ($iCrtPgNo + 1 ) . $sAdditionalArguments ), |
||
197 | 'class' => 'pagination', |
||
198 | ]); |
||
199 | } else { |
||
200 | $sReturn .= $this->setStringIntoTag($this->lclMsgCmn('i18n_Next'), 'span', [ |
||
201 | 'class' => 'pagination_inactive', |
||
202 | ]); |
||
203 | } |
||
204 | $sReturn .= '</span>'; |
||
205 | return $sReturn; |
||
206 | } |
||
239 |