Exemple #1
0
 /**
  * Prints 'OK' or 'FAILURE' footer.
  *
  * @param Result $result
  */
 protected function printFooter(Result $result)
 {
     if (count($result->getBackups()) === 0) {
         $this->writeWithColor('fg-black, bg-yellow', 'No backups executed!');
     } elseif ($result->allOk()) {
         $this->writeWithColor('fg-black, bg-green', sprintf('OK (%d %s, %d %s, %d %s, %d %s, %d %s)' . PHP_EOL, count($result->getBackups()), Util\Str::appendPluralS('backup', count($result->getBackups())), $this->numChecks, Util\Str::appendPluralS('check', $this->numChecks), $this->numCrypts, Util\Str::appendPluralS('crypt', $this->numCrypts), $this->numSyncs, Util\Str::appendPluralS('sync', $this->numSyncs), $this->numCleanups, Util\Str::appendPluralS('cleanup', $this->numCleanups)));
     } elseif ($result->backupOkButSkipsOrFails()) {
         $this->writeWithColor('fg-black, bg-yellow', sprintf("OK, but skipped|failed Crypts, Syncs or Cleanups!\n" . 'Backups: %d, Crypts: %d|%d, Syncs: %d|%d, Cleanups: %d|%d.' . PHP_EOL, count($result->getBackups()), $result->cryptsSkippedCount(), $result->cryptsFailedCount(), $result->syncsSkippedCount(), $result->syncsFailedCount(), $result->cleanupsSkippedCount(), $result->cleanupsFailedCount()));
     } else {
         $this->writeWithColor('fg-white, bg-red', sprintf("FAILURE!\n" . 'Backups: %d, failed Checks: %d, failed Crypts: %d, failed Syncs: %d, failed Cleanups: %d.' . PHP_EOL, count($result->getBackups()), $result->checksFailedCount(), $result->cryptsFailedCount(), $result->syncsFailedCount(), $result->cleanupsFailedCount()));
     }
 }
Exemple #2
0
 /**
  * Return mail status html
  *
  * @param  \phpbu\App\Result $result
  * @return string
  */
 protected function getStatusHtml(Result $result)
 {
     if (count($result->getBackups()) === 0) {
         $color = TPL::getSnippet('cStatusWARN');
         $status = 'WARNING';
     } elseif ($result->allOk()) {
         $color = TPL::getSnippet('cStatusOK');
         $status = 'OK';
     } elseif ($result->backupOkButSkipsOrFails()) {
         $color = TPL::getSnippet('cStatusWARN');
         $status = 'WARNING';
     } else {
         $color = TPL::getSnippet('cStatusFAIL');
         $status = 'FAILURE';
     }
     $info = sprintf('(%d %s, %d %s, %d %s, %d %s, %d %s)', count($result->getBackups()), Str::appendPluralS('backup', count($result->getBackups())), $this->numChecks, Str::appendPluralS('check', $this->numChecks), $this->numCrypts, Str::appendPluralS('crypt', $this->numCrypts), $this->numSyncs, Str::appendPluralS('sync', $this->numSyncs), $this->numCleanups, Str::appendPluralS('cleanup', $this->numCleanups));
     $html = '<table ' . sprintf(TPL::getSnippet('sTableStatus'), $color) . '>' . '<tr><td>' . '<span ' . TPL::getSnippet('sTableStatusText') . '>' . date('Y-m-d H:i') . '</span>' . '<h1 ' . TPL::getSnippet('sTableStatusHead') . '>' . $status . '</h1>' . '<span ' . TPL::getSnippet('sTableStatusText') . '>' . $info . '</span>' . '</td></tr>' . '</table>';
     return $html;
 }