Changeset 90 in ExiteCMS8


Ignore:
Timestamp:
09/07/11 22:02:10 (9 months ago)
Author:
WanWizard
Message:

updated to the latest Fuel 1.1/develop branch

Location:
trunk/fuel/core
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/fuel/core/classes/form.php

    r82 r90  
    591591        $fields = $this->field(); 
    592592        $fields_output = ''; 
     593 
    593594        foreach ($fields as $f) 
    594595        { 
     
    597598        $close = static::close(); 
    598599 
    599         $template =  $this->get_config('form_template', "\t\t{form_open}\n{fields}\n\t\t{form_close}\n"); 
     600        $template =  $this->get_config('form_template', "\n\t\t{form_open}\n\t\t<table>\n{fields}\n\t\t</table>\n\t\t{form_close}\n"); 
    600601        $template = str_replace(array('{form_open}', '{fields}', '{form_close}'), 
    601602            array($open, $fields_output, $close), 
     
    607608     * Build & template individual field 
    608609     * 
    609      * @param   string|Fieldset_Field  field instance or name of a field in this form's fieldset 
     610     * @param   string|Fieldset_Field   field       instance or name of a field in this form's fieldset 
    610611     * @return  string 
    611612     */ 
     
    716717        $required_mark = $required ? $this->get_config('required_mark', null) : null; 
    717718        $label = $field->label ? static::label($field->label, $field->get_attribute('id', null)) : ''; 
     719        $error_template = $this->get_config('error_template', ""); 
     720        $error_msg = ($this->get_config('inline_errors') && $field->error()) ? str_replace('{error_msg}', $field->error(), $error_template) : ''; 
     721        $error_class = $field->error() ? $this->get_config('error_class') : ''; 
    718722 
    719723        if (is_array($build_field)) 
    720724        { 
    721725            $label = $field->label ? static::label($field->label) : ''; 
    722             $template = $field->template ?: $this->get_config('multi_field_template', '\t\t\t{group_label}\n {fields}\t\t\t{label} {field}{fields}'); 
     726            $template = $field->template ?: $this->get_config('multi_field_template', '\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{group_label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{fields}\n\t\t\t\t{field} {label}<br />\n{fields}\t\t\t{error_msg}\n\t\t\t</td>\n\t\t</tr>\n'); 
    723727            if ($template && preg_match('#\{fields\}(.*)\{fields\}#Dus', $template, $match) > 0) 
    724728            { 
     
    733737 
    734738                $template = str_replace($match[0], '{fields}', $template); 
    735                 $template = str_replace(array('{group_label}', '{required}', '{fields}'), array($label, $required_mark, $build_fields), $template); 
     739                $template = str_replace(array('{group_label}', '{required}', '{fields}', '{error_msg}', '{error_class}'), array($label, $required_mark, $build_fields, $error_msg, $error_class), $template); 
    736740 
    737741                return $template; 
     
    742746        } 
    743747 
    744         $template = $field->template ?: $this->get_config('field_template', '\t\t\t{label} {field}\n'); 
    745         $template = str_replace(array('{label}', '{required}', '{field}'), 
    746             array($label, $required_mark, $build_field), 
     748        $template = $field->template ?: $this->get_config('field_template', '\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{field} {error_msg}</td>\n\t\t</tr>\n'); 
     749        $template = str_replace(array('{label}', '{required}', '{field}', '{error_msg}', '{error_class}'), 
     750            array($label, $required_mark, $build_field, $error_msg, $error_class), 
    747751            $template); 
    748752        return $template; 
  • trunk/fuel/core/classes/lang.php

    r87 r90  
    110110     * @param   string  value for the key 
    111111     * @param   string  group 
    112      * @return  bool    success 
     112     * @return  void 
    113113     */ 
    114114    public static function set($line, $value, $group = null) 
  • trunk/fuel/core/classes/num.php

    r78 r90  
    159159        if ($num >= 1000 && $num < 1000000) 
    160160        { 
    161             return sprintf('%01.'.$decimals.'f', (sprintf('%01.0.f', $num) / 1000)).'K'; 
     161            return sprintf('%01.'.$decimals.'f', (sprintf('%01.0f', $num) / 1000)).'K'; 
    162162        } 
    163163        elseif ($num >= 1000000 && $num < 1000000000) 
    164164        { 
    165             return sprintf('%01.'.$decimals.'f', (sprintf('%01.0.f', $num) / 1000000)).'M'; 
     165            return sprintf('%01.'.$decimals.'f', (sprintf('%01.0f', $num) / 1000000)).'M'; 
    166166        } 
    167167        elseif ($num >= 1000000000) 
    168168        { 
    169             return sprintf('%01.'.$decimals.'f', (sprintf('%01.0.f', $num) / 1000000000)).'B'; 
     169            return sprintf('%01.'.$decimals.'f', (sprintf('%01.0f', $num) / 1000000000)).'B'; 
    170170        } 
    171171 
  • trunk/fuel/core/classes/upload.php

    r87 r90  
    241241                foreach ($keys as $key) 
    242242                { 
    243                     // skip this entry if no file was uploaded 
    244                     if ($value['error'][$key] == static::UPLOAD_ERR_NO_FILE) 
    245                     { 
    246                         continue; 
    247                     } 
    248243                    // store the file data 
    249244                    $file = array('field' => $name, 'key' => $key); 
     
    258253            else 
    259254            { 
    260                 // skip this entry if no file was uploaded 
    261                 if ($value['error'] == static::UPLOAD_ERR_NO_FILE) 
    262                 { 
    263                     continue; 
    264                 } 
    265255                // store the file data 
    266256                $file = array('field' => $name, 'key' => false, 'file' => $value['tmp_name']); 
     
    311301            if ($files[$key]['error'] == UPLOAD_ERR_OK) 
    312302            { 
    313                 if (in_array($files[$key]['extension'], (array) static::$config['ext_blacklist'])) 
     303                if (in_array(strtolower($files[$key]['extension']), (array) static::$config['ext_blacklist'])) 
    314304                { 
    315305                    $files[$key]['error'] = static::UPLOAD_ERR_EXT_BLACKLISTED; 
    316306                } 
    317                 elseif ( ! empty(static::$config['ext_whitelist']) and ! in_array($files[$key]['extension'], (array) static::$config['ext_whitelist'])) 
     307                elseif ( ! empty(static::$config['ext_whitelist']) and ! in_array(strtolower($files[$key]['extension']), (array) static::$config['ext_whitelist'])) 
    318308                { 
    319309                    $files[$key]['error'] = static::UPLOAD_ERR_EXT_NOT_WHITELISTED; 
     
    447437            throw new \Fuel_Exception('No uploaded files are selected.'); 
    448438        } 
    449          
     439 
    450440        // supplied new name and not auto renaming? 
    451441        if (array_key_exists('new_name', static::$config) and ! static::$config['auto_rename'] and count($files) > 1) 
     
    462452            umask($oldumask); 
    463453        } 
    464          
     454 
    465455        if ( ! is_dir($path)) 
    466456        { 
     
    493483                } 
    494484            } 
    495              
     485 
    496486            array_key_exists('new_name', static::$config) and $filename = (string) static::$config['new_name']; 
    497487 
  • trunk/fuel/core/classes/uri.php

    r78 r90  
    106106        $url .= ltrim($uri, '/'); 
    107107 
    108         substr($url, -1) != '/' and strrchr($url, '.') !== \Config::get('url_suffix') and $url .= \Config::get('url_suffix'); 
     108        // Add a url_suffix if defined and the url doesn't already have one 
     109        if (substr($url, -1) != '/' and (($suffix = strrchr($url, '.')) === false or strlen($suffix) > 5)) 
     110        { 
     111            \Config::get('url_suffix') and $url .= \Config::get('url_suffix'); 
     112        } 
    109113 
    110114        if ( ! empty($get_variables)) 
    111115        { 
    112116            $char = strpos($url, '?') === false ? '?' : '&'; 
    113             $url .= $char.http_build_query($get_variables); 
     117            $url .= $char.str_replace('%3A', ':', http_build_query($get_variables)); 
    114118        } 
    115119 
  • trunk/fuel/core/config/form.php

    r64 r90  
    2222 
    2323return array( 
    24     'prep_value'            => true, 
    25     'auto_id'               => true, 
    26     'auto_id_prefix'        => 'form_', 
    27     'form_method'           => 'post', 
    28     'form_template'         => "\t\t{form_open}\n{fields}\n\t\t{form_close}\n", 
    29     'field_template'        => "\t\t\t{label} {field}\n", 
    30     'multi_field_template'  => "\t\t\t{group_label}{required}\n {fields}\t\t\t{label} {field}{fields}", 
    31     'required_mark'         => '*', 
     24    'prep_value'            => true, 
     25    'auto_id'               => true, 
     26    'auto_id_prefix'        => 'form_', 
     27    'form_method'           => 'post', 
     28    'form_template'         => "\n\t\t{form_open}\n\t\t<table>\n{fields}\n\t\t</table>\n\t\t{form_close}\n", 
     29    'field_template'        => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{field} {error_msg}</td>\n\t\t</tr>\n", 
     30    'multi_field_template'  => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{group_label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{fields}\n\t\t\t\t{field} {label}<br />\n{fields}\t\t\t{error_msg}\n\t\t\t</td>\n\t\t</tr>\n", 
     31    'error_template'        => '<span>{error_msg}</span>', 
     32    'required_mark'         => '*', 
     33    'inline_errors'         => false, 
     34    'error_class'           => 'validation_error', 
    3235); 
    3336 
  • trunk/fuel/core/phpunit.xml

    r53 r90  
    44    <php> 
    55        <server name="doc_root" value="../../"/> 
    6         <server name="app_path" value="fuel/app"/> 
     6        <server name="app_path" value="exitecms"/> 
    77        <server name="core_path" value="fuel/core"/> 
    88        <server name="package_path" value="fuel/packages"/> 
  • trunk/fuel/core/tests/html.php

    r64 r90  
    1515/** 
    1616 * Html class tests 
    17  *  
     17 * 
    1818 * @group Core 
    1919 * @group Html 
     
    2222 
    2323    /** 
    24      * Tests Html::h() 
    25      *  
    26      * @test 
    27      */ 
    28     public function test_h() 
    29     { 
    30         $output = Html::h('Example'); 
    31         $expected = "<h1>Example</h1>"; 
    32         $this->assertEquals($expected, $output); 
    33  
    34         $output = Html::h('Some other example', '2', array('id' => 'h2', 'class' => 'sample', 'style' => 'color:red;')); 
    35         $expected = '<h2 id="h2" class="sample" style="color:red;">Some other example</h2>'; 
    36         $this->assertEquals($expected, $output); 
    37  
    38         $attributes = array('id' => 'sample', 'class' => 'sample', 'style' => 'color:blue;'); 
    39         $output = Html::h('Variable!', '3', $attributes); 
    40         $expected = '<h3 id="sample" class="sample" style="color:blue;">Variable!</h3>'; 
    41         $this->assertEquals($expected, $output); 
    42     } 
    43  
    44     /** 
    45      * Tests Html::br() 
    46      *  
    47      * @test 
    48      */ 
    49     public function test_br() 
    50     { 
    51         $output = Html::br(); 
    52         $expected = "<br />"; 
    53         $this->assertEquals($expected, $output); 
    54  
    55         $output = Html::br('2', array('id' => 'example', 'class' => 'sample', 'style' => 'color:red;')); 
    56         $expected = '<br id="example" class="sample" style="color:red;" /><br id="example" class="sample" style="color:red;" />'; 
    57         $this->assertEquals($expected, $output); 
    58     } 
    59  
    60     /** 
    61      * Tests Html::hr() 
    62      *  
    63      * @test 
    64      */ 
    65     public function test_hr() 
    66     { 
    67         $output = Html::hr(); 
    68         $expected = "<hr />"; 
    69         $this->assertEquals($expected, $output); 
    70  
    71         $output = Html::hr(array('id' => 'example', 'class' => 'sample', 'style' => 'color:red;')); 
    72         $expected = '<hr id="example" class="sample" style="color:red;" />'; 
    73         $this->assertEquals($expected, $output); 
    74     } 
    75  
    76     /** 
    77      * Tests Html::title() 
    78      *  
    79      * @test 
    80      */ 
    81     public function test_title() 
    82     { 
    83         $output = Html::title(); 
    84         $expected = "<title></title>"; 
    85         $this->assertEquals($expected, $output); 
    86  
    87         $output = Html::title('Some Title!'); 
    88         $expected = "<title>Some Title!</title>"; 
    89         $this->assertEquals($expected, $output); 
    90     } 
    91  
    92     /** 
    93      * Tests Html::nbs() 
    94      *  
    95      * @test 
    96      */ 
    97     public function test_nbs() 
    98     { 
    99         $output = Html::nbs(); 
    100         $expected = "&nbsp;"; 
    101         $this->assertEquals($expected, $output); 
    102  
    103         $output = Html::nbs(2); 
    104         $expected = "&nbsp;&nbsp;"; 
    105         $this->assertEquals($expected, $output); 
    106     } 
    107  
    108     /** 
    10924     * Tests Html::meta() 
    110      *  
     25     * 
    11126     * @test 
    11227     */ 
     
    13752    /** 
    13853     * Tests Html::anchor() 
    139      *  
     54     * 
    14055     * @test 
    14156     */ 
    14257    public function test_anchor() 
    14358    { 
    144         $index_url = Uri::create(''); 
    145          
    14659        // External uri 
    14760        $output = Html::anchor('http://google.com', 'Go to Google'); 
    14861        $expected = '<a href="http://google.com">Go to Google</a>'; 
    14962        $this->assertEquals($expected, $output); 
    150          
     63 
    15164        $output = Html::anchor('javascript:do();', 'Do()'); 
    15265        $expected = '<a href="javascript:do();">Do()</a>'; 
    15366        $this->assertEquals($expected, $output); 
    154          
     67 
    15568        $output = Html::anchor('http://google.com', 'Go to Google', array('rel' => 'example', 'class' => 'sample', 'style' => 'color:red;')); 
    15669        $expected = '<a rel="example" class="sample" style="color:red;" href="http://google.com">Go to Google</a>'; 
    15770        $this->assertEquals($expected, $output); 
    158          
     71 
    15972        // Internal uri 
    16073        $output = Html::anchor('controller/method', 'Method'); 
    161         $expected = '<a href="' . $index_url . 'controller/method">Method</a>'; 
     74        $expected = '<a href="' . Uri::create('controller/method') . '">Method</a>'; 
    16275        $this->assertEquals($expected, $output); 
    16376    } 
    164      
     77 
    16578    /** 
    16679     * Tests Html::img() 
    167      *  
     80     * 
    16881     * This test does not account for the image file existing in 
    16982     * the filesystem. There are no images bundled with the framework 
    17083     * by default, so no reliable test can be run on an actual image. 
    171      *  
     84     * 
    17285     * @test 
    17386     */ 
    17487    public function test_img() 
    17588    { 
    176         $index_url = Uri::create(''); 
    177          
     89        $index_url = Uri::create('image.png'); 
     90 
    17891        // Internal uri 
    17992        $output = Html::img('image.png'); 
    180         $expected = '<img src="'. $index_url . 'image.png" alt="image" />'; 
     93        $expected = '<img src="'. $index_url . '" alt="image" />'; 
    18194        $this->assertEquals($expected, $output); 
    182          
     95 
    18396        $output = Html::img('image.png', array('alt' => 'Image')); 
    184         $expected = '<img alt="Image" src="'. $index_url . 'image.png" />'; 
     97        $expected = '<img alt="Image" src="'. $index_url . '" />'; 
    18598        $this->assertEquals($expected, $output); 
    186          
     99 
    187100        // External uri 
    188101        $output = Html::img('http://google.com/image.png'); 
    189102        $expected = '<img src="http://google.com/image.png" />'; 
    190103    } 
    191      
     104 
    192105    /** 
    193106     * Tests Html::prep_url() 
    194      *  
     107     * 
    195108     * @test 
    196109     */ 
     
    200113        $expected = 'http://google.com'; 
    201114        $this->assertEquals($expected, $output); 
    202          
     115 
    203116        $output = Html::prep_url('google.com', 'https'); 
    204117        $expected = 'https://google.com'; 
    205118        $this->assertEquals($expected, $output); 
    206119    } 
    207      
     120 
    208121    /** 
    209122     * Tests Html::mail_to() 
    210      *  
     123     * 
    211124     * @test 
    212125     */ 
     
    216129        $expected = '<a href="mailto:test@test.com">test@test.com</a>'; 
    217130        $this->assertEquals($expected, $output); 
    218          
     131 
    219132        $output = Html::mail_to('test@test.com', 'Email'); 
    220133        $expected = '<a href="mailto:test@test.com">Email</a>'; 
    221134        $this->assertEquals($expected, $output); 
    222          
     135 
    223136        $output = Html::mail_to('test@test.com', NULL, 'Test'); 
    224137        $expected = '<a href="mailto:test@test.com?subject=Test">test@test.com</a>'; 
    225138        $this->assertEquals($expected, $output); 
    226          
     139 
    227140        $output = Html::mail_to('test@test.com', 'Test', 'Test'); 
    228141        $expected = '<a href="mailto:test@test.com?subject=Test">Test</a>'; 
    229142        $this->assertEquals($expected, $output); 
    230143    } 
    231      
     144 
    232145    /** 
    233146     * Tests Html::doctype() 
    234      *  
     147     * 
    235148     * @test 
    236149     */ 
     
    240153        $expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; 
    241154        $this->assertEquals($expected, $output); 
    242          
     155 
    243156        $output = Html::doctype('html5'); 
    244157        $expected = '<!DOCTYPE html>'; 
    245158        $this->assertEquals($expected, $output); 
    246          
     159 
    247160        // Ensure static::$html5 is set 
    248161        $doctype = Html::doctype('html5'); 
    249162        $this->assertTrue(Html::$html5); 
    250          
     163 
    251164        // Ensure === false if doctype is invalid 
    252165        $this->assertFalse(Html::doctype('shouldfail')); 
    253166    } 
    254      
    255     /** 
    256      * Tests Html::header() 
    257      *  
    258      * @test 
    259      */ 
    260     public function test_header() 
    261     { 
    262         // Doctype != html5 
    263         Html::$html5 = FALSE; 
    264          
    265         $output = Html::header(); 
    266         $expected = '<div id="header"></div>'; 
    267         $this->assertEquals($expected, $output); 
    268          
    269         $output = Html::header('Content'); 
    270         $expected = '<div id="header">Content</div>'; 
    271         $this->assertEquals($expected, $output); 
    272          
    273         // Doctype = html5 
    274         Html::$html5 = TRUE; 
    275         $output = Html::header(); 
    276         $expected = '<header></header>'; 
    277         $this->assertEquals($expected, $output); 
    278          
    279         $output = Html::header('Content'); 
    280         $expected = '<header>Content</header>'; 
    281         $this->assertEquals($expected, $output); 
    282     } 
    283      
     167 
    284168    /** 
    285169     * Tests Html::ul() & Html::ol() 
    286      *  
     170     * 
    287171     * @test 
    288172     */ 
     
    290174    { 
    291175        $list = array('one', 'two'); 
    292          
     176 
    293177        $output = Html::ul($list); 
    294178        $expected = '<ul> 
     
    298182'; 
    299183        $this->assertEquals($expected, $output); 
    300          
     184 
    301185        $output = Html::ol($list); 
    302186        $expected = '<ol> 
  • trunk/fuel/core/tests/lang.php

    r53 r90  
    1515/** 
    1616 * Lang class tests 
    17  *  
     17 * 
    1818 * @group Core 
    1919 * @group Lang 
    2020 */ 
    2121class Test_Lang extends TestCase { 
    22   
     22 
    2323    /** 
    2424     * Test for Lang::line() 
    25      *  
     25     * 
    2626     * @test 
    27      */  
     27     */ 
    2828    public function test_line() 
    2929    { 
    3030        Lang::load('test'); 
    31         $output = Lang::line('hello', array('name' => 'Bob')); 
     31        $output = Lang::get('hello', array('name' => 'Bob')); 
    3232        $expected = 'Hello there Bob!'; 
    3333        $this->assertEquals($expected, $output); 
     
    3636    /** 
    3737     * Test for Lang::line() 
    38      *  
     38     * 
    3939     * @test 
    40      */  
     40     */ 
    4141    public function test_line_invalid() 
    4242    { 
    4343        Lang::load('test'); 
    44         $output = Lang::line('non_existant_hello', array('name' => 'Bob')); 
    45         $expected = 'non_existant_hello'; 
     44        $output = Lang::get('non_existant_hello', array('name' => 'Bob')); 
     45        $expected = false; 
    4646        $this->assertEquals($expected, $output); 
    4747    } 
     
    4949    /** 
    5050     * Test for Lang::set() 
    51      *  
     51     * 
    5252     * @test 
    53      */  
     53     */ 
    5454    public function test_set_return_true() 
    5555    { 
    5656        $output = Lang::set('testing_set_valid', 'Ahoy :name!'); 
    57         $this->assertTrue($output); 
     57        $this->assertNull($output); 
    5858    } 
    59      
     59 
    6060    /** 
    6161     * Test for Lang::set() 
    62      *  
     62     * 
    6363     * @test 
    6464     */ 
     
    6666    { 
    6767        Lang::set('testing_set_valid', 'Ahoy :name!'); 
    68         $output = Lang::line('testing_set_valid', array('name' => 'Bob')); 
     68        $output = Lang::get('testing_set_valid', array('name' => 'Bob')); 
    6969        $expected = 'Ahoy Bob!'; 
    7070        $this->assertEquals($expected, $output); 
  • trunk/fuel/core/tests/num.php

    r77 r90  
    5353        $output = Num::quantity('7500'); 
    5454        $expected = '8K'; 
     55 
     56        $this->assertEquals($expected, $output); 
     57 
     58        $output = Num::quantity('7500', 1); 
     59        $expected = '7.5K'; 
    5560 
    5661        $this->assertEquals($expected, $output); 
     
    111116        $this->assertEquals($expected, $output); 
    112117    } 
    113      
     118 
    114119    /** 
    115120     * @see     Num::mask_credit_card 
  • trunk/fuel/core/tests/uri.php

    r64 r90  
    2828    public function test_create() 
    2929    { 
     30        Config::set('url_suffix', ''); 
     31 
    3032        $prefix = Uri::create(''); 
    3133 
     
    4749        $expected = $prefix."controller/thing.html?what=more"; 
    4850        $this->assertEquals($expected, $output); 
    49          
     51 
    5052        $output = Uri::create('http://example.com/controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and')); 
    5153        $expected = "http://example.com/controller/thing.html?what=more"; 
Note: See TracChangeset for help on using the changeset viewer.