2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2002 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.02 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Author: Xavier Noguer <xnoguer@php.net> |
17 // | Based on OLE::Storage_Lite by Kawai, Takanori |
18 // +----------------------------------------------------------------------+
23 require_once('PEAR.php');
24 require_once('OLE.php');
27 * Class for creating PPS's for OLE containers
29 * @author Xavier Noguer <xnoguer@php.net>
30 * @category Structures
33 class OLE_PPS
extends PEAR
42 * The PPS name (in Unicode)
48 * The PPS type. Dir, Root or File
54 * The index of the previous PPS
60 * The index of the next PPS
66 * The index of it's first child if this is a Dir or Root PPS
84 * Starting block (small or big) for this PPS's data inside the container
90 * The size of the PPS's data (in bytes)
96 * The PPS's data (only used if it's not using a temporary file)
102 * Array of child PPS's (only used by Root and Dir PPS's)
105 var $children = array();
111 * @param integer $No The PPS index
112 * @param string $name The PPS name (in Unicode)
113 * @param integer $type The PPS type. Dir, Root or File
114 * @param integer $prev The index of the previous PPS
115 * @param integer $next The index of the next PPS
116 * @param integer $dir The index of it's first child if this is a Dir or Root PPS
117 * @param integer $time_1st A timestamp
118 * @param integer $time_2nd A timestamp
119 * @param array $children Array containing children PPS for this PPS
121 function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
126 $this->PrevPps
= $prev;
127 $this->NextPps
= $next;
128 $this->DirPps
= $dir;
129 $this->Time1st
= $time_1st;
130 $this->Time2nd
= $time_2nd;
131 $this->_data
= $data;
132 $this->children
= $children;
134 $this->Size
= strlen($data);
142 * Returns the amount of data saved for this PPS
145 * @return integer The amount of data (in bytes)
149 if (!isset($this->_data
)) {
152 if (isset($this->_PPS_FILE
))
154 fseek($this->_PPS_FILE
, 0);
155 $stats = fstat($this->_PPS_FILE
);
159 return strlen($this->_data
);
164 * Returns a string with the PPS's WK (What is a WK?)
167 * @return string The binary string
172 for ($i = 0; $i < (64 - strlen($this->Name
)); $i++
) {
175 $ret .= pack("v", strlen($this->Name
) +
2) // 66
176 . pack("c", $this->Type
) // 67
177 . pack("c", 0x00) //UK // 68
178 . pack("V", $this->PrevPps
) //Prev // 72
179 . pack("V", $this->NextPps
) //Next // 76
180 . pack("V", $this->DirPps
) //Dir // 80
181 . "\x00\x09\x02\x00" // 84
182 . "\x00\x00\x00\x00" // 88
183 . "\xc0\x00\x00\x00" // 92
184 . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
185 . "\x00\x00\x00\x00" // 100
186 . OLE
::LocalDate2OLE($this->Time1st
) // 108
187 . OLE
::LocalDate2OLE($this->Time2nd
) // 116
188 . pack("V", isset($this->_StartBlock
)?
189 $this->_StartBlock
:0) // 120
190 . pack("V", $this->Size
) // 124
191 . pack("V", 0); // 128
196 * Updates index and pointers to previous, next and children PPS's for this
197 * PPS. I don't think it'll work with Dir PPS's.
200 * @param array &$pps_array Reference to the array of PPS's for the whole OLE
202 * @return integer The index for this PPS
204 function _savePpsSetPnt(&$pps_array)
206 $pps_array[count($pps_array)] = &$this;
207 $this->No
= count($pps_array) - 1;
208 $this->PrevPps
= 0xFFFFFFFF;
209 $this->NextPps
= 0xFFFFFFFF;
210 if (count($this->children
) > 0) {
211 $this->DirPps
= $this->children
[0]->_savePpsSetPnt($pps_array);
214 $this->DirPps
= 0xFFFFFFFF;