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


PHP Kit::formatBytes方法代码示例

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


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

示例1: DisplayGrid

 /**
  * Grid of Displays
  * @return
  */
 function DisplayGrid()
 {
     // validate displays so we get a realistic view of the table
     Display::ValidateDisplays();
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     // Filter by Name
     $filter_display = Kit::GetParam('filter_display', _POST, _STRING);
     setSession('display', 'filter_display', $filter_display);
     // Filter by Name
     $filterMacAddress = Kit::GetParam('filterMacAddress', _POST, _STRING);
     setSession('display', 'filterMacAddress', $filterMacAddress);
     // Display Group
     $filter_displaygroupid = Kit::GetParam('filter_displaygroup', _POST, _INT);
     setSession('display', 'filter_displaygroup', $filter_displaygroupid);
     // Thumbnail?
     $filter_showView = Kit::GetParam('filter_showView', _REQUEST, _INT);
     setSession('display', 'filter_showView', $filter_showView);
     $filterVersion = Kit::GetParam('filterVersion', _REQUEST, _STRING);
     setSession('display', 'filterVersion', $filterVersion);
     // filter_autoRefresh?
     $filter_autoRefresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0);
     setSession('display', 'filter_autoRefresh', $filter_autoRefresh);
     // Pinned option?
     setSession('display', 'DisplayFilter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));
     $displays = $user->DisplayList(array('displayid'), array('displaygroupid' => $filter_displaygroupid, 'display' => $filter_display, 'macAddress' => $filterMacAddress, 'clientVersion' => $filterVersion));
     if (!is_array($displays)) {
         trigger_error($db->error());
         trigger_error(__('Unable to get list of displays'), E_USER_ERROR);
     }
     // Do we want to make a VNC link out of the display name?
     $vncTemplate = Config::GetSetting('SHOW_DISPLAY_AS_VNCLINK');
     $linkTarget = Kit::ValidateParam(Config::GetSetting('SHOW_DISPLAY_AS_VNC_TGT'), _STRING);
     $cols = array(array('name' => 'displayid', 'title' => __('ID')), array('name' => 'displayWithLink', 'title' => __('Display')), array('name' => 'status', 'title' => __('Status'), 'icons' => true, 'iconDescription' => 'statusDescription'), array('name' => 'licensed', 'title' => __('License'), 'icons' => true), array('name' => 'currentLayout', 'title' => __('Current Layout'), 'hidden' => $filter_showView != 3), array('name' => 'storageAvailableSpaceFormatted', 'title' => __('Storage Available'), 'hidden' => $filter_showView != 3), array('name' => 'storageTotalSpaceFormatted', 'title' => __('Storage Total'), 'hidden' => $filter_showView != 3), array('name' => 'storagePercentage', 'title' => __('Storage Free %'), 'hidden' => $filter_showView != 3), array('name' => 'description', 'title' => __('Description'), 'hidden' => $filter_showView != 4), array('name' => 'layout', 'title' => __('Default Layout'), 'hidden' => $filter_showView != 0), array('name' => 'inc_schedule', 'title' => __('Interleave Default'), 'icons' => true, 'hidden' => $filter_showView == 1 || $filter_showView == 2), array('name' => 'email_alert', 'title' => __('Email Alert'), 'icons' => true, 'hidden' => $filter_showView != 0), array('name' => 'loggedin', 'title' => __('Logged In'), 'icons' => true), array('name' => 'lastaccessed', 'title' => __('Last Accessed')), array('name' => 'clientVersionCombined', 'title' => __('Version'), 'hidden' => $filter_showView != 3), array('name' => 'clientaddress', 'title' => __('IP Address'), 'hidden' => $filter_showView == 1), array('name' => 'macaddress', 'title' => __('Mac Address'), 'hidden' => $filter_showView == 1), array('name' => 'screenShotRequested', 'title' => __('Screen shot?'), 'icons' => true, 'hidden' => $filter_showView != 1 && $filter_showView != 2), array('name' => 'thumbnail', 'title' => __('Thumbnail'), 'hidden' => $filter_showView != 1 && $filter_showView != 2));
     Theme::Set('table_cols', $cols);
     Theme::Set('rowClass', 'rowColor');
     $rows = array();
     foreach ($displays as $row) {
         // VNC Template as display name?
         if ($vncTemplate != '' && $row['clientaddress'] != '') {
             if ($linkTarget == '') {
                 $linkTarget = '_top';
             }
             $row['displayWithLink'] = sprintf('<a href="' . $vncTemplate . '" title="VNC to ' . $row['display'] . '" target="' . $linkTarget . '">' . Theme::Prepare($row['display']) . '</a>', $row['clientaddress']);
         } else {
             $row['displayWithLink'] = $row['display'];
         }
         // Format last accessed
         $row['lastaccessed'] = DateManager::getLocalDate($row['lastaccessed']);
         // Create some login lights
         $row['rowColor'] = $row['mediainventorystatus'] == 1 ? 'success' : ($row['mediainventorystatus'] == 2 ? 'danger' : 'warning');
         // Set some text for the display status
         switch ($row['mediainventorystatus']) {
             case 1:
                 $row['statusDescription'] = __('Display is up to date');
                 break;
             case 2:
                 $row['statusDescription'] = __('Display is downloading new files');
                 break;
             case 3:
                 $row['statusDescription'] = __('Display is out of date but has not yet checked in with the server');
                 break;
             default:
                 $row['statusDescription'] = __('Unknown Display Status');
         }
         $row['status'] = $row['mediainventorystatus'] == 1 ? 1 : ($row['mediainventorystatus'] == 2 ? 0 : -1);
         // Thumbnail
         $row['thumbnail'] = '';
         // If we aren't logged in, and we are showThumbnail == 2, then show a circle
         if ($filter_showView == 2 && $row['loggedin'] == 0) {
             $row['thumbnail'] = '<i class="fa fa-times-circle"></i>';
         } else {
             if ($filter_showView != 0 && file_exists(Config::GetSetting('LIBRARY_LOCATION') . 'screenshots/' . $row['displayid'] . '_screenshot.jpg')) {
                 $row['thumbnail'] = '<a data-toggle="lightbox" data-type="image" href="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '"><img class="display-screenshot" src="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '&' . Kit::uniqueId() . '" /></a>';
             }
         }
         // Version
         $row['clientVersionCombined'] = $row['client_type'] . ' / ' . $row['client_version'];
         // Format the storage available / total space
         $row['storageAvailableSpaceFormatted'] = Kit::formatBytes($row['storageAvailableSpace']);
         $row['storageTotalSpaceFormatted'] = Kit::formatBytes($row['storageTotalSpace']);
         $row['storagePercentage'] = $row['storageTotalSpace'] == 0 ? 100 : round($row['storageAvailableSpace'] / $row['storageTotalSpace'] * 100.0, 2);
         // Edit and Delete buttons first
         if ($row['edit'] == 1) {
             // Edit
             $row['buttons'][] = array('id' => 'display_button_edit', 'url' => 'index.php?p=display&q=displayForm&displayid=' . $row['displayid'], 'text' => __('Edit'));
         }
         // Delete
         if ($row['del'] == 1) {
             $row['buttons'][] = array('id' => 'display_button_delete', 'url' => 'index.php?p=display&q=DeleteForm&displayid=' . $row['displayid'], 'text' => __('Delete'));
         }
         if ($row['edit'] == 1 || $row['del'] == 1) {
             $row['buttons'][] = array('linkType' => 'divider');
         }
         // Schedule Now
//.........这里部分代码省略.........
开发者ID:fignew,项目名称:xibo-cms,代码行数:101,代码来源:display.class.php

示例2: tidyLibraryForm

 public function tidyLibraryForm()
 {
     $response = new ResponseManager();
     Theme::Set('form_id', 'TidyLibraryForm');
     Theme::Set('form_action', 'index.php?p=content&q=tidyLibrary');
     $formFields = array();
     $formFields[] = FormManager::AddMessage(__('Tidying your Library will delete any media that is not currently in use.'));
     // Work out how many files there are
     $media = Media::entriesUnusedForUser($this->user->userid);
     $formFields[] = FormManager::AddMessage(sprintf(__('There is %s of data stored in %d files . Are you sure you want to proceed?', Kit::formatBytes(array_sum(array_map(function ($element) {
         return $element['fileSize'];
     }, $media))), count($media))));
     Theme::Set('form_fields', $formFields);
     $response->SetFormRequestResponse(NULL, __('Tidy Library'), '350px', '275px');
     $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('Content', 'TidyLibrary') . '")');
     $response->AddButton(__('No'), 'XiboDialogClose()');
     $response->AddButton(__('Yes'), '$("#TidyLibraryForm").submit()');
     $response->Respond();
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:19,代码来源:content.class.php

示例3: Grid

    /**
     * Group Grid
     * Called by AJAX
     * @return 
     */
    function Grid()
    {
        $db =& $this->db;
        $user =& $this->user;
        $filter_name = Kit::GetParam('filter_name', _POST, _STRING);
        setSession('usergroup', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));
        setSession('usergroup', 'filter_name', $filter_name);
        $SQL = <<<END
\t\tSELECT \tgroup.group,
\t\t\t\tgroup.groupID,
\t\t\t\tgroup.libraryQuota
\t\tFROM `group`
\t\tWHERE IsUserSpecific = 0 AND IsEveryone = 0
END;
        if ($filter_name != '') {
            $SQL .= sprintf(" AND group.group LIKE '%%%s%%' ", $db->escape_string($filter_name));
        }
        $SQL .= " ORDER BY group.group ";
        //Debug::LogEntry('audit', $SQL);
        if (!($results = $db->query($SQL))) {
            trigger_error($db->error());
            trigger_error(__("Can not get group information."), E_USER_ERROR);
        }
        $cols = array(array('name' => 'usergroup', 'title' => __('User Group')), array('name' => 'libraryQuotaText', 'title' => __('Library Quota')));
        Theme::Set('table_cols', $cols);
        $rows = array();
        while ($row = $db->get_assoc_row($results)) {
            $groupid = Kit::ValidateParam($row['groupID'], _INT);
            $group = Kit::ValidateParam($row['group'], _STRING);
            $row['usergroup'] = $group;
            $row['libraryQuota'] = Kit::ValidateParam($row['libraryQuota'], _INT);
            $row['libraryQuotaText'] = $row['libraryQuota'] == 0 ? '' : Kit::formatBytes($row['libraryQuota'] * 1024);
            // we only want to show certain buttons, depending on the user logged in
            if ($user->GetUserTypeID() == 1) {
                // Edit
                $row['buttons'][] = array('id' => 'usergroup_button_edit', 'url' => 'index.php?p=group&q=GroupForm&groupid=' . $groupid, 'text' => __('Edit'));
                // Delete
                $row['buttons'][] = array('id' => 'usergroup_button_delete', 'url' => 'index.php?p=group&q=DeleteForm&groupid=' . $groupid, 'text' => __('Delete'));
                // Members
                $row['buttons'][] = array('id' => 'usergroup_button_members', 'url' => 'index.php?p=group&q=MembersForm&groupid=' . $groupid, 'text' => __('Members'));
                // Page Security
                $row['buttons'][] = array('id' => 'usergroup_button_page_security', 'url' => 'index.php?p=group&q=PageSecurityForm&groupid=' . $groupid, 'text' => __('Page Security'));
                // Menu Security
                $row['buttons'][] = array('id' => 'usergroup_button_menu_security', 'url' => 'index.php?p=group&q=MenuItemSecurityForm&groupid=' . $groupid, 'text' => __('Menu Security'));
                // User Quota
                $row['buttons'][] = array('id' => 'usergroup_button_quota', 'url' => 'index.php?p=group&q=quotaForm&groupid=' . $groupid, 'text' => __('Set User Quota'));
            }
            $rows[] = $row;
        }
        Theme::Set('table_rows', $rows);
        $output = Theme::RenderReturn('table_render');
        $response = new ResponseManager();
        $response->SetGridResponse($output);
        $response->Respond();
    }
开发者ID:fignew,项目名称:xibo-cms,代码行数:60,代码来源:group.class.php

示例4: UserGrid

 /**
  * Prints the user information in a table based on a check box selection
  *
  */
 function UserGrid()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     // Capture the filter options
     // User ID
     $filter_username = Kit::GetParam('filter_username', _POST, _STRING);
     setSession('user_admin', 'filter_username', $filter_username);
     // User Type ID
     $filter_usertypeid = Kit::GetParam('filter_usertypeid', _POST, _INT);
     setSession('user_admin', 'filter_usertypeid', $filter_usertypeid);
     $filterRetired = Kit::GetParam('filterRetired', _POST, _INT);
     setSession('user_admin', 'filterRetired', $filterRetired);
     // Pinned option?
     setSession('user_admin', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));
     // Filter our users?
     $filterBy = array();
     // Filter on User Type
     if ($filter_usertypeid != 0) {
         $filterBy['userTypeId'] = $filter_usertypeid;
     }
     // Filter on User Name
     if ($filter_username != '') {
         $filterBy['userName'] = $filter_username;
     }
     $filterBy['retired'] = $filterRetired;
     // Load results into an array
     $users = $user->userList(array('userName'), $filterBy);
     if (!is_array($users)) {
         trigger_error(__('Error getting list of users'), E_USER_ERROR);
     }
     $cols = array(array('name' => 'username', 'title' => __('Name')), array('name' => 'homepage', 'title' => __('Homepage')), array('name' => 'email', 'title' => __('Email')), array('name' => 'libraryQuotaText', 'title' => __('Library Quota')), array('name' => 'retired', 'title' => __('Retired?'), 'icons' => true));
     Theme::Set('table_cols', $cols);
     $rows = array();
     foreach ($users as $row) {
         $row['libraryQuotaText'] = $row['object']->libraryQuota == 0 ? '' : Kit::formatBytes($row['object']->libraryQuota * 1024);
         // Super admins have some buttons
         if ($user->usertypeid == 1) {
             // Edit
             $row['buttons'][] = array('id' => 'user_button_edit', 'url' => 'index.php?p=user&q=DisplayForm&userID=' . $row['userid'], 'text' => __('Edit'));
             // Delete
             $row['buttons'][] = array('id' => 'user_button_delete', 'url' => 'index.php?p=user&q=DeleteForm&userID=' . $row['userid'], 'text' => __('Delete'));
             // Page Security
             $row['buttons'][] = array('id' => 'user_button_page_security', 'url' => 'index.php?p=group&q=PageSecurityForm&groupid=' . $row['object']->groupId, 'text' => __('Page Security'));
             // Menu Security
             $row['buttons'][] = array('id' => 'user_button_menu_security', 'url' => 'index.php?p=group&q=MenuItemSecurityForm&groupid=' . $row['object']->groupId, 'text' => __('Menu Security'));
             // Applications
             $row['buttons'][] = array('id' => 'user_button_applications', 'url' => 'index.php?p=oauth&q=UserTokens&userID=' . $row['userid'], 'text' => __('Applications'));
             // Set Home Page
             $row['buttons'][] = array('id' => 'user_button_homepage', 'url' => 'index.php?p=user&q=SetUserHomePageForm&userid=' . $row['userid'], 'text' => __('Set Homepage'));
             // Set Password
             $row['buttons'][] = array('id' => 'user_button_delete', 'url' => 'index.php?p=user&q=SetPasswordForm&userid=' . $row['userid'], 'text' => __('Set Password'));
             // User Quota
             $row['buttons'][] = array('id' => 'usergroup_button_quota', 'url' => 'index.php?p=group&q=quotaForm&groupid=' . $row['object']->groupId, 'text' => __('Set User Quota'));
         }
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     $table = Theme::RenderReturn('table_render');
     $response->SetGridResponse($table);
     $response->Respond();
 }
