本文整理汇总了PHP中ExternalUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP ExternalUrl函数的具体用法?PHP ExternalUrl怎么用?PHP ExternalUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExternalUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _FormatStringCallback
function _FormatStringCallback($Match, $SetArgs = FALSE)
{
static $Args = array();
if ($SetArgs) {
$Args = $Match;
return;
}
$Match = $Match[1];
if ($Match == '{') {
return $Match;
}
// Parse out the field and format.
$Parts = explode(',', $Match);
$Field = trim($Parts[0]);
$Format = strtolower(trim(GetValue(1, $Parts, '')));
$SubFormat = strtolower(trim(GetValue(2, $Parts, '')));
$FomatArgs = GetValue(3, $Parts, '');
if (in_array($Format, array('currency', 'integer', 'percent'))) {
$FormatArgs = $SubFormat;
$SubFormat = $Format;
$Format = 'number';
} elseif (is_numeric($SubFormat)) {
$FormatArgs = $SubFormat;
$SubFormat = '';
}
$Value = GetValueR($Field, $Args, '');
if ($Value == '' && !in_array($Format, array('url', 'exurl'))) {
$Result = '';
} else {
switch (strtolower($Format)) {
case 'date':
switch ($SubFormat) {
case 'short':
$Result = Gdn_Format::Date($Value, '%d/%m/%Y');
break;
case 'medium':
$Result = Gdn_Format::Date($Value, '%e %b %Y');
break;
case 'long':
$Result = Gdn_Format::Date($Value, '%e %B %Y');
break;
default:
$Result = Gdn_Format::Date($Value);
break;
}
break;
case 'html':
case 'htmlspecialchars':
$Result = htmlspecialchars($Value);
break;
case 'number':
if (!is_numeric($Value)) {
$Result = $Value;
} else {
switch ($SubFormat) {
case 'currency':
$Result = '$' . number_format($Value, is_numeric($FormatArgs) ? $FormatArgs : 2);
case 'integer':
$Result = (string) round($Value);
if (is_numeric($FormatArgs) && strlen($Result) < $FormatArgs) {
$Result = str_repeat('0', $FormatArgs - strlen($Result)) . $Result;
}
break;
case 'percent':
$Result = round($Value * 100, is_numeric($FormatArgs) ? $FormatArgs : 0);
break;
default:
$Result = number_format($Value, is_numeric($FormatArgs) ? $FormatArgs : 0);
break;
}
}
break;
case 'rawurlencode':
$Result = rawurlencode($Value);
break;
case 'time':
$Result = Gdn_Format::Date($Value, '%l:%M%p');
break;
case 'url':
if (strpos($Field, '/') !== FALSE) {
$Value = $Field;
}
$Result = Url($Value, $SubFormat == 'domain');
break;
case 'exurl':
if (strpos($Field, '/') !== FALSE) {
$Value = $Field;
}
$Result = ExternalUrl($Value);
break;
case 'urlencode':
$Result = urlencode($Value);
break;
default:
$Result = $Value;
break;
}
}
return $Result;
}
示例2: _FormatStringCallback
//.........这里部分代码省略.........
$Value = 1;
}
if (!is_numeric($Value)) {
$Result = $Value;
} else {
if (!$SubFormat) {
$SubFormat = rtrim("%s {$Field}", 's');
}
if (!$FormatArgs) {
$FormatArgs = $SubFormat . 's';
}
$Result = Plural($Value, $SubFormat, $FormatArgs);
}
break;
case 'rawurlencode':
$Result = rawurlencode($Value);
break;
case 'text':
$Result = Gdn_Format::Text($Value, FALSE);
break;
case 'time':
$Result = Gdn_Format::Date($Value, '%l:%M%p');
break;
case 'url':
if (strpos($Field, '/') !== FALSE) {
$Value = $Field;
}
$Result = Url($Value, $SubFormat == 'domain');
break;
case 'exurl':
if (strpos($Field, '/') !== FALSE) {
$Value = $Field;
}
$Result = ExternalUrl($Value);
break;
case 'urlencode':
$Result = urlencode($Value);
break;
case 'gender':
// Format in the form of FieldName,gender,male,female,unknown
if (is_array($Value) && count($Value) == 1) {
$Value = array_shift($Value);
}
$Gender = 'u';
if (!is_array($Value)) {
$User = Gdn::UserModel()->GetID($Value);
if ($User) {
$Gender = $User->Gender;
}
}
switch ($Gender) {
case 'm':
$Result = $SubFormat;
break;
case 'f':
$Result = $FormatArgs;
break;
default:
$Result = GetValue(4, $Parts);
}
break;
case 'user':
case 'you':
case 'his':
case 'her':
case 'your':
示例3: passwordRequest
/**
* Send forgot password email.
*
* @param $Email
* @return bool
* @throws Exception
*/
public function passwordRequest($Email)
{
if (!$Email) {
return false;
}
$Users = $this->getWhere(array('Email' => $Email))->resultObject();
if (count($Users) == 0) {
// Check for the username.
$Users = $this->getWhere(array('Name' => $Email))->resultObject();
}
$this->EventArguments['Users'] =& $Users;
$this->EventArguments['Email'] = $Email;
$this->fireEvent('BeforePasswordRequest');
if (count($Users) == 0) {
$this->Validation->addValidationResult('Name', "Couldn't find an account associated with that email/username.");
return false;
}
$NoEmail = true;
foreach ($Users as $User) {
if (!$User->Email) {
continue;
}
$Email = new Gdn_Email();
// Instantiate in loop to clear previous settings
$PasswordResetKey = BetterRandomString(20, 'Aa0');
$PasswordResetExpires = strtotime('+1 hour');
$this->saveAttribute($User->UserID, 'PasswordResetKey', $PasswordResetKey);
$this->saveAttribute($User->UserID, 'PasswordResetExpires', $PasswordResetExpires);
$AppTitle = c('Garden.Title');
$Email->subject(sprintf(t('[%s] Password Reset Request'), $AppTitle));
$Email->to($User->Email);
$Email->message(sprintf(t('PasswordRequest'), $User->Name, $AppTitle, ExternalUrl('/entry/passwordreset/' . $User->UserID . '/' . $PasswordResetKey)));
$Email->send();
$NoEmail = false;
}
if ($NoEmail) {
$this->Validation->addValidationResult('Name', 'There is no email address associated with that account.');
return false;
}
return true;
}
示例4: RegisterApproval
/**
* Registration that requires approval.
*
* Events: RegistrationPending
*
* @access private
* @since 2.0.0
*/
private function RegisterApproval()
{
Gdn::UserModel()->AddPasswordStrength($this);
// If the form has been posted back...
if ($this->Form->IsPostBack()) {
// Add validation rules that are not enforced by the model
$this->UserModel->DefineSchema();
$this->UserModel->Validation->ApplyRule('Name', 'Username', $this->UsernameError);
$this->UserModel->Validation->ApplyRule('TermsOfService', 'Required', T('You must agree to the terms of service.'));
$this->UserModel->Validation->ApplyRule('Password', 'Required');
$this->UserModel->Validation->ApplyRule('Password', 'Strength');
$this->UserModel->Validation->ApplyRule('Password', 'Match');
$this->UserModel->Validation->ApplyRule('DiscoveryText', 'Required', 'Tell us why you want to join!');
// $this->UserModel->Validation->ApplyRule('DateOfBirth', 'MinimumAge');
$this->FireEvent('RegisterValidation');
try {
$Values = $this->Form->FormValues();
unset($Values['Roles']);
$AuthUserID = $this->UserModel->Register($Values);
if (!$AuthUserID) {
$this->Form->SetValidationResults($this->UserModel->ValidationResults());
} else {
// The user has been created successfully, so sign in now.
Gdn::Session()->Start($AuthUserID);
if ($this->Form->GetFormValue('RememberMe')) {
Gdn::Authenticator()->SetIdentity($AuthUserID, TRUE);
}
// Notification text
$Label = T('NewApplicantEmail', 'New applicant:');
$Story = Anchor(Gdn_Format::Text($Label . ' ' . $Values['Name']), ExternalUrl('dashboard/user/applicants'));
$this->EventArguments['AuthUserID'] = $AuthUserID;
$this->EventArguments['Story'] =& $Story;
$this->FireEvent('RegistrationPending');
$this->View = "RegisterThanks";
// Tell the user their application will be reviewed by an administrator.
// Grab all of the users that need to be notified.
$Data = Gdn::Database()->SQL()->GetWhere('UserMeta', array('Name' => 'Preferences.Email.Applicant'))->ResultArray();
$ActivityModel = new ActivityModel();
foreach ($Data as $Row) {
$ActivityModel->Add($AuthUserID, 'Applicant', $Story, $Row['UserID'], '', '/dashboard/user/applicants', 'Only');
}
}
} catch (Exception $Ex) {
$this->Form->AddError($Ex);
}
}
$this->Render();
}
示例5: QueueNotification
/**
* Queue a notification for sending.
*
* @since 2.0.17
* @access public
* @param int $ActivityID
* @param string $Story
* @param string $Position
* @param bool $Force
*/
public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE)
{
$Activity = $this->GetID($ActivityID);
if (!is_object($Activity)) {
return;
}
$Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
// If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
$CommentActivity = $this->GetID($Activity->CommentActivityID);
$Activity->RegardingUserID = $CommentActivity->RegardingUserID;
$Activity->Route = '/activity/item/' . $Activity->CommentActivityID;
}
$User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT);
//$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
if ($User) {
if ($Force) {
$Preference = $Force;
} else {
// $Preferences = Gdn_Format::Unserialize($User->Preferences);
$ConfigPreference = C('Preferences.Email.' . $Activity->ActivityType, '0');
if ($ConfigPreference !== FALSE) {
$Preference = GetValue('Email.' . $Activity->ActivityType, $User->Preferences, $ConfigPreference);
} else {
$Preference = FALSE;
}
}
if ($Preference) {
$ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
$Email = new Gdn_Email();
$Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
$Email->To($User);
$Message = sprintf($Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"), $ActivityHeadline, ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route), $Story);
$Email->Message($Message);
if (!array_key_exists($User->UserID, $this->_NotificationQueue)) {
$this->_NotificationQueue[$User->UserID] = array();
}
$Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
if ($Position == 'first') {
$this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]);
} else {
$this->_NotificationQueue[$User->UserID][] = $Notification;
}
}
}
}
示例6: send
/**
*
*
* @param $InvitationID
* @throws Exception
*/
public function send($InvitationID)
{
$Invitation = $this->GetByInvitationID($InvitationID);
$Session = Gdn::session();
if ($Invitation === false) {
throw new Exception(t('ErrorRecordNotFound'));
} elseif ($Session->UserID != $Invitation->SenderUserID) {
throw new Exception(t('InviteErrorPermission', t('ErrorPermission')));
} else {
// Some information for the email
$RegistrationUrl = ExternalUrl("entry/registerinvitation/{$Invitation->Code}");
$AppTitle = Gdn::config('Garden.Title');
$Email = new Gdn_Email();
$Email->subject(sprintf(t('[%s] Invitation'), $AppTitle));
$Email->to($Invitation->Email);
$Email->message(sprintf(t('EmailInvitation'), $Invitation->SenderName, $AppTitle, $RegistrationUrl));
$Email->send();
}
}
示例7: PasswordRequest
public function PasswordRequest($Email)
{
if (!$Email) {
return FALSE;
}
$Users = $this->GetWhere(array('Email' => $Email))->ResultObject();
if (count($Users) == 0) {
// Check for the username.
$Users = $this->GetWhere(array('Name' => $Email))->ResultObject();
}
$this->EventArguments['Users'] =& $Users;
$this->EventArguments['Email'] = $Email;
$this->FireEvent('BeforePasswordRequest');
if (count($Users) == 0) {
$this->Validation->AddValidationResult('Name', "Couldn't find an account associated with that email/username.");
return FALSE;
}
$Email = new Gdn_Email();
$NoEmail = TRUE;
foreach ($Users as $User) {
if (!$User->Email) {
continue;
}
$PasswordResetKey = RandomString(6);
$this->SaveAttribute($User->UserID, 'PasswordResetKey', $PasswordResetKey);
$AppTitle = C('Garden.Title');
$Email->Subject(sprintf(T('[%s] Password Reset Request'), $AppTitle));
$Email->To($User->Email);
$Email->Message(sprintf(T('PasswordRequest'), $User->Name, $AppTitle, ExternalUrl('/entry/passwordreset/' . $User->UserID . '/' . $PasswordResetKey)));
$Email->Send();
$NoEmail = FALSE;
}
if ($NoEmail) {
$this->Validation->AddValidationResult('Name', 'There is no email address associated with that account.');
return FALSE;
}
return TRUE;
}
示例8: send
/**
*
*
* @param $InvitationID
* @throws Exception
*/
public function send($InvitationID)
{
$Invitation = $this->GetByInvitationID($InvitationID);
$Session = Gdn::session();
if ($Invitation === false) {
throw new Exception(t('ErrorRecordNotFound'));
} elseif ($Session->UserID != $Invitation->SenderUserID) {
throw new Exception(t('InviteErrorPermission', t('ErrorPermission')));
} else {
// Some information for the email
$RegistrationUrl = ExternalUrl("entry/registerinvitation/{$Invitation->Code}");
$AppTitle = Gdn::config('Garden.Title');
$Email = new Gdn_Email();
$Email->subject(sprintf(t('[%s] Invitation'), $AppTitle));
$Email->to($Invitation->Email);
$emailTemplate = $Email->getEmailTemplate();
$message = t('Hello!') . ' ' . sprintf(t('%s has invited you to join %s.'), $Invitation->SenderName, $AppTitle);
$emailTemplate->setButton($RegistrationUrl, t('Join this Community Now'))->setMessage($message)->setTitle(sprintf(t('Join %s'), $AppTitle));
$Email->setEmailTemplate($emailTemplate);
try {
$Email->send();
} catch (Exception $e) {
if (debug()) {
throw $e;
}
}
}
}
示例9: NotifyNewDiscussion
public function NotifyNewDiscussion($Discussion)
{
if (is_numeric($Discussion)) {
$Discussion = $this->GetID($Discussion);
}
// Grab all of the users that need to be notified.
$Data = $this->SQL->GetWhere('UserMeta', array('Name' => 'Preferences.Email.NewDiscussion'))->ResultArray();
// Grab all of their follow/unfollow preferences.
$UserIDs = ConsolidateArrayValuesByKey($Data, 'UserID');
$CategoryID = $Discussion['CategoryID'];
$UserPrefs = $this->SQL->Select('*')->From('UserCategory')->Where('CategoryID', $CategoryID)->WhereIn('UserID', $UserIDs)->Get()->ResultArray();
$UserPrefs = Gdn_DataSet::Index($UserPrefs, 'UserID');
foreach ($Data as $Row) {
$UserID = $Row['UserID'];
if ($UserID == $Discussion['InsertUserID']) {
continue;
}
if (array_key_exists($UserID, $UserPrefs) && $UserPrefs[$UserID]['Unfollow']) {
continue;
}
AddActivity($Discussion['InsertUserID'], 'NewDiscussion', Anchor(Gdn_Format::Text($Discussion['Name']), ExternalUrl('discussion/' . $Discussion['DiscussionID'] . '/' . Gdn_Format::Url($Discussion['Name']))), $UserID, '/discussion/' . $Discussion['DiscussionID'] . '/' . Gdn_Format::Url($Discussion['Name']), TRUE);
}
}
示例10: PasswordRequest
public function PasswordRequest($Email)
{
if (!$Email) {
return FALSE;
}
$Users = $this->GetWhere(array('Email' => $Email))->ResultObject();
if (count($Users) == 0 && C('Garden.Registration.NameUnique', 1)) {
// Check for the username.
$Users = $this->GetWhere(array('Name' => $Email))->ResultObject();
}
$this->EventArguments['Users'] =& $Users;
$this->EventArguments['Email'] = $Email;
$this->FireEvent('BeforePasswordRequest');
if (count($Users) == 0) {
return FALSE;
}
$Email = new Gdn_Email();
foreach ($Users as $User) {
$PasswordResetKey = RandomString(6);
$this->SaveAttribute($User->UserID, 'PasswordResetKey', $PasswordResetKey);
$AppTitle = C('Garden.Title');
$Email->Subject(sprintf(T('[%s] Password Reset Request'), $AppTitle));
$Email->To($User->Email);
$Email->Message(sprintf(T('PasswordRequest'), $User->Name, $AppTitle, ExternalUrl('/entry/passwordreset/' . $User->UserID . '/' . $PasswordResetKey)));
$Email->Send();
}
return TRUE;
}
示例11: calculateRow
/**
*
*
* @param $Row
*/
public function calculateRow(&$Row)
{
$ActivityType = self::GetActivityType($Row['ActivityTypeID']);
$Row['ActivityType'] = val('Name', $ActivityType);
if (is_string($Row['Data'])) {
$Row['Data'] = @unserialize($Row['Data']);
}
$Row['PhotoUrl'] = url($Row['Route'], true);
if (!$Row['Photo']) {
if (isset($Row['ActivityPhoto'])) {
$Row['Photo'] = $Row['ActivityPhoto'];
$Row['PhotoUrl'] = userUrl($Row, 'Activity');
} else {
$User = Gdn::userModel()->getID($Row['ActivityUserID'], DATASET_TYPE_ARRAY);
if ($User) {
$Photo = $User['Photo'];
$Row['PhotoUrl'] = userUrl($User);
if (!$Photo || stringBeginsWith($Photo, 'http')) {
$Row['Photo'] = $Photo;
} else {
$Row['Photo'] = Gdn_Upload::url(changeBasename($Photo, 'n%s'));
}
}
}
}
$Data = $Row['Data'];
if (isset($Data['ActivityUserIDs'])) {
$Row['ActivityUserID'] = array_merge(array($Row['ActivityUserID']), $Data['ActivityUserIDs']);
$Row['ActivityUserID_Count'] = val('ActivityUserID_Count', $Data);
}
if (isset($Data['RegardingUserIDs'])) {
$Row['RegardingUserID'] = array_merge(array($Row['RegardingUserID']), $Data['RegardingUserIDs']);
$Row['RegardingUserID_Count'] = val('RegardingUserID_Count', $Data);
}
$Row['Url'] = ExternalUrl($Row['Route']);
if ($Row['HeadlineFormat']) {
$Row['Headline'] = formatString($Row['HeadlineFormat'], $Row);
} else {
$Row['Headline'] = Gdn_Format::activityHeadline($Row);
}
}
示例12: NotifyNewDiscussion
public function NotifyNewDiscussion($Discussion) {
if (is_numeric($Discussion)) {
$Discussion = $this->GetID($Discussion);
}
// Grab all of the users that are need to be notified.
$Data = $this->SQL->GetWhere('UserMeta', array('Name' => 'Preferences.Email.NewDiscussion'))->ResultArray();
foreach ($Data as $Row) {
$UserID = $Row['UserID'];
if ($UserID == $Discussion['InsertUserID'])
continue;
AddActivity($Discussion['InsertUserID'],
'NewDiscussion',
Anchor(Gdn_Format::Text($Discussion['Name']), ExternalUrl('discussion/'.$Discussion['DiscussionID'].'/'.Gdn_Format::Url($Discussion['Name']))),
$UserID,
'/discussion/'.$Discussion['DiscussionID'].'/'.Gdn_Format::Url($Discussion['Name']),
TRUE);
}
}
示例13: t
}
$Flag = $this->Data['Plugin.Flagging.Data'];
$Report = $this->Data['Plugin.Flagging.Report'];
$DiscussionID = $this->Data['Plugin.Flagging.DiscussionID'];
$Reason = $this->Data['Plugin.Flagging.Reason'];
echo t('Discussion');
?>
: <?php
if (isset($Report['DiscussionName'])) {
echo $Report['DiscussionName'];
}
?>
<?php
echo ExternalUrl($Flag['URL']);
?>
<?php
echo t('Reason') . ': ' . $Reason;
?>
<?php
echo t('FlaggedBy', 'Reported by:') . ' ' . $Flag['UserName'];
?>
<?php
if ($DiscussionID) {
echo t('FlagDiscuss', 'Discuss it') . ': ' . ExternalUrl('discussion/' . $DiscussionID);
}
示例14: SendNotification
public function SendNotification($ActivityID, $Story = '') {
$Activity = $this->GetID($ActivityID);
if (!is_object($Activity))
return;
$Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
// If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
$CommentActivity = $this->GetID($Activity->CommentActivityID);
$Activity->RegardingUserID = $CommentActivity->RegardingUserID;
$Activity->Route = '/activity/item/'.$Activity->CommentActivityID;
}
$User = $this->SQL->Select('Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
if ($User) {
$Preferences = Gdn_Format::Unserialize($User->Preferences);
$Preference = ArrayValue('Email.'.$Activity->ActivityType, $Preferences, Gdn::Config('Preferences.Email.'.$Activity->ActivityType));
if ($Preference) {
$ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
$Email = new Gdn_Email();
$Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
$Email->To($User->Email, $User->Name);
//$Email->From(Gdn::Config('Garden.SupportEmail'), Gdn::Config('Garden.SupportName'));
$Email->Message(
sprintf(
T($Story == '' ? 'EmailNotification' : 'EmailStoryNotification'),
$ActivityHeadline,
ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route),
$Story
)
);
try {
$Email->Send();
} catch (Exception $ex) {
// Don't do anything with the exception.
}
}
}
}
示例15: if
<?php if (!defined('APPLICATION')) exit(); ?>
<?php
$Flag = $this->Data['Plugin.Flagging.Data'];
$Report = $this->Data['Plugin.Flagging.Report'];
$DiscussionID = $this->Data['Plugin.Flagging.DiscussionID'];
$Reason = $this->Data['Plugin.Flagging.Reason'];
echo T('Discussion'); ?>: <?php if (isset($Report['DiscussionName'])) echo $Report['DiscussionName']; ?>
<?php echo ExternalUrl($Flag['URL']); ?>
<?php echo T('Reason') . ': ' . $Reason; ?>
<?php echo T('Flagged by') . ': ' . $Flag['UserName']; ?>
<?php if ($DiscussionID) echo T('Discuss it') . ': ' . ExternalUrl('discussion/'.$DiscussionID); ?>