[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/MIME/Viewer/ -> rpm.php (source)

   1  <?php
   2  /**
   3   * The MIME_Viewer_rpm class renders out lists of files in RPM
   4   * packages by using the rpm tool to query the package.
   5   *
   6   * $Horde: framework/MIME/MIME/Viewer/rpm.php,v 1.12.10.7 2006/01/01 21:28:25 jan Exp $
   7   *
   8   * Copyright 1999-2006 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   * @since   Horde 1.3
  15   * @package Horde_MIME_Viewer
  16   */
  17  class MIME_Viewer_rpm extends MIME_Viewer {
  18  
  19      /**
  20       * Render out the RPM contents.
  21       *
  22       * @param array $params  Any parameters the Viewer may need.
  23       *
  24       * @return string  The rendered contents.
  25       */
  26      function render($params = array())
  27      {
  28          global $mime_drivers;
  29  
  30          /* Check to make sure the program actually exists. */
  31          if (!file_exists($mime_drivers['horde']['rpm']['location'])) {
  32              return '<pre>' . sprintf(_("The program used to view this data type (%s) was not found on the system."), $mime_drivers['horde']['rpm']['location']) . '</pre>';
  33          }
  34  
  35          $data = '';
  36          $tmp_rpm = Horde::getTempFile('horde_rpm');
  37  
  38          $fh = fopen($tmp_rpm, 'w');
  39          fwrite($fh, $this->mime_part->getContents());
  40          fclose($fh);
  41  
  42          $fh = popen($mime_drivers['horde']['rpm']['location'] . " -qip $tmp_rpm 2>&1", 'r');
  43          while (($rc = fgets($fh, 8192))) {
  44              $data .= $rc;
  45          }
  46          pclose($fh);
  47  
  48          return '<pre>' . htmlentities($data) . '</pre>';
  49      }
  50  
  51      /**
  52       * Return the MIME content type of the rendered content.
  53       *
  54       * @return string  The content type of the output.
  55       */
  56      function getType()
  57      {
  58          return 'text/html; charset=' . NLS::getCharset();
  59      }
  60  
  61  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7