A curious class_exists() allows for alternate Joomla Classes - Joomla! Forum - community, help and support
has noticed, when walking through code of typical start joomla 1.5 website, file, import.php, ( called in index file, index.php, require_once ( jpath_base .ds.'includes'.ds.'framework.php' ); ), test first see if jloader class has not been included?
.../libraries/joomla/import.php:
what curious thing!
the file used throughout joomla load in core framework classes , more tested see if it's included before included!
looks me done design allow sly if not malicious intervention.
what if class, jloader, had existed @ point?
what if 'alternate' index file called, indexalt.php, had following code?:
the code above includes alternative traditional loader file, loader.php, , includes usual root file, index.php.
the new jloader class have segment of code allows me load alternate helper file or have you:
in code above, first intended file in alternate location. if file not found there, resort going traditional location specified in original loader class.
now, can dangerous heck if don't know you're doing!
with every update of joomla! framework, there danger you're missing out on new functions , features , or damaging whole website 'out-of-date' alternate classes , code.
but approach rather clean way 'override' fundmental behavior of joomla! framework---if chance feel need so.
in case, had rather unique situation required joomla not load plugins installed (when joomla website being called within facebook -- that's story.).
it literally required of me rewrite core class, jpluginhelper, call, jpluginhelper::_load() modified query string, loaded specific plugins when running within facebook.
because of test jloader class, if (! class_exists('jloader')) {, able without touching actual core class code.
cheers.
.../libraries/joomla/import.php:
code: select all
/**
* load loader class
*/
if (! class_exists('jloader')) {
require_once( jpath_libraries.ds.'loader.php');
}
the file used throughout joomla load in core framework classes , more tested see if it's included before included!
looks me done design allow sly if not malicious intervention.
what if class, jloader, had existed @ point?
what if 'alternate' index file called, indexalt.php, had following code?:
code: select all
<?php
if(!defined('ds')) {
define( 'ds', directory_separator );
}
$altloader = dirname( __file__ ).ds.'plugins'.ds.'system'.ds.basename(__file__, '.php').ds.'libraries'.ds.'loader.php';
if ( file_exists($altloader) ){
include_once($altloader);
}
$indexfile = 'index.php';
if ( file_exists($indexfile) ){
include($indexfile);
}
?>
the new jloader class have segment of code allows me load alternate helper file or have you:
code: select all
$phpfile = $altbase.ds.$path.'.php';
if ( !is_file($phpfile) ){
$phpfile = $base.ds.$path.'.php';
}
now, can dangerous heck if don't know you're doing!
with every update of joomla! framework, there danger you're missing out on new functions , features , or damaging whole website 'out-of-date' alternate classes , code.
but approach rather clean way 'override' fundmental behavior of joomla! framework---if chance feel need so.
in case, had rather unique situation required joomla not load plugins installed (when joomla website being called within facebook -- that's story.).
it literally required of me rewrite core class, jpluginhelper, call, jpluginhelper::_load() modified query string, loaded specific plugins when running within facebook.
because of test jloader class, if (! class_exists('jloader')) {, able without touching actual core class code.
cheers.
hi suchitis,
this interesting indeed. concept of being able load alternate files automatic detection. cool implement on template level well.
best,
matt
this interesting indeed. concept of being able load alternate files automatic detection. cool implement on template level well.
best,
matt
Comments
Post a Comment