开发者ID:fignew,项目名称:xibo-cms,代码行数:67,代码来源:user.class.php

示例5: displayPage

 function displayPage()
 {
     // Set up some suffixes
     $suffixes = array('bytes', 'k', 'M', 'G', 'T');
     // Get some data for a bandwidth chart
     try {
         $dbh = PDOConnect::init();
         $sth = $dbh->prepare('SELECT FROM_UNIXTIME(month) AS month, IFNULL(SUM(Size), 0) AS size FROM `bandwidth` WHERE month > :month GROUP BY FROM_UNIXTIME(month) ORDER BY MIN(month);');
         $sth->execute(array('month' => time() - 86400 * 365));
         $results = $sth->fetchAll();
         // Monthly bandwidth - optionally tested against limits
         $xmdsLimit = Config::GetSetting('MONTHLY_XMDS_TRANSFER_LIMIT_KB');
         $maxSize = 0;
         foreach ($results as $row) {
             $maxSize = $row['size'] > $maxSize ? $row['size'] : $maxSize;
         }
         // Decide what our units are going to be, based on the size
         $base = $maxSize == 0 ? 0 : floor(log($maxSize) / log(1024));
         if ($xmdsLimit > 0) {
             // Convert to appropriate size (xmds limit is in KB)
             $xmdsLimit = $xmdsLimit * 1024 / pow(1024, $base);
             Theme::Set('xmdsLimit', $xmdsLimit . ' ' . $suffixes[$base]);
         }
         $output = array();
         foreach ($results as $row) {
             $size = (double) $row['size'] / pow(1024, $base);
             $remaining = $xmdsLimit - $size;
             $output[] = array('label' => DateManager::getLocalDate(DateManager::getDateFromGregorianString($row['month']), 'F'), 'value' => round($size, 2), 'limit' => round($remaining, 2));
         }
         // What if we are empty?
         if (count($output) == 0) {
             $output[] = array('label' => DateManager::getLocalDate(null, 'F'), 'value' => 0, 'limit' => 0);
         }
         // Set the data
         Theme::Set('xmdsLimitSet', $xmdsLimit > 0);
         Theme::Set('bandwidthSuffix', $suffixes[$base]);
         Theme::Set('bandwidthWidget', json_encode($output));
         // We would also like a library usage pie chart!
         $libraryLimit = Config::GetSetting('LIBRARY_SIZE_LIMIT_KB');
         $libraryLimit = $libraryLimit * 1024;
         // Library Size in Bytes
         $sth = $dbh->prepare('SELECT IFNULL(SUM(FileSize), 0) AS SumSize, type FROM media GROUP BY type;');
         $sth->execute();
         $results = $sth->fetchAll();
         // Do we base the units on the maximum size or the library limit
         $maxSize = 0;
         if ($libraryLimit > 0) {
             $maxSize = $libraryLimit;
         } else {
             // Find the maximum sized chunk of the items in the library
             foreach ($results as $library) {
                 $maxSize = $library['SumSize'] > $maxSize ? $library['SumSize'] : $maxSize;
             }
         }
         // Decide what our units are going to be, based on the size
         $base = $maxSize == 0 ? 0 : floor(log($maxSize) / log(1024));
         $output = array();
         $totalSize = 0;
         foreach ($results as $library) {
             $output[] = array('value' => round((double) $library['SumSize'] / pow(1024, $base), 2), 'label' => ucfirst($library['type']));
             $totalSize = $totalSize + $library['SumSize'];
         }
         // Do we need to add the library remaining?
         if ($libraryLimit > 0) {
             $remaining = round(($libraryLimit - $totalSize) / pow(1024, $base), 2);
             $output[] = array('value' => $remaining, 'label' => __('Free'));
         }
         // What if we are empty?
         if (count($output) == 0) {
             $output[] = array('label' => __('Empty'), 'value' => 0);
         }
         Theme::Set('libraryLimitSet', $libraryLimit);
         Theme::Set('libraryLimit', round((double) $libraryLimit / pow(1024, $base), 2) . ' ' . $suffixes[$base]);
         Theme::Set('librarySize', Kit::formatBytes($totalSize, 1));
         Theme::Set('librarySuffix', $suffixes[$base]);
         Theme::Set('libraryWidget', json_encode($output));
         // Also a display widget
         $sort_order = array('display');
         $displays = $this->user->DisplayList($sort_order);
         $rows = array();
         if (is_array($displays) && count($displays) > 0) {
             // Output a table showing the displays
             foreach ($displays as $row) {
                 $row['mediainventorystatus'] = $row['mediainventorystatus'] == 1 ? 'success' : ($row['mediainventorystatus'] == 2 ? 'danger' : 'warning');
                 // Assign this to the table row
                 $rows[] = $row;
             }
         }
         Theme::Set('display-widget-rows', $rows);
         // Get a count of users
         $sth = $dbh->prepare('SELECT IFNULL(COUNT(*), 0) AS count_users FROM `user`');
         $sth->execute();
         Theme::Set('countUsers', $sth->fetchColumn(0));
         // Get a count of active layouts
         $sth = $dbh->prepare('SELECT IFNULL(COUNT(*), 0) AS count_scheduled FROM `schedule_detail` WHERE :now BETWEEN FromDT AND ToDT');
         $sth->execute(array('now' => time()));
         Theme::Set('nowShowing', $sth->fetchColumn(0));
         // Latest news
         if (Config::GetSetting('DASHBOARD_LATEST_NEWS_ENABLED') == 1) {
             // Make sure we have the cache location configured
//.........这里部分代码省略.........
开发者ID:fignew,项目名称:xibo-cms,代码行数:101,代码来源:statusdashboard.class.php


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