Changeset 8 in ExiteCMS8
- Timestamp:
- 01/10/11 00:17:02 (17 months ago)
- Location:
- trunk/fuel
- Files:
-
- 8 edited
-
core/classes/file.php (modified) (1 diff)
-
core/classes/request.php (modified) (1 diff)
-
core/classes/validation.php (modified) (11 diffs)
-
packages/activerecord/classes/model.php (modified) (2 diffs)
-
packages/oil/classes/generate.php (modified) (3 diffs)
-
packages/oil/classes/package.php (modified) (1 diff)
-
packages/oil/views/scaffold/actions/create.php (modified) (2 diffs)
-
packages/oil/views/scaffold/actions/edit.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fuel/core/classes/file.php
r2 r8 381 381 if ( ! is_file($path)) 382 382 { 383 echo $path.PHP_EOL;384 383 throw new \Exception('Cannot delete file: given path "'.$path.'" is not a file.'); 385 384 } -
trunk/fuel/core/classes/request.php
r2 r8 151 151 return $controller->output; 152 152 } 153 154 \Output::send_headers(); 153 155 exit($controller->output); 154 156 } -
trunk/fuel/core/classes/validation.php
r2 r8 419 419 { 420 420 // first try direct match 421 if ( $val === $compare || ( ! $strict && $val == $compare))421 if (empty($val) || $val === $compare || ( ! $strict && $val == $compare)) 422 422 { 423 423 return true; … … 449 449 public function _validation_match_pattern($val, $pattern) 450 450 { 451 return preg_match($pattern, $val) > 0;451 return empty($val) || preg_match($pattern, $val) > 0; 452 452 } 453 453 … … 462 462 public function _validation_match_field($val, $field) 463 463 { 464 return $this->input($field) === $val;464 return empty($val) || $this->input($field) === $val; 465 465 } 466 466 … … 474 474 public function _validation_min_length($val, $length) 475 475 { 476 return (MBSTRING ? mb_strlen($val) : strlen($val)) >= $length;476 return empty($val) || (MBSTRING ? mb_strlen($val) : strlen($val)) >= $length; 477 477 } 478 478 … … 486 486 public function _validation_max_length($val, $length) 487 487 { 488 return (MBSTRING ? mb_strlen($val) : strlen($val)) <= $length;488 return empty($val) || (MBSTRING ? mb_strlen($val) : strlen($val)) <= $length; 489 489 } 490 490 … … 498 498 public function _validation_exact_length($val, $length) 499 499 { 500 return (MBSTRING ? mb_strlen($val) : strlen($val)) == $length;500 return empty($val) || (MBSTRING ? mb_strlen($val) : strlen($val)) == $length; 501 501 } 502 502 … … 568 568 public function _validation_valid_string($val, $flags = array('alpha', 'utf8')) 569 569 { 570 if (empty($val)) 571 { 572 return true; 573 } 574 570 575 if ( ! is_array($flags)) 571 576 { … … 600 605 } 601 606 602 $pattern = '/^(['; 603 $pattern .= ! in_array('uppercase', $flags) && in_array('alpha', $flags) ? 'a-z' : ''; 607 $pattern = ! in_array('uppercase', $flags) && in_array('alpha', $flags) ? 'a-z' : ''; 604 608 $pattern .= ! in_array('lowercase', $flags) && in_array('alpha', $flags) ? 'A-Z' : ''; 605 609 $pattern .= in_array('numeric', $flags) ? '0-9' : ''; … … 610 614 $pattern .= in_array('punctuation', $flags) ? "\.,\!\?:;" : ''; 611 615 $pattern .= in_array('dashes', $flags) ? '_\-' : ''; 612 $pattern .= '])+$/';616 $pattern = empty($pattern) ? '/^(.*)$/' : ('/^(['.$pattern.'])+$/'); 613 617 $pattern .= in_array('utf8', $flags) ? 'u' : ''; 614 618 … … 625 629 public function _validation_numeric_min($val, $min_val) 626 630 { 627 return floatval($val) >= floatval($min_val);631 return empty($val) || floatval($val) >= floatval($min_val); 628 632 } 629 633 … … 637 641 public function _validation_numeric_max($val, $max_val) 638 642 { 639 return floatval($val) <= floatval($max_val);643 return empty($val) || floatval($val) <= floatval($max_val); 640 644 } 641 645 } -
trunk/fuel/packages/activerecord/classes/model.php
r6 r8 410 410 $this->associations[$assoc_name]->set_ids($value, $this); 411 411 } 412 else 413 { 414 throw new \Exception("attribute called '$name' doesn't exist", Exception::AttributeNotFound); 415 } 412 416 } 413 417 … … 667 671 foreach ($this->columns as $column) 668 672 { 669 if ($column == $this->primary_key OR ! in_array($column, $this->columns))673 if ($column == $this->primary_key) 670 674 { 671 675 continue; -
trunk/fuel/packages/oil/classes/generate.php
r6 r8 76 76 if (self::write($filepath, $controller)) 77 77 { 78 \Cli::write( 'Created controller: ' . $filepath);78 \Cli::write("\t".'Created controller: ' . \Fuel::clean_path($filepath)); 79 79 } 80 80 } … … 106 106 if (self::write($filepath, $model)) 107 107 { 108 \Cli::write( 'Created model: ' . \Fuel::clean_path($filepath));108 \Cli::write("\t".'Created model: ' . \Fuel::clean_path($filepath)); 109 109 } 110 110 … … 151 151 if (self::write($view_file, $view)) 152 152 { 153 \Cli::write("\t Created view: " . $view_file);153 \Cli::write("\t".'Created view: ' . \Fuel::clean_path($view_file)); 154 154 } 155 155 } -
trunk/fuel/packages/oil/classes/package.php
r6 r8 98 98 } 99 99 100 \Cli::write(' Uninstalling package "' . $package . '"', 'yellow');100 \Cli::write('Package "' . $package . '" was uninstalled.', 'yellow'); 101 101 102 102 \File::delete_dir($package_folder); -
trunk/fuel/packages/oil/views/scaffold/actions/create.php
r6 r8 1 1 if ($_POST) 2 2 { 3 $<?php echo $singular; ?> = <?php echo $model; ?>::factory($_POST); 3 $<?php echo $singular; ?> = <?php echo $model; ?>::factory(array( 4 <?php foreach ($fields as $field): ?> 5 '<?php echo $field['name']; ?>' => Input::post('<?php echo $field['name']; ?>'), 6 <?php endforeach; ?> 7 )); 4 8 5 9 if ($<?php echo $singular; ?> and $<?php echo $singular; ?>->save()) 6 10 { 7 Session::set_flash('notice', 'Added ' . $<?php echo $singular; ?> . ' #' . $<?php echo $singular; ?>->id );11 Session::set_flash('notice', 'Added ' . $<?php echo $singular; ?> . ' #' . $<?php echo $singular; ?>->id . '.'); 8 12 9 13 Output::redirect('<?php echo $plural; ?>'); … … 12 16 else 13 17 { 14 Session::set_flash('notice', 'Could not save ' . $<?php echo $singular; ?> . ' #' . $id);18 Session::set_flash('notice', 'Could not save <?php echo $singular; ?>.'); 15 19 } 16 17 20 } 18 21 -
trunk/fuel/packages/oil/views/scaffold/actions/edit.php
r6 r8 3 3 if ($_POST) 4 4 { 5 if ($<?php echo $singular; ?>->update($_POST)) 5 <?php foreach ($fields as $field): ?> 6 $<?php echo $singular; ?>-><?php echo $field['name']; ?> = Input::post('<?php echo $field['name']; ?>'); 7 <?php endforeach; ?> 8 9 if ($<?php echo $singular; ?>->save()) 6 10 { 7 11 Session::set_flash('notice', 'Updated ' . $<?php echo $singular; ?> . ' #' . $<?php echo $singular; ?>->id);
Note: See TracChangeset
for help on using the changeset viewer.
