本文整理汇总了PHP中UI::format_bytes方法的典型用法代码示例。如果您正苦于以下问题:PHP UI::format_bytes方法的具体用法?PHP UI::format_bytes怎么用?PHP UI::format_bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UI
的用法示例。
在下文中一共展示了UI::format_bytes方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_files
/**
* add_files
*
* Recurses through $this->path and pulls out all mp3s and returns the
* full path in an array. Passes gather_type to determine if we need to
* check id3 information against the db.
*/
public function add_files($path, $options)
{
// Profile the memory a bit
debug_event('Memory', UI::format_bytes(memory_get_usage(true)), 5);
// See if we want a non-root path for the add
if (isset($options['subdirectory'])) {
$path = $options['subdirectory'];
unset($options['subdirectory']);
}
// Correctly detect the slash we need to use here
if (strpos($path, '/') !== false) {
$slash_type = '/';
} else {
$slash_type = '\\';
}
/* Open up the directory */
$handle = opendir($path);
if (!is_resource($handle)) {
debug_event('read', "Unable to open {$path}", 5);
AmpError::add('catalog_add', sprintf(T_('Error: Unable to open %s'), $path));
return false;
}
/* Change the dir so is_dir works correctly */
if (!chdir($path)) {
debug_event('read', "Unable to chdir to {$path}", 2);
AmpError::add('catalog_add', sprintf(T_('Error: Unable to change to directory %s'), $path));
return false;
}
debug_event('Memory', UI::format_bytes(memory_get_usage(true)), 5);
/* Recurse through this dir and create the files array */
while (false !== ($file = readdir($handle))) {
/* Skip to next if we've got . or .. */
if (substr($file, 0, 1) == '.') {
continue;
}
debug_event('read', "Starting work on {$file} inside {$path}", 5);
debug_event('Memory', UI::format_bytes(memory_get_usage(true)), 5);
/* Create the new path */
$full_file = $path . $slash_type . $file;
$this->add_file($full_file, $options);
}
// end while reading directory
debug_event('closedir', "Finished reading {$path} , closing handle", 5);
// This should only happen on the last run
if ($path == $this->path) {
UI::update_text('add_count_' . $this->id, $this->count);
}
/* Close the dir handle */
@closedir($handle);
}
示例2: T_
<tr>
<td><?php
echo T_('Confirm Password');
?>
:</td>
<td>
<input type="password" name="password2" id="password2" />
</td>
</tr>
<tr>
<td>
<?php
echo T_('Avatar');
?>
(< <?php
echo UI::format_bytes(AmpConfig::get('max_upload_size'));
?>
)
</td>
<td>
<input type="file" id="avatar" name="avatar" value="" />
<a href="<?php
echo AmpConfig::get('web_path');
?>
/admin/users.php?action=show_delete_avatar&user_id=<?php
echo $client->id;
?>
"><?php
echo UI::get_icon('delete', T_('Delete'));
?>
</a>
示例3: T_
echo Ajax::observe('license_select', 'change', 'check_inline_song_edit("license", "0")');
?>
</div>
</td>
</tr>
<?php
}
?>
<tr>
<td>
<?php
echo T_('Files');
?>
<?php
if ($upload_max > 0) {
echo " (< " . UI::format_bytes($upload_max) . ")";
}
?>
<br /><br />
<?php
echo T_('Allowed file type');
?>
:<br />
<?php
echo str_replace("|", ", ", AmpConfig::get('catalog_file_pattern'));
?>
</td>
<td>
<div id="dropfile">
<?php
echo T_('Drop File Here');
示例4: format
/**
* format
* This function sets up the extra variables we need when we are displaying a
* user for an admin, these should not be normally called when creating a
* user object
*/
public function format($details = true)
{
/* If they have a last seen date */
if (!$this->last_seen) {
$this->f_last_seen = T_('Never');
} else {
$this->f_last_seen = date("m\\/d\\/Y - H:i", $this->last_seen);
}
/* If they have a create date */
if (!$this->create_date) {
$this->f_create_date = T_('Unknown');
} else {
$this->f_create_date = date("m\\/d\\/Y - H:i", $this->create_date);
}
$this->f_name = $this->fullname_public ? $this->fullname : $this->username;
// Base link
$this->link = AmpConfig::get('web_path') . '/stats.php?action=show_user&user_id=' . $this->id;
$this->f_link = '<a href="' . $this->link . '">' . $this->f_name . '</a>';
if ($details) {
/* Calculate their total Bandwidth Usage */
$sql = "SELECT sum(`song`.`size`) as size FROM `song` LEFT JOIN `object_count` ON `song`.`id`=`object_count`.`object_id` " . "WHERE `object_count`.`user`='{$this->id}' AND `object_count`.`object_type`='song'";
$db_results = Dba::read($sql);
$result = Dba::fetch_assoc($db_results);
$total = $result['size'];
$this->f_useage = UI::format_bytes($total);
/* Get Users Last ip */
if (count($data = $this->get_ip_history(1))) {
$this->ip_history = inet_ntop($data['0']['ip']);
} else {
$this->ip_history = T_('Not Enough Data');
}
}
$avatar = $this->get_avatar();
if (!empty($avatar['url'])) {
$this->f_avatar = '<img src="' . $avatar['url'] . '" title="' . $avatar['title'] . '" />';
}
if (!empty($avatar['url_mini'])) {
$this->f_avatar_mini = '<img src="' . $avatar['url_mini'] . '" title="' . $avatar['title'] . '" style="width: 32px; height: 32px;" />';
}
if (!empty($avatar['url_medium'])) {
$this->f_avatar_medium = '<img src="' . $avatar['url_medium'] . '" title="' . $avatar['title'] . '" style="width: 64px; height: 64px;" />';
}
}
示例5: add_files
/**
* add_files
*
* Recurses through $this->path and pulls out all mp3s and returns the
* full path in an array. Passes gather_type to determine if we need to
* check id3 information against the db.
*/
public function add_files($path, $options)
{
// Profile the memory a bit
debug_event('Memory', UI::format_bytes(memory_get_usage(true)), 5);
// See if we want a non-root path for the add
if (isset($options['subdirectory'])) {
$path = $options['subdirectory'];
unset($options['subdirectory']);
}
// Correctly detect the slash we need to use here
if (strpos($path, '/') !== false) {
$slash_type = '/';
} else {
$slash_type = '\\';
}
/* Open up the directory */
$handle = opendir($path);
if (!is_resource($handle)) {
debug_event('read', "Unable to open {$path}", 5);
Error::add('catalog_add', sprintf(T_('Error: Unable to open %s'), $path));
return false;
}
/* Change the dir so is_dir works correctly */
if (!chdir($path)) {
debug_event('read', "Unable to chdir to {$path}", 2);
Error::add('catalog_add', sprintf(T_('Error: Unable to change to directory %s'), $path));
return false;
}
// Ensure that we've got our cache
$this->_create_filecache();
debug_event('Memory', UI::format_bytes(memory_get_usage(true)), 5);
/* Recurse through this dir and create the files array */
while (false !== ($file = readdir($handle))) {
/* Skip to next if we've got . or .. */
if (substr($file, 0, 1) == '.') {
continue;
}
debug_event('read', "Starting work on {$file} inside {$path}", 5);
debug_event('Memory', UI::format_bytes(memory_get_usage(true)), 5);
/* Create the new path */
$full_file = $path . $slash_type . $file;
/* First thing first, check if file is already in catalog.
* This check is very quick, so it should be performed before any other checks to save time
*/
if (isset($this->_filecache[strtolower($full_file)])) {
continue;
}
// Incase this is the second time through clear this variable
// if it was set the day before
unset($failed_check);
if (AmpConfig::get('no_symlinks')) {
if (is_link($full_file)) {
debug_event('read', "Skipping symbolic link {$path}", 5);
continue;
}
}
/* If it's a dir run this function again! */
if (is_dir($full_file)) {
$this->add_files($full_file, $options);
/* Change the dir so is_dir works correctly */
if (!chdir($path)) {
debug_event('read', "Unable to chdir to {$path}", 2);
Error::add('catalog_add', sprintf(T_('Error: Unable to change to directory %s'), $path));
}
/* Skip to the next file */
continue;
}
//it's a directory
$is_audio_file = Catalog::is_audio_file($file);
if (AmpConfig::get('catalog_video_pattern')) {
$is_video_file = Catalog::is_video_file($file);
}
if ($options['parse_playlist'] && AmpConfig::get('catalog_playlist_pattern')) {
$is_playlist = Catalog::is_playlist_file($file);
}
/* see if this is a valid audio file or playlist file */
if ($is_audio_file or $is_video_file or $is_playlist) {
/* Now that we're sure its a file get filesize */
$file_size = filesize($full_file);
if (!$file_size) {
debug_event('read', "Unable to get filesize for {$full_file}", 2);
/* HINT: FullFile */
Error::add('catalog_add', sprintf(T_('Error: Unable to get filesize for %s'), $full_file));
}
// file_size check
if (!Core::is_readable($full_file)) {
// not readable, warn user
debug_event('read', "{$full_file} is not readable by ampache", 2);
/* HINT: FullFile */
Error::add('catalog_add', sprintf(T_('%s is not readable by ampache'), $full_file));
continue;
}
// Check to make sure the filename is of the expected charset
//.........这里部分代码省略.........
示例6: get_stats
/**
* get_stats
*
* This returns an hash with the #'s for the different
* objects that are associated with this catalog. This is used
* to build the stats box, it also calculates time.
*/
public static function get_stats($catalog_id = null)
{
$results = self::count_songs($catalog_id);
$results = array_merge(User::count(), $results);
$results['tags'] = self::count_tags();
$results['videos'] = self::count_videos($catalog_id);
$hours = floor($results['time'] / 3600);
$results['formatted_size'] = UI::format_bytes($results['size']);
$days = floor($hours / 24);
$hours = $hours % 24;
$time_text = "{$days} ";
$time_text .= ngettext('day', 'days', $days);
$time_text .= ", {$hours} ";
$time_text .= ngettext('hour', 'hours', $hours);
$results['time_text'] = $time_text;
return $results;
}
示例7: pGraph_Yformat_bytes
function pGraph_Yformat_bytes($value)
{
return UI::format_bytes($value);
}
示例8: format
/**
* format
* this function takes the object and reformats some values
*/
public function format($details = true)
{
$this->f_title = scrub_out($this->title);
$this->f_description = scrub_out($this->description);
$this->f_category = scrub_out($this->category);
$this->f_author = scrub_out($this->author);
$this->f_website = scrub_out($this->website);
$this->f_pubdate = date("m\\/d\\/Y - H:i", $this->pubdate);
$this->f_state = ucfirst($this->state);
// Format the Time
$min = floor($this->time / 60);
$sec = sprintf("%02d", $this->time % 60);
$this->f_time = $min . ":" . $sec;
$hour = sprintf("%02d", floor($min / 60));
$min_h = sprintf("%02d", $min % 60);
$this->f_time_h = $hour . ":" . $min_h . ":" . $sec;
// Format the Size
$this->f_size = UI::format_bytes($this->size);
$this->f_file = $this->f_title . '.' . $this->type;
$this->link = AmpConfig::get('web_path') . '/podcast_episode.php?action=show&podcast_episode=' . $this->id;
$this->f_link = '<a href="' . $this->link . '" title="' . $this->f_title . '">' . $this->f_title . '</a>';
if ($details) {
$podcast = new Podcast($this->podcast);
$podcast->format();
$this->catalog = $podcast->catalog;
$this->f_podcast = $podcast->f_title;
$this->f_podcast_link = $podcast->f_link;
$this->f_file = $this->f_podcast . ' - ' . $this->f_file;
}
return true;
}
示例9: T_
}
?>
</select>
</td>
</tr>
<tr id="search_size_limit">
<td><?php
echo T_('Size Limit');
?>
</td>
<td>
<select name="size_limit">
<?php
echo "\t\t\t" . '<option value="0" ' . ($_POST['size_limit'] == 0 ? 'selected="selected"' : '') . '>' . T_('Unlimited') . "</option>\n";
foreach (array(64, 128, 256, 512, 1024) as $i) {
echo "\t\t\t" . '<option value="' . $i . '"' . ($_POST['size_limit'] == $i ? 'selected="selected"' : '') . '>' . UI::format_bytes($i * 1048576) . "</option>\n";
}
?>
</select>
</td>
</tr>
</table>
<?php
require AmpConfig::get('prefix') . '/templates/show_rules.inc.php';
?>
<div class="formValidation">
<input type="submit" value="<?php
echo T_('Enqueue');
?>
示例10: format
/**
* format
* This takes the current song object
* and does a ton of formating on it creating f_??? variables on the current
* object
*/
public function format($details = true)
{
if ($details) {
$this->fill_ext_info();
// Get the top tags
$this->tags = Tag::get_top_tags('song', $this->id);
$this->f_tags = Tag::get_display($this->tags, true, 'song');
}
// Format the album name
$this->f_album_full = $this->get_album_name();
$this->f_album = $this->f_album_full;
// Format the artist name
$this->f_artist_full = $this->get_artist_name();
$this->f_artist = $this->f_artist_full;
// Format the album_artist name
$this->f_albumartist_full = $this->get_album_artist_name();
// Format the title
$this->f_title_full = $this->title;
$this->f_title = $this->title;
// Create Links for the different objects
$this->link = AmpConfig::get('web_path') . "/song.php?action=show_song&song_id=" . $this->id;
$this->f_link = "<a href=\"" . scrub_out($this->link) . "\" title=\"" . scrub_out($this->f_artist) . " - " . scrub_out($this->title) . "\"> " . scrub_out($this->f_title) . "</a>";
$this->f_album_link = "<a href=\"" . AmpConfig::get('web_path') . "/albums.php?action=show&album=" . $this->album . "\" title=\"" . scrub_out($this->f_album_full) . "\"> " . scrub_out($this->f_album) . "</a>";
$this->f_artist_link = "<a href=\"" . AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $this->artist . "\" title=\"" . scrub_out($this->f_artist_full) . "\"> " . scrub_out($this->f_artist) . "</a>";
if (!empty($this->albumartist)) {
$this->f_albumartist_link = "<a href=\"" . AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $this->albumartist . "\" title=\"" . scrub_out($this->f_albumartist_full) . "\"> " . scrub_out($this->f_albumartist_full) . "</a>";
}
// Format the Bitrate
$this->f_bitrate = intval($this->bitrate / 1000) . "-" . strtoupper($this->mode);
// Format the Time
$min = floor($this->time / 60);
$sec = sprintf("%02d", $this->time % 60);
$this->f_time = $min . ":" . $sec;
$hour = sprintf("%02d", floor($min / 60));
$min_h = sprintf("%02d", $min % 60);
$this->f_time_h = $hour . ":" . $min_h . ":" . $sec;
// Format the track (there isn't really anything to do here)
$this->f_track = (string) $this->track;
// Format the size
$this->f_size = UI::format_bytes($this->size);
$this->f_lyrics = "<a title=\"" . scrub_out($this->title) . "\" href=\"" . AmpConfig::get('web_path') . "/song.php?action=show_lyrics&song_id=" . $this->id . "\">" . T_('Show Lyrics') . "</a>";
$this->f_file = $this->f_artist . ' - ';
if ($this->track) {
$this->f_file .= $this->track . ' - ';
}
$this->f_file .= $this->f_title . '.' . $this->type;
$this->f_publisher = $this->label;
$this->f_composer = $this->composer;
}
示例11: format
/**
* format
* This takes the current song object
* and does a ton of formating on it creating f_??? variables on the current
* object
*/
public function format()
{
$this->fill_ext_info();
// Format the filename
preg_match("/^.*\\/(.*?)\$/", $this->file, $short);
if (is_array($short) && isset($short[1])) {
$this->f_file = htmlspecialchars($short[1]);
}
// Format the album name
$this->f_album_full = $this->get_album_name();
$this->f_album = $this->f_album_full;
// Format the artist name
$this->f_artist_full = $this->get_artist_name();
$this->f_artist = $this->f_artist_full;
// Format the title
$this->f_title_full = $this->title;
$this->f_title = $this->title;
// Create Links for the different objects
$this->link = AmpConfig::get('web_path') . "/song.php?action=show_song&song_id=" . $this->id;
$this->f_link = "<a href=\"" . scrub_out($this->link) . "\" title=\"" . scrub_out($this->f_artist) . " - " . scrub_out($this->title) . "\"> " . scrub_out($this->f_title) . "</a>";
$this->f_album_link = "<a href=\"" . AmpConfig::get('web_path') . "/albums.php?action=show&album=" . $this->album . "\" title=\"" . scrub_out($this->f_album_full) . "\"> " . scrub_out($this->f_album) . "</a>";
$this->f_artist_link = "<a href=\"" . AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $this->artist . "\" title=\"" . scrub_out($this->f_artist_full) . "\"> " . scrub_out($this->f_artist) . "</a>";
// Format the Bitrate
$this->f_bitrate = intval($this->bitrate / 1000) . "-" . strtoupper($this->mode);
// Format the Time
$min = floor($this->time / 60);
$sec = sprintf("%02d", $this->time % 60);
$this->f_time = $min . ":" . $sec;
// Format the track (there isn't really anything to do here)
$this->f_track = $this->track;
// Get the top tags
$this->tags = Tag::get_top_tags('song', $this->id);
$this->f_tags = Tag::get_display($this->tags);
// Format the size
$this->f_size = UI::format_bytes($this->size);
$this->f_lyrics = "<a title=\"" . scrub_out($this->title) . "\" href=\"" . AmpConfig::get('web_path') . "/song.php?action=show_lyrics&song_id=" . $this->id . "\">" . T_('Show Lyrics') . "</a>";
return true;
}