当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Upload类代码示例

本文整理汇总了PHP中Gdn_Upload的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Upload类的具体用法?PHP Gdn_Upload怎么用?PHP Gdn_Upload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Gdn_Upload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Settings

 /**
  * Manage the current ranks and add new ones
  */
 public function Settings()
 {
     $this->Permission('Yaga.Ranks.Manage');
     $this->AddSideMenu('rank/settings');
     $this->Title(T('Yaga.Ranks.Manage'));
     // Get list of ranks from the model and pass to the view
     $this->SetData('Ranks', $this->RankModel->Get());
     if ($this->Form->IsPostBack() == TRUE) {
         // Handle the photo upload
         $Upload = new Gdn_Upload();
         $TmpImage = $Upload->ValidateUpload('PhotoUpload', FALSE);
         if ($TmpImage) {
             // Generate the target image name
             $TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS);
             $ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
             // Save the uploaded image
             $Parts = $Upload->SaveAs($TmpImage, 'yaga' . DS . $ImageBaseName);
             $RelativeUrl = StringBeginsWith($Parts['Url'], Gdn_Url::WebRoot(TRUE), TRUE, TRUE);
             SaveToConfig('Yaga.Ranks.Photo', $RelativeUrl);
             if (C('Yaga.Ranks.Photo') == $Parts['SaveName']) {
                 $this->InformMessage(T('Yaga.Rank.PhotoUploaded'));
             }
         }
     }
     include_once $this->FetchViewLocation('helper_functions', 'rank');
     $this->Render();
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:30,代码来源:class.rankcontroller.php

示例2: generateUrl

 /**
  * Generate a Gravatar image URL based on the provided email address.
  *
  * @link http://en.gravatar.com/site/implement/images/ Gravatar Image Requests
  * @param string $email Email address for the user, used to generate the avatar ID.
  * @param int $size Target image size.
  * @return string A formatted Gravatar image URL.
  */
 public static function generateUrl($email, $size = 80)
 {
     $avatarID = md5(strtolower($email));
     // Figure out our base URLs.  Gravatar doesn't support SVGs, so we're stuck with using Vanillicon v1.
     if (Gdn::request()->scheme() === 'https') {
         $baseUrl = 'https://secure.gravatar.com/avatar';
         $vanilliconBaseUrl = 'https://vanillicon.com';
     } else {
         $baseUrl = 'http://www.gravatar.com/avatar';
         $vanilliconBaseUrl = 'http://vanillicon.com';
     }
     if (c('Plugins.Gravatar.UseVanillicon', true)) {
         // Version 1 of Vanillicon only supports three sizes.  Figure out which one is best for this image.
         if ($size <= 50) {
             $vanilliconSize = 50;
         } elseif ($size <= 100) {
             $vanilliconSize = 100;
         } else {
             $vanilliconSize = 200;
         }
         $default = "{$vanilliconBaseUrl}/{$avatarID}_{$vanilliconSize}.png";
     } else {
         $configuredDefaultAvatar = c('Plugins.Gravatar.DefaultAvatar', c('Garden.DefaultAvatar'));
         if ($configuredDefaultAvatar) {
             $defaultParsed = Gdn_Upload::parse($configuredDefaultAvatar);
             $default = val('Url', $defaultParsed);
         }
     }
     if (empty($default)) {
         $default = asset($size <= 50 ? 'plugins/Gravatar/default.png' : 'plugins/Gravatar/default_250.png', true);
     }
     $query = ['default' => $default, 'rating' => c('Plugins.Gravatar.Rating', 'g'), 'size' => $size];
     return $baseUrl . "/{$avatarID}/?" . http_build_query($query);
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:42,代码来源:default.php

示例3: _checkTable

/**
 *
 *
 * @param $Data
 */
function _checkTable($Data)
{
    echo "<table class='Data' width='100%' style='table-layout: fixed;'>\n";
    echo "<thead><tr><td width='20%'>Field</td><td width='45%'>Current</td><td width='35%'>File</td></tr></thead>";
    $First = true;
    foreach ($Data as $Key => $Value) {
        if (stringBeginsWith($Key, 'File_') || is_array($Value) || $Key == 'Name') {
            continue;
        }
        $Value = Gdn_Format::html($Value);
        $FileValue = Gdn_Format::html(val('File_' . $Key, $Data));
        if ($Key == 'MD5') {
            $Value = substr($Value, 0, 10);
            $FileValue = substr($FileValue, 0, 10);
        }
        if ($Key == 'FileSize') {
            $Value = Gdn_Upload::FormatFileSize($Value);
        }
        echo "<tr><td>{$Key}</td><td>{$Value}</td>";
        if ($Error = val('File_Error', $Data)) {
            if ($First) {
                echo '<td rowspan="4">', htmlspecialchars($Error), '</td>';
            }
        } else {
            echo "<td>{$FileValue}</td></tr>";
        }
        echo "\n";
        $First = false;
    }
    echo '</table>';
}
开发者ID:vanilla,项目名称:community,代码行数:36,代码来源:check.php

示例4: WriteDiscussion

function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt) {
   $CssClass = 'Item';
   $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
   $CssClass .= $Alt.' ';
   $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
   $CssClass .= $Discussion->Closed == '1' ? ' Closed' : '';
   $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
   $CssClass .= ($Discussion->CountUnreadComments > 0 && $Session->IsValid()) ? ' New' : '';
   $Sender->EventArguments['Discussion'] = &$Discussion;
   $Sender->FireEvent('BeforeDiscussionName');
   
   $DiscussionName = Gdn_Format::Text($Discussion->Name);
   if ($DiscussionName == '')
      $DiscussionName = T('Blank Discussion Topic');

   static $FirstDiscussion = TRUE;
   if (!$FirstDiscussion)
      $Sender->FireEvent('BetweenDiscussion');
   else
      $FirstDiscussion = FALSE;
?>
<li class="<?php echo $CssClass; ?>">
   <?php
      if ($Discussion->FirstPhoto) {
         $PhotoImage = 'n'.basename($Discussion->FirstPhoto);
         $PhotoUrl = Gdn_Upload::Url(dirname($Discussion->FirstPhoto).'/'.$PhotoImage);
         echo Img($PhotoUrl, array('alt' => $Discussion->FirstName));
		}
   ?>
   <div class="ItemContent Discussion">
      <?php echo Anchor($DiscussionName, '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_'.$Discussion->CountCommentWatch : ''), 'Title'); ?>
      <?php $Sender->FireEvent('AfterDiscussionTitle'); ?>
      <div class="Meta">
         <span class="Author"><?php echo $Discussion->FirstName; ?></span>
         <?php
            echo '<span class="Counts'.($Discussion->CountUnreadComments > 0 ? ' NewCounts' : '').'">'
               .($Discussion->CountUnreadComments > 0 ? $Discussion->CountUnreadComments.'/' : '')
               .$Discussion->CountComments
            .'</span>';
            if ($Discussion->LastCommentID != '')
               echo '<span class="LastCommentBy">'.sprintf(T('Latest %1$s'), $Discussion->LastName).'</span> ';
               
            echo '<span class="LastCommentDate">'.Gdn_Format::Date($Discussion->LastDate).'</span> ';
         ?>
      </div>
   </div>
</li>
<?php
}
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:49,代码来源:helper_functions.php

示例5: Import

 /**
  * Import a Yaga transport file
  */
 public function Import()
 {
     $this->Title(T('Yaga.Import'));
     $this->SetData('TransportType', 'Import');
     if (!class_exists('ZipArchive')) {
         $this->Form->AddError(T('Yaga.Error.TransportRequirements'));
     }
     if ($this->Form->IsPostBack() == TRUE) {
         // Handle the file upload
         $Upload = new Gdn_Upload();
         $TmpZip = $Upload->ValidateUpload('FileUpload', FALSE);
         $ZipFile = FALSE;
         if ($TmpZip) {
             // Generate the target name
             $TargetFile = $Upload->GenerateTargetName(PATH_UPLOADS, 'zip');
             $BaseName = pathinfo($TargetFile, PATHINFO_BASENAME);
             // Save the uploaded zip
             $Parts = $Upload->SaveAs($TmpZip, $BaseName);
             $ZipFile = PATH_UPLOADS . DS . $Parts['SaveName'];
             $this->SetData('TransportPath', $ZipFile);
         }
         $Include = $this->_FindIncludes();
         if (count($Include)) {
             $Info = $this->_ExtractZip($ZipFile);
             $this->_ImportData($Info, $Include);
             Gdn_FileSystem::RemoveFolder(PATH_UPLOADS . DS . 'import' . DS . 'yaga');
         } else {
             $this->Form->AddError(T('Yaga.Error.Includes'));
         }
     }
     if ($this->Form->ErrorCount() == 0 && $this->Form->IsPostBack()) {
         $this->Render('transport-success');
     } else {
         $this->Render();
     }
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:39,代码来源:class.yagacontroller.php

示例6: 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');
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:27,代码来源:class.bbcode.php

示例7: DoAttachment

    public function DoAttachment($bbcode, $action, $name, $default, $params, $content)
    {
        $Medias = $this->Media();
        $MediaID = $content;
        if (isset($Medias[$MediaID])) {
            $Media = $Medias[$MediaID];
            //         decho($Media, 'Media');
            $Src = htmlspecialchars(Gdn_Upload::Url(GetValue('Path', $Media)));
            $Name = htmlspecialchars(GetValue('Name', $Media));
            if (GetValue('ImageWidth', $Media)) {
                return <<<EOT
<div class="Attachment Image"><img src="{$Src}" alt="{$Name}" /></div>
EOT;
            } else {
                return Anchor($Name, $Src, 'Attachment File');
            }
        }
        return Anchor(T('Attachment not found.'), '#', 'Attachment NotFound');
    }
开发者ID:SatiricMan,项目名称:addons,代码行数:19,代码来源:class.nbbc.plugin.php

示例8: 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();
 }
