示例#1
0
 /**
  * Parses a signed_request and validates the signature.
  *
  * @param string $signedRequest A signed token
  * @param string $appSecret
  *
  * @return array The payload inside it or null if the sig is wrong
  */
 public static function decode($signedRequest, $appSecret)
 {
     if (!$signedRequest || strpos($signedRequest, '.') === false) {
         Debugger::log('Signed request is invalid! ' . json_encode($signedRequest), 'facebook');
         return NULL;
     }
     list($encoded_sig, $payload) = explode('.', $signedRequest, 2);
     // decode the data
     $sig = Helpers::base64UrlDecode($encoded_sig);
     $data = Json::decode(Helpers::base64UrlDecode($payload), Json::FORCE_ARRAY);
     if (!isset($data['algorithm']) || strtoupper($data['algorithm']) !== Configuration::SIGNED_REQUEST_ALGORITHM) {
         Debugger::log("Unknown algorithm '{$data['algorithm']}', expected " . Configuration::SIGNED_REQUEST_ALGORITHM, 'facebook');
         return NULL;
     }
     // check sig
     $expected_sig = hash_hmac('sha256', $payload, $appSecret, $raw = TRUE);
     if (strlen($expected_sig) !== strlen($sig)) {
         Debugger::log('Bad Signed JSON signature! Expected ' . Dumper::toText($expected_sig) . ', but given ' . Dumper::toText($sig), 'facebook');
         return NULL;
     }
     $result = 0;
     for ($i = 0; $i < strlen($expected_sig); $i++) {
         $result |= ord($expected_sig[$i]) ^ ord($sig[$i]);
     }
     if ($result !== 0) {
         Debugger::log('Bad Signed JSON signature! Expected ' . Dumper::toText($expected_sig) . ', but given ' . Dumper::toText($sig), 'facebook');
         return NULL;
     }
     return $data;
 }
示例#2
0
 /**
  * Dumps information about a variable in readable format.
  *
  * @param  mixed $var to dump
  * @param null   $title
  * @return void
  */
 public static function sdump($var, $title = null)
 {
     if (!Debugger::$productionMode) {
         self::initialize();
         $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
         $item = Helpers::findTrace($trace, 'sdump', $index) ?: Helpers::findTrace($trace, __CLASS__ . '::sdump', $index);
         if (isset($item['file'], $item['line']) && is_file($item['file'])) {
             $lines = file($item['file']);
             preg_match('#sdump\\((.*)\\)#', $lines[$item['line'] - 1], $matches);
             $params = isset($matches[1]) ? htmlspecialchars($matches[1]) : false;
             if ($params) {
                 preg_match('#array\\((.*)\\)#', $params, $matches2);
                 $params = isset($matches2[1]) ? $matches2[1] : $params;
                 $params = explode(',', $params);
             }
             $dumpParams = isset($matches[0]) ? "{$matches['0']};" : '';
             $location = Debugger::$showLocation ? "<br>" . Helpers::editorLink($item['file'], $item['line']) : false;
         }
         $tiMethod = $trace[$index + 1];
         $dumpTitle = isset($tiMethod['class']) ? $tiMethod['class'] . $tiMethod['type'] . $tiMethod['function'] . '(); ' : $tiMethod['function'] . $title;
         $dumpObject = self::$dumpObject && isset($tiMethod['object']) ? Dumper::toHtml($tiMethod['object']) : '';
         $dump = (isset($dumpParams) ? "<b>{$dumpParams}</b> " : '') . (isset($location) ? $location : '') . $dumpObject;
         if (self::$traceMode) {
             for ($i = 0; $i <= $index; $i++) {
                 array_shift($trace);
             }
             $dump .= "<br/>" . self::showTraceSimple($trace);
         }
         $dump .= Dumper::toHtml($var);
         self::$dumps = array('title' => $dumpTitle, 'dump' => $dump);
         self::addToDumpPanel($dump, $dumpTitle);
     }
 }
 /**
  * e.g. SQL explain
  *
  * @return NULL|Html|string
  */
 public function getInfo()
 {
     $info = $this->response;
     unset($info['hits']['hits']);
     $html = Dumper::toHtml($info, [Dumper::COLLAPSE => TRUE, Dumper::TRUNCATE => 50]);
     return Html::el()->setHtml($html);
 }
