本文整理汇总了PHP中Gdn_Url::Request方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Url::Request方法的具体用法?PHP Gdn_Url::Request怎么用?PHP Gdn_Url::Request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Url
的用法示例。
在下文中一共展示了Gdn_Url::Request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ActivityController_Render_Before
public function ActivityController_Render_Before(&$Sender)
{
$Session = Gdn::Session();
if (!$Session->CheckPermission('Plugins.Privacy.Activity')) {
if (!$Session->IsValid()) {
Redirect(Gdn::Authenticator()->SignInUrl(Gdn_Url::Request()));
} else {
Redirect(Gdn::Config('Routes.DefaultPermission'));
}
}
}
示例2: _AnalyzeRequest
/**
* Parses the query string looking for supplied request parameters. Places
* anything useful into this object's Controller properties.
*
* @param int $FolderDepth
* @todo $folderDepth needs a description.
*/
protected function _AnalyzeRequest($FolderDepth = 2)
{
// Here are some examples of what this method could/would receive:
// /application/controllergroup/controller/method/argn
// /controllergroup/controller/method/argn
// /application/controllergroup/controller/argn
// /controllergroup/controller/argn
// /controllergroup/controller
// /application/controller/method/argn
// /controller/method/argn
// /application/controller/argn
// /controller/argn
// /controller
// Clear the slate
$this->_ApplicationFolder = '';
$this->_ControllerFolder = '';
$this->_ControllerName = '';
$this->_ControllerMethod = 'index';
$this->_ControllerMethodArgs = array();
// Retrieve and parse the request
if ($this->Request == '') {
$this->Request = Gdn_Url::Request();
$Prefix = strtolower(substr($this->Request, 0, strpos($this->Request, '/')));
switch ($Prefix) {
case 'rss':
$this->_SyndicationMethod = SYNDICATION_RSS;
$this->Request = substr($this->Request, 4);
break;
case 'atom':
$this->_SyndicationMethod = SYNDICATION_ATOM;
$this->Request = substr($this->Request, 5);
break;
default:
$this->_SyndicationMethod = SYNDICATION_NONE;
break;
}
}
if ($this->Request == '') {
$this->Request = $this->Routes['DefaultController'];
}
// Check for re-routing
// Is there a literal match?
if (isset($this->Routes[$this->Request])) {
$this->Request = $this->Routes[$this->Request];
} else {
// Check for other matching custom routes
foreach ($this->Routes as $Route => $Destination) {
// Check for wild-cards
$Route = str_replace(array(':alphanum', ':num'), array('.+', '[0-9]+'), $Route);
// Check for a match
if (preg_match('#^' . $Route . '$#', $this->Request)) {
// Do we have a back-reference?
if (strpos($Destination, '$') !== FALSE && strpos($this->Request, '(') !== FALSE) {
$Destination = preg_replace('#^' . $Route . '$#', $Destination, $this->Request);
}
$this->Request = $Destination;
}
}
}
$Parts = explode('/', $this->Request);
$Length = count($Parts);
if ($Length == 1 || $FolderDepth <= 0) {
$FolderDepth = 0;
$this->_ControllerName = $Parts[0];
$this->_MapParts($Parts, 0);
$this->_FetchController(TRUE);
// Throw an error if this fails because there's nothing else to check
} else {
if ($Length == 2) {
// Force a depth of 1 because only one of the two url parts can be a folder.
$FolderDepth = 1;
}
}
if ($FolderDepth == 2) {
// print_r($Parts);
// echo $Parts[1];
$this->_ApplicationFolder = $Parts[0];
$this->_ControllerFolder = $Parts[1];
$this->_MapParts($Parts, 2);
if (!$this->_FetchController()) {
// echo '<div>Failed. AppFolder: '.$this->_ApplicationFolder.'; Cont Folder: '.$this->_ControllerFolder.'; Cont: '.$this->_ControllerName.';</div>';
$this->_AnalyzeRequest(1);
}
} else {
if ($FolderDepth == 1) {
// Try the application folder first
$Found = FALSE;
if (in_array($Parts[0], $this->EnabledApplicationFolders())) {
// Check to see if the first part is an application
$this->_ApplicationFolder = $Parts[0];
$this->_MapParts($Parts, 1);
$Found = $this->_FetchController();
}
//.........这里部分代码省略.........
示例3: WriteActivityComment
function WriteActivityComment($Comment, &$Sender, &$Session)
{
?>
<li id="Activity_<?php
echo $Comment->ActivityID;
?>
" class="<?php
echo $Comment->ActivityType;
?>
"><?php
if ($Comment->ActivityPhoto != '') {
if ($Comment->InsertUserID == $Session->UserID) {
echo '<a href="' . Url('/garden/profile/' . urlencode($Comment->ActivityName)) . '">' . $Sender->Html->Image('uploads/n' . $Comment->ActivityPhoto) . '</a>';
} else {
echo $Sender->Html->Image('uploads/n' . $Comment->ActivityPhoto);
}
}
?>
<h3><?php
echo $Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete') ? Anchor('Delete', 'garden/activity/delete/' . $Comment->ActivityID . '/' . $Session->TransientKey() . '?Return=' . urlencode(Gdn_Url::Request()), 'Delete') : '';
?>
<strong><?php
echo Format::ActivityHeadline($Comment, $Sender->ProfileUserID);
?>
<em><?php
echo Format::Date($Comment->DateInserted);
?>
</em></strong></h3>
<blockquote><?php
echo Format::Display($Comment->Story);
?>
</blockquote>
</li>
<?php
}
示例4: RemoteSignOutUrl
public function RemoteSignOutUrl()
{
$Session = Gdn::Session();
$Url = sprintf($this->_SignOutUrl, urlencode(Gdn_Url::Request()));
$Url = str_replace('{Session_TransientKey}', $Session->TransientKey(), $Url);
return $Url;
}
示例5: CombinePaths
// This header is redundantly set in the controller.
//header('X-Garden-Version: '.APPLICATION.' '.APPLICATION_VERSION);
Gdn::FactoryInstall(Gdn::AliasCache, 'Gdn_Cache', CombinePaths(array(PATH_LIBRARY_CORE, 'class.cache.php')), Gdn::FactoryRealSingleton, 'Initialize');
// Default request object
Gdn::FactoryInstall(Gdn::AliasRequest, 'Gdn_Request', PATH_LIBRARY . DS . 'core' . DS . 'class.request.php', Gdn::FactoryRealSingleton, 'Create');
Gdn::Request()->FromEnvironment();
/// Load the configurations for the installed items.
$Gdn_EnabledApplications = Gdn::Config('EnabledApplications', array());
foreach ($Gdn_EnabledApplications as $ApplicationName => $ApplicationFolder) {
$Gdn_Config->Load(PATH_APPLICATIONS . DS . $ApplicationFolder . DS . 'settings' . DS . 'configuration.php', 'Use');
}
/// Load the custom configurations again so that application setting defaults are overridden.
$Gdn_Config->Load(PATH_CONF . DS . 'config.php', 'Use');
unset($Gdn_Config);
// Redirect to the setup screen if Dashboard hasn't been installed yet.
if (!Gdn::Config('Garden.Installed', FALSE) && strpos(Gdn_Url::Request(), 'setup') === FALSE) {
header('location: ' . Gdn::Request()->Url('dashboard/setup', TRUE));
exit;
}
/// Install some of the services.
// Default database.
Gdn::FactoryInstall(Gdn::AliasDatabase, 'Gdn_Database', PATH_LIBRARY . DS . 'database' . DS . 'class.database.php', Gdn::FactorySingleton, array('Database'));
// Database drivers.
Gdn::FactoryInstall('MySQLDriver', 'Gdn_MySQLDriver', PATH_LIBRARY . DS . 'database' . DS . 'class.mysql.driver.php', Gdn::FactoryInstance);
Gdn::FactoryInstall('MySQLStructure', 'Gdn_MySQLStructure', PATH_LIBRARY . DS . 'database' . DS . 'class.mysql.structure.php', Gdn::FactoryInstance);
// Form class
Gdn::FactoryInstall('Form', 'Gdn_Form', PATH_LIBRARY . DS . 'core' . DS . 'class.form.php', Gdn::FactoryInstance);
// Identity, Authenticator & Session.
Gdn::FactoryInstall('Identity', 'Gdn_CookieIdentity', PATH_LIBRARY_CORE . DS . 'class.cookieidentity.php');
Gdn::FactoryInstall(Gdn::AliasSession, 'Gdn_Session', PATH_LIBRARY_CORE . DS . 'class.session.php');
Gdn::FactoryInstall(Gdn::AliasAuthenticator, 'Gdn_Auth', PATH_LIBRARY_CORE . DS . 'class.auth.php', Gdn::FactorySingleton);
示例6: Url
function Url($Path = '', $WithDomain = FALSE, $RemoveSyndication = FALSE)
{
$Result = Gdn::Request()->Url($Path, $WithDomain);
return $Result;
// Cache the rewrite urls config setting in this object.
static $RewriteUrls = NULL;
if (is_null($RewriteUrls)) {
$RewriteUrls = ForceBool(Gdn::Config('Garden.RewriteUrls', FALSE));
}
$Prefix = substr($Path, 0, 7);
if (in_array($Prefix, array('http://', 'https:/'))) {
return $Path;
}
if ($Path == '#' || $Path == '') {
$Path = Gdn_Url::Request(FALSE, FALSE, $RemoveSyndication) . $Path;
}
$Paths = array();
if (!$WithDomain) {
$Paths[] = '/';
}
$Paths[] = Gdn_Url::WebRoot($WithDomain);
if (!$RewriteUrls) {
$Paths[] = 'index.php';
}
$Paths[] = $Path;
return CombinePaths($Paths, '/');
}
示例7: Url
function Url($Destination = '', $WithDomain = FALSE, $RemoveSyndication = FALSE)
{
// Cache the rewrite urls config setting in this object.
static $RewriteUrls = NULL;
if (is_null($RewriteUrls)) {
$RewriteUrls = ForceBool(Gdn::Config('Garden.RewriteUrls', FALSE));
}
$Prefix = substr($Destination, 0, 7);
if (in_array($Prefix, array('http://', 'https:/'))) {
return $Destination;
} else {
if ($Destination == '#' || $Destination == '') {
if ($WithDomain) {
return Gdn_Url::Request(TRUE, TRUE, $RemoveSyndication) . $Destination;
} else {
return '/' . Gdn_Url::Request(TRUE, FALSE, $RemoveSyndication) . $Destination;
}
} else {
$Paths = array();
if (!$WithDomain) {
$Paths[] = '/';
}
$Paths[] = Gdn_Url::WebRoot($WithDomain);
if (!$RewriteUrls) {
$Paths[] = 'index.php';
}
$Paths[] = $Destination;
return CombinePaths($Paths, '/');
}
}
}
示例8: DiscussionController_BeforeDiscussion_Handler
public function DiscussionController_BeforeDiscussion_Handler(&$Sender) {
echo sprintf($this->Code, Gdn_Url::Request(true, true, true));
}
示例9: SignOutUrl
public function SignOutUrl()
{
$Url = sprintf($this->_SignOutUrl, urlencode(Gdn_Url::Request()));
return Gdn::Config('Garden.Authenticator.SignOutUrl');
}
示例10: ToString
public function ToString($HighlightRoute = '')
{
if ($HighlightRoute == '') {
$HighlightRoute = $this->_HighlightRoute;
}
if ($HighlightRoute == '') {
$HighlightRoute = Gdn_Url::Request();
}
$Username = '';
$UserID = '';
$Session_TransientKey = '';
$Permissions = array();
$Session = Gdn::Session();
$HasPermissions = FALSE;
$Admin = FALSE;
if ($Session->IsValid() === TRUE) {
$UserID = $Session->User->UserID;
$Username = $Session->User->Name;
$Session_TransientKey = $Session->TransientKey();
$Permissions = $Session->GetPermissions();
$HasPermissions = count($Permissions) > 0;
$Admin = $Session->User->Admin == '1' ? TRUE : FALSE;
}
$Menu = '';
if (count($this->Items) > 0) {
// Apply the menu group sort if present...
if (is_array($this->Sort)) {
$Items = array();
$Count = count($this->Sort);
for ($i = 0; $i < $Count; ++$i) {
$Group = $this->Sort[$i];
if (array_key_exists($Group, $this->Items)) {
$Items[$Group] = $this->Items[$Group];
unset($this->Items[$Group]);
}
}
foreach ($this->Items as $Group => $Links) {
$Items[$Group] = $Links;
}
} else {
$Items = $this->Items;
}
foreach ($Items as $GroupName => $Links) {
$ItemCount = 0;
$LinkCount = 0;
$OpenGroup = FALSE;
$Group = '';
foreach ($Links as $Key => $Link) {
$CurrentLink = FALSE;
$ShowLink = FALSE;
$RequiredPermissions = array_key_exists('Permission', $Link) ? $Link['Permission'] : FALSE;
if ($RequiredPermissions !== FALSE && !is_array($RequiredPermissions)) {
$RequiredPermissions = explode(',', $RequiredPermissions);
}
// Show if there are no permissions or the user has the required permissions or the user is admin
$ShowLink = $Admin || $RequiredPermissions === FALSE || ArrayInArray($RequiredPermissions, $Permissions, FALSE) === TRUE;
if ($ShowLink === TRUE) {
if ($ItemCount == 1) {
$Group .= '<ul>';
$OpenGroup = TRUE;
} else {
if ($ItemCount > 1) {
$Group .= "</li>\r\n";
}
}
$Url = ArrayValue('Url', $Link);
if (substr($Link['Code'], 0, 1) === '\\') {
$Text = substr($Link['Code'], 1);
} else {
$Text = str_replace('{Username}', $Username, Gdn::Translate($Link['Code']));
}
$Attributes = ArrayValue('Attributes', $Link, array());
if ($Url !== FALSE) {
$Url = str_replace(array('{Username}', '{UserID}', '{Session_TransientKey}'), array(urlencode($Username), $UserID, $Session_TransientKey), $Link['Url']);
if (substr($Url, 0, 5) != 'http:') {
$Url = Url($Url);
$CurrentLink = $Url == Url($HighlightRoute);
}
$CssClass = ArrayValue('class', $Attributes, '');
if ($CurrentLink) {
$Attributes['class'] = $CssClass . ' Highlight';
}
$Group .= '<li' . Attribute($Attributes) . '><a href="' . $Url . '">' . $Text . '</a>';
++$LinkCount;
} else {
$Group .= '<li' . Attribute($Attributes) . '>' . $Text;
}
++$ItemCount;
}
}
if ($OpenGroup === TRUE) {
$Group .= "</li>\r\n</ul>\r\n";
}
if ($Group != '' && $LinkCount > 0) {
$Menu .= $Group . "</li>\r\n";
}
}
if ($Menu != '') {
$Menu = '<ul id="' . $this->HtmlId . '"' . ($this->CssClass != '' ? ' class="' . $this->CssClass . '"' : '') . '>' . $Menu . '</ul>';
}
//.........这里部分代码省略.........
示例11: DiscussionController_AfterDiscussionBody_Handler
public function DiscussionController_AfterDiscussionBody_Handler(&$Sender)
{
echo '<div class="fb-like" data-href="';
echo Gdn_Url::Request(true, true, true);
echo '" data-send="false" data-width="450" data-show-faces="false" data-font="lucida grande"></div>';
}
示例12: ToString
public function ToString($HighlightRoute = '')
{
if ($HighlightRoute == '') {
$HighlightRoute = $this->_HighlightRoute;
}
if ($HighlightRoute == '') {
$HighlightRoute = Gdn_Url::Request();
}
$Username = '';
$UserID = '';
$Session_TransientKey = '';
$Permissions = array();
$Session = Gdn::Session();
$HasPermissions = FALSE;
$Admin = FALSE;
if ($Session->IsValid() === TRUE) {
$UserID = $Session->User->UserID;
$Username = $Session->User->Name;
$Session_TransientKey = $Session->TransientKey();
$Permissions = $Session->GetPermissions();
$HasPermissions = count($Permissions) > 0;
$Admin = $Session->User->Admin == '1' ? TRUE : FALSE;
}
$Menu = '';
if (count($this->Items) > 0) {
// Apply the menu sort if present...
if (is_array($this->Sort)) {
$Items = array();
$Count = count($this->Sort);
for ($i = 0; $i < $Count; ++$i) {
$Group = $this->Sort[$i];
if (array_key_exists($Group, $this->Items)) {
$Items[$Group] = $this->Items[$Group];
unset($this->Items[$Group]);
}
}
foreach ($Items as $Group => $Links) {
$LinkNames = ConsolidateArrayValuesByKey($Links, 'Text');
$SortedLinks = array();
for ($j = 0; $j < $Count; ++$j) {
$SortName = $this->Sort[$j];
$Key = array_search($SortName, $LinkNames);
if ($Key !== FALSE) {
$SortedLinks[] = $Links[$Key];
unset($Links[$Key]);
$LinkNames[$Key] = '-=EMPTY=-';
}
}
$SortedLinks = array_merge($SortedLinks, $Links);
$Items[$Group] = $SortedLinks;
}
} else {
$Items = $this->Items;
}
// Build the menu
foreach ($Items as $GroupName => $Links) {
$ItemCount = 0;
$LinkCount = 0;
$OpenGroup = FALSE;
$GroupIsActive = FALSE;
$GroupAnchor = '';
$Group = '';
foreach ($Links as $Key => $Link) {
$CurrentLink = FALSE;
$ShowLink = FALSE;
$RequiredPermissions = array_key_exists('Permission', $Link) ? $Link['Permission'] : FALSE;
if ($RequiredPermissions !== FALSE && !is_array($RequiredPermissions)) {
$RequiredPermissions = explode(',', $RequiredPermissions);
}
// Show if there are no permissions or the user has the required permissions or the user is admin
$ShowLink = $Admin || $RequiredPermissions === FALSE || ArrayInArray($RequiredPermissions, $Permissions, FALSE) === TRUE;
if ($ShowLink === TRUE) {
if ($ItemCount == 1) {
$Group .= '<ul class="PanelInfo">';
$OpenGroup = TRUE;
} else {
if ($ItemCount > 1) {
$Group .= "</li>\r\n";
}
}
$Url = ArrayValue('Url', $Link);
if (substr($Link['Text'], 0, 1) === '\\') {
$Text = substr($Link['Text'], 1);
} else {
$Text = str_replace('{Username}', $Username, $Link['Text']);
}
$Attributes = ArrayValue('Attributes', $Link, array());
if ($Url !== FALSE) {
$Url = str_replace(array('{Username}', '{UserID}', '{Session_TransientKey}'), array(urlencode($Username), $UserID, $Session_TransientKey), $Link['Url']);
if (substr($Url, 0, 5) != 'http:') {
if ($GroupAnchor == '' && $this->AutoLinkGroups) {
$GroupAnchor = $Url;
}
$Url = Url($Url);
$CurrentLink = $Url == Url($HighlightRoute);
if ($CurrentLink && !$GroupIsActive) {
$GroupIsActive = TRUE;
}
}
$CssClass = ArrayValue('class', $Attributes, '');
//.........这里部分代码省略.........
示例13: WriteActivityComment
function WriteActivityComment($Comment, &$Sender, &$Session)
{
?>
<li id="Activity_<?php
echo $Comment->ActivityID;
?>
" class="<?php
echo $Comment->ActivityType;
if ($Comment->ActivityPhoto != '') {
echo ' HasPhoto';
}
?>
"><?php
if ($Comment->ActivityPhoto != '') {
echo '<a href="' . Url('/garden/profile/' . urlencode($Comment->ActivityName)) . '" class="Photo">' . $Sender->Html->Image('uploads/n' . $Comment->ActivityPhoto) . '</a>';
}
echo '<div>';
echo UserAnchor($Comment->ActivityName, 'Name');
echo Format::Display($Comment->Story);
echo '<div class="Meta">';
echo Format::Date($Comment->DateInserted);
echo $Session->UserID == $Comment->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete') ? '<span>•</span>' . Anchor('Delete', 'garden/activity/delete/' . $Comment->ActivityID . '/' . $Session->TransientKey() . '?Return=' . urlencode(Gdn_Url::Request())) : '';
echo '</div>';
echo '</div>';
?>
</li>
<?php
}
示例14: writeActivityComment
function writeActivityComment($Comment, $Activity)
{
$Session = Gdn::session();
$Author = UserBuilder($Comment, 'Insert');
$PhotoAnchor = userPhoto($Author, 'Photo');
$CssClass = 'Item ActivityComment ActivityComment';
if ($PhotoAnchor != '') {
$CssClass .= ' HasPhoto';
}
?>
<li id="ActivityComment_<?php
echo $Comment['ActivityCommentID'];
?>
" class="<?php
echo $CssClass;
?>
">
<?php
if ($PhotoAnchor != '') {
?>
<div class="Author Photo"><?php
echo $PhotoAnchor;
?>
</div>
<?php
}
?>
<div class="ItemContent ActivityComment">
<?php
echo userAnchor($Author, 'Title Name');
?>
<div class="Excerpt"><?php
echo Gdn_Format::to($Comment['Body'], $Comment['Format']);
?>
</div>
<div class="Meta">
<span class="DateCreated"><?php
echo Gdn_Format::date($Comment['DateInserted'], 'html');
?>
</span>
<?php
if (ActivityModel::canDelete($Activity)) {
echo anchor(t('Delete'), "dashboard/activity/deletecomment?id={$Comment['ActivityCommentID']}&tk=" . $Session->TransientKey() . '&target=' . urlencode(Gdn_Url::Request()), 'DeleteComment');
}
?>
</div>
</div>
</li>
<?php
}
示例15: ToString
public function ToString($HighlightRoute = '')
{
if ($HighlightRoute == '') {
$HighlightRoute = $this->_HighlightRoute;
}
if ($HighlightRoute == '') {
$HighlightRoute = Gdn_Url::Request();
}
$HighlightUrl = Url($HighlightRoute);
// Apply a sort to the items if given.
if (is_array($this->Sort)) {
$Sort = array_flip($this->Sort);
foreach ($this->Items as $Group => &$Item) {
if (isset($Sort[$Group])) {
$Item['Sort'] = $Sort[$Group];
} else {
$Item['_Sort'] += count($Sort);
}
foreach ($Item['Links'] as $Url => &$Link) {
if (isset($Sort[$Url])) {
$Link['Sort'] = $Sort[$Url];
} elseif (isset($Sort[$Link['Text']])) {
$Link['Sort'] = $Sort[$Link['Text']];
} else {
$Link['_Sort'] += count($Sort);
}
}
}
}
// Sort the groups.
$this->_Compare($this->Items);
uasort($this->Items, array($this, '_Compare'));
// Sort the items within the groups.
foreach ($this->Items as &$Item) {
$this->_Compare($Item['Links']);
uasort($Item['Links'], array($this, '_Compare'));
// Highlight the group.
if (GetValue('Url', $Item) && Url($Item['Url']) == $HighlightUrl) {
$Item['Attributes']['class'] = ConcatSep(' ', GetValue('class', $Item['Attributes']), 'Active');
}
// Hightlight the correct item in the group.
foreach ($Item['Links'] as &$Link) {
if (GetValue('Url', $Link) && Url($Link['Url']) == $HighlightUrl) {
$Link['Attributes']['class'] = ConcatSep(' ', GetValue('class', $Link['Attributes']), 'Active');
$Item['Attributes']['class'] = ConcatSep(' ', GetValue('class', $Item['Attributes']), 'Active');
}
}
}
return parent::ToString();
}