Skip to content

Commit

Permalink
Removing usage of up() and low() from core
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8253 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
DarkAngelBGE committed Jul 23, 2009
1 parent 8f61c66 commit 9eaad75
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion cake/console/libs/api.php
Expand Up @@ -66,7 +66,7 @@ function main() {
return $this->help();
}

$type = low($this->args[0]);
$type = strtolower($this->args[0]);

if (isset($this->paths[$type])) {
$path = $this->paths[$type];
Expand Down
14 changes: 7 additions & 7 deletions cake/console/libs/shell.php
Expand Up @@ -149,10 +149,10 @@ function __construct(&$dispatch) {
ClassRegistry::map($this->name, $this->alias);

if (!PHP5 && isset($this->args[0])) {
if (strpos($this->name, low(Inflector::camelize($this->args[0]))) !== false) {
if (strpos($this->name, strtolower(Inflector::camelize($this->args[0]))) !== false) {
$dispatch->shiftArgs();
}
if (low($this->command) == low(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
if (strtolower($this->command) == strtolower(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
$dispatch->shiftArgs();
}
}
Expand Down Expand Up @@ -329,7 +329,7 @@ function in($prompt, $options = null, $default = null) {
}
}
if (is_array($options)) {
while ($in == '' || ($in && (!in_array(low($in), $options) && !in_array(up($in), $options)) && !in_array($in, $options))) {
while ($in == '' || ($in && (!in_array(strtolower($in), $options) && !in_array(strtoupper($in), $options)) && !in_array($in, $options))) {
$in = $this->Dispatch->getInput($prompt, $options, $default);
}
}
Expand Down Expand Up @@ -427,10 +427,10 @@ function createFile ($path, $contents) {
$this->out("\n" . sprintf(__("Creating file %s", true), $path));
if (is_file($path) && $this->interactive === true) {
$key = $this->in(__("File exists, overwrite?", true). " {$path}", array('y', 'n', 'q'), 'n');
if (low($key) == 'q') {
if (strtolower($key) == 'q') {
$this->out(__("Quitting.", true) ."\n");
exit;
} elseif (low($key) != 'y') {
} elseif (strtolower($key) != 'y') {
$this->out(__("Skip", true) ." {$path}\n");
return false;
}
Expand Down Expand Up @@ -472,7 +472,7 @@ function _checkUnitTest() {
return true;
}
$unitTest = $this->in('SimpleTest is not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
$result = low($unitTest) == 'y' || low($unitTest) == 'yes';
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';

if ($result) {
$this->out("\nYou can download SimpleTest from http://simpletest.org", true);
Expand Down Expand Up @@ -528,7 +528,7 @@ function getAdmin() {
* @access protected
*/
function _controllerPath($name) {
return low(Inflector::underscore($name));
return strtolower(Inflector::underscore($name));
}
/**
* Creates the proper controller plural name for the specified controller class name
Expand Down
28 changes: 14 additions & 14 deletions cake/console/libs/tasks/controller.php
Expand Up @@ -120,37 +120,37 @@ function __interactive($controllerName = false) {
$this->out("Baking {$controllerName}Controller");
$this->hr();

$controllerFile = low(Inflector::underscore($controllerName));
$controllerFile = strtolower(Inflector::underscore($controllerName));

$question[] = __("Would you like to build your controller interactively?", true);
if (file_exists($this->path . $controllerFile .'_controller.php')) {
$question[] = sprintf(__("Warning: Choosing no will overwrite the %sController.", true), $controllerName);
}
$doItInteractive = $this->in(join("\n", $question), array('y','n'), 'y');

if (low($doItInteractive) == 'y' || low($doItInteractive) == 'yes') {
if (strtolower($doItInteractive) == 'y' || strtolower($doItInteractive) == 'yes') {
$this->interactive = true;

$wannaUseScaffold = $this->in(__("Would you like to use scaffolding?", true), array('y','n'), 'n');

if (low($wannaUseScaffold) == 'n' || low($wannaUseScaffold) == 'no') {
if (strtolower($wannaUseScaffold) == 'n' || strtolower($wannaUseScaffold) == 'no') {

$wannaDoScaffolding = $this->in(__("Would you like to include some basic class methods (index(), add(), view(), edit())?", true), array('y','n'), 'n');

if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes') {
$wannaDoAdmin = $this->in(__("Would you like to create the methods for admin routing?", true), array('y','n'), 'n');
}

$wannaDoHelpers = $this->in(__("Would you like this controller to use other helpers besides HtmlHelper and FormHelper?", true), array('y','n'), 'n');

if (low($wannaDoHelpers) == 'y' || low($wannaDoHelpers) == 'yes') {
if (strtolower($wannaDoHelpers) == 'y' || strtolower($wannaDoHelpers) == 'yes') {
$helpersList = $this->in(__("Please provide a comma separated list of the other helper names you'd like to use.\nExample: 'Ajax, Javascript, Time'", true));
$helpersListTrimmed = str_replace(' ', '', $helpersList);
$helpers = explode(',', $helpersListTrimmed);
}
$wannaDoComponents = $this->in(__("Would you like this controller to use any components?", true), array('y','n'), 'n');

if (low($wannaDoComponents) == 'y' || low($wannaDoComponents) == 'yes') {
if (strtolower($wannaDoComponents) == 'y' || strtolower($wannaDoComponents) == 'yes') {
$componentsList = $this->in(__("Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'", true));
$componentsListTrimmed = str_replace(' ', '', $componentsList);
$components = explode(',', $componentsListTrimmed);
Expand All @@ -163,20 +163,20 @@ function __interactive($controllerName = false) {
} else {
$wannaDoScaffolding = $this->in(__("Would you like to include some basic class methods (index(), add(), view(), edit())?", true), array('y','n'), 'y');

if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes') {
$wannaDoAdmin = $this->in(__("Would you like to create the methods for admin routing?", true), array('y','n'), 'y');
}
}
$admin = false;

if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) {
if ((strtolower($wannaDoAdmin) == 'y' || strtolower($wannaDoAdmin) == 'yes')) {
$admin = $this->getAdmin();
}

if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
$actions = $this->bakeActions($controllerName, null, in_array(low($wannaUseSession), array('y', 'yes')));
if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes') {
$actions = $this->bakeActions($controllerName, null, in_array(strtolower($wannaUseSession), array('y', 'yes')));
if ($admin) {
$actions .= $this->bakeActions($controllerName, $admin, in_array(low($wannaUseSession), array('y', 'yes')));
$actions .= $this->bakeActions($controllerName, $admin, in_array(strtolower($wannaUseSession), array('y', 'yes')));
}
}

Expand All @@ -187,7 +187,7 @@ function __interactive($controllerName = false) {
$this->hr();
$this->out("Controller Name: $controllerName");

if (low($wannaUseScaffold) == 'y' || low($wannaUseScaffold) == 'yes') {
if (strtolower($wannaUseScaffold) == 'y' || strtolower($wannaUseScaffold) == 'yes') {
$this->out(" var \$scaffold;");
$actions = 'scaffold';
}
Expand Down Expand Up @@ -218,7 +218,7 @@ function __interactive($controllerName = false) {
$this->hr();
$looksGood = $this->in(__('Look okay?', true), array('y','n'), 'y');

if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
$baked = $this->bake($controllerName, $actions, $helpers, $components, $uses);
if ($baked && $this->_checkUnitTest()) {
$this->bakeTest($controllerName);
Expand Down Expand Up @@ -408,7 +408,7 @@ function bake($controllerName, $actions = '', $helpers = null, $components = nul
$out .= "class $controllerName" . "Controller extends {$this->plugin}AppController {\n\n";
$out .= "\tvar \$name = '$controllerName';\n";

if (low($actions) == 'scaffold') {
if (strtolower($actions) == 'scaffold') {
$out .= "\tvar \$scaffold;\n";
} else {
if (count($uses)) {
Expand Down
2 changes: 1 addition & 1 deletion cake/console/libs/tasks/db_config.php
Expand Up @@ -240,7 +240,7 @@ function __verify($config) {
$this->hr();
$looksGood = $this->in('Look okay?', array('y', 'n'), 'y');

if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
return $config;
}
return false;
Expand Down
16 changes: 8 additions & 8 deletions cake/console/libs/tasks/model.php
Expand Up @@ -112,11 +112,11 @@ function __interactive() {
$tableIsGood = $this->in(__('Do you want to use this table?', true), array('y','n'), 'y');
}

if (low($tableIsGood) == 'n' || low($tableIsGood) == 'no') {
if (strtolower($tableIsGood) == 'n' || strtolower($tableIsGood) == 'no') {
$useTable = $this->in(__('What is the name of the table (enter "null" to use NO table)?', true));
}

while ($tableIsGood == false && low($useTable) != 'null') {
while ($tableIsGood == false && strtolower($useTable) != 'null') {
if (is_array($this->__tables) && !in_array($useTable, $this->__tables)) {
$fullTableName = $db->fullTableName($useTable, false);
$this->out($fullTableName . ' does not exist.');
Expand Down Expand Up @@ -144,12 +144,12 @@ function __interactive() {
}
}

if (array_search($useTable, $this->__tables) !== false && (low($wannaDoValidation) == 'y' || low($wannaDoValidation) == 'yes')) {
if (array_search($useTable, $this->__tables) !== false && (strtolower($wannaDoValidation) == 'y' || strtolower($wannaDoValidation) == 'yes')) {
$validate = $this->doValidation($tempModel);
}

$wannaDoAssoc = $this->in(__('Would you like to define model associations (hasMany, hasOne, belongsTo, etc.)?', true), array('y','n'), 'y');
if ((low($wannaDoAssoc) == 'y' || low($wannaDoAssoc) == 'yes')) {
if ((strtolower($wannaDoAssoc) == 'y' || strtolower($wannaDoAssoc) == 'yes')) {
$associations = $this->doAssociations($tempModel);
}

Expand Down Expand Up @@ -201,7 +201,7 @@ function __interactive() {
$this->hr();
$looksGood = $this->in(__('Look okay?', true), array('y','n'), 'y');

if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
if ($this->bake($currentModelName, $associations, $validate, $primaryKey, $useTable, $useDbConfig)) {
if ($this->_checkUnitTest()) {
$this->bakeTest($currentModelName, $useTable, $associations);
Expand Down Expand Up @@ -401,7 +401,7 @@ function doAssociations(&$model, $interactive = true) {
$prompt = "{$model->name} {$type} {$associations[$type][$i]['alias']}";
$response = $this->in("{$prompt}?", array('y','n'), 'y');

if ('n' == low($response) || 'no' == low($response)) {
if ('n' == strtolower($response) || 'no' == strtolower($response)) {
unset($associations[$type][$i]);
} else {
if ($model->name === $associations[$type][$i]['alias']) {
Expand All @@ -414,7 +414,7 @@ function doAssociations(&$model, $interactive = true) {

$alternateAlias = $this->in(sprintf(__('This is a self join. Use %s as the alias', true), $alias), array('y', 'n'), 'y');

if ('n' == low($alternateAlias) || 'no' == low($alternateAlias)) {
if ('n' == strtolower($alternateAlias) || 'no' == strtolower($alternateAlias)) {
$associations[$type][$i]['alias'] = $this->in(__('Specify an alternate alias.', true));
} else {
$associations[$type][$i]['alias'] = $alias;
Expand All @@ -429,7 +429,7 @@ function doAssociations(&$model, $interactive = true) {

$wannaDoMoreAssoc = $this->in(__('Would you like to define some additional model associations?', true), array('y','n'), 'n');

while ((low($wannaDoMoreAssoc) == 'y' || low($wannaDoMoreAssoc) == 'yes')) {
while ((strtolower($wannaDoMoreAssoc) == 'y' || strtolower($wannaDoMoreAssoc) == 'yes')) {
$assocs = array(1 => 'belongsTo', 2 => 'hasOne', 3 => 'hasMany', 4 => 'hasAndBelongsToMany');
$bad = true;
while ($bad) {
Expand Down
4 changes: 2 additions & 2 deletions cake/console/libs/tasks/plugin.php
Expand Up @@ -136,7 +136,7 @@ function bake($plugin) {

$looksGood = $this->in('Look okay?', array('y', 'n', 'q'), 'y');

if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');

$Folder = new Folder($this->path . $pluginPath);
Expand All @@ -146,7 +146,7 @@ function bake($plugin) {
$Folder->create($this->path . $pluginPath . DS . $directory);
}

if (low($verbose) == 'y' || low($verbose) == 'yes') {
if (strtolower($verbose) == 'y' || strtolower($verbose) == 'yes') {
foreach ($Folder->messages() as $message) {
$this->out($message);
}
Expand Down
6 changes: 3 additions & 3 deletions cake/console/libs/tasks/project.php
Expand Up @@ -144,7 +144,7 @@ function bake($path, $skel = null, $skip = array('empty')) {

$looksGood = $this->in('Look okay?', array('y', 'n', 'q'), 'y');

if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');

$Folder = new Folder($skel);
Expand All @@ -157,14 +157,14 @@ function bake($path, $skel = null, $skip = array('empty')) {
return false;
}

if (low($verbose) == 'y' || low($verbose) == 'yes') {
if (strtolower($verbose) == 'y' || strtolower($verbose) == 'yes') {
foreach ($Folder->messages() as $message) {
$this->out($message);
}
}

return true;
} elseif (low($looksGood) == 'q' || low($looksGood) == 'quit') {
} elseif (strtolower($looksGood) == 'q' || strtolower($looksGood) == 'quit') {
$this->out('Bake Aborted.');
} else {
$this->execute(false);
Expand Down
12 changes: 6 additions & 6 deletions cake/console/libs/tasks/view.php
Expand Up @@ -161,25 +161,25 @@ function __interactive() {

$this->controllerName = $this->Controller->getName();

$this->controllerPath = low(Inflector::underscore($this->controllerName));
$this->controllerPath = strtolower(Inflector::underscore($this->controllerName));

$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');

if (low($interactive) == 'y' || low($interactive) == 'yes') {
if (strtolower($interactive) == 'y' || strtolower($interactive) == 'yes') {
$this->interactive = true;
$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');
}

if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') {
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoScaffold) == 'yes') {
$wannaDoAdmin = $this->in("Would you like to create the views for admin routing?", array('y','n'), 'y');
}
$admin = false;

if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) {
if ((strtolower($wannaDoAdmin) == 'y' || strtolower($wannaDoAdmin) == 'yes')) {
$admin = $this->getAdmin();
}

if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') {
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoScaffold) == 'yes') {
$actions = $this->scaffoldActions;
if ($admin) {
foreach ($actions as $action) {
Expand Down Expand Up @@ -213,7 +213,7 @@ function __interactive() {
$this->out("Path: ".$this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp");
$this->hr();
$looksGood = $this->in('Look okay?', array('y','n'), 'y');
if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
if (strtolower($looksGood) == 'y' || strtolower($looksGood) == 'yes') {
$this->bake($action);
$this->_stop();
} else {
Expand Down

0 comments on commit 9eaad75

Please sign in to comment.