Changeset 1766

Show
Ignore:
Timestamp:
01/21/2008 06:56:39 AM (9 months ago)
Author:
Geert
Message:

Cleaning up tons of whitespace:

  • Use tabs for indenting
  • Use spaces for aligning
  • Avoid whitespace at the end of a line
Location:
trunk
Files:
45 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/examples.php

    r1733 r1766  
    288288                $credit_card = new Payment('Paypal'); 
    289289                $credit_card = new Payment('Authorize'); 
    290                  
     290 
    291291                // You can specify one parameter at a time: 
    292292                $credit_card->login = 'this'; 
     
    299299                // Or you can also set fields with an array and the <Payment.set_fields> method: 
    300300                $credit_card->set_fields(array('login' => 'test', 
    301                                        'first_name' => 'Jeremy', 
    302                                        'last_name' => 'Bush', 
    303                                        'card_num' => '1234567890', 
    304                                        'exp_date' => '0910', 
    305                                        'amount' => '487.41')); 
     301                                               'first_name' => 'Jeremy', 
     302                                               'last_name' => 'Bush', 
     303                                               'card_num' => '1234567890', 
     304                                               'exp_date' => '0910', 
     305                                               'amount' => '487.41')); 
    306306 
    307307                echo '<pre>'.print_r($credit_card, true).'</pre>'; 
  • trunk/modules/auth/models/user.php

    r1707 r1766  
    6060                if (is_object($role)) 
    6161                        return parent::has_role($role); 
    62          
     62 
    6363                // Make sure the role name is a string 
    6464                $role = (string) $role; 
    65          
     65 
    6666                if (ctype_digit($role)) 
    6767                { 
  • trunk/modules/media/controllers/media.php

    r1765 r1766  
    2121        protected $use_cache = FALSE; 
    2222        protected $cache_lifetime; 
    23          
     23 
    2424        protected $pack_css = FALSE; 
    2525        protected $pack_js = FALSE; 
    26          
     26 
    2727        public function __construct() 
    2828        { 
    2929                parent::__construct(); 
    30                  
     30 
    3131                $cache = Config::item('media.cache'); 
    3232                $this->use_cache = ($cache > 0); 
    33                  
     33 
    3434                if (is_int($cache)) 
    3535                { 
     
    4040                        $this->cache_lifetime = config::item('cache.lifetime') OR $this->cache_lifetime = 1800; 
    4141                } 
    42                  
     42 
    4343                if ($this->use_cache AND ! isset($this->cache))  
    4444                { 
    4545                        $this->load->library('cache'); 
    4646                } 
    47                  
     47 
    4848                $this->pack_css = (bool) Config::item('media.pack_css'); 
    4949                $this->pack_js = Config::item('media.pack_js'); 
    50                  
     50 
    5151                if ($this->pack_js === TRUE) 
    5252                { 
     
    5454                } 
    5555        } 
    56          
     56 
    5757        public function css() 
    5858        { 
     
    6262                        $filename = substr($filename, 0, -4); 
    6363                } 
    64                  
     64 
    6565                $mimetype = config::item('mimes.css'); 
    6666                $mimetype = (isset($mimetype[0])) ? $mimetype[0] : 'text/stylesheet'; 
    67                  
     67 
    6868                $this->use_cache AND $data = $this->cache->get('media.css.'.$filename); 
    69                  
     69 
    7070                if ( ! isset($data) OR empty($data)) 
    7171                { 
     
    8787                                } 
    8888                        } 
    89                          
     89 
    9090                        if (isset($view)) 
    9191                        { 
    9292                                $data = $view->render(); 
    93                                  
     93 
    9494                                if ($this->pack_css)  
    9595                                { 
    9696                                        $data = $this->_css_compress($data); 
    9797                                } 
    98                                  
     98 
    9999                                if ($this->use_cache)  
    100100                                { 
     
    107107                        } 
    108108                } 
    109                  
     109 
    110110                $mimetype AND header('Content-type: '.$mimetype); 
    111111                echo $data; 
     
    119119                        $filename = substr($filename, 0, -3); 
    120120                } 
    121                  
     121 
    122122                $mimetype = Config::item('mimes.js'); 
    123123                $mimetype = (isset($mimetype[0])) ? $mimetype[0] : 'text/javascript'; 
    124124 
    125                  
     125 
    126126                $this->use_cache AND $data = $this->cache->get('media.js.'.$filename); 
    127                  
     127 
    128128                if ( ! isset($data) OR empty($data))  
    129129                { 
     
    145145                                } 
    146146                        } 
    147                          
     147 
    148148                        if (isset($view))  
    149149                        { 
    150150                                $data = $view->render(); 
    151                                  
     151 
    152152                                if ($this->pack_js)  
    153153                                { 
     
    155155                                        $data = $packer->pack(); 
    156156                                } 
    157                                  
     157 
    158158                                if ($this->use_cache)  
    159159                                { 
     
    166166                        } 
    167167                } 
    168                  
     168 
    169169                $mimetype AND header('Content-type: '.$mimetype); 
    170170                echo $data; 
     
    184184                // Remove comments 
    185185                $data = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $data); 
    186                  
     186 
    187187                // Remove tabs, spaces, newlines, etc. 
    188188                $data = preg_replace('/\s+/s', ' ', $data); 
  • trunk/modules/media/libraries/JavaScriptPacker.php

    r1641 r1766  
    7373        private $_fastDecode = true; 
    7474        private $_specialChars = false; 
    75          
     75 
    7676        private $LITERAL_ENCODING = array( 
    7777                'None' => 0, 
     
    8080                'High ASCII' => 95 
    8181        ); 
    82          
     82 
    8383        public function __construct($_script, $_encoding = 62, $_fastDecode = true, $_specialChars = false) 
    8484        { 
     
    9090                $this->_specialChars = $_specialChars; 
    9191        } 
    92          
     92 
    9393        public function pack() { 
    9494                $this->_addParser('_basicCompression'); 
     
    9797                if ($this->_encoding) 
    9898                        $this->_addParser('_encodeKeywords'); 
    99                  
     99 
    100100                // go! 
    101101                return $this->_pack($this->_script); 
    102102        } 
    103          
     103 
    104104        // apply all parsing routines 
    105105        private function _pack($script) { 
     
    109109                return $script; 
    110110        } 
    111          
     111 
    112112        // keep a list of parsing functions, they'll be executed all at once 
    113113        private $_parsers = array(); 
     
    115115                $this->_parsers[] = $parser; 
    116116        } 
    117          
     117 
    118118        // zero encoding - just removal of white space and comments 
    119119        private function _basicCompression($script) { 
     
    145145                return $parser->exec($script); 
    146146        } 
    147          
     147 
    148148        private function _encodeSpecialChars($script) { 
    149149                $parser = new ParseMaster(); 
     
    158158                // quick ref 
    159159                $encoded = $keywords['encoded']; 
    160                  
     160 
    161161                $parser->add($regexp, 
    162162                        array( 
     
    167167                return $parser->exec($script); 
    168168        } 
    169          
     169 
    170170        private function _encodeKeywords($script) { 
    171171                // escape high-ascii values already in the script (i.e. in strings) 
     
    180180                $keywords = $this->_analyze($script, $regexp, $encode); 
    181181                $encoded = $keywords['encoded']; 
    182                  
     182 
    183183                // encode 
    184184                $parser->add($regexp, 
     
    196196                } 
    197197        } 
    198          
     198 
    199199        private function _analyze($script, $regexp, $encode) { 
    200200                // analyse 
     
    243243                                } 
    244244                        } while ($i); 
    245                          
     245 
    246246                        // sort the words by frequency 
    247247                        // Note: the javascript and php version of sort can be different : 
     
    269269                        'protected' => $_protected); 
    270270        } 
    271          
     271 
    272272        private $_count = array(); 
    273273        private function _sortWords($match1, $match2) { 
    274274                return $this->_count[$match2] - $this->_count[$match1]; 
    275275        } 
    276          
     276 
    277277        // build the boot function used for loading and decoding 
    278278        private function _bootStrap($packed, $keywords) { 
     
    341341                $unpackPacker = new JavaScriptPacker($unpack, 0, false, true); 
    342342                $unpack = $unpackPacker->pack(); 
    343                  
     343 
    344344                // arguments 
    345345                $params = array($packed, $ascii, $count, $keywords); 
     
    349349                } 
    350350                $params = implode(',', $params); 
    351                  
     351 
    352352                // the whole thing 
    353353                return 'eval(' . $unpack . '(' . $params . "))\n"; 
    354354        } 
    355          
     355 
    356356        private $buffer; 
    357357        private function _insertFastDecode($match) { 
     
    361361                return '{$encode=' . $this->buffer . ';'; 
    362362        } 
    363          
     363 
    364364        // mmm.. ..which one do i need ?? 
    365365        private function _getEncoder($ascii) { 
     
    367367                       '_encode95' : '_encode62' : '_encode36' : '_encode10'; 
    368368        } 
    369          
     369 
    370370        // zero encoding 
    371371        // characters: 0123456789 
     
    373373                return $charCode; 
    374374        } 
    375          
     375 
    376376        // inherent base36 support 
    377377        // characters: 0123456789abcdefghijklmnopqrstuvwxyz 
     
    379379                return base_convert($charCode, 10, 36); 
    380380        } 
    381          
     381 
    382382        // hitch a ride on base36 and add the upper case alpha characters 
    383383        // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 
     
    388388                } 
    389389                $charCode = $charCode % $this->_encoding; 
    390                  
     390 
    391391                if ($charCode > 35) 
    392392                        return $res . chr($charCode + 29); 
     
    394394                        return $res . base_convert($charCode, 10, 36); 
    395395        } 
    396          
     396 
    397397        // use high-ascii values 
    398398        // characters: ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ 
     
    401401                if ($charCode >= $this->_encoding) 
    402402                        $res = $this->_encode95($charCode / $this->_encoding); 
    403                  
     403 
    404404                return $res . chr(($charCode % $this->_encoding) + 161); 
    405405        } 
    406          
     406 
    407407        private function _safeRegExp($string) { 
    408408                return '/'.preg_replace('/\$/', '\\\$', $string).'/'; 
    409409        } 
    410          
     410 
    411411        private function _encodePrivate($charCode) { 
    412412                return "_" . $charCode; 
    413413        } 
    414          
     414 
    415415        // protect characters used by the parser 
    416416        private function _escape($script) { 
    417417                return preg_replace('/([\\\\\'])/', '\\\$1', $script); 
    418418        } 
    419          
     419 
    420420        // protect high-ascii characters already in the script 
    421421        private function _escape95($script) { 
     
    429429                return '\x'.((string)dechex(ord($match))); 
    430430        } 
    431          
    432          
     431 
     432 
    433433        private function _getJSFunction($aName) { 
    434434                if (defined('self::JSFUNCTION'.$aName)) 
     
    437437                        return ''; 
    438438        } 
    439          
     439 
    440440        // JavaScript Functions used. 
    441441        // Note : In Dean's version, these functions are converted 
     
    445445        // 'while (aBool) { anAction(); }'. 
    446446        // The JavaScript functions below are corrected. 
    447          
     447 
    448448        // unpacking function - this is the boot strap function 
    449449        //  data extracted from this packing routine is passed to 
     
    468468}'; 
    469469*/ 
    470          
     470 
    471471        // code-snippet inserted into the unpacker to speed up decoding 
    472472        const JSFUNCTION_decodeBody = 
     
    501501    }'; 
    502502*/ 
    503          
     503 
    504504         // zero encoding 
    505505         // characters: 0123456789 
     
    508508    return $charCode; 
    509509}';//;'; 
    510          
     510 
    511511         // inherent base36 support 
    512512         // characters: 0123456789abcdefghijklmnopqrstuvwxyz 
     
    515515    return $charCode.toString(36); 
    516516}';//;'; 
    517          
     517 
    518518        // hitch a ride on base36 and add the upper case alpha characters 
    519519        // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 
     
    523523    (($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36)); 
    524524}'; 
    525          
     525 
    526526        // use high-ascii values 
    527527        // characters: ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ 
     
    531531        String.fromCharCode($charCode % _encoding + 161); 
    532532}';  
    533          
     533 
    534534} 
    535535 
     
    538538        public $ignoreCase = false; 
    539539        public $escapeChar = ''; 
    540          
     540 
    541541        // constants 
    542542        const EXPRESSION = 0; 
    543543        const REPLACEMENT = 1; 
    544544        const LENGTH = 2; 
    545          
     545 
    546546        // used to determine nesting levels 
    547547        private $GROUPS = '/\\(/';//g 
     
    552552        private $QUOTE = '/\'/'; 
    553553        private $DELETED = '/\\x01[^\\x01]*\\x01/';//g 
    554          
     554 
    555555        public function add($expression, $replacement = '') { 
    556556                // count the number of sub-expressions 
    557557                //  - add one because each pattern is itself a sub-expression 
    558558                $length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string)$expression), $out); 
    559                  
     559 
    560560                // treat only strings $replacement 
    561561                if (is_string($replacement)) { 
     
    585585                else $this->_add('/^$/', $replacement, $length); 
    586586        } 
    587          
     587 
    588588        public function exec($string) { 
    589589                // execute the global replacement 
    590590                $this->_escaped = array(); 
    591                  
     591 
    592592                // simulate the _patterns.toSTring of Dean 
    593593                $regexp = '/';