本文整理汇总了PHP中qa_get_request_map函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_get_request_map函数的具体用法?PHP qa_get_request_map怎么用?PHP qa_get_request_map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_get_request_map函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: qa_has_custom_home
function qa_has_custom_home()
{
return qa_opt('show_custom_home') || array_search('', qa_get_request_map()) !== false;
}
示例2: qa_admin_is_slug_reserved
function qa_admin_is_slug_reserved($requestpart)
{
$requestpart = trim(strtolower($requestpart));
$routing = qa_page_routing();
if (isset($routing[$requestpart]) || isset($routing[$requestpart . '/']) || is_numeric($requestpart)) {
return true;
}
$pathmap = qa_get_request_map();
foreach ($pathmap as $mappedrequest) {
if (trim(strtolower($mappedrequest)) == $requestpart) {
return true;
}
}
switch ($requestpart) {
case '':
case 'qa':
case 'feed':
case 'install':
case 'url':
case 'image':
case 'ajax':
return true;
}
$pagemodules = qa_load_modules_with('page', 'match_request');
foreach ($pagemodules as $pagemodule) {
if ($pagemodule->match_request($requestpart)) {
return true;
}
}
return false;
}
示例3: qa_path
function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
if (!isset($neaturls)) {
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
$neaturls = qa_opt('neat_urls');
}
if (!isset($rooturl)) {
$rooturl = qa_path_to_root();
}
$url = $rooturl . (empty($rooturl) || substr($rooturl, -1) == '/' ? '' : '/');
$paramsextra = '';
$requestparts = explode('/', $request);
$pathmap = qa_get_request_map();
if (isset($pathmap[$requestparts[0]])) {
$newpart = $pathmap[$requestparts[0]];
if (strlen($newpart)) {
$requestparts[0] = $newpart;
} elseif (count($requestparts) == 1) {
array_shift($requestparts);
}
}
foreach ($requestparts as $index => $requestpart) {
$requestparts[$index] = urlencode($requestpart);
}
$requestpath = implode('/', $requestparts);
switch ($neaturls) {
case QA_URL_FORMAT_INDEX:
if (!empty($request)) {
$url .= 'index.php/' . $requestpath;
}
break;
case QA_URL_FORMAT_NEAT:
$url .= $requestpath;
break;
case QA_URL_FORMAT_PARAM:
if (!empty($request)) {
$paramsextra = '?qa=' . $requestpath;
}
break;
default:
$url .= 'index.php';
case QA_URL_FORMAT_PARAMS:
if (!empty($request)) {
foreach ($requestparts as $partindex => $requestpart) {
$paramsextra .= (strlen($paramsextra) ? '&' : '?') . 'qa' . ($partindex ? '_' . $partindex : '') . '=' . $requestpart;
}
}
break;
}
if (isset($params)) {
foreach ($params as $key => $value) {
$paramsextra .= (strlen($paramsextra) ? '&' : '?') . urlencode($key) . '=' . urlencode((string) $value);
}
}
return $url . $paramsextra . (empty($anchor) ? '' : '#' . urlencode($anchor));
}
示例4: qa_index_set_request
function qa_index_set_request()
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$relativedepth = 0;
if (isset($_GET['qa-rewrite'])) {
// URLs rewritten by .htaccess
$urlformat = QA_URL_FORMAT_NEAT;
$requestparts = explode('/', qa_gpc_to_string($_GET['qa-rewrite']));
unset($_GET['qa-rewrite']);
if (!empty($_SERVER['REQUEST_URI'])) {
// workaround for the fact that Apache unescapes characters while rewriting
$origpath = $_SERVER['REQUEST_URI'];
$_GET = array();
$questionpos = strpos($origpath, '?');
if (is_numeric($questionpos)) {
$params = explode('&', substr($origpath, $questionpos + 1));
foreach ($params as $param) {
if (preg_match('/^([^\\=]*)(\\=(.*))?$/', $param, $matches)) {
$argument = strtr(urldecode($matches[1]), '.', '_');
// simulate PHP's $_GET behavior
$_GET[$argument] = qa_string_to_gpc(urldecode(@$matches[3]));
}
}
$origpath = substr($origpath, 0, $questionpos);
}
// Generally we assume that $_GET['qa-rewrite'] has the right path depth, but this won't be the case if there's
// a & or # somewhere in the middle of the path, due to apache unescaping. So we make a special case for that.
$keepparts = count($requestparts);
$requestparts = explode('/', urldecode($origpath));
// new request calculated from $_SERVER['REQUEST_URI']
for ($part = count($requestparts) - 1; $part >= 0; $part--) {
if (is_numeric(strpos($requestparts[$part], '&')) || is_numeric(strpos($requestparts[$part], '#'))) {
$keepparts += count($requestparts) - $part - 1;
// this is how many parts we lost
break;
}
}
$requestparts = array_slice($requestparts, -$keepparts);
// remove any irrelevant parts from the beginning
}
$relativedepth = count($requestparts);
} elseif (isset($_GET['qa'])) {
if (strpos($_GET['qa'], '/') === false) {
$urlformat = empty($_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], '/index.php') !== false ? QA_URL_FORMAT_SAFEST : QA_URL_FORMAT_PARAMS;
$requestparts = array(qa_gpc_to_string($_GET['qa']));
for ($part = 1; $part < 10; $part++) {
if (isset($_GET['qa_' . $part])) {
$requestparts[] = qa_gpc_to_string($_GET['qa_' . $part]);
unset($_GET['qa_' . $part]);
}
}
} else {
$urlformat = QA_URL_FORMAT_PARAM;
$requestparts = explode('/', qa_gpc_to_string($_GET['qa']));
}
unset($_GET['qa']);
} else {
$phpselfunescaped = strtr($_SERVER['PHP_SELF'], '+', ' ');
// seems necessary, and plus does not work with this scheme
$indexpath = '/index.php/';
$indexpos = strpos($phpselfunescaped, $indexpath);
if (is_numeric($indexpos)) {
$urlformat = QA_URL_FORMAT_INDEX;
$requestparts = explode('/', substr($phpselfunescaped, $indexpos + strlen($indexpath)));
$relativedepth = 1 + count($requestparts);
} else {
$urlformat = null;
// at home page so can't identify path type
$requestparts = array();
}
}
foreach ($requestparts as $part => $requestpart) {
// remove any blank parts
if (!strlen($requestpart)) {
unset($requestparts[$part]);
}
}
reset($requestparts);
$key = key($requestparts);
$replacement = array_search(@$requestparts[$key], qa_get_request_map());
if ($replacement !== false) {
$requestparts[$key] = $replacement;
}
qa_set_request(implode('/', $requestparts), $relativedepth > 1 ? str_repeat('../', $relativedepth - 1) : './', $urlformat);
}
示例5: qa_index_set_request
function qa_index_set_request()
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$relativedepth = 0;
if (isset($_GET['qa-rewrite'])) {
// URLs rewritten by .htaccess
$urlformat = QA_URL_FORMAT_NEAT;
$requestparts = explode('/', qa_gpc_to_string($_GET['qa-rewrite']));
unset($_GET['qa-rewrite']);
$relativedepth = count($requestparts);
// Workaround for fact that Apache unescapes characters while rewriting, based on assumption that $_GET['qa-rewrite'] has
// right path depth, which is true do long as there are only escaped characters in the last part of the path
if (!empty($_SERVER['REQUEST_URI'])) {
$origpath = $_SERVER['REQUEST_URI'];
$_GET = array();
$questionpos = strpos($origpath, '?');
if (is_numeric($questionpos)) {
$params = explode('&', substr($origpath, $questionpos + 1));
foreach ($params as $param) {
if (preg_match('/^([^\\=]*)(\\=(.*))?$/', $param, $matches)) {
$_GET[urldecode($matches[1])] = qa_string_to_gpc(urldecode(@$matches[3]));
}
}
$origpath = substr($origpath, 0, $questionpos);
}
$requestparts = array_slice(explode('/', urldecode($origpath)), -count($requestparts));
}
} elseif (isset($_GET['qa'])) {
if (strpos($_GET['qa'], '/') === false) {
$urlformat = empty($_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], '/index.php') !== false ? QA_URL_FORMAT_SAFEST : QA_URL_FORMAT_PARAMS;
$requestparts = array(qa_gpc_to_string($_GET['qa']));
for ($part = 1; $part < 10; $part++) {
if (isset($_GET['qa_' . $part])) {
$requestparts[] = qa_gpc_to_string($_GET['qa_' . $part]);
unset($_GET['qa_' . $part]);
}
}
} else {
$urlformat = QA_URL_FORMAT_PARAM;
$requestparts = explode('/', qa_gpc_to_string($_GET['qa']));
}
unset($_GET['qa']);
} else {
$phpselfunescaped = strtr($_SERVER['PHP_SELF'], '+', ' ');
// seems necessary, and plus does not work with this scheme
$indexpath = '/index.php/';
$indexpos = strpos($phpselfunescaped, $indexpath);
if (is_numeric($indexpos)) {
$urlformat = QA_URL_FORMAT_INDEX;
$requestparts = explode('/', substr($phpselfunescaped, $indexpos + strlen($indexpath)));
$relativedepth = 1 + count($requestparts);
} else {
$urlformat = null;
// at home page so can't identify path type
$requestparts = array();
}
}
foreach ($requestparts as $part => $requestpart) {
// remove any blank parts
if (!strlen($requestpart)) {
unset($requestparts[$part]);
}
}
reset($requestparts);
$key = key($requestparts);
$replacement = array_search(@$requestparts[$key], qa_get_request_map());
if ($replacement !== false) {
$requestparts[$key] = $replacement;
}
qa_set_request(implode('/', $requestparts), $relativedepth > 1 ? str_repeat('../', $relativedepth - 1) : './', $urlformat);
}
示例6: qa_content_prepare
function qa_content_prepare($voting = false, $categoryids = null)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
global $qa_template, $qa_page_error_html;
if (QA_DEBUG_PERFORMANCE) {
global $qa_usage;
$qa_usage->mark('control');
}
$request = qa_request();
$requestlower = qa_request();
$navpages = qa_db_get_pending_result('navpages');
$widgets = qa_db_get_pending_result('widgets');
if (isset($categoryids) && !is_array($categoryids)) {
// accept old-style parameter
$categoryids = array($categoryids);
}
$lastcategoryid = count($categoryids) ? end($categoryids) : null;
$charset = 'utf-8';
$qa_content = array('content_type' => 'text/html; charset=' . $charset, 'charset' => $charset, 'direction' => qa_opt('site_text_direction'), 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array());
// add meta description if we're on the home page
if ($request === '' || $request === array_search('', qa_get_request_map())) {
$qa_content['description'] = qa_html(qa_opt('home_description'));
}
if (qa_opt('show_custom_in_head')) {
$qa_content['head_lines'][] = qa_opt('custom_in_head');
}
if (qa_opt('show_custom_header')) {
$qa_content['body_header'] = qa_opt('custom_header');
}
if (qa_opt('show_custom_footer')) {
$qa_content['body_footer'] = qa_opt('custom_footer');
}
if (isset($categoryids)) {
$qa_content['categoryids'] = $categoryids;
}
foreach ($navpages as $page) {
if ($page['nav'] == 'B') {
qa_navigation_add_page($qa_content['navigation']['main'], $page);
}
}
if (qa_opt('nav_home') && qa_opt('show_custom_home')) {
$qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home'));
}
if (qa_opt('nav_activity')) {
$qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity'));
}
$hascustomhome = qa_has_custom_home();
if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) {
$qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa'));
}
if (qa_opt('nav_questions')) {
$qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs'));
}
if (qa_opt('nav_hot')) {
$qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot'));
}
if (qa_opt('nav_unanswered')) {
$qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered'));
}
if (qa_using_tags() && qa_opt('nav_tags')) {
$qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags'), 'selected_on' => array('tags$', 'tag/'));
}
if (qa_using_categories() && qa_opt('nav_categories')) {
$qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories'), 'selected_on' => array('categories$', 'categories/'));
}
if (qa_opt('nav_users')) {
$qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users'), 'selected_on' => array('users$', 'users/', 'user/'));
}
// Only the 'level' permission error prevents the menu option being shown - others reported on qa-page-ask.php
if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') {
$qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask'));
}
if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN || !qa_user_maximum_permit_error('permit_moderate') || !qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')) {
$qa_content['navigation']['main']['admin'] = array('url' => qa_path_html('admin'), 'label' => qa_lang_html('main/nav_admin'), 'selected_on' => array('admin/'));
}
$qa_content['search'] = array('form_tags' => 'method="get" action="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'name="q"', 'button_label' => qa_lang_html('main/search_button'));
if (!qa_opt('feedback_enabled')) {
unset($qa_content['navigation']['footer']['feedback']);
}
foreach ($navpages as $page) {
if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') {
qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page);
}
}
$regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side');
$placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom');
foreach ($widgets as $widget) {
if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) {
// see if it has been selected for display on this template
$region = @$regioncodes[substr($widget['place'], 0, 1)];
$place = @$placecodes[substr($widget['place'], 1, 2)];
if (isset($region) && isset($place)) {
// check region/place codes recognized
$module = qa_load_module('widget', $widget['title']);
if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template(substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) {
$qa_content['widgets'][$region][$place][] = $module;
}
//.........这里部分代码省略.........