Source for file Csv.php
Documentation is available at Csv.php
* A Framework for Creating and Using Complex Web Elements
* The purpose of this framework is to provide a library of high-level objects
* to facilitate common HTML coding tasks, such as menus, tables, and forms.
* The intent is to reduce repetitive HTML coding as much as possible, replacing
* it with a combination of configuration files and style sheets with
* standardized naming conventions.
* This framework is built on and requires the
* {@link http://framework.zend.com/ Zend Framework}.
* @author Lyle Frost <lfrost@cnz.com>
* @copyright Copyright (c) 2006-2007 Citadel Network <{@link http://www.citadelnetwork.com/}>
* @license http://www.citadelnetwork.com/license/cnzframework New BSD License
* @version $Id: Csv.php 27 2007-07-19 18:47:54Z lfrost $
Zend_Loader::loadClass('Cnz_Html_Table');
* The data file is <i>name</i>.csv. The file is searched for first in the
* current directory, then in $_SERVER['DOCUMENT_ROOT'] . '/../dat/table/'
* @todo Add limit/offset functionality.
private $filename = NULL;
/* Methods ===========================================================*/
* action Form action for button press
* method Form method for button press
* param Parameter to pass with button press
* @param array $options Options
* @param Zend_Config $config Configuration
$filename = $this->name . '.' . self::FILE_EXT;
$filename = $_SERVER['DOCUMENT_ROOT'] . '/../dat/table/' . $filename;
$this->filename = $filename;
* @param mixed $v1 Value 1
* @param mixed $v2 Value 2
* @return int <, =, > 0 if $v1 <, =, > $v2
$columnOrder = self::ORDER_ASC;
if ($this->orderByArray[$columnName] == self::ORDER_DESC) $columnOrder = self::ORDER_DESC;
if ($columnNumber === false)
trigger_error("Unknown column name $columnName in sort callback.", E_USER_ERROR);
$result = (int) $v1[$columnName] - (int) $v2[$columnName];
$result = strcmp($v1[$columnName], $v2[$columnName]);
if ($columnOrder == self::ORDER_DESC) $result = - $result;
* Read table head and data from a CSV file into an array of table
* items. The column delimiter must be a comma, and the column
* enclosure character a double quotation mark.
* @return boolean Success
$fp = fopen($this->filename, 'r');
while (($data = fgetcsv($fp, 1000, ",")) !== FALSE)
if (!empty($this->orderByArray))
|