|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 00003 // +----------------------------------------------------------------------+ 00004 // | PHP Version 4 | 00005 // +----------------------------------------------------------------------+ 00006 // | Copyright (c) 1997-2002 The PHP Group | 00007 // +----------------------------------------------------------------------+ 00008 // | This source file is subject to version 2.02 of the PHP license, | 00009 // | that is bundled with this package in the file LICENSE, and is | 00010 // | available at through the world-wide-web at | 00011 // | http://www.php.net/license/2_02.txt. | 00012 // | If you did not receive a copy of the PHP license and are unable to | 00013 // | obtain it through the world-wide-web, please send a note to | 00014 // | license@php.net so we can mail you a copy immediately. | 00015 // +----------------------------------------------------------------------+ 00016 // | Author: Xavier Noguer <xnoguer@php.net> | 00017 // | Based on OLE::Storage_Lite by Kawai, Takanori | 00018 // +----------------------------------------------------------------------+ 00019 // 00020 // $Id: PPS.php,v 1.4 2010/12/14 17:36:03 moodlerobot Exp $ 00021 00022 00023 require_once('PEAR.php'); 00024 require_once('OLE.php'); 00025 00033 class OLE_PPS extends PEAR 00034 { 00039 var $No; 00040 00045 var $Name; 00046 00051 var $Type; 00052 00057 var $PrevPps; 00058 00063 var $NextPps; 00064 00069 var $DirPps; 00070 00075 var $Time1st; 00076 00081 var $Time2nd; 00082 00087 var $_StartBlock; 00088 00093 var $Size; 00094 00099 var $_data; 00100 00105 var $children = array(); 00106 00121 function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children) 00122 { 00123 $this->No = $No; 00124 $this->Name = $name; 00125 $this->Type = $type; 00126 $this->PrevPps = $prev; 00127 $this->NextPps = $next; 00128 $this->DirPps = $dir; 00129 $this->Time1st = $time_1st; 00130 $this->Time2nd = $time_2nd; 00131 $this->_data = $data; 00132 $this->children = $children; 00133 if ($data != '') { 00134 $this->Size = strlen($data); 00135 } 00136 else { 00137 $this->Size = 0; 00138 } 00139 } 00140 00147 function _DataLen() 00148 { 00149 if (!isset($this->_data)) { 00150 return 0; 00151 } 00152 if (isset($this->_PPS_FILE)) 00153 { 00154 fseek($this->_PPS_FILE, 0); 00155 $stats = fstat($this->_PPS_FILE); 00156 return $stats[7]; 00157 } 00158 else { 00159 return strlen($this->_data); 00160 } 00161 } 00162 00169 function _getPpsWk() 00170 { 00171 $ret = $this->Name; 00172 for ($i = 0; $i < (64 - strlen($this->Name)); $i++) { 00173 $ret .= "\x00"; 00174 } 00175 $ret .= pack("v", strlen($this->Name) + 2) // 66 00176 . pack("c", $this->Type) // 67 00177 . pack("c", 0x00) //UK // 68 00178 . pack("V", $this->PrevPps) //Prev // 72 00179 . pack("V", $this->NextPps) //Next // 76 00180 . pack("V", $this->DirPps) //Dir // 80 00181 . "\x00\x09\x02\x00" // 84 00182 . "\x00\x00\x00\x00" // 88 00183 . "\xc0\x00\x00\x00" // 92 00184 . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root 00185 . "\x00\x00\x00\x00" // 100 00186 . OLE::LocalDate2OLE($this->Time1st) // 108 00187 . OLE::LocalDate2OLE($this->Time2nd) // 116 00188 . pack("V", isset($this->_StartBlock)? 00189 $this->_StartBlock:0) // 120 00190 . pack("V", $this->Size) // 124 00191 . pack("V", 0); // 128 00192 return $ret; 00193 } 00194 00204 function _savePpsSetPnt(&$pps_array) 00205 { 00206 $pps_array[count($pps_array)] = &$this; 00207 $this->No = count($pps_array) - 1; 00208 $this->PrevPps = 0xFFFFFFFF; 00209 $this->NextPps = 0xFFFFFFFF; 00210 if (count($this->children) > 0) { 00211 $this->DirPps = $this->children[0]->_savePpsSetPnt($pps_array); 00212 } 00213 else { 00214 $this->DirPps = 0xFFFFFFFF; 00215 } 00216 return $this->No; 00217 } 00218 } 00219 ?>