[zi-cvs] packages/com.zzoss.browser.lib Browser.php,NONE,1.1 package.xml,NONE,1.1

[email protected] Wed, 21 Jan 2004 01:16:37 -0800
Newsgroups gmane.comp.php.zzoss.installer.cvs
Message-ID <[email protected]>
Update of /cvsroot/zzossinstaller/packages/com.zzoss.browser.lib
In directory sc8-pr-cvs1:/tmp/cvs-serv30910/com.zzoss.browser.lib

Added Files:
	Browser.php package.xml 
Log Message:
PNG-24 transparency in MSIE 5+

--- NEW FILE: Browser.php ---
<?php   
    /*
    Copyright (C) 2001-2004 ZZOSS GbR, http://www.zzoss.com

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
    
/**
* Methods for enhancing browser compatibility.
*
* @version $Id: Browser.php,v 1.1 2004/01/21 09:16:27 ordnas Exp $
* @copyright Copyright &copy; 2001-2004 ZZ/OSS GbR, http://www.zzoss.com
* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
*/
class ZZOSS_Browser
{
    /*
    * Handle PNG images in MSIE 5+
    *
    * Ensures that PNG-24 transparencies are displayed correctly as described at
    * http://www.msdn.microsoft.com/library/default.asp?url=/workshop/author/filter/reference/filters/alphaimageloader.asp
    *
    * @param  $str  HTML content with src tags.
    * @param $spacer Location of the 1x1 pixel transparent GIF.
    * @result Returns the modified string.
    */
    function png($str, $spacer){
        include_once 'Net/UserAgent/Detect.php';
        // Make sure that we only deal with MSIE5+ and not with masqueraded Opera.
        if(!isset($_SERVER['HTTP_USER_AGENT']) ||
            !Net_UserAgent_Detect::isBrowser('ie5up') ||
            Net_UserAgent_Detect::isBrowser('opera')){
            return $str;
        }
        
        $pattern = "/src=\"([^\"]+\.png)\"/i";
        $replacement = 'src="'.$spacer.'" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'\\1\')"';
        $str = preg_replace($pattern, $replacement, $str);
        return $str;
    }
}
?>

--- NEW FILE: package.xml ---
<?xml version="1.0" encoding="ISO-8859-1" ?>
<package version="1.0"
	xmlns="http://www.zzoss.com/NS/installer/package/">
    <name>com.zzoss.browser.lib</name>
    <summary>Methods for cross-browser compatibility</summary>
    <description>Handles PNG-24 transparency in MSIE5+.</description>
    <maintainers>
        <maintainer>
            <user>ordnas</user>
            <name>Sandro Zic</name>
            <email>[email protected]</email>
            <role>lead</role>
        </maintainer>
    </maintainers>
    <release>
        <version>1.0.0</version>
        <date>{zi_release_date}</date>
        <license url="http://www.gnu.org/licenses/lgpl.txt" version="2">LGPL</license>
        <state>stable</state>
        <notes>Initial release.</notes>
        <copyright>
            <holder year="{zi_copyright_year}" url="http://www.zzoss.com">ZZ/OSS</holder>
        </copyright>
        <filelist>
            <file role="php" baseinstalldir="ZZOSS_Browser" name="Browser.php"/>
        </filelist>
        <deps>
            <dep type="pkg" rel="ge" version="1.0">Net_UserAgent_Detect</dep>
        </deps>
    </release>
</package>




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn