Skip to content

Commit

Permalink
Replaced all usages of count() with empty() if appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Sep 27, 2012
1 parent 8afa353 commit 6357435
Show file tree
Hide file tree
Showing 50 changed files with 168 additions and 170 deletions.
44 changes: 22 additions & 22 deletions system/drivers/DC_ProductData.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function showAll()
}

// Custom filter
if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']) && count($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']))
if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']) && !empty($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']))
{
foreach ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter'] as $filter)
{
Expand Down Expand Up @@ -302,15 +302,15 @@ protected function copyChilds($table, $insertID, $id, $parentId)
// Duplicate the child records
foreach ($copy as $k=>$v)
{
if (count($v))
if (!empty($v))
{
foreach ($v as $kk=>$vv)
{
$objInsertStmt = $this->Database->prepare("INSERT INTO " . $k . " %s")
->set($vv)
->execute();

if ($objInsertStmt->affectedRows && (count($cctable[$k]) || $GLOBALS['TL_DCA'][$k]['list']['sorting']['mode'] == 5) && $kk != $parentId)
if ($objInsertStmt->affectedRows && (!empty($cctable[$k]) || $GLOBALS['TL_DCA'][$k]['list']['sorting']['mode'] == 5) && $kk != $parentId)
{
$this->copyChilds($k, $objInsertStmt->insertId, $kk, $parentId);
}
Expand Down Expand Up @@ -546,7 +546,7 @@ public function edit($intID=false, $ajaxId=false)
$boxes = trimsplit(';', $this->strPalette);
$legends = array();

if (count($boxes))
if (!empty($boxes))
{
foreach ($boxes as $k=>$v)
{
Expand Down Expand Up @@ -978,7 +978,7 @@ public function editAll($intId=false, $ajaxId=false)
// Add fields
$fields = $session['CURRENT'][$this->strTable];

if (is_array($fields) && count($fields) && $this->Input->get('fields'))
if (is_array($fields) && !empty($fields) && $this->Input->get('fields'))
{
$class = 'tl_tbox block';
$this->checkForTinyMce();
Expand Down Expand Up @@ -1185,7 +1185,7 @@ public function editAll($intId=false, $ajaxId=false)
}
}

$blnIsError = ($_POST && !count($_POST['all_fields']));
$blnIsError = ($_POST && empty($_POST['all_fields']));

// Return the select menu
$return .= '
Expand Down Expand Up @@ -1258,7 +1258,7 @@ public function overrideAll()
// Add fields
$fields = $session['CURRENT'][$this->strTable];

if (is_array($fields) && count($fields) && $this->Input->get('fields'))
if (is_array($fields) && !empty($fields) && $this->Input->get('fields'))
{
$class = 'tl_tbox block';
$formFields = array();
Expand Down Expand Up @@ -1438,7 +1438,7 @@ public function overrideAll()
}
}

$blnIsError = ($_POST && !count($_POST['all_fields']));
$blnIsError = ($_POST && empty($_POST['all_fields']));

// Return the select menu
$return .= '
Expand Down Expand Up @@ -1556,7 +1556,7 @@ protected function treeView()
$node = $this->strTable.'_tree';

// Expand tree
if (!is_array($session[$node]) || count($session[$node]) < 1 || current($session[$node]) != 1)
if (!is_array($session[$node]) || empty($session[$node]) || current($session[$node]) != 1)
{
$session[$node] = array();

Expand Down Expand Up @@ -1584,7 +1584,7 @@ protected function treeView()
$node = $this->strTable.'_'.$gtable.'_tree';

// Expand tree
if (!is_array($session[$node]) || count($session[$node]) < 1 || current($session[$node]) != 1)
if (!is_array($session[$node]) || empty($session[$node]) || current($session[$node]) != 1)
{
$session[$node] = array();

Expand Down Expand Up @@ -1623,7 +1623,7 @@ protected function treeView()
$arrClipboard = $this->Session->get('CLIPBOARD');

// Check clipboard
if (isset($arrClipboard[$this->strTable]) && count($arrClipboard[$this->strTable]))
if (isset($arrClipboard[$this->strTable]) && !empty($arrClipboard[$this->strTable]))
{
$blnClipboard = true;
$arrClipboard = $arrClipboard[$this->strTable];
Expand Down Expand Up @@ -1681,7 +1681,7 @@ protected function treeView()
$_buttons = '&nbsp;';

// Show paste button only if there are no root records specified
if ($this->Input->get('act') != 'select' && $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 5 && $blnClipboard && ((!count($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) && $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] !== false) || $GLOBALS['TL_DCA'][$table]['list']['sorting']['rootPaste']))
if ($this->Input->get('act') != 'select' && $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 5 && $blnClipboard && ((empty($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) && $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] !== false) || $GLOBALS['TL_DCA'][$table]['list']['sorting']['rootPaste']))
{
// Call paste_button_callback (&$dc, $row, $table, $cr, $childs, $previous, $next)
if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['paste_button_callback']))
Expand Down Expand Up @@ -1783,7 +1783,7 @@ public function ajaxTreeView($id, $level)
$arrClipboard = $this->Session->get('CLIPBOARD');

// Check clipboard
if (isset($arrClipboard[$this->strTable]) && count($arrClipboard[$this->strTable]))
if (isset($arrClipboard[$this->strTable]) && !empty($arrClipboard[$this->strTable]))
{
$blnClipboard = true;
$arrClipboard = $arrClipboard[$this->strTable];
Expand Down Expand Up @@ -2046,7 +2046,7 @@ protected function generateProductTree($table, $id, $arrPrevNext, $intMargin=0,
$rows = '';

// Add records of the table itself
if ($table != $this->strTable && count($gchilds) && $session[$node][$id] == 1)
if ($table != $this->strTable && !empty($gchilds) && $session[$node][$id] == 1)
{
for ($j=0; $j<count($gchilds); $j++)
{
Expand Down Expand Up @@ -2080,7 +2080,7 @@ protected function generateProductTree($table, $id, $arrPrevNext, $intMargin=0,
$group .= '</ul></li>';
}

if ($group == '' && $table != $this->strTable && !count($childs) && !count($gchilds) && $arrClipboard === false)
if ($group == '' && $table != $this->strTable && empty($childs) && empty($gchilds) && $arrClipboard === false)
{
return '';
}
Expand Down Expand Up @@ -2181,7 +2181,7 @@ protected function sortMenu()
}

// Return if there are no sorting fields
if (!count($sortingFields))
if (empty($sortingFields))
{
return '';
}
Expand Down Expand Up @@ -2259,7 +2259,7 @@ public function copyFallback()
}
}

if (count($arrDuplicate))
if (!empty($arrDuplicate))
{
$intLanguageId = $this->Database->execute("SELECT id FROM {$this->strTable} WHERE pid={$this->intId} AND language='$strLanguage'")->id;

Expand All @@ -2285,15 +2285,15 @@ private function fetchProductIds()
$arrVariants = array();

// No products available
if (!is_array($this->root) || !count($this->root))
if (!is_array($this->root) || !count($this->root)) // Can't use empty() because its an object property (using __get)
{
$this->root = array(0);
}

// Get root IDs matching search & filters
$query = "SELECT id FROM {$this->strTable} p1 WHERE id IN(" . implode(',', array_map('intval', $this->root)) . ")";

if (count($this->procedure))
if (count($this->procedure)) // Can't use empty() because its an object property (using __get)
{
$query .= ' AND ' . implode(' AND ', $this->procedure);
}
Expand All @@ -2309,7 +2309,7 @@ private function fetchProductIds()
// Get variant IDs matching search & filters
$query = "SELECT id, language, pid AS pid1, (SELECT pid FROM {$this->strTable} WHERE id=p1.pid) AS pid2 FROM {$this->strTable} p1 WHERE pid>0";

if (count($this->procedure))
if (count($this->procedure)) // Can't use empty() because its an object property (using __get)
{
$query .= " AND " . implode(' AND ', $this->procedure);
}
Expand Down Expand Up @@ -2355,7 +2355,7 @@ private function fetchProductIds()

// Fetch all variants of matching products
$arrMissing = array_diff($arrProducts, $arrVariants);
if (count($arrMissing) > 0)
if (!empty($arrMissing))
{
$objChilds = $this->Database->execute("SELECT id, pid AS pid1, (SELECT pid FROM {$this->strTable} WHERE id=p1.pid) AS pid2 FROM {$this->strTable} p1 HAVING pid1 IN (" . implode(',', $arrMissing) . ") OR pid2 IN (" . implode(',', $arrMissing) . ")");

Expand Down Expand Up @@ -2401,7 +2401,7 @@ private function fetchProductIds()
}
}

if (!count($this->products))
if (!count($this->products)) // Can't use empty() because its an object property (using __get)
{
$this->products = array(0);
}
Expand Down
24 changes: 12 additions & 12 deletions system/drivers/DC_TablePageId.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function showAll()
}

// Custom filter
if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']) && count($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']))
if (is_array($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']) && !empty($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter']))
{
foreach ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['filter'] as $filter)
{
Expand Down Expand Up @@ -511,7 +511,7 @@ protected function reviseTable()
}

// Delete all new but incomplete records (tstamp=0)
if (is_array($new_records[$this->strTable]) && count($new_records[$this->strTable]) > 0)
if (is_array($new_records[$this->strTable]) && !empty($new_records[$this->strTable]))
{
$objStmt = $this->Database->execute("DELETE FROM " . $this->strTable . " WHERE id IN(" . implode(',', array_map('intval', $new_records[$this->strTable])) . ") AND tstamp=0");

Expand All @@ -533,7 +533,7 @@ protected function reviseTable()
}

// Delete all records of the child table that are not related to the current table
if (is_array($ctable) && count($ctable))
if (is_array($ctable) && !empty($ctable))
{
foreach ($ctable as $v)
{
Expand Down Expand Up @@ -570,7 +570,7 @@ protected function parentView()
$blnMultiboard = false;

// Check clipboard
if (isset($arrClipboard[$table]) && count($arrClipboard[$table]))
if (isset($arrClipboard[$table]) && !empty($arrClipboard[$table]))
{
$blnClipboard = true;
$arrClipboard = $arrClipboard[$table];
Expand Down Expand Up @@ -748,17 +748,17 @@ protected function parentView()
$firstOrderBy = preg_replace('/\s+.*$/i', '', $orderBy[0]);
}

if (count($this->procedure))
if (!empty($this->procedure))
{
$query .= " WHERE " . implode(' AND ', $this->procedure);
}

if (is_array($this->root) && count($this->root) > 0)
if (is_array($this->root) && count($this->root) > 0) // Can't use empty() because its an object property (using __get)
{
$query .= (count($this->procedure) ? " AND " : " WHERE ") . "id IN(" . implode(',', array_map('intval', $this->root)) . ")";
}

if (is_array($orderBy) && count($orderBy) > 0)
if (is_array($orderBy) && !empty($orderBy))
{
$query .= " ORDER BY " . implode(', ', $orderBy);
}
Expand Down Expand Up @@ -966,7 +966,7 @@ protected function listView()
$query .= " WHERE " . implode(' AND ', $this->procedure);
}

if (is_array($this->root) && count($this->root) > 0)
if (is_array($this->root) && count($this->root)) // Can't use empty() because its an object property (using __get)
{
$query .= (count($this->procedure) ? " AND " : " WHERE ") . "id IN(" . implode(',', array_map('intval', $this->root)) . ")";
}
Expand Down Expand Up @@ -1019,7 +1019,7 @@ protected function listView()
$this->bid = strlen($return) ? $this->bid : 'tl_buttons';

// Display buttos
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] || count($GLOBALS['TL_DCA'][$this->strTable]['list']['global_operations']))
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['closed'] || !empty($GLOBALS['TL_DCA'][$this->strTable]['list']['global_operations']))
{
$return .= '
Expand Down Expand Up @@ -1264,7 +1264,7 @@ protected function listView()
*/
protected function generateButtons($arrRow, $strTable, $arrRootIds=array(), $blnCircularReference=false, $arrChildRecordIds=null, $strPrevious=null, $strNext=null)
{
if (!count($GLOBALS['TL_DCA'][$strTable]['list']['operations']))
if (empty($GLOBALS['TL_DCA'][$strTable]['list']['operations']))
{
return '';
}
Expand Down Expand Up @@ -1307,11 +1307,11 @@ protected function generateButtons($arrRow, $strTable, $arrRootIds=array(), $bln

if ($dir == 'up')
{
$return .= ((is_numeric($strPrevious) && (!in_array($arrRow['id'], $arrRootIds) || !count($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root']))) ? '<a href="'.$this->addToUrl($href.'&amp;id='.$arrRow['id']).'&amp;sid='.intval($strPrevious).'" title="'.specialchars($title).'"'.$attributes.'>'.$label.'</a> ' : $this->generateImage('up_.gif')).' ';
$return .= ((is_numeric($strPrevious) && (!in_array($arrRow['id'], $arrRootIds) || empty($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root']))) ? '<a href="'.$this->addToUrl($href.'&amp;id='.$arrRow['id']).'&amp;sid='.intval($strPrevious).'" title="'.specialchars($title).'"'.$attributes.'>'.$label.'</a> ' : $this->generateImage('up_.gif')).' ';
continue;
}

$return .= ((is_numeric($strNext) && (!in_array($arrRow['id'], $arrRootIds) || !count($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root']))) ? '<a href="'.$this->addToUrl($href.'&amp;id='.$arrRow['id']).'&amp;sid='.intval($strNext).'" title="'.specialchars($title).'"'.$attributes.'>'.$label.'</a> ' : $this->generateImage('down_.gif')).' ';
$return .= ((is_numeric($strNext) && (!in_array($arrRow['id'], $arrRootIds) || empty($GLOBALS['TL_DCA'][$strTable]['list']['sorting']['root']))) ? '<a href="'.$this->addToUrl($href.'&amp;id='.$arrRow['id']).'&amp;sid='.intval($strNext).'" title="'.specialchars($title).'"'.$attributes.'>'.$label.'</a> ' : $this->generateImage('down_.gif')).' ';
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/modules/isotope/AttributeWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function generate()


// Add a "no entries found" message if there are no options
if (!count($arrOptions))
if (empty($arrOptions))
{
$arrOptions[]= '<p class="tl_noopt">'.$GLOBALS['TL_LANG']['MSC']['noResult'].'</p>';
$blnCheckAll = false;
Expand Down
4 changes: 2 additions & 2 deletions system/modules/isotope/InheritCheckBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function validate()
{
parent::validate();

if (is_array($this->varValue) && count($this->varValue))
if (is_array($this->varValue) && !empty($this->varValue))
{
foreach ($this->varValue as $field)
{
Expand All @@ -73,7 +73,7 @@ public function generate()
}

// Add a "no entries found" message if there are no options
if (!count($arrOptions))
if (empty($arrOptions))
{
$arrOptions[]= '<p class="tl_noopt">'.$GLOBALS['TL_LANG']['MSC']['noResult'].'</p>';
}
Expand Down
Loading

0 comments on commit 6357435

Please sign in to comment.