Commit f87e7748 authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Markus Klein
Browse files

[CLEANUP] Replace count with empty in EXT:backend

Replace occurences of count() with matching empty() pendants.

Resolves: #67774
Releases: master
Change-Id: Ie75551a9410affe8840b521e15a0daf68655ba2a
Reviewed-on: http://review.typo3.org/40683


Reviewed-by: Stephan Großberndt's avatarStephan Großberndt <stephan@grossberndt.de>
Reviewed-by: default avatarMarkus Sommer <markussom@posteo.de>
Tested-by: default avatarMarkus Sommer <markussom@posteo.de>
Reviewed-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
parent 1912954e
......@@ -372,7 +372,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
$backendUser = $this->getBackendUser();
// Groups from TSConfig
$bookmarkGroups = $backendUser->getTSConfigProp('options.bookmarkGroups');
if (is_array($bookmarkGroups) && count($bookmarkGroups)) {
if (is_array($bookmarkGroups) && !empty($bookmarkGroups)) {
foreach ($bookmarkGroups as $groupId => $label) {
if (!empty($label)) {
$this->shortcutGroups[$groupId] = (string)$label;
......@@ -382,7 +382,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
}
}
// Generate global groups, all global groups have negative IDs.
if (count($this->shortcutGroups)) {
if (!empty($this->shortcutGroups)) {
$groups = $this->shortcutGroups;
foreach ($groups as $groupId => $groupLabel) {
$this->shortcutGroups[$groupId * -1] = $groupLabel;
......@@ -518,7 +518,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
$pageId = $shortcut['recordid'] ? $shortcut['recordid'] : $this->getLinkedPageId($url);
if (MathUtility::canBeInterpretedAsInteger($pageId)) {
$page = BackendUtility::getRecord('pages', $pageId);
if (count($page)) {
if (!empty($page)) {
// Set the name to the title of the page
if ($shortcut['type'] == 'other') {
$shortcutName = $page['title'];
......
......@@ -129,7 +129,7 @@ class BackendLayoutWizardController {
for ($j = 1; $j <= $colCount; $j++) {
$cellData = array();
if (!$spannedMatrix[$i][$j]) {
if (is_array($columns) && count($columns)) {
if (is_array($columns) && !empty($columns)) {
$column = array_shift($columns);
if (isset($column['colspan'])) {
$cellData['colspan'] = (int)$column['colspan'];
......
......@@ -619,7 +619,7 @@ class ElementInformationController {
// Compile information for title tag:
$infoData = array();
$infoDataHeader = '';
if (count($rows)) {
if (!empty($rows)) {
$infoDataHeader = '
<tr>
<th class="col-icon"></th>
......@@ -690,7 +690,7 @@ class ElementInformationController {
}
}
$referenceLine = '';
if (count($infoData)) {
if (!empty($infoData)) {
$referenceLine = '
<div class="table-fit">
<table class="table table-striped table-hover">
......@@ -720,7 +720,7 @@ class ElementInformationController {
// Compile information for title tag:
$infoData = array();
$infoDataHeader = '';
if (count($rows)) {
if (!empty($rows)) {
$infoDataHeader = '
<tr>
<th class="col-icon"></th>
......
......@@ -385,7 +385,7 @@ class NewContentElementController {
}
}
}
if (count($groupItems)) {
if (!empty($groupItems)) {
$wizardItems[$groupKey] = $this->wizard_getGroupHeader($groupKey, $wizardGroup);
$wizardItems = array_merge($wizardItems, $groupItems);
}
......@@ -496,7 +496,7 @@ class NewContentElementController {
if (!isset($keepItems[$fN])) {
$keepItems[$fN] = GeneralUtility::trimExplode(',', $TCEFORM_TSconfig[$fN]['keepItems'], TRUE);
}
$isNotInKeepItems = count($keepItems[$fN]) && !in_array($fV, $keepItems[$fN]);
$isNotInKeepItems = !empty($keepItems[$fN]) && !in_array($fV, $keepItems[$fN]);
if ($authModeDeny || $fN === 'CType' && in_array($fV, $removeItems[$fN]) || $isNotInKeepItems) {
// Remove element all together:
unset($wizardItems[$key]);
......
......@@ -570,17 +570,17 @@ class EditDocumentController {
$tce->process_datamap();
$tce->process_cmdmap();
// If pages are being edited, we set an instruction about updating the page tree after this operation.
if ($tce->pagetreeNeedsRefresh && (isset($this->data['pages']) || $beUser->workspace != 0 && count($this->data))) {
if ($tce->pagetreeNeedsRefresh && (isset($this->data['pages']) || $beUser->workspace != 0 && !empty($this->data))) {
BackendUtility::setUpdateSignal('updatePageTree');
}
// If there was saved any new items, load them:
if (count($tce->substNEWwithIDs_table)) {
if (!empty($tce->substNEWwithIDs_table)) {
// save the expanded/collapsed states for new inline records, if any
FormEngineUtility::updateInlineView($this->uc, $tce);
$newEditConf = array();
foreach ($this->editconf as $tableName => $tableCmds) {
$keys = array_keys($tce->substNEWwithIDs_table, $tableName);
if (count($keys) > 0) {
if (!empty($keys)) {
foreach ($keys as $key) {
$editId = $tce->substNEWwithIDs[$key];
// Check if the $editId isn't a child record of an IRRE action
......@@ -601,7 +601,7 @@ class EditDocumentController {
}
}
// Resetting editconf if newEditConf has values:
if (count($newEditConf)) {
if (!empty($newEditConf)) {
$this->editconf = $newEditConf;
}
// Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
......@@ -612,7 +612,7 @@ class EditDocumentController {
$this->compileStoreDat();
}
// See if any records was auto-created as new versions?
if (count($tce->autoVersionIdMap)) {
if (!empty($tce->autoVersionIdMap)) {
$this->fixWSversioningInEditConf($tce->autoVersionIdMap);
}
// If a document is saved and a new one is created right after.
......@@ -1608,7 +1608,7 @@ class EditDocumentController {
if ($retUrl === '') {
return;
}
if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) {
if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && !empty($this->docHandler)) {
if (isset($this->docHandler[$currentDocFromHandlerMD5])) {
$setupArr = $this->docHandler[$currentDocFromHandlerMD5];
} else {
......
......@@ -174,7 +174,7 @@ class FileController {
$this->init();
$this->main();
$errors = $this->fileProcessor->getErrorMessages();
if (count($errors)) {
if (!empty($errors)) {
$ajaxObj->setError(implode(',', $errors));
} else {
$flatResult = array();
......
......@@ -511,7 +511,7 @@ class NewRecordController {
* @return int -1 for lower, 0 for equal, 1 for greater
*/
public function sortNewRecordsByConfig($a, $b) {
if (count($this->newRecordSortList)) {
if (!empty($this->newRecordSortList)) {
if (in_array($a, $this->newRecordSortList) && in_array($b, $this->newRecordSortList)) {
// Both are in the list, return relative to position in array
$sub = array_search($a, $this->newRecordSortList) - array_search($b, $this->newRecordSortList);
......@@ -612,13 +612,11 @@ class NewRecordController {
$allowedNewTables = $allowedNewTables ?: $this->allowedNewTables;
$deniedNewTables = $deniedNewTables ?: $this->deniedNewTables;
// No deny/allow tables are set:
if (!count($allowedNewTables) && !count($deniedNewTables)) {
if (empty($allowedNewTables) && empty($deniedNewTables)) {
return TRUE;
} elseif (!in_array($table, $deniedNewTables) && (!count($allowedNewTables) || in_array($table, $allowedNewTables))) {
return TRUE;
} else {
return FALSE;
}
return !in_array($table, $deniedNewTables) && (empty($allowedNewTables) || in_array($table, $allowedNewTables));
}
/**
......
......@@ -608,7 +608,7 @@ class PageLayoutController {
$languageMenu = count($this->MOD_MENU['language']) > 1 ? $lang->sL('LLL:EXT:lang/locallang_general.xlf:LGL.language', TRUE) . BackendUtility::getFuncMenu($this->id, 'SET[language]', $this->current_sys_language, $this->MOD_MENU['language'], '', '') : '';
// Find backend layout / coumns
$backendLayout = GeneralUtility::callUserFunction(BackendLayoutView::class . '->getSelectedBackendLayout', $this->id, $this);
if (count($backendLayout['__colPosList'])) {
if (!empty($backendLayout['__colPosList'])) {
$this->colPosList = implode(',', $backendLayout['__colPosList']);
}
// Removing duplicates, if any
......
......@@ -104,7 +104,7 @@ class BackendModuleRepository implements \TYPO3\CMS\Core\SingletonInterface {
return $entry;
}
$children = $entry->getChildren();
if (count($children) > 0) {
if (!empty($children)) {
$childRecord = $this->findByModuleNameInGivenEntries($name, $children);
if ($childRecord !== FALSE) {
return $childRecord;
......
......@@ -63,7 +63,7 @@ class FlexFormLanguageContainer extends AbstractContainer {
$flexFormRowData['meta']['currentLangId'][] = $langInfo['ISOcode'];
}
}
if (!is_array($flexFormRowData['meta']['currentLangId']) || !count($flexFormRowData['meta']['currentLangId'])) {
if (!is_array($flexFormRowData['meta']['currentLangId']) || empty($flexFormRowData['meta']['currentLangId'])) {
$flexFormRowData['meta']['currentLangId'] = array('DEF');
}
$flexFormRowData['meta']['currentLangId'] = array_unique($flexFormRowData['meta']['currentLangId']);
......
......@@ -276,7 +276,7 @@ class InlineControlContainer extends AbstractContainer {
*/
protected function getUniqueIds($records, $conf = array(), $splitValue = FALSE) {
$uniqueIds = array();
if (isset($conf['foreign_unique']) && $conf['foreign_unique'] && count($records)) {
if (isset($conf['foreign_unique']) && $conf['foreign_unique'] && !empty($records)) {
foreach ($records as $rec) {
// Skip virtual records (e.g. shown in localization mode):
if (!isset($rec['__virtual']) || !$rec['__virtual']) {
......
......@@ -533,7 +533,7 @@ class SingleFieldContainer extends AbstractContainer {
protected function arrayCompareComplex($subjectArray, $searchArray, $type = '') {
$localMatches = 0;
$localEntries = 0;
if (is_array($searchArray) && count($searchArray)) {
if (is_array($searchArray) && !empty($searchArray)) {
// If no type was passed, try to determine
if (!$type) {
reset($searchArray);
......@@ -587,7 +587,7 @@ class SingleFieldContainer extends AbstractContainer {
* @return bool Returns TRUE, if the object is an associative array
*/
protected function isAssociativeArray($object) {
return is_array($object) && count($object) && array_keys($object) !== range(0, sizeof($object) - 1) ? TRUE : FALSE;
return is_array($object) && !empty($object) && array_keys($object) !== range(0, sizeof($object) - 1) ? TRUE : FALSE;
}
/**
......
......@@ -405,7 +405,7 @@ class DataPreprocessor {
if ($GLOBALS['TCA'][$fieldConfig['config']['foreign_table']]) {
// Getting the data
$dataIds = $this->getDataIdList($elements, $fieldConfig, $row, $table);
if (!count($dataIds)) {
if (empty($dataIds)) {
$dataIds = array(0);
}
$dataAcc[] = $dataIds[0];
......
......@@ -622,7 +622,7 @@ abstract class AbstractFormElement extends AbstractNode {
}
}
$clipElements = $this->getClipboardElements($allowed, $mode);
if (count($clipElements)) {
if (!empty($clipElements)) {
$aOnClick = '';
foreach ($clipElements as $elValue) {
if ($mode == 'db') {
......
......@@ -97,7 +97,7 @@ class GroupElement extends AbstractFormElement {
// Fall through
case 'file':
// Creating string showing allowed types:
if (!count($allowed)) {
if (empty($allowed)) {
$allowed = array('*');
}
// Making the array of file items:
......
......@@ -124,7 +124,7 @@ class SelectCheckBoxElement extends AbstractFormElement {
$hasHelp = FALSE;
$help = '';
$helpArray = array();
if (is_array($p[3]) && count($p[3]) > 0 || !empty($p[3])) {
if (!empty($p[3])) {
$hasHelp = TRUE;
if (is_array($p[3])) {
$helpArray = $p[3];
......@@ -160,7 +160,7 @@ class SelectCheckBoxElement extends AbstractFormElement {
}
}
// Remaining values (invalid):
if (count($itemArray) && !$parameterArray['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
if (!empty($itemArray) && !$parameterArray['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
$currentGroup++;
foreach ($itemArray as $theNoMatchValue => $temp) {
// Build item array
......
......@@ -120,7 +120,7 @@ class SelectSingleBoxElement extends AbstractFormElement {
$c++;
}
// Remaining values:
if (count($itemArray) && !$parameterArray['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
if (!empty($itemArray) && !$parameterArray['fieldTSConfig']['disableNoMatchingValueElement'] && !$config['disableNoMatchingValueElement']) {
foreach ($itemArray as $theNoMatchValue => $temp) {
// Compile <option> tag:
array_unshift($opt, '<option value="' . htmlspecialchars($theNoMatchValue) . '" selected="selected">'
......
......@@ -255,7 +255,7 @@ class SelectSingleElement extends AbstractFormElement {
</div>';
// Create icon table:
if (count($selectIcons) && !$config['noIconsBelowSelect']) {
if (!empty($selectIcons) && !$config['noIconsBelowSelect']) {
$selectIconColumns = (int)$config['selicon_cols'];
if (!$selectIconColumns) {
$selectIconColumns = count($selectIcons);
......@@ -264,7 +264,8 @@ class SelectSingleElement extends AbstractFormElement {
$selectIconRows = ceil(count($selectIcons) / $selectIconColumns);
$selectIcons = array_pad($selectIcons, $selectIconRows * $selectIconColumns, '');
$out .= '<div class="table-fit table-fit-inline-block"><table class="table table-condensed table-white table-center"><tbody><tr>';
for ($selectIconCount = 0; $selectIconCount < count($selectIcons); $selectIconCount++) {
$selectIconTotalCount = count($selectIcons);
for ($selectIconCount = 0; $selectIconCount < $selectIconTotalCount; $selectIconCount++) {
if ($selectIconCount % $selectIconColumns === 0 && $selectIconCount !== 0) {
$out .= '</tr><tr>';
}
......
......@@ -87,7 +87,7 @@ class SelectTreeElement extends AbstractFormElement {
if (!empty($PA['itemFormElValue'])) {
$valueArray = explode(',', $PA['itemFormElValue']);
}
if (count($valueArray)) {
if (!empty($valueArray)) {
foreach ($valueArray as $selectedValue) {
$temp = explode('|', $selectedValue);
$selectedNodes[] = $temp[0];
......
......@@ -87,13 +87,13 @@ class ElementConditionMatcher {
}
}
}
if (count($conditionEvaluations['OR']) > 0 && in_array(TRUE, $conditionEvaluations['OR'], TRUE)) {
if (!empty($conditionEvaluations['OR']) && in_array(TRUE, $conditionEvaluations['OR'], TRUE)) {
// There are OR conditions and at least one of them is TRUE
$result = TRUE;
} elseif (count($conditionEvaluations['AND']) > 0 && !in_array(FALSE, $conditionEvaluations['AND'], TRUE)) {
} elseif (!empty($conditionEvaluations['AND']) && !in_array(FALSE, $conditionEvaluations['AND'], TRUE)) {
// There are AND conditions and none of them is FALSE
$result = TRUE;
} elseif (count($conditionEvaluations['OR']) > 0 || count($conditionEvaluations['AND']) > 0) {
} elseif (!empty($conditionEvaluations['OR']) || !empty($conditionEvaluations['AND'])) {
// There are some conditions. But no OR was TRUE and at least one AND was FALSE
$result = FALSE;
} else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment