[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_ext/PEAR/OLE/ -> PPS.php (source)

   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4: */
   3  // +----------------------------------------------------------------------+
   4  // | PHP Version 4                                                        |
   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  // +----------------------------------------------------------------------+
  19  //
  20  // $Id: PPS.php,v 1.5 2003/12/14 18:12:28 xnoguer Exp $
  21  
  22  
  23  require_once('PEAR.php');
  24  require_once ('OLE.php');
  25  
  26  /**
  27  * Class for creating PPS's for OLE containers
  28  *
  29  * @author   Xavier Noguer <xnoguer@php.net>
  30  * @category Structures
  31  * @package  OLE
  32  */
  33  class OLE_PPS extends PEAR
  34  {
  35      /**
  36      * The PPS index
  37      * @var integer
  38      */
  39      var $No;
  40  
  41      /**
  42      * The PPS name (in Unicode)
  43      * @var string
  44      */
  45      var $Name;
  46   
  47      /**
  48      * The PPS type. Dir, Root or File
  49      * @var integer
  50      */
  51      var $Type;
  52   
  53      /**
  54      * The index of the previous PPS
  55      * @var integer
  56      */
  57      var $PrevPps;
  58   
  59      /**
  60      * The index of the next PPS
  61      * @var integer
  62      */
  63      var $NextPps;
  64   
  65      /**
  66      * The index of it's first child if this is a Dir or Root PPS
  67      * @var integer
  68      */
  69      var $DirPps;
  70   
  71      /**
  72      * A timestamp
  73      * @var integer
  74      */
  75      var $Time1st;
  76  
  77      /**
  78      * A timestamp
  79      * @var integer
  80      */
  81      var $Time2nd;
  82  
  83      /**
  84      * Starting block (small or big) for this PPS's data  inside the container
  85      * @var integer
  86      */
  87      var $_StartBlock;
  88  
  89      /**
  90      * The size of the PPS's data (in bytes)
  91      * @var integer
  92      */
  93      var $Size;
  94  
  95      /**
  96      * The PPS's data (only used if it's not using a temporary file)
  97      * @var string
  98      */
  99      var $_data;
 100  
 101      /**
 102      * Array of child PPS's (only used by Root and Dir PPS's)
 103      * @var array
 104      */
 105      var $children = array();
 106  
 107      /**
 108      * The constructor
 109      *
 110      * @access public
 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
 120      */
 121      function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
 122      {
 123          $this->No      = $No;
 124          $this->Name    = $name;
 125          $this->Type    = $type;
 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;
 133          if ($data != '') {
 134              $this->Size = strlen($data);
 135          }
 136          else {
 137              $this->Size = 0;
 138          }
 139      }
 140  
 141      /**
 142      * Returns the amount of data saved for this PPS
 143      *
 144      * @access private
 145      * @return integer The amount of data (in bytes)
 146      */
 147      function _DataLen()
 148      {
 149          if (!isset($this->_data)) {
 150              return 0;
 151          }
 152          if (isset($this->_PPS_FILE))
 153          {
 154              fseek($this->_PPS_FILE, 0);
 155              $stats = fstat($this->_PPS_FILE);
 156              return $stats[7];
 157          }
 158          else {
 159              return strlen($this->_data);
 160          }
 161      }
 162  
 163      /**
 164      * Returns a string with the PPS's WK (What is a WK?)
 165      *
 166      * @access private
 167      * @return string The binary string
 168      */
 169      function _getPpsWk()
 170      {
 171          $ret = $this->Name;
 172          for ($i = 0; $i < (64 - strlen($this->Name)); $i++) {
 173              $ret .= "\x00";
 174          }
 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
 192          return $ret;
 193      }
 194  
 195      /**
 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.
 198      *
 199      * @access private
 200      * @param array &$pps_array Reference to the array of PPS's for the whole OLE
 201      *                          container 
 202      * @return integer          The index for this PPS
 203      */
 204      function _savePpsSetPnt(&$pps_array) 
 205      {
 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);
 212          }
 213          else {
 214              $this->DirPps = 0xFFFFFFFF;
 215          }
 216          return $this->No;
 217      }
 218  }
 219  ?>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7