Skip to content

Commit 2029231

Browse files
committed
Change class filenames to Ucfirst
1 parent 2d536f8 commit 2029231

File tree

20 files changed

+133
-85
lines changed

20 files changed

+133
-85
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ public function index()
5050
}
5151

5252
/* End of file welcome.php */
53-
/* Location: ./application/controllers/welcome.php */
53+
/* Location: ./application/controllers/Welcome.php */

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,4 @@
274274
require_once BASEPATH.'core/CodeIgniter.php';
275275

276276
/* End of file index.php */
277-
/* Location: ./index.php */
277+
/* Location: ./index.php */

system/core/CodeIgniter.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,13 @@ function &get_instance()
240240
// Load the local application controller
241241
// Note: The Router class automatically validates the controller path using the router->_validate_request().
242242
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
243-
if ( ! file_exists(APPPATH.'controllers/'.$RTR->directory.$RTR->class.'.php'))
243+
$class = ucfirst($RTR->class);
244+
if ( ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php'))
244245
{
245246
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
246247
}
247248

248-
include(APPPATH.'controllers/'.$RTR->directory.$RTR->class.'.php');
249+
include(APPPATH.'controllers/'.$RTR->directory.$class.'.php');
249250

250251
// Set a mark point for benchmarking
251252
$BM->mark('loading_time:_base_classes_end');
@@ -257,9 +258,8 @@ function &get_instance()
257258
*
258259
* None of the methods in the app controller or the
259260
* loader class can be called via the URI, nor can
260-
* controller functions that begin with an underscore.
261+
* controller methods that begin with an underscore.
261262
*/
262-
$class = $RTR->class;
263263
$method = $RTR->method;
264264

265265
if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
@@ -271,6 +271,8 @@ function &get_instance()
271271
$method = 'index';
272272
}
273273

274+
$class = ucfirst($class);
275+
274276
if ( ! class_exists($class, FALSE))
275277
{
276278
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
@@ -309,6 +311,8 @@ function &get_instance()
309311
$method = 'index';
310312
}
311313

314+
$class = ucfirst($class);
315+
312316
if ( ! class_exists($class, FALSE))
313317
{
314318
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))

system/core/Loader.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,33 +261,32 @@ public function model($model, $name = '', $db_conn = FALSE)
261261
show_error('The model name you are loading is the name of a resource that is already being used: '.$name);
262262
}
263263

264-
$model = strtolower($model);
265-
266-
foreach ($this->_ci_model_paths as $mod_path)
264+
if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE))
267265
{
268-
if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
266+
if ($db_conn === TRUE)
269267
{
270-
continue;
268+
$db_conn = '';
271269
}
272270

273-
if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE))
274-
{
275-
if ($db_conn === TRUE)
276-
{
277-
$db_conn = '';
278-
}
271+
$CI->load->database($db_conn, FALSE, TRUE);
272+
}
279273

280-
$CI->load->database($db_conn, FALSE, TRUE);
281-
}
274+
if ( ! class_exists('CI_Model', FALSE))
275+
{
276+
load_class('Model', 'core');
277+
}
278+
279+
$model = ucfirst(strtolower($model));
282280

283-
if ( ! class_exists('CI_Model', FALSE))
281+
foreach ($this->_ci_model_paths as $mod_path)
282+
{
283+
if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
284284
{
285-
load_class('Model', 'core');
285+
continue;
286286
}
287287

288288
require_once($mod_path.'models/'.$path.$model.'.php');
289289

290-
$model = ucfirst($model);
291290
$CI->$name = new $model();
292291
$this->_ci_models[] = $name;
293292
return;

system/core/Router.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ protected function _validate_request($segments)
270270
return $segments;
271271
}
272272

273-
$test = ($this->translate_uri_dashes === TRUE)
274-
? str_replace('-', '_', $segments[0]) : $segments[0];
273+
$test = ucfirst($this->translate_uri_dashes === TRUE ? str_replace('-', '_', $segments[0]) : $segments[0]);
275274

