Author: Tobias Schlitt
Date: 2007-05-06 16:45:02 +0200 (Sun, 06 May 2007)
New Revision: 5073
Log:
- Implemented issue #8471: Disable borders for the ConsoleTable.
Modified:
trunk/ConsoleTools/ChangeLog
trunk/ConsoleTools/src/options/table.php
trunk/ConsoleTools/src/table.php
trunk/ConsoleTools/tests/table_test.php
Modified: trunk/ConsoleTools/ChangeLog
===================================================================
--- trunk/ConsoleTools/ChangeLog 2007-05-06 12:29:21 UTC (rev 5072)
+++ trunk/ConsoleTools/ChangeLog 2007-05-06 14:45:02 UTC (rev 5073)
@@ -26,6 +26,8 @@
- Implemented issue #9216: ezcConsoleInput::getOptionValues I want long names.
ezcConsoleInput->getOptionsValues() can now be configured to index the
returning array with option long names.
+- Implemented issue #8471: Disable borders for ezcConsoleTable. Borders can be
+ disabled by setting the line and corner properties to null.
1.2 - Monday 18 December 2006
Modified: trunk/ConsoleTools/src/options/table.php
===================================================================
--- trunk/ConsoleTools/src/options/table.php 2007-05-06 12:29:21 UTC (rev
5072)
+++ trunk/ConsoleTools/src/options/table.php 2007-05-06 14:45:02 UTC (rev
5073)
@@ -31,11 +31,11 @@
* @property int $widthType
* Type of the given table width (fixed or maximal value).
* @property string $lineVertical
- * Character to use for drawing vertical lines.
+ * Character to use for drawing vertical lines. Null to switch off.
* @property string $lineHorizontal
- * Character to use for drawing horizontal lines.
+ * Character to use for drawing horizontal lines. Null to switch off.
* @property string $corner
- * Character to use for drawing line corners.
+ * Character to use for drawing line corners. Null to switch off.
* @property string $defaultFormat
* Standard column content format, applied to cells that have
* "default" as the content format.
@@ -170,9 +170,9 @@
case 'lineVertical':
case 'lineHorizontal':
case 'corner':
- if ( is_string( $val ) === false || strlen( $val ) !== 1 )
+ if ( ( is_string( $val ) === false || strlen( $val ) !== 1 )
&& $val !== null )
{
- throw new ezcBaseValueException( $propertyName, $val,
'string, length = 1' );
+ throw new ezcBaseValueException( $propertyName, $val,
'string, length = 1, or null' );
}
break;
case 'defaultFormat':
Modified: trunk/ConsoleTools/src/table.php
===================================================================
--- trunk/ConsoleTools/src/table.php 2007-05-06 12:29:21 UTC (rev 5072)
+++ trunk/ConsoleTools/src/table.php 2007-05-06 14:45:02 UTC (rev 5073)
@@ -278,9 +278,9 @@
*/
public function offsetGet( $offset )
{
- if ( !is_int( $offset ) || $offset < 0 )
+ if ( !is_int( $offset ) || $offset < 0 )
{
- throw new ezcBaseValueException( 'offset', $offset, 'int >= 0' );
+ throw new ezcBaseValueException( 'offset', $offset, 'int >= 0 or
null' );
}
if ( !isset( $this->rows[$offset] ) )
{
@@ -508,7 +508,10 @@
{
$colWidth = $this->getColWidths();
$table = array();
- $table[] = $this->generateBorder( $colWidth, $this[0]->borderFormat );
+ if ( $this->options->lineVertical !== null )
+ {
+ $table[] = $this->generateBorder( $colWidth,
$this[0]->borderFormat );
+ }
// Rows submitted by the user
for ( $i = 0; $i < count( $this->rows ); $i++ )
{
@@ -518,7 +521,10 @@
$table[] = $this->generateRow( $brkCells, $colWidth,
$this->rows[$i] );
}
$afterBorderFormat = isset( $this->rows[$i + 1] ) &&
$this->rows[$i + 1]->borderFormat != 'default' ? $this->rows[$i +
1]->borderFormat : $this->rows[$i]->borderFormat;
- $table[] = $this->generateBorder( $colWidth, $afterBorderFormat );
+ if ( $this->options->lineVertical !== null )
+ {
+ $table[] = $this->generateBorder( $colWidth,
$afterBorderFormat );
+ }
}
return $table;
}
@@ -534,9 +540,10 @@
$border = '';
foreach ( $colWidth as $col => $width )
{
- $border .= $this->properties['options']->corner . str_repeat(
$this->properties['options']->lineVertical, $width + ( 2 * strlen(
$this->properties['options']->colPadding ) ) );
+ $border .= ( $this->options->lineHorizontal !== null ?
$this->properties['options']->corner : '' )
+ . str_repeat( $this->properties['options']->lineVertical,
$width + ( 2 * strlen( $this->properties['options']->colPadding ) ) );
}
- $border .= $this->properties['options']->corner;
+ $border .= ( $this->options->lineHorizontal !== null ?
$this->properties['options']->corner : '' );
return $this->outputHandler->formatText( $border, $format );
}
Modified: trunk/ConsoleTools/tests/table_test.php
===================================================================
--- trunk/ConsoleTools/tests/table_test.php 2007-05-06 12:29:21 UTC (rev
5072)
+++ trunk/ConsoleTools/tests/table_test.php 2007-05-06 14:45:02 UTC (rev
5073)
@@ -220,6 +220,50 @@
);
}
+ public function testTableWithoutBorders()
+ {
+ $this->commonTableTest(
+ __FUNCTION__,
+ $this->tableData4,
+ array( 'cols' => count( $this->tableData4[0] ), 'width' => 120 ),
+ array( 'lineVertical' => null, 'lineHorizontal' => null, 'corner'
=> null ),
+ array( 0 )
+ );
+ }
+
+ public function testTableWithSpaceBorders()
+ {
+ $this->commonTableTest(
+ __FUNCTION__,
+ $this->tableData4,
+ array( 'cols' => count( $this->tableData4[0] ), 'width' => 120 ),
+ array( 'lineVertical' => ' ', 'lineHorizontal' => ' ', 'corner' =>
' ' ),
+ array( 0 )
+ );
+ }
+
+ public function testTableWithoutVerticalBorders()
+ {
+ $this->commonTableTest(
+ __FUNCTION__,
+ $this->tableData4,
+ array( 'cols' => count( $this->tableData4[0] ), 'width' => 120 ),
+ array( 'lineVertical' => null ),
+ array( 0 )
+ );
+ }
+
+ public function testTableWithoutHorizontalBorders()
+ {
+ $this->commonTableTest(
+ __FUNCTION__,
+ $this->tableData4,
+ array( 'cols' => count( $this->tableData4[0] ), 'width' => 120 ),
+ array( 'lineHorizontal' => null ),
+ array( 0 )
+ );
+ }
+
public function testTableConfigurationFailure1 ()
{
// Missing 'cols' setting
@@ -928,7 +972,7 @@
$refFile = dirname( __FILE__ ) . '/data/' . ( ezcBaseFeatures::os()
=== "Windows" ? "windows/" : "posix/" ) . $refFile . '.dat';
// To prepare test files, uncomment this block
- //file_put_contents( $refFile, implode( PHP_EOL, $table->getTable() )
);
+ // file_put_contents( $refFile, implode( PHP_EOL, $table->getTable() )
);
// For test assertion, uncomment this block
$this->assertEquals(
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components