CoreFiles by mySites.guru
cmsloader.php62 lines, 1,786 bytes, from Joomla_2.5.0-Stable-Full_Package.zip
Raw History Compare with 1.7.5
md5
6f26858afe04c96d9806a446d3cf0165
sha1
9f2b384cb82f1c715fadbd6357c57b912c792d02
sha256
7cc991c591c48c5d42e76ca5b08f9abc0149a3c4393c9b41d51adb8b04783d95
<?php
/**
 * @package     Joomla.Libraries
 *
 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * Static class to handle loading of CMS libraries.
 *
 * @package  Joomla.Libraries
 * @since    2.5
 */
abstract class JCmsLoader extends JLoader
{
	/**
	 * Method to setup the autoloaders for the Joomla CMS. Since the SPL autoloaders are
	 * called in a queue we will add our explicit, class-registration based loader first, then
	 * fall back on the autoloader based on conventions. This will allow people to register a
	 * class in a specific location and override platform libraries as was previously possible.
	 *
	 * @return  void
	 *
	 * @since   2.5
	 */
	public static function setup()
	{
		spl_autoload_register(array('JCmsLoader', '_autoload'));
	}

	/**
	 * Autoload a Joomla library class based on name.
	 *
	 * @param   string   $class  The class to be loaded.
	 *
	 * @return  void
	 *
	 * @since   2.5
	 */
	private static function _autoload($class)
	{
		// Only attempt autoloading if we are dealing with a Joomla Platform class.
		if ($class[0] == 'J') {
			// Split the class name (without the J) into parts separated by camelCase.
			$parts = preg_split('/(?<=[a-z])(?=[A-Z])/x', substr($class, 1));

			// If there is only one part we want to duplicate that part for generating the path.
			$parts = (count($parts) === 1) ? array($parts[0], $parts[0]) : $parts;

			// Generate the path based on the class name parts.
			$path = JPATH_PLATFORM . '/cms/' . implode('/', array_map('strtolower', $parts)) . '.php';

			// Load the file if it exists.
			if (file_exists($path)) {
				include $path;
			}
		}
	}
}

The same content is in 5 releases, Joomla 2.5.0 to 2.5.4. See them all, or every version of this file.