/** * @param $string * @return mixed */ public function write($string) { $time = microtime(true); if ($time - $this->lastWriteTime > $this->threshold) { $this->writer->write($string); $this->lastWriteTime = $time; } }
/** * Display the log file contents for today * * @param string $q * @param array $matches * @param array $params */ function fn_logs($q, $matches, $params) { $log_file = TITANIUM_ROOT . 'logs/' . date('Y-m-d') . '.txt'; Logger::write("Reading log file: {$log_file}"); if (file_exists($log_file)) { Output::write(file_get_contents($log_file), false, true); } else { Output::write("{$log_file} does not exist.", 'red', true); } }
protected function run_before_loop_exec() { $exec = \AIP\lib\Config::get(\AIP\lib\Config::OPTION_BEFORE_LOOP_EXEC); ob_start(); foreach($exec as $line) $this->tick($line); $output = ob_get_clean(); if(\AIP\lib\Config::get(\AIP\lib\Config::OPTION_VERBOSITY) > 0) { Output::write(\AIP\lib\srvr\evlr\Result::message("Start of 'before_loop_exec'")); Output::raw_write($output); Output::write(\AIP\lib\srvr\evlr\Result::message("End of 'before_loop_exec'")); } }
public static function debug($vars) { ob_get_clean(); Evaluer::$path[] = 'debug'; Evaluer::sandbox_vars($vars, false); $parser = new Parser; $interrupted = false; while(!$interrupted) { $line = Input::read(Evaluer::pathenize()); $statement = $parser->parse($line); $result = Evaluer::execute($statement); Output::write($result); $interrupted = $statement->interrupted(); } $vars = Evaluer::sandbox_vars(); array_pop(Evaluer::$path); ob_start(); return $vars; }
/** * Display the help page * * @param string $q * @param array $matches * @param array $params */ function fn_help($q, $matches, $params) { Logger::write("Running: " . __FUNCTION__); Output::write(Template::render('functions/help.tpl.php', $data), false, true); }
function print_ticker() { if (RUN_MODE == 'INTERACTIVE') { Output::write(TICKER, 'bold'); } }
#include_once('3rd-party/simplepie/idn/idna_convert.class.php'); # RSS init: $rss = new Rss(); # Get the posts: Debug::info("Getting the posts"); $posts = $rss->getPosts($Config->getFeeds()); # Write mode output openning: Debug::info("Generating HTML output at " . OUTDIR . "/" . OUTFILE); Debug::info("Generating RSS 2.0 output at " . OUTDIR . "/rss20.xml"); $fOutput = new Output(); # # Output files generation: # # Header: Debug::info("Headers"); $fOutput->write(File::ReadAndParse('html/header.html')); $fOutput->writeRss(File::ReadAndParse('xml/rss20_head.xml')); # Javascript: Debug::info("HTML: Javascript functions"); $fOutput->write(File::Read('html/functions.js')); # Body: Debug::info("Bodies"); # The posts: Debug::info("The posts"); $fOutput->write('<div id="posts">'); # Posts loop: foreach ($posts as $post) { Debug::info(" Output (" . $post['author'] . ") " . $post['title']); $fOutput->write(File::ReadAndParse('html/post.html', $post)); $fOutput->writeRss(File::ReadAndParse('xml/rss20_item.xml', $post)); }
/** * Display a list of the base class includes * * @param string $q * @param array $matches * @param array $params */ function fn_listincludes($q, $matches, $params) { Logger::write("Running: " . __FUNCTION__); $data = array('includes' => Titanium::loaded_classes()); Output::write(Template::render('functions/listincludes.tpl.php', $data), false, true); }
/** * Outputs the help menu. * * @return PhpCli\Parser Returns $this, for object-chaining. */ public function help() { echo PHP_EOL; $output = new Output(); $output->write('Available Commands', ['color' => 'red', 'bold' => true, 'underline' => true]); echo PHP_EOL; $maxlen = 0; foreach ($this->supportedArgs as $key => $description) { $len = strlen($key); if ($len > $maxlen) { $maxlen = $len; } } foreach ($this->supportedArgs as $key => $description) { $len = strlen($key); $output->write(' ')->write($key, ['color' => 'yellow'])->write(str_repeat(' ', $maxlen - $len))->write(' - ')->write($description); echo PHP_EOL; } echo PHP_EOL; }
/** * 换行输入 * * @param string $message */ function writeln($message = '') { $this->out->write($message, true); }
/** * Display the tutorial page * * @param string $q * @param array $matches * @param array $params */ function fn_tutorial($q, $matches, $params) { Logger::write("Running: " . __FUNCTION__); Output::write(Template::render('functions/tutorial.tpl.php'), false, true); }
/** * Writes to an output and returns the output * * @param var $value * @param text.json.Output $output * @return text.json.Output The given output */ public static function write($value, Output $output) { $output->write($value); return $output; }