示例#4
0
 private function renderHtml()
 {
     $res = '<style>code, pre {white-space:nowrap} a {text-decoration:none} pre {color:gray;display:inline} big {color:red}</style><code>';
     foreach ($this->list as $item) {
         $res .= Helpers::editorLink($item[0], $item[1]) . ' ' . str_replace(self::BOM, '<big>BOM</big>', Dumper::toHtml($item[2])) . "<br>\n";
     }
     return $res . '</code>';
 }
示例#5
0
 /**
  * @internal
  * @param \Exception|NULL $e
  * @return string[]|NULL
  */
 public static function render(\Exception $e = NULL)
 {
     if (!$e instanceof \Nella\Tracy\DebugInfoException) {
         return NULL;
         // skip
     }
     return ['tab' => 'Exception Debug Info', 'panel' => \Tracy\Dumper::toHtml($e->__debugInfo())];
 }
 /**
  * @return Html|string
  */
 public function getResult()
 {
     $data = iterator_to_array($this->result);
     foreach ($data as &$row) {
         $row = $this->rowToArray($row);
     }
     $html = Dumper::toHtml($data, [Dumper::COLLAPSE => TRUE]);
     return Html::el()->setHtml($html);
 }
 protected function doDump($data)
 {
     if (!class_exists('\\Tracy\\Dumper')) {
         return '';
     }
     ob_start();
     Dumper::dump($data, $this->options);
     return ob_get_clean();
 }
示例#8
0
 /**
  * @param array
  * @return string
  */
 protected function processQuery(array $query)
 {
     $s = '';
     list($sql, $params, $time) = $query;
     $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
     $s .= '</td><td class="nette-Doctrine2Panel-sql">' . Helpers::dumpSql($sql);
     $s .= '</td><td>' . Dumper::toHtml($params) . '</tr>';
     return $s;
 }
示例#9
0
	public static function initializePanel(Nette\Application\Application $application)
	{
		Tracy\Debugger::getBlueScreen()->addPanel(function ($e) use ($application) {
			return $e ? NULL : array(
				'tab' => 'Nette Application',
				'panel' => '<h3>Requests</h3>' . Tracy\Dumper::toHtml($application->getRequests())
					. '<h3>Presenter</h3>' . Tracy\Dumper::toHtml($application->getPresenter()),
			);
		});
	}
示例#10
0
 /**
  * Renders HTML code for custom panel.
  * @return string
  */
 function getPanel()
 {
     if (!$this->messages) {
         return NULL;
     }
     ob_start();
     $esc = callback('Nette\\Templating\\Helpers::escapeHtml');
     $click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
         return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
     } : callback('\\Tracy\\Helpers::clickableDump');
     require __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
示例#11
0
 private function renderHtml()
 {
     $res = '<style>code, pre {white-space:nowrap} a {text-decoration:none} pre {color:gray;display:inline} big {color:red}</style><code>';
     foreach ($this->list as $item) {
         $stack = array();
         foreach (array_slice($item[3], 1) as $t) {
             $t += array('class' => '', 'type' => '', 'function' => '');
             $stack[] = "{$t['class']}{$t['type']}{$t['function']}()" . (isset($t['file'], $t['line']) ? ' in ' . basename($t['file']) . ":{$t['line']}" : '');
         }
         $res .= Helpers::editorLink($item[0], $item[1]) . ' ' . '<span title="' . htmlspecialchars(implode("\n", $stack), ENT_IGNORE | ENT_QUOTES, 'UTF-8') . '">' . str_replace(self::BOM, '<big>BOM</big>', Dumper::toHtml($item[2])) . "</span><br>\n";
     }
     return $res . '</code>';
 }
