Changeset 59 in ExiteCMS8
- Timestamp:
- 07/11/11 14:22:53 (11 months ago)
- Location:
- trunk/fuel
- Files:
-
- 32 edited
-
core/classes/arr.php (modified) (1 diff)
-
core/classes/asset.php (modified) (1 diff)
-
core/classes/config.php (modified) (2 diffs)
-
core/classes/controller/rest.php (modified) (3 diffs)
-
core/classes/database/query/builder/update.php (modified) (3 diffs)
-
core/classes/email.php (modified) (1 diff)
-
core/classes/fieldset/field.php (modified) (2 diffs)
-
core/classes/form.php (modified) (1 diff)
-
core/classes/format.php (modified) (1 diff)
-
core/classes/pagination.php (modified) (6 diffs)
-
core/classes/security.php (modified) (3 diffs)
-
core/classes/str.php (modified) (1 diff)
-
core/classes/upload.php (modified) (1 diff)
-
core/classes/uri.php (modified) (2 diffs)
-
core/classes/validation.php (modified) (1 diff)
-
core/classes/validation/error.php (modified) (4 diffs)
-
core/classes/viewmodel.php (modified) (1 diff)
-
core/tests/arr.php (modified) (1 diff)
-
core/tests/uri.php (modified) (3 diffs)
-
core/vendor/htmlawed/htmlawed.php (modified) (6 diffs)
-
packages/oil/classes/generate.php (modified) (5 diffs)
-
packages/oil/classes/scaffold.php (modified) (3 diffs)
-
packages/oil/views/default/scaffold/actions/create.php (modified) (2 diffs)
-
packages/oil/views/default/scaffold/actions/delete.php (modified) (1 diff)
-
packages/oil/views/default/scaffold/actions/edit.php (modified) (2 diffs)
-
packages/oil/views/default/scaffold/actions/index.php (modified) (1 diff)
-
packages/oil/views/default/scaffold/actions/view.php (modified) (1 diff)
-
packages/oil/views/default/scaffold/controller.php (modified) (2 diffs)
-
packages/oil/views/default/scaffold/views/create.php (modified) (1 diff)
-
packages/oil/views/default/scaffold/views/edit.php (modified) (1 diff)
-
packages/oil/views/default/scaffold/views/index.php (modified) (3 diffs)
-
packages/oil/views/default/scaffold/views/view.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fuel/core/classes/arr.php
r53 r59 23 23 24 24 /** 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 /** 25 52 * Flattens a multi-dimensional associative array down into a 1 dimensional 26 53 * associative array. -
trunk/fuel/core/classes/asset.php
r53 r59 154 154 } 155 155 156 $ file = static::$_asset_url.$file.(static::$_add_mtime ? '?'.filemtime($file) : '');156 $raw or $file = static::$_asset_url.$file.(static::$_add_mtime ? '?'.filemtime($file) : ''); 157 157 } 158 158 else -
trunk/fuel/core/classes/config.php
r53 r59 38 38 foreach ($paths as $path) 39 39 { 40 $config = \Fuel::load($path) + $config; 41 } 42 } 40 $config = array_merge($config, \Fuel::load($path)); 41 } 42 } 43 43 44 if ($group === null) 44 45 { … … 52 53 static::$items[$group] = array(); 53 54 } 54 static::$items[$group] = static::$items[$group] + $config;55 static::$items[$group] = array_merge(static::$items[$group],$config); 55 56 } 56 57 -
trunk/fuel/core/classes/controller/rest.php
r54 r59 14 14 */ 15 15 protected $methods = array(); 16 17 /** 18 * @var string the detected response format 19 */ 20 protected $format = null; 16 21 17 22 /** … … 69 74 $resource = preg_replace($pattern, '', $resource); 70 75 71 $this-> request->format = $matches[1];76 $this->format = $matches[1]; 72 77 } 73 78 else 74 79 { 75 80 // Which format should the data be returned in? 76 $this-> request->format = $this->_detect_format();81 $this->format = $this->_detect_format(); 77 82 } 78 83 … … 111 116 112 117 // 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)) 114 119 { 115 120 // 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}()); 119 124 } 120 125 -
trunk/fuel/core/classes/database/query/builder/update.php
r53 r59 19 19 // SET ... 20 20 protected $_set = array(); 21 22 // JOIN ... 23 protected $_join = array(); 21 24 22 25 /** … … 92 95 $query = 'UPDATE '.$db->quote_table($this->_table); 93 96 97 if ( ! empty($this->_join)) 98 { 99 // Add tables to join 100 $query .= ' '.$this->_compile_join($db, $this->_join); 101 } 102 94 103 // Add the columns to update 95 104 $query .= ' SET '.$this->_compile_set($db, $this->_set); … … 124 133 } 125 134 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 } 126 163 127 164 } // End Database_Query_Builder_Update -
trunk/fuel/core/classes/email.php
r53 r59 39 39 public static function factory($config = array()) 40 40 { 41 $initconfig = Config::load('email' );41 $initconfig = Config::load('email', null, true); 42 42 43 43 if (is_array($config) && is_array($initconfig)) -
trunk/fuel/core/classes/fieldset/field.php
r53 r59 203 203 { 204 204 $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; 206 207 } 207 208 } … … 212 213 { 213 214 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))) 214 233 { 215 234 $this->rules[] = array($callback, $args); -
trunk/fuel/core/classes/form.php
r57 r59 761 761 if (is_array($build_field)) 762 762 { 763 $label = $field->label ? static::label($field->label) : ''; 763 764 $template = $field->template ?: $this->get_config('multi_field_template', '\t\t\t{group_label}\n {fields}\t\t\t{label} {field}{fields}'); 764 765 if ($template && preg_match('#\{fields\}(.*)\{fields\}#Dus', $template, $match) > 0) -
trunk/fuel/core/classes/format.php
r53 r59 150 150 { 151 151 $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 } 155 158 } 156 159 -
trunk/fuel/core/classes/pagination.php
r57 r59 35 35 */ 36 36 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' => '« ', 49 'next_start' => '<span class="next"> ', 50 'next_end' => ' </span>', 51 'next_mark' => ' »', 52 'active_start' => '<span class="active"> ', 53 'active_end' => ' </span>', 54 ); 37 55 38 56 /** … … 87 105 foreach ($config as $key => $value) 88 106 { 107 if ($key == 'template') 108 { 109 static::$template = array_merge(static::$template, $config['template']); 110 continue; 111 } 112 89 113 static::${$key} = $value; 90 114 } … … 137 161 \Lang::load('pagination', true); 138 162 139 $pagination = '';140 $pagination .= ' '.static::prev_link('« '.\Lang::line('pagination.previous')).' ';163 $pagination = static::$template['wrapper_start']; 164 $pagination .= static::prev_link(\Lang::line('pagination.previous')); 141 165 $pagination .= static::page_links(); 142 $pagination .= ' '.static::next_link(\Lang::line('pagination.next').' »'); 166 $pagination .= static::next_link(\Lang::line('pagination.next')); 167 $pagination .= static::$template['wrapper_end']; 143 168 144 169 return $pagination; … … 172 197 if (static::$current_page == $i) 173 198 { 174 $pagination .= '<b>'.$i.'</b>';199 $pagination .= static::$template['active_start'].$i.static::$template['active_end']; 175 200 } 176 201 else 177 202 { 178 203 $url = ($i == 1) ? '' : '/'.$i; 179 $pagination .= \Html::anchor(rtrim(static::$pagination_url, '/') .$url, $i);204 $pagination .= \Html::anchor(rtrim(static::$pagination_url, '/').$url, $i); 180 205 } 181 206 } 182 207 183 return $pagination;208 return static::$template['page_start'].$pagination.static::$template['page_end']; 184 209 } 185 210 … … 202 227 if (static::$current_page == static::$total_pages) 203 228 { 204 return $value ;229 return $value.static::$template['next_mark']; 205 230 } 206 231 else 207 232 { 208 233 $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']); 210 235 } 211 236 } … … 229 254 if (static::$current_page == 1) 230 255 { 231 return $value;256 return static::$template['previous_mark'].$value; 232 257 } 233 258 else 234 259 { 235 260 $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); 238 263 } 239 264 } -
trunk/fuel/core/classes/security.php
r53 r59 165 165 public static function htmlentities($value) 166 166 { 167 static $already_cleaned = array(); 168 169 // Prevent looping & encoding twice 170 if (in_array($value, $already_cleaned)) 171 { 172 return $value; 173 } 174 167 175 if (is_string($value)) 168 176 { … … 175 183 $value[$k] = static::htmlentities($v); 176 184 } 185 186 // Add to $already_cleaned variable when object 187 is_object($value) and $already_cleaned[] = $value; 177 188 } 178 189 elseif (is_object($value)) … … 183 194 if (is_a($value, $class)) 184 195 { 196 // Add to $already_cleaned variable 197 $already_cleaned[] = $value; 198 185 199 return $value; 186 200 } -
trunk/fuel/core/classes/str.php
r57 r59 68 68 * @return string 69 69 */ 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; 75 75 } 76 76 -
trunk/fuel/core/classes/upload.php
r57 r59 419 419 elseif(is_numeric($param)) 420 420 { 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]; 424 424 } 425 425 } -
trunk/fuel/core/classes/uri.php
r53 r59 104 104 } 105 105 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 106 110 // Do some final clean up of the uri 107 111 static::$detected_uri = str_replace(array('//', '../'), '/', $uri); … … 150 154 public static function create($uri = null, $variables = array(), $get_variables = array()) 151 155 { 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 } 157 166 } 158 167 159 168 $url = $url.ltrim(is_null($uri) ? static::string() : $uri, '/'); 169 170 substr($url, -1) != '/' and $url .= \Config::get('url_suffix'); 160 171 161 172 if ( ! empty($get_variables)) -
trunk/fuel/core/classes/validation.php
r57 r59 300 300 protected function _run_rule($rule, &$value, $params, $field) 301 301 { 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)); 303 303 304 304 if ($output === false && $value !== false) -
trunk/fuel/core/classes/validation/error.php
r54 r59 36 36 public $field = ''; 37 37 public $value = ''; 38 public $ callback= '';38 public $rule = ''; 39 39 public $params = array(); 40 40 … … 49 49 public function __construct($field, $value, $callback, $params) 50 50 { 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); 74 55 } 75 56 … … 84 65 * @return string 85 66 */ 86 public function get_message($msg = false, $open = null, $close = null)67 public function get_message($msg = false, $open = '', $close = '') 87 68 { 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); 90 71 91 72 if ($msg === false) 92 73 { 93 $msg = $this->field->fieldset()->validation()->get_message($this-> callback);74 $msg = $this->field->fieldset()->validation()->get_message($this->rule); 94 75 $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)) 96 77 : $msg; 97 78 } 98 79 if ($msg == false) 99 80 { 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; 101 82 } 102 83 … … 107 88 } 108 89 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 } 109 96 $value = is_array($this->value) ? implode(', ', $this->value) : $this->value; 110 97 $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); 118 99 foreach($this->params as $key => $val) 119 100 { -
trunk/fuel/core/classes/viewmodel.php
r53 r59 42 42 if ( ! class_exists($class = $viewmodel)) 43 43 { 44 throw new \OutOfBoundsException('ViewModel could not be found.');44 throw new \OutOfBoundsException('ViewModel "View_'.ucfirst(str_replace(DS, '_', $viewmodel)).'" could not be found.'); 45 45 } 46 46 } -
trunk/fuel/core/tests/arr.php
r57 r59 38 38 ); 39 39 } 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 } 40 74 41 75 /** -
trunk/fuel/core/tests/uri.php
r57 r59 15 15 /** 16 16 * Html class tests 17 * 17 * 18 18 * @group Core 19 19 * @group Uri … … 23 23 /** 24 24 * Tests Uri::create() 25 * 25 * 26 26 * @test 27 27 */ … … 37 37 $expected = $prefix."controller/thing?what=more"; 38 38 $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 39 54 } 40 55 -
trunk/fuel/core/vendor/htmlawed/htmlawed.php
r53 r59 2 2 3 3 /* 4 htmLawed 1.1.9. 4, 3 July 20104 htmLawed 1.1.9.5, 6 July 2011 5 5 Copyright Santosh Patnaik 6 6 LGPL v3 license … … 150 150 $cN2 = array_keys($cN); 151 151 $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-child152 $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 153 153 $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 154 154 $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 … … 208 208 if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open 209 209 $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;){ 211 211 if(($d = array_pop($q)) == $e){break;} 212 212 else{$add .= "</{$d}>";} … … 375 375 // final $spec 376 376 $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))); 378 378 for($i = count(($t = explode(';', $t))); --$i>=0;){ 379 379 $w = $t[$i]; … … 659 659 $x = $e[0] == '/' ? 0 : (substr($e, -1) == '/' ? 1 : ($e[0] != '!' ? 2 : -1)); 660 660 $y = !$x ? ltrim($e, '/') : ($x > 0 ? substr($e, 0, strcspn($e, ' ')) : 0); 661 $e = "<$e>"; 661 $e = "<$e>"; 662 662 if(isset($d[$y])){ 663 663 if(!$x){echo "\n", str_repeat($s, --$n), "$e\n", str_repeat($s, $n);} … … 685 685 function hl_version(){ 686 686 // rel 687 return '1.1.9. 4';687 return '1.1.9.5'; 688 688 // eof 689 689 } -
trunk/fuel/packages/oil/classes/generate.php
r56 r59 55 55 static::views($args, false); 56 56 57 $actions or $actions = array('index');57 $actions or $actions = array('index'); 58 58 59 59 $action_str = ''; … … 68 68 } 69 69 70 $extends = \Cli::option('extends', 'Controller_Template'); 71 70 72 // Build Controller 71 73 $controller = <<<CONTROLLER 72 74 <?php 73 75 74 class Controller_{$class_name} extends Controller_Template{76 class Controller_{$class_name} extends {$extends} { 75 77 {$action_str} 76 78 } … … 81 83 // Write controller 82 84 static::create($filepath, $controller, 'controller'); 85 83 86 $build and static::build(); 84 87 } … … 87 90 public static function model($args, $build = true) 88 91 { 89 $singular = strtolower(array_shift($args));92 $singular = \Str::lower(array_shift($args)); 90 93 91 94 if (empty($args)) … … 179 182 { 180 183 // Get the migration name 181 $migration_name = strtolower(str_replace('-', '_', array_shift($args)));184 $migration_name = \Str::lower(str_replace(array('-', '/'), '_', array_shift($args))); 182 185 183 186 // Check if a migration with this name already exists -
trunk/fuel/packages/oil/classes/scaffold.php
r51 r59 47 47 48 48 $fields[] = array( 49 'name' => strtolower($matches[1]),49 'name' => \Str::lower($matches[1]), 50 50 'type' => isset($matches[2]) ? $matches[2] : 'string', 51 51 'constraint' => isset($matches[4]) ? $matches[4] : null … … 53 53 } 54 54 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); 57 65 $data['plural'] = $plural = \Inflector::pluralize($singular); 58 66 $data['fields'] = $fields; 59 67 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'; 61 69 $controller = \View::factory($subfolder.'/scaffold/controller', $data); 62 70 … … 95 103 foreach (array('index', 'view', 'create', 'edit', '_form') as $view) 96 104 { 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'); 98 106 } 99 107 -
trunk/fuel/packages/oil/views/default/scaffold/actions/create.php
r44 r59 11 11 Session::set_flash('notice', 'Added <?php echo $singular; ?> #' . $<?php echo $singular; ?>->id . '.'); 12 12 13 Response::redirect('<?php echo $ plural; ?>');13 Response::redirect('<?php echo $controller_uri; ?>'); 14 14 } 15 15 … … 20 20 } 21 21 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 11 11 } 12 12 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 11 11 Session::set_flash('notice', 'Updated <?php echo $singular; ?> #' . $id); 12 12 13 Response::redirect('<?php echo $ plural; ?>');13 Response::redirect('<?php echo $controller_uri; ?>'); 14 14 } 15 15 … … 26 26 27 27 $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'); 2 2 $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); 2 2 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 1 1 <?php echo '<?php' ?> 2 2 3 class Controller_<?php echo ucfirst($plural); ?> extends Controller_Template{3 class <?php echo $controller; ?> extends <?php echo \Cli::option('extends', 'Controller_Template') ?> { 4 4 5 5 <?php foreach ($actions as $action): ?> … … 13 13 } 14 14 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> 2 2 3 <?php echo '<?php'; ?> echo render('<?php echo $ plural;?>/_form'); ?>3 <?php echo '<?php'; ?> echo render('<?php echo $controller_uri ?>/_form'); ?> 4 4 <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> 2 2 3 <?php echo '<?php'; ?> echo render('<?php echo $ plural; ?>/_form'); ?>3 <?php echo '<?php'; ?> echo render('<?php echo $controller_uri; ?>/_form'); ?> 4 4 <br /> 5 5 <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 '?>'; ?> 8 8 </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> 2 2 3 3 <table cellspacing="0"> … … 16 16 <?php endforeach; ?> 17 17 <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 '?>'; ?> 21 21 </td> 22 22 </tr> … … 26 26 <br /> 27 27 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 6 6 <?php endforeach; ?> 7 7 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.
