We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 13 |
Paths | 74 |
Total Lines | 90 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | 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 |
||
34 | public function main($content, $conf) { |
||
35 | |||
36 | $this->init($conf); |
||
37 | |||
38 | if (!empty($this->cObj->data['conf'])) { |
||
39 | // Merge configuration with conf array of toolbox. |
||
40 | $this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf); |
||
41 | } |
||
42 | |||
43 | $this->addSearchInDocumentJS(); |
||
44 | |||
45 | // Load current document. |
||
46 | $this->loadDocument(); |
||
47 | |||
48 | if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext']) || empty($this->conf['solrcore'])) { |
||
|
|||
49 | |||
50 | // Quit without doing anything if required variables are not set. |
||
51 | return $content; |
||
52 | |||
53 | } else { |
||
54 | |||
55 | if (!empty($this->piVars['logicalPage'])) { |
||
56 | |||
57 | $this->piVars['page'] = $this->doc->getPhysicalPage($this->piVars['logicalPage']); |
||
58 | // The logical page parameter should not appear again |
||
59 | unset($this->piVars['logicalPage']); |
||
60 | |||
61 | } |
||
62 | |||
63 | // Set default values if not set. |
||
64 | // $this->piVars['page'] may be integer or string (physical structure @ID) |
||
65 | if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) { |
||
66 | |||
67 | $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); |
||
68 | |||
69 | } else { |
||
70 | |||
71 | $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure); |
||
72 | |||
73 | } |
||
74 | |||
75 | } |
||
76 | |||
77 | // Quit if no fulltext file is present |
||
78 | $fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']]; |
||
79 | |||
80 | if (empty($fullTextFile)) { |
||
81 | |||
82 | return $content; |
||
83 | |||
84 | } |
||
85 | |||
86 | // Load template file. |
||
87 | if (!empty($this->conf['toolTemplateFile'])) { |
||
88 | |||
89 | $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['toolTemplateFile']), '###TEMPLATE###'); |
||
90 | |||
91 | } else { |
||
92 | |||
93 | $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/toolbox/tools/searchindocument/template.tmpl'), '###TEMPLATE###'); |
||
94 | |||
95 | } |
||
96 | |||
97 | // Configure @action URL for form. |
||
98 | $linkConf = array( |
||
99 | 'parameter' => $GLOBALS['TSFE']->id, |
||
100 | 'forceAbsoluteUrl' => 1 |
||
101 | ); |
||
102 | |||
103 | $encryptedSolr = $this->getEncryptedCoreName(); |
||
104 | |||
105 | // Fill markers. |
||
106 | $markerArray = array( |
||
107 | '###ACTION_URL###' => $this->cObj->typoLink_URL($linkConf), |
||
108 | '###LABEL_QUERY###' => $this->pi_getLL('label.query'), |
||
109 | '###LABEL_DELETE_SEARCH###' => $this->pi_getLL('label.delete_search'), |
||
110 | '###LABEL_LOADING###' => $this->pi_getLL('label.loading'), |
||
111 | '###LABEL_SUBMIT###' => $this->pi_getLL('label.submit'), |
||
112 | '###LABEL_SEARCH_IN_DOCUMENT###' => $this->pi_getLL('label.searchInDocument'), |
||
113 | '###LABEL_NEXT###' => $this->pi_getLL('label.next'), |
||
114 | '###LABEL_PREVIOUS###' => $this->pi_getLL('label.previous'), |
||
115 | '###LABEL_PAGE###' => $this->pi_getLL('label.logicalPage'), |
||
116 | '###CURRENT_DOCUMENT###' => $this->doc->uid, |
||
117 | '###SOLR_ENCRYPTED###' => isset($encryptedSolr['encrypted']) ? $encryptedSolr['encrypted'] : '', |
||
118 | '###SOLR_HASH###' => isset($encryptedSolr['hash']) ? $encryptedSolr['hash'] : '', |
||
119 | ); |
||
120 | |||
121 | $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); |
||
122 | |||
123 | return $this->pi_wrapInBaseClass($content); |
||
124 | } |
||
155 |