示例#12
0
 /**
  * Renders HTML code for custom panel.
  * @return string
  */
 public function getPanel()
 {
     if (!$this->resources) {
         return null;
     }
     $esc = \Nette\Utils\Callback::closure('Latte\\Runtime\\Filters::escapeHtml');
     $click = function ($o, $c = false) {
         return \Tracy\Dumper::toHtml($o, ['collapse' => $c]);
     };
     ob_start();
     include __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
示例#13
0
 /**
  * @return string
  */
 public function getPanel()
 {
     if (empty($this->evaluatedFeatures)) {
         return NULL;
     }
     $evaluatedFeatures = $this->evaluatedFeatures;
     $click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = TRUE, $d = 4) {
         return \Tracy\Dumper::toHtml($o, array('collapse' => $c, 'depth' => $d));
     } : callback('\\Tracy\\Helpers::clickableDump');
     ob_start();
     require __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
示例#14
0
文件: Logger.php 项目: enumag/tracy
 /**
  * @return string
  */
 protected function formatMessage($message)
 {
     if ($message instanceof \Exception) {
         while ($message) {
             $tmp[] = ($message instanceof \ErrorException ? 'Fatal error: ' . $message->getMessage() : get_class($message) . ': ' . $message->getMessage()) . ' in ' . $message->getFile() . ':' . $message->getLine();
             $message = $message->getPrevious();
         }
         $message = implode($tmp, "\ncaused by ");
     } elseif (!is_string($message)) {
         $message = Dumper::toText($message);
     }
     return trim($message);
 }
示例#15
0
文件: Panel.php 项目: kdyby/google
 /**
  * @return string
  */
 public function getPanel()
 {
     if (!$this->calls) {
         return NULL;
     }
     ob_start();
     $esc = array('Nette\\Templating\\Helpers', 'escapeHtml');
     $click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
         return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
     } : array('\\Tracy\\Helpers', 'clickableDump');
     $totalTime = $this->totalTime ? sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : 'none';
     require __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
示例#16
0
文件: Panel.php 项目: noikiy/Curl
 /**
  * @param \Kdyby\Curl\Response $response
  *
  * @return string
  */
 public static function allResponses($response)
 {
     if (!$response instanceof Curl\Response) {
         return NULL;
     }
     $click = function ($o, $c = TRUE) {
         return Dumper::toHtml($o, array('collapse' => $c));
     };
     $responses = array($click($response, TRUE));
     while ($response = $response->getPrevious()) {
         $responses[] = $click($response, TRUE);
     }
     return implode('', $responses);
 }
示例#17
0
 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>';
 }
示例#18
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $printMapping = $output->getVerbosity() > $output::VERBOSITY_NORMAL;
     $metadataFactory = $this->searchManager->getMetadataFactory();
     /** @var ClassMetadata $class */
     foreach ($metadataFactory->getAllMetadata() as $class) {
         $output->writeln(sprintf('Entity <info>%s</info> is searchable', $class->getName()));
         if (!$printMapping) {
             continue;
         }
         $meta = (array) $class;
         unset($meta['reflFields'], $meta['reflClass']);
         $output->writeln(Dumper::toTerminal($meta));
     }
 }
示例#19
0
文件: Panel.php 项目: runt18/Github-1
 /**
  * @return string
  */
 public function getPanel()
 {
     if (!$this->calls) {
         return NULL;
     }
     ob_start();
     $esc = function ($s) {
         return htmlSpecialChars($s, ENT_QUOTES, 'UTF-8');
     };
     $click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
         return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
     } : Callback::closure('\\Tracy\\Helpers::clickableDump');
     $totalTime = $this->totalTime ? sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : 'none';
     require __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
示例#20
0
文件: Panel.php 项目: kdyby/facebook
 /**
  * @return string
  */
 public function getPanel()
 {
     if (!$this->calls) {
         return NULL;
     }
     ob_start();
     if (class_exists('Latte\\Runtime\\Filters')) {
         $esc = Nette\Utils\Callback::closure('Latte\\Runtime\\Filters::escapeHtml');
     } else {
         $esc = 'Nette\\Templating\\Helpers::escapeHtml';
     }
     $click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
         return \Tracy\Dumper::toHtml($o, array('collapse' => $c));
     } : '\\Tracy\\Helpers::clickableDump';
     $totalTime = $this->totalTime ? sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : 'none';
     require __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
示例#21
0
 /**
  * Returns syntax highlighted source code.
  * @param  string
  * @param  int
  * @param  int
  * @return string
  */
 public static function highlightPhp($source, $line, $lines = 15, $vars = array())
 {
     if (function_exists('ini_set')) {
         ini_set('highlight.comment', '#998; font-style: italic');
         ini_set('highlight.default', '#000');
         ini_set('highlight.html', '#06B');
         ini_set('highlight.keyword', '#D24; font-weight: bold');
         ini_set('highlight.string', '#080');
     }
     $source = str_replace(array("\r\n", "\r"), "\n", $source);
     $source = explode("\n", highlight_string($source, TRUE));
     $out = $source[0];
     // <code><span color=highlight.html>
     $source = str_replace('<br />', "\n", $source[1]);
     $out .= static::highlightLine($source, $line, $lines);
     $out = preg_replace_callback('#">\\$(\\w+)(&nbsp;)?</span>#', function ($m) use($vars) {
         return isset($vars[$m[1]]) ? '" title="' . str_replace('"', '&quot;', strip_tags(Dumper::toHtml($vars[$m[1]]))) . $m[0] : $m[0];
     }, $out);
     return "<pre class='php'><div>{$out}</div></pre>";
 }
示例#22
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int
  * @throws \Exception
  */
 public function run(InputInterface $input = NULL, OutputInterface $output = NULL)
 {
     $input = $input ?: new ArgvInput();
     $output = $output ?: new ConsoleOutput();
     if ($input->hasParameterOption('--debug-mode')) {
         if ($input->hasParameterOption(['--debug-mode=no', '--debug-mode=off', '--debug-mode=false', '--debug-mode=0'])) {
             if ($this->serviceLocator->parameters['debugMode']) {
                 $this->renderException(new InvalidApplicationModeException("The app is running in debug mode. You have to use Kdyby\\Console\\DI\\BootstrapHelper in app/bootstrap.php, " . "Kdyby\\Console cannot switch already running app to production mode . "), $output);
                 return self::INVALID_APP_MODE_EXIT_CODE;
             }
         } else {
             if (!$this->serviceLocator->parameters['debugMode']) {
                 $this->renderException(new InvalidApplicationModeException("The app is running in production mode. You have to use Kdyby\\Console\\DI\\BootstrapHelper in app/bootstrap.php, " . "Kdyby\\Console cannot switch already running app to debug mode."), $output);
                 return self::INVALID_APP_MODE_EXIT_CODE;
             }
         }
     }
     if (class_exists('Tracy\\Dumper') && $input->hasParameterOption('--no-ansi')) {
         Dumper::$terminalColors = FALSE;
     }
     try {
         return parent::run($input, $output);
     } catch (UnknownCommandException $e) {
         $this->renderException($e->getPrevious(), $output);
         list($message) = explode("\n", $e->getMessage());
         Debugger::log($message, Debugger::ERROR);
         return self::INPUT_ERROR_EXIT_CODE;
     } catch (\Exception $e) {
         if (in_array(get_class($e), self::$invalidArgumentExceptions, TRUE) && preg_match('/^(The "-?-?.+" (option|argument) (does not (exist|accept a value)|requires a value)|(Not enough|Too many) arguments.*)\\.$/', $e->getMessage()) === 1) {
             $this->renderException($e, $output);
             Debugger::log($e->getMessage(), Debugger::ERROR);
             return self::INPUT_ERROR_EXIT_CODE;
         } elseif ($app = $this->serviceLocator->getByType('Nette\\Application\\Application', FALSE)) {
             /** @var Nette\Application\Application $app */
             $app->onError($app, $e);
         } else {
             $this->handleException($e, $output);
         }
         return max(min((int) $e->getCode(), 254), 1);
     }
 }
示例#23
0
文件: Panel.php 项目: kdyby/rabbitmq
 /**
  * @return string
  */
 public function getPanel()
 {
     $isRunning = function ($type, $name) {
         if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
             return FALSE;
             // sry, I don't know how to do this
         }
         $command = sprintf('ps aux |grep %s |grep %s', $type === 'consumer' ? 'rabbitmq:consumer' : 'rabbitmq:rpc-server', escapeshellarg($name));
         if (!@exec($command, $output)) {
             return FALSE;
         }
         $instances = 0;
         foreach ($output as $line) {
             if (stripos($line, '|grep') === FALSE) {
                 $instances += 1;
             }
         }
         return $instances;
     };
     $workers = [];
     $runningWorkers = $configuredWorkers = 0;
     foreach ($this->serviceMap as $type => $services) {
         foreach ($services as $name => $serviceId) {
             $workers[$key = $type . '/' . $name] = $isRunning($type, $name);
             $runningWorkers += (int) $workers[$key];
             $configuredWorkers++;
         }
     }
     ob_start();
     $esc = class_exists('Nette\\Templating\\Helpers') ? ['Nette\\Templating\\Helpers', 'escapeHtml'] : ['Latte\\Runtime\\Filters', 'escapeHtml'];
     $click = class_exists('\\Tracy\\Dumper') ? function ($o, $c = FALSE) {
         return \Tracy\Dumper::toHtml($o, ['collapse' => $c]);
     } : ['Tracy\\Helpers', 'clickableDump'];
     require __DIR__ . '/panel.phtml';
     return ob_get_clean();
 }
