Always utilize global Horde_Browser object
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 11 Feb 2010 19:20:20 +0000 (12:20 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 11 Feb 2010 19:58:30 +0000 (12:58 -0700)
23 files changed:
ansel/image.php
ansel/img/upload.php
ansel/lib/XPPublisher.php
ansel/xppublish.php
framework/Block/lib/Horde/Block/Layout/View.php
framework/Browser/lib/Horde/Browser.php
framework/Browser/package.xml
framework/Core/lib/Horde.php
framework/Core/lib/Horde/Registry.php
framework/Data/Data.php
framework/Data/Data/tsv.php
framework/Form/Form/Type.php
framework/Mobile/Mobile.php
framework/Model/lib/Horde/Form.php
framework/Notification/lib/Horde/Notification/Listener/Status.php
framework/Tree/lib/Horde/Tree/Javascript.php
framework/Util/lib/Horde/Util.php
gollem/manager.php
horde/services/problem.php
imp/lib/Application.php
koward/lib/Koward.php
news/add.php
wicked/lib/Page/AttachedFiles.php

index 9142e93..59b39e8 100644 (file)
@@ -190,7 +190,7 @@ case 'save':
         /* See if we were replacing photo */
         if (!empty($info['file0']['file'])) {
             try {
-                Horde_Browser::wasFileUploaded('file0');
+                $GLOBALS['browser']->wasFileUploaded('file0');
                 if (filesize($info['file0']['file'])) {
                     /* Read in the uploaded data. */
                     $data = file_get_contents($info['file0']['file']);
index 7e17729..6492c7a 100644 (file)
@@ -37,10 +37,7 @@ if ($form->validate($vars)) {
 
         /* Save new image. */
         try {
-            Horde_Browser::wasFileUploaded('file' . $i);
-            if (!filesize($info['file' . $i]['file'])) {
-                throw new Horde_Browser_Exception();
-            }
+            $GLOBALS['browser']->wasFileUploaded('file' . $i);
         } catch (Horde_Browser_Exception $e) {
             if (!empty($info['file' . $i]['error'])) {
                 $notification->push(sprintf(_("There was a problem uploading the photo: %s"), $info['file' . $i]['error']), 'horde.error');
index 7575fed..5623202 100644 (file)
@@ -32,8 +32,7 @@ class Ansel_XPPublisher
      */
     public function sendRegFile($appKey, $displayName, $description, $href, $icon)
     {
-        $browser = Horde_Browser::singleton();
-        $browser->downloadHeaders('install_registry.reg', 'application/octet-stream');
+        $GLOBALS['browser']->downloadHeaders('install_registry.reg', 'application/octet-stream');
 
         $lines = array(
             'Windows Registry Editor Version 5.00',
index a0e321c..3b6af53 100644 (file)
@@ -180,7 +180,7 @@ if ($cmd == 'add') {
         $error = _("No file specified");
     } else {
         try {
-            Horde_Browser::wasFileUploaded('imagefile', _("photo"));
+            $GLOBALS['browser']->wasFileUploaded('imagefile', _("photo"));
             $image = &Ansel::getImageFromFile($file, array('image_filename' => $name));
             if (is_a($image, 'PEAR_Error')) {
                 $error = $image->getMessage();
index f897db7..f067c3b 100644 (file)
@@ -53,7 +53,6 @@ class Horde_Block_Layout_View extends Horde_Block_Layout
      */
     public function toHtml()
     {
-        $browser = Horde_Browser::singleton();
         $tplDir = $GLOBALS['registry']->get('templates', 'horde');
         $interval = $GLOBALS['prefs']->getValue('summary_refresh_time');
 
@@ -87,7 +86,7 @@ class Horde_Block_Layout_View extends Horde_Block_Layout
                             if ($content instanceof PEAR_Error) {
                                 $content = $content->getMessage();
                             }
-                            if ($browser->hasFeature('xmlhttpreq')) {
+                            if ($GLOBALS['browser']->hasFeature('xmlhttpreq')) {
                                 $refresh_time = isset($item['params']['params']['_refresh_time']) ? $item['params']['params']['_refresh_time'] : $interval;
                             }
                             ob_start();
index 21b73d1..33b347f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The Horde_Browser:: class provides capability information for the current
+ * The Horde_Browser class provides capability information for the current
  * web client.
  *
  * Browser identification is performed by examining the HTTP_USER_AGENT
@@ -262,15 +262,6 @@ class Horde_Browser
     protected $_images = array('jpeg', 'gif', 'png', 'pjpeg', 'x-png', 'bmp');
 
     /**
-     * @deprecated
-     */
-    public static function singleton($userAgent = null, $accept = null)
-    {
-        // trigger_error - warning?
-        return new self($userAgent, $accept);
-    }
-
-    /**
      * Creates a browser instance (Constructor).
      *
      * @param string $userAgent  The browser string to parse.
index 77f91ef..6678e5e 100644 (file)
@@ -6,7 +6,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  <name>Browser</name>
  <channel>pear.horde.org</channel>
  <summary>Horde Browser API</summary>
- <description>The Horde_Browser:: class provides an API for getting information
+ <description>The Horde_Browser class provides an API for getting information
 about the current user&apos;s browser and its capabilities.
  </description>
  <lead>
index cc7465b..f1b3850 100644 (file)
@@ -1644,8 +1644,7 @@ HTML;
      */
     static public function allowOutputCompression()
     {
-        $browser = Horde_Browser::singleton();
-        return !$browser->hasQuirk('buggy_compression') &&
+        return !$GLOBALS['browser']->hasQuirk('buggy_compression') &&
                (ini_get('zlib.output_compression') == '') &&
                (ini_get('zend_accelerator.compress_all') == '') &&
                (ini_get('output_handler') != 'ob_gzhandler');
index bdc9052..6bd63a6 100644 (file)
@@ -158,7 +158,9 @@ class Horde_Registry
         $s_ctrl = 0;
         switch ($args['session_control']) {
         case 'netscape':
-            if (Horde_Browser::singleton()->isBrowser('mozilla')) {
+            // Chicken/egg: Browser object doesn't exist yet.
+            $browser = new Horde_Browser();
+            if ($browser->isBrowser('mozilla')) {
                 session_cache_limiter('private, must-revalidate');
             }
             break;
@@ -236,7 +238,7 @@ class Horde_Registry
         $injector->setInstance('Horde_Registry', $this);
 
         /* Initialize browser object. */
-        $GLOBALS['browser'] = Horde_Browser::singleton();
+        $GLOBALS['browser'] = new Horde_Browser();
         $injector->setInstance('Horde_Browser', $GLOBALS['browser']);
 
         /* Import and global Horde's configuration values. Almost a chicken
index 7998d88..f75343f 100644 (file)
@@ -94,10 +94,7 @@ class Horde_Data extends PEAR {
      */
     function getNewline()
     {
-        require_once 'Horde/Browser.php';
-        $browser = &Horde_Browser::singleton();
-
-        switch ($browser->getPlatform()) {
+        switch ($GLOBALS['browser']->getPlatform()) {
         case 'win':
             return "\r\n";
 
@@ -313,7 +310,7 @@ class Horde_Data extends PEAR {
             /* Sanitize uploaded file. */
             $import_format = Horde_Util::getFormData('import_format');
             try {
-                Horde_Browser::wasFileUploaded('import_file', $param['file_types'][$import_format]);
+                $GLOBALS['browser']->wasFileUploaded('import_file', $param['file_types'][$import_format]);
             } catch (Horde_Exception $e) {
                 PEAR::raiseError($e->getMessage());
             }
index 9d00db0..7779a54 100644 (file)
@@ -184,7 +184,7 @@ class Horde_Data_tsv extends Horde_Data {
             /* Move uploaded file so that we can read it again in the next step
                after the user gave some format details. */
             try {
-                Horde_Browser::wasFileUploaded('import_file', _("TSV file"));
+                $GLOBALS['browser']->wasFileUploaded('import_file', _("TSV file"));
             } catch (Horde_Browser_Exception $e) {
                 return PEAR::raiseError($e->getMessage());
             }
index da419df..2253b82 100644 (file)
@@ -871,7 +871,7 @@ class Horde_Form_Type_file extends Horde_Form_Type {
     {
         if ($var->isRequired()) {
             try {
-                Horde_Browser::wasFileUploaded($var->getVarName());
+                $GLOBALS['browser']->wasFileUploaded($var->getVarName());
             } catch (Horde_Browser_Exception $e) {
                 $message = $e->getMessage();
                 return false;
@@ -885,7 +885,7 @@ class Horde_Form_Type_file extends Horde_Form_Type {
     {
         $name = $var->getVarName();
         try {
-            Horde_Browser::wasFileUploaded($name);
+            $GLOBALS['browser']->wasFileUploaded($name);
             $info['name'] = Horde_Util::dispelMagicQuotes($_FILES[$name]['name']);
             $info['type'] = $_FILES[$name]['type'];
             $info['tmp_name'] = $_FILES[$name]['tmp_name'];
@@ -1074,7 +1074,7 @@ class Horde_Form_Type_image extends Horde_Form_Type {
         $varname = $var->getVarName();
 
         try {
-            Horde_Browser::wasFileUploaded($varname . '[new]');
+            $GLOBALS['browser']->wasFileUploaded($varname . '[new]');
             $this->_uploaded = true;
 
             /* A file has been uploaded on this submit. Save to temp dir for
index 27717a1..3f0b474 100644 (file)
@@ -139,12 +139,9 @@ class Horde_Mobile extends Horde_Mobile_card {
             $this->_title = $title;
         }
 
-        require_once 'Horde/Browser.php';
-        $browser = &Horde_Browser::singleton($agent);
-
-        if ($browser->hasFeature('html')) {
+        if ($GLOBALS['browser']->hasFeature('html')) {
             $ml = 'html';
-        } elseif ($browser->hasFeature('wml')) {
+        } elseif ($GLOBALS['browser']->hasFeature('wml')) {
             $ml = 'wml';
         } else {
             $ml = 'html';
index 18d60b8..bccd710 100644 (file)
@@ -1090,7 +1090,7 @@ class Horde_Form_Type_file extends Horde_Form_Type {
     {
         if ($var->isRequired()) {
             try {
-                Horde_Browser::wasFileUploaded($var->getVarName());
+                $GLOBALS['browser']->wasFileUploaded($var->getVarName());
             } catch (Horde_Browser_Exception $e) {
                 $message = $e->getMessage();
                 return false;
@@ -1104,7 +1104,7 @@ class Horde_Form_Type_file extends Horde_Form_Type {
     {
         $name = $var->getVarName();
         try {
-            Horde_Browser::wasFileUploaded($name);
+            $GLOBALS['browser']->wasFileUploaded($name);
             $info['name'] = $_FILES[$name]['name'];
             $info['type'] = $_FILES[$name]['type'];
             $info['tmp_name'] = $_FILES[$name]['tmp_name'];
index 1a974a6..e91aa69 100644 (file)
@@ -134,8 +134,7 @@ class Horde_Notification_Listener_Status extends Horde_Notification_Listener
             $message = Horde::link(Horde::url($GLOBALS['registry']->linkByPackage($alarm['params']['notify']['show']['__app'], 'show', $alarm['params']['notify']['show'])), $alarm['text']) . $message . '</a>';
         }
 
-        $browser = Horde_Browser::singleton();
-        if (!empty($alarm['user']) && $browser->hasFeature('xmlhttpreq')) {
+        if (!empty($alarm['user']) && $GLOBALS['browser']->hasFeature('xmlhttpreq')) {
             Horde::addScriptFile('prototype.js', 'horde');
             $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/snooze.php', true);
             $opts = array('-1' => _("Dismiss"),
index c306a6b..6a4f8d7 100644 (file)
@@ -103,8 +103,7 @@ class Horde_Tree_Javascript extends Horde_Tree
      */
     public function isSupported()
     {
-        $browser = Horde_Browser::singleton();
-        return $browser->hasFeature('dom');
+        return $GLOBALS['browser']->hasFeature('dom');
     }
 
     /**
index f191c1d..a7a4375 100644 (file)
@@ -281,8 +281,7 @@ class Horde_Util
     {
         /* We may need to set a dummy parameter 'nocache' since some
          * browsers do not always honor the 'no-cache' header. */
-        $browser = Horde_Browser::singleton();
-        if ($browser->hasQuirk('cache_same_url')) {
+        if ($GLOBALS['browser']->hasQuirk('cache_same_url')) {
             if (is_null(self::$_randnum)) {
                 self::$_randnum = base_convert(microtime(), 10, 36);
             }
index ff47a7e..84c82cf 100644 (file)
@@ -109,7 +109,7 @@ case 'upload_file':
             $val = 'file_upload_' . $i;
             if (isset($_FILES[$val]) && ($_FILES[$val]['error'] != 4)) {
                 try {
-                    Horde_Browser::wasFileUploaded($val);
+                    $GLOBALS['browser']->wasFileUploaded($val);
                     $filename = Horde_Util::dispelMagicQuotes($_FILES[$val]['name']);
                     $res = Gollem::writeFile($old_dir, $filename, $_FILES[$val]['tmp_name']);
                     if (is_a($res, 'PEAR_Error')) {
index a587ef8..84462b4 100644 (file)
@@ -54,7 +54,7 @@ case 'send_problem_report':
         $attachment = null;
         if (!empty($conf['problems']['attachments'])) {
             try {
-                Horde_Browser::wasFileUploaded('attachment', _("attachment"));
+                $GLOBALS['browser']->wasFileUploaded('attachment', _("attachment"));
                 $attachment = $_FILES['attachment'];
             } catch (Horde_Browser_Exception $e) {
                 if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
index 0db7ae7..3e01609 100644 (file)
@@ -229,12 +229,9 @@ class IMP_Application extends Horde_Registry_Application
         } else {
             $views = array();
             if (!($view_cookie = Horde_Util::getFormData('imp_select_view'))) {
-                if (isset($_COOKIE['default_imp_view'])) {
-                    $view_cookie = $_COOKIE['default_imp_view'];
-                } else {
-                    $browser = Horde_Browser::singleton();
-                    $view_cookie = $browser->isMobile() ? 'mimp' : 'imp';
-                }
+                $view_cookie = isset($_COOKIE['default_imp_view'])
+                    ? $_COOKIE['default_imp_view']
+                    : ($GLOBALS['browser']->isMobile() ? 'mimp' : 'imp');
             }
 
             $params['imp_select_view'] = array(
index 9503f6b..16ae833 100644 (file)
@@ -55,13 +55,6 @@ class Koward {
         $notification = Horde_Notification::singleton();
         $notification->attach('status');
 
-        /* Browser detection object. */
-        if (class_exists('Horde_Browser')) {
-            $browser = Horde_Browser::singleton();
-        } else if (class_exists('Browser')) {
-            $browser = Browser::singleton();
-        }
-
         if ($webroot === null) {
             $webroot = $registry->get('webroot', 'koward');
         }
index fbf73f2..65c007e 100644 (file)
@@ -474,7 +474,7 @@ if ($form->validate()) {
             for ($i = 1; $i < 6; $i++) {
                 $input = 'file_' . $key . '_' . $i;
                 try {
-                    Horde_Browser::wasFileUploaded($input);
+                    $GLOBALS['browser']->wasFileUploaded($input);
                     $file_id = $news->write_db->nextID($news->prefix . '_files');
                     if ($file_id instanceof PEAR_Error) {
                         $notification->push($file_id);
index da6098f..875c84a 100644 (file)
@@ -213,7 +213,7 @@ class AttachedFiles extends Page {
         }
 
         try {
-            Horde_Browser::wasFileUploaded('attachment_file', _("attachment"));
+            $GLOBALS['browser']->wasFileUploaded('attachment_file', _("attachment"));
         } catch (Horde_Browser_Exception $e) {
             $notification->push($e, 'horde.error');
             return;