276275
// Does the requested controller exist in the root folder?
277276
if (file_exists(APPPATH.'controllers/'.$test.'.php'))
@@ -286,8 +285,7 @@ protected function _validate_request($segments)
286285
$this->set_directory(array_shift($segments));
287286
if (count($segments) > 0)
288287
{
289-
$test = ($this->translate_uri_dashes === TRUE)
290-
? str_replace('-', '_', $segments[0]) : $segments[0];
288+
$test = ucfirst($this->translate_uri_dashes === TRUE ? str_replace('-', '_', $segments[0]) : $segments[0]);
291289

292290
// Does the requested controller exist in the sub-directory?
293291
if ( ! file_exists(APPPATH.'controllers/'.$this->directory.$test.'.php'))
@@ -307,7 +305,7 @@ protected function _validate_request($segments)
307305
{
308306
// Is the method being specified in the route?
309307
$segments = explode('/', $this->default_controller);
310-
if ( ! file_exists(APPPATH.'controllers/'.$this->directory.$segments[0].'.php'))
308+
if ( ! file_exists(APPPATH.'controllers/'.$this->directory.ucfirst($segments[0]).'.php'))
311309
{
312310
$this->directory = '';
313311
}

user_guide_src/source/general/cli.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Let's try it: Hello World!
3333
==========================
3434

3535
Let's create a simple controller so you can see it in action. Using your
36-
text editor, create a file called tools.php, and put the following code
36+
text editor, create a file called Tools.php, and put the following code
3737
in it::
3838

3939
<?php

user_guide_src/source/general/controllers.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Consider this URI::
1818
example.com/index.php/blog/
1919

2020
In the above example, CodeIgniter would attempt to find a controller
21-
named blog.php and load it.
21+
named Blog.php and load it.
2222

2323
**When a controller's name matches the first segment of a URI, it will
2424
be loaded.**
@@ -27,7 +27,7 @@ Let's try it: Hello World!
2727
==========================
2828

2929
Let's create a simple controller so you can see it in action. Using your
30-
text editor, create a file called blog.php, and put the following code
30+
text editor, create a file called Blog.php, and put the following code
3131
in it::
3232

3333
<?php
@@ -41,6 +41,8 @@ in it::
4141

4242
Then save the file to your *application/controllers/* directory.
4343

44+
.. important:: The file must be called 'Blog.php', with a capital 'B'.
45+
4446
Now visit the your site using a URL similar to this::
4547

4648
example.com/index.php/blog/
@@ -136,7 +138,7 @@ present, as will be the case when only your site root URL is requested.
136138
To specify a default controller, open your **application/config/routes.php**
137139
file and set this variable::
138140

139-
$route['default_controller'] = 'blog';
141+
$route['default_controller'] = 'Blog';
140142

141143
Where Blog is the name of the controller class you want used. If you now
142144
load your main index.php file without specifying any URI segments you'll
@@ -272,7 +274,7 @@ and place your controller classes within them.
272274
specify the folder. For example, let's say you have a controller located
273275
here::
274276

275-
application/controllers/products/shoes.php
277+
application/controllers/products/Shoes.php
276278

277279
To call the above controller your URI will look something like this::
278280

user_guide_src/source/general/creating_libraries.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ Naming Conventions
4242
The Class File
4343
==============
4444

45-
Classes should have this basic prototype (Note: We are using the name
46-
Someclass purely as an example)::
45+
Classes should have this basic prototype::
4746

4847
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
4948

@@ -56,6 +55,8 @@ Someclass purely as an example)::
5655

5756
/* End of file Someclass.php */
5857

58+
.. note:: We are using the name Someclass purely as an example.
59+
5960
Using Your Class
6061
================
6162

@@ -81,7 +82,7 @@ constructor::
8182

8283
$params = array('type' => 'large', 'color' => 'red');
8384

84-
$this->load->library('Someclass', $params);
85+
$this->load->library('someclass', $params);
8586

8687
If you use this feature you must set up your class constructor to expect
8788
data::

user_guide_src/source/general/libraries.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ Creating Your Own Libraries
2929
===========================
3030

3131
Please read the section of the user guide that discusses how to
32-
:doc:`create your own libraries <creating_libraries>`.
32+
:doc:`create your own libraries <creating_libraries>`.

user_guide_src/source/general/models.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ Where **Model_name** is the name of your class. Class names **must** have
8484
the first letter capitalized with the rest of the name lowercase. Make
8585
sure your class extends the base Model class.
8686

87-
The file name will be a lower case version of your class name. For
88-
example, if your class is this::
87+
The file name must match the class name. For example, if this is your class::
8988

9089
class User_model extends CI_Model {
9190

@@ -98,7 +97,7 @@ example, if your class is this::
9897

9998
Your file will be this::
10099

101-
application/models/user_model.php
100+
application/models/User_model.php
102101

103102
Loading a Model
104103
===============
@@ -111,7 +110,7 @@ the following method::
111110

112111
If your model is located in a sub-directory, include the relative path
113112
from your models directory. For example, if you have a model located at
114-
*application/models/blog/queries.php* you'll load it using::
113+
*application/models/blog/Queries.php* you'll load it using::
115114

116115
$this->load->model('blog/queries');
117116

@@ -181,4 +180,4 @@ database. The following options for connecting are available to you:
181180
$config['pconnect'] = FALSE;
182181
$config['db_debug'] = TRUE;
183182

184-
$this->load->model('Model_name', '', $config);
183+
$this->load->model('model_name', '', $config);

0 commit comments

Comments
 (0)