本文整理汇总了PHP中ezcConsoleOutput::formatText方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcConsoleOutput::formatText方法的具体用法?PHP ezcConsoleOutput::formatText怎么用?PHP ezcConsoleOutput::formatText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcConsoleOutput
的用法示例。
在下文中一共展示了ezcConsoleOutput::formatText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProgressMonitor4
public function testProgressMonitor4()
{
$out = new ezcConsoleOutput();
$out->formats->tag->color = 'red';
$out->formats->percent->color = 'blue';
$out->formats->percent->style = array('bold');
$out->formats->data->color = 'green';
$status = new ezcConsoleProgressMonitor($out, 7, array('formatString' => $out->formatText('%2$10s', 'tag') . ' ' . $out->formatText('%1$6.2f%%', 'percent') . ' ' . $out->formatText('%3$s', 'data')));
ob_start();
for ($i = 0; $i < 7; $i++) {
$status->addEntry($this->stati[$i][0], $this->stati[$i][1]);
}
$res = ob_get_contents();
ob_end_clean();
// To prepare test files use this:
// file_put_contents( dirname( __FILE__ ) . '/data/' . ( ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/" ) . 'testProgressMonitor4.dat', $res );
$this->assertEquals(file_get_contents(dirname(__FILE__) . '/data/' . (ezcBaseFeatures::os() === "Windows" ? "windows/" : "posix/") . 'testProgressMonitor4.dat'), $res, "Formated statusbar not generated correctly.");
}
示例2: generateRow
/**
* Generate a single physical row.
* This method generates the string for a single physical table row.
*
* @param array(int=>string) $cells Cells of the row.
* @param array(int=>int) $colWidth Calculated columns widths.
* @param ezcConsoleTableRow $row The row to generate.
* @return string The row.
*/
private function generateRow($cells, $colWidth, $row)
{
$rowData = '';
for ($cell = 0; $cell < count($colWidth); $cell++) {
$align = $this->determineAlign($row, $cell);
$format = $this->determineFormat($row, $cell);
$borderFormat = $this->determineBorderFormat($row);
$data = isset($cells[$cell]) ? $cells[$cell] : '';
$rowData .= $this->outputHandler->formatText($this->properties['options']->lineHorizontal, $borderFormat);
$rowData .= $this->properties['options']->colPadding;
$rowData .= $this->outputHandler->formatText(str_pad($data, $colWidth[$cell], ' ', $align), $format);
$rowData .= $this->properties['options']->colPadding;
}
$rowData .= $this->outputHandler->formatText($this->properties['options']->lineHorizontal, $row->borderFormat);
return $rowData;
}
示例3: testProgress9
public function testProgress9()
{
$out = new ezcConsoleOutput();
$formatString = '' . $out->formatText('Actual progress', 'success') . ': <' . $out->formatText('%bar%', 'failure') . '> ' . $out->formatText('%fraction%', 'success');
$this->commonProgressbarTest(__FUNCTION__, 1073, 123, array('barChar' => '123', 'emptyChar' => '987', 'progressChar' => '---', 'width' => 97, 'formatString' => $formatString, 'fractionFormat' => '%o'));
}
示例4: __autoload
require_once 'Base/src/base.php';
/**
* Autoload ezc classes
*
* @param string $className
*/
function __autoload($className)
{
ezcBase::autoload($className);
}
$out = new ezcConsoleOutput();
$out->formats->red->color = "red";
// Create progress bar itself
$progress = new ezcConsoleProgressbar($out, 100, array('step' => 5));
$progress->options->emptyChar = '-';
$progress->options->progressChar = $out->formatText('>', "red");
$progress->options->formatString = "Uploading file </tmp/foobar.tar.bz2>: %act%/%max% kb [%bar%]";
// Perform actions
$i = 0;
while ($i++ < 20) {
// Do whatever you want to indicate progress for
usleep(mt_rand(20000, 2000000));
// Advance the progressbar by one step ( uploading 5k per run )
$progress->advance();
}
// Finish progress bar and jump to next line.
$progress->finish();
$out->outputText("Successfully uploaded </tmp/foobar.tar.bz2>.\n", 'success');
/*
OUTPUT: (sequential, will be printed into 1 line and updated in reallife)
Uploading file </tmp/foobar.tar.bz2>: 5/100 kb [++#----------------------------------------------]
示例5: formatText
/**
* Returns the given $text formatted with $format.
*
* In case $useFormats is set to false in the output handler, the text is
* returned as given, without any formatting.
*
* @param string $text
* @param string $format
* @return string
*/
private function formatText($text, $format)
{
if ($this->outputHandler->options->useFormats) {
return $this->outputHandler->formatText($text, $format);
} else {
return $text;
}
}
示例6: ezcConsoleOutput
<?php
require_once 'tutorial_autoload.php';
$output = new ezcConsoleOutput();
$output->formats->success->color = 'green';
$output->formats->failure->color = 'red';
$options = array('successChar' => $output->formatText('+', 'success'), 'failureChar' => $output->formatText('-', 'failure'));
$status = new ezcConsoleStatusbar($output, $options);
for ($i = 0; $i < 120; $i++) {
$nextStatus = (bool) mt_rand(0, 1);
$status->add($nextStatus);
usleep(mt_rand(200, 2000));
}
$output->outputLine();
$output->outputLine('Successes: ' . $status->getSuccessCount() . ', Failures: ' . $status->getFailureCount());
示例7: ezcConsoleOutput
<?php
require 'ezc-setup.php';
$max = 23;
$output = new ezcConsoleOutput();
$output->formats->bar->color = 'red';
$output->formats->bar->style = array('bold');
$options = array('emptyChar' => ' ', 'barChar' => '-', 'formatString' => '%act% / %max% [' . $output->formatText('%bar%', 'bar') . '] %fraction%%');
$progress = new ezcConsoleProgressbar($output, $max, $options);
for ($i = 0; $i < $max; $i++) {
usleep(20000);
$progress->advance();
}
$progress->finish();
示例8: ezcConsoleOutput
<?php
require_once 'tutorial_autoload.php';
$output = new ezcConsoleOutput();
$output->formats->bar->color = 'blue';
$output->formats->bar->style = array('bold');
$options = array('emptyChar' => ' ', 'barChar' => '-', 'formatString' => '%fraction%% <' . $output->formatText('%bar%', 'bar') . '> Uploaded %act% / %max% kb', 'redrawFrequency' => 50);
$bar = new ezcConsoleProgressbar($output, 1024, $options);
for ($i = 0; $i < 1024; $i++) {
$bar->advance();
usleep(mt_rand(200, 2000));
}
$bar->finish();
$output->outputLine();