- 论坛徽章:
- 0
|
<?php
class WP {
var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's',
'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year',
'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id',
'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
var $extra_query_vars = array();
var $query_vars;
var $query_string;
var $request;
var $matched_rule;
var $matched_query;
var $did_permalink = false;
function add_query_var($qv)
{
$this->public_query_vars[] = $qv;
}
//*query_vars 这个属性 是用来查询数据库用的。。
//add 方法也是用来 添加 查询数据库的属性的。。。
function parse_request($extra_query_vars = '') {
global $wp_rewrite;
$this->query_vars = array();
//属性query_vars 数据类型 赋值为数组。。。。。。。。。。。。
if ( is_array($extra_query_vars) )
$this->extra_query_vars = & $extra_query_vars;
//对extra_query_vars 属性 赋值。。。。
else if (! empty($extra_query_vars))
parse_str($extra_query_vars, $this->extra_query_vars);
//判断是否空值,--》把extra_query_vars 拆解。
// Process PATH_INFO, REQUEST_URI, and 404 for permalinks. //处理 PATH_INFO, REQUEST_URI,404 。
// Fetch the rewrite rules. //获取 rewrite rule。。。。
$rewrite = $wp_rewrite->wp_rewrite_rules(); //wp_rewritebu没有被定义为不是对象。。。怎么回事呢。。。?
________________________________________________________________________________________________________
//不定义直接 用一个属性 did_permalink ,并且数据类型为:boolean。
if (! empty($rewrite)) {
// If we match a rewrite rule, this will be cleared.
$error = '404';
$this->did_permalink = true;
//路径问题。
if ( isset($_SERVER['PATH_INFO']) )
$pathinfo = $_SERVER['PATH_INFO'];
else
$pathinfo = '';
$pathinfo_array = explode('?', $pathinfo);
$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
$req_uri = $_SERVER['REQUEST_URI'];
$req_uri_array = explode('?', $req_uri);
$req_uri = $req_uri_array[0];
$self = $_SERVER['PHP_SELF'];
$home_path = parse_url(get_option('home'));
if ( isset($home_path['path']) )
$home_path = $home_path['path'];
else
$home_path = '';
$home_path = trim($home_path, '/');
// Trim path info from the end and the leading home path from the 修整 路径的后面部分和从父路径部分,
// front. For path info requests, this leaves us with the requesting 对于路径信息的请求,留下了请求的文件名。
// filename, if any. For 404 requests, this leaves us with the 对于 404 ,留下链接的信息。
// requested permalink.
$req_uri = str_replace($pathinfo, '', $req_uri);
$req_uri = trim($req_uri, '/');
$req_uri = preg_replace("|^$home_path|", '', $req_uri);
$req_uri = trim($req_uri, '/');
$pathinfo = trim($pathinfo, '/');
$pathinfo = preg_replace("|^$home_path|", '', $pathinfo);
$pathinfo = trim($pathinfo, '/');
$self = trim($self, '/');
$self = preg_replace("|^$home_path|", '', $self);
$self = str_replace($home_path, '', $self);
$self = trim($self, '/');
// The requested permalink is in $pathinfo for path info requests and 对于path info请求,请求的链接在$pathinfo,对于other请求,请求的链接在$req_uri.
// $req_uri for other requests.
if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) //。。。。。。。。。。。。。正则表达式的函数
{
$request = $pathinfo;
} else
{
// If the request uri is the index, blank it out so that we don't try to match it against a rule.//如果请求的uri是索引的话,那么我们就删除他,避免和规则匹配。
if ( $req_uri == $wp_rewrite->index ) //不解。。。。。$wp_rewrite不是对象。。。怎么的。。。
________________________________________________________________________________________________________
$req_uri = '';
$request = $req_uri;
}
.
.
.
.
.
.
.
加线的部分都是不懂的了,请朋友们为小弟指点一下了。。。
[ 本帖最后由 je1024 于 2007-8-30 15:02 编辑 ] |
|