...

World Wide Web Server 2012-07-04 16:06:17 -07:00
parent b015f85b8d
commit 0108ad1c0f

@ -2,9 +2,6 @@
A simple Php5 Front-End for CI Loader Class. Bye bye [b]$this[/b].
[b]Credits[/b]
Based on Modularity Plugin by Jonathon Hill (http://codeigniter.com/forums/viewthread/99960/P15/)
[b]Advantages:[/b]
* No more calling get_instance() when you need to access the framework inside a model, library, helper, or view
* Support for multiple database connections
@ -31,7 +28,7 @@ Based on Modularity Plugin by Jonathon Hill (http://codeigniter.com/forums/viewt
* Added Php5 Helpers Mode :)
* Added Plugin suffix
[b]Version 1.4 Changelog:[/b]
[b]Version 1.4 Changelog: (downloads 8)[/b]
* Added Langs()
* Added Modularity for Configs, Helpers, Langs (es. Configs('rss')->line('ip');)
* Libraries re-renamed in "Libs" by popular acclaim (lol)
@ -43,8 +40,8 @@ Based on Modularity Plugin by Jonathon Hill (http://codeigniter.com/forums/viewt
* Check Control for Core CI Libs Autoloaded (Uri, Input, Config etc...). Now more faster
* Created CI Wiki page
[b]Dowonload:[/b]
http://codeigniter.com/forums/viewthread/134605/
[b]Credits[/b]
Based on Modularity Plugin by Jonathon Hill (http://codeigniter.com/forums/viewthread/99960/P15/)
[b]Installation:[/b]
This is a plugin so no core hacking is required. Simply download, extract it into your [b]application/plugins[/b] folder. (auto)Load it just like any other plugin.
@ -56,4 +53,133 @@ This is a plugin so no core hacking is required. Simply download, extract it int
[code]
# old way
$this->load->view('news_view', $data);
%
# new way
Views('news', $data);
[/code]
[h3]Libraries[/h3]
[code]
# old way
$this->load->library('mylibrary');
$this->mylibrary->do_something();
# new way
Libs('mylibrary')->do_something(); // the library automatically loads if needed
# core library
Libs('input')->post('name');
Libs('output')->set_header('HTTP/1.0 200 OK');
Libs('session')->userdata('id');
[/code]
[h3]Models[/h3]
[code]
# old way
$this->load->model('news_model');
$this->news_model->do_something();
# new way
Models('news')->do_something();// the model automatically loads if needed
[/code]
[h3]Langs[/h3]
[code]
# old way
$this->load->language('filename');
$this->lang->line('language_key');
# new way
Langs('filename')->line('language_key');// the language automatically loads if needed
# alternative new way
Langs('filename');
Langs()->line('language_key');
[/code]
[h3]Plugins[/h3]
[code]
# old way
$this->load->plugin('captcha');
$this->captcha->do_something();
# new way
Plugins('captcha')->do_something();// the plugin automatically loads if needed
[/code]
[h3]Configs[/h3]
[code]
# old way
$this->config->load('filename');
$this->config->item('itemname');
# new way
Configs('filename')->item('itemname'); // the config automatically loads if needed
[/code]
[h3]Helpers[/h3]
[code]
# old way
$this->load->helper('date');
echo now();
# new way
echo Helpers('date')->now(); // the helper automatically loads if needed
# alternative new way
Helpers('date');
echo now();
[/code]
[h3]Vars[/h3]
[code]
# old way
$this->load->vars(array('page_type' => 'section'));
# new way
Vars(array('page_type' => 'section'));
[/code]
[h3]Databases[/h3]
[code]
# old way - default database
$this->load->database();
$query = $this->db->query($sql);
# new way
$query = DBS()->query($sql);// the "default" database automatically loads if needed
[/code]
[h3]Multiple database connections[/h3]
[code]
# old way
$dbh1 = $this->load->database('db1', TRUE);
$dbh2 = $this->load->database('db2', TRUE);
$query1 = $dbh1->query($sql);
$query2 = $dbh2->query($sql);
# new way
$dbh1 = DBS('db1')->query($sql);// the "db1" database automatically loads if needed
$dbh2 = DBS('db2')->query($sql);// the "db2" database automatically loads if needed
[/code]
[h3]Inside libraries, helpers, or views[/h3]
[code]
# old way
$CI =& get_instance();
$CI->load->model('news_model');
$CI->news_model->do_something();
# new way
Models('news')->do_something();
[/code]