CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.
This commit is contained in:
parent
514777e8d2
commit
b11cbd8159
4546 changed files with 138 additions and 51 deletions
243
airtime_mvc/library/Zend/Text/Table/Column.php
Normal file
243
airtime_mvc/library/Zend/Text/Table/Column.php
Normal file
|
@ -0,0 +1,243 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Column.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Text_Table
|
||||
*/
|
||||
require_once 'Zend/Text/Table.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Text_MultiByte
|
||||
*/
|
||||
require_once 'Zend/Text/MultiByte.php';
|
||||
|
||||
/**
|
||||
* Column class for Zend_Text_Table_Row
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Text_Table_Column
|
||||
{
|
||||
/**
|
||||
* Aligns for columns
|
||||
*/
|
||||
const ALIGN_LEFT = 'left';
|
||||
const ALIGN_CENTER = 'center';
|
||||
const ALIGN_RIGHT = 'right';
|
||||
|
||||
/**
|
||||
* Content of the column
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_content = '';
|
||||
|
||||
/**
|
||||
* Align of the column
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_align = self::ALIGN_LEFT;
|
||||
|
||||
/**
|
||||
* Colspan of the column
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_colSpan = 1;
|
||||
|
||||
/**
|
||||
* Allowed align parameters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_allowedAligns = array(self::ALIGN_LEFT, self::ALIGN_CENTER, self::ALIGN_RIGHT);
|
||||
|
||||
/**
|
||||
* Create a column for a Zend_Text_Table_Row object.
|
||||
*
|
||||
* @param string $content The content of the column
|
||||
* @param string $align The align of the content
|
||||
* @param integer $colSpan The colspan of the column
|
||||
* @param string $charset The encoding of the content
|
||||
*/
|
||||
public function __construct($content = null, $align = null, $colSpan = null, $charset = null)
|
||||
{
|
||||
if ($content !== null) {
|
||||
$this->setContent($content, $charset);
|
||||
}
|
||||
|
||||
if ($align !== null) {
|
||||
$this->setAlign($align);
|
||||
}
|
||||
|
||||
if ($colSpan !== null) {
|
||||
$this->setColSpan($colSpan);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content.
|
||||
*
|
||||
* If $charset is not defined, it is assumed that $content is encoded in
|
||||
* the charset defined via Zend_Text_Table::setInputCharset() (defaults
|
||||
* to utf-8).
|
||||
*
|
||||
* @param string $content Content of the column
|
||||
* @param string $charset The charset of the content
|
||||
* @throws Zend_Text_Table_Exception When $content is not a string
|
||||
* @return Zend_Text_Table_Column
|
||||
*/
|
||||
public function setContent($content, $charset = null)
|
||||
{
|
||||
if (is_string($content) === false) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('$content must be a string');
|
||||
}
|
||||
|
||||
if ($charset === null) {
|
||||
$inputCharset = Zend_Text_Table::getInputCharset();
|
||||
} else {
|
||||
$inputCharset = strtolower($charset);
|
||||
}
|
||||
|
||||
$outputCharset = Zend_Text_Table::getOutputCharset();
|
||||
|
||||
if ($inputCharset !== $outputCharset) {
|
||||
if (PHP_OS !== 'AIX') {
|
||||
// AIX does not understand these character sets
|
||||
$content = iconv($inputCharset, $outputCharset, $content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->_content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the align
|
||||
*
|
||||
* @param string $align Align of the column
|
||||
* @throws Zend_Text_Table_Exception When supplied align is invalid
|
||||
* @return Zend_Text_Table_Column
|
||||
*/
|
||||
public function setAlign($align)
|
||||
{
|
||||
if (in_array($align, $this->_allowedAligns) === false) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('Invalid align supplied');
|
||||
}
|
||||
|
||||
$this->_align = $align;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the colspan
|
||||
*
|
||||
* @param int $colSpan
|
||||
* @throws Zend_Text_Table_Exception When $colSpan is smaller than 1
|
||||
* @return Zend_Text_Table_Column
|
||||
*/
|
||||
public function setColSpan($colSpan)
|
||||
{
|
||||
if (is_int($colSpan) === false or $colSpan < 1) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('$colSpan must be an integer and greater than 0');
|
||||
}
|
||||
|
||||
$this->_colSpan = $colSpan;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the colspan
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getColSpan()
|
||||
{
|
||||
return $this->_colSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the column width the given column width
|
||||
*
|
||||
* @param integer $columnWidth The width of the column
|
||||
* @param integer $padding The padding for the column
|
||||
* @throws Zend_Text_Table_Exception When $columnWidth is lower than 1
|
||||
* @throws Zend_Text_Table_Exception When padding is greater than columnWidth
|
||||
* @return string
|
||||
*/
|
||||
public function render($columnWidth, $padding = 0)
|
||||
{
|
||||
if (is_int($columnWidth) === false or $columnWidth < 1) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('$columnWidth must be an integer and greater than 0');
|
||||
}
|
||||
|
||||
$columnWidth -= ($padding * 2);
|
||||
|
||||
if ($columnWidth < 1) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('Padding (' . $padding . ') is greater than column width');
|
||||
}
|
||||
|
||||
switch ($this->_align) {
|
||||
case self::ALIGN_LEFT:
|
||||
$padMode = STR_PAD_RIGHT;
|
||||
break;
|
||||
|
||||
case self::ALIGN_CENTER:
|
||||
$padMode = STR_PAD_BOTH;
|
||||
break;
|
||||
|
||||
case self::ALIGN_RIGHT:
|
||||
$padMode = STR_PAD_LEFT;
|
||||
break;
|
||||
|
||||
default:
|
||||
// This can never happen, but the CS tells I have to have it ...
|
||||
break;
|
||||
}
|
||||
|
||||
$outputCharset = Zend_Text_Table::getOutputCharset();
|
||||
$lines = explode("\n", Zend_Text_MultiByte::wordWrap($this->_content, $columnWidth, "\n", true, $outputCharset));
|
||||
$paddedLines = array();
|
||||
|
||||
foreach ($lines AS $line) {
|
||||
$paddedLines[] = str_repeat(' ', $padding)
|
||||
. Zend_Text_MultiByte::strPad($line, $columnWidth, ' ', $padMode, $outputCharset)
|
||||
. str_repeat(' ', $padding);
|
||||
}
|
||||
|
||||
$result = implode("\n", $paddedLines);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
147
airtime_mvc/library/Zend/Text/Table/Decorator/Ascii.php
Normal file
147
airtime_mvc/library/Zend/Text/Table/Decorator/Ascii.php
Normal file
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Ascii.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Text_Table_Decorator_Interface
|
||||
*/
|
||||
require_once 'Zend/Text/Table/Decorator/Interface.php';
|
||||
|
||||
/**
|
||||
* ASCII Decorator for Zend_Text_Table
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @uses Zend_Text_Table_Decorator_Interface
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Text_Table_Decorator_Ascii implements Zend_Text_Table_Decorator_Interface
|
||||
{
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopLeft()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopRight()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomLeft()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomRight()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVertical()
|
||||
{
|
||||
return '|';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontal()
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCross()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVerticalRight()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVerticalLeft()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontalDown()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontalUp()
|
||||
{
|
||||
return '+';
|
||||
}
|
||||
}
|
108
airtime_mvc/library/Zend/Text/Table/Decorator/Interface.php
Normal file
108
airtime_mvc/library/Zend/Text/Table/Decorator/Interface.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for Zend_Text_Table decorators
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Text_Table_Decorator_Interface
|
||||
{
|
||||
/**
|
||||
* Get a single character for the top left corner
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopLeft();
|
||||
|
||||
/**
|
||||
* Get a single character for the top right corner
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopRight();
|
||||
|
||||
/**
|
||||
* Get a single character for the bottom left corner
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomLeft();
|
||||
|
||||
/**
|
||||
* Get a single character for the bottom right corner
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomRight();
|
||||
|
||||
/**
|
||||
* Get a single character for a vertical line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVertical();
|
||||
|
||||
/**
|
||||
* Get a single character for a horizontal line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontal();
|
||||
|
||||
/**
|
||||
* Get a single character for a crossing line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCross();
|
||||
|
||||
/**
|
||||
* Get a single character for a vertical divider right
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVerticalRight();
|
||||
|
||||
/**
|
||||
* Get a single character for a vertical divider left
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVerticalLeft();
|
||||
|
||||
/**
|
||||
* Get a single character for a horizontal divider down
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontalDown();
|
||||
|
||||
/**
|
||||
* Get a single character for a horizontal divider up
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontalUp();
|
||||
}
|
176
airtime_mvc/library/Zend/Text/Table/Decorator/Unicode.php
Normal file
176
airtime_mvc/library/Zend/Text/Table/Decorator/Unicode.php
Normal file
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Unicode.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Text_Table_Decorator_Interface
|
||||
*/
|
||||
require_once 'Zend/Text/Table/Decorator/Interface.php';
|
||||
|
||||
/**
|
||||
* Unicode Decorator for Zend_Text_Table
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @uses Zend_Text_Table_Decorator_Interface
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Text_Table_Decorator_Unicode implements Zend_Text_Table_Decorator_Interface
|
||||
{
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopLeft()
|
||||
{
|
||||
return $this->_uniChar(0x250C);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopRight()
|
||||
{
|
||||
return $this->_uniChar(0x2510);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomLeft()
|
||||
{
|
||||
return $this->_uniChar(0x2514);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomRight()
|
||||
{
|
||||
return $this->_uniChar(0x2518);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVertical()
|
||||
{
|
||||
return $this->_uniChar(0x2502);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontal()
|
||||
{
|
||||
return $this->_uniChar(0x2500);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCross()
|
||||
{
|
||||
return $this->_uniChar(0x253C);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVerticalRight()
|
||||
{
|
||||
return $this->_uniChar(0x251C);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVerticalLeft()
|
||||
{
|
||||
return $this->_uniChar(0x2524);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontalDown()
|
||||
{
|
||||
return $this->_uniChar(0x252C);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined by Zend_Text_Table_Decorator_Interface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHorizontalUp()
|
||||
{
|
||||
return $this->_uniChar(0x2534);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert am unicode character code to a character
|
||||
*
|
||||
* @param integer $code
|
||||
* @return string|false
|
||||
*/
|
||||
protected function _uniChar($code)
|
||||
{
|
||||
if ($code <= 0x7F) {
|
||||
$char = chr($code);
|
||||
} else if ($code <= 0x7FF) {
|
||||
$char = chr(0xC0 | $code >> 6)
|
||||
. chr(0x80 | $code & 0x3F);
|
||||
} else if ($code <= 0xFFFF) {
|
||||
$char = chr(0xE0 | $code >> 12)
|
||||
. chr(0x80 | $code >> 6 & 0x3F)
|
||||
. chr(0x80 | $code & 0x3F);
|
||||
} else if ($code <= 0x10FFFF) {
|
||||
$char = chr(0xF0 | $code >> 18)
|
||||
. chr(0x80 | $code >> 12 & 0x3F)
|
||||
. chr(0x80 | $code >> 6 & 0x3F)
|
||||
. chr(0x80 | $code & 0x3F);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $char;
|
||||
}
|
||||
}
|
38
airtime_mvc/library/Zend/Text/Table/Exception.php
Normal file
38
airtime_mvc/library/Zend/Text/Table/Exception.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Text_Exception
|
||||
*/
|
||||
require_once 'Zend/Text/Exception.php';
|
||||
|
||||
/**
|
||||
* Exception class for Zend_Text_Table
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @uses Zend_Text_Exception
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Text_Table_Exception extends Zend_Text_Exception
|
||||
{
|
||||
}
|
215
airtime_mvc/library/Zend/Text/Table/Row.php
Normal file
215
airtime_mvc/library/Zend/Text/Table/Row.php
Normal file
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Row.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Row class for Zend_Text_Table
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Table
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Text_Table_Row
|
||||
{
|
||||
/**
|
||||
* List of all columns
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_columns = array();
|
||||
|
||||
/**
|
||||
* Temporary stored column widths
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_columnWidths = null;
|
||||
|
||||
/**
|
||||
* Create a new column and append it to the row
|
||||
*
|
||||
* @param string $content
|
||||
* @param array $options
|
||||
* @return Zend_Text_Table_Row
|
||||
*/
|
||||
public function createColumn($content, array $options = null)
|
||||
{
|
||||
$align = null;
|
||||
$colSpan = null;
|
||||
$encoding = null;
|
||||
|
||||
if ($options !== null) {
|
||||
extract($options, EXTR_IF_EXISTS);
|
||||
}
|
||||
|
||||
require_once 'Zend/Text/Table/Column.php';
|
||||
|
||||
$column = new Zend_Text_Table_Column($content, $align, $colSpan, $encoding);
|
||||
|
||||
$this->appendColumn($column);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a column to the row
|
||||
*
|
||||
* @param Zend_Text_Table_Column $column The column to append to the row
|
||||
* @return Zend_Text_Table_Row
|
||||
*/
|
||||
public function appendColumn(Zend_Text_Table_Column $column)
|
||||
{
|
||||
$this->_columns[] = $column;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a column by it's index
|
||||
*
|
||||
* Returns null, when the index is out of range
|
||||
*
|
||||
* @param integer $index
|
||||
* @return Zend_Text_Table_Column|null
|
||||
*/
|
||||
public function getColumn($index)
|
||||
{
|
||||
if (!isset($this->_columns[$index])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->_columns[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all columns of the row
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->_columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the widths of all columns, which were rendered last
|
||||
*
|
||||
* @throws Zend_Text_Table_Exception When no columns were rendered yet
|
||||
* @return integer
|
||||
*/
|
||||
public function getColumnWidths()
|
||||
{
|
||||
if ($this->_columnWidths === null) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('No columns were rendered yet');
|
||||
}
|
||||
|
||||
return $this->_columnWidths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the row
|
||||
*
|
||||
* @param array $columnWidths Width of all columns
|
||||
* @param Zend_Text_Table_Decorator_Interface $decorator Decorator for the row borders
|
||||
* @param integer $padding Padding for the columns
|
||||
* @throws Zend_Text_Table_Exception When there are too many columns
|
||||
* @return string
|
||||
*/
|
||||
public function render(array $columnWidths,
|
||||
Zend_Text_Table_Decorator_Interface $decorator,
|
||||
$padding = 0)
|
||||
{
|
||||
// Prepare an array to store all column widths
|
||||
$this->_columnWidths = array();
|
||||
|
||||
// If there is no single column, create a column which spans over the
|
||||
// entire row
|
||||
if (count($this->_columns) === 0) {
|
||||
require_once 'Zend/Text/Table/Column.php';
|
||||
$this->appendColumn(new Zend_Text_Table_Column(null, null, count($columnWidths)));
|
||||
}
|
||||
|
||||
// First we have to render all columns, to get the maximum height
|
||||
$renderedColumns = array();
|
||||
$maxHeight = 0;
|
||||
$colNum = 0;
|
||||
foreach ($this->_columns as $column) {
|
||||
// Get the colspan of the column
|
||||
$colSpan = $column->getColSpan();
|
||||
|
||||
// Verify if there are enough column widths defined
|
||||
if (($colNum + $colSpan) > count($columnWidths)) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('Too many columns');
|
||||
}
|
||||
|
||||
// Calculate the column width
|
||||
$columnWidth = ($colSpan - 1 + array_sum(array_slice($columnWidths,
|
||||
$colNum,
|
||||
$colSpan)));
|
||||
|
||||
// Render the column and split it's lines into an array
|
||||
$result = explode("\n", $column->render($columnWidth, $padding));
|
||||
|
||||
// Store the width of the rendered column
|
||||
$this->_columnWidths[] = $columnWidth;
|
||||
|
||||
// Store the rendered column and calculate the new max height
|
||||
$renderedColumns[] = $result;
|
||||
$maxHeight = max($maxHeight, count($result));
|
||||
|
||||
// Set up the internal column number
|
||||
$colNum += $colSpan;
|
||||
}
|
||||
|
||||
// If the row doesnt contain enough columns to fill the entire row, fill
|
||||
// it with an empty column
|
||||
if ($colNum < count($columnWidths)) {
|
||||
$remainingWidth = (count($columnWidths) - $colNum - 1) +
|
||||
array_sum(array_slice($columnWidths,
|
||||
$colNum));
|
||||
$renderedColumns[] = array(str_repeat(' ', $remainingWidth));
|
||||
|
||||
$this->_columnWidths[] = $remainingWidth;
|
||||
}
|
||||
|
||||
// Add each single column line to the result
|
||||
$result = '';
|
||||
for ($line = 0; $line < $maxHeight; $line++) {
|
||||
$result .= $decorator->getVertical();
|
||||
|
||||
foreach ($renderedColumns as $renderedColumn) {
|
||||
if (isset($renderedColumn[$line]) === true) {
|
||||
$result .= $renderedColumn[$line];
|
||||
} else {
|
||||
$result .= str_repeat(' ', strlen($renderedColumn[0]));
|
||||
}
|
||||
|
||||
$result .= $decorator->getVertical();
|
||||
}
|
||||
|
||||
$result .= "\n";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue