示例#1
0
 echo $Img;
 ?>
               <div class="FileMeta">
                  <?php 
 echo '<div class="FileName">';
 if (isset($DownloadUrl)) {
     echo '<a href="' . $DownloadUrl . '">' . htmlspecialchars($Media->Name) . '</a>';
 } else {
     echo htmlspecialchars($Media->Name);
 }
 echo '</div>';
 echo '<div class="FileAttributes">';
 if ($Media->ImageWidth && $Media->ImageHeight) {
     echo ' <span class="FileSize">' . $Media->ImageWidth . '&#160;x&#160;' . $Media->ImageHeight . '</span> - ';
 }
 echo ' <span class="FileSize">', Gdn_Format::Bytes($Media->Size, 0), '</span>';
 echo '</div>';
 $Actions = '';
 if (StringBeginsWith($this->ControllerName, 'post', TRUE)) {
     $Actions = ConcatSep(' | ', $Actions, '<a class="InsertImage" href="' . Url(MediaModel::Url($Path)) . '">' . T('Insert Image') . '</a>');
 }
 if (GetValue('ForeignTable', $Media) == 'discussion') {
     $PermissionName = "Vanilla.Discussions.Edit";
 } else {
     $PermissionName = "Vanilla.Comments.Edit";
 }
 if ($IsOwner || Gdn::Session()->CheckPermission($PermissionName, TRUE, 'Category', $this->Data('Discussion.PermissionCategoryID'))) {
     $Actions = ConcatSep(' | ', $Actions, '<a class="DeleteFile" href="' . Url("/plugin/fileupload/delete/{$Media->MediaID}") . '"><span>' . T('Delete') . '</span></a>');
 }
 if ($Actions) {
     echo '<div>', $Actions, '</div>';
示例#2
0
 /**
  * PostController_Checkupload_Create function.
  *
  * Controller method that allows an AJAX call to check the progress of a file
  * upload that is currently in progress.
  * 
  * @access public
  * @param mixed &$Sender
  * @return void
  */
 public function PostController_Checkupload_Create($Sender)
 {
     list($ApcKey) = $Sender->RequestArgs;
     $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
     $Sender->DeliveryType(DELIVERY_TYPE_VIEW);
     $KeyData = explode('_', $ApcKey);
     array_shift($KeyData);
     $UploaderID = implode('_', $KeyData);
     $ApcAvailable = self::ApcAvailable();
     $Progress = array('key' => $ApcKey, 'uploader' => $UploaderID, 'apc' => $ApcAvailable ? 'yes' : 'no');
     if ($ApcAvailable) {
         $UploadStatus = apc_fetch('upload_' . $ApcKey, $Success);
         if (!$Success) {
             $UploadStatus = array('current' => 0, 'total' => -1);
         }
         $Progress['progress'] = $UploadStatus['current'] / $UploadStatus['total'] * 100;
         $Progress['total'] = $UploadStatus['total'];
         $Progress['format_total'] = Gdn_Format::Bytes($Progress['total'], 1);
         $Progress['cache'] = $UploadStatus;
     }
     $Sender->SetJSON('Progress', $Progress);
     $Sender->Render($this->GetView('blank.php'));
 }
示例#3
0
                <?php 
    if ($attachment['ImageHeight']) {
        echo 'data-width="' . $attachment['ImageWidth'] . '"';
        echo 'data-height="' . $attachment['ImageHeight'] . '"';
    } else {
        // Only add the download attribute if it's not an image.
        echo 'download="' . htmlspecialchars($attachment['Name']) . '"';
    }
    ?>
                >
                <?php 
    echo htmlspecialchars($attachment['Name']);
    ?>
            </a>
            <span class="meta"><?php 
    echo Gdn_Format::Bytes($attachment['Size'], 1);
    ?>
</span>
         </div>
         <span class="editor-file-remove" title="<?php 
    echo t('Remove');
    ?>
"></span>
         <span class="editor-file-reattach" title="<?php 
    echo t('Click to re-attach');
    ?>
"></span>
      </div>

   <?php 
}
示例#4
0
 function Size($Bytes, $Precision = 2)
 {
     return Gdn_Format::Bytes($Bytes, $Precision);
 }