开发者ID:vanilla,项目名称:community,代码行数:48,代码来源:class.getcontroller.php

示例9: MediaThumbnail

function MediaThumbnail($Media, $Data = FALSE)
{
    $Media = (array) $Media;
    if (GetValue('ThumbPath', $Media)) {
        $Src = Gdn_Upload::Url(ltrim(GetValue('ThumbPath', $Media), '/'));
    } else {
        $Width = GetValue('ImageWidth', $Media);
        $Height = GetValue('ImageHeight', $Media);
        if (!$Width || !$Height) {
            $Height = MediaModel::ThumbnailHeight();
            if (!$Height) {
                $Height = 100;
            }
            SetValue('ThumbHeight', $Media, $Height);
            return DefaultMediaThumbnail($Media);
        }
        $RequiresThumbnail = FALSE;
        if (MediaModel::ThumbnailHeight() && $Height > MediaModel::ThumbnailHeight()) {
            $RequiresThumbnail = TRUE;
        } elseif (MediaModel::ThumbnailWidth() && $Width > MediaModel::ThumbnailWidth()) {
            $RequiresThumbnail = TRUE;
        }
        $Path = ltrim(GetValue('Path', $Media), '/');
        if ($RequiresThumbnail) {
            $Src = Url('/utility/thumbnail/' . GetValue('MediaID', $Media, 'x') . '/' . $Path, TRUE);
        } else {
            $Src = Gdn_Upload::Url($Path);
        }
    }
    if ($Data) {
        $Result = array('src' => $Src, 'width' => GetValue('ThumbWidth', $Media), 'height' => GetValue('ThumbHeight', $Media));
    } else {
        $Result = Img($Src, array('class' => 'ImageThumbnail', 'width' => GetValue('ThumbWidth', $Media), 'height' => GetValue('ThumbHeight', $Media)));
    }
    return $Result;
}
开发者ID:SatiricMan,项目名称:addons,代码行数:36,代码来源:fileupload_functions.php

示例10: renderMaster


