Changeset 6 in ExiteCMS8
- Timestamp:
- 01/09/11 19:00:43 (17 months ago)
- Location:
- trunk/fuel
- Files:
-
- 17 edited
-
core/bootstrap.php (modified) (1 diff)
-
core/classes/cli.php (modified) (1 diff)
-
core/classes/form.php (modified) (3 diffs)
-
core/classes/fuel.php (modified) (1 diff)
-
packages/activerecord/classes/association.php (modified) (1 diff)
-
packages/activerecord/classes/model.php (modified) (7 diffs)
-
packages/oil/classes/cli.php (modified) (5 diffs)
-
packages/oil/classes/console.php (modified) (3 diffs)
-
packages/oil/classes/generate.php (modified) (2 diffs)
-
packages/oil/classes/package.php (modified) (1 diff)
-
packages/oil/classes/refine.php (modified) (2 diffs)
-
packages/oil/classes/scaffold.php (modified) (3 diffs)
-
packages/oil/views/scaffold/actions/create.php (modified) (1 diff)
-
packages/oil/views/scaffold/actions/edit.php (modified) (1 diff)
-
packages/oil/views/scaffold/views/create.php (modified) (1 diff)
-
packages/oil/views/scaffold/views/edit.php (modified) (1 diff)
-
packages/oil/views/scaffold/views/index.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fuel/core/bootstrap.php
r2 r6 37 37 */ 38 38 define('MBSTRING', function_exists('mb_get_info')); 39 40 // Is Fuel being requested via an AJAX request? 41 define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); 42 43 // Is Fuel running on the command line? 44 define('IS_CLI', defined('STDIN')); 39 45 40 46 // Load in the Autoloader -
trunk/fuel/core/classes/cli.php
r2 r6 66 66 public static function _init() 67 67 { 68 if ( ! IS_CLI) 69 { 70 throw new Exception('Cli class cannot be used outside of the command line.'); 71 } 68 72 for ($i = 1; $i < $_SERVER['argc']; $i++) 69 73 { -
trunk/fuel/core/classes/form.php
r2 r6 15 15 namespace Fuel\Core; 16 16 17 18 19 // ------------------------------------------------------------------------20 21 17 /** 22 18 * Form Class … … 26 22 * @package Fuel 27 23 * @category Core 28 * @author Philip Sturgeon,Jelmer Schreuder24 * @author Dan Horrigan & Jelmer Schreuder 29 25 */ 30 26 class Form { … … 149 145 150 146 // 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 } 152 151 153 152 // 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 } 155 162 156 163 // If method is empty, use POST -
trunk/fuel/core/classes/fuel.php
r2 r6 38 38 const L_ALL = 4; 39 39 40 const VERSION = '1.0.0- beta1';40 const VERSION = '1.0.0-dev'; 41 41 42 42 public static $initialized = false; -
trunk/fuel/packages/activerecord/classes/association.php
r2 r6 72 72 } 73 73 74 public function de stroy(&$source)74 public function delete(&$source) 75 75 { 76 76 if (isset($this->options['dependent']) && $this->options['dependent'] == 'destroy') -
trunk/fuel/packages/activerecord/classes/model.php
r2 r6 240 240 private $assoc_types = array('belongs_to', 'has_many', 'has_one'); 241 241 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 } 242 255 243 256 /** … … 247 260 * 248 261 * <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')); 251 264 * </code> 252 265 * … … 397 410 $this->associations[$assoc_name]->set_ids($value, $this); 398 411 } 399 else400 {401 throw new \Exception("attribute called '$name' doesn't exist", Exception::AttributeNotFound);402 }403 412 } 404 413 … … 658 667 foreach ($this->columns as $column) 659 668 { 660 if ($column == $this->primary_key )669 if ($column == $this->primary_key OR ! in_array($column, $this->columns)) 661 670 { 662 671 continue; … … 769 778 { 770 779 // Not running statically, AND 780 /* 771 781 if ( ! isset($this) AND empty($id)) 772 782 { … … 779 789 $obj = $id ? static::run_find($id) : $this; 780 790 } 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(); 785 796 } 786 797 foreach ($this->associations as $name => $assoc) 787 798 { 788 $assoc->delete($ obj);799 $assoc->delete($this); 789 800 } 790 801 791 802 DB::delete($this->table_name) 792 ->where($this->primary_key, '=', $ obj->{$this->primary_key})803 ->where($this->primary_key, '=', $this->{$this->primary_key}) 793 804 ->limit(1) 794 805 ->execute(); … … 796 807 $this->frozen = true; 797 808 798 if (method_exists($ obj, 'after_delete'))809 if (method_exists($this, 'after_delete')) 799 810 { 800 811 $this->after_delete(); -
trunk/fuel/packages/oil/classes/cli.php
r2 r6 40 40 case 'generate': 41 41 42 switch ($args[2]) 42 $action = isset($args[2]) ? $args[2]: 'help'; 43 44 switch ($action) 43 45 { 44 46 case 'controller': 45 47 case 'model': 46 case 'view':47 48 case 'views': 48 49 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)); 52 51 break; 53 52 … … 76 75 case 'package': 77 76 78 switch ($args[2]) 77 $action = isset($args[2]) ? $args[2]: 'help'; 78 79 switch ($action) 79 80 { 80 81 case 'install': 81 82 case 'uninstall': 82 call_user_func_array('Oil\Package::'.$a rgs[2], array_slice($args, 3));83 call_user_func_array('Oil\Package::'.$action, array_slice($args, 3)); 83 84 break; 84 85 85 86 86 default: … … 89 89 90 90 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; 93 96 94 97 case '-v': 95 98 case '--version': 96 99 \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));102 100 break; 103 101 … … 119 117 120 118 Usage: 121 php oil generate [controller|model|migration|view|views] [options]119 php oil [console|generate|help|test|package] 122 120 123 121 Runtime options: 124 122 -f, [--force] # Overwrite files that already exist 125 123 -s, [--skip] # Skip files that already exist 126 -p, [--pretend] # Run but do not make any changes127 124 -q, [--quiet] # Supress status output 128 125 … … 131 128 132 129 Description: 133 The 'oil' command can be used to generate MVC components, database migrations134 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. 135 132 136 Examples: 137 php oil g controller <controllername> [<action1> |<action2> |..] 138 php oil g model <modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..] 133 Documentation: 134 http://fuelphp.com/docs/packages/oil/intro.html 139 135 140 136 HELP; -
trunk/fuel/packages/oil/classes/console.php
r2 r6 62 62 echo ">>> "; 63 63 64 if ( !$__line = trim(fgets(STDIN), PHP_EOL))64 if ( ! $__line = rtrim(trim(trim(fgets(STDIN)), PHP_EOL), ';')) 65 65 { 66 66 continue; … … 78 78 79 79 ob_start(); 80 81 // Unset the previous line and execute the new one 80 82 $ret = eval("unset(\$__line); $__line;"); 81 83 84 // Error was returned 85 if ($ret === false) 86 { 87 \Cli::write(\Cli::color('Parse Error - ' . $__line, 'light_red')); 88 \Cli::beep(); 89 } 90 82 91 if (ob_get_length() == 0) 83 92 { … … 90 99 echo addcslashes($ret, "\0..\37\177..\377"); 91 100 } 92 else if ( !is_null($ret))101 else if ( ! is_null($ret)) 93 102 { 94 103 var_export($ret); -
trunk/fuel/packages/oil/classes/generate.php
r2 r6 85 85 $singular = strtolower(array_shift($args)); 86 86 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 87 92 $plural = \Inflector::pluralize($singular); 88 93 … … 205 210 $output = <<<HELP 206 211 Usage: 207 php oil generate [controller|model|migration|view|views] [options]212 php oil [g|generate] [controller|model|migration|scaffold|views] [options] 208 213 209 214 Runtime options: 210 215 -f, [--force] # Overwrite files that already exist 211 216 -s, [--skip] # Skip files that already exist 212 -q, [--quiet] # Supress status output213 214 Fuel options:215 -v, [--version] # Show Fuel version number and quit216 217 217 218 Description: 218 The 'oil' command can be used to generate MVC components, database migrations219 and run specific tasks.219 The 'oil' command can be used to generate MVC components, database migrations 220 and run specific tasks. 220 221 221 222 Examples: 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 228 Documentation: 229 http://fuelphp.com/docs/packages/oil/generate.html 224 230 HELP; 225 231 -
trunk/fuel/packages/oil/classes/package.php
r2 r6 105 105 public static function help() 106 106 { 107 \Cli::write('Help coming soon!', 'blue'); 107 $output = <<<HELP 108 109 Usage: 110 php oil [p|package] <packagename> 111 112 Description: 113 Packages containing extra functionality can be downloaded (or git cloned) simply with 114 the following commands. 115 116 Runtime options: 117 --direct # Download direct from ZIP even if Git is installed 118 119 Examples: 120 php oil package install <packagename> 121 php oil package uninstall <packagename> 122 123 Documentation: 124 http://fuelphp.com/docs/packages/oil/package.html 125 HELP; 126 \Cli::write($output); 127 108 128 } 109 129 -
trunk/fuel/packages/oil/classes/refine.php
r2 r6 66 66 public static function help() 67 67 { 68 echo<<<HELP68 $output = <<<HELP 69 69 70 70 Usage: 71 php oil refine<taskname>71 php oil [r|refine] <taskname> 72 72 73 73 Description: … … 78 78 php oil refine robots:protect 79 79 80 Documentation: 81 http://fuelphp.com/docs/packages/oil/refine.html 80 82 HELP; 83 \Cli::write($output); 81 84 82 85 } -
trunk/fuel/packages/oil/classes/scaffold.php
r2 r6 28 28 { 29 29 // Do this first as there is the largest chance of error here 30 //Generate::model($args);30 Generate::model($args); 31 31 32 32 // Go through all arguments after the first and make them into field arrays … … 64 64 ), 65 65 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( 66 76 'name' => 'delete', 67 77 'params' => '$id = null', … … 90 100 91 101 // Create each of the views 92 foreach (array('index', 'view', 'create', 'edit' ) as $view)102 foreach (array('index', 'view', 'create', 'edit', '_form') as $view) 93 103 { 94 104 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 1 19 $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 1 23 $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 17 17 <td><?php echo '<?php'; ?> echo $<?php echo $singular.'->'.$field['name']; ?>; <?php echo '?>'; ?></td> 18 18 <?php endforeach; ?> 19 20 19 <td><?php echo '<?php'; ?> echo HTML::anchor('<?php echo $plural; ?>/view/'.$<?php echo $singular; ?>->id, 'View'); <?php echo '?>'; ?></td> 21 20 <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> 23 22 </tr> 24 23 <?php echo '<?php endforeach; ?>'; ?>
Note: See TracChangeset
for help on using the changeset viewer.
