Changeset 6 in ExiteCMS8


Ignore:
Timestamp:
01/09/11 19:00:43 (17 months ago)
Author:
WanWizard
Message:

merged upstream changes in the fuel core

Location:
trunk/fuel
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/fuel/core/bootstrap.php

    r2 r6  
    3737 */ 
    3838define('MBSTRING', function_exists('mb_get_info')); 
     39 
     40// Is Fuel being requested via an AJAX request? 
     41define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); 
     42 
     43// Is Fuel running on the command line? 
     44define('IS_CLI', defined('STDIN')); 
    3945 
    4046// Load in the Autoloader 
  • trunk/fuel/core/classes/cli.php

    r2 r6  
    6666    public static function _init() 
    6767    { 
     68        if ( ! IS_CLI) 
     69        { 
     70            throw new Exception('Cli class cannot be used outside of the command line.'); 
     71        } 
    6872        for ($i = 1; $i < $_SERVER['argc']; $i++) 
    6973        { 
  • trunk/fuel/core/classes/form.php

    r2 r6  
    1515namespace Fuel\Core; 
    1616 
    17  
    18  
    19 // ------------------------------------------------------------------------ 
    20  
    2117/** 
    2218 * Form Class 
     
    2622 * @package     Fuel 
    2723 * @category    Core 
    28  * @author      Philip Sturgeon, Jelmer Schreuder 
     24 * @author      Dan Horrigan & Jelmer Schreuder 
    2925 */ 
    3026class Form { 
     
    149145 
    150146        // If there is still no action set, Form-post 
    151         empty($attributes['action']) && $attributes['action'] = \Uri::current(); 
     147        if(empty($attributes['action'])) 
     148        { 
     149            $attributes['action'] = ''; 
     150        } 
    152151 
    153152        // If not a full URL, create one 
    154         ! strpos($attributes['action'], '://') && $attributes['action'] = \Uri::create($attributes['action']); 
     153        elseif ( ! strpos($attributes['action'], '://')) 
     154        { 
     155            $attributes['action'] = \Uri::create($attributes['action']); 
     156        } 
     157 
     158        if (empty($attributes['accept-charset'])) 
     159        { 
     160            $attributes['accept-charset'] = strtolower(INTERNAL_ENC); 
     161        } 
    155162 
    156163        // If method is empty, use POST 
  • trunk/fuel/core/classes/fuel.php

    r2 r6  
    3838    const L_ALL = 4; 
    3939 
    40     const VERSION = '1.0.0-beta1'; 
     40    const VERSION = '1.0.0-dev'; 
    4141 
    4242    public static $initialized = false; 
  • trunk/fuel/packages/activerecord/classes/association.php

    r2 r6  
    7272    } 
    7373 
    74     public function destroy(&$source) 
     74    public function delete(&$source) 
    7575    { 
    7676        if (isset($this->options['dependent']) && $this->options['dependent'] == 'destroy') 
  • trunk/fuel/packages/activerecord/classes/model.php

    r2 r6  
    240240    private $assoc_types = array('belongs_to', 'has_many', 'has_one'); 
    241241 
     242    /** 
     243     * The factory takes $params and returns a new instance. 
     244     * 
     245     *     $view = Model_User::factory(array('stuff' => 'junk')); 
     246     * 
     247     * @param   string  view filename 
     248     * @param   array   array of values 
     249     * @return  View 
     250     */ 
     251    public static function factory($params = null) 
     252    { 
     253        return new static($params, true); 
     254    } 
    242255 
    243256    /** 
     
    247260     * 
    248261     * <code> 
    249      * $user = new User; 
    250      * $user = new User(array('name' => 'Dan')); 
     262     * $user = new Model_User; 
     263     * $user = new Model_User(array('name' => 'Dan')); 
    251264     * </code> 
    252265     * 
     
    397410            $this->associations[$assoc_name]->set_ids($value, $this); 
    398411        } 
    399         else 
    400         { 
    401             throw new \Exception("attribute called '$name' doesn't exist", Exception::AttributeNotFound); 
    402         } 
    403412    } 
    404413 
     
    658667            foreach ($this->columns as $column) 
    659668            { 
    660                 if ($column == $this->primary_key) 
     669                if ($column == $this->primary_key OR ! in_array($column, $this->columns)) 
    661670                { 
    662671                    continue; 
     
    769778    { 
    770779        // Not running statically, AND 
     780        /* 
    771781        if ( ! isset($this) AND empty($id)) 
    772782        { 
     
    779789            $obj = $id ? static::run_find($id) : $this; 
    780790        } 
    781  
    782         if (method_exists($obj, 'before_delete')) 
    783         { 
    784             $obj->before_delete(); 
     791        */ 
     792 
     793        if (method_exists($this, 'before_delete')) 
     794        { 
     795            $this->before_delete(); 
    785796        } 
    786797        foreach ($this->associations as $name => $assoc) 
    787798        { 
    788             $assoc->delete($obj); 
     799            $assoc->delete($this); 
    789800        } 
    790801 
    791802        DB::delete($this->table_name) 
    792             ->where($this->primary_key, '=', $obj->{$this->primary_key}) 
     803            ->where($this->primary_key, '=', $this->{$this->primary_key}) 
    793804            ->limit(1) 
    794805            ->execute(); 
     
    796807        $this->frozen = true; 
    797808 
    798         if (method_exists($obj, 'after_delete')) 
     809        if (method_exists($this, 'after_delete')) 
    799810        { 
    800811            $this->after_delete(); 
  • trunk/fuel/packages/oil/classes/cli.php

    r2 r6  
    4040                case 'generate': 
    4141 
    42                     switch ($args[2]) 
     42                    $action = isset($args[2]) ? $args[2]: 'help'; 
     43 
     44                    switch ($action) 
    4345                    { 
    4446                        case 'controller': 
    4547                        case 'model': 
    46                         case 'view': 
    4748                        case 'views': 
    4849                        case 'migration': 
    49  
    50                             call_user_func('Oil\Generate::'.$args[2], array_slice($args, 3)); 
    51  
     50                            call_user_func('Oil\Generate::'.$action, array_slice($args, 3)); 
    5251                        break; 
    5352 
     
    7675                case 'package': 
    7776 
    78                     switch ($args[2]) 
     77                    $action = isset($args[2]) ? $args[2]: 'help'; 
     78                     
     79                    switch ($action) 
    7980                    { 
    8081                        case 'install': 
    8182                        case 'uninstall': 
    82                             call_user_func_array('Oil\Package::'.$args[2], array_slice($args, 3)); 
     83                            call_user_func_array('Oil\Package::'.$action, array_slice($args, 3)); 
    8384                        break; 
    84  
    8585 
    8686                        default: 
     
    8989 
    9090                break; 
    91              
    92                  
     91 
     92                case 'test': 
     93                    \Fuel::add_package('octane'); 
     94                    call_user_func('\\Fuel\\Octane\\Tests::run_'.$args[2], array_slice($args, 3)); 
     95                break; 
    9396 
    9497                case '-v': 
    9598                case '--version': 
    9699                    \Cli::write('Fuel: ' . \Fuel::VERSION); 
    97                 break; 
    98  
    99                 case 'test': 
    100                     \Fuel::add_package('octane'); 
    101                     call_user_func('\\Fuel\\Octane\\Tests::run_'.$args[2], array_slice($args, 3)); 
    102100                break; 
    103101 
     
    119117    
    120118Usage: 
    121   php oil generate [controller|model|migration|view|views] [options] 
     119  php oil [console|generate|help|test|package] 
    122120 
    123121Runtime options: 
    124122  -f, [--force]    # Overwrite files that already exist 
    125123  -s, [--skip]     # Skip files that already exist 
    126   -p, [--pretend]  # Run but do not make any changes 
    127124  -q, [--quiet]    # Supress status output 
    128125 
     
    131128 
    132129Description: 
    133     The 'oil' command can be used to generate MVC components, database migrations 
    134     and run specific tasks. 
     130  The 'oil' command can be used in serveral ways to facilitate quick development, help with 
     131  testing your application and for running Tasks. 
    135132 
    136 Examples: 
    137     php oil g controller <controllername> [<action1> |<action2> |..] 
    138     php oil g model <modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..] 
     133Documentation: 
     134  http://fuelphp.com/docs/packages/oil/intro.html 
    139135 
    140136HELP; 
  • trunk/fuel/packages/oil/classes/console.php

    r2 r6  
    6262            echo ">>> "; 
    6363 
    64             if (!$__line = trim(fgets(STDIN), PHP_EOL)) 
     64            if ( ! $__line = rtrim(trim(trim(fgets(STDIN)), PHP_EOL), ';')) 
    6565            { 
    6666                continue; 
     
    7878 
    7979            ob_start(); 
     80 
     81            // Unset the previous line and execute the new one 
    8082            $ret = eval("unset(\$__line); $__line;"); 
    8183 
     84            // Error was returned 
     85            if ($ret === false) 
     86            { 
     87                \Cli::write(\Cli::color('Parse Error - ' . $__line, 'light_red')); 
     88                \Cli::beep(); 
     89            } 
     90 
    8291            if (ob_get_length() == 0) 
    8392            { 
     
    9099                    echo addcslashes($ret, "\0..\37\177..\377"); 
    91100                } 
    92                 else if (!is_null($ret)) 
     101                else if ( ! is_null($ret)) 
    93102                { 
    94103                    var_export($ret); 
  • trunk/fuel/packages/oil/classes/generate.php

    r2 r6  
    8585        $singular = strtolower(array_shift($args)); 
    8686 
     87        if (empty($args)) 
     88        { 
     89            throw new Exception('No fields have been provided, the model will not know how to build the table.'); 
     90        } 
     91 
    8792        $plural = \Inflector::pluralize($singular); 
    8893 
     
    205210        $output = <<<HELP 
    206211Usage: 
    207   php oil generate [controller|model|migration|view|views] [options] 
     212  php oil [g|generate] [controller|model|migration|scaffold|views] [options] 
    208213 
    209214Runtime options: 
    210215  -f, [--force]    # Overwrite files that already exist 
    211216  -s, [--skip]     # Skip files that already exist 
    212   -q, [--quiet]    # Supress status output 
    213  
    214 Fuel options: 
    215   -v, [--version]  # Show Fuel version number and quit 
    216217 
    217218Description: 
    218     The 'oil' command can be used to generate MVC components, database migrations 
    219     and run specific tasks. 
     219  The 'oil' command can be used to generate MVC components, database migrations 
     220  and run specific tasks. 
    220221 
    221222Examples: 
    222     php oil generate controller <controllername> [<action1> |<action2> |..] 
    223     php oil g model <modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..] 
     223  php oil generate controller <controllername> [<action1> |<action2> |..] 
     224  php oil g model <modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..] 
     225  php oil g migration <migrationname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..] 
     226  php oil g scaffold <modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..] 
     227 
     228Documentation: 
     229  http://fuelphp.com/docs/packages/oil/generate.html 
    224230HELP; 
    225231 
  • trunk/fuel/packages/oil/classes/package.php

    r2 r6  
    105105    public static function help() 
    106106    { 
    107         \Cli::write('Help coming soon!', 'blue'); 
     107        $output = <<<HELP 
     108 
     109Usage: 
     110  php oil [p|package] <packagename> 
     111 
     112Description: 
     113  Packages containing extra functionality can be downloaded (or git cloned) simply with 
     114  the following commands. 
     115 
     116Runtime options: 
     117  --direct       # Download direct from ZIP even if Git is installed 
     118 
     119Examples: 
     120  php oil package install <packagename> 
     121  php oil package uninstall <packagename> 
     122 
     123Documentation: 
     124  http://fuelphp.com/docs/packages/oil/package.html 
     125HELP; 
     126        \Cli::write($output); 
     127 
    108128    } 
    109129 
  • trunk/fuel/packages/oil/classes/refine.php

    r2 r6  
    6666    public static function help() 
    6767    { 
    68         echo <<<HELP 
     68        $output = <<<HELP 
    6969 
    7070Usage: 
    71   php oil refine <taskname> 
     71  php oil [r|refine] <taskname> 
    7272 
    7373Description: 
     
    7878    php oil refine robots:protect 
    7979 
     80Documentation: 
     81    http://fuelphp.com/docs/packages/oil/refine.html 
    8082HELP; 
     83        \Cli::write($output); 
    8184 
    8285    } 
  • trunk/fuel/packages/oil/classes/scaffold.php

    r2 r6  
    2828    { 
    2929        // Do this first as there is the largest chance of error here 
    30 //      Generate::model($args); 
     30        Generate::model($args); 
    3131         
    3232        // Go through all arguments after the first and make them into field arrays 
     
    6464            ), 
    6565            array( 
     66                'name'      => 'create', 
     67                'params'    => '$id = null', 
     68                'code'      => \View::factory('scaffold/actions/create', $data), 
     69            ), 
     70            array( 
     71                'name'      => 'edit', 
     72                'params'    => '$id = null', 
     73                'code'      => \View::factory('scaffold/actions/edit', $data), 
     74            ), 
     75            array( 
    6676                'name'      => 'delete', 
    6777                'params'    => '$id = null', 
     
    90100 
    91101        // Create each of the views 
    92         foreach (array('index', 'view', 'create', 'edit') as $view) 
     102        foreach (array('index', 'view', 'create', 'edit', '_form') as $view) 
    93103        { 
    94104            static::write($view_file = $view_folder . $view . '.php', \View::factory('scaffold/views/'.$view, $data)); 
  • trunk/fuel/packages/oil/views/scaffold/actions/create.php

    r2 r6  
     1        if ($_POST) 
     2        { 
     3            $<?php echo $singular; ?> = <?php echo $model; ?>::factory($_POST); 
     4 
     5            if ($<?php echo $singular; ?> and $<?php echo $singular; ?>->save()) 
     6            { 
     7                Session::set_flash('notice', 'Added ' . $<?php echo $singular; ?> . ' #' . $<?php echo $singular; ?>->id); 
     8 
     9                Output::redirect('<?php echo $plural; ?>'); 
     10            } 
     11 
     12            else 
     13            { 
     14                Session::set_flash('notice', 'Could not save ' . $<?php echo $singular; ?> . ' #' . $id); 
     15            } 
     16 
     17        } 
     18 
    119        $this->template->title = "<?php echo ucfirst($plural); ?>"; 
    2         $this->template-><?php echo strtolower($plural);?> = <?php echo $model; ?>::find('all'); 
    3         $this->template->content = View::factory('<?php echo strtolower($plural);?>/index'); 
     20        $this->template->content = View::factory('<?php echo strtolower($plural);?>/create'); 
  • trunk/fuel/packages/oil/views/scaffold/actions/edit.php

    r2 r6  
     1        $<?php echo $singular; ?> = <?php echo $model; ?>::find($id); 
     2 
     3        if ($_POST) 
     4        { 
     5            if ($<?php echo $singular; ?>->update($_POST)) 
     6            { 
     7                Session::set_flash('notice', 'Updated ' . $<?php echo $singular; ?> . ' #' . $<?php echo $singular; ?>->id); 
     8 
     9                Output::redirect('<?php echo $plural; ?>'); 
     10            } 
     11 
     12            else 
     13            { 
     14                Session::set_flash('notice', 'Could not update ' . $<?php echo $singular; ?> . ' #' . $id); 
     15            } 
     16        } 
     17         
     18        else 
     19        { 
     20            $this->template->set_global('<?php echo $singular; ?>', $<?php echo $singular; ?>); 
     21        } 
     22         
    123        $this->template->title = "<?php echo ucfirst($plural); ?>"; 
    2         $this->template-><?php echo strtolower($plural);?> = <?php echo $model; ?>::find('all'); 
    3         $this->template->content = View::factory('<?php echo strtolower($plural);?>/index'); 
     24        $this->template->content = View::factory('<?php echo strtolower($plural);?>/edit'); 
  • trunk/fuel/packages/oil/views/scaffold/views/create.php

    r2 r6  
    1         $this->template->title = "<?php echo ucfirst($plural); ?>"; 
    2         $this->template-><?php echo strtolower($plural);?> = <?php echo $model; ?>::find('all'); 
    3         $this->template->content = View::factory('<?php echo strtolower($plural);?>/index'); 
     1<h2>New <?php echo $singular; ?></h2> 
     2 
     3<?php echo '<?php'; ?> echo render('<?php echo $plural; ?>/_form'); ?> 
     4 
     5<?php echo '<?php'; ?> echo HTML::anchor('<?php echo $plural; ?>', 'Back'); <?php echo '?>'; ?> 
  • trunk/fuel/packages/oil/views/scaffold/views/edit.php

    r2 r6  
    1         $this->template->title = "<?php echo ucfirst($plural); ?>"; 
    2         $this->template-><?php echo strtolower($plural);?> = <?php echo $model; ?>::find('all'); 
    3         $this->template->content = View::factory('<?php echo strtolower($plural);?>/index'); 
     1<h2>Editing <?php echo $singular; ?></h2> 
     2 
     3<?php echo '<?php'; ?> echo render('<?php echo $plural; ?>/_form'); ?> 
     4 
     5<?php echo '<?php'; ?> echo HTML::anchor('<?php echo $plural; ?>/view/'.$<?php echo $singular; ?>->id, 'View'); <?php echo '?>'; ?> | 
     6<?php echo '<?php'; ?> echo HTML::anchor('<?php echo $plural; ?>', 'Back'); <?php echo '?>'; ?> 
  • trunk/fuel/packages/oil/views/scaffold/views/index.php

    r2 r6  
    1717        <td><?php echo '<?php'; ?> echo $<?php echo $singular.'->'.$field['name']; ?>; <?php echo '?>'; ?></td> 
    1818<?php endforeach; ?> 
    19  
    2019        <td><?php echo '<?php'; ?> echo HTML::anchor('<?php echo $plural; ?>/view/'.$<?php echo $singular; ?>->id, 'View'); <?php echo '?>'; ?></td> 
    2120        <td><?php echo '<?php'; ?> echo HTML::anchor('<?php echo $plural; ?>/edit/'.$<?php echo $singular; ?>->id, 'Edit'); <?php echo '?>'; ?></td> 
    22         <td><?php echo '<?php'; ?> echo HTML::anchor('<?php echo $plural; ?>/delete/'.$<?php echo $singular; ?>->id, 'Delete'); <?php echo '?>'; ?></td> 
     21        <td><?php echo '<?php'; ?> echo HTML::anchor('<?php echo $plural; ?>/delete/'.$<?php echo $singular; ?>->id, 'Delete', array('onclick' => "return confirm('Are you sure?')")); <?php echo '?>'; ?></td> 
    2322    </tr> 
    2423    <?php echo '<?php endforeach; ?>'; ?> 
Note: See TracChangeset for help on using the changeset viewer.