Fixes found through lint checking
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 20 Jul 2009 04:58:12 +0000 (22:58 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 20 Jul 2009 19:16:10 +0000 (13:16 -0600)
36 files changed:
framework/Browser/lib/Horde/Browser.php
framework/Cache/lib/Horde/Cache.php
framework/Cipher/lib/Horde/Cipher/BlockMode/Cfb64.php
framework/Compress/lib/Horde/Compress/Rar.php
framework/Compress/lib/Horde/Compress/Tar.php
framework/Compress/lib/Horde/Compress/Tnef.php
framework/Compress/lib/Horde/Compress/Zip.php
framework/Core/lib/Horde.php
framework/Core/lib/Horde/Config.php
framework/Core/lib/Horde/Menu.php
framework/Crypt/lib/Horde/Crypt.php
framework/Crypt/lib/Horde/Crypt/Pgp.php
framework/Crypt/lib/Horde/Crypt/Smime.php
framework/Editor/lib/Horde/Editor.php
framework/Imap_Client/lib/Horde/Imap/Client/Cclient.php
framework/Imap_Client/lib/Horde/Imap/Client/Cclient/Pop3.php
framework/Imap_Client/lib/Horde/Imap/Client/Socket.php
framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php
framework/Mime/lib/Horde/Mime/Address.php
framework/Mime/lib/Horde/Mime/Exception.php
framework/Mime/lib/Horde/Mime/Headers.php
framework/Mime/lib/Horde/Mime/Magic.php
framework/Mime/lib/Horde/Mime/Mail.php
framework/Mime/lib/Horde/Mime/Mdn.php
framework/Mime/lib/Horde/Mime/Part.php
framework/Mime/lib/Horde/Mime/Viewer/Default.php
framework/Mime/lib/Horde/Mime/Viewer/Driver.php
framework/Mime/lib/Horde/Mime/Viewer/Enscript.php
framework/Mime/lib/Horde/Mime/Viewer/Html.php
framework/Mime/lib/Horde/Mime/Viewer/Php.php
framework/Mime/lib/Horde/Mime/Viewer/Rar.php
framework/Mime/lib/Horde/Mime/Viewer/Srchighlite.php
framework/Mime/lib/Horde/Mime/Viewer/Tgz.php
framework/Mime/lib/Horde/Mime/Viewer/Zip.php
framework/Util/lib/Horde/Util.php
framework/Util/lib/Horde/Variables.php

index 022b0e8..ad6900b 100644 (file)
@@ -556,7 +556,7 @@ class Horde_Browser
                     list($this->_majorVersion, $this->_minorVersion) = explode('.', $version_string[1], 2);
                     $this->_minorVersion = intval($this->_minorVersion);
                     $this->setFeature('rte');
-                } elseif ($this->_majorVersion >= 412)  {
+                } elseif ($this->_majorVersion >= 412) {
                     $this->_majorVersion = 2;
                     $this->_minorVersion = 0;
                 } else {
index bcf2804..12b09e2 100644 (file)
@@ -84,7 +84,7 @@ class Horde_Cache
         $signature = hash('md5', serialize(array($driver, $params)));
 
         if (!isset(self::$_instances[$signature])) {
-            self::$_instances[$signature] = Horde_Cache::factory($driver, $params);
+            self::$_instances[$signature] = self::factory($driver, $params);
         }
 
         return self::$_instances[$signature];
index 96a7fe7..8f677bb 100644 (file)
@@ -24,7 +24,7 @@ class Horde_Cipher_BlockMode_Cfb64 extends Horde_Cipher_BlockMode
      *
      * @return string  The encrypted data.
      */
-    function encrypt($cipher, $plaintext)
+    public function encrypt($cipher, $plaintext)
     {
         $encrypted = '';
 
@@ -53,7 +53,7 @@ class Horde_Cipher_BlockMode_Cfb64 extends Horde_Cipher_BlockMode
      *
      * @return string  The decrypted data.
      */
-    function decrypt($cipher, $ciphertext)
+    public function decrypt($cipher, $ciphertext)
     {
         $decrypted = '';
 
index 6e77d96..a91889e 100644 (file)
@@ -54,10 +54,11 @@ class Horde_Compress_Rar extends Horde_Compress
             throw new Horde_Exception(_("Invalid RAR data."));
         }
 
+        $data_len = strlen($data);
         $position = $blockStart + 7;
         $return_array = array();
 
-        while ($position < strlen($data)) {
+        while ($position < $data_len) {
             $head_crc = substr($data, $position + 0, 2);
             $head_type = ord(substr($data, $position + 2, 1));
             $head_flags = unpack('vFlags', substr($data, $position + 3, 2));
index 60c9bea..5558147 100644 (file)
@@ -64,10 +64,11 @@ class Horde_Compress_Tar extends Horde_Compress
      */
     public function decompress($data, $params = array())
     {
+        $data_len = strlen($data);
         $position = 0;
         $return_array = array();
 
-        while ($position < strlen($data)) {
+        while ($position < $data_len) {
             $info = @unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", substr($data, $position));
             if (!$info) {
                 throw new Horde_Exception(_("Unable to decompress data."));
@@ -105,8 +106,6 @@ class Horde_Compress_Tar extends Horde_Compress
                         (($mode & 0x004) ? 'r' : '-') .
                         (($mode & 0x002) ? 'w' : '-') .
                         (($mode & 0x001) ? 'x' : '-');
-                } else {
-                    /* Some other type. */
                 }
 
                 $return_array[] = $file;
index 1ebe1fa..4d0ecc6 100644 (file)
@@ -237,7 +237,7 @@ class Horde_Compress_Tnef extends Horde_Compress
                     $datalen = $length + ((4 - ($length % 4)) % 4);
 
                     if ($attr_type == self::MAPI_STRING) {
-                        $length -= 1;
+                        --$length;
                     }
 
                     /* Read and truncate to length. */
index 4dbce83..510961d 100644 (file)
@@ -237,14 +237,16 @@ class Horde_Compress_Zip extends Horde_Compress
         /* Get details from local file header. */
         $fhStart = strpos($data, self::FILE_HEADER);
 
+        $data_len = strlen($data);
+
         do {
-            if (strlen($data) < $fhStart + 34) {
+            if ($data_len < $fhStart + 34) {
                 throw new Horde_Exception(_("Invalid ZIP data"));
             }
             $info = unpack('vMethod/VTime/VCRC32/VCompressed/VUncompressed/vLength/vExtraLength', substr($data, $fhStart + 8, 25));
             $name = substr($data, $fhStart + 30, $info['Length']);
             $entries[$name]['_dataStart'] = $fhStart + 30 + $info['Length'] + $info['ExtraLength'];
-        } while (strlen($data) > $fhStart + 30 + $info['Length'] &&
+        } while ($data_len > $fhStart + 30 + $info['Length'] &&
                  ($fhStart = strpos($data, self::FILE_HEADER, $fhStart + 30 + $info['Length'])) !== false);
 
         return array_values($entries);
@@ -365,25 +367,25 @@ class Horde_Compress_Zip extends Horde_Compress
         $old_offset = ftell($this->_tmp);
 
         fwrite($this->_tmp,
-            self::FILE_HEADER .        /* Begin creating the ZIP data. */
-            $common .                   /* Common data. */
-            $name .                     /* File name. */
-            $zdata                      /* "File data" segment. */
+            self::FILE_HEADER .  /* Begin creating the ZIP data. */
+            $common .            /* Common data. */
+            $name .              /* File name. */
+            $zdata               /* "File data" segment. */
         );
 
         /* Add to central directory record. */
         $this->_ctrldir[] =
             self::CTRL_DIR_HEADER .
-            "\x00\x00" .               /* Version made by. */
-            $common .                  /* Common data. */
-            pack('v', 0) .             /* File comment length. */
-            pack('v', 0) .             /* Disk number start. */
-            pack('v', 0) .             /* Internal file attributes. */
-            pack('V', 32) .            /* External file attributes -
-                                          'archive' bit set. */
-            pack('V', $old_offset) .   /* Relative offset of local
-                                          header. */
-            $name;                     /* File name. */
+            "\x00\x00" .              /* Version made by. */
+            $common .                 /* Common data. */
+            pack('v', 0) .            /* File comment length. */
+            pack('v', 0) .            /* Disk number start. */
+            pack('v', 0) .            /* Internal file attributes. */
+            pack('V', 32) .           /* External file attributes -
+                                       * 'archive' bit set. */
+            pack('V', $old_offset) .  /* Relative offset of local
+                                       * header. */
+            $name;                    /* File name. */
     }
 
 }
index 4cf67cb..5d58e59 100644 (file)
@@ -702,7 +702,7 @@ HTML;
         // Return an error if neither main or vhosted versions of the config
         // file exist.
         if (!$was_included) {
-            Horde::logMessage(sprintf('Failed to import configuration file "%s".', $config_dir . $config_file), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+            self::logMessage(sprintf('Failed to import configuration file "%s".', $config_dir . $config_file), __FILE__, __LINE__, PEAR_LOG_DEBUG);
             return;
         }
 
@@ -1972,7 +1972,7 @@ HTML;
             $url .= '/' . $key . '=' . rawurlencode(strval($val));
         }
 
-        return Horde::url($url);
+        return self::url($url);
     }
 
 }
index f1a0890..b0a902e 100644 (file)
@@ -1170,7 +1170,7 @@ class Horde_Config
         $ctx = explode('|', $ctx);
         $ptr = $this->_currentConfig;
 
-        for ($i = 0; $i < count($ctx); ++$i) {
+        for ($i = 0, $ctx_count = count($ctx); $i < $ctx_count; ++$i) {
             if (!isset($ptr[$ctx[$i]])) {
                 return array($default, true);
             }
index 2c9cbc4..b324a4b 100644 (file)
@@ -203,8 +203,8 @@ class Horde_Menu
 
         /* Sort to match explicitly set positions. */
         ksort($this->_menu);
-        if (!empty($GLOBALS['nls']['rtl'][$GLOBALS['language']]))  {
-            $this->_menu = array_reverse($this->_menu) ;
+        if (!empty($GLOBALS['nls']['rtl'][$GLOBALS['language']])) {
+            $this->_menu = array_reverse($this->_menu);
         }
 
         $menu_view = $prefs->getValue('menu_view');
index ee4a865..9510774 100644 (file)
@@ -89,7 +89,7 @@ class Horde_Crypt
         $signature = hash('md5', serialize(array($driver, $params)));
 
         if (!isset(self::$_instances[$signature])) {
-            self::$_instances[$signature] = Horde_Crypt::factory($driver, $params);
+            self::$_instances[$signature] = self::factory($driver, $params);
         }
 
         return self::$_instances[$signature];
index afbbb26..4be563b 100644 (file)
@@ -654,7 +654,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
 
         /* Try to decrypt the message. */
         try {
-           $this->decrypt($result, array('type' => 'message', 'pubkey' => $public_key, 'privkey' => $private_key, 'passphrase' => $passphrase));
+            $this->decrypt($result, array('type' => 'message', 'pubkey' => $public_key, 'privkey' => $private_key, 'passphrase' => $passphrase));
         } catch (Horde_Exception $e) {
             return false;
         }
@@ -1394,7 +1394,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         /* Setup the multipart MIME Part. */
         $part = new Horde_Mime_Part();
         $part->setType('multipart/signed');
-        $part->setContents('This message is in MIME format and has been PGP signed.' . "\n");
+        $part->setContents("This message is in MIME format and has been PGP signed.\n");
         $part->addPart($mime_part);
         $part->addPart($pgp_sign);
         $part->setContentTypeParameter('protocol', 'application/pgp-signature');
@@ -1429,7 +1429,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $part->setCharset($charset);
         $part->setContentTypeParameter('protocol', 'application/pgp-encrypted');
         $part->setDescription(Horde_String::convertCharset(_("PGP Encrypted Data"), Horde_Nls::getCharset(), $charset));
-        $part->setContents('This message is in MIME format and has been PGP encrypted.' . "\n");
+        $part->setContents("This message is in MIME format and has been PGP encrypted.\n");
 
         $part1 = new Horde_Mime_Part();
         $part1->setType('application/pgp-encrypted');
@@ -1468,7 +1468,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
          * know whether a subclass has extended these methods. */
         $part = $this->signMIMEPart($mime_part, $sign_params);
         $part = $this->encryptMIMEPart($part, $encrypt_params);
-        $part->setContents('This message is in MIME format and has been PGP signed and encrypted.' . "\n");
+        $part->setContents("This message is in MIME format and has been PGP signed and encrypted.\n");
 
         $charset = Horde_Nls::getEmailCharset();
         $part->setCharset($charset);
@@ -1546,7 +1546,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $cmdline = implode(' ', array_merge($this->_gnupg, $options));
 
         if ($mode == 'w') {
-            if ($fp = popen($cmdline, 'w')) {;
+            if ($fp = popen($cmdline, 'w')) {
                 $win32 = !strncasecmp(PHP_OS, 'WIN', 3);
 
                 if (!is_array($input)) {
@@ -1618,7 +1618,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $cmdline = array(
             $keyring,
             '--command-fd 0',
-            '--gen-revoke' . ' ' . $email,
+            '--gen-revoke ' . $email,
         );
         $results = $this->_callGpg($cmdline, 'w', $input, true);
 
index 8eceaa5..5049cf3 100644 (file)
@@ -262,7 +262,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
 
         $smime_part = new Horde_Mime_Part();
         $smime_part->setType('multipart/signed');
-        $smime_part->setContents('This is a cryptographically signed message in MIME format.' . "\n");
+        $smime_part->setContents("This is a cryptographically signed message in MIME format.\n");
         $smime_part->setContentTypeParameter('protocol', 'application/pkcs7-signature');
         $smime_part->setContentTypeParameter('micalg', 'sha1');
         $smime_part->addPart($mime_part);
@@ -581,7 +581,8 @@ class Horde_Crypt_Smime extends Horde_Crypt
                 $text .= "&nbsp;&nbsp;" . sprintf(_("RSA Public Key (%d bit)"), strlen($modulus_hex) * 4) . ":\n";
 
                 $modulus_str = '';
-                for ($i = 0; $i < strlen($modulus_hex); $i += 2) {
+
+                for ($i = 0, $m_len = strlen($modulus_hex); $i < $m_len; $i += 2) {
                     if (($i % 32) == 0) {
                         $modulus_str .= "\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                     }
@@ -621,7 +622,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
         foreach ($cert_details['fingerprints'] as $hash => $fingerprint) {
             $label = sprintf(_("%s Fingerprint"), Horde_String::upper($hash));
             $fingerprint_str = '';
-            for ($i = 0; $i < strlen($fingerprint); $i += 2) {
+            for ($i = 0, $f_len = strlen($fingerprint); $i < $f_len; $i += 2) {
                 $fingerprint_str .= substr($fingerprint, $i, 2) . ':';
             }
             $text .= sprintf("&nbsp;&nbsp;%s:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%s\n", $label, $fingerprint_str);
@@ -630,7 +631,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
         $text .= sprintf("&nbsp;&nbsp;%s:", _("Signature"));
 
         $sig_str = '';
-        for ($i = 0; $i < strlen($cert_details['signature']); $i++) {
+        for ($i = 0, $s_len = strlen($cert_details['signature']); $i < $s_len; ++$i) {
             if (($i % 16) == 0) {
                 $sig_str .= "\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
             }
@@ -824,7 +825,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
 
                 $newVal = '';
 
-                for ($i = 0; $i < strlen($val); $i++) {
+                for ($i = 0, $v_len = strlen($val); $i < $v_len; ++$i) {
                     $newVal .= sprintf("%02x:", ord($val[$i]));
                 }
                 $cert_details['certificate']['extensions'][$oid] = $newVal;
@@ -836,7 +837,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
                     $val = $val[1];
 
                     $newVal = '';
-                    for ($i = 0; $i < strlen($val); $i++) {
+                    for ($i = 0, $v_len = strlen($val); $i < $v_len; ++$i) {
                         $newVal .= sprintf("%02x:", ord($val[$i]));
                     }
                     $cert_details['certificate']['extensions'][$oid] = $newVal;
@@ -940,13 +941,13 @@ class Horde_Crypt_Smime extends Horde_Crypt
                 $value = 0;
                 if ($len <= 4) {
                     /* Method works fine for small integers */
-                    for ($i = 0; $i < strlen($integer_data); $i++) {
+                    for ($i = 0, $i_len = strlen($integer_data); $i < $i_len; ++$i) {
                         $value = ($value << 8) | ord($integer_data[$i]);
                     }
                 } else {
                     /* Method works for arbitrary length integers */
                     if (Horde_Util::extensionExists('bcmath')) {
-                        for ($i = 0; $i < strlen($integer_data); $i++) {
+                        for ($i = 0, $i_len = strlen($integer_data); $i < $i_len; ++$i) {
                             $value = bcadd(bcmul($value, 256), ord($integer_data[$i]));
                         }
                     } else {
@@ -1014,7 +1015,9 @@ class Horde_Crypt_Smime extends Horde_Crypt
 
                 $value = 0;
                 $i = 1;
-                while ($i < strlen($oid_data)) {
+                $o_len = strlen($oid_data);
+
+                while ($i < $o_len) {
                     $value = $value << 7;
                     $value = $value | (ord($oid_data[$i]) & 0x7f);
 
index 3cd6534..1f753c0 100644 (file)
@@ -82,7 +82,7 @@ class Horde_Editor
 
         $signature = serialize(array($driver, $params));
         if (!array_key_exists($signature, $instances)) {
-            $instances[$signature] = Horde_Editor::factory($driver, $params);
+            $instances[$signature] = self::factory($driver, $params);
         }
 
         return $instances[$signature];
index 9b4fdd5..dab4348 100644 (file)
@@ -825,7 +825,7 @@ class Horde_Imap_Client_Cclient extends Horde_Imap_Client_Base
         return $ret;
     }
 
-   /**
+    /**
      * Set the comparator to use for searching/sorting (RFC 5255).
      *
      * @param string $comparator  The comparator string (see RFC 4790 [3.1] -
index 684c107..56df970 100644 (file)
@@ -250,7 +250,7 @@ class Horde_Imap_Client_Cclient_Pop3 extends Horde_Imap_Client_Cclient
         return parent::_search($query, $options);
     }
 
-   /**
+    /**
      * Set the comparator to use for searching/sorting (RFC 5255).
      *
      * @param string $comparator  The comparator string (see RFC 4790 [3.1] -
index 23270f9..d41def6 100644 (file)
@@ -2017,7 +2017,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
         $this->_temp['threadparse'] = array('base' => null, 'resp' => array());
 
         reset($data);
-        while(list($k, $v) = each($data)) {
+        while (list($k, $v) = each($data)) {
             $subject = empty($v['envelope']['subject'])
                 ? ''
                 : $this->utils->getBaseSubject($v['envelope']['subject']);
@@ -3219,7 +3219,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
             $this->_temp['logout'] = true;
             $this->logout();
             if ($this->_debug) {
-                fwrite($this->_debug, '[ERROR: IMAP server closed the connection.]' . "\n");
+                fwrite($this->_debug, "[ERROR: IMAP server closed the connection.]\n");
             }
             throw new Horde_Imap_Client_Exception('IMAP server closed the connection unexpectedly.', Horde_Imap_Client_Exception::DISCONNECT);
         }
@@ -3271,7 +3271,7 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base
 
         if (!$got_data) {
             if ($this->_debug) {
-                fwrite($this->_debug, '[ERROR: IMAP read/timeout error.]' . "\n");
+                fwrite($this->_debug, "[ERROR: IMAP read/timeout error.]\n");
             }
             throw new Horde_Imap_Client_Exception('IMAP read error or IMAP connection timed out.', Horde_Imap_Client_Exception::SERVER_READERROR);
         }
index 1c16f7e..3e29685 100644 (file)
@@ -688,7 +688,7 @@ class Horde_Imap_Client_Socket_Pop3 extends Horde_Imap_Client_Base
         return $ret;
     }
 
-   /**
+    /**
      * Set the comparator to use for searching/sorting (RFC 5255).
      *
      * @param string $comparator  The comparator string (see RFC 4790 [3.1] -
@@ -1059,15 +1059,15 @@ class Horde_Imap_Client_Socket_Pop3 extends Horde_Imap_Client_Base
 
         /* Only support deleting/undeleting messages. */
         if (isset($options['replace'])) {
-            $delete = (bool) (count(array_intersect($options['replace'], array('\\deleted'))));
+            $delete = (bool)(count(array_intersect($options['replace'], array('\\deleted'))));
             $reset = !$delete;
         } else {
             if (!empty($options['add'])) {
-                $delete = (bool) (count(array_intersect($options['add'], array('\\deleted'))));
+                $delete = (bool)(count(array_intersect($options['add'], array('\\deleted'))));
             }
 
             if (!empty($options['remove'])) {
-                $reset = !(bool) (count(array_intersect($options['remove'], array('\\deleted'))));
+                $reset = !(bool)(count(array_intersect($options['remove'], array('\\deleted'))));
             }
         }
 
index af50439..8a1c3f4 100644 (file)
@@ -392,11 +392,11 @@ class Horde_Mime_Address
 
         /* Convert objects to arrays. */
         foreach (array_keys($ret) as $key) {
-            $ret[$key] = (array) $ret[$key];
+            $ret[$key] = (array)$ret[$key];
             if (isset($ret[$key]['addresses'])) {
                 $ptr = &$ret[$key]['addresses'];
                 foreach (array_keys($ptr) as $key2) {
-                    $ptr[$key2] = (array) $ptr[$key2];
+                    $ptr[$key2] = (array)$ptr[$key2];
                 }
             }
         }
index 8e78717..2772c60 100644 (file)
@@ -11,4 +11,6 @@
  * @category Horde
  * @package  Horde_Mime
  */
-class Horde_Mime_Exception extends Horde_Exception {}
+class Horde_Mime_Exception extends Horde_Exception
+{
+}
index f578d09..9cc0e91 100644 (file)
@@ -273,7 +273,7 @@ class Horde_Mime_Headers
      * <pre>
      * 'decode' - (boolean) MIME decode the value?
      * 'params' - (array) MIME parameters for Content-Type or
-     *            Content-Disposition
+     *            Content-Disposition.
      * </pre>
      */
     public function addHeader($header, $value, $options = array())
@@ -351,7 +351,7 @@ class Horde_Mime_Headers
      * <pre>
      * 'decode' - (boolean) MIME decode the value?
      * 'params' - (array) MIME parameters for Content-Type or
-     *            Content-Disposition
+     *            Content-Disposition.
      * </pre>
      *
      * @return boolean  True if value was set.
@@ -359,7 +359,7 @@ class Horde_Mime_Headers
     public function setValue($header, $value, $options = array())
     {
         if (isset($this->_headers[Horde_String::lower($header)])) {
-            $this->addHeader($header, $value, $decode);
+            $this->addHeader($header, $value, $options);
             return true;
         }
 
@@ -509,7 +509,7 @@ class Horde_Mime_Headers
      */
     public function listHeadersExist()
     {
-        return (bool) count(array_intersect(array_keys($this->listHeaders()), array_keys($this->_headers)));
+        return (bool)count(array_intersect(array_keys($this->listHeaders()), array_keys($this->_headers)));
     }
 
     /**
index 65c5b26..609b449 100644 (file)
@@ -58,7 +58,7 @@ class Horde_Mime_Magic
     static public function extToMime($ext)
     {
         if (empty($ext)) {
-           return 'application/octet-stream';
+            return 'application/octet-stream';
         }
 
         $ext = Horde_String::lower($ext);
index cf809a3..847295a 100644 (file)
@@ -89,8 +89,8 @@ class Horde_Mime_Mail
      *
      * @throws Horde_Mime_Exception
      */
-    function __construct($subject = null, $body = null, $to = null,
-                         $from = null, $charset = null)
+    public function __construct($subject = null, $body = null, $to = null,
+                                $from = null, $charset = null)
     {
         /* Set SERVER_NAME. */
         if (!isset($_SERVER['SERVER_NAME'])) {
index c11cb7a..be54b59 100644 (file)
@@ -32,7 +32,7 @@ class Horde_Mime_Mdn
      *
      * @param Horde_Mime_Headers $mime_headers  A Horde_Mime_Headers object.
      */
-    function __construct($headers = null)
+    public function __construct($headers = null)
     {
         $this->_headers = $headers;
     }
index e60bd54..91462ad 100644 (file)
@@ -508,20 +508,20 @@ class Horde_Mime_Part
       * @return string  The mimetype of this part (ex.: text/plain;
       *                 charset=us-ascii) or false.
       */
-     public function getType($charset = false)
-     {
-         if (empty($this->_type) || empty($this->_subtype)) {
-             return false;
-         }
+    public function getType($charset = false)
+    {
+        if (empty($this->_type) || empty($this->_subtype)) {
+            return false;
+        }
 
-         $ptype = $this->getPrimaryType();
-         $type = $ptype . '/' . $this->getSubType();
-         if ($charset && ($ptype == 'text')) {
-             $type .= '; charset=' . $this->getCharset();
-         }
+        $ptype = $this->getPrimaryType();
+        $type = $ptype . '/' . $this->getSubType();
+        if ($charset && ($ptype == 'text')) {
+            $type .= '; charset=' . $this->getCharset();
+        }
 
-         return $type;
-     }
+        return $type;
+    }
 
     /**
      * If the subtype of a MIME part is unrecognized by an application, the
@@ -1213,7 +1213,7 @@ class Horde_Mime_Part
 
         $localeinfo = Horde_Nls::getLocaleInfo();
         return number_format($bytes / 1024, 2, $localeinfo['decimal_point'], $localeinfo['thousands_sep']);
-     }
+    }
 
     /**
      * Sets the Content-ID header for this part.
@@ -1289,7 +1289,7 @@ class Horde_Mime_Part
                 }
                 $i = 1;
                 foreach (array_keys($this->_parts) as $val) {
-                    $this->_parts[$val]->buildMimeIds($id . $i++);
+                    $this->_parts[$val]->buildMimeIds($id . ($i++));
                 }
             }
         } else {
@@ -1304,7 +1304,7 @@ class Horde_Mime_Part
             } elseif (!empty($this->_parts)) {
                 $i = 1;
                 foreach (array_keys($this->_parts) as $val) {
-                    $this->_parts[$val]->buildMimeIds($id . $i++);
+                    $this->_parts[$val]->buildMimeIds($id . ($i++));
                 }
             }
         }
index 64b7421..0a0b997 100644 (file)
@@ -12,4 +12,6 @@
  * @author  Anil Madhavapeddy <anil@recoil.org>
  * @package Horde_Mime_Viewer
  */
-class Horde_Mime_Viewer_Default extends Horde_Mime_Viewer_Driver {}
+class Horde_Mime_Viewer_Default extends Horde_Mime_Viewer_Driver
+{
+}
index 5ab5ab1..816469e 100644 (file)
@@ -50,12 +50,12 @@ class Horde_Mime_Viewer_Driver
     /**
      * Constructor.
      *
-     * @param Horde_Mime_Part &$mime_part  Reference to an object with the
-     *                                     information to be rendered.
-     * @param array $conf                  Configuration specific to the
-     *                                     driver.
+     * @param Horde_Mime_Part $mime_part  Reference to an object with the
+     *                                    information to be rendered.
+     * @param array $conf                 Configuration specific to the
+     *                                    driver.
      */
-    function __construct(&$mime_part, $conf = array())
+    public function __construct($mime_part, $conf = array())
     {
         $this->_mimepart = $mime_part;
         $this->_conf = $conf;
index 1cad8b2..1a2ddf5 100644 (file)
@@ -35,7 +35,7 @@ class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source
     {
         return array(
             $this->_mimepart->getMimeId() => array(
-                'data' => $this->_toHTML(false),
+                'data' => $this->_toHTML(),
                 'status' => array(),
                 'type' => 'text/html; charset=' . Horde_Nls::getCharset()
             )
@@ -51,7 +51,7 @@ class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source
     {
         return array(
             $this->_mimepart->getMimeId() => array(
-                'data' => $this->_toHTML(true),
+                'data' => $this->_toHTML(),
                 'status' => array(),
                 'type' => 'text/html; charset=' . Horde_Nls::getCharset()
             )
@@ -61,11 +61,9 @@ class Horde_Mime_Viewer_Enscript extends Horde_Mime_Viewer_Source
     /**
      * Converts the code to HTML.
      *
-     * @param boolean $inline  Is this an inline display?
-     *
      * @return string  The HTML-ified version of the MIME part contents.
      */
-    protected function _toHTML($inline)
+    protected function _toHTML()
     {
         /* Check to make sure the viewer program exists. */
         if (!isset($this->_conf['location']) ||
index b32ff75..00e8eda 100644 (file)
@@ -13,7 +13,7 @@
  * @author  Michael Slusarz <slusarz@horde.org>
  * @package Horde_Mime_Viewer
  */
-class Horde_Mime_Viewer_html extends Horde_Mime_Viewer_Driver
+class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver
 {
     /**
      * Can this driver render various views?
index 39d52cd..56b4f21 100644 (file)
@@ -78,7 +78,7 @@ class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_Source
      *
      * @return string  The code with line numbers added.
      */
-    protected function _lineNumber($code, $linebreak = "\n")
+    protected function _lineNumber($code)
     {
         // Clean up.
         $code = preg_replace(
index 1aef5aa..e35be9f 100644 (file)
@@ -63,7 +63,7 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Driver
             $name = _("unnamed");
         }
 
-        $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':</strong>' . "\n" .
+        $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
             '<table><tr><td align="left"><tt><span class="fixed">' .
             Horde_Text_Filter::filter(_("Archive Name") . ':  ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
             Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
@@ -99,7 +99,7 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Driver
 
         return array(
             $this->_mimepart->getMimeId() => array(
-                'data' => nl2br($text . str_repeat('-', 106) . "\n" . '</span></tt></td></tr></table>'),
+                'data' => nl2br($text . str_repeat('-', 106) . "\n</span></tt></td></tr></table>"),
                 'status' => array(),
                 'type' => 'text/html; charset=' . $charset
             )
index 5beff68..0ee5c63 100644 (file)
@@ -93,6 +93,8 @@ class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Source
      */
     protected function _typeToLang($type)
     {
+        // TODO: 'prolog', 'flex', 'changelog', 'ruby'
+
         switch ($type) {
         case 'text/x-java':
             return 'java';
@@ -115,8 +117,6 @@ class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Source
 
         case 'application/x-python':
             return 'python';
-
-        // TODO: 'prolog', 'flex', 'changelog', 'ruby'
         }
     }
 }
index e6c3512..e80035e 100644 (file)
@@ -69,7 +69,7 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Driver
             $name = _("unnamed");
         }
 
-        $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':</strong>' . "\n" .
+        $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
             '<table><tr><td align="left"><tt><span class="fixed">' .
             Horde_Text_Filter::filter(_("Archive Name") . ':  ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
             Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
@@ -98,7 +98,7 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Driver
 
         return array(
             $this->_mimepart->getMimeId() => array(
-                'data' => nl2br($text . str_repeat('-', 106) . "\n" . '</span></tt></td></tr></table>'),
+                'data' => nl2br($text . str_repeat('-', 106) . "\n</span></tt></td></tr></table>"),
                 'status' => array(),
                 'type' => 'text/html; charset=' . $charset
             )
index fad2e6f..268a10c 100644 (file)
@@ -88,12 +88,12 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver
             $name = _("unnamed");
         }
 
-        $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ':</strong>' . "\n" .
+        $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
             '<table><tr><td align="left"><tt><span class="fixed">' .
             Horde_Text_Filter::filter(
                 _("Archive Name") . ': ' . $name . "\n" .
                 _("Archive File Size") . ': ' . strlen($contents) .
-                ' bytes' . "\n" .
+                " bytes\n" .
                 sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) .
                 "\n\n" .
                 Horde_String::pad(_("File Name"), $maxlen, ' ', STR_PAD_RIGHT) .
@@ -114,7 +114,7 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver
                 : 100 * ($val['csize'] / $val['size']);
 
             $val['name']   = Horde_String::pad($val['name'], $maxlen, ' ', STR_PAD_RIGHT);
-            $val['attr']   = Horde_String::pad($val['attr'], 10,' ', STR_PAD_LEFT);
+            $val['attr']   = Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT);
             $val['size']   = Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT);
             $val['date']   = Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT);
             $val['method'] = Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT);
@@ -133,7 +133,7 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver
 
         return array(
             $this->_mimepart->getMimeId() => array(
-                'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n" . '</span></tt></td></tr></table>'),
+                'data' => nl2br($text . str_repeat('-', 69 + $maxlen) . "\n</span></tt></td></tr></table>"),
                 'status' => array(),
                 'type' => 'text/html; charset=' . Horde_Nls::getCharset()
             )
index 7d0e93b..930f697 100644 (file)
@@ -57,6 +57,16 @@ class Horde_Util
     );
 
     /**
+     * Temp directory locations.
+     *
+     * @var array
+     */
+    static public $tmpLocations = array(
+        '/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp', 'c:\windows\temp',
+        'c:\winnt\temp'
+    );
+
+    /**
      * Random number for nocacheUrl().
      *
      * @var integer.
@@ -487,17 +497,15 @@ class Horde_Util
 
         // If we still cannot determine a value, then cycle through a
         // list of preset possibilities.
-        $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp',
-                               'c:\windows\temp', 'c:\winnt\temp');
-        while (empty($tmp) && count($tmp_locations)) {
-            $tmp_check = array_shift($tmp_locations);
-            if (@is_dir($tmp_check)) {
-                $tmp = $tmp_check;
+        if (empty($tmp)) {
+            foreach (self::$tmpLocations as $tmp_check) {
+                if (@is_dir($tmp_check)) {
+                    $tmp = $tmp_check;
+                    break;
+                }
             }
         }
 
-        // If it is still empty, we have failed, so return false;
-        // otherwise return the directory determined.
         return empty($tmp) ? false : $tmp;
     }
 
@@ -791,8 +799,9 @@ class Horde_Util
      */
     static public function closeWindowJS($code = '')
     {
-        echo '<script type="text/javascript">//<![CDATA[' . "\n"
-            . $code . 'window.close();' . "\n//]]></script>\n";
+        echo "<script type=\"text/javascript\">//<![CDATA[\n" .
+            $code .
+            "window.close();\n//]]></script>\n";
     }
 
     /**
@@ -899,9 +908,10 @@ class Horde_Util
      */
     static public function date2strftime($format)
     {
+        $f_len = strlen($format);
         $result = '';
 
-        for ($pos = 0; $pos < strlen($format);) {
+        for ($pos = 0; $pos < $f_len;) {
             for ($symbol = 0, $symcount = count(self::$dateSymbols); $symbol < $symcount; ++$symbol) {
                 if (strpos($format, self::$dateSymbols[$symbol], $pos) === $pos) {
                     $result .= self::$strftimeSymbols[$symbol];
index 12d3dd0..ab22d82 100644 (file)
@@ -123,8 +123,9 @@ class Horde_Variables
         } else {
             array_unshift($keys, $base);
             $place = &$this->_vars;
+            $i = count($keys);
 
-            while (count($keys)) {
+            while ($i--) {
                 $key = array_shift($keys);
                 if (!isset($place[$key])) {
                     $place[$key] = array();
@@ -238,7 +239,9 @@ class Horde_Variables
                     : false;
             } else {
                 $searchspace = &$array[$base];
-                while (count($keys)) {
+                $i = count($keys);
+
+                while ($i--) {
                     $key = array_shift($keys);
                     if (!isset($searchspace[$key])) {
                         $value = null;