本文整理汇总了PHP中UserPhotoDefaultUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP UserPhotoDefaultUrl函数的具体用法?PHP UserPhotoDefaultUrl怎么用?PHP UserPhotoDefaultUrl使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UserPhotoDefaultUrl函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
*
*
* @param $Path
* @param $Controller
*/
public function init($Path, $Controller)
{
$Smarty = $this->smarty();
// Get a friendly name for the controller.
$ControllerName = get_class($Controller);
if (StringEndsWith($ControllerName, 'Controller', true)) {
$ControllerName = substr($ControllerName, 0, -10);
}
// Get an ID for the body.
$BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($Controller->RequestMethod)));
$Smarty->assign('BodyID', $BodyIdentifier);
//$Smarty->assign('Config', Gdn::Config());
// Assign some information about the user.
$Session = Gdn::session();
if ($Session->isValid()) {
$User = array('Name' => $Session->User->Name, 'Photo' => '', 'CountNotifications' => (int) val('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) val('CountUnreadConversations', $Session->User, 0), 'SignedIn' => true);
$Photo = $Session->User->Photo;
if ($Photo) {
if (!IsUrl($Photo)) {
$Photo = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
}
} else {
if (function_exists('UserPhotoDefaultUrl')) {
$Photo = UserPhotoDefaultUrl($Session->User, 'ProfilePhoto');
} elseif ($ConfigPhoto = C('Garden.DefaultAvatar')) {
$Photo = Gdn_Upload::url($ConfigPhoto);
} else {
$Photo = Asset('/applications/dashboard/design/images/defaulticon.png', true);
}
}
$User['Photo'] = $Photo;
} else {
$User = false;
/*array(
'Name' => '',
'CountNotifications' => 0,
'SignedIn' => FALSE);*/
}
$Smarty->assign('User', $User);
// Make sure that any datasets use arrays instead of objects.
foreach ($Controller->Data as $Key => $Value) {
if ($Value instanceof Gdn_DataSet) {
$Controller->Data[$Key] = $Value->resultArray();
} elseif ($Value instanceof stdClass) {
$Controller->Data[$Key] = (array) $Value;
}
}
$BodyClass = val('CssClass', $Controller->Data, '', true);
$Sections = Gdn_Theme::section(null, 'get');
if (is_array($Sections)) {
foreach ($Sections as $Section) {
$BodyClass .= ' Section-' . $Section;
}
}
$Controller->Data['BodyClass'] = $BodyClass;
// Set the current locale for themes to take advantage of.
$Locale = Gdn::locale()->Locale;
$CurrentLocale = array('Key' => $Locale, 'Lang' => str_replace('_', '-', $Locale));
if (class_exists('Locale')) {
$CurrentLocale['Language'] = Locale::getPrimaryLanguage($Locale);
$CurrentLocale['Region'] = Locale::getRegion($Locale);
$CurrentLocale['DisplayName'] = Locale::getDisplayName($Locale, $Locale);
$CurrentLocale['DisplayLanguage'] = Locale::getDisplayLanguage($Locale, $Locale);
$CurrentLocale['DisplayRegion'] = Locale::getDisplayRegion($Locale, $Locale);
}
$Smarty->assign('CurrentLocale', $CurrentLocale);
$Smarty->assign('Assets', (array) $Controller->Assets);
$Smarty->assign('Path', Gdn::request()->path());
// Assign the controller data last so the controllers override any default data.
$Smarty->assign($Controller->Data);
$Smarty->Controller = $Controller;
// for smarty plugins
$Smarty->security = true;
$Smarty->security_settings['IF_FUNCS'] = array_merge($Smarty->security_settings['IF_FUNCS'], array('Category', 'CheckPermission', 'InSection', 'InCategory', 'MultiCheckPermission', 'GetValue', 'SetValue', 'Url'));
$Smarty->security_settings['MODIFIER_FUNCS'] = array_merge($Smarty->security_settings['MODIFIER_FUNCS'], array('sprintf'));
$Smarty->secure_dir = array($Path);
}
示例2: Init
public function Init($Path, $Controller)
{
$Smarty = $this->Smarty();
// Get a friendly name for the controller.
$ControllerName = get_class($Controller);
if (StringEndsWith($ControllerName, 'Controller', TRUE)) {
$ControllerName = substr($ControllerName, 0, -10);
}
// Get an ID for the body.
$BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::AlphaNumeric(strtolower($Controller->RequestMethod)));
$Smarty->assign('BodyID', $BodyIdentifier);
//$Smarty->assign('Config', Gdn::Config());
// Assign some information about the user.
$Session = Gdn::Session();
if ($Session->IsValid()) {
$User = array('Name' => $Session->User->Name, 'Photo' => '', 'CountNotifications' => (int) GetValue('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) GetValue('CountUnreadConversations', $Session->User, 0), 'SignedIn' => TRUE);
$Photo = $Session->User->Photo;
if ($Photo) {
if (!preg_match('`^https?://`i', $Photo)) {
$Photo = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
}
} else {
if (function_exists('UserPhotoDefaultUrl')) {
$Photo = UserPhotoDefaultUrl($Session->User, 'ProfilePhoto');
} elseif ($ConfigPhoto = C('Garden.DefaultAvatar')) {
$Photo = Gdn_Upload::Url($ConfigPhoto);
} else {
$Photo = Asset('/applications/dashboard/design/images/defaulticon.png', TRUE);
}
}
$User['Photo'] = $Photo;
} else {
$User = FALSE;
/*array(
'Name' => '',
'CountNotifications' => 0,
'SignedIn' => FALSE);*/
}
$Smarty->assign('User', $User);
// Make sure that any datasets use arrays instead of objects.
foreach ($Controller->Data as $Key => $Value) {
if ($Value instanceof Gdn_DataSet) {
$Controller->Data[$Key] = $Value->ResultArray();
} elseif ($Value instanceof stdClass) {
$Controller->Data[$Key] = (array) $Value;
}
}
$BodyClass = GetValue('CssClass', $Controller->Data, '', TRUE);
$Sections = Gdn_Theme::Section(NULL, 'get');
if (is_array($Sections)) {
foreach ($Sections as $Section) {
$BodyClass .= ' Section-' . $Section;
}
}
$Controller->Data['BodyClass'] = $BodyClass;
$Smarty->assign('Assets', (array) $Controller->Assets);
$Smarty->assign('Path', Gdn::Request()->Path());
// Assigign the controller data last so the controllers override any default data.
$Smarty->assign($Controller->Data);
$Smarty->Controller = $Controller;
// for smarty plugins
$Smarty->security = TRUE;
$Smarty->security_settings['IF_FUNCS'] = array_merge($Smarty->security_settings['IF_FUNCS'], array('CheckPermission', 'MultiCheckPermission', 'GetValue', 'SetValue', 'Url', 'InSection', 'InCategory'));
$Smarty->security_settings['MODIFIER_FUNCS'] = array_merge($Smarty->security_settings['MODIFIER_FUNCS'], array('sprintf'));
$Smarty->secure_dir = array($Path);
}
示例3: IsUrl
$AllowImages = Gdn_UploadImage::CanUploadImages();
// Is the photo hosted remotely?
$RemotePhoto = IsUrl($this->User->Photo, 0, 7);
// Define the current profile picture
$Picture = '';
if ($this->User->Photo != '') {
if (IsUrl($this->User->Photo)) {
$Picture = img($this->User->Photo, array('class' => 'ProfilePhotoLarge'));
} else {
$Picture = img(Gdn_Upload::url(changeBasename($this->User->Photo, 'p%s')), array('class' => 'ProfilePhotoLarge'));
}
}
// Define the current thumbnail icon
$Thumbnail = $this->User->Photo;
if (!$Thumbnail && function_exists('UserPhotoDefaultUrl')) {
$Thumbnail = UserPhotoDefaultUrl($this->User);
}
if ($Thumbnail && !isUrl($Thumbnail)) {
$Thumbnail = Gdn_Upload::url(changeBasename($Thumbnail, 'n%s'));
}
$Thumbnail = img($Thumbnail, array('alt' => t('Thumbnail')));
?>
<div class="SmallPopup FormTitleWrapper">
<h1 class="H"><?php
echo $this->data('Title');
?>
</h1>
<?php
echo $this->Form->open(array('enctype' => 'multipart/form-data'));
echo $this->Form->errors();
?>
示例4: JoinUsers
/**
* Add user data to a result set.
*
* @param object $Data Results we need to associate user data with.
* @param array $Columns Database columns containing UserIDs to get data for.
* @param array $Options Optionally pass list of user data to collect with key 'Join'.
*/
public function JoinUsers(&$Data, $Columns, $Options = array())
{
// Grab all of the user fields that need to be joined.
$UserIDs = array();
foreach ($Data as $Row) {
foreach ($Columns as $ColumnName) {
$ID = GetValue($ColumnName, $Row);
if (is_numeric($ID)) {
$UserIDs[$ID] = 1;
}
}
}
// Get the users.
$Users = $this->GetIDs(array_keys($UserIDs));
// Get column name prefix (ex: 'Insert' from 'InsertUserID')
$Prefixes = array();
foreach ($Columns as $ColumnName) {
$Prefixes[] = StringEndsWith($ColumnName, 'UserID', TRUE, TRUE);
}
// Join the user data using prefixes (ex: 'Name' for 'InsertUserID' becomes 'InsertName')
$Join = GetValue('Join', $Options, array('Name', 'Email', 'Photo'));
$UserPhotoDefaultUrl = function_exists('UserPhotoDefaultUrl');
foreach ($Data as &$Row) {
foreach ($Prefixes as $Px) {
$ID = GetValue($Px . 'UserID', $Row);
if (is_numeric($ID)) {
$User = GetValue($ID, $Users, FALSE);
foreach ($Join as $Column) {
$Value = $User[$Column];
if ($Column == 'Photo') {
if (!$Value) {
if ($UserPhotoDefaultUrl) {
$Value = UserPhotoDefaultUrl($User);
}
} elseif (!IsUrl($Value)) {
$Value = Gdn_Upload::Url(ChangeBasename($Value, 'n%s'));
}
}
SetValue($Px . $Column, $Row, $Value);
}
} else {
foreach ($Join as $Column) {
SetValue($Px . $Column, $Row, NULL);
}
}
}
}
}
示例5: userPhotoUrl
/**
* Take a user object an return the URL to their photo.
*
* @param object|array $User
*/
function userPhotoUrl($User)
{
$FullUser = Gdn::UserModel()->GetID(GetValue('UserID', $User), DATASET_TYPE_ARRAY);
$Photo = GetValue('Photo', $User);
if ($FullUser && $FullUser['Banned']) {
$Photo = 'http://cdn.vanillaforums.com/images/banned_100.png';
}
if (!$Photo && function_exists('UserPhotoDefaultUrl')) {
$Photo = UserPhotoDefaultUrl($User);
}
if ($Photo) {
if (!isUrl($Photo)) {
$PhotoUrl = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
} else {
$PhotoUrl = $Photo;
}
return $PhotoUrl;
}
return '';
}
示例6: ProfileController_JsConnect_Create
/**
*
* @param Gdn_Controller $Sender
* @param array $Args
*/
public function ProfileController_JsConnect_Create($Sender, $Args = array())
{
include_once dirname(__FILE__) . '/functions.jsconnect.php';
$client_id = $Sender->Request->Get('client_id', 0);
$Provider = self::GetProvider($client_id);
$client_id = GetValue('AuthenticationKey', $Provider);
$Secret = GetValue('AssociationSecret', $Provider);
if (Gdn::Session()->IsValid()) {
$User = ArrayTranslate((array) Gdn::Session()->User, array('UserID' => 'UniqueID', 'Name', 'Email', 'PhotoUrl', 'DateOfBirth', 'Gender'));
// $Sfx = 'F';
// $User['UniqueID'] .= $Sfx;
// $User['Name'] .= $Sfx;
// $User['Email'] = str_replace('@', '+'.$Sfx.'@', $User['Email']);
if (!$User['PhotoUrl'] && function_exists('UserPhotoDefaultUrl')) {
$User['PhotoUrl'] = Url(UserPhotoDefaultUrl(Gdn::Session()->User), TRUE);
}
} else {
$User = array();
}
ob_clean();
WriteJsConnect($User, $Sender->Request->Get(), $client_id, $Secret, GetValue('HashType', $Provider, TRUE));
exit;
}
示例7: profileController_jsConnect_create
/**
*
* @param Gdn_Controller $Sender
* @param array $Args
*/
public function profileController_jsConnect_create($Sender, $Args = array())
{
include_once dirname(__FILE__) . '/functions.jsconnect.php';
$client_id = $Sender->Request->Get('client_id', 0);
$Provider = self::getProvider($client_id);
$client_id = GetValue('AuthenticationKey', $Provider);
$Secret = GetValue('AssociationSecret', $Provider);
if (Gdn::Session()->IsValid()) {
$User = ArrayTranslate((array) Gdn::Session()->User, array('UserID' => 'UniqueID', 'Name', 'Email', 'PhotoUrl', 'DateOfBirth', 'Gender'));
// Grab the user's roles.
$Roles = Gdn::UserModel()->GetRoles(Gdn::Session()->UserID);
$Roles = ConsolidateArrayValuesByKey($Roles, 'Name');
$User['Roles'] = '';
if (is_array($Roles) && sizeof($Roles)) {
$User['Roles'] = implode(',', $Roles);
}
// $Sfx = 'F';
// $User['UniqueID'] .= $Sfx;
// $User['Name'] .= $Sfx;
// $User['Email'] = str_replace('@', '+'.$Sfx.'@', $User['Email']);
if (!$User['PhotoUrl'] && function_exists('UserPhotoDefaultUrl')) {
$User['PhotoUrl'] = Url(UserPhotoDefaultUrl(Gdn::Session()->User), TRUE);
}
} else {
$User = array();
}
ob_clean();
writeJsConnect($User, $Sender->Request->Get(), $client_id, $Secret, GetValue('HashType', $Provider, TRUE));
exit;
}
示例8: joinUsers
/**
* Add user data to a result set.
*
* @param object $Data Results we need to associate user data with.
* @param array $Columns Database columns containing UserIDs to get data for.
* @param array $Options Optionally pass list of user data to collect with key 'Join'.
*/
public function joinUsers(&$Data, $Columns, $Options = array())
{
if ($Data instanceof Gdn_DataSet) {
$Data2 = $Data->result();
} else {
$Data2 =& $Data;
}
// Grab all of the user fields that need to be joined.
$UserIDs = array();
foreach ($Data as $Row) {
foreach ($Columns as $ColumnName) {
$ID = val($ColumnName, $Row);
if (is_numeric($ID)) {
$UserIDs[$ID] = 1;
}
}
}
// Get the users.
$Users = $this->getIDs(array_keys($UserIDs));
// Get column name prefix (ex: 'Insert' from 'InsertUserID')
$Prefixes = array();
foreach ($Columns as $ColumnName) {
$Prefixes[] = StringEndsWith($ColumnName, 'UserID', true, true);
}
// Join the user data using prefixes (ex: 'Name' for 'InsertUserID' becomes 'InsertName')
$Join = val('Join', $Options, array('Name', 'Email', 'Photo'));
$UserPhotoDefaultUrl = function_exists('UserPhotoDefaultUrl');
foreach ($Data2 as &$Row) {
foreach ($Prefixes as $Px) {
$ID = val($Px . 'UserID', $Row);
if (is_numeric($ID)) {
$User = val($ID, $Users, false);
foreach ($Join as $Column) {
$Value = $User[$Column];
if ($Column == 'Photo') {
if (!$Value) {
if ($UserPhotoDefaultUrl) {
$Value = UserPhotoDefaultUrl($User);
}
} elseif (!isUrl($Value)) {
$Value = Gdn_Upload::url(changeBasename($Value, 'n%s'));
}
}
setValue($Px . $Column, $Row, $Value);
}
} else {
foreach ($Join as $Column) {
setValue($Px . $Column, $Row, null);
}
}
}
}
}
示例9: UserPhoto
function UserPhoto($User, $Options = array())
{
$User = (object) $User;
if (is_string($Options)) {
$Options = array('LinkClass' => $Options);
}
$LinkClass = GetValue('LinkClass', $Options, 'ProfileLink');
$ImgClass = GetValue('ImageClass', $Options, 'ProfilePhotoMedium');
$LinkClass = $LinkClass == '' ? '' : ' class="' . $LinkClass . '"';
$Photo = $User->Photo;
if (!$Photo && function_exists('UserPhotoDefaultUrl')) {
$Photo = UserPhotoDefaultUrl($User);
}
if ($Photo) {
if (!preg_match('`^https?://`i', $Photo)) {
$PhotoUrl = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
} else {
$PhotoUrl = $Photo;
}
$Href = Url(UserUrl($User));
return '<a title="' . $User->Name . '" href="' . $Href . '"' . $LinkClass . '>' . Img($PhotoUrl, array('alt' => $User->Name, 'class' => $ImgClass)) . '</a>';
} else {
return '';
}
}
示例10: getDefaultAvatarUrl
/**
* Returns the url to the default avatar for a user.
*
* @param User $user The user to get the default avatar for.
* @param string $size The size of avatar to return (only respected for dashboard-uploaded default avatars).
* @return string The url to the default avatar image.
*/
public static function getDefaultAvatarUrl($user = array(), $size = 'thumbnail')
{
if ($user && function_exists('UserPhotoDefaultUrl')) {
return UserPhotoDefaultUrl($user);
}
if ($avatar = c('Garden.DefaultAvatar', false)) {
if (strpos($avatar, 'uploads/defaultavatar') !== false) {
if ($size == 'thumbnail') {
return changeBasename($avatar, 'n%s');
} elseif ($size == 'profile') {
return changeBasename($avatar, 'p%s');
}
}
return $avatar;
}
return 'applications/dashboard/design/images/defaulticon.png';
}
示例11: UserPhoto
function UserPhoto($User, $Options = array())
{
if (is_string($Options)) {
$Options = array('LinkClass' => $Options);
}
if ($Px = GetValue('Px', $Options)) {
$User = UserBuilder($User, $Px);
} else {
$User = (object) $User;
}
$LinkClass = ConcatSep(' ', GetValue('LinkClass', $Options, ''), 'PhotoWrap');
$ImgClass = GetValue('ImageClass', $Options, 'ProfilePhoto');
$Size = GetValue('Size', $Options);
if ($Size) {
$LinkClass .= " PhotoWrap{$Size}";
$ImgClass .= " {$ImgClass}{$Size}";
} else {
$ImgClass .= " {$ImgClass}Medium";
// backwards compat
}
$FullUser = Gdn::UserModel()->GetID(GetValue('UserID', $User), DATASET_TYPE_ARRAY);
$UserCssClass = GetValue('_CssClass', $FullUser);
if ($UserCssClass) {
$LinkClass .= ' ' . $UserCssClass;
}
$LinkClass = $LinkClass == '' ? '' : ' class="' . $LinkClass . '"';
$Photo = GetValue('Photo', $User);
$Name = GetValue('Name', $User);
$Title = htmlspecialchars(GetValue('Title', $Options, $Name));
if ($FullUser['Banned']) {
$Photo = 'http://cdn.vanillaforums.com/images/banned_100.png';
$Title .= ' (' . T('Banned') . ')';
}
if (!$Photo && function_exists('UserPhotoDefaultUrl')) {
$Photo = UserPhotoDefaultUrl($User, $ImgClass);
}
if ($Photo) {
if (!preg_match('`^https?://`i', $Photo)) {
$PhotoUrl = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
} else {
$PhotoUrl = $Photo;
}
$Href = Url(UserUrl($User));
return '<a title="' . $Title . '" href="' . $Href . '"' . $LinkClass . '>' . Img($PhotoUrl, array('alt' => htmlspecialchars($Name), 'class' => $ImgClass)) . '</a>';
} else {
return '';
}
}
示例12: profileController_jsConnect_create
/**
*
*
* @param Gdn_Controller $Sender
* @param array $Args
*/
public function profileController_jsConnect_create($Sender, $Args = array())
{
include_once dirname(__FILE__) . '/functions.jsconnect.php';
$client_id = $Sender->Request->get('client_id', 0);
$Provider = self::getProvider($client_id);
$client_id = val('AuthenticationKey', $Provider);
$Secret = val('AssociationSecret', $Provider);
if (Gdn::session()->isValid()) {
$User = ArrayTranslate((array) Gdn::session()->User, array('UserID' => 'UniqueID', 'Name', 'Email', 'PhotoUrl', 'DateOfBirth', 'Gender'));
// Grab the user's roles.
$Roles = Gdn::userModel()->getRoles(Gdn::session()->UserID);
$Roles = array_column($Roles, 'Name');
$User['Roles'] = '';
if (is_array($Roles) && sizeof($Roles)) {
$User['Roles'] = implode(',', $Roles);
}
if (!$User['PhotoUrl'] && function_exists('UserPhotoDefaultUrl')) {
$User['PhotoUrl'] = Url(UserPhotoDefaultUrl(Gdn::session()->User), true);
}
} else {
$User = [];
}
ob_clean();
writeJsConnect($User, $Sender->Request->get(), $client_id, $Secret, val('HashType', $Provider, true));
exit;
}