We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 16 |
| Paths | 57 |
| Total Lines | 74 |
| Code Lines | 49 |
| 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 |
||
| 147 | public function makeMenuArray($content, $conf) { |
||
|
1 ignored issue
–
show
|
|||
| 148 | $this->init($conf); |
||
| 149 | // Load current document. |
||
| 150 | $this->loadDocument(); |
||
| 151 | if ($this->doc === NULL) { |
||
| 152 | // Quit without doing anything if required variables are not set. |
||
| 153 | return []; |
||
| 154 | } else { |
||
| 155 | if (!empty($this->piVars['logicalPage'])) { |
||
| 156 | $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
||
| 157 | // The logical page parameter should not appear again |
||
| 158 | unset($this->piVars['logicalPage']); |
||
| 159 | } |
||
| 160 | // Set default values for page if not set. |
||
| 161 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
| 162 | if ((int) $this->piVars['page'] > 0 |
||
| 163 | || empty($this->piVars['page'])) { |
||
| 164 | $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
||
| 165 | } else { |
||
| 166 | $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
||
| 167 | } |
||
| 168 | $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); |
||
| 169 | } |
||
| 170 | $menuArray = []; |
||
| 171 | // Does the document have physical elements or is it an external file? |
||
| 172 | if ($this->doc->physicalStructure |
||
| 173 | || !\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->doc->uid)) { |
||
| 174 | // Get all logical units the current page or track is a part of. |
||
| 175 | if (!empty($this->piVars['page']) |
||
| 176 | && $this->doc->physicalStructure) { |
||
| 177 | $this->activeEntries = array_merge((array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[0]], (array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[$this->piVars['page']]]); |
||
| 178 | if (!empty($this->piVars['double']) |
||
| 179 | && $this->piVars['page'] < $this->doc->numPages) { |
||
| 180 | $this->activeEntries = array_merge($this->activeEntries, (array) $this->doc->smLinks['p2l'][$this->doc->physicalStructure[$this->piVars['page'] + 1]]); |
||
| 181 | } |
||
| 182 | } |
||
| 183 | // Go through table of contents and create all menu entries. |
||
| 184 | foreach ($this->doc->tableOfContents as $entry) { |
||
| 185 | $menuArray[] = $this->getMenuEntry($entry, TRUE); |
||
| 186 | } |
||
| 187 | } else { |
||
| 188 | // Go through table of contents and create top-level menu entries. |
||
| 189 | foreach ($this->doc->tableOfContents as $entry) { |
||
| 190 | $menuArray[] = $this->getMenuEntry($entry, FALSE); |
||
| 191 | } |
||
| 192 | // Get all child documents from database. |
||
| 193 | $whereClause = 'tx_dlf_documents.partof='.intval($this->doc->uid).' AND tx_dlf_documents.structure=tx_dlf_structures.uid AND tx_dlf_structures.pid='.$this->doc->pid.Helper::whereClause('tx_dlf_documents').Helper::whereClause('tx_dlf_structures'); |
||
| 194 | if ($this->conf['excludeOther']) { |
||
| 195 | $whereClause .= ' AND tx_dlf_documents.pid='.intval($this->conf['pages']); |
||
| 196 | } |
||
| 197 | // Build table of contents from database. |
||
| 198 | $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
||
| 199 | 'tx_dlf_documents.uid AS uid,tx_dlf_documents.title AS title,tx_dlf_documents.volume AS volume,tx_dlf_structures.index_name AS type', |
||
| 200 | 'tx_dlf_documents,tx_dlf_structures', |
||
| 201 | $whereClause, |
||
| 202 | '', |
||
| 203 | 'tx_dlf_documents.volume_sorting' |
||
| 204 | ); |
||
| 205 | if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { |
||
| 206 | $menuArray[0]['ITEM_STATE'] = 'CURIFSUB'; |
||
| 207 | $menuArray[0]['_SUB_MENU'] = []; |
||
| 208 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
||
| 209 | $entry = [ |
||
| 210 | 'label' => $resArray['title'], |
||
| 211 | 'type' => $resArray['type'], |
||
| 212 | 'volume' => $resArray['volume'], |
||
| 213 | 'pagination' => '', |
||
| 214 | 'targetUid' => $resArray['uid'] |
||
| 215 | ]; |
||
| 216 | $menuArray[0]['_SUB_MENU'][] = $this->getMenuEntry($entry, FALSE); |
||
| 217 | } |
||
| 218 | } |
||
| 219 | } |
||
| 220 | return $menuArray; |
||
| 221 | } |
||
| 223 |