~ubuntu-branches/ubuntu/saucy/horde3/saucy

« back to all changes in this revision

Viewing changes to lib/Horde/MIME/Viewer/msexcel.php

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-05-04 23:08:08 UTC
  • Revision ID: james.westby@ubuntu.com-20050504230808-p4hf3hk28o3v7wir
Tags: upstream-3.0.4
ImportĀ upstreamĀ versionĀ 3.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * The MIME_Viewer_msexcel class renders out Microsoft Excel
 
4
 * documents in HTML format by using the xlHtml package.
 
5
 *
 
6
 * $Horde: framework/MIME/MIME/Viewer/msexcel.php,v 1.20.10.2 2005/01/12 15:02:35 jan Exp $
 
7
 *
 
8
 * Copyright 1999-2005 Anil Madhavapeddy <anil@recoil.org>
 
9
 *
 
10
 * See the enclosed file COPYING for license information (LGPL). If you
 
11
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 
12
 *
 
13
 * @author  Anil Madhavapeddy <anil@recoil.org>
 
14
 * @version $Revision: 1.20.10.2 $
 
15
 * @since   Horde 1.3
 
16
 * @package Horde_MIME_Viewer
 
17
 */
 
18
class MIME_Viewer_msexcel extends MIME_Viewer {
 
19
 
 
20
    /**
 
21
     * Render out the currently data using xlhtml.
 
22
     *
 
23
     * @access public
 
24
     *
 
25
     * @param optional array $params  Any params this Viewer may need.
 
26
     *
 
27
     * @return string  The rendered data.
 
28
     */
 
29
    function render($params = array())
 
30
    {
 
31
        global $mime_drivers;
 
32
 
 
33
        /* Check to make sure the program actually exists. */
 
34
        if (!file_exists($mime_drivers['horde']['msexcel']['location'])) {
 
35
            return '<pre>' . sprintf(_("The program used to view this data type (%s) was not found on the system."), $mime_drivers['horde']['msexcel']['location']) . '</pre>';
 
36
        }
 
37
 
 
38
        $data = '';
 
39
        $tmp_xls = Horde::getTempFile('horde_msexcel');
 
40
 
 
41
        $fh = fopen($tmp_xls, 'w');
 
42
        fwrite($fh, $this->mime_part->getContents());
 
43
        fclose($fh);
 
44
 
 
45
        $fh = popen($mime_drivers['horde']['msexcel']['location'] . " -nh $tmp_xls 2>&1", 'r');
 
46
        while (($rc = fgets($fh, 8192))) {
 
47
            $data .= $rc;
 
48
        }
 
49
        pclose($fh);
 
50
 
 
51
        return $data;
 
52
    }
 
53
 
 
54
    /**
 
55
     * Return the MIME content type of the rendered content.
 
56
     *
 
57
     * @access public
 
58
     *
 
59
     * @return string  The content type of the output. 
 
60
     */
 
61
    function getType()
 
62
    {
 
63
        return 'text/html; charset=' . NLS::getCharset();
 
64
    }
 
65
 
 
66
}