本文整理汇总了PHP中Gdn_Upload::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Upload::url方法的具体用法?PHP Gdn_Upload::url怎么用?PHP Gdn_Upload::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Upload
的用法示例。
在下文中一共展示了Gdn_Upload::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doAttachment
/**
* Perform formatting against a string for the attach tag.
*
* @param Nbbc $bbcode Instance of Nbbc doing the parsing.
* @param int $action Value of one of NBBC's defined constants. Typically, this will be BBCODE_CHECK.
* @param string $name Name of the tag.
* @param string $default Value of the _default parameter, from the $params array.
* @param array $params A standard set parameters related to the tag.
* @param string $content Value between the open and close tags, if any.
* @return string Formatted value.
*/
public function doAttachment($bbcode, $action, $name, $default, $params, $content)
{
$medias = $this->media();
$mediaID = $content;
if (isset($medias[$mediaID])) {
$media = $medias[$mediaID];
$src = htmlspecialchars(Gdn_Upload::url(val('Path', $media)));
$name = htmlspecialchars(val('Name', $media));
if (val('ImageWidth', $media)) {
return "<div class=\"Attachment Image\"><img src=\"{$src}\" alt=\"{$name}\" /></div>";
} else {
return anchor($name, $src, 'Attachment File');
}
}
return anchor(t('Attachment not found.'), '#', 'Attachment NotFound');
}
示例2: index
/**
*
*
* @param string $ID
* @param string $ServeFile
*/
public function index($ID = '', $ServeFile = '0')
{
$this->addJsFile('jquery.js');
// Define the item being downloaded
if (strtolower($ID) == 'vanilla') {
$ID = 'vanilla-core';
}
$UrlFilename = Gdn::request()->filename();
$PathInfo = pathinfo($UrlFilename);
$Ext = val('extension', $PathInfo);
if ($Ext == 'zip') {
$ServeFile = '1';
$ID = $Ext = val('filename', $PathInfo);
}
// Find the requested addon
$this->Addon = $this->AddonModel->getSlug($ID, true);
$this->setData('Addon', $this->Addon);
if (!is_array($this->Addon) || !val('File', $this->Addon)) {
$this->Addon = array('Name' => 'Not Found', 'Version' => 'undefined', 'File' => '');
} else {
$AddonID = $this->Addon['AddonID'];
if ($ServeFile != '1') {
$this->addJsFile('get.js');
}
if ($ServeFile == '1') {
// Record this download
$this->Database->sql()->insert('Download', array('AddonID' => $AddonID, 'DateInserted' => Gdn_Format::toDateTime(), 'RemoteIp' => @$_SERVER['REMOTE_ADDR']));
$this->AddonModel->setProperty($AddonID, 'CountDownloads', $this->Addon['CountDownloads'] + 1);
if (val('Slug', $this->Addon)) {
$Filename = $this->Addon['Slug'];
} else {
$Filename = "{$this->Addon['Name']}-{$this->Addon['Version']}";
}
$Filename = Gdn_Format::url($Filename) . '.zip';
$File = $this->Addon['File'];
$Url = Gdn_Upload::url($File);
Gdn_FileSystem::serveFile($Url, $Filename);
}
}
$this->addModule('AddonHelpModule');
$this->render();
}
示例3: writeAddon
/**
*
*
* @param $Addon
* @param $Alt
*/
function writeAddon($Addon, $Alt)
{
$Url = '/addon/' . AddonModel::slug($Addon, FALSE);
?>
<li class="Item AddonRow<?php
echo $Alt;
?>
">
<?php
if ($Addon->Icon != '') {
echo '<a class="Icon" href="' . url($Url) . '"><div class="IconWrap"><img src="' . Gdn_Upload::url($Addon->Icon) . '" /></div></a>';
}
?>
<div class="ItemContent">
<?php
echo anchor(htmlspecialchars($Addon->Name), $Url, 'Title');
echo '<div class="Description">', anchor(htmlspecialchars(sliceString(Gdn_Format::text($Addon->Description), 300)), $Url), '</div>';
?>
<div class="Meta">
<span class="TypeTag"><?php
echo $Addon->Type;
?>
</span>
<?php
if ($Addon->Type === 'Locale') {
?>
<?php
if (!is_null($Addon->EnName)) {
?>
<span class="EnName">
Name (en)
<span><?php
echo htmlspecialchars($Addon->EnName);
?>
</span>
</span>
<?php
}
?>
<?php
if (!is_null($Addon->PercentComplete)) {
?>
<span class="PercentComplete">
Translated
<span><?php
echo (int) $Addon->PercentComplete . '%';
?>
</span>
</span>
<?php
}
?>
<?php
} else {
?>
<span class="Version">
Version
<span><?php
echo htmlspecialchars($Addon->Version);
?>
</span>
</span>
<?php
}
?>
<span class="Author">
Author
<span><?php
echo val('Official', $Addon) ? t('Vanilla Staff') : htmlspecialchars($Addon->InsertName);
?>
</span>
</span>
<span class="Downloads">
Downloads
<span><?php
echo number_format($Addon->CountDownloads);
?>
</span>
</span>
<span class="Updated">
Updated
<span><?php
echo Gdn_Format::date($Addon->DateUpdated, 'html');
?>
</span>
</span>
</div>
</div>
</li>
<?php
}
示例4: userPhotoUrl
/**
* Take a user object an return the URL to their photo.
*
* @param object|array $User
*/
function userPhotoUrl($User)
{
$FullUser = Gdn::userModel()->getID(val('UserID', $User), DATASET_TYPE_ARRAY);
$Photo = val('Photo', $User);
if ($FullUser && $FullUser['Banned']) {
$Photo = 'https://c3409409.ssl.cf0.rackcdn.com/images/banned_100.png';
}
if ($Photo) {
if (!isUrl($Photo)) {
$PhotoUrl = Gdn_Upload::url(changeBasename($Photo, 'n%s'));
} else {
$PhotoUrl = $Photo;
}
return $PhotoUrl;
}
return UserModel::getDefaultAvatarUrl($User);
}
示例5: mobileLogo
/**
* Returns the mobile banner logo. If there is no mobile logo defined then this will just return
* the regular logo or the mobile title.
*
* @return string
*/
public static function mobileLogo()
{
$Logo = C('Garden.MobileLogo', C('Garden.Logo'));
$Title = C('Garden.MobileTitle', C('Garden.Title', 'Title'));
if ($Logo) {
return Img(Gdn_Upload::url($Logo), array('alt' => $Title));
} else {
return $Title;
}
}
示例6: renderMaster
/**
*
*/
public function renderMaster()
{
// Build the master view if necessary
if (in_array($this->_DeliveryType, array(DELIVERY_TYPE_ALL))) {
$this->MasterView = $this->masterView();
// Only get css & ui components if this is NOT a syndication request
if ($this->SyndicationMethod == SYNDICATION_NONE && is_object($this->Head)) {
$CssAnchors = AssetModel::getAnchors();
$this->EventArguments['CssFiles'] =& $this->_CssFiles;
$this->fireEvent('BeforeAddCss');
$ETag = AssetModel::eTag();
$CombineAssets = c('Garden.CombineAssets');
$ThemeType = isMobile() ? 'mobile' : 'desktop';
// And now search for/add all css files.
foreach ($this->_CssFiles as $CssInfo) {
$CssFile = $CssInfo['FileName'];
if (!array_key_exists('Options', $CssInfo) || !is_array($CssInfo['Options'])) {
$CssInfo['Options'] = array();
}
$Options =& $CssInfo['Options'];
// style.css and admin.css deserve some custom processing.
if (in_array($CssFile, $CssAnchors)) {
if (!$CombineAssets) {
// Grab all of the css files from the asset model.
$AssetModel = new AssetModel();
$CssFiles = $AssetModel->getCssFiles($ThemeType, ucfirst(substr($CssFile, 0, -4)), $ETag);
foreach ($CssFiles as $Info) {
$this->Head->addCss($Info[1], 'all', true, $CssInfo);
}
} else {
$Basename = substr($CssFile, 0, -4);
$this->Head->addCss(url("/asset/css/{$ThemeType}/{$Basename}-{$ETag}.css", '//'), 'all', false, $CssInfo['Options']);
}
continue;
}
$AppFolder = $CssInfo['AppFolder'];
$LookupFolder = !empty($AppFolder) ? $AppFolder : $this->ApplicationFolder;
$Search = AssetModel::CssPath($CssFile, $LookupFolder, $ThemeType);
if (!$Search) {
continue;
}
list($Path, $UrlPath) = $Search;
if (isUrl($Path)) {
$this->Head->AddCss($Path, 'all', val('AddVersion', $Options, true), $Options);
continue;
} else {
// Check to see if there is a CSS cacher.
$CssCacher = Gdn::factory('CssCacher');
if (!is_null($CssCacher)) {
$Path = $CssCacher->get($Path, $AppFolder);
}
if ($Path !== false) {
$Path = substr($Path, strlen(PATH_ROOT));
$Path = str_replace(DS, '/', $Path);
$this->Head->addCss($Path, 'all', true, $Options);
}
}
}
// Add a custom js file.
if (arrayHasValue($this->_CssFiles, 'style.css')) {
$this->addJsFile('custom.js');
// only to non-admin pages.
}
$Cdns = array();
if (!c('Garden.Cdns.Disable', false)) {
$Cdns = array('jquery.js' => "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js");
}
// And now search for/add all JS files.
$this->EventArguments['Cdns'] =& $Cdns;
$this->fireEvent('AfterJsCdns');
$this->Head->addScript('', 'text/javascript', false, array('content' => $this->definitionList(false)));
foreach ($this->_JsFiles as $Index => $JsInfo) {
$JsFile = $JsInfo['FileName'];
if (!is_array($JsInfo['Options'])) {
$JsInfo['Options'] = array();
}
$Options =& $JsInfo['Options'];
if (isset($Cdns[$JsFile])) {
$JsFile = $Cdns[$JsFile];
}
$AppFolder = $JsInfo['AppFolder'];
$LookupFolder = !empty($AppFolder) ? $AppFolder : $this->ApplicationFolder;
$Search = AssetModel::JsPath($JsFile, $LookupFolder, $ThemeType);
if (!$Search) {
continue;
}
list($Path, $UrlPath) = $Search;
if ($Path !== false) {
$AddVersion = true;
if (!isUrl($Path)) {
$Path = substr($Path, strlen(PATH_ROOT));
$Path = str_replace(DS, '/', $Path);
$AddVersion = val('AddVersion', $Options, true);
}
$this->Head->addScript($Path, 'text/javascript', $AddVersion, $Options);
continue;
}
//.........这里部分代码省略.........
示例7: setCalculatedFields
/**
* Set fields that need additional manipulation after retrieval.
*
* @param $User
* @throws Exception
*/
public function setCalculatedFields(&$User)
{
if ($v = val('Attributes', $User)) {
if (is_string($v)) {
setValue('Attributes', $User, @unserialize($v));
}
}
if ($v = val('Permissions', $User)) {
if (is_string($v)) {
setValue('Permissions', $User, @unserialize($v));
}
}
if ($v = val('Preferences', $User)) {
if (is_string($v)) {
setValue('Preferences', $User, @unserialize($v));
}
}
if ($v = val('Photo', $User)) {
if (!isUrl($v)) {
$PhotoUrl = Gdn_Upload::url(changeBasename($v, 'n%s'));
} else {
$PhotoUrl = $v;
}
setValue('PhotoUrl', $User, $PhotoUrl);
}
if ($v = val('AllIPAddresses', $User)) {
if (is_string($v)) {
$IPAddresses = explode(',', $v);
foreach ($IPAddresses as $i => $IPAddress) {
$IPAddresses[$i] = ForceIPv4($IPAddress);
}
setValue('AllIPAddresses', $User, $IPAddresses);
}
}
setValue('_CssClass', $User, '');
if ($v = val('Banned', $User)) {
setValue('_CssClass', $User, 'Banned');
}
$this->EventArguments['User'] =& $User;
$this->fireEvent('SetCalculatedFields');
}
示例8: array
<?php
echo $this->Form->label('Description', 'Description');
echo $this->Form->textBox('Description', array('MultiLine' => TRUE));
?>
</li>
<li>
<?php
echo $this->Form->label('Css Class', 'CssClass');
echo $this->Form->textBox('CssClass', array('MultiLine' => FALSE));
?>
</li>
<li>
<?php
echo $this->Form->label('Photo', 'PhotoUpload');
if ($Photo = $this->Form->getValue('Photo')) {
echo img(Gdn_Upload::url($Photo));
echo '<br />' . anchor(t('Delete Photo'), CombinePaths(array('vanilla/settings/deletecategoryphoto', $this->Category->CategoryID, Gdn::session()->TransientKey())), 'SmallButton Danger PopConfirm');
}
echo $this->Form->Input('PhotoUpload', 'file');
?>
</li>
<?php
echo $this->Form->Simple($this->data('_ExtendedFields', array()), array('Wrap' => array('', '')));
?>
<li>
<?php
echo $this->Form->label('Display As', 'DisplayAs');
echo $this->Form->DropDown('DisplayAs', array('Default' => 'Default', 'Categories' => 'Categories', 'Discussions' => 'Discussions', 'Heading' => 'Heading'));
?>
</li>
<li>
示例9: img
// 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();
?>
<ul>
<?php
if ($Picture != '') {
示例10: setCalculatedFields
/**
* Finish setting up data for the retrieved addon(s).
*
* @param $Data
*/
public function setCalculatedFields(&$Data)
{
if (!$Data) {
return;
}
if (is_a($Data, 'Gdn_DataSet')) {
$this->setCalculatedFields($Data->result());
} elseif (is_object($Data) || isset($Data['Icon'])) {
$File = val('File', $Data);
setValue('Url', $Data, Gdn_Upload::url($File));
$Icon = val('Icon', $Data, null);
if ($Icon !== null) {
// Fix the icon path.
if ($Icon && strpos($Icon, '/') == false) {
$Icon = 'ai' . $Icon;
setValue('Icon', $Data, $Icon);
}
if (empty($Icon)) {
setValue('IconUrl', $Data, 'foo');
} else {
setValue('IconUrl', $Data, Gdn_Upload::url($Icon));
}
} else {
// Set a default icon.
setValue('Icon', $Data, url('/applications/dashboard/design/images/eyes.png', true));
}
if (val('AddonKey', $Data) && val('Checked', $Data)) {
$Slug = strtolower(val('AddonKey', $Data) . '-' . val('Type', $Data) . '-' . val('Version', $Data));
setValue('Slug', $Data, $Slug);
}
// Set the requirements.
if (val('Checked', $Data)) {
$Requirements = val('Requirements', $Data);
try {
$Requirements = unserialize($Requirements);
if (is_array($Requirements)) {
setValue('Requirements', $Data, $Requirements);
}
} catch (Exception $Ex) {
}
}
} elseif (is_array($Data)) {
foreach ($Data as &$Row) {
$this->setCalculatedFields($Row);
}
}
}
示例11: wrap
echo wrap(t('FaviconDescription', "Your site's favicon appears in your browser's title bar. It will be scaled to 16x16 pixels."), 'div', array('class' => 'Info'));
$Favicon = $this->data('Favicon');
if ($Favicon) {
echo wrap(img(Gdn_Upload::url($Favicon)), 'div');
echo wrap(Anchor(t('Remove Favicon'), '/dashboard/settings/removefavicon/' . $Session->TransientKey(), 'SmallButton'), 'div', array('style' => 'padding: 10px 0;'));
echo wrap(t('FaviconBrowse', 'Browse for a new favicon if you would like to change it:'), 'div', array('class' => 'Info'));
} else {
echo wrap(t('FaviconDescription', "The shortcut icon that shows up in your browser's bookmark menu (16x16 px)."), 'div', array('class' => 'Info'));
}
echo $this->Form->Input('Favicon', 'file');
?>
</li>
<li>
<?php
echo $this->Form->label('Share Image', 'ShareImage');
echo wrap(t('ShareImageDescription', "When someone shares a link from your site we try and grab an image from the page. If there isn't an image on the page then we'll use this image instead. The image should be at least 50×50, but we recommend 200×200."), 'div', array('class' => 'Info'));
$ShareImage = $this->data('ShareImage');
if ($ShareImage) {
echo wrap(img(Gdn_Upload::url($ShareImage), array('style' => 'max-width: 300px')), 'div');
echo wrap(Anchor(t('Remove Image'), '/dashboard/settings/removeshareimage', 'SmallButton Hijack'), 'div', array('style' => 'padding: 10px 0;'));
echo wrap(t('FaviconBrowse', 'Browse for a new favicon if you would like to change it:'), 'div', array('class' => 'Info'));
}
echo $this->Form->Input('ShareImage', 'file');
?>
</li>
</ul>
</div>
</div>
<?php
echo '<div class="Buttons">' . $this->Form->button('Save') . '</div>';
echo $this->Form->close();
示例12: 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);
}
}
示例13: c
$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 val('_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
echo anchor(t('Add a Profile Picture'), '/profile/picture?userid=' . $User->UserID, 'AddPicture BigButton');
?>
示例14: htmlspecialchars
if (!defined('APPLICATION')) {
exit;
}
?>
<h1><?php
if ($this->Addon['File'] == '') {
echo 'The requested addon could not be found';
} else {
echo 'Downloading: ' . htmlspecialchars($this->Addon['Name']) . ' version ' . $this->Addon['Version'];
?>
</h1>
<div class="Box DownloadInfo">
<strong>Your download should begin shortly</strong>
<p>If your download does not begin right away, <a href="<?php
echo Gdn_Upload::url($this->Addon['File']);
?>
">click here to download now</a>.</p>
<strong>Need help installing this addon?</strong>
<p>There should be a readme file in the addon with more specific instructions on how to install it. If you are still having problems, <a href="//vanillaforums.org/discussions">ask for help on the community forums</a>.</p>
<strong>Note</strong>
<p>Vanilla Forums Inc cannot be held liable for issues that arise from the download or use of these addons.</p>
<strong>Now what?</strong>
<p>Head on back to the <a href="<?php
echo url('/addon/' . $this->Addon['AddonID']);
?>
"><?php
echo $this->Addon['Name'];
示例15: calculate
/**
* Calculate the dynamic fields of a category.
*
* @param array &$category The category to calculate.
*/
private static function calculate(&$category)
{
$category['CountAllDiscussions'] = $category['CountDiscussions'];
$category['CountAllComments'] = $category['CountComments'];
$category['Url'] = self::categoryUrl($category, false, '/');
if (val('Photo', $category)) {
$category['PhotoUrl'] = Gdn_Upload::url($category['Photo']);
} else {
$category['PhotoUrl'] = '';
}
self::calculateDisplayAs($category);
if (!val('CssClass', $category)) {
$category['CssClass'] = 'Category-' . $category['UrlCode'];
}
if (isset($category['AllowedDiscussionTypes']) && is_string($category['AllowedDiscussionTypes'])) {
$category['AllowedDiscussionTypes'] = dbdecode($category['AllowedDiscussionTypes']);
}
}