111 'defaultColumnAlign',
132 if ($this->_columnWidths ===
null) {
133 #require_once 'Zend/Text/Table/Exception.php'; 138 if ($this->_decorator ===
null) {
139 if (self::getOutputCharset() ===
'utf-8') {
156 if (in_array(strtolower($key), $this->_skipOptions)) {
160 $method =
'set' . ucfirst($key);
161 if (method_exists($this,
$method)) {
190 if (count($columnWidths) === 0) {
191 #require_once 'Zend/Text/Table/Exception.php'; 195 foreach ($columnWidths as $columnNum => $columnWidth) {
196 if (is_int($columnWidth) ===
false or $columnWidth < 1) {
197 #require_once 'Zend/Text/Table/Exception.php'; 203 $this->_columnWidths = $columnWidths;
216 $this->_autoSeparate = (int) $autoSeparate;
229 $this->_decorator = $decorator;
232 $this->_decorator =
new $classname;
246 $this->_padding = max(0, (
int) $padding);
257 if ($this->_pluginLoader ===
null) {
258 $prefix =
'Zend_Text_Table_Decorator_';
259 $pathPrefix =
'Zend/Text/Table/Decorator/';
261 #require_once 'Zend/Loader/PluginLoader.php'; 262 $this->_pluginLoader =
new Zend_Loader_PluginLoader(array(
$prefix => $pathPrefix));
277 $this->_defaultColumnAligns[$columnNum] = $align;
289 self::$_inputCharset = strtolower($charset);
309 self::$_outputCharset = strtolower($charset);
333 #require_once 'Zend/Text/Table/Exception.php'; 337 if (is_array(
$row)) {
338 if (count(
$row) > count($this->_columnWidths)) {
339 #require_once 'Zend/Text/Table/Exception.php'; 343 #require_once 'Zend/Text/Table/Row.php'; 344 #require_once 'Zend/Text/Table/Column.php'; 349 foreach (
$data as $columnData) {
350 if (isset($this->_defaultColumnAligns[$colNum])) {
351 $align = $this->_defaultColumnAligns[$colNum];
361 $this->_rows[] =
$row;
375 if (count($this->_rows) === 0) {
376 #require_once 'Zend/Text/Table/Exception.php'; 384 $totalNumColumns = count($this->_columnWidths);
387 $numRows = count($this->_rows);
388 foreach ($this->_rows as $rowNum =>
$row) {
390 if (isset($columnWidths) ===
true) {
391 $lastColumnWidths = $columnWidths;
394 $renderedRow =
$row->render($this->_columnWidths, $this->_decorator, $this->_padding);
395 $columnWidths =
$row->getColumnWidths();
401 $result .= $this->_decorator->getTopLeft();
403 foreach ($columnWidths as $columnNum => $columnWidth) {
404 $result .= str_repeat($this->_decorator->getHorizontal(),
408 $result .= $this->_decorator->getTopRight();
410 $result .= $this->_decorator->getHorizontalDown();
417 if ($this->_autoSeparate & self::AUTO_SEPARATE_ALL) {
418 $drawSeparator =
true;
419 }
else if ($rowNum === 1 && $this->_autoSeparate & self::AUTO_SEPARATE_HEADER) {
420 $drawSeparator =
true;
421 }
else if ($rowNum === ($numRows - 1) && $this->_autoSeparate & self::AUTO_SEPARATE_FOOTER) {
422 $drawSeparator =
true;
424 $drawSeparator =
false;
427 if ($drawSeparator) {
428 $result .= $this->_decorator->getVerticalRight();
430 $currentUpperColumn = 0;
431 $currentLowerColumn = 0;
432 $currentUpperWidth = 0;
433 $currentLowerWidth = 0;
436 foreach ($this->_columnWidths as $columnNum => $columnWidth) {
438 $result .= str_repeat($this->_decorator->getHorizontal(),
442 if (($columnNum + 1) === $totalNumColumns) {
448 $currentUpperWidth += $columnWidth;
449 $currentLowerWidth += $columnWidth;
451 if ($lastColumnWidths[$currentUpperColumn] === $currentUpperWidth) {
453 $currentUpperColumn += 1;
454 $currentUpperWidth = 0;
456 $currentUpperWidth += 1;
459 if ($columnWidths[$currentLowerColumn] === $currentLowerWidth) {
461 $currentLowerColumn += 1;
462 $currentLowerWidth = 0;
464 $currentLowerWidth += 1;
467 switch ($connector) {
469 $result .= $this->_decorator->getHorizontal();
473 $result .= $this->_decorator->getHorizontalUp();
477 $result .= $this->_decorator->getHorizontalDown();
481 $result .= $this->_decorator->getCross();
490 $result .= $this->_decorator->getVerticalLeft() .
"\n";
498 if (($rowNum + 1) === $numRows) {
499 $result .= $this->_decorator->getBottomLeft();
501 foreach ($columnWidths as $columnNum => $columnWidth) {
502 $result .= str_repeat($this->_decorator->getHorizontal(),
506 $result .= $this->_decorator->getBottomRight();
508 $result .= $this->_decorator->getHorizontalUp();
528 }
catch (Exception $e) {
529 trigger_error($e->getMessage(), E_USER_ERROR);
setConfig(Zend_Config $config)
setColumnWidths(array $columnWidths)
const AUTO_SEPARATE_HEADER
setOptions(array $options)
setAutoSeparate($autoSeparate)
static setInputCharset($charset)
static getOutputCharset()
static setOutputCharset($charset)
setDefaultColumnAlign($columnNum, $align)
__construct($options=null)
const AUTO_SEPARATE_FOOTER