Skip to content

Commit

Permalink
More code reduced from CI_Table
Browse files Browse the repository at this point in the history
  • Loading branch information
narfbg committed Feb 11, 2014
1 parent 3fcc3f6 commit f0b69a8
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions system/libraries/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,26 +242,14 @@ protected function _prep_args($args)
// If there is no $args[0], skip this and treat as an associative array
// This can happen if there is only a single key, for example this is passed to table->generate
// array(array('foo'=>'bar'))
if (isset($args[0]) && count($args) === 1 && is_array($args[0]))
if (isset($args[0]) && count($args) === 1 && is_array($args[0]) && ! isset($args[0]['data']))
{
// args sent as indexed array
if ( ! isset($args[0]['data']))
{
foreach ($args[0] as $key => $val)
{
$args[$key] = (is_array($val) && isset($val['data'])) ? $val : array('data' => $val);
}
}
$args = $args[0];
}
else

foreach ($args as $key => $val)
{
foreach ($args as $key => $val)
{
if ( ! is_array($val))
{
$args[$key] = array('data' => $val);
}
}
is_array($val) OR $args[$key] = array('data' => $val);
}

return $args;
Expand Down

0 comments on commit f0b69a8

Please sign in to comment.