joomla1.56 loader.php
来源:互联网 发布:软件后端开发是什么 编辑:程序博客网 时间:2024/05/01 14:38
分享一下,有错误请写出来,谢谢啦
- <?php
- /**
- * @version $Id: loader.php 10381 2008-06-01 03:35:53Z pasamio $
- * @package Joomla.Framework
- * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
- * @license GNU/GPL, see LICENSE.php
- * Joomla! is free software. This version may have been modified pursuant
- * to the GNU General Public License, and as distributed it includes or
- * is derivative of works licensed under the GNU General Public License or
- * other free or open source software licenses.
- * See COPYRIGHT.php for copyright notices and details.
- */
- //定义分隔符
- if(!defined('DS')) {
- define( 'DS', DIRECTORY_SEPARATOR );
- }
- /**
- * @package Joomla.Framework
- */
- class JLoader
- {
- /**
- * Loads a class from specified directories.
- *
- * @param string $name The class name to look for ( dot notation ).
- * @param string $base Search this directory for the class.
- * @param string $key String used as a prefix to denote the full path of the file ( dot notation ).
- * @return void
- * @since 1.5
- */
- function import( $filePath, $base = null, $key = 'libraries.' )
- {
- static $paths;//保存 $paths[***.***.**.**] = bool 或者 include...
- if (!isset($paths)) { //头一回
- $paths = array();//设置为空数组
- }
- //在原路径中加上前缀,$keypath是作为$paths的键名,静态保存
- $keyPath = $key ? $key . $filePath : $filePath;
- //如果没设置这个键名
- if (!isset($paths[$keyPath]))
- {
- if ( ! $base ) {//基本路径为空
- $base = dirname( __FILE__ );//其实就是JPATH_LIBRARIES
- }
- //把原路径依.分开
- $parts = explode( '.', $filePath );
- //取出最后一个,就是类名
- $classname = array_pop( $parts );
- switch($classname)//判断下类名
- {
- case 'helper' ://如果是'helper'
- //再取一个双大写组合
- $classname = ucfirst(array_pop( $parts )).ucfirst($classname);
- break;
- default ://默认的话就类名开头大写
- $classname = ucfirst($classname);
- break;
- }
- //路径更改, .变DS
- $path = str_replace( '.', DS, $filePath );
- //joomla开头
- if (strpos($filePath, 'joomla') === 0)
- {
- /*
- * If we are loading a joomla class prepend the classname with a
- * capital J.
- */
- $classname = 'J'.$classname;//J+类名
- //注册一下
- $classes = JLoader::register($classname, $base.DS.$path.'.php');
- //是否设置了
- $rs = isset($classes[strtolower($classname)]);
- }
- else
- {
- /*
- * If it is not in the joomla namespace then we have no idea if
- * it uses our pattern for class names/files so just include.
- */
- //直接导入
- $rs = include($base.DS.$path.'.php');
- }
- $paths[$keyPath] = $rs;
- }
- //返回的可以是bool或是导入的内容
- return $paths[$keyPath];
- }
- /**
- * Add a class to autoload
- *
- * @param string $classname The class name
- * @param string $file Full path to the file that holds the class
- * @return array|boolean Array of classes
- * @since 1.5
- */
- /**
- * 配合php5的自动读取
- *
- * @param string $classname 类名
- * @param string $file 绝对路径
- * @return array|boolean Array of classes
- * @since 1.5
- */
- function & register ($class = null, $file = null)
- {
- static $classes;//classes[(小写)类名] = 路径
- if(!isset($classes)) {//如果头一回
- $classes = array();//为空数组
- }
- if($class && is_file($file))//if都没问题
- {
- // Force to lower case.
- $class = strtolower($class);//强制小写
- $classes[$class] = $file; //classes[(小写)类名] = 路径
- // In php4 we load the class immediately.
- if((version_compare( phpversion(), '5.0' ) < 0)) {//PHP就直接读取class
- JLoader::load($class);
- }
- }
- //return classes
- return $classes;
- }
- /**
- * Load the file for a class
- *
- * @access public
- * @param string $class The class that will be loaded
- * @return boolean True on success
- * @since 1.5
- */
- /**
- * 从注册函数中返回classes,$class是classes的键值就包括进来
- * @access public
- * @param string $class
- * @return boolean True on success
- */
- function load( $class )
- {
- $class = strtolower($class); //强制小写
- if (class_exists($class)) {//最在返回空
- return;
- }
- $classes = JLoader::register();//取得所有注册的类
- if(array_key_exists( strtolower($class), $classes)) {
- //如果存在,包括进来
- include($classes[$class]);
- return true;
- }
- //否则返回 false
- return false;
- }
- }
- /**
- * When calling a class that hasn't been defined, __autoload will attempt to
- * include the correct file for that class.
- *
- * This function get's called by PHP. Never call this function yourself.
- *
- * @param string $class
- * @access public
- * @return boolean
- * @since 1.5
- */
- //PHP5的新特性,包括已经注册的类
- function __autoload($class)
- {
- if(JLoader::load($class)) {
- return true;
- }
- return false;
- }
- /**
- * Global application exit.全局的退出函数
- *
- * This function provides a single exit point for the framework.
- *
- * @param mixed Exit code or string. Defaults to zero.
- */
- function jexit($message = 0) {
- exit($message);
- }
- /**
- * Intelligent file importer一个系统内部的导入,因为是用libraries.开始
- *
- * @access public
- * @param string $path A dot syntax path
- * @since 1.5
- */
- function jimport( $path ) {
- return JLoader::import($path);
- }
- joomla1.56 loader.php
- joomla1.56 profiler.php
- Joomla1.5模板特征
- Joomla1.5学习笔记
- requires the ionCube PHP Loader
- [李景山php]每天TP5-20161208|Loader.php
- joomla1.5重新安装的方法
- joomla1.6的权限控制
- 学习Joomla1--密码加密方式
- 学习joomla1.5扩展开发
- CodeIgniter源码分析之Loader.php
- php启用zend guard loader扩展问题
- php 3和Zend Guard Loader
- Loader
- Loader
- Loader
- loader
- loader
- ZigBee密西西比协议栈的中断回调usrSlowTimerInt()函数
- 清除 googleupdate.exe进程
- 利用Sql Server的top分页查询的通用构造方式
- 使用TestDirector管理测试用例和评估测试用例执行状况
- C++经典面试题
- joomla1.56 loader.php
- Mozilla将于2010年推出手机版火狐浏览器
- 《系统分析与设计》读书笔记(二)
- [推荐]100句经典构建良好人际关系
- C语言位域常见问题分析
- 一个简单的超链接控制div的js
- jira 安装 破解 连接mysql
- xmart-project总结
- C#学习步骤