| Conditions | 12 |
| Paths | 85 |
| Total Lines | 121 |
| Code Lines | 81 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 106 | private function showLogAction(int $setId, string $quiPath): string |
||
| 107 | { |
||
| 108 | $this->view->setTemplate('ShowLog'); |
||
| 109 | if (empty($this->pageId)) { |
||
| 110 | $this->isErrorDetected = true; |
||
| 111 | MessageUtility::addErrorMessage($this->getLanguageService()->sL('LLL:EXT:crawler/Resources/Private/Language/locallang.xlf:labels.noPageSelected')); |
||
| 112 | } else { |
||
| 113 | $this->findCrawler()->setAccessMode('gui'); |
||
|
|
|||
| 114 | $this->findCrawler()->setID = GeneralUtility::md5int(microtime()); |
||
| 115 | |||
| 116 | $csvExport = GeneralUtility::_POST('_csv'); |
||
| 117 | $this->CSVExport = isset($csvExport); |
||
| 118 | |||
| 119 | // Read URL: |
||
| 120 | if (GeneralUtility::_GP('qid_read')) { |
||
| 121 | $this->findCrawler()->readUrl((int) GeneralUtility::_GP('qid_read'), true); |
||
| 122 | } |
||
| 123 | |||
| 124 | // Look for set ID sent - if it is, we will display contents of that set: |
||
| 125 | $showSetId = (int) GeneralUtility::_GP('setID'); |
||
| 126 | |||
| 127 | $queueId = GeneralUtility::_GP('qid_details'); |
||
| 128 | $this->view->assign('queueId', $queueId); |
||
| 129 | $this->view->assign('setId', $showSetId); |
||
| 130 | // Show details: |
||
| 131 | if ($queueId) { |
||
| 132 | // Get entry record: |
||
| 133 | $q_entry = $this->queryBuilder |
||
| 134 | ->from('tx_crawler_queue') |
||
| 135 | ->select('*') |
||
| 136 | ->where( |
||
| 137 | $this->queryBuilder->expr()->eq('qid', $this->queryBuilder->createNamedParameter($queueId)) |
||
| 138 | ) |
||
| 139 | ->execute() |
||
| 140 | ->fetch(); |
||
| 141 | |||
| 142 | // Explode values |
||
| 143 | $q_entry['parameters'] = $this->jsonCompatibilityConverter->convert($q_entry['parameters']); |
||
| 144 | $q_entry['result_data'] = $this->jsonCompatibilityConverter->convert($q_entry['result_data']); |
||
| 145 | $resStatus = ResultHandler::getResStatus($q_entry['result_data']); |
||
| 146 | if (is_array($q_entry['result_data'])) { |
||
| 147 | $q_entry['result_data']['content'] = $this->jsonCompatibilityConverter->convert($q_entry['result_data']['content']); |
||
| 148 | if (! $this->infoModuleController->MOD_SETTINGS['log_resultLog']) { |
||
| 149 | unset($q_entry['result_data']['content']['log']); |
||
| 150 | } |
||
| 151 | } |
||
| 152 | |||
| 153 | $this->view->assign('queueStatus', $resStatus); |
||
| 154 | $this->view->assign('queueDetails', DebugUtility::viewArray($q_entry)); |
||
| 155 | } else { |
||
| 156 | // Show list |
||
| 157 | // Drawing tree: |
||
| 158 | $tree = GeneralUtility::makeInstance(PageTreeView::class); |
||
| 159 | $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); |
||
| 160 | $tree->init('AND ' . $perms_clause); |
||
| 161 | |||
| 162 | // Set root row: |
||
| 163 | $pageinfo = BackendUtility::readPageAccess( |
||
| 164 | $this->pageId, |
||
| 165 | $perms_clause |
||
| 166 | ); |
||
| 167 | $HTML = $this->getIconFactory()->getIconForRecord('pages', $pageinfo, Icon::SIZE_SMALL)->render(); |
||
| 168 | $tree->tree[] = [ |
||
| 169 | 'row' => $pageinfo, |
||
| 170 | 'HTML' => $HTML, |
||
| 171 | ]; |
||
| 172 | |||
| 173 | // Get branch beneath: |
||
| 174 | if ($this->infoModuleController->MOD_SETTINGS['depth']) { |
||
| 175 | $tree->getTree($this->pageId, $this->infoModuleController->MOD_SETTINGS['depth']); |
||
| 176 | } |
||
| 177 | |||
| 178 | // If Flush button is pressed, flush tables instead of selecting entries: |
||
| 179 | if (GeneralUtility::_POST('_flush')) { |
||
| 180 | $doFlush = true; |
||
| 181 | $doFullFlush = false; |
||
| 182 | } elseif (GeneralUtility::_POST('_flush_all')) { |
||
| 183 | $doFlush = true; |
||
| 184 | $doFullFlush = true; |
||
| 185 | } else { |
||
| 186 | $doFlush = false; |
||
| 187 | $doFullFlush = false; |
||
| 188 | } |
||
| 189 | $itemsPerPage = (int) $this->infoModuleController->MOD_SETTINGS['itemsPerPage']; |
||
| 190 | $queueFilter = new QueueFilter($this->infoModuleController->MOD_SETTINGS['log_display']); |
||
| 191 | // Traverse page tree: |
||
| 192 | $code = ''; |
||
| 193 | $count = 0; |
||
| 194 | foreach ($tree->tree as $data) { |
||
| 195 | // Get result: |
||
| 196 | $logEntriesOfPage = $this->crawlerController->getLogEntriesForPageId( |
||
| 197 | (int) $data['row']['uid'], |
||
| 198 | $queueFilter, |
||
| 199 | $doFlush, |
||
| 200 | $doFullFlush, |
||
| 201 | $itemsPerPage |
||
| 202 | ); |
||
| 203 | |||
| 204 | $code .= $this->drawLog_addRows( |
||
| 205 | $logEntriesOfPage, |
||
| 206 | $data['HTML'] . BackendUtility::getRecordTitle('pages', $data['row'], true) |
||
| 207 | ); |
||
| 208 | if (++$count === 1000) { |
||
| 209 | break; |
||
| 210 | } |
||
| 211 | } |
||
| 212 | $this->view->assign('code', $code); |
||
| 213 | } |
||
| 214 | |||
| 215 | if ($this->CSVExport) { |
||
| 216 | $this->outputCsvFile(); |
||
| 217 | } |
||
| 218 | } |
||
| 219 | $this->view->assign('showResultLog', (bool) $this->infoModuleController->MOD_SETTINGS['log_resultLog']); |
||
| 220 | $this->view->assign('showFeVars', (bool) $this->infoModuleController->MOD_SETTINGS['log_feVars']); |
||
| 221 | $this->view->assign('displayActions', 1); |
||
| 222 | $this->view->assign('displayLogFilterHtml', $this->getDisplayLogFilterHtml($setId)); |
||
| 223 | $this->view->assign('itemPerPageHtml', $this->getItemsPerPageDropDownHtml()); |
||
| 224 | $this->view->assign('showResultLogHtml', $this->getShowResultLogCheckBoxHtml($setId, $quiPath)); |
||
| 225 | $this->view->assign('showFeVarsHtml', $this->getShowFeVarsCheckBoxHtml($setId, $quiPath)); |
||
| 226 | return $this->view->render(); |
||
| 227 | } |
||
| 402 |