ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PPS.php
Go to the documentation of this file.
1<?php
2
4
5// vim: set expandtab tabstop=4 shiftwidth=4:
6// +----------------------------------------------------------------------+
7// | PHP Version 4 |
8// +----------------------------------------------------------------------+
9// | Copyright (c) 1997-2002 The PHP Group |
10// +----------------------------------------------------------------------+
11// | This source file is subject to version 2.02 of the PHP license, |
12// | that is bundled with this package in the file LICENSE, and is |
13// | available at through the world-wide-web at |
14// | http://www.php.net/license/2_02.txt. |
15// | If you did not receive a copy of the PHP license and are unable to |
16// | obtain it through the world-wide-web, please send a note to |
17// | license@php.net so we can mail you a copy immediately. |
18// +----------------------------------------------------------------------+
19// | Author: Xavier Noguer <xnoguer@php.net> |
20// | Based on OLE::Storage_Lite by Kawai, Takanori |
21// +----------------------------------------------------------------------+
22//
24
30class PPS
31{
37 public $No;
38
44 public $Name;
45
51 public $Type;
52
58 public $PrevPps;
59
65 public $NextPps;
66
72 public $DirPps;
73
79 public $Time1st;
80
86 public $Time2nd;
87
94
100 public $Size;
101
107 public $_data;
108
114 public $children = [];
115
121 public $ole;
122
137 public function __construct($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
138 {
139 $this->No = $No;
140 $this->Name = $name;
141 $this->Type = $type;
142 $this->PrevPps = $prev;
143 $this->NextPps = $next;
144 $this->DirPps = $dir;
145 $this->Time1st = $time_1st ?? 0;
146 $this->Time2nd = $time_2nd ?? 0;
147 $this->_data = $data;
148 $this->children = $children;
149 if ($data != '') {
150 $this->Size = strlen($data);
151 } else {
152 $this->Size = 0;
153 }
154 }
155
161 public function getDataLen()
162 {
163 if (!isset($this->_data)) {
164 return 0;
165 }
166
167 return strlen($this->_data);
168 }
169
175 public function getPpsWk()
176 {
177 $ret = str_pad($this->Name, 64, "\x00");
178
179 $ret .= pack('v', strlen($this->Name) + 2) // 66
180 . pack('c', $this->Type) // 67
181 . pack('c', 0x00) //UK // 68
182 . pack('V', $this->PrevPps) //Prev // 72
183 . pack('V', $this->NextPps) //Next // 76
184 . pack('V', $this->DirPps) //Dir // 80
185 . "\x00\x09\x02\x00" // 84
186 . "\x00\x00\x00\x00" // 88
187 . "\xc0\x00\x00\x00" // 92
188 . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
189 . "\x00\x00\x00\x00" // 100
190 . OLE::localDateToOLE($this->Time1st) // 108
191 . OLE::localDateToOLE($this->Time2nd) // 116
192 . pack('V', $this->startBlock ?? 0) // 120
193 . pack('V', $this->Size) // 124
194 . pack('V', 0); // 128
195
196 return $ret;
197 }
198
210 public static function savePpsSetPnt(&$raList, $to_save, $depth = 0)
211 {
212 if (!is_array($to_save) || (empty($to_save))) {
213 return 0xFFFFFFFF;
214 } elseif (count($to_save) == 1) {
215 $cnt = count($raList);
216 // If the first entry, it's the root... Don't clone it!
217 $raList[$cnt] = ($depth == 0) ? $to_save[0] : clone $to_save[0];
218 $raList[$cnt]->No = $cnt;
219 $raList[$cnt]->PrevPps = 0xFFFFFFFF;
220 $raList[$cnt]->NextPps = 0xFFFFFFFF;
221 $raList[$cnt]->DirPps = self::savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++);
222 } else {
223 $iPos = floor(count($to_save) / 2);
224 $aPrev = array_slice($to_save, 0, $iPos);
225 $aNext = array_slice($to_save, $iPos + 1);
226 $cnt = count($raList);
227 // If the first entry, it's the root... Don't clone it!
228 $raList[$cnt] = ($depth == 0) ? $to_save[$iPos] : clone $to_save[$iPos];
229 $raList[$cnt]->No = $cnt;
230 $raList[$cnt]->PrevPps = self::savePpsSetPnt($raList, $aPrev, $depth++);
231 $raList[$cnt]->NextPps = self::savePpsSetPnt($raList, $aNext, $depth++);
232 $raList[$cnt]->DirPps = self::savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++);
233 }
234
235 return $cnt;
236 }
237}
An exception for terminatinating execution or to throw for unit testing.
Class for creating PPS's for OLE containers.
Definition: PPS.php:31
static savePpsSetPnt(&$raList, $to_save, $depth=0)
Updates index and pointers to previous, next and children PPS's for this PPS.
Definition: PPS.php:210
getPpsWk()
Returns a string with the PPS's WK (What is a WK?).
Definition: PPS.php:175
getDataLen()
Returns the amount of data saved for this PPS.
Definition: PPS.php:161
__construct($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
The constructor.
Definition: PPS.php:137
static localDateToOLE($date)
Utility function Returns a string for the OLE container with the date given.
Definition: OLE.php:498
$ret
Definition: parser.php:6
$type
$data
Definition: bench.php:6