Ejemplo n.º 1
0
 /**
  * Generate table output
  *
  * @param VcsStats_Table $table Table
  * @return void
  */
 public function renderTable(VcsStats_Report_Element_Table $table)
 {
     $result = '';
     $output = new ezcConsoleOutput();
     $output->formats->title->style = array('bold');
     $alignments = array('center' => ezcConsoleTable::ALIGN_CENTER, 'left' => ezcConsoleTable::ALIGN_LEFT, 'right' => ezcConsoleTable::ALIGN_RIGHT);
     $consoleTable = new ezcConsoleTable($output, 78);
     // Display header
     $consoleTable[0]->align = ezcConsoleTable::ALIGN_CENTER;
     foreach ($table->getColumns() as $column) {
         $consoleTable[0][]->content = $column->getTitle();
     }
     // Display values
     foreach ($table->getRows() as $i => $row) {
         $j = 0;
         foreach ($row as $code => $value) {
             $alignment = $table->getColumn($code)->getAlignment();
             $consoleTable[$i + 1][$j]->align = $alignments[$alignment];
             $consoleTable[$i + 1][$j]->content = $value;
             $j++;
         }
     }
     ob_start();
     $output->outputLine();
     $output->outputLine($table->getTitle(), 'title');
     $consoleTable->outputTable();
     $output->outputLine();
     $output->outputLine();
     $result .= ob_get_clean();
     echo $result;
 }
Ejemplo n.º 2
0
 public function testSetColumnsExistingColumnsShouldBeReplaced()
 {
     $table = new VcsStats_Report_Element_Table();
     $table->addColumn(new VcsStats_Report_Element_Table_Column('Column 0', 'col0'));
     $columns = array(new VcsStats_Report_Element_Table_Column('Column 1', 'col1'), new VcsStats_Report_Element_Table_Column('Column 2', 'col2'), new VcsStats_Report_Element_Table_Column('Column 3', 'col3'));
     $table->setColumns($columns);
     $this->assertSame($columns, $table->getColumns());
 }