Commonize redundancy in the index and admin/index files
Posted: Tue Mar 23, 2010 1:55 am
I've noticed that the index.php and admin/index.php files have been growing into a huge pile of code, most of which is common between the two. I also see the "startup.php" file which seems to handle similar bits of code.
Why not just move all the common stuff into startup.php or something like common.php. This can cut down on the redundancy. It would also help make external 3rd party scripts that don't use the controller to easily include the common file for easy integration.
Examples
index.php has:
admin/index.php also has:
system/startup.php has:
So the currency require step could certainly be done in the startup.php
Same thing with all the rest of the registry stuff:
It's all the same in both files and should be in a common place. Only the specifics should be in the individual index files
Why not just move all the common stuff into startup.php or something like common.php. This can cut down on the redundancy. It would also help make external 3rd party scripts that don't use the controller to easily include the common file for easy integration.
Examples
index.php has:
Code: Select all
require_once(DIR_SYSTEM . 'library/currency.php');
Code: Select all
require_once(DIR_SYSTEM . 'library/currency.php');
Code: Select all
// Common
require_once(DIR_SYSTEM . 'library/cache.php');
require_once(DIR_SYSTEM . 'library/config.php');
require_once(DIR_SYSTEM . 'library/db.php');
require_once(DIR_SYSTEM . 'library/document.php');
require_once(DIR_SYSTEM . 'library/image.php');
require_once(DIR_SYSTEM . 'library/language.php');
require_once(DIR_SYSTEM . 'library/log.php');
require_once(DIR_SYSTEM . 'library/mail.php');
require_once(DIR_SYSTEM . 'library/pagination.php');
require_once(DIR_SYSTEM . 'library/request.php');
require_once(DIR_SYSTEM . 'library/response.php');
require_once(DIR_SYSTEM . 'library/session.php');
require_once(DIR_SYSTEM . 'library/template.php');
Same thing with all the rest of the registry stuff:
Code: Select all
// Registry
$registry = new Registry();
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);