| Conditions | 19 |
| Paths | 381 |
| Total Lines | 112 |
| Code Lines | 70 |
| 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 |
||
| 155 | protected function renderContent(): void |
||
| 156 | { |
||
| 157 | $lang = $this->getLanguageService(); |
||
| 158 | |||
| 159 | if ($this->page_id) { |
||
| 160 | $assigns = []; |
||
| 161 | $backendUser = $this->getBackendUser(); |
||
| 162 | $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip'); |
||
| 163 | // Get record for element: |
||
| 164 | $elRow = BackendUtility::getRecordWSOL($this->table, $this->moveUid); |
||
| 165 | // Headerline: Icon, record title: |
||
| 166 | $assigns['table'] = $this->table; |
||
| 167 | $assigns['elRow'] = $elRow; |
||
| 168 | $assigns['recordTooltip'] = BackendUtility::getRecordToolTip($elRow, $this->table); |
||
| 169 | $assigns['recordTitle'] = BackendUtility::getRecordTitle($this->table, $elRow, true); |
||
| 170 | // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently): |
||
| 171 | $assigns['makeCopyChecked'] = $this->makeCopy ? ' checked="checked"' : ''; |
||
| 172 | $assigns['makeCopyUrl'] = GeneralUtility::linkThisScript(['makeCopy' => !$this->makeCopy]); |
||
| 173 | // IF the table is "pages": |
||
| 174 | if ((string)$this->table === 'pages') { |
||
| 175 | // Get page record (if accessible): |
||
| 176 | $pageInfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause); |
||
| 177 | if (is_array($pageInfo) && $backendUser->isInWebMount($pageInfo['pid'], $this->perms_clause)) { |
||
|
|
|||
| 178 | // Initialize the position map: |
||
| 179 | $posMap = GeneralUtility::makeInstance(PageMovingPagePositionMap::class); |
||
| 180 | $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move'; |
||
| 181 | $posMap->moveUid = $this->moveUid; |
||
| 182 | // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page). |
||
| 183 | if ($pageInfo['pid']) { |
||
| 184 | $pidPageInfo = BackendUtility::readPageAccess($pageInfo['pid'], $this->perms_clause); |
||
| 185 | if (is_array($pidPageInfo)) { |
||
| 186 | if ($backendUser->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) { |
||
| 187 | $assigns['pages']['goUpUrl'] = GeneralUtility::linkThisScript([ |
||
| 188 | 'uid' => (int)$pageInfo['pid'], |
||
| 189 | 'moveUid' => $this->moveUid |
||
| 190 | ]); |
||
| 191 | } else { |
||
| 192 | $assigns['pages']['pidPageInfo'] = $pidPageInfo; |
||
| 193 | } |
||
| 194 | $assigns['pages']['pidRecordTitle'] = BackendUtility::getRecordTitle('pages', $pidPageInfo, true); |
||
| 195 | } |
||
| 196 | } |
||
| 197 | // Create the position tree: |
||
| 198 | $assigns['pages']['positionTree'] = $posMap->positionTree($this->page_id, $pageInfo, $this->perms_clause, $this->R_URI); |
||
| 199 | } |
||
| 200 | } |
||
| 201 | // IF the table is "tt_content": |
||
| 202 | if ((string)$this->table === 'tt_content') { |
||
| 203 | // First, get the record: |
||
| 204 | $tt_content_rec = BackendUtility::getRecord('tt_content', $this->moveUid); |
||
| 205 | // ? |
||
| 206 | if (!$this->input_moveUid) { |
||
| 207 | $this->page_id = $tt_content_rec['pid']; |
||
| 208 | } |
||
| 209 | // Checking if the parent page is readable: |
||
| 210 | $pageInfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause); |
||
| 211 | if (is_array($pageInfo) && $backendUser->isInWebMount($pageInfo['pid'], $this->perms_clause)) { |
||
| 212 | // Initialize the position map: |
||
| 213 | $posMap = GeneralUtility::makeInstance(ContentMovingPagePositionMap::class); |
||
| 214 | $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move'; |
||
| 215 | $posMap->moveUid = $this->moveUid; |
||
| 216 | $posMap->cur_sys_language = $this->sys_language; |
||
| 217 | // Headerline for the parent page: Icon, record title: |
||
| 218 | $assigns['ttContent']['pageInfo'] = $pageInfo; |
||
| 219 | $assigns['ttContent']['recordTooltip'] = BackendUtility::getRecordToolTip($pageInfo, 'pages'); |
||
| 220 | $assigns['ttContent']['recordTitle'] = BackendUtility::getRecordTitle('pages', $pageInfo, true); |
||
| 221 | $colPosArray = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getColPosListItemsParsed', $this->page_id, $this); |
||
| 222 | $colPosIds = []; |
||
| 223 | foreach ($colPosArray as $colPos) { |
||
| 224 | $colPosIds[] = $colPos[1]; |
||
| 225 | } |
||
| 226 | // Removing duplicates, if any |
||
| 227 | $colPosList = implode(',', array_unique($colPosIds)); |
||
| 228 | // Adding parent page-header and the content element columns from position-map: |
||
| 229 | $assigns['ttContent']['contentElementColumns'] = $posMap->printContentElementColumns($this->page_id, $this->moveUid, $colPosList, 1, $this->R_URI); |
||
| 230 | // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page). |
||
| 231 | if ($pageInfo['pid']) { |
||
| 232 | $pidPageInfo = BackendUtility::readPageAccess($pageInfo['pid'], $this->perms_clause); |
||
| 233 | if (is_array($pidPageInfo)) { |
||
| 234 | if ($backendUser->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) { |
||
| 235 | $assigns['ttContent']['goUpUrl'] = GeneralUtility::linkThisScript([ |
||
| 236 | 'uid' => (int)$pageInfo['pid'], |
||
| 237 | 'moveUid' => $this->moveUid |
||
| 238 | ]); |
||
| 239 | } else { |
||
| 240 | $assigns['ttContent']['pidPageInfo'] = $pidPageInfo; |
||
| 241 | } |
||
| 242 | $assigns['ttContent']['pidRecordTitle'] = BackendUtility::getRecordTitle('pages', $pidPageInfo, true); |
||
| 243 | } |
||
| 244 | } |
||
| 245 | // Create the position tree (for pages): |
||
| 246 | $assigns['ttContent']['positionTree'] = $posMap->positionTree($this->page_id, $pageInfo, $this->perms_clause, $this->R_URI); |
||
| 247 | } |
||
| 248 | } |
||
| 249 | // Rendering of the output via fluid |
||
| 250 | $view = GeneralUtility::makeInstance(StandaloneView::class); |
||
| 251 | $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates')]); |
||
| 252 | $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials')]); |
||
| 253 | $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName( |
||
| 254 | 'EXT:backend/Resources/Private/Templates/ContentElement/MoveElement.html' |
||
| 255 | )); |
||
| 256 | $view->assignMultiple($assigns); |
||
| 257 | $this->content .= $view->render(); |
||
| 258 | } |
||
| 259 | |||
| 260 | // Setting up the buttons and markers for docheader |
||
| 261 | $this->getButtons(); |
||
| 262 | // Build the <body> for the module |
||
| 263 | $this->moduleTemplate->setTitle($lang->getLL('movingElement')); |
||
| 264 | $this->moduleTemplate->setContent($this->content); |
||
| 265 | |||
| 266 | $this->content = $this->moduleTemplate->renderContent(); |
||
| 267 | } |
||
| 314 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
integervalues, zero is a special case, in particular the following results might be unexpected: