protected function doDump($data) { if (!class_exists('\\Tracy\\Dumper')) { return ''; } ob_start(); Dumper::dump($data, $this->options); return ob_get_clean(); }
public function getPanel() { if (empty($this->requests)) { return ''; } $panel = '<h1>Mandrill API calls</h1>' . '<div class="tracy-inner tracy-MandrillPanel">' . '<style type="text/css">' . '#tracy-debug .tracy-panel .tracy-MandrillPanel tr:nth-child(2n) td { background: inherit; }' . '</style>' . '<table>'; foreach ($this->requests as $index => $request) { $panel .= '<tr><th>' . ($index + 1) . '</th><td>'; ob_start(); Dumper::dump($request, [Dumper::DEPTH => 6]); $panel .= ob_get_clean() . '</td></tr>'; } return $panel . '</table>' . '</div>'; }
public function getPanel() { $s = ''; ob_start(); echo '<div class="tracy-inner">'; echo '<table>'; foreach (array_filter($this->requests, function ($value) { return isset($value['result']); }) as $req) { /** @var QueryInterface $query */ $query = $req['query']; /** @var Request $request */ $request = $req['request']; /** @var ResultInterface $result */ $result = $req['result']; $data = $result->getData(); echo '<tr><td>'; echo '<h3 style="font-weight:bold;font-size: 15px">Rows:</h3>'; if (isset($data['grouped'])) { $groupInfo = []; foreach ($data['grouped'] as $name => $info) { $groupInfo[] = $name . ' - ' . $info['matches'] . (isset($info['ngroups']) ? ' (' . $info['ngroups'] . ' groups)' : ''); } echo implode(', ', $groupInfo); } else { echo $data['response']['numFound']; } echo '<h3 style="font-weight:bold;font-size: 15px">Request:</h3>'; echo '<div>' . $request->getMethod() . ': ' . $request->getUri() . '</div>'; echo '<h3 style="font-weight:bold;font-size: 13px">Parameters:</h3><table style="margin-top: 5px">'; foreach ($request->getParams() as $key => $value) { echo '<tr><th>' . $key . '</th><td>'; Dumper::dump($value); echo '</td></tr>'; } echo '</table>'; echo '<h3 style="font-weight: bold;font-size:16px">Timing: </h3>'; $hasTiming = $result instanceof SelectResult && $result->getDebug()->getTiming(); if ($hasTiming) { $debugTime = $result->getDebug()->getTiming()->getPhase('process')->getTiming('debug'); } else { $debugTime = 0; } echo '<h4 style="font-weight: bold;font-size:14px">' . ($data['responseHeader']['QTime'] - $debugTime) . 'ms (without debug)</h4>'; if ($hasTiming) { echo '<table>'; /** @var TimingPhase $phase */ foreach ($result->getDebug()->getTiming() as $name => $phase) { echo '<tr>'; echo '<th>' . $name . "</th>"; echo '<td>' . $phase->getTime() . 'ms</td>'; echo '<td><table>'; foreach ($phase->getTimings() as $key => $time) { echo '<tr><th>' . $key . "</t><td>" . $time . 'ms</td></tr>'; } echo '</table></td>'; echo '</tr>'; } echo '</table>'; } if ($result instanceof SelectResult) { echo '<h3 style="font-weight: bold;font-size:16px">Explain:</h3>'; Dumper::dump($result->getDebug()->getExplain(), [Dumper::DEPTH => 16]); if (count($result->getDebug()->getExplainOther())) { Dumper::dump($result->getDebug()->getExplainOther(), [Dumper::DEPTH => 16]); } } echo '</td></tr>'; } echo '</table>'; echo '</div>'; $s .= ob_get_clean(); return empty($this->requests) ? '' : '<h1>Queries: ' . count($this->requests) . ($this->totalTime !== NULL ? ', time: ' . $this->totalTime . ' ms' : '') . '</h1>' . $s; }
/** * Dumps information about a variable in readable format. * @tracySkipLocation * @param mixed variable to dump * @param bool return output instead of printing it? (bypasses $productionMode) * @return mixed variable itself or dump */ public static function dump($var, $return = FALSE) { if ($return) { ob_start(); Dumper::dump($var, [Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLen]); return ob_get_clean(); } elseif (!self::$productionMode) { Dumper::dump($var, [Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLen, Dumper::LOCATION => self::$showLocation]); } return $var; }
$second = $form->addContainer('second'); $second->addText('name', 'Your name:'); $second->addText('email', 'Email:'); $second->addText('street', 'Street:'); $second->addText('city', 'City:'); // group for button $form->addGroup(); $form->addSubmit('submit', 'Send'); if ($form->isSuccess()) { echo '<h2>Form was submitted and successfully validated</h2>'; Dumper::dump($form->getValues()); exit; } ?> <!DOCTYPE html> <meta charset="utf-8"> <title>Nette Forms containers example</title> <link rel="stylesheet" media="screen" href="assets/style.css" /> <h1>Nette Forms containers example</h1> <?php echo $form ?> <footer><a href="https://doc.nette.org/en/forms">see documentation</a></footer>
$countries = ['World' => ['bu' => 'Buranda', 'qu' => 'Qumran', 'st' => 'Saint Georges Island'], '?' => 'other']; $form->addSelect('country', 'Country:', $countries)->setPrompt('Select your country')->addConditionOn($form['send'], $form::FILLED)->setRequired('Select your country'); // group Your account $form->addGroup('Your account'); $form->addPassword('password', 'Choose password:'******'Choose your password')->addRule($form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3); $form->addPassword('password2', 'Reenter password:'******'Reenter your password')->addRule($form::EQUAL, 'Passwords do not match', $form['password']); $form->addUpload('avatar', 'Picture:')->setRequired(FALSE)->addRule($form::IMAGE, 'Uploaded file is not image'); $form->addHidden('userid'); $form->addTextArea('note', 'Comment:'); // group for buttons $form->addGroup(); $form->addSubmit('submit', 'Send'); $form->setDefaults(['name' => 'John Doe', 'userid' => 231]); if ($form->isSuccess()) { echo '<h2>Form was submitted and successfully validated</h2>'; Dumper::dump($form->getValues(), [Dumper::COLLAPSE => FALSE]); exit; } ?> <!DOCTYPE html> <meta charset="utf-8"> <title>Nette Forms basic example</title> <link rel="stylesheet" media="screen" href="assets/style.css" /> <script src="https://nette.github.io/resources/js/netteForms.js"></script> <h1>Nette Forms basic example</h1> <?php echo $form; ?>
/** * @param mixed $parameter * @return string */ public static function format($parameter) { if ($parameter === NULL) { return '<span style="color: blue">NULL</span>'; } else { if ($parameter instanceof ArrayAccessor) { ob_start(); Dumper::dump($parameter->getArray(), [Dumper::TRUNCATE => Debugger::$maxLen, Dumper::DEPTH => Debugger::$maxDepth, Dumper::COLLAPSE => TRUE]); return ob_get_clean(); } else { if (is_array($parameter)) { ob_start(); Dumper::dump($parameter, [Dumper::TRUNCATE => Debugger::$maxLen, Dumper::DEPTH => Debugger::$maxDepth, Dumper::COLLAPSE => TRUE]); return ob_get_clean(); } else { return (string) $parameter; } } } }