Skip to content
This repository
Browse code

Removing usage of up() and low() from core

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8253 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 9eaad7528fc1efb09c2420c9e77ae75cb39ed1b4 1 parent 8f61c66
Tim Koschuetzki authored July 23, 2009
2  cake/console/libs/api.php
@@ -66,7 +66,7 @@ function main() {
66 66
 			return $this->help();
67 67
 		}
68 68
 
69  
-		$type = low($this->args[0]);
  69
+		$type = strtolower($this->args[0]);
70 70
 
71 71
 		if (isset($this->paths[$type])) {
72 72
 			$path = $this->paths[$type];
14  cake/console/libs/shell.php
@@ -149,10 +149,10 @@ function __construct(&$dispatch) {
149 149
 		ClassRegistry::map($this->name, $this->alias);
150 150
 
151 151
 		if (!PHP5 && isset($this->args[0])) {
152  
-			if (strpos($this->name, low(Inflector::camelize($this->args[0]))) !== false) {
  152
+			if (strpos($this->name, strtolower(Inflector::camelize($this->args[0]))) !== false) {
153 153
 				$dispatch->shiftArgs();
154 154
 			}
155  
-			if (low($this->command) == low(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
  155
+			if (strtolower($this->command) == strtolower(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
156 156
 				$dispatch->shiftArgs();
157 157
 			}
158 158
 		}
@@ -329,7 +329,7 @@ function in($prompt, $options = null, $default = null) {
329 329
 			}
330 330
 		}
331 331
 		if (is_array($options)) {
332  
-			while ($in == '' || ($in && (!in_array(low($in), $options) && !in_array(up($in), $options)) && !in_array($in, $options))) {
  332
+			while ($in == '' || ($in && (!in_array(strtolower($in), $options) && !in_array(strtoupper($in), $options)) && !in_array($in, $options))) {
333 333
 				$in = $this->Dispatch->getInput($prompt, $options, $default);
334 334
 			}
335 335
 		}
@@ -427,10 +427,10 @@ function createFile ($path, $contents) {
427 427
 		$this->out("\n" . sprintf(__("Creating file %s", true), $path));
428 428
 		if (is_file($path) && $this->interactive === true) {
429 429
 			$key = $this->in(__("File exists, overwrite?", true). " {$path}",  array('y', 'n', 'q'), 'n');
430  
-			if (low($key) == 'q') {
  430
+			if (strtolower($key) == 'q') {
431 431
 				$this->out(__("Quitting.", true) ."\n");
432 432
 				exit;
433  
-			} elseif (low($key) != 'y') {
  433
+			} elseif (strtolower($key) != 'y') {
434 434
 				$this->out(__("Skip", true) ." {$path}\n");
435 435
 				return false;
436 436
 			}
@@ -472,7 +472,7 @@ function _checkUnitTest() {
472 472
 			return true;
473 473
 		}
474 474
 		$unitTest = $this->in('SimpleTest is not installed.  Do you want to bake unit test files anyway?', array('y','n'), 'y');
475  
-		$result = low($unitTest) == 'y' || low($unitTest) == 'yes';
  475
+		$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
476 476
 
477 477
 		if ($result) {
478 478
 			$this->out("\nYou can download SimpleTest from http://simpletest.org", true);
@@ -528,7 +528,7 @@ function getAdmin() {
528 528
  * @access protected
529 529
  */
530 530
 	function _controllerPath($name) {
531  
-		return low(Inflector::underscore($name));
  531
+		return strtolower(Inflector::underscore($name));
532 532
 	}
533 533
 /**
534 534
  * Creates the proper controller plural name for the specified controller class name
28  cake/console/libs/tasks/controller.php
@@ -120,7 +120,7 @@ function __interactive($controllerName = false) {
120 120
 		$this->out("Baking {$controllerName}Controller");
121 121
 		$this->hr();
122 122
 
123  
-		$controllerFile = low(Inflector::underscore($controllerName));
  123
+		$controllerFile = strtolower(Inflector::underscore($controllerName));
124 124
 
125 125
 		$question[] = __("Would you like to build your controller interactively?", true);
126 126
 		if (file_exists($this->path . $controllerFile .'_controller.php')) {
@@ -128,29 +128,29 @@ function __interactive($controllerName = false) {
128 128
 		}
129 129
 		$doItInteractive = $this->in(join("\n", $question), array('y','n'), 'y');
130 130
 
131  
-		if (low($doItInteractive) == 'y' || low($doItInteractive) == 'yes') {
  131
+		if (strtolower($doItInteractive) == 'y' || strtolower($doItInteractive) == 'yes') {
132 132
 			$this->interactive = true;
133 133
 
134 134
 			$wannaUseScaffold = $this->in(__("Would you like to use scaffolding?", true), array('y','n'), 'n');
135 135
 
136  
-			if (low($wannaUseScaffold) == 'n' || low($wannaUseScaffold) == 'no') {
  136
+			if (strtolower($wannaUseScaffold) == 'n' || strtolower($wannaUseScaffold) == 'no') {
137 137
 
138 138
 				$wannaDoScaffolding = $this->in(__("Would you like to include some basic class methods (index(), add(), view(), edit())?", true), array('y','n'), 'n');
139 139
 
140  
-				if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
  140
+				if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes') {
141 141
 					$wannaDoAdmin = $this->in(__("Would you like to create the methods for admin routing?", true), array('y','n'), 'n');
142 142
 				}
143 143
 
144 144
 				$wannaDoHelpers = $this->in(__("Would you like this controller to use other helpers besides HtmlHelper and FormHelper?", true), array('y','n'), 'n');
145 145
 
146  
-				if (low($wannaDoHelpers) == 'y' || low($wannaDoHelpers) == 'yes') {
  146
+				if (strtolower($wannaDoHelpers) == 'y' || strtolower($wannaDoHelpers) == 'yes') {
147 147
 					$helpersList = $this->in(__("Please provide a comma separated list of the other helper names you'd like to use.\nExample: 'Ajax, Javascript, Time'", true));
148 148
 					$helpersListTrimmed = str_replace(' ', '', $helpersList);
149 149
 					$helpers = explode(',', $helpersListTrimmed);
150 150
 				}
151 151
 				$wannaDoComponents = $this->in(__("Would you like this controller to use any components?", true), array('y','n'), 'n');
152 152
 
153  
-				if (low($wannaDoComponents) == 'y' || low($wannaDoComponents) == 'yes') {
  153
+				if (strtolower($wannaDoComponents) == 'y' || strtolower($wannaDoComponents) == 'yes') {
154 154
 					$componentsList = $this->in(__("Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'", true));
155 155
 					$componentsListTrimmed = str_replace(' ', '', $componentsList);
156 156
 					$components = explode(',', $componentsListTrimmed);
@@ -163,20 +163,20 @@ function __interactive($controllerName = false) {
163 163
 		} else {
164 164
 			$wannaDoScaffolding = $this->in(__("Would you like to include some basic class methods (index(), add(), view(), edit())?", true), array('y','n'), 'y');
165 165
 
166  
-			if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
  166
+			if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes') {
167 167
 				$wannaDoAdmin = $this->in(__("Would you like to create the methods for admin routing?", true), array('y','n'), 'y');
168 168
 			}
169 169
 		}
170 170
 		$admin = false;
171 171
 
172  
-		if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) {
  172
+		if ((strtolower($wannaDoAdmin) == 'y' || strtolower($wannaDoAdmin) == 'yes')) {
173 173
 			$admin = $this->getAdmin();
174 174
 		}
175 175
 
176  
-		if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
177  
-			$actions = $this->bakeActions($controllerName, null, in_array(low($wannaUseSession), array('y', 'yes')));
  176
+		if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes') {
  177
+			$actions = $this->bakeActions($controllerName, null, in_array(strtolower($wannaUseSession), array('y', 'yes')));
178 178
 			if ($admin) {
179  
-				$actions .= $this->bakeActions($controllerName, $admin, in_array(low($wannaUseSession), array('y', 'yes')));
  179
+				$actions .= $this->bakeActions($controllerName, $admin, in_array(strtolower($wannaUseSession), array('y', 'yes')));
180 180
 			}
181 181
 		}
182 182
 
@@ -187,7 +187,7 @@ function __interactive($controllerName = false) {
187 187
 			$this->hr();
188 188
 			$this->out("Controller Name:  $controllerName");
189 189
 
190  
-			if (low($wannaUseScaffold) == 'y' || low($wannaUseScaffold) == 'yes') {
  190
+			if (strtolower($wannaUseScaffold) == 'y' || strtolower($wannaUseScaffold) == 'yes') {
191 191
 				$this->out("		   var \$scaffold;");
192 192
 				$actions = 'scaffold';
193 193
 			}
@@ -218,7 +218,7 @@ function __interactive($controllerName = false) {
218 218
 			$this->hr();
219 219
 			$looksGood = $this->in(__('Look okay?', true), array('y','n'), 'y');
220 220
 
221  
-			if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
  221
+			if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
222 222
 				$baked = $this->bake($controllerName, $actions, $helpers, $components, $uses);
223 223
 				if ($baked && $this->_checkUnitTest()) {
224 224
 					$this->bakeTest($controllerName);
@@ -408,7 +408,7 @@ function bake($controllerName, $actions = '', $helpers = null, $components = nul
408 408
 		$out .= "class $controllerName" . "Controller extends {$this->plugin}AppController {\n\n";
409 409
 		$out .= "\tvar \$name = '$controllerName';\n";
410 410
 
411  
-		if (low($actions) == 'scaffold') {
  411
+		if (strtolower($actions) == 'scaffold') {
412 412
 			$out .= "\tvar \$scaffold;\n";
413 413
 		} else {
414 414
 			if (count($uses)) {
2  cake/console/libs/tasks/db_config.php
@@ -240,7 +240,7 @@ function __verify($config) {
240 240
 		$this->hr();
241 241
 		$looksGood = $this->in('Look okay?', array('y', 'n'), 'y');
242 242
 
243  
-		if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
  243
+		if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
244 244
 			return $config;
245 245
 		}
246 246
 		return false;
16  cake/console/libs/tasks/model.php
@@ -112,11 +112,11 @@ function __interactive() {
112 112
 			$tableIsGood = $this->in(__('Do you want to use this table?', true), array('y','n'), 'y');
113 113
 		}
114 114
 
115  
-		if (low($tableIsGood) == 'n' || low($tableIsGood) == 'no') {
  115
+		if (strtolower($tableIsGood) == 'n' || strtolower($tableIsGood) == 'no') {
116 116
 			$useTable = $this->in(__('What is the name of the table (enter "null" to use NO table)?', true));
117 117
 		}
118 118
 
119  
-		while ($tableIsGood == false && low($useTable) != 'null') {
  119
+		while ($tableIsGood == false && strtolower($useTable) != 'null') {
120 120
 			if (is_array($this->__tables) && !in_array($useTable, $this->__tables)) {
121 121
 				$fullTableName = $db->fullTableName($useTable, false);
122 122
 				$this->out($fullTableName . ' does not exist.');
@@ -144,12 +144,12 @@ function __interactive() {
144 144
 			}
145 145
 		}
146 146
 
147  
-		if (array_search($useTable, $this->__tables) !== false && (low($wannaDoValidation) == 'y' || low($wannaDoValidation) == 'yes')) {
  147
+		if (array_search($useTable, $this->__tables) !== false && (strtolower($wannaDoValidation) == 'y' || strtolower($wannaDoValidation) == 'yes')) {
148 148
 			$validate = $this->doValidation($tempModel);
149 149
 		}
150 150
 
151 151
 		$wannaDoAssoc = $this->in(__('Would you like to define model associations (hasMany, hasOne, belongsTo, etc.)?', true), array('y','n'), 'y');
152  
-		if ((low($wannaDoAssoc) == 'y' || low($wannaDoAssoc) == 'yes')) {
  152
+		if ((strtolower($wannaDoAssoc) == 'y' || strtolower($wannaDoAssoc) == 'yes')) {
153 153
 			$associations = $this->doAssociations($tempModel);
154 154
 		}
155 155
 
@@ -201,7 +201,7 @@ function __interactive() {
201 201
 		$this->hr();
202 202
 		$looksGood = $this->in(__('Look okay?', true), array('y','n'), 'y');
203 203
 
204  
-		if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
  204
+		if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
205 205
 			if ($this->bake($currentModelName, $associations, $validate, $primaryKey, $useTable, $useDbConfig)) {
206 206
 				if ($this->_checkUnitTest()) {
207 207
 					$this->bakeTest($currentModelName, $useTable, $associations);
@@ -401,7 +401,7 @@ function doAssociations(&$model, $interactive = true) {
401 401
 							$prompt = "{$model->name} {$type} {$associations[$type][$i]['alias']}";
402 402
 							$response = $this->in("{$prompt}?", array('y','n'), 'y');
403 403
 
404  
-							if ('n' == low($response) || 'no' == low($response)) {
  404
+							if ('n' == strtolower($response) || 'no' == strtolower($response)) {
405 405
 								unset($associations[$type][$i]);
406 406
 							} else {
407 407
 								if ($model->name === $associations[$type][$i]['alias']) {
@@ -414,7 +414,7 @@ function doAssociations(&$model, $interactive = true) {
414 414
 
415 415
 									$alternateAlias = $this->in(sprintf(__('This is a self join. Use %s as the alias', true), $alias), array('y', 'n'), 'y');
416 416
 
417  
-									if ('n' == low($alternateAlias) || 'no' == low($alternateAlias)) {
  417
+									if ('n' == strtolower($alternateAlias) || 'no' == strtolower($alternateAlias)) {
418 418
 										$associations[$type][$i]['alias'] = $this->in(__('Specify an alternate alias.', true));
419 419
 									} else {
420 420
 										$associations[$type][$i]['alias'] = $alias;
@@ -429,7 +429,7 @@ function doAssociations(&$model, $interactive = true) {
429 429
 
430 430
 			$wannaDoMoreAssoc = $this->in(__('Would you like to define some additional model associations?', true), array('y','n'), 'n');
431 431
 
432  
-			while ((low($wannaDoMoreAssoc) == 'y' || low($wannaDoMoreAssoc) == 'yes')) {
  432
+			while ((strtolower($wannaDoMoreAssoc) == 'y' || strtolower($wannaDoMoreAssoc) == 'yes')) {
433 433
 				$assocs = array(1 => 'belongsTo', 2 => 'hasOne', 3 => 'hasMany', 4 => 'hasAndBelongsToMany');
434 434
 				$bad = true;
435 435
 				while ($bad) {
4  cake/console/libs/tasks/plugin.php
@@ -136,7 +136,7 @@ function bake($plugin) {
136 136
 
137 137
 		$looksGood = $this->in('Look okay?', array('y', 'n', 'q'), 'y');
138 138
 
139  
-		if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
  139
+		if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
140 140
 			$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
141 141
 
142 142
 			$Folder = new Folder($this->path . $pluginPath);
@@ -146,7 +146,7 @@ function bake($plugin) {
146 146
 				$Folder->create($this->path . $pluginPath . DS . $directory);
147 147
 			}
148 148
 
149  
-			if (low($verbose) == 'y' || low($verbose) == 'yes') {
  149
+			if (strtolower($verbose) == 'y' || strtolower($verbose) == 'yes') {
150 150
 				foreach ($Folder->messages() as $message) {
151 151
 					$this->out($message);
152 152
 				}
6  cake/console/libs/tasks/project.php
@@ -144,7 +144,7 @@ function bake($path, $skel = null, $skip = array('empty')) {
144 144
 
145 145
 		$looksGood = $this->in('Look okay?', array('y', 'n', 'q'), 'y');
146 146
 
147  
-		if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
  147
+		if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
148 148
 			$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
149 149
 
150 150
 			$Folder = new Folder($skel);
@@ -157,14 +157,14 @@ function bake($path, $skel = null, $skip = array('empty')) {
157 157
 				return false;
158 158
 			}
159 159
 
160  
-			if (low($verbose) == 'y' || low($verbose) == 'yes') {
  160
+			if (strtolower($verbose) == 'y' || strtolower($verbose) == 'yes') {
161 161
 				foreach ($Folder->messages() as $message) {
162 162
 					$this->out($message);
163 163
 				}
164 164
 			}
165 165
 
166 166
 			return true;
167  
-		} elseif (low($looksGood) == 'q' || low($looksGood) == 'quit') {
  167
+		} elseif (strtolower($looksGood) == 'q' || strtolower($looksGood) == 'quit') {
168 168
 			$this->out('Bake Aborted.');
169 169
 		} else {
170 170
 			$this->execute(false);
12  cake/console/libs/tasks/view.php
@@ -161,25 +161,25 @@ function __interactive() {
161 161
 
162 162
 		$this->controllerName = $this->Controller->getName();
163 163
 
164  
-		$this->controllerPath = low(Inflector::underscore($this->controllerName));
  164
+		$this->controllerPath = strtolower(Inflector::underscore($this->controllerName));
165 165
 
166 166
 		$interactive = $this->in("Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite {$this->controllerName} views if it exist.", array('y','n'), 'y');
167 167
 
168  
-		if (low($interactive) == 'y' || low($interactive) == 'yes') {
  168
+		if (strtolower($interactive) == 'y' || strtolower($interactive) == 'yes') {
169 169
 			$this->interactive = true;
170 170
 			$wannaDoScaffold = $this->in("Would you like to create some scaffolded views (index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller and model classes (including associated models).", array('y','n'), 'n');
171 171
 		}
172 172
 
173  
-		if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') {
  173
+		if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoScaffold) == 'yes') {
174 174
 			$wannaDoAdmin = $this->in("Would you like to create the views for admin routing?", array('y','n'), 'y');
175 175
 		}
176 176
 		$admin = false;
177 177
 
178  
-		if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) {
  178
+		if ((strtolower($wannaDoAdmin) == 'y' || strtolower($wannaDoAdmin) == 'yes')) {
179 179
 			$admin = $this->getAdmin();
180 180
 		}
181 181
 
182  
-		if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') {
  182
+		if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoScaffold) == 'yes') {
183 183
 			$actions = $this->scaffoldActions;
184 184
 			if ($admin) {
185 185
 				foreach ($actions as $action) {
@@ -213,7 +213,7 @@ function __interactive() {
213 213
 			$this->out("Path:			 ".$this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp");
214 214
 			$this->hr();
215 215
 			$looksGood = $this->in('Look okay?', array('y','n'), 'y');
216  
-			if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
  216
+			if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
217 217
 				$this->bake($action);
218 218
 				$this->_stop();
219 219
 			} else {

0 notes on commit 9eaad75

Please sign in to comment.
Something went wrong with that request. Please try again.