示例#1
0
 /**
  * @covers \Fuel\Common\Table\Render::renderTable
  * @covers \Fuel\Common\Table\Render\SimpleTable::container
  * @covers \Fuel\Common\Table\Render\SimpleTable::row
  * @covers \Fuel\Common\Table\Render\SimpleTable::cell
  * @covers \Fuel\Common\Table\Render\SimpleTable::addAttributes
  * @group Common
  */
 public function testRenderWithAttributes()
 {
     $table = new \Fuel\Common\Table();
     $table->setAttributes(array('id' => 'table'))->addCell('foo', array('id' => 'foo'))->addCell('bar', array('id' => 'bar'))->setCurrentRowAttributes(array('id' => 'row'))->addRow();
     $expected = '<table id="table"><thead></thead><tbody><tr id="row"><td id="foo">foo</td><td id="bar">bar</td></tr></tbody><tfoot></tfoot></table>';
     $result = $this->object->renderTable($table);
     $this->assertXmlStringEqualsXmlString($expected, $result);
 }
示例#2
0
 /**
  *
  */
 public function testClean()
 {
     $tab = new SimpleTable();
     $tab->border = true;
     $tab->padding = 0;
     $tab->addRow(array('1', 'one'));
     $tab->clean();
     $tab->addRow(array('2', 'two'));
     $tab->addRow(array('3', 'three'));
     $expected = array('+-+-----+', '|2|two  |', '|3|three|', '+-+-----+');
     $this->assertEquals($expected, $tab->getTable(true));
 }
示例#3
0
文件: Script.php 项目: phellow/cli
 /**
  * Show the help message.
  *
  * @param Parameters $params
  *
  * @return void
  */
 protected function showHelp(Parameters $params)
 {
     $table = new SimpleTable();
     $table->border = false;
     $table->padding = 3;
     $executedFile = basename($params->getExecutedFile());
     $arguments = $params->getRegisteredArguments();
     $argsUsage = '';
     $argsRows = [];
     foreach ($arguments as $arg) {
         $argsUsage .= ' <' . $arg['name'] . '>';
         $argsRows[] = [$arg['name'], $arg['description']];
     }
     $this->outln('Usage: ' . $executedFile . $argsUsage);
     // show possible arguments
     if ($argsRows) {
         $table->addRow([]);
         $table->addRow(['Arguments:']);
         foreach ($argsRows as $row) {
             $table->addRow($row);
         }
     }
     // show possible options
     $options = $params->getRegisteredOptions();
     if ($options) {
         $table->addRow([]);
         $table->addRow(['Options:']);
         foreach ($options as $opt) {
             $val = '';
             switch ($opt['valueFlag']) {
                 case Parameters::VALUE_YES:
                     $val = '=<value>';
                     break;
                 case Parameters::VALUE_OPTIONAL:
                     $val = '[=<value>]';
                     break;
             }
             $def = '--' . $opt['name'] . $val;
             if ($opt['short']) {
                 $def .= ' -' . $opt['short'] . $val;
             }
             $table->addRow([$def, $opt['description']]);
         }
     }
     $this->outln($table->getTable());
 }
示例#4
0
<?php

$csv = new SimpleTable();
$dom = DOMDocument::load('supplementalData.xml');
$csv->load_byDomAttribs($dom, "/supplementalData/languageData/language[@territories]", ['type', 'alt', 'territories'])->save('scrapped/languageData_bylang.csv');
$csv->load_byDomAttribs($dom, "/supplementalData/territoryContainment/group[not(@status)]", ['type', 'contains'])->save('scrapped/territoryContainment.csv');
$popPercMin = 1;
$csv->load_byDomFunc($dom, function ($xp, $node, $head) use($popPercMin) {
    $oficiais = [];
    $etc = [];
    $country = $node->getAttribute('type');
    $pop = $node->getAttribute('population');
    $lst = $xp->query("languagePopulation", $node);
    // subquery
    if ($lst->length) {
        foreach ($lst as $g) {
            $lang = $g->getAttribute('type');
            $popPerc = $g->getAttribute('populationPercent');
            if ($g->getAttribute('officialStatus') == 'official') {
                $oficiais[] = $lang;
            } elseif ((int) $popPerc >= $popPercMin) {
                $etc[] = $lang;
            }
        }
    }
    // if for $g
    return [$country, $pop, join(' ', $oficiais), join(' ', $etc)];
}, "/supplementalData/territoryInfo/territory", ['country', 'population', 'langs_official', 'langs_other'])->save('scrapped/territoryInfo.csv');
// testar -> joinWith($csv2, [1=>2,2=>1], [3,4]) -> save();
//country,langs_official,langs_otherGt1perc
//FALTA (inclui tag -BR, etc. da lang oficial caso exista IETF)
示例#5
0
 public function getMaxPosition($table, $parent = 0)
 {
     return parent::getMaxPosition($table, $parent);
 }