[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The Horde_Compress:: class provides an API for various compression 4 * techniques that can be used by Horde applications. 5 * 6 * $Horde: framework/Compress/Compress.php,v 1.7.12.10 2006/01/01 21:28:11 jan Exp $ 7 * 8 * Copyright 2003-2006 Michael Slusarz <slusarz@bigworm.colorado.edu> 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 Michael Slusarz <slusarz@bigworm.colorado.edu> 14 * @since Horde 3.0 15 * @package Horde_Compress 16 */ 17 class Horde_Compress { 18 19 /** 20 * Attempts to return a concrete Horde_Compress instance based on $driver. 21 * 22 * @param mixed $driver The type of concrete Horde_Compress subclass to 23 * return. If $driver is an array, then we will look 24 * in $driver[0]/lib/Compress/ for the subclass 25 * implementation named $driver[1].php. 26 * @param array $params A hash containing any additional configuration or 27 * parameters a subclass might need. 28 * 29 * @return Horde_Compress The newly created concrete Horde_Compress 30 * instance, or false on an error. 31 */ 32 function &factory($driver, $params = array()) 33 { 34 if (is_array($driver)) { 35 list($app, $driver) = $driver; 36 } 37 38 $driver = basename($driver); 39 40 if (!empty($app)) { 41 require_once $app . '/lib/Compress/' . $driver . '.php'; 42 } elseif (@file_exists(dirname(__FILE__) . '/Compress/' . $driver . '.php')) { 43 require_once dirname(__FILE__) . '/Compress/' . $driver . '.php'; 44 } else { 45 @include_once 'Horde/Compress/' . $driver . '.php'; 46 } 47 48 $class = 'Horde_Compress_' . $driver; 49 if (class_exists($class)) { 50 $compress = &new $class($params); 51 } else { 52 $compress = false; 53 } 54 55 return $compress; 56 } 57 58 /** 59 * Attempts to return a reference to a concrete Horde_Compress instance 60 * based on $driver. It will only create a new instance if no 61 * Horde_Compress instance with the same parameters currently exists. 62 * 63 * This method must be invoked as: 64 * $var = &Horde_Compress::singleton(); 65 * 66 * @param mixed $driver See Horde_Compress::factory(). 67 * @param array $params See Horde_Compress::factory(). 68 * 69 * @return Horde_Compress The concrete Horde_Compress reference, or false 70 * on an error. 71 */ 72 function &singleton($driver, $params = array()) 73 { 74 static $instances = array(); 75 76 $signature = md5(serialize(array($driver, $params))); 77 if (!isset($instances[$signature])) { 78 $instances[$signature] = &Horde_Compress::factory($driver, $params); 79 } 80 81 return $instances[$signature]; 82 } 83 84 /** 85 * Constructor. 86 * 87 * @param array $params Parameter array. 88 */ 89 function Horde_Compress($params = array()) 90 { 91 } 92 93 /** 94 * Compress the data. 95 * 96 * @param string $data The data to compress. 97 * @param array $params An array of arguments needed to compress the data. 98 * 99 * @return mixed The compressed data. 100 * Returns PEAR_Error object on error. 101 */ 102 function compress($data, $params = array()) 103 { 104 return PEAR::raiseError('Unsupported'); 105 } 106 107 /** 108 * Decompress the data. 109 * 110 * @param string $data The data to decompress. 111 * @param array $params An array of arguments needed to decompress the 112 * data. 113 * 114 * @return array The decompressed data. 115 * Returns PEAR_Error object on error. 116 */ 117 function decompress($data, $params = array()) 118 { 119 return PEAR::raiseError('Unsupported'); 120 } 121 122 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |