去掉所有不必要的require_once
This commit is contained in:
joyqi 2014-02-12 17:51:47 +08:00
parent 1ee0fa0805
commit c056ba70fa
45 changed files with 83 additions and 169 deletions

View File

@ -295,7 +295,6 @@ class Typecho_Common
$code = $exception;
}
require_once 'Typecho/Response.php';
$charset = self::$charset;
if ($isException && $exception instanceof Typecho_Db_Exception) {
@ -330,7 +329,6 @@ class Typecho_Common
/** 设置http code */
if (is_numeric($code) && $code > 200) {
require_once 'Typecho/Response.php';
Typecho_Response::setStatus($code);
}
@ -876,7 +874,6 @@ EOF;
{
static $loaded;
if (!$loaded) {
require_once 'Typecho/Common/Paragraph.php';
$loaded = true;
}

View File

@ -8,9 +8,6 @@
* @license GNU General Public License 2.0
* @version $Id$
*/
/** 载入api支持 */
require_once 'Typecho/Common.php';
/**
* 用于对自动分段做处理

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** 载入api支持 */
require_once 'Typecho/Common.php';
/**
* cookie支持
*

View File

@ -1,8 +1,5 @@
<?php
/** Typecho_I18n */
require_once 'Typecho/I18n.php';
/**
* 日期处理
*

View File

@ -7,12 +7,6 @@
* @version $Id: Db.php 107 2008-04-11 07:14:43Z magike.net $
*/
/** 配置管理 */
require_once 'Typecho/Config.php';
/** sql构建器 */
require_once 'Typecho/Db/Query.php';
/**
* 包含获取数据支持方法的类.
* 必须定义__TYPECHO_DB_HOST__, __TYPECHO_DB_PORT__, __TYPECHO_DB_NAME__,
@ -123,7 +117,6 @@ class Typecho_Db
$this->_adapterName = $adapterName;
/** 数据库适配器 */
require_once 'Typecho/Db/Adapter/' . str_replace('_', '/', $adapterName) . '.php';
$adapterName = 'Typecho_Db_Adapter_' . $adapterName;
if (!call_user_func(array($adapterName, 'isAvailable'))) {
@ -233,7 +226,6 @@ class Typecho_Db
{
if (empty(self::$_instance)) {
/** Typecho_Db_Exception */
require_once 'Typecho/Db/Exception.php';
throw new Typecho_Db_Exception('Missing Database Object');
}
@ -310,7 +302,6 @@ class Typecho_Db
if (!isset($this->_connectedPool[$op])) {
if (empty($this->_pool[$op])) {
/** Typecho_Db_Exception */
require_once 'Typecho/Db/Exception.php';
throw new Typecho_Db_Exception('Missing Database Connection');
}

View File

@ -7,9 +7,6 @@
* @version $Id: DbException.php 52 2008-03-18 08:04:01Z magike.net $
*/
/** 数据库异常基类 */
require_once 'Typecho/Db/Exception.php';
/**
* 数据库连接异常类
*

View File

@ -7,9 +7,6 @@
* @version $Id: Mysql.php 103 2008-04-09 16:22:43Z magike.net $
*/
/** 数据库适配器接口 */
require_once 'Typecho/Db/Adapter.php';
/**
* 数据库Mysql适配器
*
@ -56,7 +53,6 @@ class Typecho_Db_Adapter_Mysql implements Typecho_Db_Adapter
}
/** 数据库异常 */
require_once 'Typecho/Db/Adapter/Exception.php';
throw new Typecho_Db_Adapter_Exception(@mysql_error($this->_dbLink));
}
@ -77,7 +73,6 @@ class Typecho_Db_Adapter_Mysql implements Typecho_Db_Adapter
}
/** 数据库异常 */
require_once 'Typecho/Db/Query/Exception.php';
throw new Typecho_Db_Query_Exception(@mysql_error($this->_dbLink), mysql_errno($this->_dbLink));
}

View File

@ -7,9 +7,6 @@
* @version $Id: Mysql.php 89 2008-03-31 00:10:57Z magike.net $
*/
/** 数据库适配器接口 */
require_once 'Typecho/Db/Adapter.php';
/**
* 数据库PDOMysql适配器
*
@ -59,7 +56,6 @@ abstract class Typecho_Db_Adapter_Pdo implements Typecho_Db_Adapter
return $this->_object;
} catch (PDOException $e) {
/** 数据库异常 */
require_once 'Typecho/Db/Adapter/Exception.php';
throw new Typecho_Db_Adapter_Exception($e->getMessage());
}
}
@ -93,7 +89,6 @@ abstract class Typecho_Db_Adapter_Pdo implements Typecho_Db_Adapter
$resource->execute();
} catch (PDOException $e) {
/** 数据库异常 */
require_once 'Typecho/Db/Query/Exception.php';
throw new Typecho_Db_Query_Exception($e->getMessage(), $e->getCode());
}

View File

@ -7,9 +7,6 @@
* @version $Id: Mysql.php 89 2008-03-31 00:10:57Z magike.net $
*/
/** 数据库适配器接口 */
require_once 'Typecho/Db/Adapter/Pdo.php';
/**
* 数据库Pdo_Mysql适配器
*

View File

@ -7,9 +7,6 @@
* @version $Id$
*/
/** 数据库适配器接口 */
require_once 'Typecho/Db/Adapter/Pdo.php';
/**
* 数据库Pdo_Pgsql适配器
*

View File

@ -7,9 +7,6 @@
* @version $Id$
*/
/** 数据库适配器接口 */
require_once 'Typecho/Db/Adapter/Pdo.php';
/**
* 数据库Pdo_SQLite适配器
*

View File

@ -7,9 +7,6 @@
* @version $Id$
*/
/** 数据库适配器接口 */
require_once 'Typecho/Db/Adapter.php';
/**
* 数据库Pgsql适配器
*
@ -61,7 +58,6 @@ class Typecho_Db_Adapter_Pgsql implements Typecho_Db_Adapter
}
/** 数据库异常 */
require_once 'Typecho/Db/Adapter/Exception.php';
throw new Typecho_Db_Adapter_Exception(@pg_last_error($this->_dbLink));
}
@ -84,7 +80,6 @@ class Typecho_Db_Adapter_Pgsql implements Typecho_Db_Adapter
}
/** 数据库异常 */
require_once 'Typecho/Db/Query/Exception.php';
throw new Typecho_Db_Query_Exception(@pg_last_error($this->_dbLink),
pg_result_error_field(pg_get_result($this->_dbLink), PGSQL_DIAG_SQLSTATE));
}

View File

@ -7,9 +7,6 @@
* @version $Id: Mysql.php 103 2008-04-09 16:22:43Z magike.net $
*/
/** 数据库适配器接口 */
require_once 'Typecho/Db/Adapter.php';
/**
* 数据库SQLite适配器
*
@ -84,7 +81,6 @@ class Typecho_Db_Adapter_SQLite implements Typecho_Db_Adapter
}
/** 数据库异常 */
require_once 'Typecho/Db/Adapter/Exception.php';
throw new Typecho_Db_Adapter_Exception($error);
}
@ -104,7 +100,6 @@ class Typecho_Db_Adapter_SQLite implements Typecho_Db_Adapter
}
/** 数据库异常 */
require_once 'Typecho/Db/Query/Exception.php';
$errorCode = sqlite_last_error($this->_dbHandle);
throw new Typecho_Db_Query_Exception(sqlite_error_string($errorCode), $errorCode);
}

View File

@ -7,9 +7,6 @@
* @version $Id: DbException.php 52 2008-03-18 08:04:01Z magike.net $
*/
/** 异常基类 */
require_once 'Typecho/Exception.php';
/**
* 数据库异常类
*

View File

@ -7,9 +7,6 @@
* @version $Id: DbQuery.php 97 2008-04-04 04:39:54Z magike.net $
*/
/** Typecho_Config */
require_once 'Typecho/Config.php';
/**
* Typecho数据库查询语句构建类
* 使用方法:

View File

@ -7,9 +7,6 @@
* @version $Id: DbException.php 52 2008-03-18 08:04:01Z magike.net $
*/
/** 数据库异常基类 */
require_once 'Typecho/Db/Exception.php';
/**
* 数据库查询异常类
*

View File

@ -10,9 +10,6 @@
* @version $Id$
*/
/** Typecho_Common */
require_once 'Typecho/Common.php';
/**
* Http客户端
*
@ -50,7 +47,6 @@ class Typecho_Http_Client
}
foreach ($adapters as $adapter) {
require_once 'Typecho/Http/Client/Adapter/' . $adapter . '.php';
$adapterName = 'Typecho_Http_Client_Adapter_' . $adapter;
if (Typecho_Common::isAvailableClass($adapterName) && call_user_func(array($adapterName, 'isAvailable'))) {
return new $adapterName();

View File

@ -10,9 +10,6 @@
* @version $Id$
*/
/** Typecho_Http_Client */
require_once 'Typecho/Http/Client.php';
/**
* 客户端适配器
*
@ -307,8 +304,6 @@ abstract class Typecho_Http_Client_Adapter
if (!empty($params['host'])) {
$this->host = $params['host'];
} else {
/** Typecho_Http_Client_Exception */
require_once 'Typecho/Http/Client/Exception.php';
throw new Typecho_Http_Client_Exception('Unknown Host', 500);
}

View File

@ -10,9 +10,6 @@
* @version $Id$
*/
/** Typecho_Http_Client_Adapter */
require_once 'Typecho/Http/Client/Adapter.php';
/**
* CURL适配器
*
@ -111,8 +108,6 @@ class Typecho_Http_Client_Adapter_Curl extends Typecho_Http_Client_Adapter
$response = curl_exec($ch);
if (false === $response) {
/** Typecho_Http_Client_Exception */
require_once 'Typecho/Http/Client/Exception.php';
throw new Typecho_Http_Client_Exception(curl_error($ch), 500);
}

View File

@ -10,9 +10,6 @@
* @version $Id$
*/
/** Typecho_Http_Client_Adapter */
require_once 'Typecho/Http/Client/Adapter.php';
/**
* Socket适配器
*

View File

@ -7,9 +7,6 @@
* @version $Id: DbException.php 52 2008-03-18 08:04:01Z magike.net $
*/
/** 异常基类 */
require_once 'Typecho/Exception.php';
/**
* Http客户端异常类
*

View File

@ -78,7 +78,6 @@ class Typecho_I18n
private static function init()
{
/** GetText支持 */
require_once 'Typecho/I18n/GetTextMulti.php';
self::$_loaded = new Typecho_I18n_GetTextMulti(self::$_lang);
return true;
}

View File

@ -7,9 +7,6 @@
* @version $Id$
*/
/** Typecho_I18n_GetText */
require_once 'Typecho/I18n/GetText.php';
/**
* 用于解决一个多个mo文件带来的读写问题
* 我们重写了一个文件读取类

View File

@ -7,9 +7,6 @@
* @version $Id: WidgetException.php 46 2008-03-10 13:59:36Z magike.net $
*/
/** 异常基类 */
require_once 'Typecho/Exception.php';
/**
* 插件异常
*

View File

@ -494,9 +494,6 @@ class Typecho_Request
}
$parts['query'] = http_build_query($args);
/** Typecho_Common */
require_once 'Typecho/Common.php';
/** 返回地址 */
return Typecho_Common::buildUrl($parts);
}

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** 载入api支持 */
require_once 'Typecho/Common.php';
/**
* Typecho公用方法
*
@ -246,7 +243,6 @@ class Typecho_Response
public function redirect($location, $isPermanently = false)
{
/** Typecho_Common */
require_once 'Typecho/Common.php';
$location = Typecho_Common::safeUrl($location);
if ($isPermanently) {

View File

@ -7,15 +7,6 @@
* @version $Id: Route.php 107 2008-04-11 07:14:43Z magike.net $
*/
/** 载入api支持 */
require_once 'Typecho/Common.php';
/** Typecho_Ruquest */
require_once 'Typecho/Request.php';
/** Typecho_Widget */
require_once 'Typecho/Widget.php';
/**
* Typecho组件基类
*
@ -161,7 +152,6 @@ class Typecho_Router
}
/** 载入路由异常支持 */
require_once 'Typecho/Router/Exception.php';
throw new Typecho_Router_Exception("Path '{$pathInfo}' not found", 404);
}
@ -195,9 +185,6 @@ class Typecho_Router
*/
public static function setRoutes($routes)
{
/** 载入路由解析支持 */
require_once 'Typecho/Router/Parser.php';
if (isset($routes[0])) {
self::$_routingTable = $routes[0];
} else {

View File

@ -7,9 +7,6 @@
* @version $Id: RouteException.php 104 2008-04-10 07:58:09Z magike.net $
*/
/** 异常基类 */
require_once 'Typecho/Exception.php';
/**
* 路由异常类
*

View File

@ -16,9 +16,6 @@
* @version $Id: Validation.php 106 2008-04-11 02:23:54Z magike.net $
*/
/** Typecho_Common */
require_once 'Typecho/Common.php';
/**
* 验证类
*

View File

@ -7,12 +7,6 @@
* @version $Id: Widget.php 107 2008-04-11 07:14:43Z magike.net $
*/
/** Typecho_Config */
require_once 'Typecho/Config.php';
/** Typecho_Plugin */
require_once 'Typecho/Plugin.php';
/**
* Typecho组件基类
*
@ -132,8 +126,6 @@ abstract class Typecho_Widget
if ($condition) {
return $this;
} else {
/** Typecho_Widget_Helper_Null */
require_once 'Typecho/Widget/Helper/Empty.php';
return new Typecho_Widget_Helper_Empty();
}
}
@ -171,8 +163,6 @@ abstract class Typecho_Widget
/** 如果类不存在 */
if (!class_exists($className)) {
/** Typecho_Exception */
require_once 'Typecho/Widget/Exception.php';
throw new Typecho_Widget_Exception($className);
}

View File

@ -7,9 +7,6 @@
* @version $Id: WidgetException.php 46 2008-03-10 13:59:36Z magike.net $
*/
/** 异常基类 */
require_once 'Typecho/Exception.php';
/**
* 组件异常类
*

View File

@ -9,12 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Layout */
require_once 'Typecho/Widget/Helper/Layout.php';
/** Typecho_Validate */
require_once 'Typecho/Validate.php';
/**
* 表单处理帮手
*

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Layout */
require_once 'Typecho/Widget/Helper/Layout.php';
/**
* 表单元素抽象类
*

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Form_Element */
require_once 'Typecho/Widget/Helper/Form/Element.php';
/**
* 多选框帮手类
*

View File

@ -0,0 +1,83 @@
<?php
/**
* 虚拟域帮手类
*
* @category typecho
* @package Widget
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org)
* @license GNU General Public License 2.0
* @version $Id$
*/
/**
* 虚拟域帮手类
*
* @category typecho
* @package Widget
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org)
* @license GNU General Public License 2.0
*/
class Typecho_Widget_Helper_Form_Element_Fake extends Typecho_Widget_Helper_Form_Element
{
/**
* 构造函数
*
* @access public
* @param string $name 表单输入项名称
* @param mixed $value 表单默认值
* @return void
*/
public function __construct($name, $value)
{
$this->name = $name;
self::$uniqueId ++;
/** 运行自定义初始函数 */
$this->init();
/** 初始化表单项 */
$this->input = $this->input($name, $options);
/** 初始化表单值 */
if (NULL !== $value) {
$this->value($value);
}
}
/**
* 自定义初始函数
*
* @access public
* @return void
*/
public function init()
{}
/**
* 初始化当前输入项
*
* @access public
* @param string $name 表单元素名称
* @param array $options 选择项
* @return Typecho_Widget_Helper_Layout
*/
public function input($name = NULL, array $options = NULL)
{
$input = new Typecho_Widget_Helper_Layout('input');
$this->inputs[] = $input;
return $input;
}
/**
* 设置表单项默认值
*
* @access protected
* @param string $value 表单项默认值
* @return void
*/
protected function _value($value)
{
$this->input->setAttribute('value', $value);
}
}

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Form_Element */
require_once 'Typecho/Widget/Helper/Form/Element.php';
/**
* 隐藏域帮手类
*

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Form_Element */
require_once 'Typecho/Widget/Helper/Form/Element.php';
/**
* 密码输入表单项帮手类
*

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Form_Element */
require_once 'Typecho/Widget/Helper/Form/Element.php';
/**
* 单选框帮手类
*

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Form_Element */
require_once 'Typecho/Widget/Helper/Form/Element.php';
/**
* 下拉选择框帮手类
*

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Form_Element */
require_once 'Typecho/Widget/Helper/Form/Element.php';
/**
* 提交按钮表单项帮手类
*

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Form_Element */
require_once 'Typecho/Widget/Helper/Form/Element.php';
/**
* 文字输入表单项帮手类
*

View File

@ -9,9 +9,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_Form_Element */
require_once 'Typecho/Widget/Helper/Form/Element.php';
/**
* 多行文字域帮手类
*

View File

@ -126,8 +126,6 @@ abstract class Typecho_Widget_Helper_PageNavigator
*/
public function render()
{
/** 载入异常支持 */
require_once 'Typecho/Widget/Exception.php';
throw new Typecho_Widget_Exception(get_class($this) . ':' . __METHOD__, 500);
}
}

View File

@ -7,9 +7,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_PageNavigator */
require_once 'Typecho/Widget/Helper/PageNavigator.php';
/**
* 盒状分页样式
*

View File

@ -7,9 +7,6 @@
* @version $Id$
*/
/** Typecho_Widget_Helper_PageNavigator */
require_once 'Typecho/Widget/Helper/PageNavigator.php';
/**
* 经典分页样式
*