Welcome Guest, Not a member yet? Register   Sign In
Unified Loading Patch
#1

[eluser]Neophyte[/eluser]
Been a while since i've posted so first up just a quick hi to any old members who remember me :p ...

This is a code contribution to compliment a very old thread so before reading further please have a quick scan over this thread 'making CI easier to extend/modify'.

Ok now youve had a quick look over that thread you can find here a little code which implements the changes outlined. First up here are the files provided in a few different ways to make it as easy as possible for people to read over and use.

- View Patch Online
- Patch File (unified diff of the changes applied to a checkout of the CI 1.7.2 tag)
- Affected (zip holding just the affected files - maintains correct directory structure)
- All (an export of CI 1.7.2 with the patch applied)

With this patch i've tried to stick to the codeigniter coding conventions and general style keeping changes where possible just one for one replacements of the previous code maintaining the original logic and behaviour.

Although the bulk of the patch is just one for one replacements there are a few main areas where more extensive changes have been made to include the necessary logic to implement this change.

Common.php:

Within this file aswell as the usual one for one replacements you will find two additional functions, ci_file_exists and ci_find.

ci_file_exists() works in the same manner as php's own file_exist function in that it returns true or false based if the specified file exists the difference is that this function makes use of the function ci_find to determine if the file exists.

ci_find() provides the core but very simply logic of checking the APPPATH and BASEPATH for the specified file returning the absolute path of where it find the file. If the file is not found then the specified path is returned the reasoning behind this is it allows the one for one replacements to error out as they originally did whilst being able to present you with a sensible path.

index.php:

Originally this file included 'system/codeigniter/CodeIgniter.php' which acts as a bootstrap and front controller this file then included 'system/codeigniter/Common.php' which provides a set of useful global functions needed by the framework.

As our new functions which control loading are in this Common.php file we could really do with grabbing these functions first and then loading CodeIgniter.php making use of are now available loading functions, as such a code block has been added which includes Common.php, the approach taken is to check APPPATH then BASEPATH providing an easy way to overried the functions.

CodeIgniter.php:

As index.php now includes the common functions this line has been removed from this file.

The files affected by this patch are as follows:

index.php
system/codeigniter/CodeIgniter.php
system/codeigniter/Common.php
system/database/DB.php
system/helpers/download_helper.php
system/helpers/file_helper.php
system/helpers/html_helper.php
system/helpers/smileys_helper.php
system/libraries/Config.php
system/libraries/Exception.php
system/libraries/Hooks.php
system/libraries/Language.php
system/libraries/Loader.php
system/libraries/Router.php
system/libraries/Upload.php
system/libraries/User_agent.php

All of this stuff is a bit niche i guess but hopefully a few others will find some of the work useful, that's all for now, i will update as i do more.




Theme © iAndrew 2016 - Forum software by © MyBB