2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Merging the Limesurvey 1.91+ branch of queXS in to the trunk

This commit is contained in:
azammitdcarf
2011-09-08 01:58:41 +00:00
parent dfa55a3b9e
commit eaa9578ab8
2312 changed files with 811461 additions and 597534 deletions

View File

@@ -21,8 +21,8 @@
/**
* Constants for OLE package
*/
* Constants for OLE package
*/
define('OLE_PPS_TYPE_ROOT', 5);
define('OLE_PPS_TYPE_DIR', 1);
define('OLE_PPS_TYPE_FILE', 2);
@@ -35,43 +35,43 @@ require_once($homedir.'/classes/pear/PEAR.php');
require_once $homedir.'/classes/pear/OLE/PPS.php';
/**
* OLE package base class.
*
* @author Xavier Noguer <xnoguer@php.net>
* @category Structures
* @package OLE
*/
* OLE package base class.
*
* @author Xavier Noguer <xnoguer@php.net>
* @category Structures
* @package OLE
*/
class OLE extends PEAR
{
/**
* The file handle for reading an OLE container
* @var resource
*/
* The file handle for reading an OLE container
* @var resource
*/
var $_file_handle;
/**
* Array of PPS's found on the OLE container
* @var array
*/
* Array of PPS's found on the OLE container
* @var array
*/
var $_list;
/**
* Creates a new OLE object
* Remember to use ampersand when creating an OLE object ($my_ole =& new OLE();)
* @access public
*/
* Creates a new OLE object
* Remember to use ampersand when creating an OLE object ($my_ole =& new OLE();)
* @access public
*/
function OLE()
{
$this->_list = array();
}
/**
* Reads an OLE container from the contents of the file given.
*
* @acces public
* @param string $file
* @return mixed true on success, PEAR_Error on failure
*/
* Reads an OLE container from the contents of the file given.
*
* @acces public
* @param string $file
* @return mixed true on success, PEAR_Error on failure
*/
function read($file)
{
/* consider storing offsets as constants */
@@ -122,25 +122,25 @@ class OLE extends PEAR
}
/**
* Destructor (using PEAR)
* Just closes the file handle on the OLE file.
*
* @access private
*/
* Destructor (using PEAR)
* Just closes the file handle on the OLE file.
*
* @access private
*/
function _OLE()
{
fclose($this->_file_handle);
}
/**
* Gets information about all PPS's on the OLE container from the PPS WK's
* creates an OLE_PPS object for each one.
*
* @access private
* @param integer $pps_wk_start Position inside the OLE file where PPS WK's start
* @param integer $big_block_size Size of big blobks in the OLE file
* @return mixed true on success, PEAR_Error on failure
*/
* Gets information about all PPS's on the OLE container from the PPS WK's
* creates an OLE_PPS object for each one.
*
* @access private
* @param integer $pps_wk_start Position inside the OLE file where PPS WK's start
* @param integer $big_block_size Size of big blobks in the OLE file
* @return mixed true on success, PEAR_Error on failure
*/
function _readPpsWks($pps_wk_start, $big_block_size)
{
$pointer = ($pps_wk_start + 1) * $big_block_size;
@@ -149,7 +149,7 @@ class OLE extends PEAR
fseek($this->_file_handle, $pointer);
$pps_wk = fread($this->_file_handle, OLE_PPS_SIZE);
if (strlen($pps_wk) != OLE_PPS_SIZE) {
break; // Excel likes to add a trailing byte sometimes
break; // Excel likes to add a trailing byte sometimes
//return $this->raiseError("PPS at $pointer seems too short: ".strlen($pps_wk));
}
$name_length = unpack("c", substr($pps_wk, 64, 2)); // FIXME (2 bytes??)
@@ -157,8 +157,8 @@ class OLE extends PEAR
$name = substr($pps_wk, 0, $name_length);
$type = unpack("c", substr($pps_wk, 66, 1));
if (($type[''] != OLE_PPS_TYPE_ROOT) and
($type[''] != OLE_PPS_TYPE_DIR) and
($type[''] != OLE_PPS_TYPE_FILE))
($type[''] != OLE_PPS_TYPE_DIR) and
($type[''] != OLE_PPS_TYPE_FILE))
{
return $this->raiseError("PPS at $pointer has unknown type: {$type['']}");
}
@@ -174,9 +174,9 @@ class OLE extends PEAR
// _data member will point to position in file!!
// OLE_PPS object is created with an empty children array!!
$this->_list[] = new OLE_PPS(null, '', $type[''], $prev[''], $next[''],
$dir[''], OLE::OLE2LocalDate($time_1st),
OLE::OLE2LocalDate($time_2nd),
($start_block[''] + 1) * $big_block_size, array());
$dir[''], OLE::OLE2LocalDate($time_1st),
OLE::OLE2LocalDate($time_2nd),
($start_block[''] + 1) * $big_block_size, array());
// give it a size
$this->_list[count($this->_list) - 1]->Size = $size[''];
// check if the PPS tree (starting from root) is complete
@@ -186,15 +186,15 @@ class OLE extends PEAR
$pointer += OLE_PPS_SIZE;
}
}
/**
* It checks whether the PPS tree is complete (all PPS's read)
* starting with the given PPS (not necessarily root)
*
* @access private
* @param integer $index The index of the PPS from which we are checking
* @return boolean Whether the PPS tree for the given PPS is complete
*/
* It checks whether the PPS tree is complete (all PPS's read)
* starting with the given PPS (not necessarily root)
*
* @access private
* @param integer $index The index of the PPS from which we are checking
* @return boolean Whether the PPS tree for the given PPS is complete
*/
function _ppsTreeComplete($index)
{
if ($this->_list[$index]->NextPps != -1) {
@@ -216,14 +216,14 @@ class OLE extends PEAR
return true;
}
/**
* Checks whether a PPS is a File PPS or not.
* If there is no PPS for the index given, it will return false.
*
* @access public
* @param integer $index The index for the PPS
* @return bool true if it's a File PPS, false otherwise
*/
/**
* Checks whether a PPS is a File PPS or not.
* If there is no PPS for the index given, it will return false.
*
* @access public
* @param integer $index The index for the PPS
* @return bool true if it's a File PPS, false otherwise
*/
function isFile($index)
{
if (isset($this->_list[$index])) {
@@ -232,14 +232,14 @@ class OLE extends PEAR
return false;
}
/**
* Checks whether a PPS is a Root PPS or not.
* If there is no PPS for the index given, it will return false.
*
* @access public
* @param integer $index The index for the PPS.
* @return bool true if it's a Root PPS, false otherwise
*/
/**
* Checks whether a PPS is a Root PPS or not.
* If there is no PPS for the index given, it will return false.
*
* @access public
* @param integer $index The index for the PPS.
* @return bool true if it's a Root PPS, false otherwise
*/
function isRoot($index)
{
if (isset($this->_list[$index])) {
@@ -248,28 +248,28 @@ class OLE extends PEAR
return false;
}
/**
* Gives the total number of PPS's found in the OLE container.
*
* @access public
* @return integer The total number of PPS's found in the OLE container
*/
/**
* Gives the total number of PPS's found in the OLE container.
*
* @access public
* @return integer The total number of PPS's found in the OLE container
*/
function ppsTotal()
{
return count($this->_list);
}
/**
* Gets data from a PPS
* If there is no PPS for the index given, it will return an empty string.
*
* @access public
* @param integer $index The index for the PPS
* @param integer $position The position from which to start reading
* (relative to the PPS)
* @param integer $length The amount of bytes to read (at most)
* @return string The binary string containing the data requested
*/
* Gets data from a PPS
* If there is no PPS for the index given, it will return an empty string.
*
* @access public
* @param integer $index The index for the PPS
* @param integer $position The position from which to start reading
* (relative to the PPS)
* @param integer $length The amount of bytes to read (at most)
* @return string The binary string containing the data requested
*/
function getData($index, $position, $length)
{
// if position is not valid return empty string
@@ -280,15 +280,15 @@ class OLE extends PEAR
fseek($this->_file_handle, $this->_list[$index]->_data + $position);
return fread($this->_file_handle, $length);
}
/**
* Gets the data length from a PPS
* If there is no PPS for the index given, it will return 0.
*
* @access public
* @param integer $index The index for the PPS
* @return integer The amount of bytes in data the PPS has
*/
* Gets the data length from a PPS
* If there is no PPS for the index given, it will return 0.
*
* @access public
* @param integer $index The index for the PPS
* @return integer The amount of bytes in data the PPS has
*/
function getDataLength($index)
{
if (isset($this->_list[$index])) {
@@ -298,13 +298,13 @@ class OLE extends PEAR
}
/**
* Utility function to transform ASCII text to Unicode
*
* @access public
* @static
* @param string $ascii The ASCII string to transform
* @return string The string in Unicode
*/
* Utility function to transform ASCII text to Unicode
*
* @access public
* @static
* @param string $ascii The ASCII string to transform
* @return string The string in Unicode
*/
static function Asc2Ucs($ascii)
{
$rawname = '';
@@ -315,14 +315,14 @@ class OLE extends PEAR
}
/**
* Utility function
* Returns a string for the OLE container with the date given
*
* @access public
* @static
* @param integer $date A timestamp
* @return string The string for the OLE container
*/
* Utility function
* Returns a string for the OLE container with the date given
*
* @access public
* @static
* @param integer $date A timestamp
* @return string The string for the OLE container
*/
static function LocalDate2OLE($date = null)
{
if (!isset($date)) {
@@ -336,7 +336,7 @@ class OLE extends PEAR
$days = 134774;
// calculate seconds
$big_date = $days*24*3600 + gmmktime(date("H",$date),date("i",$date),date("s",$date),
date("m",$date),date("d",$date),date("Y",$date));
date("m",$date),date("d",$date),date("Y",$date));
// multiply just to make MS happy
$big_date *= 10000000;
@@ -363,13 +363,13 @@ class OLE extends PEAR
}
/**
* Returns a timestamp from an OLE container's date
*
* @access public
* @static
* @param integer $string A binary string with the encoded date
* @return string The timestamp corresponding to the string
*/
* Returns a timestamp from an OLE container's date
*
* @access public
* @static
* @param integer $string A binary string with the encoded date
* @return string The timestamp corresponding to the string
*/
static function OLE2LocalDate($string)
{
if (strlen($string) != 8) {
@@ -399,10 +399,10 @@ class OLE extends PEAR
$big_date = ($high_part*$factor) + $low_part;
// translate to seconds
$big_date /= 10000000;
// days from 1-1-1601 until the beggining of UNIX era
$days = 134774;
// translate to seconds from beggining of UNIX era
$big_date -= $days*24*3600;
return floor($big_date);