Remove horde/Core dependency in Horde_Browser
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 8 Oct 2010 22:55:18 +0000 (16:55 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Sat, 9 Oct 2010 07:20:05 +0000 (01:20 -0600)
framework/Browser/lib/Horde/Browser.php
framework/Browser/package.xml
framework/Core/lib/Horde/Core/Browser.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Factory/Browser.php [new file with mode: 0644]
framework/Core/lib/Horde/Registry.php
framework/Core/package.xml

index aad478e..d5f6520 100644 (file)
@@ -383,34 +383,6 @@ class Horde_Browser
                 $this->setQuirk('png_transparency');
             }
 
-            /* IE 6 (pre-SP1) and 5.5 (pre-SP1) have buggy compression.
-             * The versions affected are as follows:
-             * 6.00.2462.0000  Internet Explorer 6 Public Preview (Beta)
-             * 6.00.2479.0006  Internet Explorer 6 Public Preview (Beta) Refresh
-             * 6.00.2600.0000  Internet Explorer 6 (Windows XP)
-             * 5.50.3825.1300  Internet Explorer 5.5 Developer Preview (Beta)
-             * 5.50.4030.2400  Internet Explorer 5.5 & Internet Tools Beta
-             * 5.50.4134.0100  Internet Explorer 5.5 for Windows Me (4.90.3000)
-             * 5.50.4134.0600  Internet Explorer 5.5
-             * 5.50.4308.2900  Internet Explorer 5.5 Advanced Security Privacy Beta
-             *
-             * See:
-             * ====
-             * http://support.microsoft.com/kb/164539;
-             * http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312496)
-             * http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313712
-             */
-            $ie_vers = $this->getIEVersion();
-            $buggy_list = array(
-                '6,00,2462,0000', '6,0,2462,0', '6,00,2479,0006',
-                '6,0,2479,0006', '6,00,2600,0000', '6,0,2600,0',
-                '5,50,3825,1300', '5,50,4030,2400', '5,50,4134,0100',
-                '5,50,4134,0600', '5,50,4308,2900'
-            );
-            if (!is_null($ie_vers) && in_array($ie_vers, $buggy_list)) {
-                $this->setQuirk('buggy_compression');
-            }
-
             /* Some Handhelds have their screen resolution in the user
              * agent string, which we can use to look for mobile
              * agents. */
@@ -1193,28 +1165,4 @@ class Horde_Browser
         return in_array($subtype, $this->_images);
     }
 
-    /**
-     * Sets the IE version in the session.
-     *
-     * @param string $ver  The IE Version string.
-     */
-    public function setIEVersion($ver)
-    {
-        $_SESSION['horde_browser'] = array(
-            'ie_version' => $ver
-        );
-    }
-
-    /**
-     * Returns the IE version stored in the session, if available.
-     *
-     * @return mixed  The IE Version string or null if no string is stored.
-     */
-    public function getIEVersion()
-    {
-        return isset($_SESSION['horde_browser']['ie_version'])
-            ? $_SESSION['horde_browser']['ie_version']
-            : null;
-    }
-
 }
index 41378e1..2933646 100644 (file)
@@ -25,7 +25,7 @@ about the current user&apos;s browser and its capabilities.
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Remove PEAR dependency.
+ <notes>* Remove PEAR and horde/Core dependencies.
  * Remove Horde_Browser::escapeJSCode().
  * Add Horde_Browser_Exception::.
  * Initial Horde 4 package.</notes>