//.........这里部分代码省略.........
             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;
                 }
             }
         }
         // Add the favicon.
         $Favicon = C('Garden.FavIcon');
         if ($Favicon) {
             $this->Head->setFavIcon(Gdn_Upload::url($Favicon));
         }
         // Make sure the head module gets passed into the assets collection.
         $this->addModule('Head');
     }
     // Master views come from one of four places:
     $MasterViewPaths = array();
     if (strpos($this->MasterView, '/') !== false) {
         $MasterViewPaths[] = combinePaths(array(PATH_ROOT, str_replace('/', DS, $this->MasterView) . '.master*'));
     } else {
         if ($this->Theme) {
             // 1. Application-specific theme view. eg. root/themes/theme_name/app_name/views/
             $MasterViewPaths[] = combinePaths(array(PATH_THEMES, $this->Theme, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
             // 2. Garden-wide theme view. eg. /path/to/application/themes/theme_name/views/
             $MasterViewPaths[] = combinePaths(array(PATH_THEMES, $this->Theme, 'views', $this->MasterView . '.master*'));
         }
         // 3. Plugin default. eg. root/plugin_name/views/
         $MasterViewPaths[] = combinePaths(array(PATH_ROOT, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
         // 4. Application default. eg. root/app_name/views/
         $MasterViewPaths[] = combinePaths(array(PATH_APPLICATIONS, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
         // 5. Garden default. eg. root/dashboard/views/
         $MasterViewPaths[] = combinePaths(array(PATH_APPLICATIONS, 'dashboard', 'views', $this->MasterView . '.master*'));
     }
     // Find the first file that matches the path.
     $MasterViewPath = false;
     foreach ($MasterViewPaths as $Glob) {
         $Paths = safeGlob($Glob);
         if (is_array($Paths) && count($Paths) > 0) {
             $MasterViewPath = $Paths[0];
             break;
         }
     }
     $this->EventArguments['MasterViewPath'] =& $MasterViewPath;
     $this->fireEvent('BeforeFetchMaster');
     if ($MasterViewPath === false) {
         trigger_error(errorMessage("Could not find master view: {$this->MasterView}.master*", $this->ClassName, '_FetchController'), E_USER_ERROR);
     }
     /// A unique identifier that can be used in the body tag of the master view if needed.
     $ControllerName = $this->ClassName;
     // Strip "Controller" from the body identifier.
     if (substr($ControllerName, -10) == 'Controller') {
         $ControllerName = substr($ControllerName, 0, -10);
     }
     // Strip "Gdn_" from the body identifier.
     if (substr($ControllerName, 0, 4) == 'Gdn_') {
         $ControllerName = substr($ControllerName, 4);
     }
     $this->setData('CssClass', $this->Application . ' ' . $ControllerName . ' ' . $this->RequestMethod . ' ' . $this->CssClass, true);
     // Check to see if there is a handler for this particular extension.
     $ViewHandler = Gdn::factory('ViewHandler' . strtolower(strrchr($MasterViewPath, '.')));
     if (is_null($ViewHandler)) {
         $BodyIdentifier = strtolower($this->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($this->RequestMethod)));
         include $MasterViewPath;
     } else {
         $ViewHandler->render($MasterViewPath, $this);
     }
 }
开发者ID:battaglia01,项目名称:vanilla,代码行数:101,代码来源:class.controller.php

示例11: CurrentImage

 /**
  * Returns the current image in a field.
  * This is meant to be used with image uploads so that users can see the current value.
  * 
  * @param type $FieldName
  * @param type $Attributes
  * @since 2.1
  */
 public function CurrentImage($FieldName, $Attributes = array())
 {
     $Result = $this->Hidden($FieldName);
     $Value = $this->GetValue($FieldName);
     if ($Value) {
         TouchValue('class', $Attributes, 'CurrentImage');
         $Result .= Img(Gdn_Upload::Url($Value), $Attributes);
     }
     return $Result;
 }
开发者ID:bishopb,项目名称:vanilla,代码行数:18,代码来源:class.form.php

示例12: Thumbnail

   public function Thumbnail($UserReference = '', $Username = '') {
      $this->Permission('Garden.SignIn.Allow');
      $this->AddJsFile('jquery.jcrop.pack.js');
      $this->AddJsFile('profile.js');
            
      $Session = Gdn::Session();
      if (!$Session->IsValid())
         $this->Form->AddError('You must be authenticated in order to use this form.');
               
      $this->GetUserInfo($UserReference, $Username);
      
      if ($this->User->UserID != $Session->UserID && !$Session->CheckPermission('Garden.Users.Edit'))
         throw new Exception(T('You cannot edit the thumbnail of another member.'));
      
      $this->Form->SetModel($this->UserModel);
      $this->Form->AddHidden('UserID', $this->User->UserID);
      
      if (!$this->User->Photo)
         $this->Form->AddError('You must first upload a picture before you can create a thumbnail.');
      
      // Define the thumbnail size
      $this->ThumbSize = Gdn::Config('Garden.Thumbnail.Size', 32);
      
      // Define the source (profile sized) picture & dimensions.
      $Basename = ChangeBasename($this->User->Photo, 'p%s');
      $Upload = new Gdn_UploadImage();
      $PhotoParsed = Gdn_Upload::Parse($Basename);
      $Source = $Upload->CopyLocal($Basename);

      if (!$Source) {
         $this->Form->AddError('You cannot edit the thumbnail of an externally linked profile picture.');
      } else {
         $this->SourceSize = getimagesize($Source);
      }
      
      // Add some more hidden form fields for jcrop
      $this->Form->AddHidden('x', '0');
      $this->Form->AddHidden('y', '0');
      $this->Form->AddHidden('w', $this->ThumbSize);
      $this->Form->AddHidden('h', $this->ThumbSize);
      $this->Form->AddHidden('HeightSource', $this->SourceSize[1]);
      $this->Form->AddHidden('WidthSource', $this->SourceSize[0]);
      $this->Form->AddHidden('ThumbSize', $this->ThumbSize);      
      if ($this->Form->AuthenticatedPostBack() === TRUE) {
         try {
            // Get the dimensions from the form.
            Gdn_UploadImage::SaveImageAs(
               $Source,
               'userpics/'.ChangeBasename(basename($this->User->Photo), 'n%s'),
               $this->ThumbSize, $this->ThumbSize,
               array('Crop' => TRUE, 'SourceX' => $this->Form->GetValue('x'), 'SourceY' => $this->Form->GetValue('y'), 'SourceWidth' => $this->Form->GetValue('w'), 'SourceHeight' => $this->Form->GetValue('h')));
         } catch (Exception $Ex) {
            $this->Form->AddError($Ex);
         }
         // If there were no problems, redirect back to the user account
         if ($this->Form->ErrorCount() == 0) {
            Redirect('dashboard/profile/'.$this->ProfileUrl());
         }
      }
      // Delete the source image if it is externally hosted.
      if ($PhotoParsed['Type']) {
         @unlink($Source);
      }
      $this->Render();
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:65,代码来源:class.profilecontroller.php

示例13: DoAttachment

    public function DoAttachment($bbcode, $action, $name, $default, $params, $content)
    {
        $Medias = $this->Media();
        $Parts = explode(':', $default);
        $MediaID = $Parts[0];
        if (isset($Medias[$MediaID])) {
            $Media = $Medias[$MediaID];
            //         decho($Media, 'Media');
            $Src = htmlspecialchars(Gdn_Upload::Url(GetValue('Path', $Media)));
            $Name = htmlspecialchars(GetValue('Name', $Media));
            return <<<EOT
<div class="Attachment"><img src="{$Src}" alt="{$Name}" /></div>
EOT;
        }
        return '';
    }
开发者ID:nilsen,项目名称:addons,代码行数:16,代码来源:class.ipbformatter.plugin.php

示例14: Banner

 /**
  * Banner management screen.
  */
 public function Banner()
 {
     $this->Permission('Garden.Settings.Manage');
     $this->AddSideMenu('dashboard/settings/banner');
     $this->Title(T('Banner'));
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Garden.Title'));
     // Set the model on the form.
     $this->Form->SetModel($ConfigurationModel);
     // If seeing the form for the first time...
     if ($this->Form->AuthenticatedPostBack() === FALSE) {
         // Apply the config settings to the form.
         $this->Form->SetData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required');
         if ($this->Form->Save() !== FALSE) {
             $Upload = new Gdn_Upload();
             try {
                 // Validate the upload
                 $TmpImage = $Upload->ValidateUpload('Logo', FALSE);
                 if ($TmpImage) {
                     // Generate the target image name
                     $TargetImage = $Upload->GenerateTargetName(PATH_ROOT . DS . 'uploads');
                     $ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
                     // Delete any previously uploaded images
                     @unlink(PATH_ROOT . DS . C('Garden.Logo', ''));
                     // Save the uploaded image
                     $Upload->SaveAs($TmpImage, PATH_ROOT . DS . 'uploads' . DS . $ImageBaseName);
                 }
             } catch (Exception $ex) {
                 $this->Form->AddError($ex->getMessage());
             }
             // If there were no errors, save the path to the logo in the config
             if ($this->Form->ErrorCount() == 0 && $Upload->GetUploadedFileName() != '') {
                 SaveToConfig('Garden.Logo', 'uploads' . DS . $ImageBaseName);
             }
             $this->StatusMessage = T("Your settings have been saved.");
         }
     }
     $this->Render();
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:46,代码来源:class.settingscontroller.php

示例15: RemoveFavicon

 /**
  * Remove the logo from config & delete it.
  *
  * @since 2.1
  * @param string $TransientKey Security token.
  */
 public function RemoveFavicon($TransientKey = '')
 {
     $Session = Gdn::Session();
     if ($Session->ValidateTransientKey($TransientKey) && $Session->CheckPermission('Garden.Settings.Manage')) {
         $Favicon = C('Garden.FavIcon', '');
         RemoveFromConfig('Garden.FavIcon');
         $Upload = new Gdn_Upload();
         $Upload->Delete($Favicon);
     }
     Redirect('/settings/banner');
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:17,代码来源:class.settingscontroller.php


注:本文中的Gdn_Upload类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。