本文整理汇总了PHP中Request::getBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getBaseUrl方法的具体用法?PHP Request::getBaseUrl怎么用?PHP Request::getBaseUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::getBaseUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: baseUrl
public function baseUrl()
{
if ($this->_baseUrl === null) {
$this->_baseUrl = $this->_request->getBaseUrl();
}
return $this->_baseUrl;
}
示例2: match
/**
* Tries to match a URL path with a set of routes.
*
* If the matcher can not find information, it must throw one of the
* exceptions documented below.
*
* @param string $pathinfo The path info to be parsed (raw format, i.e. not
* urldecoded)
*
* @return array An array of parameters
*
* @throws ResourceNotFoundException If the resource could not be found
* @throws MethodNotAllowedException If the resource was found but the
* request method is not allowed
*/
public function match($pathinfo)
{
$urlMatcher = new UrlMatcher($this->routeCollection, $this->getContext());
$result = $urlMatcher->match($pathinfo);
if (!empty($result)) {
try {
// The route matches, now check if it actually exists
$result['content'] = $this->contentManager->findActiveBySlug($result['slug']);
} catch (NoResultException $e) {
try {
//is it directory index
if (substr($result['slug'], -1) == '/' || $result['slug'] == '') {
$result['content'] = $this->contentManager->findActiveBySlug($result['slug'] . 'index');
} else {
if ($this->contentManager->findActiveBySlug($result['slug'] . '/index')) {
$redirect = new RedirectResponse($this->request->getBaseUrl() . "/" . $result['slug'] . '/');
$redirect->sendHeaders();
exit;
}
}
} catch (NoResultException $ex) {
try {
$result['content'] = $this->contentManager->findActiveByAlias($result['slug']);
} catch (NoResultException $ex) {
throw new ResourceNotFoundException('No page found for slug ' . $pathinfo);
}
}
}
}
return $result;
}
示例3: getIconLocation
/**
* return the path to the icon for this type
* @return string
*/
function getIconLocation()
{
$baseUrl = Request::getBaseUrl() . '/lib/pkp/templates/images/icons/';
switch ($this->getAssocType()) {
case NOTIFICATION_TYPE_MONOGRAPH_SUBMITTED:
return $baseUrl . 'page_new.gif';
break;
case NOTIFICATION_TYPE_METADATA_MODIFIED:
case NOTIFICATION_TYPE_GALLEY_MODIFIED:
return $baseUrl . 'edit.gif';
break;
case NOTIFICATION_TYPE_SUBMISSION_COMMENT:
case NOTIFICATION_TYPE_LAYOUT_COMMENT:
case NOTIFICATION_TYPE_COPYEDIT_COMMENT:
case NOTIFICATION_TYPE_PROOFREAD_COMMENT:
case NOTIFICATION_TYPE_REVIEWER_COMMENT:
case NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT:
case NOTIFICATION_TYPE_EDITOR_DECISION_COMMENT:
case NOTIFICATION_TYPE_USER_COMMENT:
return $baseUrl . 'comment_new.gif';
break;
case NOTIFICATION_TYPE_PUBLISHED_MONOGRAPH:
return $baseUrl . 'list_world.gif';
break;
case NOTIFICATION_TYPE_NEW_ANNOUNCEMENT:
return $baseUrl . 'note_new.gif';
break;
default:
return $baseUrl . 'page_alert.gif';
}
}
示例4: send
public function send(Request $request)
{
$functionUrl = $request->getBaseUrl() . '/' . $request->getFunction();
if (count($request->getUrlParams()) > 0) {
$finalUrl = $functionUrl . '?' . http_build_query($request->getUrlParams());
} else {
$finalUrl = $functionUrl;
}
$ch = curl_init($finalUrl);
$headerArray = [];
foreach ($request->getHeaders() as $key => $value) {
$headerArray[] = ucfirst($key) . ': ' . $value;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$method = strtoupper($request->getMethod());
switch ($method) {
case "GET":
break;
case "POST":
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getParams());
break;
case "DELETE":
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
break;
case "PUT":
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request->getParams()));
break;
}
return json_decode(curl_exec($ch));
}
示例5: displayTemplateCallback
function displayTemplateCallback($hookName, $args)
{
$templateMgr =& $args[0];
$template =& $args[1];
if ($template != 'article/article.tpl') {
return false;
}
// Determine the query terms to use.
$queryVariableNames = array('q', 'p', 'ask', 'searchfor', 'key', 'query', 'search', 'keyword', 'keywords', 'qry', 'searchitem', 'kwd', 'recherche', 'search_text', 'search_term', 'term', 'terms', 'qq', 'qry_str', 'qu', 's', 'k', 't', 'va');
$this->queryTerms = array();
if (($referer = getenv('HTTP_REFERER')) == '') {
return false;
}
$urlParts = parse_url($referer);
if (!isset($urlParts['query'])) {
return false;
}
$queryArray = explode('&', $urlParts['query']);
foreach ($queryArray as $var) {
$varArray = explode('=', $var);
if (in_array($varArray[0], $queryVariableNames) && !empty($varArray[1])) {
$this->queryTerms += $this->parse_quote_string($varArray[1]);
}
}
if (empty($this->queryTerms)) {
return false;
}
$templateMgr->addStylesheet(Request::getBaseUrl() . '/' . $this->getPluginPath() . '/sehl.css');
$templateMgr->register_outputfilter(array(&$this, 'outputFilter'));
return false;
}
示例6: sign
public function sign(Request $request)
{
$currentHeaders = $request->getHeaders();
$signatureHeader = $this->getV1SignatureHeader($this->credentials->getPublicId(), base64_decode($this->credentials->getSecret()));
$currentHeaders['x-signature'] = $signatureHeader;
return new ApiRequest($request->getBaseUrl(), $request->getFunction(), $request->getUrlParams(), $request->getMethod(), $request->getParams(), $currentHeaders);
}
示例7: addTinyMCE
/**
* Add the tinyMCE script for editing sidebar blocks with a WYSIWYG editor
*/
function addTinyMCE()
{
$journalId = $this->journalId;
$plugin =& $this->plugin;
$templateMgr =& TemplateManager::getManager();
// Enable TinyMCE with specific params
$additionalHeadData = $templateMgr->get_template_vars('additionalHeadData');
import('classes.file.JournalFileManager');
$publicFileManager = new PublicFileManager();
$tinyMCE_script = '
<script language="javascript" type="text/javascript" src="' . Request::getBaseUrl() . '/' . TINYMCE_JS_PATH . '/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
plugins : "style,paste",
theme : "advanced",
theme_advanced_buttons1 : "formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink",
theme_advanced_buttons3 : "cut,copy,paste,pastetext,pasteword,|,cleanup,help,code,",
theme_advanced_toolbar_location : "bottom",
theme_advanced_toolbar_align : "left",
content_css : "' . Request::getBaseUrl() . '/styles/common.css",
relative_urls : false,
document_base_url : "' . Request::getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/",
extended_valid_elements : "span[*], div[*]"
});
</script>';
$templateMgr->assign('additionalHeadData', $additionalHeadData . "\n" . $tinyMCE_script);
}
示例8: getIconLocation
/**
* return the path to the icon for this type
* @return string
*/
function getIconLocation()
{
$baseUrl = Request::getBaseUrl() . '/lib/pkp/templates/images/icons/';
switch ($this->getAssocType()) {
case NOTIFICATION_TYPE_PAPER_SUBMITTED:
return $baseUrl . 'page_new.gif';
break;
case NOTIFICATION_TYPE_SUPP_FILE_MODIFIED:
case NOTIFICATION_TYPE_SUPP_FILE_ADDED:
return $baseUrl . 'page_attachment.gif';
break;
case NOTIFICATION_TYPE_METADATA_MODIFIED:
case NOTIFICATION_TYPE_GALLEY_MODIFIED:
return $baseUrl . 'edit.gif';
break;
case NOTIFICATION_TYPE_SUBMISSION_COMMENT:
case NOTIFICATION_TYPE_REVIEWER_COMMENT:
case NOTIFICATION_TYPE_REVIEWER_FORM_COMMENT:
case NOTIFICATION_TYPE_DIRECTOR_DECISION_COMMENT:
case NOTIFICATION_TYPE_USER_COMMENT:
return $baseUrl . 'comment_new.gif';
break;
case NOTIFICATION_TYPE_NEW_ANNOUNCEMENT:
return $baseUrl . 'note_new.gif';
break;
default:
return $baseUrl . 'page_alert.gif';
}
}
示例9: index
/**
* For public access:
* If no press is selected, display list of presses associated with this system.
* Otherwise, display the index page for the selected press.
*
* For private access (user is logged in):
* Display the dashboard.
*
* @param $args array
* @param $request Request
*/
function index($args, &$request)
{
$this->validate();
// FIXME: Replace with an authorization policy, see #6100.
// Get the requested press.
$router =& $request->getRouter();
$requestedPressPath = $router->getRequestedContextPath(&$request);
// No press requested: should we redirect to a specific press by default?
$pressDao =& DAORegistry::getDAO('PressDAO');
/* @var $pressDao PressDAO */
$site =& $request->getSite();
if ($requestedPressPath == 'index' && $site->getRedirect()) {
$press =& $pressDao->getPress($site->getRedirect());
} else {
$press =& $router->getContext($request);
}
// Check whether the press exists and identify the actual target press path.
if ($press && is_a($press, 'Press')) {
$targetPressPath = $press->getPath();
} else {
$targetPressPath = 'index';
}
// Is this a private access? Then redirect to the dashboard of the target press.
$user =& $request->getUser();
if (is_a($user, 'User')) {
$request->redirect($targetPressPath, 'dashboard');
return;
}
// Do we have to redirect to another target press?
if ($requestedPressPath != $targetPressPath && $targetPressPath != 'index') {
$request->redirect($targetPressPath);
return;
}
// This is a public request: set up the template.
$this->setupTemplate();
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('helpTopicId', 'user.home');
// If the request is for the site, display the overview page with all presses.
if ($targetPressPath == 'index') {
$templateMgr->assign('intro', $site->getLocalizedIntro());
$templateMgr->assign('pressFilesPath', Request::getBaseUrl() . '/' . Config::getVar('files', 'public_files_dir') . '/presses/');
$presses =& $pressDao->getEnabledPresses();
$templateMgr->assign_by_ref('presses', $presses);
$templateMgr->setCacheability(CACHEABILITY_PUBLIC);
$templateMgr->display('index/site.tpl');
} else {
// Assign header and content for home page.
$templateMgr->assign('displayPageHeaderTitle', $press->getPressPageHeaderTitle(true));
$templateMgr->assign('displayPageHeaderLogo', $press->getPressPageHeaderLogo(true));
$templateMgr->assign('additionalHomeContent', $press->getLocalizedSetting('additionalHomeContent'));
$templateMgr->assign('homepageImage', $press->getLocalizedSetting('homepageImage'));
$templateMgr->assign('pressDescription', $press->getLocalizedSetting('description'));
// Display creative commons logo/licence if enabled.
$templateMgr->assign('displayCreativeCommons', $press->getSetting('includeCreativeCommons'));
// Disable announcements if enabled.
$enableAnnouncements = $press->getSetting('enableAnnouncements');
$templateMgr->display('index/press.tpl');
}
}
示例10: activate
/**
* Activate the theme.
*/
function activate(&$templateMgr)
{
// Subclasses may override this function.
if (($stylesheetFilename = $this->getStylesheetFilename()) != null) {
$path = Request::getBaseUrl() . '/' . $this->getPluginPath() . '/' . $stylesheetFilename;
$templateMgr->addStyleSheet($path);
}
}
示例11: display
/**
* Display the form.
*/
function display()
{
$journalId = $this->journalId;
$plugin =& $this->plugin;
// Ensure upload file settings are reloaded when the form is displayed.
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('journalStyleSheet', $plugin->getSetting($journalId, 'externalFeedStyleSheet'));
$templateMgr->assign('defaultStyleSheetUrl', Request::getBaseUrl() . '/' . $plugin->getDefaultStyleSheetFile());
parent::display();
}
示例12: callbackDisplay
/**
* Template manager display hook callback to register smarty filters.
* @param $hookName string
* @param $args array
* @return boolean
*/
function callbackDisplay($hookName, $args)
{
$smarty = $args[0];
/* @var $smarty Smarty */
$additionalHeadData = $smarty->get_template_vars('additionalHeadData');
$pluginScriptImportString = '<script language="javascript" type="text/javascript" src="' . Request::getBaseUrl() . DIRECTORY_SEPARATOR . $this->getPluginPath() . DIRECTORY_SEPARATOR . 'js/modernThemeSiteHandler.js"></script>';
$googleFonts = "<link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz' rel='stylesheet' type='text/css' />" . "<link href='http://fonts.googleapis.com/css?family=Open+Sans:700,400' rel='stylesheet' type='text/css' />";
$smarty->assign('additionalHeadData', $pluginScriptImportString . $googleFonts);
$smarty->register_prefilter(array(&$this, 'addPluginSiteController'));
return false;
}
示例13: display
/**
* Display the form.
*/
function display()
{
import('file.PublicFileManager');
$site =& Request::getSite();
$schedConf =& Request::getSchedConf();
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('helpTopicId', 'conference.currentConferences.program');
$templateMgr->assign('publicSchedConfFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getSchedConfFilesPath($schedConf->getId()));
$templateMgr->assign('programFile', $schedConf->getSetting('programFile'));
parent::display();
}
示例14: display
function display()
{
$templateMgr =& TemplateManager::getManager();
$additionalHeadData = $templateMgr->get_template_vars('additionalHeadData');
$additionalHeadData .= '<script type="text/javascript" src="' . Request::getBaseUrl() . '/plugins/themes/custom/picker.js"></script>' . "\n";
$templateMgr->addStyleSheet(Request::getBaseUrl() . '/plugins/themes/custom/picker.css');
$templateMgr->assign('additionalHeadData', $additionalHeadData);
$stylesheetFileLocation = $this->plugin->getPluginPath() . '/' . $this->plugin->getStylesheetFilename();
$templateMgr->assign('canSave', is_writable($stylesheetFileLocation));
$templateMgr->assign('stylesheetFileLocation', $stylesheetFileLocation);
return parent::display();
}
示例15: requestAction
/**
* Returns a View object.
*
* @route GET /?method=example.request
* @route GET /example/request
*
* @param Request $request
* @return View
*/
public function requestAction($request)
{
$view = new View();
$view->setLayout('main');
$view->method = $request->getMethod();
$view->controller = $request->getController();
$view->action = $request->getAction();
$view->baseUrl = $request->getBaseUrl();
$view->urlPath = $request->getUrlPath();
$view->params = $request->getParams();
return $view;
}