/** * Load data to row * @param array $data * @return Row */ public function loadRow($data, $newInstance = false) { if ($data instanceof Row) { return $data; } if (!is_array($data)) { $data = array(); } if ($newInstance) { $row = $this->table->row(); $row->init($data); return $row; } if (null === $this->row) { $this->row = $this->table->row(); } $this->row->init($data); return $this->row; }
/** * Writes the help for a given schema. * * @param array $schema A command line scheme returned from {@see Cli::getSchema()}. */ protected function writeHelp($schema) { // Write the command description. $meta = Cli::val(Cli::META, $schema, []); $description = Cli::val('description', $meta); if ($description) { echo implode("\n", Cli::breakLines($description, 80, false)) . PHP_EOL . PHP_EOL; } unset($schema[Cli::META]); // Add the help. $schema['help'] = ['description' => 'Display this help.', 'type' => 'boolean', 'short' => '?']; echo Cli::bold('OPTIONS') . PHP_EOL; ksort($schema); $table = new Table(); $table->format = $this->format; foreach ($schema as $key => $definition) { $table->row(); // Write the keys. $keys = "--{$key}"; if ($shortKey = Cli::val('short', $definition, false)) { $keys .= ", -{$shortKey}"; } if (Cli::val('required', $definition)) { $table->bold($keys); } else { $table->cell($keys); } // Write the description. $table->cell(Cli::val('description', $definition, '')); } $table->write(); echo PHP_EOL; $args = Cli::val(Cli::ARGS, $meta, []); if (!empty($args)) { echo Cli::bold('ARGUMENTS') . PHP_EOL; $table = new Table(); $table->format = $this->format; foreach ($args as $aname => $arg) { $table->row(); if (Cli::val('required', $definition)) { $table->bold($aname); } else { $table->cell($aname); } $table->cell(Cli::val('description', $arg, '')); } $table->write(); echo PHP_EOL; } }
<p> Here is the data in tabular form for easier reading. <p> <?php $t = new Table("b"); $t->set("First Name"); $t->set("Last Name"); $t->set("Team Name"); $t->set("Team Role"); $t->set("Username"); $t->set("Password"); $lc = count($lines); for ($lineno = 0; $lineno < $lc; $lineno++) { $l =& $lines[$lineno]; $t->row($lineno + 1); $t->set($l[0]); $t->set($l[1]); $t->set($l[2]); $t->set($l[3]); $t->set($l[4]); $t->set($l[5]); } $t->dump(); ?> <p> <?php if ($errcount < 1) { ?>
function pageTable($page, $table = NULL, $doCols = true) { if (!isset($this->cache['page']) or $page != $this->cache['page']) { $this->cache['page'] = $page; $this->_save(); } $this->_cachePage($page); if (!$table) { require_once '../classes/Table.php'; $table = new Table(); } if ($doCols) { $table->columns($this->columns()); } if ($this->name) { $table->parameters(array('rpt' => $this->name, 'rpt_colnames' => $this->columnNames())); } $table->start(); foreach ($this->cache['rows'] as $row) { $table->row($row); } $table->end(); }
<?php include "table.php"; $t = new Table("top"); $t->set("<div id=hh1>Rank</div>"); $t->set("<div id=hh1>Percentile</div>"); $t->set("<div id=hh1>Student</div>"); $rs = dbExec("select\n r.p_final,\n\t\t\t\t\t\t\tconcat(u.last_name,', ',u.first_name) as name,\n\t\t\t\t\t\t\tconcat_ws(' ',s.name,s.city,s.state) as school,\n\t\t\t\t\t\t\tu.school_code as sc,\n r.uid\n from\n results as r\n left outer join users as u on\n u.id = r.uid\n left outer join schools as s on\n s.code = u.school_code\n where\n p_final is not null\n\t\t\t\t\t\torder by p_final desc\n\t\t\t\t\t\tlimit {$topcount}\n\t\t\t\t\t\t"); while ($o = $rs->FetchNextObj()) { $id = $o->uid; $pcntl = $o->p_final; $name = $o->name; $name = "<a href='?rtype=indv&n={$id}'>{$name}</a>"; $sc = $o->sc; $school = $o->school; $school = "<font color=gray size=-1>{$school}</font>"; $t->row($rs->CurrentRow() + 1); $t->set($rs->CurrentRow() + 1); $t->set(percbar_str($pcntl, $pcntl)); $t->set($name . "<br>" . $school); } $t->dump(); } } ?> <p> <?php $id = rt("n"); $fc = rt("fc"); if ($id != "") { function sr($t, $v) {