本文整理匯總了PHP中IsUrl函數的典型用法代碼示例。如果您正苦於以下問題:PHP IsUrl函數的具體用法?PHP IsUrl怎麽用?PHP IsUrl使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了IsUrl函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: smarty_function_include_file
/**
* Includes a file in template. Handy for adding html files to tpl files
*
* @param array The parameters passed into the function.
* The parameters that can be passed to this function are as follows.
* - <b>name</b>: The name of the file.
* @param Smarty The smarty object rendering the template.
* @return The rendered asset.
*/
function smarty_function_include_file($Params, &$Smarty)
{
$Name = ltrim(ArrayValue('name', $Params), '/');
if (strpos($Name, '..') !== false) {
return '<!-- Error, moving up directory path not allowed -->';
}
if (IsUrl($Name)) {
return '<!-- Error, urls are not allowed -->';
}
$filename = rtrim($Smarty->template_dir, '/') . '/' . $Name;
if (!file_exists($filename)) {
return '<!-- Error, file does not exist -->';
}
return file_get_contents($filename);
}
示例2: val
<?php
if (!defined('APPLICATION')) {
exit;
}
$User = val('User', Gdn::controller());
if (!$User && Gdn::session()->isValid()) {
$User = Gdn::session()->User;
}
if (!$User) {
return;
}
$Photo = $User->Photo;
if ($Photo) {
if (!IsUrl($Photo)) {
$Photo = Gdn_Upload::url(changeBasename($Photo, 'p%s'));
}
} else {
$Photo = UserModel::getDefaultAvatarUrl($User, 'profile');
}
if ($User->Banned) {
$BannedPhoto = c('Garden.BannedPhoto', 'https://c3409409.ssl.cf0.rackcdn.com/images/banned_large.png');
if ($BannedPhoto) {
$Photo = Gdn_Upload::url($BannedPhoto);
}
}
if ($Photo) {
?>
<div class="Photo PhotoWrap PhotoWrapLarge <?php
echo val('_CssClass', $User);
?>
示例3: CssPath
public static function CssPath($ThemeType, $Filename, $Folder)
{
if (!$ThemeType) {
$ThemeType = IsMobile() ? 'mobile' : 'desktop';
}
// 1. Check for a url.
if (IsUrl($Filename)) {
return array($Filename, $Filename);
}
// 2. Check for a full path.
if (strpos($Filename, '/') !== FALSE) {
$Filename = '/' . ltrim($Filename, '/');
$Path = PATH_ROOT . $Filename;
if (file_exists($Path)) {
return array($Path, $Filename);
} else {
return FALSE;
}
}
// 3. Check the theme.
if ($Theme = Gdn::ThemeManager()->ThemeFromType($ThemeType)) {
$Paths[] = array(PATH_THEMES . "/{$Theme}/design/{$Filename}", "/themes/{$Theme}/design/{$Filename}");
}
if ($Folder) {
// 4. Check static, a plugin or application.
if (in_array($Folder, array('resources', 'static'))) {
$path = "/resources/css/{$Filename}";
$Paths[] = array(PATH_ROOT . $path, $path);
} elseif (StringBeginsWith($Folder, 'plugins/')) {
$Folder = substr($Folder, strlen('plugins/'));
$Paths[] = array(PATH_PLUGINS . "/{$Folder}/design/{$Filename}", "/plugins/{$Folder}/design/{$Filename}");
$Paths[] = array(PATH_PLUGINS . "/{$Folder}/{$Filename}", "/plugins/{$Folder}/{$Filename}");
} else {
$Paths[] = array(PATH_APPLICATIONS . "/{$Folder}/design/{$Filename}", "/applications/{$Folder}/design/{$Filename}");
}
}
// 5. Check the default.
if ($Folder != 'dashboard') {
$Paths[] = array(PATH_APPLICATIONS . '/dashboard/design/$Filename', "/applications/dashboard/design/{$Filename}");
}
foreach ($Paths as $Info) {
if (file_exists($Info[0])) {
return $Info;
}
}
return FALSE;
}
示例4: BuildEditMenu
/**
* @param SideMenuModule $Module
* @param string $CurrentUrl
*/
public function BuildEditMenu(&$Module, $CurrentUrl = '')
{
if (!$this->User) {
return;
}
$Module->HtmlId = 'UserOptions';
$Module->AutoLinkGroups = FALSE;
$Session = Gdn::Session();
$ViewingUserID = $Session->UserID;
$Module->AddItem('Options', '', FALSE, array('class' => 'SideMenu'));
// Check that we have the necessary tools to allow image uploading
$AllowImages = C('Garden.Profile.EditPhotos', TRUE) && Gdn_UploadImage::CanUploadImages();
// Is the photo hosted remotely?
$RemotePhoto = IsUrl($this->User->Photo);
if ($this->User->UserID != $ViewingUserID) {
// Include user js files for people with edit users permissions
if (CheckPermission('Garden.Users.Edit') || CheckPermission('Moderation.Profiles.Edit')) {
// $this->AddJsFile('jquery.gardenmorepager.js');
$this->AddJsFile('user.js');
}
$Module->AddLink('Options', Sprite('SpProfile') . ' ' . T('Edit Profile'), UserUrl($this->User, '', 'edit'), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'Popup EditAccountLink'));
$Module->AddLink('Options', Sprite('SpProfile') . ' ' . T('Edit Account'), '/user/edit/' . $this->User->UserID, 'Garden.Users.Edit', array('class' => 'Popup EditAccountLink'));
$Module->AddLink('Options', Sprite('SpDelete') . ' ' . T('Delete Account'), '/user/delete/' . $this->User->UserID, 'Garden.Users.Delete', array('class' => 'Popup DeleteAccountLink'));
if ($this->User->Photo != '' && $AllowImages) {
$Module->AddLink('Options', Sprite('SpDelete') . ' ' . T('Remove Picture'), CombinePaths(array(UserUrl($this->User, '', 'removepicture'), $Session->TransientKey())), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'RemovePictureLink'));
}
$Module->AddLink('Options', Sprite('SpPreferences') . ' ' . T('Edit Preferences'), UserUrl($this->User, '', 'preferences'), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'Popup PreferencesLink'));
// Add profile options for everyone
$Module->AddLink('Options', Sprite('SpPicture') . ' ' . T('Change Picture'), UserUrl($this->User, '', 'picture'), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'PictureLink'));
if ($this->User->Photo != '' && $AllowImages && !$RemotePhoto) {
$Module->AddLink('Options', Sprite('SpThumbnail') . ' ' . T('Edit Thumbnail'), UserUrl($this->User, '', 'thumbnail'), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'ThumbnailLink'));
}
} else {
// Add profile options for the profile owner
// Don't allow account editing if it has been turned off.
// Don't allow password editing if using SSO Connect ONLY.
// This is for security. We encountered the case where a customer charges
// for membership using their external application and use SSO to let
// their customers into Vanilla. If you allow those people to change their
// password in Vanilla, they will then be able to log into Vanilla using
// Vanilla's login form regardless of the state of their membership in the
// external app.
if (C('Garden.UserAccount.AllowEdit') && C('Garden.Registration.Method') != 'Connect') {
$Module->AddLink('Options', Sprite('SpEdit') . ' ' . T('Edit Profile'), '/profile/edit', FALSE, array('class' => 'Popup EditAccountLink'));
// No password may have been set if they have only signed in with a connect plugin
$PasswordLabel = T('Change My Password');
if ($this->User->HashMethod && $this->User->HashMethod != "Vanilla") {
$PasswordLabel = T('Set A Password');
}
$Module->AddLink('Options', Sprite('SpPassword') . ' ' . $PasswordLabel, '/profile/password', FALSE, array('class' => 'Popup PasswordLink'));
}
$Module->AddLink('Options', Sprite('SpPreferences') . ' ' . T('Notification Preferences'), UserUrl($this->User, '', 'preferences'), FALSE, array('class' => 'Popup PreferencesLink'));
if ($AllowImages) {
$Module->AddLink('Options', Sprite('SpPicture') . ' ' . T('Change My Picture'), '/profile/picture', array('Garden.Profiles.Edit', 'Garden.ProfilePicture.Edit'), array('class' => 'PictureLink'));
}
if ($this->User->Photo != '' && $AllowImages && !$RemotePhoto) {
$Module->AddLink('Options', Sprite('SpThumbnail') . ' ' . T('Edit My Thumbnail'), '/profile/thumbnail', array('Garden.Profiles.Edit', 'Garden.ProfilePicture.Edit'), array('class' => 'ThumbnailLink'));
}
}
if ($this->User->UserID == $ViewingUserID || $Session->CheckPermission('Garden.Users.Edit')) {
$this->SetData('Connections', array());
$this->EventArguments['User'] = $this->User;
$this->FireEvent('GetConnections');
if (count($this->Data('Connections')) > 0) {
$Module->AddLink('Options', Sprite('SpConnection') . ' ' . T('Social'), '/profile/connections', 'Garden.SignIn.Allow');
}
}
}
示例5: SetCalculatedFields
public function SetCalculatedFields(&$User)
{
if ($v = GetValue('Attributes', $User)) {
if (is_string($v)) {
SetValue('Attributes', $User, @unserialize($v));
}
}
if ($v = GetValue('Permissions', $User)) {
SetValue('Permissions', $User, @unserialize($v));
}
if ($v = GetValue('Preferences', $User)) {
SetValue('Preferences', $User, @unserialize($v));
}
if ($v = GetValue('Photo', $User)) {
if (!IsUrl($v)) {
$PhotoUrl = Gdn_Upload::Url(ChangeBasename($v, 'n%s'));
} else {
$PhotoUrl = $v;
}
SetValue('PhotoUrl', $User, $PhotoUrl);
}
if ($v = GetValue('AllIPAddresses', $User)) {
$IPAddresses = explode(',', $v);
foreach ($IPAddresses as $i => $IPAddress) {
$IPAddresses[$i] = ForceIPv4($IPAddress);
}
SetValue('AllIPAddresses', $User, $IPAddresses);
}
TouchValue('_CssClass', $User, '');
if ($v = GetValue('Banned', $User)) {
SetValue('_CssClass', $User, 'Banned');
}
$this->EventArguments['User'] =& $User;
$this->FireEvent('SetCalculatedFields');
}
示例6: img
/**
* Returns an img tag.
*/
function img($Image, $Attributes = '', $WithDomain = false)
{
if ($Attributes != '') {
$Attributes = Attribute($Attributes);
}
if (preg_match('/^(.*)AvatarFirstLetter_(.+)$/', $Image, $matches)) {
$name = $matches[2];
$firstLetter = substr($name, 0, 1);
$rgb = AvatarFirstLetter::stringToColor($name);
$Image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQI12NgYAAAAAMAASDVlMcAAAAASUVORK5CYII=';
$output = '<span class="AvatarFirstLetter" style="background-color: ' . $rgb . ';">';
$output .= '<img src="' . $Image . '"' . $Attributes . ' />';
$output .= '<span>' . $firstLetter . '</span>';
$output .= '</span>';
return $output;
}
if (!IsUrl($Image)) {
$Image = SmartAsset($Image, $WithDomain);
}
return '<img src="' . $Image . '"' . $Attributes . ' />';
}
示例7: 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);
}
示例8: smartAsset
/**
* Takes the path to an asset (image, js file, css file, etc) and prepends the web root.
*
* @param string $Destination The subpath of the asset.
* @param bool|string $WithDomain Whether or not to include the domain in the final URL.
* @param bool $AddVersion Whether or not to add a cache-busting version querystring parameter to the URL.
* @return string Returns the URL of the asset.
*/
function smartAsset($Destination = '', $WithDomain = false, $AddVersion = false)
{
$Destination = str_replace('\\', '/', $Destination);
if (IsUrl($Destination)) {
$Result = $Destination;
} else {
$Result = Gdn::Request()->UrlDomain($WithDomain) . Gdn::Request()->AssetRoot() . '/' . ltrim($Destination, '/');
}
if ($AddVersion) {
if (strpos($Result, '?') === false) {
$Result .= '?';
} else {
$Result .= '&';
}
// Figure out which version to put after the asset.
$Version = APPLICATION_VERSION;
if (preg_match('`^/([^/]+)/([^/]+)/`', $Destination, $Matches)) {
$Type = $Matches[1];
$Key = $Matches[2];
static $ThemeVersion = null;
switch ($Type) {
case 'plugins':
$PluginInfo = Gdn::PluginManager()->GetPluginInfo($Key);
$Version = GetValue('Version', $PluginInfo, $Version);
break;
case 'themes':
if ($ThemeVersion === null) {
$ThemeInfo = Gdn::ThemeManager()->GetThemeInfo(Theme());
if ($ThemeInfo !== false) {
$ThemeVersion = GetValue('Version', $ThemeInfo, $Version);
} else {
$ThemeVersion = $Version;
}
}
$Version = $ThemeVersion;
break;
}
}
$Result .= 'v=' . urlencode($Version);
}
return $Result;
}
示例9: _processImportUriCB
private static function _processImportUriCB($m)
{
$uri = trim($m[1], '()"\' ');
// We want to grab the import.
if (strpos($uri, '//') !== false) {
$path = $uri;
} elseif ($uri[0] == '/') {
$path = self::_realpath(self::$_docRoot, $uri);
} else {
$path = realpath2(self::$_currentDir . '/' . trim($uri, '/\\'));
if (substr_compare(self::$_docRoot, $path, 0, strlen($path)) != 0) {
return "/* Error: {$uri} isn't in the webroot. */\n";
} elseif (substr_compare($path, '.css', -4, 4, true) != 0) {
return "/* Error: {$uri} must end in .css. */\n";
}
}
$css = file_get_contents($path);
// Not so fast, we've got to rewrite this file too. What's more, the current dir and path are different.
$bak = array(self::$_currentDir, self::$_prependPath, self::$_docRoot, self::$debugText);
self::$debugText = '';
if (IsUrl($path)) {
$newCurrentDir = $path;
$newDocRoot = $path;
} else {
$newDocRoot = self::$_docRoot;
$newCurrentDir = realpath2($currentDirBak . realpath2(dirname($uri)));
}
$css = self::rewrite($css, $newCurrentDir, $newDocRoot);
list(self::$_currentDir, self::$_prependPath, self::$_docRoot, self::$debugText) = $bak;
return "/* @include url('{$uri}'); */\n" . $css;
}
示例10: ParseSpecialFields
/**
* Special manipulations.
*/
public function ParseSpecialFields($Fields = array())
{
if (!is_array($Fields)) {
return $Fields;
}
foreach ($Fields as $Label => $Value) {
if ($Value == '') {
continue;
}
// Use plaintext for building these
$Value = Gdn_Format::Text($Value);
switch ($Label) {
case 'Twitter':
$Fields['Twitter'] = Anchor('@' . $Value, 'http://twitter.com/' . $Value);
break;
case 'Facebook':
$Fields['Facebook'] = Anchor($Value, 'http://facebook.com/' . $Value);
break;
case 'LinkedIn':
$Fields['LinkedIn'] = Anchor($Value, 'http://www.linkedin.com/in/' . $Value);
break;
case 'Google':
$Fields['Google'] = Anchor('Google+', $Value, '', array('rel' => 'me'));
break;
case 'Website':
$LinkValue = IsUrl($Value) ? $Value : 'http://' . $Value;
$Fields['Website'] = Anchor($Value, $LinkValue);
break;
case 'Real Name':
$Fields['Real Name'] = Wrap(htmlspecialchars($Value), 'span', array('itemprop' => 'name'));
break;
}
}
return $Fields;
}
示例11: cssPath
/**
* Lookup the path to a CSS file and return its info array
*
* @param string $Filename name/relative path to css file
* @param string $Folder optional. app or plugin folder to search
* @param string $ThemeType mobile or desktop
* @return array|bool
*/
public static function cssPath($Filename, $Folder = '', $ThemeType = '')
{
if (!$ThemeType) {
$ThemeType = IsMobile() ? 'mobile' : 'desktop';
}
// 1. Check for a url.
if (IsUrl($Filename)) {
return array($Filename, $Filename);
}
$Paths = array();
// 2. Check for a full path.
if (strpos($Filename, '/') !== false) {
$Filename = ltrim($Filename, '/');
// Direct path was given
$Filename = "/{$Filename}";
$Path = PATH_ROOT . $Filename;
if (file_exists($Path)) {
Deprecated("AssetModel::CssPath() with direct paths");
return array($Path, $Filename);
}
return false;
}
// 3. Check the theme.
$Theme = Gdn::ThemeManager()->ThemeFromType($ThemeType);
if ($Theme) {
$Path = "/{$Theme}/design/{$Filename}";
$Paths[] = array(PATH_THEMES . $Path, "/themes{$Path}");
}
// 4. Static, Plugin, or App relative file
if ($Folder) {
if (in_array($Folder, array('resources', 'static'))) {
$Path = "/resources/design/{$Filename}";
$Paths[] = array(PATH_ROOT . $Path, $Path);
// A plugin-relative path was given
} elseif (stringBeginsWith($Folder, 'plugins/')) {
$Folder = substr($Folder, strlen('plugins/'));
$Path = "/{$Folder}/design/{$Filename}";
$Paths[] = array(PATH_PLUGINS . $Path, "/plugins{$Path}");
// Allow direct-to-file links for plugins
$Paths[] = array(PATH_PLUGINS . "/{$Folder}/{$Filename}", "/plugins/{$Folder}/{$Filename}", true);
// deprecated
// An app-relative path was given
} else {
$Path = "/{$Folder}/design/{$Filename}";
$Paths[] = array(PATH_APPLICATIONS . $Path, "/applications{$Path}");
}
}
// 5. Check the default application.
if ($Folder != 'dashboard') {
$Paths[] = array(PATH_APPLICATIONS . "/dashboard/design/{$Filename}", "/applications/dashboard/design/{$Filename}", true);
// deprecated
}
foreach ($Paths as $Info) {
if (file_exists($Info[0])) {
if (!empty($Info[2])) {
// This path is deprecated.
unset($Info[2]);
Deprecated("The css file '{$Filename}' in folder '{$Folder}'");
}
return $Info;
}
}
if (!(StringEndsWith($Filename, 'custom.css') || StringEndsWith($Filename, 'customadmin.css'))) {
trace("Could not find file '{$Filename}' in folder '{$Folder}'.");
}
return false;
}
示例12: smartAsset
/**
* Takes the path to an asset (image, js file, css file, etc) and prepends the web root.
*
* @param string $Destination The subpath of the asset.
* @param bool|string $WithDomain Whether or not to include the domain in the final URL.
* @param bool $AddVersion Whether or not to add a cache-busting version querystring parameter to the URL.
* @return string Returns the URL of the asset.
*/
function smartAsset($Destination = '', $WithDomain = false, $AddVersion = false)
{
$Destination = str_replace('\\', '/', $Destination);
if (IsUrl($Destination)) {
$Result = $Destination;
} else {
$Result = Gdn::Request()->UrlDomain($WithDomain) . Gdn::Request()->AssetRoot() . '/' . ltrim($Destination, '/');
}
if ($AddVersion) {
$Version = assetVersion($Destination);
$Result .= (strpos($Result, '?') === false ? '?' : '&') . 'v=' . urlencode($Version);
}
return $Result;
}
示例13: C
}
$Photo = $User->Photo;
if ($User->Banned) {
$BannedPhoto = C('Garden.BannedPhoto', 'http://cdn.vanillaforums.com/images/banned_large.png');
if ($BannedPhoto) {
$Photo = Gdn_Upload::Url($BannedPhoto);
}
}
if ($Photo) {
?>
<div class="Photo PhotoWrap PhotoWrapLarge <?php
echo GetValue('_CssClass', $User);
?>
">
<?php
if (IsUrl($Photo)) {
$Img = Img($Photo, array('class' => 'ProfilePhotoLarge'));
} else {
$Img = Img(Gdn_Upload::Url(ChangeBasename($Photo, 'p%s')), array('class' => 'ProfilePhotoLarge'));
}
if (!$User->Banned && C('Garden.Profile.EditPhotos', TRUE) && (Gdn::Session()->UserID == $User->UserID || Gdn::Session()->CheckPermission('Garden.Users.Edit'))) {
echo Anchor(Wrap(T('Change Picture')), '/profile/picture?userid=' . $User->UserID, 'ChangePicture');
}
echo $Img;
?>
</div>
<?php
} else {
if ($User->UserID == Gdn::Session()->UserID || Gdn::Session()->CheckPermission('Garden.Users.Edit')) {
?>
<div class="Photo"><?php
示例14: ToString
/**
* Render the entire head module.
*/
public function ToString()
{
// Add the canonical Url if necessary.
if (method_exists($this->_Sender, 'CanonicalUrl') && !C('Garden.Modules.NoCanonicalUrl', FALSE)) {
$CanonicalUrl = $this->_Sender->CanonicalUrl();
if (!IsUrl($CanonicalUrl)) {
$CanonicalUrl = Gdn::Router()->ReverseRoute($CanonicalUrl);
}
$this->_Sender->CanonicalUrl($CanonicalUrl);
// $CurrentUrl = Url('', TRUE);
// if ($CurrentUrl != $CanonicalUrl) {
$this->AddTag('link', array('rel' => 'canonical', 'href' => $CanonicalUrl));
// }
}
// Include facebook open-graph meta information.
if ($FbAppID = C('Plugins.Facebook.ApplicationID')) {
$this->AddTag('meta', array('property' => 'fb:app_id', 'content' => $FbAppID));
}
$SiteName = C('Garden.Title', '');
if ($SiteName != '') {
$this->AddTag('meta', array('property' => 'og:site_name', 'content' => $SiteName));
}
$Title = Gdn_Format::Text($this->Title('', TRUE));
if ($Title != '') {
$this->AddTag('meta', array('property' => 'og:title', 'itemprop' => 'name', 'content' => $Title));
}
if (isset($CanonicalUrl)) {
$this->AddTag('meta', array('property' => 'og:url', 'content' => $CanonicalUrl));
}
if ($Description = $this->_Sender->Description()) {
$this->AddTag('meta', array('name' => 'description', 'property' => 'og:description', 'itemprop' => 'description', 'content' => $Description));
}
// Default to the site logo if there were no images provided by the controller.
if (count($this->_Sender->Image()) == 0) {
$Logo = C('Garden.ShareImage', C('Garden.Logo', ''));
if ($Logo != '') {
// Fix the logo path.
if (StringBeginsWith($Logo, 'uploads/')) {
$Logo = substr($Logo, strlen('uploads/'));
}
$Logo = Gdn_Upload::Url($Logo);
$this->AddTag('meta', array('property' => 'og:image', 'itemprop' => 'image', 'content' => $Logo));
}
} else {
foreach ($this->_Sender->Image() as $Img) {
$this->AddTag('meta', array('property' => 'og:image', 'itemprop' => 'image', 'content' => $Img));
}
}
$this->FireEvent('BeforeToString');
$Tags = $this->_Tags;
// Make sure that css loads before js (for jquery)
usort($this->_Tags, array('HeadModule', 'TagCmp'));
// "link" comes before "script"
$Tags2 = $this->_Tags;
// Start with the title.
$Head = '<title>' . Gdn_Format::Text($this->Title()) . "</title>\n";
$TagStrings = array();
// Loop through each tag.
foreach ($this->_Tags as $Index => $Attributes) {
$Tag = $Attributes[self::TAG_KEY];
// Inline the content of the tag, if necessary.
if (GetValue('_hint', $Attributes) == 'inline') {
$Path = GetValue('_path', $Attributes);
if (!StringBeginsWith($Path, 'http')) {
$Attributes[self::CONTENT_KEY] = file_get_contents($Path);
if (isset($Attributes['src'])) {
$Attributes['_src'] = $Attributes['src'];
unset($Attributes['src']);
}
if (isset($Attributes['href'])) {
$Attributes['_href'] = $Attributes['href'];
unset($Attributes['href']);
}
}
}
// If we set an IE conditional AND a "Not IE" condition, we will need to make a second pass.
do {
// Reset tag string
$TagString = '';
// IE conditional? Validates condition.
$IESpecific = isset($Attributes['_ie']) && preg_match('/((l|g)t(e)? )?IE [0-9\\.]/', $Attributes['_ie']);
// Only allow $NotIE if we're not doing a conditional this loop.
$NotIE = !$IESpecific && isset($Attributes['_notie']);
// Open IE conditional tag
if ($IESpecific) {
$TagString .= '<!--[if ' . $Attributes['_ie'] . ']>';
}
if ($NotIE) {
$TagString .= '<!--[if !IE]> -->';
}
// Build tag
$TagString .= ' <' . $Tag . Attribute($Attributes, '_');
if (array_key_exists(self::CONTENT_KEY, $Attributes)) {
$TagString .= '>' . $Attributes[self::CONTENT_KEY] . '</' . $Tag . '>';
} elseif ($Tag == 'script') {
$TagString .= '></script>';
} else {
//.........這裏部分代碼省略.........
示例15: IsUrl
$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">
<h2 class="H"><?php
echo $this->Data('Title');
?>
</h2>
<?php
echo $this->Form->Open(array('enctype' => 'multipart/form-data'));
echo $this->Form->Errors();
?>
<ul>
<?php