adding zend project folders into old campcaster.
This commit is contained in:
parent
56abfaf28e
commit
7ef0c18b26
4045 changed files with 1054952 additions and 0 deletions
38
library/Zend/Text/Exception.php
Normal file
38
library/Zend/Text/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
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend_Exception
|
||||
*/
|
||||
require_once 'Zend/Exception.php';
|
||||
|
||||
/**
|
||||
* Exception class for Zend_Text
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text
|
||||
* @uses Zend_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_Exception extends Zend_Exception
|
||||
{
|
||||
}
|
1232
library/Zend/Text/Figlet.php
Normal file
1232
library/Zend/Text/Figlet.php
Normal file
File diff suppressed because it is too large
Load diff
38
library/Zend/Text/Figlet/Exception.php
Normal file
38
library/Zend/Text/Figlet/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_Figlet
|
||||
* @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_Figlet
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text_Figlet
|
||||
* @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_Figlet_Exception extends Zend_Text_Exception
|
||||
{
|
||||
}
|
753
library/Zend/Text/Figlet/zend-framework.flf
Normal file
753
library/Zend/Text/Figlet/zend-framework.flf
Normal file
|
@ -0,0 +1,753 @@
|
|||
flf2a$ 7 6 10 51 22 0 7987
|
||||
Author : Wil Sinclair
|
||||
Date : 2008/6/26 20:34:25
|
||||
Version: 1.0
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
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.
|
||||
|
||||
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
$ #
|
||||
$ #
|
||||
$ #
|
||||
$ #
|
||||
$ #
|
||||
$ #
|
||||
$ ##
|
||||
__ #
|
||||
/ \\ #
|
||||
| || #
|
||||
|$ || #
|
||||
\// #
|
||||
[]| #
|
||||
##
|
||||
__ __ #
|
||||
/ /// //#
|
||||
/_///_// #
|
||||
`-` `-` #
|
||||
#
|
||||
#
|
||||
##
|
||||
##
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
_ #
|
||||
| ||_ #
|
||||
/ ___// #
|
||||
\___ \\ #
|
||||
/ $ // #
|
||||
/_ // #
|
||||
`-|_|| ##
|
||||
%#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
&#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
'#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
(#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
)#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
*#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
#
|
||||
_ #
|
||||
_| || #
|
||||
|_ $ _|| #
|
||||
`-|_|-` #
|
||||
- #
|
||||
##
|
||||
,#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
#
|
||||
#
|
||||
,------,,#
|
||||
'======'' #
|
||||
#
|
||||
#
|
||||
##
|
||||
.#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
/#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
___ #
|
||||
/ _ \\ #
|
||||
| |$| || #
|
||||
| |_| || #
|
||||
\___// #
|
||||
`---` #
|
||||
##
|
||||
__ #
|
||||
/ || #
|
||||
| || #
|
||||
_| ||_ #
|
||||
|__$__|| #
|
||||
`-----` #
|
||||
##
|
||||
_____ #
|
||||
\___ \\ #
|
||||
/ ___// #
|
||||
| $ \\ #
|
||||
|_____\\ #
|
||||
`------` #
|
||||
##
|
||||
_____ #
|
||||
|___ \\ #
|
||||
__$\ // #
|
||||
__$/ \\ #
|
||||
|_____// #
|
||||
`-----` #
|
||||
##
|
||||
__ #
|
||||
/ || #
|
||||
/ /|||_ #
|
||||
/__ $ _||#
|
||||
|_|| #
|
||||
`-` #
|
||||
##
|
||||
_____ #
|
||||
/ ___// #
|
||||
/___ \\ #
|
||||
/ $ // #
|
||||
/___// #
|
||||
`----` #
|
||||
##
|
||||
__ #
|
||||
/ // #
|
||||
/ // #
|
||||
/ __ \\ #
|
||||
\____// #
|
||||
`---` #
|
||||
##
|
||||
______ #
|
||||
|___ // #
|
||||
/ // #
|
||||
| || #
|
||||
|_|| #
|
||||
`-` #
|
||||
##
|
||||
____ #
|
||||
/ \\ #
|
||||
\ -- // #
|
||||
/ -- \\ #
|
||||
\____// #
|
||||
`----` #
|
||||
##
|
||||
____ #
|
||||
/ __ \\ #
|
||||
\__ || #
|
||||
/ // #
|
||||
/_// #
|
||||
`-` #
|
||||
##
|
||||
#
|
||||
#
|
||||
[]| #
|
||||
#
|
||||
[]| #
|
||||
#
|
||||
##
|
||||
#
|
||||
_ #
|
||||
[_]| #
|
||||
_ #
|
||||
| ]] #
|
||||
|// #
|
||||
' ##
|
||||
<#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
#
|
||||
______ #
|
||||
/_____// #
|
||||
/_____// #
|
||||
`-----` #
|
||||
#
|
||||
##
|
||||
>#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
?#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
@#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
___ #
|
||||
/ _ \\ #
|
||||
/ //\ \\ #
|
||||
| ___ ||#
|
||||
|_|| |_||#
|
||||
`-` `-` #
|
||||
##
|
||||
______ #
|
||||
| \\ #
|
||||
| --$ // #
|
||||
| -- \\ #
|
||||
|______// #
|
||||
`------` #
|
||||
##
|
||||
_____ #
|
||||
/ ____|| #
|
||||
/ //---`' #
|
||||
\ \\___ #
|
||||
\_____|| #
|
||||
`----` #
|
||||
##
|
||||
_____ #
|
||||
| __ \\ #
|
||||
| |$ \ || #
|
||||
| |__/ || #
|
||||
|_____// #
|
||||
-----` #
|
||||
##
|
||||
_____ #
|
||||
| ___|| #
|
||||
| ||__ #
|
||||
| ||__ #
|
||||
|_____|| #
|
||||
`-----` #
|
||||
##
|
||||
______ #
|
||||
/_____// #
|
||||
`____ ` #
|
||||
/___// #
|
||||
`__ ` #
|
||||
/_// #
|
||||
`-` ##
|
||||
_____ #
|
||||
/ ___|| #
|
||||
| //$__ #
|
||||
| \\_\ || #
|
||||
\____// #
|
||||
`---` #
|
||||
##
|
||||
__ _ #
|
||||
| || | || #
|
||||
| '--' || #
|
||||
| .--. || #
|
||||
|_|| |_|| #
|
||||
`-` `-` #
|
||||
##
|
||||
______ #
|
||||
/_ _// #
|
||||
-| ||- #
|
||||
_| ||_ #
|
||||
/_____// #
|
||||
`-----` #
|
||||
##
|
||||
______ #
|
||||
/_ _// #
|
||||
| || #
|
||||
_| || #
|
||||
/__// #
|
||||
`--` #
|
||||
##
|
||||
_ __ #
|
||||
| |/ // #
|
||||
| ' // #
|
||||
| . \\ #
|
||||
|_|\_\\ #
|
||||
`-` --` #
|
||||
##
|
||||
__ #
|
||||
| || #
|
||||
| || #
|
||||
| ||__ #
|
||||
|____// #
|
||||
`----` #
|
||||
##
|
||||
_ _ #
|
||||
| \ / || #
|
||||
| \/ || #
|
||||
| . . || #
|
||||
|_|\/|_|| #
|
||||
`-` `-` #
|
||||
##
|
||||
_ _ #
|
||||
| \| || #
|
||||
| ' || #
|
||||
| . || #
|
||||
|_|\_|| #
|
||||
`-` -` #
|
||||
##
|
||||
___ #
|
||||
/ _ \\ #
|
||||
| /$\ || #
|
||||
| \_/ || #
|
||||
\___// #
|
||||
`---` #
|
||||
##
|
||||
____ #
|
||||
| _ \\ #
|
||||
| |_| || #
|
||||
| .__// #
|
||||
|_|--` #
|
||||
`-` #
|
||||
##
|
||||
___ #
|
||||
/ _ \\ #
|
||||
| /$\ || #
|
||||
| \_/ || #
|
||||
\___ \\ #
|
||||
`---` #
|
||||
##
|
||||
____ #
|
||||
| _ \\ #
|
||||
| |_| || #
|
||||
| . // #
|
||||
|_|\_\\ #
|
||||
`-` --` #
|
||||
##
|
||||
_____ #
|
||||
/ ___// #
|
||||
\___ \\ #
|
||||
/ $ // #
|
||||
/____// #
|
||||
`-----` #
|
||||
##
|
||||
______ #
|
||||
/_ _// #
|
||||
`-| |,- #
|
||||
| || #
|
||||
|_|| #
|
||||
`-`' #
|
||||
##
|
||||
_ _ #
|
||||
| || | || #
|
||||
| || | || #
|
||||
| \\_/ || #
|
||||
\____// #
|
||||
`---` #
|
||||
##
|
||||
__ __ #
|
||||
\ \\ / // #
|
||||
\ \/ // #
|
||||
\ // #
|
||||
\// #
|
||||
` #
|
||||
##
|
||||
_ _ #
|
||||
| | | || #
|
||||
| |/\| || #
|
||||
| /\ || #
|
||||
|_// \_|| #
|
||||
`-` `-` #
|
||||
##
|
||||
__ __ #
|
||||
\ \\/ // #
|
||||
\ $ // #
|
||||
/ . \\ #
|
||||
/_//\_\\ #
|
||||
`-` --` #
|
||||
##
|
||||
__ __ #
|
||||
\ \\/ // #
|
||||
\ ` // #
|
||||
| || #
|
||||
|_|| #
|
||||
`-`' #
|
||||
##
|
||||
______ #
|
||||
|____ // #
|
||||
/ // #
|
||||
/ // #
|
||||
/ //__ #
|
||||
/______|| #
|
||||
`------` ##
|
||||
[#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
\#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
]#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
^#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
_#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
`#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
___ #
|
||||
/ _ \\ #
|
||||
/ //\ \\ #
|
||||
| ___ ||#
|
||||
|_|| |_||#
|
||||
`-` `-` #
|
||||
##
|
||||
______ #
|
||||
| \\ #
|
||||
| --$ // #
|
||||
| -- \\ #
|
||||
|______// #
|
||||
`------` #
|
||||
##
|
||||
_____ #
|
||||
/ ____|| #
|
||||
/ //---`' #
|
||||
\ \\___ #
|
||||
\_____|| #
|
||||
`----` #
|
||||
##
|
||||
_____ #
|
||||
| __ \\ #
|
||||
| |$ \ || #
|
||||
| |__/ || #
|
||||
|_____// #
|
||||
-----` #
|
||||
##
|
||||
_____ #
|
||||
| ___|| #
|
||||
| ||__ #
|
||||
| ||__ #
|
||||
|_____|| #
|
||||
`-----` #
|
||||
##
|
||||
______ #
|
||||
/_____// #
|
||||
`____ ` #
|
||||
/___// #
|
||||
`__ ` #
|
||||
/_// #
|
||||
`-` ##
|
||||
_____ #
|
||||
/ ___|| #
|
||||
| //$__ #
|
||||
| \\_\ || #
|
||||
\____// #
|
||||
`---` #
|
||||
##
|
||||
__ _ #
|
||||
| || | || #
|
||||
| '--' || #
|
||||
| .--. || #
|
||||
|_|| |_|| #
|
||||
`-` `-` #
|
||||
##
|
||||
______ #
|
||||
/_ _// #
|
||||
-| ||- #
|
||||
_| ||_ #
|
||||
/_____// #
|
||||
`-----` #
|
||||
##
|
||||
______ #
|
||||
/_ _// #
|
||||
| || #
|
||||
_| || #
|
||||
/__// #
|
||||
`--` #
|
||||
##
|
||||
_ __ #
|
||||
| |/ // #
|
||||
| ' // #
|
||||
| . \\ #
|
||||
|_|\_\\ #
|
||||
`-` --` #
|
||||
##
|
||||
__ #
|
||||
| || #
|
||||
| || #
|
||||
| ||__ #
|
||||
|____// #
|
||||
`----` #
|
||||
##
|
||||
_ _ #
|
||||
| \ / || #
|
||||
| \/ || #
|
||||
| . . || #
|
||||
|_|\/|_|| #
|
||||
`-` `-` #
|
||||
##
|
||||
_ _ #
|
||||
| \| || #
|
||||
| ' || #
|
||||
| . || #
|
||||
|_|\_|| #
|
||||
`-` -` #
|
||||
##
|
||||
___ #
|
||||
/ _ \\ #
|
||||
| /$\ || #
|
||||
| \_/ || #
|
||||
\___// #
|
||||
`---` #
|
||||
##
|
||||
#
|
||||
____ #
|
||||
| \\ #
|
||||
| [] || #
|
||||
| __// #
|
||||
|_|`-` #
|
||||
`-` ##
|
||||
#
|
||||
___ #
|
||||
/ || #
|
||||
| [] || #
|
||||
\__ || #
|
||||
-|_|| #
|
||||
`-` ##
|
||||
____ #
|
||||
| _ \\ #
|
||||
| |_| || #
|
||||
| . // #
|
||||
|_|\_\\ #
|
||||
`-` --` #
|
||||
##
|
||||
_____ #
|
||||
/ ___// #
|
||||
\___ \\ #
|
||||
/ $ // #
|
||||
/____// #
|
||||
`-----` #
|
||||
##
|
||||
______ #
|
||||
/_ _// #
|
||||
`-| |,- #
|
||||
| || #
|
||||
|_|| #
|
||||
`-`' #
|
||||
##
|
||||
_ _ #
|
||||
| || | || #
|
||||
| || | || #
|
||||
| \\_/ || #
|
||||
\____// #
|
||||
`---` #
|
||||
##
|
||||
__ __ #
|
||||
\ \\ / // #
|
||||
\ \/ // #
|
||||
\ // #
|
||||
\// #
|
||||
` #
|
||||
##
|
||||
_ _ #
|
||||
| | | || #
|
||||
| |/\| || #
|
||||
| /\ || #
|
||||
|_// \_|| #
|
||||
`-` `-` #
|
||||
##
|
||||
__ __ #
|
||||
\ \\/ // #
|
||||
\ $ // #
|
||||
/ . \\ #
|
||||
/_//\_\\ #
|
||||
`-` --` #
|
||||
##
|
||||
__ __ #
|
||||
\ \\/ // #
|
||||
\ ` // #
|
||||
| || #
|
||||
|_|| #
|
||||
`-`' #
|
||||
##
|
||||
_____ #
|
||||
|__ // #
|
||||
/ // #
|
||||
/ //__ #
|
||||
/_____|| #
|
||||
`-----` #
|
||||
##
|
||||
{#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
|#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
}#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
~#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##
|
||||
[]|_[]| #
|
||||
/ _ \\ #
|
||||
/ //\ \\ #
|
||||
| $___$ ||#
|
||||
|_||$ |_||#
|
||||
`-` `-` #
|
||||
##
|
||||
[]|_[]| #
|
||||
/ _ \\ #
|
||||
| /$\ || #
|
||||
| \_/ || #
|
||||
\___// #
|
||||
---` #
|
||||
##
|
||||
[]| []| #
|
||||
| ||$| || #
|
||||
| ||$| || #
|
||||
| \\_/ || #
|
||||
\____// #
|
||||
`---` #
|
||||
##
|
||||
[]|_[]| #
|
||||
/ _ \\ #
|
||||
/ //\ \\ #
|
||||
| $___$ ||#
|
||||
|_||$ |_||#
|
||||
`-` `-` #
|
||||
##
|
||||
[]|_[]| #
|
||||
/ _ \\ #
|
||||
| /$\ || #
|
||||
| \_/ || #
|
||||
\___// #
|
||||
---` #
|
||||
##
|
||||
[]| []| #
|
||||
| ||$| || #
|
||||
| ||$| || #
|
||||
| \\_/ || #
|
||||
\____// #
|
||||
`---` #
|
||||
##
|
||||
,--. #
|
||||
| _$ \\ #
|
||||
| // #
|
||||
| |\ \\ #
|
||||
|$ ___\\ #
|
||||
|_|----` #
|
||||
- ##
|
||||
162 CENT SIGN
|
||||
_ #
|
||||
| || #
|
||||
/ __// #
|
||||
| (__` #
|
||||
\ \\ #
|
||||
|_|` #
|
||||
`-` ##
|
||||
215 MULTIPLICATION SIGN
|
||||
#
|
||||
#
|
||||
\\// #
|
||||
\\ #
|
||||
//\\ #
|
||||
#
|
||||
##
|
153
library/Zend/Text/MultiByte.php
Normal file
153
library/Zend/Text/MultiByte.php
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?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
|
||||
* @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: MultiByte.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend_Text_MultiByte contains multibyte safe string methods
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Text
|
||||
* @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_MultiByte
|
||||
{
|
||||
/**
|
||||
* Word wrap
|
||||
*
|
||||
* @param string $string
|
||||
* @param integer $width
|
||||
* @param string $break
|
||||
* @param boolean $cut
|
||||
* @param string $charset
|
||||
* @return string
|
||||
*/
|
||||
public static function wordWrap($string, $width = 75, $break = "\n", $cut = false, $charset = 'UTF-8')
|
||||
{
|
||||
$result = array();
|
||||
|
||||
while (($stringLength = iconv_strlen($string, $charset)) > 0) {
|
||||
$subString = iconv_substr($string, 0, $width, $charset);
|
||||
|
||||
if ($subString === $string) {
|
||||
$cutLength = null;
|
||||
} else {
|
||||
$nextChar = iconv_substr($string, $width, 1, $charset);
|
||||
|
||||
if ($nextChar === ' ' || $nextChar === $break) {
|
||||
$afterNextChar = iconv_substr($string, $width + 1, 1, $charset);
|
||||
|
||||
if ($afterNextChar === false) {
|
||||
$subString .= $nextChar;
|
||||
}
|
||||
|
||||
$cutLength = iconv_strlen($subString, $charset) + 1;
|
||||
} else {
|
||||
$spacePos = iconv_strrpos($subString, ' ', $charset);
|
||||
|
||||
if ($spacePos !== false) {
|
||||
$subString = iconv_substr($subString, 0, $spacePos, $charset);
|
||||
$cutLength = $spacePos + 1;
|
||||
} else if ($cut === false) {
|
||||
$spacePos = iconv_strpos($string, ' ', 0, $charset);
|
||||
|
||||
if ($spacePos !== false) {
|
||||
$subString = iconv_substr($string, 0, $spacePos, $charset);
|
||||
$cutLength = $spacePos + 1;
|
||||
} else {
|
||||
$subString = $string;
|
||||
$cutLength = null;
|
||||
}
|
||||
} else {
|
||||
$breakPos = iconv_strpos($subString, $break, 0, $charset);
|
||||
|
||||
if ($breakPos !== false) {
|
||||
$subString = iconv_substr($subString, 0, $breakPos, $charset);
|
||||
$cutLength = $breakPos + 1;
|
||||
} else {
|
||||
$subString = iconv_substr($subString, 0, $width, $charset);
|
||||
$cutLength = $width;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = $subString;
|
||||
|
||||
if ($cutLength !== null) {
|
||||
$string = iconv_substr($string, $cutLength, ($stringLength - $cutLength), $charset);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return implode($break, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* String padding
|
||||
*
|
||||
* @param string $input
|
||||
* @param integer $padLength
|
||||
* @param string $padString
|
||||
* @param integer $padType
|
||||
* @param string $charset
|
||||
* @return string
|
||||
*/
|
||||
public static function strPad($input, $padLength, $padString = ' ', $padType = STR_PAD_RIGHT, $charset = 'UTF-8')
|
||||
{
|
||||
$return = '';
|
||||
$lengthOfPadding = $padLength - iconv_strlen($input, $charset);
|
||||
$padStringLength = iconv_strlen($padString, $charset);
|
||||
|
||||
if ($padStringLength === 0 || $lengthOfPadding === 0) {
|
||||
$return = $input;
|
||||
} else {
|
||||
$repeatCount = floor($lengthOfPadding / $padStringLength);
|
||||
|
||||
if ($padType === STR_PAD_BOTH) {
|
||||
$lastStringLeft = '';
|
||||
$lastStringRight = '';
|
||||
$repeatCountLeft = $repeatCountRight = ($repeatCount - $repeatCount % 2) / 2;
|
||||
|
||||
$lastStringLength = $lengthOfPadding - 2 * $repeatCountLeft * $padStringLength;
|
||||
$lastStringLeftLength = $lastStringRightLength = floor($lastStringLength / 2);
|
||||
$lastStringRightLength += $lastStringLength % 2;
|
||||
|
||||
$lastStringLeft = iconv_substr($padString, 0, $lastStringLeftLength, $charset);
|
||||
$lastStringRight = iconv_substr($padString, 0, $lastStringRightLength, $charset);
|
||||
|
||||
$return = str_repeat($padString, $repeatCountLeft) . $lastStringLeft
|
||||
. $input
|
||||
. str_repeat($padString, $repeatCountRight) . $lastStringRight;
|
||||
} else {
|
||||
$lastString = iconv_substr($padString, 0, $lengthOfPadding % $padStringLength, $charset);
|
||||
|
||||
if ($padType === STR_PAD_LEFT) {
|
||||
$return = str_repeat($padString, $repeatCount) . $lastString . $input;
|
||||
} else {
|
||||
$return = $input . str_repeat($padString, $repeatCount) . $lastString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
532
library/Zend/Text/Table.php
Normal file
532
library/Zend/Text/Table.php
Normal file
|
@ -0,0 +1,532 @@
|
|||
<?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: Table.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Zend_Text_Table enables developers to create tables out of characters
|
||||
*
|
||||
* @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
|
||||
{
|
||||
/**
|
||||
* Auto seperator settings
|
||||
*/
|
||||
const AUTO_SEPARATE_NONE = 0x0;
|
||||
const AUTO_SEPARATE_HEADER = 0x1;
|
||||
const AUTO_SEPARATE_FOOTER = 0x2;
|
||||
const AUTO_SEPARATE_ALL = 0x4;
|
||||
|
||||
/**
|
||||
* Decorator used for the table borders
|
||||
*
|
||||
* @var Zend_Text_Table_Decorator_Interface
|
||||
*/
|
||||
protected $_decorator = null;
|
||||
|
||||
/**
|
||||
* List of all column widths
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_columnWidths = null;
|
||||
|
||||
/**
|
||||
* Rows of the table
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_rows = array();
|
||||
|
||||
/**
|
||||
* Auto separation mode
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_autoSeparate = self::AUTO_SEPARATE_ALL;
|
||||
|
||||
/**
|
||||
* Padding for columns
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_padding = 0;
|
||||
|
||||
/**
|
||||
* Default column aligns for rows created by appendRow(array $data)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_defaultColumnAligns = array();
|
||||
|
||||
/**
|
||||
* Plugin loader for decorators
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_pluginLoader = null;
|
||||
|
||||
/**
|
||||
* Charset which is used for input by default
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_inputCharset = 'utf-8';
|
||||
|
||||
/**
|
||||
* Charset which is used internally
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_outputCharset = 'utf-8';
|
||||
|
||||
/**
|
||||
* Option keys to skip when calling setOptions()
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_skipOptions = array(
|
||||
'options',
|
||||
'config',
|
||||
'defaultColumnAlign',
|
||||
);
|
||||
|
||||
/**
|
||||
* Create a basic table object
|
||||
*
|
||||
* @param array $columnsWidths List of all column widths
|
||||
* @param Zend_Config|array $options Configuration options
|
||||
* @throws Zend_Text_Table_Exception When no columns widths were set
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
// Set options
|
||||
if (is_array($options)) {
|
||||
$this->setOptions($options);
|
||||
} else if ($options instanceof Zend_Config) {
|
||||
$this->setConfig($options);
|
||||
}
|
||||
|
||||
// Check if column widths were set
|
||||
// @todo When column widths were not set, assume auto-sizing
|
||||
if ($this->_columnWidths === null) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('You must define the column widths');
|
||||
}
|
||||
|
||||
// If no decorator was given, use default unicode decorator
|
||||
if ($this->_decorator === null) {
|
||||
if (self::getOutputCharset() === 'utf-8') {
|
||||
$this->setDecorator('unicode');
|
||||
} else {
|
||||
$this->setDecorator('ascii');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options from array
|
||||
*
|
||||
* @param array $options Configuration for Zend_Text_Table
|
||||
* @return Zend_Text_Table
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
if (in_array(strtolower($key), $this->_skipOptions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = 'set' . ucfirst($key);
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options from config object
|
||||
*
|
||||
* @param Zend_Config $config Configuration for Zend_Text_Table
|
||||
* @return Zend_Text_Table
|
||||
*/
|
||||
public function setConfig(Zend_Config $config)
|
||||
{
|
||||
return $this->setOptions($config->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set column widths
|
||||
*
|
||||
* @param array $columnWidths Widths of all columns
|
||||
* @throws Zend_Text_Table_Exception When no columns were supplied
|
||||
* @throws Zend_Text_Table_Exception When a column has an invalid width
|
||||
* @return Zend_Text_Table
|
||||
*/
|
||||
public function setColumnWidths(array $columnWidths)
|
||||
{
|
||||
if (count($columnWidths) === 0) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('You must supply at least one column');
|
||||
}
|
||||
|
||||
foreach ($columnWidths as $columnNum => $columnWidth) {
|
||||
if (is_int($columnWidth) === false or $columnWidth < 1) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('Column ' . $columnNum . ' has an invalid'
|
||||
. ' column width');
|
||||
}
|
||||
}
|
||||
|
||||
$this->_columnWidths = $columnWidths;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set auto separation mode
|
||||
*
|
||||
* @param integer $autoSeparate Auto separation mode
|
||||
* @return Zend_Text_Table
|
||||
*/
|
||||
public function setAutoSeparate($autoSeparate)
|
||||
{
|
||||
$this->_autoSeparate = (int) $autoSeparate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set decorator
|
||||
*
|
||||
* @param Zend_Text_Table_Decorator_Interface|string $decorator Decorator to use
|
||||
* @return Zend_Text_Table
|
||||
*/
|
||||
public function setDecorator($decorator)
|
||||
{
|
||||
if ($decorator instanceof Zend_Text_Table_Decorator_Interface) {
|
||||
$this->_decorator = $decorator;
|
||||
} else {
|
||||
$classname = $this->getPluginLoader()->load($decorator);
|
||||
$this->_decorator = new $classname;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the column padding
|
||||
*
|
||||
* @param integer $padding The padding for the columns
|
||||
* @return Zend_Text_Table
|
||||
*/
|
||||
public function setPadding($padding)
|
||||
{
|
||||
$this->_padding = max(0, (int) $padding);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin loader for decorators
|
||||
*
|
||||
* @return Zend_Loader_PluginLoader
|
||||
*/
|
||||
public function getPluginLoader()
|
||||
{
|
||||
if ($this->_pluginLoader === null) {
|
||||
$prefix = 'Zend_Text_Table_Decorator_';
|
||||
$pathPrefix = 'Zend/Text/Table/Decorator/';
|
||||
|
||||
require_once 'Zend/Loader/PluginLoader.php';
|
||||
$this->_pluginLoader = new Zend_Loader_PluginLoader(array($prefix => $pathPrefix));
|
||||
}
|
||||
|
||||
return $this->_pluginLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default column align for rows created by appendRow(array $data)
|
||||
*
|
||||
* @param integer $columnNum
|
||||
* @param string $align
|
||||
* @return Zend_Text_Table
|
||||
*/
|
||||
public function setDefaultColumnAlign($columnNum, $align)
|
||||
{
|
||||
$this->_defaultColumnAligns[$columnNum] = $align;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the input charset for column contents
|
||||
*
|
||||
* @param string $charset
|
||||
*/
|
||||
public static function setInputCharset($charset)
|
||||
{
|
||||
self::$_inputCharset = strtolower($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the input charset for column contents
|
||||
*
|
||||
* @param string $charset
|
||||
*/
|
||||
public static function getInputCharset()
|
||||
{
|
||||
return self::$_inputCharset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the output charset for column contents
|
||||
*
|
||||
* @param string $charset
|
||||
*/
|
||||
public static function setOutputCharset($charset)
|
||||
{
|
||||
self::$_outputCharset = strtolower($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the output charset for column contents
|
||||
*
|
||||
* @param string $charset
|
||||
*/
|
||||
public static function getOutputCharset()
|
||||
{
|
||||
return self::$_outputCharset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a row to the table
|
||||
*
|
||||
* @param array|Zend_Text_Table_Row $row The row to append to the table
|
||||
* @throws Zend_Text_Table_Exception When $row is neither an array nor Zend_Zext_Table_Row
|
||||
* @throws Zend_Text_Table_Exception When a row contains too many columns
|
||||
* @return Zend_Text_Table
|
||||
*/
|
||||
public function appendRow($row)
|
||||
{
|
||||
if (!is_array($row) && !($row instanceof Zend_Text_Table_Row)) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('$row must be an array or instance of Zend_Text_Table_Row');
|
||||
}
|
||||
|
||||
if (is_array($row)) {
|
||||
if (count($row) > count($this->_columnWidths)) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('Row contains too many columns');
|
||||
}
|
||||
|
||||
require_once 'Zend/Text/Table/Row.php';
|
||||
|
||||
$data = $row;
|
||||
$row = new Zend_Text_Table_Row();
|
||||
$colNum = 0;
|
||||
foreach ($data as $columnData) {
|
||||
if (isset($this->_defaultColumnAligns[$colNum])) {
|
||||
$align = $this->_defaultColumnAligns[$colNum];
|
||||
} else {
|
||||
$align = null;
|
||||
}
|
||||
|
||||
$row->appendColumn(new Zend_Text_Table_Column($columnData, $align));
|
||||
$colNum++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_rows[] = $row;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the table
|
||||
*
|
||||
* @throws Zend_Text_Table_Exception When no rows were added to the table
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
// There should be at least one row
|
||||
if (count($this->_rows) === 0) {
|
||||
require_once 'Zend/Text/Table/Exception.php';
|
||||
throw new Zend_Text_Table_Exception('No rows were added to the table yet');
|
||||
}
|
||||
|
||||
// Initiate the result variable
|
||||
$result = '';
|
||||
|
||||
// Count total columns
|
||||
$totalNumColumns = count($this->_columnWidths);
|
||||
|
||||
// Now render all rows, starting from the first one
|
||||
$numRows = count($this->_rows);
|
||||
foreach ($this->_rows as $rowNum => $row) {
|
||||
// Get all column widths
|
||||
if (isset($columnWidths) === true) {
|
||||
$lastColumnWidths = $columnWidths;
|
||||
}
|
||||
|
||||
$renderedRow = $row->render($this->_columnWidths, $this->_decorator, $this->_padding);
|
||||
$columnWidths = $row->getColumnWidths();
|
||||
$numColumns = count($columnWidths);
|
||||
|
||||
// Check what we have to draw
|
||||
if ($rowNum === 0) {
|
||||
// If this is the first row, draw the table top
|
||||
$result .= $this->_decorator->getTopLeft();
|
||||
|
||||
foreach ($columnWidths as $columnNum => $columnWidth) {
|
||||
$result .= str_repeat($this->_decorator->getHorizontal(),
|
||||
$columnWidth);
|
||||
|
||||
if (($columnNum + 1) === $numColumns) {
|
||||
$result .= $this->_decorator->getTopRight();
|
||||
} else {
|
||||
$result .= $this->_decorator->getHorizontalDown();
|
||||
}
|
||||
}
|
||||
|
||||
$result .= "\n";
|
||||
} else {
|
||||
// Else check if we have to draw the row separator
|
||||
if ($this->_autoSeparate & self::AUTO_SEPARATE_ALL) {
|
||||
$drawSeparator = true;
|
||||
} else if ($rowNum === 1 && $this->_autoSeparate & self::AUTO_SEPARATE_HEADER) {
|
||||
$drawSeparator = true;
|
||||
} else if ($rowNum === ($numRows - 1) && $this->_autoSeparate & self::AUTO_SEPARATE_FOOTER) {
|
||||
$drawSeparator = true;
|
||||
} else {
|
||||
$drawSeparator = false;
|
||||
}
|
||||
|
||||
if ($drawSeparator) {
|
||||
$result .= $this->_decorator->getVerticalRight();
|
||||
|
||||
$currentUpperColumn = 0;
|
||||
$currentLowerColumn = 0;
|
||||
$currentUpperWidth = 0;
|
||||
$currentLowerWidth = 0;
|
||||
|
||||
// Loop through all column widths
|
||||
foreach ($this->_columnWidths as $columnNum => $columnWidth) {
|
||||
// Add the horizontal line
|
||||
$result .= str_repeat($this->_decorator->getHorizontal(),
|
||||
$columnWidth);
|
||||
|
||||
// If this is the last line, break out
|
||||
if (($columnNum + 1) === $totalNumColumns) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Else check, which connector style has to be used
|
||||
$connector = 0x0;
|
||||
$currentUpperWidth += $columnWidth;
|
||||
$currentLowerWidth += $columnWidth;
|
||||
|
||||
if ($lastColumnWidths[$currentUpperColumn] === $currentUpperWidth) {
|
||||
$connector |= 0x1;
|
||||
$currentUpperColumn += 1;
|
||||
$currentUpperWidth = 0;
|
||||
} else {
|
||||
$currentUpperWidth += 1;
|
||||
}
|
||||
|
||||
if ($columnWidths[$currentLowerColumn] === $currentLowerWidth) {
|
||||
$connector |= 0x2;
|
||||
$currentLowerColumn += 1;
|
||||
$currentLowerWidth = 0;
|
||||
} else {
|
||||
$currentLowerWidth += 1;
|
||||
}
|
||||
|
||||
switch ($connector) {
|
||||
case 0x0:
|
||||
$result .= $this->_decorator->getHorizontal();
|
||||
break;
|
||||
|
||||
case 0x1:
|
||||
$result .= $this->_decorator->getHorizontalUp();
|
||||
break;
|
||||
|
||||
case 0x2:
|
||||
$result .= $this->_decorator->getHorizontalDown();
|
||||
break;
|
||||
|
||||
case 0x3:
|
||||
$result .= $this->_decorator->getCross();
|
||||
break;
|
||||
|
||||
default:
|
||||
// This can never happen, but the CS tells I have to have it ...
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$result .= $this->_decorator->getVerticalLeft() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Add the rendered row to the result
|
||||
$result .= $renderedRow;
|
||||
|
||||
// If this is the last row, draw the table bottom
|
||||
if (($rowNum + 1) === $numRows) {
|
||||
$result .= $this->_decorator->getBottomLeft();
|
||||
|
||||
foreach ($columnWidths as $columnNum => $columnWidth) {
|
||||
$result .= str_repeat($this->_decorator->getHorizontal(),
|
||||
$columnWidth);
|
||||
|
||||
if (($columnNum + 1) === $numColumns) {
|
||||
$result .= $this->_decorator->getBottomRight();
|
||||
} else {
|
||||
$result .= $this->_decorator->getHorizontalUp();
|
||||
}
|
||||
}
|
||||
|
||||
$result .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method which returns the rendered table
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
try {
|
||||
return $this->render();
|
||||
} catch (Exception $e) {
|
||||
trigger_error($e->getMessage(), E_USER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
243
library/Zend/Text/Table/Column.php
Normal file
243
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
library/Zend/Text/Table/Decorator/Ascii.php
Normal file
147
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
library/Zend/Text/Table/Decorator/Interface.php
Normal file
108
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
library/Zend/Text/Table/Decorator/Unicode.php
Normal file
176
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
library/Zend/Text/Table/Exception.php
Normal file
38
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
library/Zend/Text/Table/Row.php
Normal file
215
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