diff --git a/framework/Core/lib/Horde/Core/Browser.php b/framework/Core/lib/Horde/Core/Browser.php
new file mode 100644 (file)
index 0000000..856b1e4
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/**
+ * The Horde_Core_Browser class extends the base Horde_Browser class by
+ * allowing storage of IE version information in order to identify additional
+ * browser quirks.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Browser extends Horde_Browser
+{
+    /**
+     */
+    public function match($userAgent = null, $accept = null)
+    {
+        parent::match($userAgent, $accept);
+
+        if ($this->isBrowser('msie')) {
+            /* IE 6 (pre-SP1) and 5.5 (pre-SP1) have buggy compression.
+             * The versions affected are as follows:
+             * 6.00.2462.0000  Internet Explorer 6 Public Preview (Beta)
+             * 6.00.2479.0006  Internet Explorer 6 Public Preview (Beta) Refresh
+             * 6.00.2600.0000  Internet Explorer 6 (Windows XP)
+             * 5.50.3825.1300  Internet Explorer 5.5 Developer Preview (Beta)
+             * 5.50.4030.2400  Internet Explorer 5.5 & Internet Tools Beta
+             * 5.50.4134.0100  Internet Explorer 5.5 for Windows Me (4.90.3000)
+             * 5.50.4134.0600  Internet Explorer 5.5
+             * 5.50.4308.2900  Internet Explorer 5.5 Advanced Security Privacy Beta
+             *
+             * See:
+             * ====
+             * http://support.microsoft.com/kb/164539;
+             * http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312496)
+             * http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313712
+             */
+            $ie_vers = $this->getIEVersion();
+            $buggy_list = array(
+                '6,00,2462,0000', '6,0,2462,0', '6,00,2479,0006',
+                '6,0,2479,0006', '6,00,2600,0000', '6,0,2600,0',
+                '5,50,3825,1300', '5,50,4030,2400', '5,50,4134,0100',
+                '5,50,4134,0600', '5,50,4308,2900'
+            );
+            if (!is_null($ie_vers) && in_array($ie_vers, $buggy_list)) {
+                $this->setQuirk('buggy_compression');
+            }
+        }
+    }
+
+    /**
+     * Sets the IE version in the session.
+     *
+     * @param string $ver  The IE Version string.
+     */
+    public function setIEVersion($ver)
+    {
+        $_SESSION['horde_browser'] = array(
+            'ie_version' => $ver
+        );
+    }
+
+    /**
+     * Returns the IE version stored in the session, if available.
+     *
+     * @return mixed  The IE Version string or null if no string is stored.
+     */
+    public function getIEVersion()
+    {
+        return isset($_SESSION['horde_browser']['ie_version'])
+            ? $_SESSION['horde_browser']['ie_version']
+            : null;
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Factory/Browser.php b/framework/Core/lib/Horde/Core/Factory/Browser.php
new file mode 100644 (file)
index 0000000..95eee56
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+/**
+ * @category Horde
+ * @package  Core
+ */
+class Horde_Core_Factory_Browser
+{
+    /**
+     */
+    public function create(Horde_Injector $injector)
+    {
+        return new Horde_Core_Browser();
+    }
+
+}
index 3b014fc..74ddbdc 100644 (file)
@@ -175,7 +175,7 @@ class Horde_Registry
         switch ($args['session_control']) {
         case 'netscape':
             // Chicken/egg: Browser object doesn't exist yet.
-            $browser = new Horde_Browser();
+            $browser = new Horde_Core_Browser();
             if ($browser->isBrowser('mozilla')) {
                 session_cache_limiter('private, must-revalidate');
             }
@@ -253,6 +253,7 @@ class Horde_Registry
          * second element in an array. */
         $factories = array(
             'Horde_Alarm' => 'Horde_Core_Factory_Alarm',
+            'Horde_Browser' => 'Horde_Core_Factory_Browser',
             'Horde_Cache' => 'Horde_Core_Factory_Cache',
             'Horde_Cache_Session' => array(
                 'Horde_Core_Factory_Cache',
index 693a68c..b896d95 100644 (file)
@@ -118,6 +118,7 @@ Application Framework.</description>
        <file name="Ajax.php" role="php" />
        <file name="Alarm.php" role="php" />
        <file name="Auth.php" role="php" />
+       <file name="Browser.php" role="php" />
        <file name="Cache.php" role="php" />
        <file name="Crypt.php" role="php" />
        <file name="Data.php" role="php" />
@@ -214,6 +215,7 @@ Application Framework.</description>
        <file name="VarRenderer.php" role="php" />
        <file name="Widget.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Ui -->
+      <file name="Browser.php" role="php" />
       <file name="Sidebar.php" role="php" />
      </dir> <!-- /lib/Horde/Core -->
      <dir name="Exception">
@@ -400,6 +402,7 @@ Application Framework.</description>
    <install as="Horde/Session.php" name="lib/Horde/Session.php" />
    <install as="Horde/Themes.php" name="lib/Horde/Themes.php" />
    <install as="Horde/Config/Form.php" name="lib/Horde/Config/Form.php" />
+   <install as="Horde/Core/Browser.php" name="lib/Horde/Core/Browser.php" />
    <install as="Horde/Core/Sidebar.php" name="lib/Horde/Core/Sidebar.php" />
    <install as="Horde/Core/Ajax/Application.php" name="lib/Horde/Core/Ajax/Application.php" />
    <install as="Horde/Core/Ajax/Imple.php" name="lib/Horde/Core/Ajax/Imple.php" />
@@ -424,6 +427,7 @@ Application Framework.</description>
    <install as="Horde/Core/Factory/Ajax.php" name="lib/Horde/Core/Factory/Ajax.php" />
    <install as="Horde/Core/Factory/Alarm.php" name="lib/Horde/Core/Factory/Alarm.php" />
    <install as="Horde/Core/Factory/Auth.php" name="lib/Horde/Core/Factory/Auth.php" />
+   <install as="Horde/Core/Factory/Browser.php" name="lib/Horde/Core/Factory/Browser.php" />
    <install as="Horde/Core/Factory/Cache.php" name="lib/Horde/Core/Factory/Cache.php" />
    <install as="Horde/Core/Factory/Crypt.php" name="lib/Horde/Core/Factory/Crypt.php" />
    <install as="Horde/Core/Factory/Data.php" name="lib/Horde/Core/Factory/Data.php" />