示例#24
0
 public static function textDump($var)
 {
     trigger_error(__METHOD__ . '() is deprecated; use Tracy\\Dumper::toText() instead.', E_USER_DEPRECATED);
     return Tracy\Dumper::toText($var);
 }
示例#25
0
 /**
  * (HTML) content of panel based on object 
  * 
  * @author Martin Hlaváč
  * @link http://www.ktstudio.cz/
  * 
  * @param mixed $object
  * @param string $title
  * @return string
  */
 public function getObjectPanel($object, $title = null)
 {
     $output = null;
     if (self::issetAndNotEmpty($title)) {
         $output .= "<h1>{$title}</h1>";
     }
     $output .= "<div class=\"nette-inner\">";
     $output .= Dumper::toHtml($object, array(Dumper::COLLAPSE => false));
     $output .= "</div>";
     return $output;
 }
示例#26
0
 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;
 }
示例#27
0
 /**
  * Dump implementation for JSON.
  * @param  mixed  variable to dump
  * @param  int    current recursion level
  * @return string
  */
 private function jsonDump(&$var, $level = 0)
 {
     if (is_bool($var) || is_null($var) || is_int($var) || is_float($var)) {
         return $var;
     } elseif (is_string($var)) {
         return Dumper::encodeString($var, $this->maxLength);
     } elseif (is_array($var)) {
         static $marker;
         if ($marker === NULL) {
             $marker = uniqid("", TRUE);
         }
         if (isset($var[$marker])) {
             return "…RECURSION…";
         } elseif ($level < $this->maxDepth || !$this->maxDepth) {
             $var[$marker] = TRUE;
             $res = array();
             foreach ($var as $k => &$v) {
                 if ($k !== $marker) {
                     $res[$this->jsonDump($k)] = $this->jsonDump($v, $level + 1);
                 }
             }
             unset($var[$marker]);
             return $res;
         } else {
             return " … ";
         }
     } elseif (is_object($var)) {
         $arr = (array) $var;
         static $list = array();
         if (in_array($var, $list, TRUE)) {
             return "…RECURSION…";
         } elseif ($level < $this->maxDepth || !$this->maxDepth) {
             $list[] = $var;
             $res = array("" => '(object) ' . get_class($var));
             foreach ($arr as $k => &$v) {
                 if ($k[0] === "") {
                     $k = substr($k, strrpos($k, "") + 1);
                 }
                 $res[$this->jsonDump($k)] = $this->jsonDump($v, $level + 1);
             }
             array_pop($list);
             return $res;
         } else {
             return " … ";
         }
     } elseif (is_resource($var)) {
         return 'resource ' . get_resource_type($var);
     } else {
         return 'unknown type';
     }
 }
示例#28
0
 /**
  * Dumps information about a variable in Tracy Debug Bar.
  * @tracySkipLocation
  * @param  mixed  variable to dump
  * @param  string optional title
  * @param  array  dumper options
  * @return mixed  variable itself
  */
 public static function barDump($var, $title = NULL, array $options = NULL)
 {
     if (!self::$productionMode) {
         static $panel;
         if (!$panel) {
             self::getBar()->addPanel($panel = new DefaultBarPanel('dumps'));
         }
         $panel->data[] = ['title' => $title, 'dump' => Dumper::toHtml($var, (array) $options + [Dumper::DEPTH => self::$maxDepth, Dumper::TRUNCATE => self::$maxLen, Dumper::LOCATION => self::$showLocation])];
     }
     return $var;
 }
示例#29
0
$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>
示例#30
0
 /**
  * Renders HTML code for custom panel.
  * @return string
  */
 function getPanel()
 {
     ob_start();
     echo Dumper::toHtml($this->appRequest);
     return ob_get_clean();
 }