本文整理汇总了PHP中Request::base方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::base方法的具体用法?PHP Request::base怎么用?PHP Request::base使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::base方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPublication
/**
* Return data on a publication view (this will be some form of HTML)
*
* @param object $publication
* @param string $option
* @param array $areas
* @param string $rtrn
* @param string $version
* @param boolean $extended
* @return array
*/
public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true)
{
$arr = array('html' => '', 'metadata' => '', 'name' => 'share');
// Hide if version not published
if (!$extended || in_array($publication->state, array(4, 5, 6))) {
return $arr;
}
$sef = Route::url('index.php?option=' . $option . '&id=' . $publication->id);
$sef = rtrim($sef, '/') . '/?v=' . $publication->version_number;
$url = Request::base() . ltrim($sef, '/');
$mediaUrl = Request::base() . trim($sef, '/') . '/' . $publication->version_id . '/Image:master';
// Incoming action
$sharewith = Request::getVar('sharewith', '');
if ($sharewith) {
if (!User::isGuest()) {
// Log the activity
Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'publication', 'scope_id' => $publication->id, 'description' => Lang::txt('PLG_PUBLICATIONS_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $publication->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $publication->title, 'url' => $sef, 'version' => $publication->version_number)], 'recipients' => [['publication', $publication->id], ['user', $publication->created_by], ['user', User::get('id')]]]);
}
return $this->share($sharewith, $url, $mediaUrl, $publication, $version);
}
// Build the HTML meant for the "about" tab's metadata overview
if ($rtrn == 'all' || $rtrn == 'metadata') {
// Instantiate a view
$view = $this->view('default', 'options')->set('option', $option)->set('publication', $publication)->set('version', $version)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
// Return the output
$arr['metadata'] = $view->loadTemplate();
}
return $arr;
}
示例2: getInput
/**
* Method to get the field input markup for a generic list.
* Use the multiple attribute to enable multiselect.
*
* @return string The field input markup.
*/
protected function getInput()
{
// Initialize variables.
$attributes = array('type' => 'text', 'value' => htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), 'name' => $this->name, 'id' => $this->id, 'size' => $this->element['size'] ? (int) $this->element['size'] : '', 'maxlength' => $this->element['maxlength'] ? (int) $this->element['maxlength'] : '', 'class' => 'orcid' . ($this->element['class'] ? (string) $this->element['class'] : ''), 'autocomplete' => (string) $this->element['autocomplete'] == 'off' ? 'off' : '', 'readonly' => (string) $this->element['readonly'] == 'true' ? 'readonly' : '', 'disabled' => (string) $this->element['disabled'] == 'true' ? 'disabled' : '', 'onchange' => $this->element['onchange'] ? (string) $this->element['onchange'] : '');
$attr = array();
foreach ($attributes as $key => $value) {
if ($key != 'value' && !$value) {
continue;
}
$attr[] = $key . '="' . $value . '"';
}
$attr = implode(' ', $attr);
$html = array();
$html[] = '<div class="grid">';
$html[] = ' <div class="col span9">';
$html[] = ' <input ' . $attr . ' placeholder="####-####-####-####" />';
$html[] = ' <input type="hidden" name="base_uri" id="base_uri" value="' . rtrim(Request::base(true), '/') . '" />';
$html[] = ' </div>';
$html[] = ' <div class="col span3 omega">';
$html[] = ' <a class="btn button icon-search orcid-fetch" data-base="' . rtrim(Request::base(true), '/') . '" data-id="' . $this->id . '" href="' . Request::base() . '/' . Route::url('index.php?option=com_members&controller=orcid') . '">' . Lang::txt('COM_MEMBERS_PROFILE_ORCID_FIND') . '</a>';
$html[] = ' </div>';
$html[] = '</div>';
$html[] = '<p><img src="' . Request::root() . '/core/components/com_members/site/assets/img/orcid-logo.png" width="80" alt="ORCID" /> ' . Lang::txt('COM_MEMBERS_PROFILE_ORCID_ABOUT') . '</p>';
Behavior::framework(true);
Behavior::modal();
if (file_exists(PATH_ROOT . '/core/components/com_members/site/assets/js/orcid.js')) {
Document::addScript('/core/components/com_members/site/assets/js/orcid.js?t=' . filemtime(PATH_ROOT . '/core/components/com_members/site/assets/js/orcid.js'));
}
return implode($html);
}
示例3: onResources
/**
* Return data on a resource view (this will be some form of HTML)
*
* @param object $resource Current resource
* @param string $option Name of the component
* @param array $areas Active area(s)
* @param string $rtrn Data to be returned
* @return array
*/
public function onResources($model, $option, $areas, $rtrn = 'all')
{
if (!$model->type->params->get('plg_share')) {
return;
}
$arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
$resource = $model->resource;
$sef = Route::url('index.php?option=com_resources&' . ($resource->alias ? 'alias=' . $resource->alias : 'id=' . $resource->id));
$url = Request::base() . ltrim($sef, '/');
// Incoming action
$sharewith = Request::getVar('sharewith', '');
if ($sharewith) {
// Log the activity
if (!User::isGuest()) {
Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'resource', 'scope_id' => $resource->id, 'description' => Lang::txt('PLG_RESOURCES_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $resource->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $resource->title, 'url' => $sef)], 'recipients' => [['resource', $resource->id], ['user', $resource->created_by], ['user', User::get('id')]]]);
}
// Email form
if ($sharewith == 'email') {
// Instantiate a view
$view = $this->view('email', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
// Return the output
$view->display();
exit;
}
return $this->share($sharewith, $url, $resource);
}
// Build the HTML meant for the "about" tab's metadata overview
if ($rtrn == 'all' || $rtrn == 'metadata') {
// Instantiate a view
$view = $this->view('default', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
// Return the output
$arr['metadata'] = $view->loadTemplate();
}
return $arr;
}
示例4: setTransactionDetails
/**
* Set transaction details
*
*/
public function setTransactionDetails($transactionDetails)
{
$this->transactionDetails = array();
$this->transactionDetails['EXT_TRANS_ID'] = $transactionDetails->info->tId;
$this->transactionDetails['EXT_TRANS_ID_LABEL'] = $this->options->transactionName;
$this->transactionDetails['AMT'] = $transactionDetails->info->tiTotal;
$this->transactionDetails['VALIDATION_KEY'] = $this->generateValidationKey();
$this->transactionDetails['SUCCESS_LINK'] = Request::base() . 'cart' . DS . 'order' . DS . 'complete?tId=' . $transactionDetails->token . '-' . $transactionDetails->info->tId;
}
示例5: displayTask
/**
* Pull records and build the XML
*
* @return void
*/
public function displayTask()
{
// Incoming
$metadata = Request::getVar('metadataPrefix', 'oai_dc');
$from = Request::getVar('from');
if ($from) {
$from = Date::of($from)->toSql();
}
$until = Request::getVar('until');
if ($until) {
$until = Date::of($until)->toSql();
}
$set = Request::getVar('set');
$resumption = Request::getVar('resumptionToken');
$igran = "YYYY-MM-DD";
$igran .= $this->config->get('gran', 'c') == 'c' ? "Thh:mm:ssZ" : '';
$hubname = rtrim($this->config->get('base_url', str_replace('https', 'http', \Request::base())), '/');
$edate = $this->config->get('edate');
$edate = $edate ? strtotime($edate) : time();
$service = new Service($metadata, rtrim(Request::getSchemeAndHttpHost(), '/') . Route::url('index.php?option=' . $this->_option . '&task=stylesheet&metadataPrefix=' . $metadata));
$service->set('metadataPrefix', $metadata)->set('repositoryName', $this->config->get('repository_name', \Config::get('sitename')))->set('baseURL', $hubname)->set('protocolVersion', '2.0')->set('adminEmail', $this->config->get('email', \Config::get('mailfrom')))->set('earliestDatestamp', gmdate('Y-m-d\\Th:i:s\\Z', $edate))->set('deletedRecord', $this->config->get('del'))->set('granularity', $igran)->set('max', $this->config->get('max', 500))->set('limit', $this->config->get('limig', 50))->set('allow_ore', $this->config->get('allow_ore', 0))->set('gran', $this->config->get('gran', 'c'))->set('resumption', $resumption);
$verb = Request::getVar('verb');
switch ($verb) {
case 'GetRecord':
$service->record(Request::getVar('identifier'));
break;
case 'Identify':
$service->identify();
break;
case 'ListMetadataFormats':
$service->formats();
break;
case 'ListIdentifiers':
$service->identifiers($from, $until, $set);
break;
case 'ListRecords':
$sessionTokenResumptionTemp = Session::get($resumption);
if (!empty($resumption) && empty($sessionTokenResumptionTemp)) {
$service->error($service::ERROR_BAD_RESUMPTION_TOKEN);
}
$service->records($from, $until, $set);
break;
case 'ListSets':
$sessionTokenResumptionTemp = Session::get($resumption);
if (!empty($resumption) && empty($sessionTokenResumptionTemp)) {
$service->error($service::ERROR_BAD_RESUMPTION_TOKEN);
}
$service->sets();
break;
default:
$service->error($service::ERROR_BAD_VERB, Lang::txt('COM_OAIPMH_ILLEGAL_VERB'));
break;
}
Document::setType('xml');
echo $service;
}
示例6: link
/**
* Returns the code for a link.
*
* @param string $url The URL.
* @param string $label The label.
* @param array $options Options for the URL code (class, title, etc).
*
* @return string
*/
public static function link($label, $url = null, array $attributes = array())
{
if ($label === null) {
$label = $url;
}
$url = Request::base(ltrim($url, '/'));
$attributes['href'] = str_replace('&', '&', $url);
$options = static::build_attributes($attributes);
return "<a {$options}>{$label}</a>";
}
示例7: render
/**
* Generate macro output
*
* @return string
*/
public function render()
{
$et = $this->args;
$live_site = rtrim(Request::base(), '/');
// What pages are we getting?
if ($et) {
$et = strip_tags($et);
// Get pages with a prefix
$sql = "SELECT * FROM `#__wiki_attachments` WHERE LOWER(filename) LIKE '" . strtolower($et) . "%' AND pageid='" . $this->pageid . "' ORDER BY created ASC";
} else {
// Get all pages
$sql = "SELECT * FROM `#__wiki_attachments` WHERE pageid='" . $this->pageid . "' ORDER BY created ASC";
}
// Perform query
$this->_db->setQuery($sql);
$rows = $this->_db->loadObjectList();
// Did we get a result from the database?
if ($rows) {
$config = Component::params('com_wiki');
if ($this->filepath != '') {
$config->set('filepath', $this->filepath);
}
$page = new \Components\Wiki\Models\Page($this->pageid);
if ($page->get('namespace') == 'help') {
$page->set('scope', $page->get('scope') ? rtrim($this->scope, '/') . '/' . ltrim($page->get('scope'), '/') : $this->scope);
$page->set('group_cn', $this->domain);
}
// Build and return the link
$html = '<ul>';
foreach ($rows as $row) {
$page->set('pagename', $page->get('pagename') . '/' . 'File:' . $row->filename);
$link = $page->link();
//$live_site . substr(PATH_APP, strlen(PATH_ROOT)) . DS . trim($config->get('filepath', '/site/wiki'), DS) . DS . $this->pageid . DS . $row->filename;
$fpath = PATH_APP . DS . trim($config->get('filepath', '/site/wiki'), DS) . DS . $this->pageid . DS . $row->filename;
$html .= '<li><a href="' . Route::url($link) . '">' . $row->filename . '</a> (' . (file_exists($fpath) ? \Hubzero\Utility\Number::formatBytes(filesize($fpath)) : '-- file not found --') . ') ';
$huser = User::getInstance($row->created_by);
if ($huser->get('id')) {
$html .= '- added by <a href="' . Route::url('index.php?option=com_members&id=' . $huser->get('id')) . '">' . stripslashes($huser->get('name')) . '</a> ';
}
if ($row->created && $row->created != '0000-00-00 00:00:00') {
$html .= Date::of($row->created)->relative() . '. ';
}
$html .= $row->description ? '<span>"' . stripslashes($row->description) . '"</span>' : '';
$html .= '</li>' . "\n";
}
$html .= '</ul>';
return $html;
} else {
// Return error message
//return '(TitleIndex('.$et.') failed)';
return '(No ' . $et . ' files to display)';
}
}
示例8: onGetIcons
/**
* This method is called when the Quick Icons module is constructing its set
* of icons. You can return an array which defines a single icon and it will
* be rendered right after the stock Quick Icons.
*
* @param $context The calling context
* @return array A list of icon definition associative arrays, consisting of the
* keys link, image, text and access.
*/
public function onGetIcons($context)
{
if ($context != $this->params->get('context', 'mod_quickicon') || !User::authorise('core.manage', 'com_installer')) {
return;
}
$cur_template = App::get('template')->template;
$ajax_url = Request::base() . 'index.php?option=com_installer&view=update&task=update.ajax';
$script = "\n\t\t\tvar plg_quickicon_joomlaupdate_ajax_url = '{$ajax_url}';\n\t\t\tvar plg_quickicon_jupdatecheck_jversion = '" . JVERSION . "';\n\t\t\tvar plg_quickicon_joomlaupdate_text = {\n\t\t\t\t'UPTODATE' : '" . Lang::txt('PLG_QUICKICON_JOOMLAUPDATE_UPTODATE', true) . "',\n\t\t\t\t'UPDATEFOUND' : '" . Lang::txt('PLG_QUICKICON_JOOMLAUPDATE_UPDATEFOUND', true) . "',\n\t\t\t\t'ERROR' : '" . Lang::txt('PLG_QUICKICON_JOOMLAUPDATE_ERROR', true) . "'\n\t\t\t};\n\t\t\tvar plg_quickicon_joomlaupdate_img = {\n\t\t\t\t'UPTODATE' : '" . Request::base(true) . '/templates/' . $cur_template . '/images/header/icon-48-jupdate-uptodate.png' . "',\n\t\t\t\t'ERROR': '" . Request::base(true) . '/templates/' . $cur_template . '/images/header/icon-48-deny.png' . "',\n\t\t\t\t'UPDATEFOUND': '" . Request::base(true) . '/templates/' . $cur_template . '/images/header/icon-48-jupdate-updatefound.png' . "'\n\t\t\t};";
$this->js($script);
$this->js('jupdatecheck.js');
return array(array('link' => 'index.php?option=com_joomlaupdate', 'image' => 'header/icon-48-download.png', 'text' => Lang::txt('PLG_QUICKICON_JOOMLAUPDATE_CHECKING'), 'id' => 'plg_quickicon_joomlaupdate'));
}
示例9: __construct
/**
* Constructor
*
* @param object $db
* @return void
* @throws Exception
*/
public function __construct($db = null)
{
if (!$db) {
$db = \App::get('db');
}
if (!$db instanceof \Hubzero\Database\Driver && !$db instanceof \JDatabase) {
throw new \Exception(\Lang::txt('Database must be of type JDatabase'), 500);
}
$this->database = $db;
if (is_null(self::$base)) {
self::$base = rtrim(\Request::base(), '/');
}
}
示例10: onGetIcons
/**
* Returns an icon definition for an icon which looks for extensions updates
* via AJAX and displays a notification when such updates are found.
*
* @param $context The calling context
*
* @return array A list of icon definition associative arrays, consisting of the
* keys link, image, text and access.
*
* @since 2.5
*/
public function onGetIcons($context)
{
if ($context != $this->params->get('context', 'mod_quickicon') || !User::authorise('core.manage', 'com_installer')) {
return;
}
$cur_template = App::get('template')->template;
$ajax_url = Request::base() . 'index.php?option=com_installer&view=update&task=update.ajax';
$script = "var plg_quickicon_extensionupdate_ajax_url = '{$ajax_url}';\n";
$script .= 'var plg_quickicon_extensionupdate_text = {"UPTODATE" : "' . Lang::txt('PLG_QUICKICON_EXTENSIONUPDATE_UPTODATE', true) . '", "UPDATEFOUND": "' . Lang::txt('PLG_QUICKICON_EXTENSIONUPDATE_UPDATEFOUND', true) . '", "ERROR": "' . Lang::txt('PLG_QUICKICON_EXTENSIONUPDATE_ERROR', true) . "\"};\n";
$this->js($script);
$this->js('extensionupdatecheck.js');
return array(array('link' => 'index.php?option=com_installer&view=update', 'image' => 'header/icon-48-extension.png', 'text' => Lang::txt('PLG_QUICKICON_EXTENSIONUPDATE_CHECKING'), 'id' => 'plg_quickicon_extensionupdate'));
}
示例11: _checkRules
/**
* Check if the current URL is one of the set rules
*
* @return boolean True if the current page is a rule
*/
private function _checkRules()
{
if (!$this->_path) {
$this->_path = $this->_parseQueryString(str_replace(\Request::base(), '', \Request::current()));
}
$defs = str_replace("\r", '', $this->params->def('definitions', ''));
$defs = explode("\n", $defs);
foreach ($defs as $def) {
$result = $this->_parseQueryString($def);
if ($result == $this->_path) {
return true;
}
}
return false;
}
示例12: onResources
/**
* Return data on a resource view (this will be some form of HTML)
*
* @param object $resource Current resource
* @param string $option Name of the component
* @param array $areas Active area(s)
* @param string $rtrn Data to be returned
* @return array
*/
public function onResources($model, $option, $areas, $rtrn = 'all')
{
$arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
// Check if our area is in the array of areas we want to return results for
if (is_array($areas)) {
if (!array_intersect($areas, $this->onResourcesAreas($model)) && !array_intersect($areas, array_keys($this->onResourcesAreas($model)))) {
// do nothing
return $arr;
}
}
// Instantiate a view
$view = $this->view('default', 'browse')->set('option', $option)->set('model', $model)->set('live_site', rtrim(Request::base(), '/'));
// Return the output
$arr['html'] = $view->loadTemplate();
return $arr;
}
示例13: configs
/**
* Set DOI service configs
*
* @param mixed $idx Index value
* @return array
*/
public function configs()
{
if (empty($this->_configs)) {
$params = Component::params('com_publications');
$configs = new stdClass();
$configs->shoulder = $params->get('doi_shoulder');
$configs->service = trim($params->get('doi_service'), DS);
$configs->prefix = $params->get('doi_prefix');
$configs->userpw = $params->get('doi_userpw');
$configs->publisher = $params->get('doi_publisher', Config::get('sitename'));
$configs->livesite = trim(Request::base(), DS);
$configs->xmlSchema = trim($params->get('doi_xmlschema', 'http://schema.datacite.org/meta/kernel-2.1/metadata.xsd'), DS);
$this->_configs = $configs;
}
return $this->_configs;
}
示例14: onResources
/**
* Return data on a resource view (this will be some form of HTML)
*
* @param object $resource Current resource
* @param string $option Name of the component
* @param array $areas Active area(s)
* @param string $rtrn Data to be returned
* @return array
*/
public function onResources($model, $option, $areas, $rtrn = 'all')
{
if (!$model->type->params->get('plg_share')) {
return;
}
$arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
$sef = Route::url('index.php?option=' . $option . '&id=' . $model->resource->id);
$url = Request::base() . ltrim($sef, '/');
// Incoming action
$sharewith = Request::getVar('sharewith', '');
if ($sharewith && $sharewith != 'email') {
$this->share($sharewith, $url, $model->resource);
return;
}
// Email form
if ($sharewith == 'email') {
// Instantiate a view
$view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'options', 'layout' => 'email'));
// Pass the view some info
$view->option = $option;
$view->resource = $model->resource;
$view->_params = $this->params;
$view->url = $url;
foreach ($this->getErrors() as $error) {
$view->setError($error);
}
// Return the output
$view->display();
exit;
}
// Build the HTML meant for the "about" tab's metadata overview
if ($rtrn == 'all' || $rtrn == 'metadata') {
// Instantiate a view
$view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'options'));
// Pass the view some info
$view->option = $option;
$view->resource = $model->resource;
$view->_params = $this->params;
$view->url = $url;
foreach ($this->getErrors() as $error) {
$view->setError($error);
}
// Return the output
$arr['metadata'] = $view->loadTemplate();
}
return $arr;
}
示例15: render
/**
* Generate macro output
*
* @return string
*/
public function render()
{
$et = $this->args;
$live_site = rtrim(Request::base(), '/');
// Get resource by ID
$attach = \Components\Wiki\Models\Attachment::all()->whereEquals('page_id', $this->pageid);
if ($et) {
$et = strip_tags($et);
$attach->whereLike('filename', strtolower($et) . '%');
}
$rows = $attach->rows();
// Did we get a result from the database?
if ($rows) {
$config = Component::params('com_wiki');
if ($this->filepath != '') {
$config->set('filepath', $this->filepath);
}
$page = \Components\Wiki\Models\Page::oneOrFail($this->pageid);
if ($page->get('namespace') == 'help') {
$page->set('path', $page->get('path') ? rtrim($this->scope, '/') . '/' . ltrim($page->get('path'), '/') : $this->scope);
}
// Build and return the link
$html = '<ul>';
foreach ($rows as $row) {
$page->set('pagename', $page->get('pagename') . '/' . 'File:' . $row->get('filename'));
$link = $page->link();
$fpath = $row->filespace() . DS . $this->pageid . DS . $row->get('filename');
$html .= '<li><a href="' . Route::url($link) . '">' . $row->get('filename') . '</a> (' . (file_exists($fpath) ? \Hubzero\Utility\Number::formatBytes(filesize($fpath)) : '-- file not found --') . ') ';
$huser = $row->creator();
if ($huser->get('id')) {
$html .= '- added by <a href="' . Route::url('index.php?option=com_members&id=' . $huser->get('id')) . '">' . stripslashes($huser->get('name')) . '</a> ';
}
if ($row->get('created') && $row->get('created') != '0000-00-00 00:00:00') {
$html .= Date::of($row->get('created'))->relative() . '. ';
}
$html .= $row->get('description') ? '<span>"' . stripslashes($row->get('description')) . '"</span>' : '';
$html .= '</li>' . "\n";
}
$html .= '</ul>';
return $html;
}
// Return error message
return '(No ' . $et . ' files to display)';
}