本文整理汇总了PHP中Gdn_Format::Bytes方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::Bytes方法的具体用法?PHP Gdn_Format::Bytes怎么用?PHP Gdn_Format::Bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Format
的用法示例。
在下文中一共展示了Gdn_Format::Bytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: htmlspecialchars
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 . ' x ' . $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: PostController_Checkupload_Create
/**
* 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: htmlspecialchars
<?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: Size
function Size($Bytes, $Precision = 2)
{
return Gdn_Format::Bytes($Bytes, $Precision);
}