"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "framework/console/widgets/Table.php" between
yii2-2.0.35.tar.gz and yii2-2.0.36.tar.gz

About: Yii 2 is a high-performance component-based PHP framework for developing large-scale Web applications (source).

Table.php  (yii2-2.0.35):Table.php  (yii2-2.0.36)
skipping to change at line 243 skipping to change at line 243
* @return string * @return string
* @see \yii\console\widgets\Table::render() * @see \yii\console\widgets\Table::render()
*/ */
protected function renderRow(array $row, $spanLeft, $spanMiddle, $spanRight) protected function renderRow(array $row, $spanLeft, $spanMiddle, $spanRight)
{ {
$size = $this->columnWidths; $size = $this->columnWidths;
$buffer = ''; $buffer = '';
$arrayPointer = []; $arrayPointer = [];
$finalChunk = []; $finalChunk = [];
$alreadyPrintedCells = [];
for ($i = 0, ($max = $this->calculateRowHeight($row)) ?: $max = 1; $i < $max; $i++) { for ($i = 0, ($max = $this->calculateRowHeight($row)) ?: $max = 1; $i < $max; $i++) {
$buffer .= $spanLeft . ' '; $buffer .= $spanLeft . ' ';
foreach ($size as $index => $cellSize) { foreach ($size as $index => $cellSize) {
$cell = isset($row[$index]) ? $row[$index] : null; $cell = isset($row[$index]) ? $row[$index] : null;
$prefix = ''; $prefix = '';
$chunk = '';
if ($index !== 0) { if ($index !== 0) {
$buffer .= $spanMiddle . ' '; $buffer .= $spanMiddle . ' ';
} }
if (is_array($cell)) { if (is_array($cell)) {
if (empty($finalChunk[$index])) { if (empty($finalChunk[$index])) {
$finalChunk[$index] = ''; $finalChunk[$index] = '';
$start = 0;
$prefix = $this->listPrefix; $prefix = $this->listPrefix;
if (!isset($arrayPointer[$index])) { if (!isset($arrayPointer[$index])) {
$arrayPointer[$index] = 0; $arrayPointer[$index] = 0;
} }
} else {
$start = mb_strwidth($finalChunk[$index], Yii::$app->cha
rset);
} }
$chunk = mb_substr($cell[$arrayPointer[$index]], $start, $ce llSize - 4, Yii::$app->charset); $chunk = $cell[$arrayPointer[$index]];
$finalChunk[$index] .= $chunk; $finalChunk[$index] .= $chunk;
if (isset($cell[$arrayPointer[$index] + 1]) && $finalChunk[$ index] === $cell[$arrayPointer[$index]]) { if (isset($cell[$arrayPointer[$index] + 1]) && $finalChunk[$ index] === $cell[$arrayPointer[$index]]) {
$arrayPointer[$index]++; $arrayPointer[$index]++;
$finalChunk[$index] = ''; $finalChunk[$index] = '';
} }
} else { } else {
$chunk = mb_substr($cell, ($cellSize * $i) - ($i * 2), $cell if (!isset($alreadyPrintedCells[$index])) {
Size - 2, Yii::$app->charset); $chunk = $cell;
}
$alreadyPrintedCells[$index] = true;
} }
$chunk = $prefix . $chunk; $chunk = $prefix . $chunk;
$repeat = $cellSize - mb_strwidth($chunk, Yii::$app->charset) - 1; $repeat = $cellSize - Console::ansiStrwidth($chunk) - 1;
$buffer .= $chunk; $buffer .= $chunk;
if ($repeat >= 0) { if ($repeat >= 0) {
$buffer .= str_repeat(' ', $repeat); $buffer .= str_repeat(' ', $repeat);
} }
} }
$buffer .= "$spanRight\n"; $buffer .= "$spanRight\n";
} }
return $buffer; return $buffer;
} }
skipping to change at line 335 skipping to change at line 337
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
$columns[] = ArrayHelper::getColumn($this->rows, $i); $columns[] = ArrayHelper::getColumn($this->rows, $i);
if ($i < $headerCount) { if ($i < $headerCount) {
$columns[$i][] = $this->headers[$i]; $columns[$i][] = $this->headers[$i];
} }
} }
foreach ($columns as $column) { foreach ($columns as $column) {
$columnWidth = max(array_map(function ($val) { $columnWidth = max(array_map(function ($val) {
if (is_array($val)) { if (is_array($val)) {
$encodings = array_fill(0, count($val), Yii::$app->charset); return max(array_map('yii\helpers\Console::ansiStrwidth', $v
return max(array_map('mb_strwidth', $val, $encodings)) + mb_ al)) + Console::ansiStrwidth($this->listPrefix);
strwidth($this->listPrefix, Yii::$app->charset);
} }
return Console::ansiStrwidth($val);
return mb_strwidth($val, Yii::$app->charset);
}, $column)) + 2; }, $column)) + 2;
$this->columnWidths[] = $columnWidth; $this->columnWidths[] = $columnWidth;
$totalWidth += $columnWidth; $totalWidth += $columnWidth;
} }
$relativeWidth = $screenWidth / $totalWidth; $relativeWidth = $screenWidth / $totalWidth;
if ($totalWidth > $screenWidth) { if ($totalWidth > $screenWidth) {
foreach ($this->columnWidths as $j => $width) { foreach ($this->columnWidths as $j => $width) {
$this->columnWidths[$j] = (int) ($width * $relativeWidth); $this->columnWidths[$j] = (int) ($width * $relativeWidth);
skipping to change at line 371 skipping to change at line 371
* @param array $row * @param array $row
* @return int maximum row per cell * @return int maximum row per cell
* @see \yii\console\widgets\Table::render() * @see \yii\console\widgets\Table::render()
*/ */
protected function calculateRowHeight($row) protected function calculateRowHeight($row)
{ {
$rowsPerCell = array_map(function ($size, $columnWidth) { $rowsPerCell = array_map(function ($size, $columnWidth) {
if (is_array($columnWidth)) { if (is_array($columnWidth)) {
$rows = 0; $rows = 0;
foreach ($columnWidth as $width) { foreach ($columnWidth as $width) {
$rows += ceil($width / ($size - 2)); $rows += $size == 2 ? 0 : ceil($width / ($size - 2));
} }
return $rows; return $rows;
} }
return $size == 2 || $columnWidth == 0 ? 0 : ceil($columnWidth / ($s
return ceil($columnWidth / ($size - 2)); ize - 2));
}, $this->columnWidths, array_map(function ($val) { }, $this->columnWidths, array_map(function ($val) {
if (is_array($val)) { if (is_array($val)) {
$encodings = array_fill(0, count($val), Yii::$app->charset); return array_map('yii\helpers\Console::ansiStrwidth', $val);
return array_map('mb_strwidth', $val, $encodings);
} }
return Console::ansiStrwidth($val);
return mb_strwidth($val, Yii::$app->charset); }, $row));
}, $row)
);
return max($rowsPerCell); return max($rowsPerCell);
} }
/** /**
* Getting screen width. * Getting screen width.
* If it is not able to determine screen width, default value `123` will be set. * If it is not able to determine screen width, default value `123` will be set.
* *
* @return int screen width * @return int screen width
*/ */
protected function getScreenWidth() protected function getScreenWidth()
 End of changes. 14 change blocks. 
24 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)