Changeset 59 in ExiteCMS8


Ignore:
Timestamp:
07/11/11 14:22:53 (11 months ago)
Author:
WanWizard
Message:

updated the Fuel core packages to the latest develop branch

Location:
trunk/fuel
Files:
32 edited

Legend:

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

    r53 r59  
    2323 
    2424    /** 
     25     * Converts a multi-dimensional associative array into an array of key => values with the provided field names 
     26     * 
     27     * @param   array   the array to convert 
     28     * @param   string  the field name of the key field 
     29     * @param   string  the field name of the value field 
     30     * @return  array 
     31     */ 
     32    public static function assoc_to_keyval($assoc = null, $key_field = null, $val_field = null) 
     33    { 
     34        if(empty($assoc) OR empty($key_field) OR empty($val_field)) 
     35        { 
     36            return null; 
     37        } 
     38         
     39        $output = array(); 
     40        foreach($assoc as $row) 
     41        { 
     42            if(isset($row[$key_field]) AND isset($row[$val_field])) 
     43            { 
     44                $output[$row[$key_field]] = $row[$val_field]; 
     45            } 
     46        } 
     47         
     48        return $output; 
     49    } 
     50 
     51    /** 
    2552     * Flattens a multi-dimensional associative array down into a 1 dimensional 
    2653     * associative array. 
  • trunk/fuel/core/classes/asset.php

    r53 r59  
    154154                } 
    155155 
    156                 $file = static::$_asset_url.$file.(static::$_add_mtime ? '?'.filemtime($file) : ''); 
     156                $raw or $file = static::$_asset_url.$file.(static::$_add_mtime ? '?'.filemtime($file) : ''); 
    157157            } 
    158158            else 
  • trunk/fuel/core/classes/config.php

    r53 r59  
    3838            foreach ($paths as $path) 
    3939            { 
    40                 $config = \Fuel::load($path) + $config; 
    41             } 
    42         } 
     40                $config = array_merge($config, \Fuel::load($path)); 
     41            } 
     42        } 
     43 
    4344        if ($group === null) 
    4445        { 
     
    5253                static::$items[$group] = array(); 
    5354            } 
    54             static::$items[$group] = static::$items[$group] + $config; 
     55            static::$items[$group] = array_merge(static::$items[$group],$config); 
    5556        } 
    5657 
  • trunk/fuel/core/classes/controller/rest.php

    r54 r59  
    1414     */ 
    1515    protected $methods = array(); 
     16     
     17    /** 
     18     * @var  string  the detected response format 
     19     */ 
     20    protected $format = null; 
    1621 
    1722    /** 
     
    6974            $resource = preg_replace($pattern, '', $resource); 
    7075 
    71             $this->request->format = $matches[1]; 
     76            $this->format = $matches[1]; 
    7277        } 
    7378        else 
    7479        { 
    7580            // Which format should the data be returned in? 
    76             $this->request->format = $this->_detect_format(); 
     81            $this->format = $this->_detect_format(); 
    7782        } 
    7883 
     
    111116 
    112117        // If the format method exists, call and return the output in that format 
    113         if (method_exists('Format', 'to_'.$this->request->format)) 
     118        if (method_exists('Format', 'to_'.$this->format)) 
    114119        { 
    115120            // Set the correct format header 
    116             $this->response->set_header('Content-Type', $this->_supported_formats[$this->request->format]); 
    117  
    118             $this->response->body(Format::factory($data)->{'to_'.$this->request->format}()); 
     121            $this->response->set_header('Content-Type', $this->_supported_formats[$this->format]); 
     122 
     123            $this->response->body(Format::factory($data)->{'to_'.$this->format}()); 
    119124        } 
    120125 
  • trunk/fuel/core/classes/database/query/builder/update.php

    r53 r59  
    1919    // SET ... 
    2020    protected $_set = array(); 
     21 
     22    // JOIN ... 
     23    protected $_join = array(); 
    2124 
    2225    /** 
     
    9295        $query = 'UPDATE '.$db->quote_table($this->_table); 
    9396 
     97        if ( ! empty($this->_join)) 
     98        { 
     99            // Add tables to join 
     100            $query .= ' '.$this->_compile_join($db, $this->_join); 
     101        } 
     102 
    94103        // Add the columns to update 
    95104        $query .= ' SET '.$this->_compile_set($db, $this->_set); 
     
    124133    } 
    125134 
     135    /** 
     136     * Adds addition tables to "JOIN ...". 
     137     * 
     138     * @param   mixed   column name or array($column, $alias) or object 
     139     * @param   string  join type (LEFT, RIGHT, INNER, etc) 
     140     * @return  $this 
     141     */ 
     142    public function join($table, $type = NULL) 
     143    { 
     144        $this->_join[] = $this->_last_join = new \Database_Query_Builder_Join($table, $type); 
     145 
     146        return $this; 
     147    } 
     148 
     149    /** 
     150     * Adds "ON ..." conditions for the last created JOIN statement. 
     151     * 
     152     * @param   mixed   column name or array($column, $alias) or object 
     153     * @param   string  logic operator 
     154     * @param   mixed   column name or array($column, $alias) or object 
     155     * @return  $this 
     156     */ 
     157    public function on($c1, $op, $c2) 
     158    { 
     159        $this->_last_join->on($c1, $op, $c2); 
     160 
     161        return $this; 
     162    } 
    126163 
    127164} // End Database_Query_Builder_Update 
  • trunk/fuel/core/classes/email.php

    r53 r59  
    3939    public static function factory($config = array()) 
    4040    { 
    41         $initconfig = Config::load('email'); 
     41        $initconfig = Config::load('email', null, true); 
    4242 
    4343        if (is_array($config) && is_array($initconfig)) 
  • trunk/fuel/core/classes/fieldset/field.php

    r53 r59  
    203203                { 
    204204                    $callable_rule = true; 
    205                     $this->rules[] = array(array($callback_class, $callback_method), $args); 
     205                    $this->rules[] = array(array($callback => array($callback_class, $callback_method)), $args); 
     206                    break; 
    206207                } 
    207208            } 
     
    212213        { 
    213214            if (is_callable($callback)) 
     215            { 
     216                if ($callback instanceof \Closure) 
     217                { 
     218                    $callback_name = 'closure'; 
     219                } 
     220                elseif (is_array($callback)) 
     221                { 
     222                    $callback_name = preg_replace('#^([a-z_]*\\\\)*#i', '', 
     223                        is_object($callback[0]) ? get_class($callback[0]) : $callback[0]).':'.$callback[1]; 
     224                } 
     225                else 
     226                { 
     227                    $callback_name = str_replace('::', ':', $callback); 
     228                } 
     229 
     230                $this->rules[] = array(array($callback_name => $callback), $args); 
     231            } 
     232            elseif (is_array($callback) and is_callable(reset($callback))) 
    214233            { 
    215234                $this->rules[] = array($callback, $args); 
  • trunk/fuel/core/classes/form.php

    r57 r59  
    761761        if (is_array($build_field)) 
    762762        { 
     763            $label = $field->label ? static::label($field->label) : ''; 
    763764            $template = $field->template ?: $this->get_config('multi_field_template', '\t\t\t{group_label}\n {fields}\t\t\t{label} {field}{fields}'); 
    764765            if ($template && preg_match('#\{fields\}(.*)\{fields\}#Dus', $template, $match) > 0) 
  • trunk/fuel/core/classes/format.php

    r53 r59  
    150150            { 
    151151                $node = $structure->addChild($key); 
    152  
    153                 // recrusive call. 
    154                 $this->to_xml($value, $node, $key); 
     152                 
     153                // recursive call if value is not empty 
     154                if( ! empty($value)) 
     155                { 
     156                    $this->to_xml($value, $node, $key); 
     157                } 
    155158            } 
    156159 
  • trunk/fuel/core/classes/pagination.php

    r57 r59  
    3535     */ 
    3636    public static $total_pages = 0; 
     37     
     38    /** 
     39     * @var array The HTML for the display 
     40     */ 
     41    public static $template = array( 
     42        'wrapper_start'  => '<div class="pagination"> ', 
     43        'wrapper_end'    => ' </div>', 
     44        'page_start'     => '<span class="page-links"> ', 
     45        'page_end'       => ' </span>', 
     46        'previous_start' => '<span class="previous"> ', 
     47        'previous_end'   => ' </span>', 
     48        'previous_mark'  => '&laquo; ', 
     49        'next_start'     => '<span class="next"> ', 
     50        'next_end'       => ' </span>', 
     51        'next_mark'      => ' &raquo;', 
     52        'active_start'   => '<span class="active"> ', 
     53        'active_end'     => ' </span>', 
     54    ); 
    3755 
    3856    /** 
     
    87105        foreach ($config as $key => $value) 
    88106        { 
     107            if ($key == 'template') 
     108            { 
     109                static::$template = array_merge(static::$template, $config['template']); 
     110                continue; 
     111            } 
     112 
    89113            static::${$key} = $value; 
    90114        } 
     
    137161        \Lang::load('pagination', true); 
    138162 
    139         $pagination = ''; 
    140         $pagination .= '&nbsp;'.static::prev_link('&laquo; '.\Lang::line('pagination.previous')).'&nbsp;'; 
     163        $pagination  = static::$template['wrapper_start']; 
     164        $pagination .= static::prev_link(\Lang::line('pagination.previous')); 
    141165        $pagination .= static::page_links(); 
    142         $pagination .= '&nbsp;'.static::next_link(\Lang::line('pagination.next').' &raquo;'); 
     166        $pagination .= static::next_link(\Lang::line('pagination.next')); 
     167        $pagination .= static::$template['wrapper_end']; 
    143168 
    144169        return $pagination; 
     
    172197            if (static::$current_page == $i) 
    173198            { 
    174                 $pagination .= '<b>'.$i.'</b>'; 
     199                $pagination .= static::$template['active_start'].$i.static::$template['active_end']; 
    175200            } 
    176201            else 
    177202            { 
    178203                $url = ($i == 1) ? '' : '/'.$i; 
    179                 $pagination .= \Html::anchor(rtrim(static::$pagination_url, '/') . $url, $i); 
     204                $pagination .= \Html::anchor(rtrim(static::$pagination_url, '/').$url, $i); 
    180205            } 
    181206        } 
    182207 
    183         return $pagination; 
     208        return static::$template['page_start'].$pagination.static::$template['page_end']; 
    184209    } 
    185210 
     
    202227        if (static::$current_page == static::$total_pages) 
    203228        { 
    204             return $value; 
     229            return $value.static::$template['next_mark']; 
    205230        } 
    206231        else 
    207232        { 
    208233            $next_page = static::$current_page + 1; 
    209             return \Html::anchor(rtrim(static::$pagination_url, '/').'/'.$next_page, $value); 
     234            return \Html::anchor(rtrim(static::$pagination_url, '/').'/'.$next_page, $value.static::$template['next_mark']); 
    210235        } 
    211236    } 
     
    229254        if (static::$current_page == 1) 
    230255        { 
    231             return $value; 
     256            return static::$template['previous_mark'].$value; 
    232257        } 
    233258        else 
    234259        { 
    235260            $previous_page = static::$current_page - 1; 
    236             $previous_page = ($previous_page == 1) ? '' : '/' . $previous_page; 
    237             return \Html::anchor(rtrim(static::$pagination_url, '/') . $previous_page, $value); 
     261            $previous_page = ($previous_page == 1) ? '' : '/'.$previous_page; 
     262            return \Html::anchor(rtrim(static::$pagination_url, '/').$previous_page, static::$template['previous_mark'].$value); 
    238263        } 
    239264    } 
  • trunk/fuel/core/classes/security.php

    r53 r59  
    165165    public static function htmlentities($value) 
    166166    { 
     167        static $already_cleaned = array(); 
     168 
     169        // Prevent looping & encoding twice 
     170        if (in_array($value, $already_cleaned)) 
     171        { 
     172            return $value; 
     173        } 
     174 
    167175        if (is_string($value)) 
    168176        { 
     
    175183                $value[$k] = static::htmlentities($v); 
    176184            } 
     185 
     186            // Add to $already_cleaned variable when object 
     187            is_object($value) and $already_cleaned[] = $value; 
    177188        } 
    178189        elseif (is_object($value)) 
     
    183194                if (is_a($value, $class)) 
    184195                { 
     196                    // Add to $already_cleaned variable 
     197                    $already_cleaned[] = $value; 
     198 
    185199                    return $value; 
    186200                } 
  • trunk/fuel/core/classes/str.php

    r57 r59  
    6868     * @return  string 
    6969     */ 
    70     public static function increment($str, $first = 1) 
    71     { 
    72         preg_match('/(.+)_([0-9]+)$/', $str, $match); 
    73  
    74         return isset($match[2]) ? $match[1].'_'.($match[2] + 1) : $str.'_'.$first; 
     70    public static function increment($str, $first = 1, $separator = '_') 
     71    { 
     72        preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match); 
     73 
     74        return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first; 
    7575    } 
    7676 
  • trunk/fuel/core/classes/upload.php

    r57 r59  
    419419                elseif(is_numeric($param)) 
    420420                { 
    421                     if (isset(static::$files[$param - 1])) 
    422                     { 
    423                         $files[$param] = static::$files[$param - 1]; 
     421                    if (isset(static::$files[$param])) 
     422                    { 
     423                        $files[$param] = static::$files[$param]; 
    424424                    } 
    425425                } 
  • trunk/fuel/core/classes/uri.php

    r53 r59  
    104104        } 
    105105 
     106        // Strip the defined url suffix from the uri if needed 
     107        $ext = \Config::get('url_suffix'); 
     108        strrchr($uri, '.') === $ext and $uri = substr($uri,0,-strlen($ext)); 
     109 
    106110        // Do some final clean up of the uri 
    107111        static::$detected_uri = str_replace(array('//', '../'), '/', $uri); 
     
    150154    public static function create($uri = null, $variables = array(), $get_variables = array()) 
    151155    { 
    152         $url = \Config::get('base_url'); 
    153  
    154         if (\Config::get('index_file')) 
    155         { 
    156             $url .= \Config::get('index_file').'/'; 
     156        $url = ''; 
     157         
     158        if(!preg_match("/^(http|https|ftp):\/\//i", $uri)) 
     159        { 
     160            $url .= \Config::get('base_url'); 
     161 
     162            if (\Config::get('index_file')) 
     163            { 
     164                $url .= \Config::get('index_file').'/'; 
     165            } 
    157166        } 
    158167 
    159168        $url = $url.ltrim(is_null($uri) ? static::string() : $uri, '/'); 
     169 
     170        substr($url, -1) != '/' and $url .= \Config::get('url_suffix'); 
    160171 
    161172        if ( ! empty($get_variables)) 
  • trunk/fuel/core/classes/validation.php

    r57 r59  
    300300    protected function _run_rule($rule, &$value, $params, $field) 
    301301    { 
    302         $output = call_user_func_array($rule, array_merge(array($value), $params)); 
     302        $output = call_user_func_array(reset($rule), array_merge(array($value), $params)); 
    303303 
    304304        if ($output === false && $value !== false) 
  • trunk/fuel/core/classes/validation/error.php

    r54 r59  
    3636    public $field = ''; 
    3737    public $value = ''; 
    38     public $callback = ''; 
     38    public $rule = ''; 
    3939    public $params = array(); 
    4040 
     
    4949    public function __construct($field, $value, $callback, $params) 
    5050    { 
    51         $this->field = $field; 
    52         $this->value = $value; 
    53         $this->params = $params; 
    54  
    55         /** 
    56          * Simplify callback for rule, class/object and method are seperated by 1 colon 
    57          * and objects become their classname without the namespace. 
    58          * Rules called on a callable are considered without classname & method prefix 
    59          */ 
    60         if (is_array($callback)) 
    61         { 
    62             foreach ($field->fieldset()->validation()->callables() as $c) 
    63             { 
    64                 if ($c == $callback[0] && substr($callback[1], 0, 12) == '_validation_') 
    65                 { 
    66                     $callback = substr($callback[1], 12); 
    67                     break; 
    68                 } 
    69             } 
    70         } 
    71         $this->callback = is_string($callback) 
    72                 ? str_replace('::', ':', $callback) 
    73                 : preg_replace('#^([a-z_]*\\\\)*#i', '', get_class($callback[0])).':'.$callback[1]; 
     51        $this->field   = $field; 
     52        $this->value   = $value; 
     53        $this->params  = $params; 
     54        $this->rule    = key($callback); 
    7455    } 
    7556 
     
    8465     * @return  string 
    8566     */ 
    86     public function get_message($msg = false, $open = null, $close = null) 
     67    public function get_message($msg = false, $open = '', $close = '') 
    8768    { 
    88         $open   = \Config::get('validation.open_single_error', ''); 
    89         $close  = \Config::get('validation.close_single_error', ''); 
     69        $open   = \Config::get('validation.open_single_error', $open); 
     70        $close  = \Config::get('validation.close_single_error', $close); 
    9071 
    9172        if ($msg === false) 
    9273        { 
    93             $msg = $this->field->fieldset()->validation()->get_message($this->callback); 
     74            $msg = $this->field->fieldset()->validation()->get_message($this->rule); 
    9475            $msg = $msg === false 
    95                 ? __('validation.'.$this->callback) ?: __('validation.'.Arr::element(explode(':', $this->callback), 0)) 
     76                ? __('validation.'.$this->rule) ?: __('validation.'.Arr::element(explode(':', $this->rule), 0)) 
    9677                : $msg; 
    9778        } 
    9879        if ($msg == false) 
    9980        { 
    100             return $open.'Validation rule '.$this->callback.' failed for '.$this->field->label.$close; 
     81            return $open.'Validation rule '.$this->rule.' failed for '.$this->field->label.$close; 
    10182        } 
    10283 
     
    10788        } 
    10889 
     90        $label    = is_array($this->field->label) ? $this->field->label['label'] : $this->field->label; 
     91        if (\Config::get('validation.quote_labels', false) and strpos($label, ' ') !== false) 
     92        { 
     93            // put the label in quotes if it contains spaces 
     94            $label = '"'.$label.'"'; 
     95        } 
    10996        $value    = is_array($this->value) ? implode(', ', $this->value) : $this->value; 
    11097        $find     = array(':field', ':label', ':value', ':rule'); 
    111         $label    = is_array($this->field->label) ? $this->field->label['label'] : $this->field->label; 
    112         if (\Config::get('validation.quote_labels', false)) 
    113         { 
    114             // put the label in quotes if it contains spaces 
    115             strpos($label, ' ') !== false and $label = '"'.$label.'"'; 
    116         } 
    117         $replace  = array($this->field->name, $label, $value, $this->callback); 
     98        $replace  = array($this->field->name, $label, $value, $this->rule); 
    11899        foreach($this->params as $key => $val) 
    119100        { 
  • trunk/fuel/core/classes/viewmodel.php

    r53 r59  
    4242            if ( ! class_exists($class = $viewmodel)) 
    4343            { 
    44                 throw new \OutOfBoundsException('ViewModel could not be found.'); 
     44                throw new \OutOfBoundsException('ViewModel "View_'.ucfirst(str_replace(DS, '_', $viewmodel)).'" could not be found.'); 
    4545            } 
    4646        } 
  • trunk/fuel/core/tests/arr.php

    r57 r59  
    3838        ); 
    3939    } 
     40     
     41    /** 
     42     * Tests Arr::assoc_to_keyval() 
     43     * 
     44     * @test 
     45     */ 
     46    public function test_assoc_to_keyval() 
     47    { 
     48        $assoc = array( 
     49            array( 
     50                'color' => 'red', 
     51                'rank' => 4, 
     52                'name' => 'Apple', 
     53                ), 
     54            array( 
     55                'color' => 'yellow', 
     56                'rank' => 3, 
     57                'name' => 'Banana', 
     58                ), 
     59            array( 
     60                'color' => 'purple', 
     61                'rank' => 2, 
     62                'name' => 'Grape', 
     63                ), 
     64            ); 
     65         
     66        $expected = array( 
     67            'red' => 'Apple', 
     68            'yellow' => 'Banana', 
     69            'purple' => 'Grape', 
     70            ); 
     71        $output = Arr::assoc_to_keyval($assoc, 'color', 'name'); 
     72        $this->assertEquals($expected, $output); 
     73    } 
    4074 
    4175    /** 
  • trunk/fuel/core/tests/uri.php

    r57 r59  
    1515/** 
    1616 * Html class tests 
    17  *  
     17 * 
    1818 * @group Core 
    1919 * @group Uri 
     
    2323    /** 
    2424     * Tests Uri::create() 
    25      *  
     25     * 
    2626     * @test 
    2727     */ 
     
    3737        $expected = $prefix."controller/thing?what=more"; 
    3838        $this->assertEquals($expected, $output); 
     39 
     40        Config::set('url_suffix', '.html'); 
     41 
     42        $output = Uri::create('controller/method'); 
     43        $expected = $prefix."controller/method.html"; 
     44        $this->assertEquals($expected, $output); 
     45 
     46        $output = Uri::create('controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and')); 
     47        $expected = $prefix."controller/thing.html?what=more"; 
     48        $this->assertEquals($expected, $output); 
     49         
     50        $output = Uri::create('http://example.com/controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and')); 
     51        $expected = "http://example.com/controller/thing.html?what=more"; 
     52        $this->assertEquals($expected, $output); 
     53 
    3954    } 
    4055 
  • trunk/fuel/core/vendor/htmlawed/htmlawed.php

    r53 r59  
    22 
    33/* 
    4 htmLawed 1.1.9.4, 3 July 2010 
     4htmLawed 1.1.9.5, 6 July 2011 
    55Copyright Santosh Patnaik 
    66LGPL v3 license 
     
    150150$cN2 = array_keys($cN); 
    151151$cR = array('blockquote'=>1, 'dir'=>1, 'dl'=>1, 'form'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'ol'=>1, 'optgroup'=>1, 'rbc'=>1, 'rtc'=>1, 'ruby'=>1, 'select'=>1, 'table'=>1, 'tbody'=>1, 'tfoot'=>1, 'thead'=>1, 'tr'=>1, 'ul'=>1); 
    152 $cS = array('colgroup'=>array('col'=>1), 'dir'=>array('li'), 'dl'=>array('dd'=>1, 'dt'=>1), 'menu'=>array('li'=>1), 'ol'=>array('li'=>1), 'optgroup'=>array('option'=>1), 'option'=>array('#pcdata'=>1), 'rbc'=>array('rb'=>1), 'rp'=>array('#pcdata'=>1), 'rtc'=>array('rt'=>1), 'ruby'=>array('rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1), 'select'=>array('optgroup'=>1, 'option'=>1), 'script'=>array('#pcdata'=>1), 'table'=>array('caption'=>1, 'col'=>1, 'colgroup'=>1, 'tfoot'=>1, 'tbody'=>1, 'tr'=>1, 'thead'=>1), 'tbody'=>array('tr'=>1), 'tfoot'=>array('tr'=>1), 'textarea'=>array('#pcdata'=>1), 'thead'=>array('tr'=>1), 'tr'=>array('td'=>1, 'th'=>1), 'ul'=>array('li'=>1)); // Specific - immediate parent-child 
     152$cS = array('colgroup'=>array('col'=>1), 'dir'=>array('li'=>1), 'dl'=>array('dd'=>1, 'dt'=>1), 'menu'=>array('li'=>1), 'ol'=>array('li'=>1), 'optgroup'=>array('option'=>1), 'option'=>array('#pcdata'=>1), 'rbc'=>array('rb'=>1), 'rp'=>array('#pcdata'=>1), 'rtc'=>array('rt'=>1), 'ruby'=>array('rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1), 'select'=>array('optgroup'=>1, 'option'=>1), 'script'=>array('#pcdata'=>1), 'table'=>array('caption'=>1, 'col'=>1, 'colgroup'=>1, 'tfoot'=>1, 'tbody'=>1, 'tr'=>1, 'thead'=>1), 'tbody'=>array('tr'=>1), 'tfoot'=>array('tr'=>1), 'textarea'=>array('#pcdata'=>1), 'thead'=>array('tr'=>1), 'tr'=>array('td'=>1, 'th'=>1), 'ul'=>array('li'=>1)); // Specific - immediate parent-child 
    153153$cO = array('address'=>array('p'=>1), 'applet'=>array('param'=>1), 'blockquote'=>array('script'=>1), 'fieldset'=>array('legend'=>1, '#pcdata'=>1), 'form'=>array('script'=>1), 'map'=>array('area'=>1), 'object'=>array('param'=>1, 'embed'=>1)); // Other 
    154154$cT = array('colgroup'=>1, 'dd'=>1, 'dt'=>1, 'li'=>1, 'option'=>1, 'p'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1); // Omitable closing 
     
    208208  if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open 
    209209  $add = ''; // Nesting - close open tags that need to be 
    210   for($j=-1, $cj=count($q); ++$j<$cj;){   
     210  for($j=-1, $cj=count($q); ++$j<$cj;){ 
    211211   if(($d = array_pop($q)) == $e){break;} 
    212212   else{$add .= "</{$d}>";} 
     
    375375// final $spec 
    376376$s = array(); 
    377 $t = str_replace(array("\t", "\r", "\n", ' '), '', preg_replace('/"(?>(`.|[^"])*)"/sme', 'substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", \'`"\'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\""), "$0"), 1, -1)', trim($t)));  
     377$t = str_replace(array("\t", "\r", "\n", ' '), '', preg_replace('/"(?>(`.|[^"])*)"/sme', 'substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", \'`"\'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\""), "$0"), 1, -1)', trim($t))); 
    378378for($i = count(($t = explode(';', $t))); --$i>=0;){ 
    379379 $w = $t[$i]; 
     
    659659 $x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1)); 
    660660 $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); 
    661  $e = "<$e>";  
     661 $e = "<$e>"; 
    662662 if(isset($d[$y])){ 
    663663  if(!$x){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} 
     
    685685function hl_version(){ 
    686686// rel 
    687 return '1.1.9.4'; 
     687return '1.1.9.5'; 
    688688// eof 
    689689} 
  • trunk/fuel/packages/oil/classes/generate.php

    r56 r59  
    5555        static::views($args, false); 
    5656 
    57        $actions or $actions = array('index'); 
     57        $actions or $actions = array('index'); 
    5858 
    5959        $action_str = ''; 
     
    6868        } 
    6969 
     70        $extends = \Cli::option('extends', 'Controller_Template'); 
     71 
    7072        // Build Controller 
    7173        $controller = <<<CONTROLLER 
    7274<?php 
    7375 
    74 class Controller_{$class_name} extends Controller_Template { 
     76class Controller_{$class_name} extends {$extends} { 
    7577{$action_str} 
    7678} 
     
    8183        // Write controller 
    8284        static::create($filepath, $controller, 'controller'); 
     85         
    8386        $build and static::build(); 
    8487    } 
     
    8790    public static function model($args, $build = true) 
    8891    { 
    89         $singular = strtolower(array_shift($args)); 
     92        $singular = \Str::lower(array_shift($args)); 
    9093 
    9194        if (empty($args)) 
     
    179182    { 
    180183        // Get the migration name 
    181         $migration_name = strtolower(str_replace('-', '_', array_shift($args))); 
     184        $migration_name = \Str::lower(str_replace(array('-', '/'), '_', array_shift($args))); 
    182185 
    183186        // Check if a migration with this name already exists 
  • trunk/fuel/packages/oil/classes/scaffold.php

    r51 r59  
    4747 
    4848            $fields[] = array( 
    49                 'name' => strtolower($matches[1]), 
     49                'name' => \Str::lower($matches[1]), 
    5050                'type' => isset($matches[2]) ? $matches[2] : 'string', 
    5151                'constraint' => isset($matches[4]) ? $matches[4] : null 
     
    5353        } 
    5454 
    55         $data['singular'] = $singular = strtolower(array_shift($args)); 
    56         $data['model'] = $model_name = 'Model_'.\Inflector::classify($singular); 
     55        $full_thing = array_shift($args); 
     56        $full_underscores = str_replace(DS, '_', $full_thing); 
     57 
     58        // Either something[s] or folder/something[s] 
     59        $data['controller_uri'] = $controller_uri = \Inflector::pluralize(\Str::lower($full_thing)); 
     60        $data['controller'] = 'Controller_'.\Inflector::classify(\Inflector::pluralize($full_underscores)); 
     61 
     62        // If a folder is used, the entity is the last part 
     63        $data['singular'] = $singular = \Inflector::singularize(end(explode(DS, $full_thing))); 
     64        $data['model'] = $model_name = 'Model_'.\Inflector::classify($full_underscores); 
    5765        $data['plural'] = $plural = \Inflector::pluralize($singular); 
    5866        $data['fields'] = $fields; 
    5967 
    60         $filepath = APPPATH.'classes/controller/'.trim(str_replace(array('_', '-'), DS, $plural), DS).'.php'; 
     68        $filepath = APPPATH.'classes/controller/'.trim(str_replace(array('_', '-'), DS, $controller_uri), DS).'.php'; 
    6169        $controller = \View::factory($subfolder.'/scaffold/controller', $data); 
    6270 
     
    95103        foreach (array('index', 'view', 'create', 'edit', '_form') as $view) 
    96104        { 
    97             Generate::create(APPPATH.'views/'.$plural.'/'.$view.'.php', \View::factory($subfolder.'/scaffold/views/'.$view, $data), 'view'); 
     105            Generate::create(APPPATH.'views/'.$controller_uri.'/'.$view.'.php', \View::factory($subfolder.'/scaffold/views/'.$view, $data), 'view'); 
    98106        } 
    99107 
  • trunk/fuel/packages/oil/views/default/scaffold/actions/create.php

    r44 r59  
    1111                Session::set_flash('notice', 'Added <?php echo $singular; ?> #' . $<?php echo $singular; ?>->id . '.'); 
    1212 
    13                 Response::redirect('<?php echo $plural; ?>'); 
     13                Response::redirect('<?php echo $controller_uri; ?>'); 
    1414            } 
    1515 
     
    2020        } 
    2121 
    22         $this->template->title = "<?php echo ucfirst($plural); ?>"; 
    23         $this->template->content = View::factory('<?php echo Str::lower($plural);?>/create'); 
     22        $this->template->title = "<?php echo \Str::ucwords($plural); ?>"; 
     23        $this->template->content = View::factory('<?php echo $controller_uri ?>/create'); 
  • trunk/fuel/packages/oil/views/default/scaffold/actions/delete.php

    r44 r59  
    1111        } 
    1212 
    13         Response::redirect('<?php echo $plural; ?>'); 
     13        Response::redirect('<?php echo $controller_uri; ?>'); 
  • trunk/fuel/packages/oil/views/default/scaffold/actions/edit.php

    r57 r59  
    1111                Session::set_flash('notice', 'Updated <?php echo $singular; ?> #' . $id); 
    1212 
    13                 Response::redirect('<?php echo $plural; ?>'); 
     13                Response::redirect('<?php echo $controller_uri; ?>'); 
    1414            } 
    1515 
     
    2626         
    2727        $this->template->title = "<?php echo ucfirst($plural); ?>"; 
    28         $this->template->content = View::factory('<?php echo strtolower($plural);?>/edit'); 
     28        $this->template->content = View::factory('<?php echo $controller_uri; ?>/edit'); 
  • trunk/fuel/packages/oil/views/default/scaffold/actions/index.php

    r12 r59  
    1         $data['<?php echo strtolower($plural);?>'] = <?php echo $model; ?>::find('all'); 
     1        $data['<?php echo $plural ?>'] = <?php echo $model; ?>::find('all'); 
    22        $this->template->title = "<?php echo ucfirst($plural); ?>"; 
    3         $this->template->content = View::factory('<?php echo strtolower($plural);?>/index', $data); 
     3        $this->template->content = View::factory('<?php echo $controller_uri ?>/index', $data); 
  • trunk/fuel/packages/oil/views/default/scaffold/actions/view.php

    r12 r59  
    1         $data['<?php echo strtolower($singular);?>'] = <?php echo $model; ?>::find($id); 
     1        $data['<?php echo $singular ?>'] = <?php echo $model ?>::find($id); 
    22         
    3         $this->template->title = "<?php echo ucfirst($singular); ?>"; 
    4         $this->template->content = View::factory('<?php echo strtolower($plural);?>/view', $data); 
     3        $this->template->title = "<?php echo ucfirst($singular) ?>"; 
     4        $this->template->content = View::factory('<?php echo $controller_uri ?>/view', $data); 
  • trunk/fuel/packages/oil/views/default/scaffold/controller.php

    r12 r59  
    11<?php echo '<?php' ?> 
    22 
    3 class Controller_<?php echo ucfirst($plural); ?> extends Controller_Template { 
     3class <?php echo $controller; ?> extends <?php echo \Cli::option('extends', 'Controller_Template') ?> { 
    44     
    55<?php foreach ($actions as $action): ?> 
     
    1313} 
    1414 
    15 /* End of file <?php echo strtolower($plural); ?>.php */ 
     15/* End of file <?php echo $controller_uri; ?>.php */ 
  • trunk/fuel/packages/oil/views/default/scaffold/views/create.php

    r51 r59  
    1 <h2 class="first">New <?php echo ucfirst($singular); ?></h2> 
     1<h2 class="first">New <?php echo \Str::ucfirst($singular); ?></h2> 
    22 
    3 <?php echo '<?php'; ?> echo render('<?php echo $plural; ?>/_form'); ?> 
     3<?php echo '<?php'; ?> echo render('<?php echo $controller_uri ?>/_form'); ?> 
    44<br /> 
    5 <p><?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>', 'Back'); <?php echo '?>'; ?></p> 
     5<p><?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri ?>', 'Back'); <?php echo '?>'; ?></p> 
  • trunk/fuel/packages/oil/views/default/scaffold/views/edit.php

    r51 r59  
    1 <h2 class="first">Editing <?php echo ucfirst($singular); ?></h2> 
     1<h2 class="first">Editing <?php echo \Str::ucfirst($singular); ?></h2> 
    22 
    3 <?php echo '<?php'; ?> echo render('<?php echo $plural; ?>/_form'); ?> 
     3<?php echo '<?php'; ?> echo render('<?php echo $controller_uri; ?>/_form'); ?> 
    44<br /> 
    55<p> 
    6 <?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>/view/'.$<?php echo $singular; ?>->id, 'View'); <?php echo '?>'; ?> | 
    7 <?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>', 'Back'); <?php echo '?>'; ?> 
     6<?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri; ?>/view/'.$<?php echo $singular; ?>->id, 'View'); <?php echo '?>'; ?> | 
     7<?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri; ?>', 'Back'); <?php echo '?>'; ?> 
    88</p> 
  • trunk/fuel/packages/oil/views/default/scaffold/views/index.php

    r51 r59  
    1 <h2 class="first">Listing <?php echo ucfirst($plural); ?></h2> 
     1<h2 class="first">Listing <?php echo \Str::ucfirst($plural); ?></h2> 
    22 
    33<table cellspacing="0"> 
     
    1616<?php endforeach; ?> 
    1717        <td> 
    18             <?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>/view/'.$<?php echo $singular; ?>->id, 'View'); <?php echo '?>'; ?> | 
    19             <?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>/edit/'.$<?php echo $singular; ?>->id, 'Edit'); <?php echo '?>'; ?> | 
    20             <?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>/delete/'.$<?php echo $singular; ?>->id, 'Delete', array('onclick' => "return confirm('Are you sure?')")); <?php echo '?>'; ?> 
     18            <?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri; ?>/view/'.$<?php echo $singular; ?>->id, 'View'); <?php echo '?>'; ?> | 
     19            <?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri; ?>/edit/'.$<?php echo $singular; ?>->id, 'Edit'); <?php echo '?>'; ?> | 
     20            <?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri; ?>/delete/'.$<?php echo $singular; ?>->id, 'Delete', array('onclick' => "return confirm('Are you sure?')")); <?php echo '?>'; ?> 
    2121        </td> 
    2222    </tr> 
     
    2626<br /> 
    2727 
    28 <?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>/create', 'Add new <?php echo \Inflector::humanize($singular); ?>'); <?php echo '?>'; ?> 
     28<?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri; ?>/create', 'Add new <?php echo \Inflector::humanize($singular); ?>'); <?php echo '?>'; ?> 
  • trunk/fuel/packages/oil/views/default/scaffold/views/view.php

    r39 r59  
    66<?php endforeach; ?> 
    77 
    8 <?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>/edit/'.$<?php echo $singular; ?>->id, 'Edit'); <?php echo '?>'; ?> |  
    9 <?php echo '<?php'; ?> echo Html::anchor('<?php echo $plural; ?>', 'Back'); <?php echo '?>'; ?> 
     8<?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri ?>/edit/'.$<?php echo $singular; ?>->id, 'Edit'); <?php echo '?>'; ?> |  
     9<?php echo '<?php'; ?> echo Html::anchor('<?php echo $controller_uri ?>', 'Back'); <?php echo '?>'; ?> 
Note: See TracChangeset for help on using the changeset viewer.