~ubuntu-branches/ubuntu/lucid/phpmyadmin/lucid

« back to all changes in this revision

Viewing changes to libraries/PHPExcel/PHPExcel/Shared/OLE/OLE_File.php

  • Committer: Bazaar Package Importer
  • Author(s): Michal Čihař
  • Date: 2010-03-08 15:25:00 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100308152500-6e8hmuqc5co39de5
Tags: 4:3.3.0-1
* New upstream version.
* Rediff debian/patches.
* Fix permissions on mediawiki export extension.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: File.php,v 1.11 2007/02/13 21:00:42 schmidt Exp $
 
21
 
 
22
 
 
23
/** PHPExcel root directory */
 
24
if (!defined('PHPEXCEL_ROOT')) {
 
25
        /**
 
26
         * @ignore
 
27
         */
 
28
        define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
 
29
}
 
30
 
 
31
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_PPS.php';
 
32
 
 
33
/**
 
34
* Class for creating File PPS's for OLE containers
 
35
*
 
36
* @author   Xavier Noguer <xnoguer@php.net>
 
37
* @category PHPExcel
 
38
* @package  PHPExcel_Shared_OLE
 
39
*/
 
40
class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
 
41
        {
 
42
        /**
 
43
        * The temporary dir for storing the OLE file
 
44
        * @var string
 
45
        */
 
46
        public $_tmp_dir;
 
47
 
 
48
        /**
 
49
        * The constructor
 
50
        *
 
51
        * @access public
 
52
        * @param string $name The name of the file (in Unicode)
 
53
        * @see OLE::Asc2Ucs()
 
54
        */
 
55
        public function __construct($name)
 
56
        {
 
57
                $this->_tmp_dir = '';
 
58
                parent::__construct(
 
59
                        null, 
 
60
                        $name,
 
61
                        PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE,
 
62
                        null,
 
63
                        null,
 
64
                        null,
 
65
                        null,
 
66
                        null,
 
67
                        '',
 
68
                        array());
 
69
        }
 
70
 
 
71
        /**
 
72
        * Sets the temp dir used for storing the OLE file
 
73
        *
 
74
        * @access public
 
75
        * @param string $dir The dir to be used as temp dir
 
76
        * @return true if given dir is valid, false otherwise
 
77
        */
 
78
        public function setTempDir($dir)
 
79
        {
 
80
                if (is_dir($dir)) {
 
81
                        $this->_tmp_dir = $dir;
 
82
                        return true;
 
83
                }
 
84
                return false;
 
85
        }
 
86
 
 
87
        /**
 
88
        * Initialization method. Has to be called right after OLE_PPS_File().
 
89
        *
 
90
        * @access public
 
91
        * @return mixed true on success
 
92
        */
 
93
        public function init()
 
94
        {
 
95
                $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_File");
 
96
                $fh = fopen($this->_tmp_filename, "w+b");
 
97
                if ($fh === false) {
 
98
                        throw new Exception("Can't create temporary file");
 
99
                }
 
100
                $this->_PPS_FILE = $fh;
 
101
                if ($this->_PPS_FILE) {
 
102
                        fseek($this->_PPS_FILE, 0);
 
103
                }
 
104
                return true;
 
105
        }
 
106
 
 
107
        /**
 
108
        * Append data to PPS
 
109
        *
 
110
        * @access public
 
111
        * @param string $data The data to append
 
112
        */
 
113
        public function append($data)
 
114
        {
 
115
                if ($this->_PPS_FILE) {
 
116
                        fwrite($this->_PPS_FILE, $data);
 
117
                } else {
 
118
                        $this->_data .= $data;
 
119
                }
 
120
        }
 
121
 
 
122
        /**
 
123
         * Returns a stream for reading this file using fread() etc.
 
124
         * @return  resource  a read-only stream
 
125
         */
 
126
        public function getStream()
 
127
        {
 
128
                $this->ole->getStream($this);
 
129
        }
 
130
}