bytes() public static method

Converts to human readable file size.
public static bytes ( $bytes, $precision = 2 ) : string
return string plain text
Beispiel #1
0
 public function getPanel()
 {
     $buff = '<h1>AssetsLoader</h1>' . '<div class="nette-inner">' . '<table>' . '<thead><tr><th>Source</th><th>Generated file</th><th>Memory usage</th></tr></thead>';
     $i = 0;
     foreach ($this->files as $source => $generated) {
         $buff .= '<tr><th' . ($i % 2 ? 'class="nette-alt"' : '') . '>' . $source . '</th><td>' . $this->link($generated['id'], $generated['type'], $generated['lastModified']) . '</td><td>' . Runtime\Filters::bytes($generated['memory']) . '</td></tr>';
     }
     return $buff . '</table></div>';
 }
 /**
  * @param string $defaultGenre
  * @return Form
  */
 public function create(string $defaultGenre = null)
 {
     $form = $this->factory->create();
     $maxSize = SizeParser::parse_size(ini_get("upload_max_filesize"));
     $form->addUpload('song', 'Nová skladba: ', true)->addRule(Form::MAX_FILE_SIZE, 'Nemůžete nahrát vetší soubor než ' . Filters::bytes($maxSize) . '(nastaveno v php.ini)', $maxSize)->getControlPrototype()->addAttributes(['class' => 'file', 'tabindex' => 1, 'accesskey' => 'i']);
     $genres = $this->genresManager->getAllGenreIdsAndNames();
     $form->addSelect('genre', 'Žánr: ', $genres)->setPrompt('-')->setDefaultValue($defaultGenre)->getControlPrototype()->addAttributes(['tabindex' => 2, 'accesskey' => 'g']);
     $form->addSubmit('send', 'Nahrát skladbu')->getControlPrototype()->addAttributes(['tabindex' => 3, 'accesskey' => 's']);
     $form->onValidate[] = $this->validateSongsMetadata;
     return $form;
 }
Beispiel #3
0
 public function actionDeleteFinal($id)
 {
     $f = $this->folder->find($id);
     if (!$f) {
         $this->error('Složka s tímto ID neexistuje.');
     }
     $fm = $this->sm->getFolder($f->name);
     $fc = $fm["sc"];
     $maxSpace = 2 * 1024 * 1024;
     if ($fc->space_used > $maxSpace) {
         $this->flashMessage('Chyba, složka není prázdná. Obsahuje ' . \Latte\Runtime\Filters::bytes($fc->space_used) . ' dat.', 'danger');
         $this->redirect('Slozky:delete', $id);
     }
     $sharescount = $f->related('share.folder_id')->count();
     if ($sharescount != 0) {
         $this->flashMessage('Chyba, složka má stále zaplá některá sdílení. Deaktivujte je před smazáním, prosím.', 'danger');
         $this->redirect('Slozky:delete', $id);
     }
     $state = $this->sm->deleteUserFolder($id);
     if ($state == FALSE) {
         $this->flashMessage('Omlouváme se, složku se nepodařilo smazat kvůli chybě v systému. Prosím kontaktujte podporu.', 'danger');
         $this->redirect('Slozky:');
     }
     $this->flashMessage('Složka byla úspěšně smazána.', 'success');
     $this->redirect('Slozky:');
 }
Beispiel #4
0
 /**
  * Returns panel tab.
  * @return string
  */
 public function getTab()
 {
     $this->compute();
     return '<span title="WebLoader">' . '<svg viewBox="0 -50 600 600" style="vertical-align: bottom; width:1.23em; height:1.55em"><polygon fill="#1565C0" points="75.089,23.98 58.245,108.778 403.138,108.778 392.289,163.309 47.111,163.309 30.549,248.104 375.445,248.104 356.027,344.887 217.273,390.856 96.789,344.887 105.069,302.921 20.272,302.921 0,404.559 199.286,480.791 428.831,404.559 504.771,23.98"/></svg>' . Filters::bytes($this->size['combined']) . '</span>';
 }
Beispiel #5
0
 /**
  * Returns panel tab.
  * @return string
  */
 public function getTab()
 {
     $this->compute();
     return '<span title="WebLoader">' . '<img src="data:image/png;base64,' . base64_encode(file_get_contents(__DIR__ . '/icon.png')) . '" /> ' . Filters::bytes($this->size['combined']) . '</span>';
 }