Exemplo n.º 1
0
 /**
  * Nette\Diagnostics\Debugger::dump() shortcut.
  * @tracySkipLocation
  */
 function dump($var)
 {
     foreach (func_get_args() as $arg) {
         Debugger::dump($arg);
     }
     return $var;
 }
Exemplo n.º 2
0
/** Dump */
function d($var)
{
    if (func_num_args() > 1) {
        $var = func_get_args();
    }
    Debugger::dump($var);
    return func_get_arg(0);
}
Exemplo n.º 3
0
 public function actionDoctrineExample()
 {
     $articles = $this->em->getDao(Article::getClassName());
     $article = new Article();
     $article->title = "The Fight Club";
     $articles->save($article);
     $article = $articles->find(1);
     $this->template->article = $article->title;
     Debugger::dump($article);
     $this->redirect('Homepage:default');
 }
 public function renderDefault()
 {
     // Autorizoval uživatel naši aplikaci?
     if ($this->facebookConnect->isLoggedIn() === FALSE) {
         // Volitelně můžeme změnit URL, na kterou bude uživatel z Facebooku navrácen
         // Přijímá buď nette zápis odkazů nebo absolutní URL
         $this->facebookConnect->setRedirectUri("Homepage:default");
         // Přihlásíme ho přesměrováním na Login_URL
         $this->facebookConnect->login();
     } else {
         /* @var $user Illagrenan\Facebook\FacebookUser */
         $user = $this->facebookConnect->getFacebookUser();
         $this->template->user = $user;
         Debugger::dump($user);
     }
 }
Exemplo n.º 5
0
/**
 * Prints out debug message to standard output
 *
 * @param string message
 * @param mixed|null optional variable to dump along with message
 */
function debug($msg, $var = null)
{
    if (Debug::$productionMode == Debug::PRODUCTION) {
        return;
    }
    if (!isset($_SERVER['HTTP_USER_AGENT'])) {
        echo $msg . "\n";
        for ($i = 1; $i < func_num_args(); $i++) {
            Debug::dump(func_get_arg($i));
        }
    } else {
        if (!headers_sent()) {
            header('Content-type: text/html; charset=utf-8');
        }
        $msgEl = Html::el('div', array('class' => 'vBuilderDebugMsg'))->setText($msg);
        echo $msgEl->startTag();
        echo $msgEl[0];
        for ($i = 1; $i < func_num_args(); $i++) {
            Debug::dump(func_get_arg($i));
        }
        echo $msgEl->endTag();
    }
}
Exemplo n.º 6
0
$form['password']->addRule($form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3);

$form['password2']->addConditionOn($form['password'], $form::VALID)
	->addRule($form::FILLED, 'Reenter your password')
	->addRule($form::EQUAL, 'Passwords do not match', $form['password']);



// Step 2: Check if form was submitted?
if ($form->isSubmitted()) {

	// Step 2c: Check if form is valid
	if ($form->isValid()) {
		echo '<h2>Form was submitted and successfully validated</h2>';

		Debugger::dump($form->values);

		// this is the end, my friend :-)
		exit;
	}

} else {
	// not submitted, define default values
	$defaults = array(
		'name'    => 'John Doe',
		'userid'  => 231,
		'country' => 'CZ', // Czech Republic
	);

	$form->setDefaults($defaults);
}
Exemplo n.º 7
0
    public function getPanel()
    {
        $this->disabled = TRUE;
        $s = '';
        $h = 'htmlSpecialChars';
        foreach ($this->queries as $i => $query) {
            list($sql, $params, $time, $rows, $connection, $source) = $query;
            $explain = NULL;
            // EXPLAIN is called here to work SELECT FOUND_ROWS()
            if ($this->explain && preg_match('#\\s*SELECT\\s#iA', $sql)) {
                try {
                    $explain = $connection->queryArgs('EXPLAIN ' . $sql, $params)->fetchAll();
                } catch (\PDOException $e) {
                }
            }
            $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
            if ($explain) {
                static $counter;
                $counter++;
                $s .= "<br /><a href='#' class='nette-toggler' rel='#nette-DbConnectionPanel-row-{$counter}'>explain&nbsp;&#x25ba;</a>";
            }
            $s .= '</td><td class="nette-DbConnectionPanel-sql">' . Connection::highlightSql(Nette\Utils\Strings::truncate($sql, self::$maxLength));
            if ($explain) {
                $s .= "<table id='nette-DbConnectionPanel-row-{$counter}' class='nette-collapsed'><tr>";
                foreach ($explain[0] as $col => $foo) {
                    $s .= "<th>{$h($col)}</th>";
                }
                $s .= "</tr>";
                foreach ($explain as $row) {
                    $s .= "<tr>";
                    foreach ($row as $col) {
                        $s .= "<td>{$h($col)}</td>";
                    }
                    $s .= "</tr>";
                }
                $s .= "</table>";
            }
            if ($source) {
                $s .= Nette\Diagnostics\Helpers::editorLink($source[0], $source[1])->class('nette-DbConnectionPanel-source');
            }
            $s .= '</td><td>';
            foreach ($params as $param) {
                $s .= Debugger::dump($param, TRUE);
            }
            $s .= '</td><td>' . $rows . '</td></tr>';
        }
        return empty($this->queries) ? '' : '<style> #nette-debug td.nette-DbConnectionPanel-sql { background: white !important }
			#nette-debug .nette-DbConnectionPanel-source { color: #BBB !important }
			#nette-debug nette-DbConnectionPanel tr table { margin: 8px 0; max-height: 150px; overflow:auto } </style>
			<h1>Queries: ' . count($this->queries) . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . '</h1>
			<div class="nette-inner nette-DbConnectionPanel">
			<table>
				<tr><th>Time&nbsp;ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>' . $s . '
			</table>
			</div>';
    }
Exemplo n.º 8
0
        function getPanel()
        {
            $this->disabled = TRUE;
            $s = '';
            foreach ($this->queries as $i => $query) {
                list($sql, $params, $time, $rows, $connection, $source) = $query;
                $explain = NULL;
                if ($this->explain && preg_match('#\\s*\\(?\\s*SELECT\\s#iA', $sql)) {
                    try {
                        $cmd = is_string($this->explain) ? $this->explain : 'EXPLAIN';
                        $explain = $connection->queryArgs("{$cmd} {$sql}", $params)->fetchAll();
                    } catch (\PDOException $e) {
                    }
                }
                $s .= '<tr><td>' . sprintf('%0.3f', $time * 1000);
                if ($explain) {
                    static $counter;
                    $counter++;
                    $s .= "<br /><a href='#' class='nette-toggler' rel='#nette-DbConnectionPanel-row-{$counter}'>explain&nbsp;&#x25ba;</a>";
                }
                $s .= '</td><td class="nette-DbConnectionPanel-sql">' . Helpers::dumpSql(self::$maxLength ? Nette\Utils\Strings::truncate($sql, self::$maxLength) : $sql);
                if ($explain) {
                    $s .= "<table id='nette-DbConnectionPanel-row-{$counter}' class='nette-collapsed'><tr>";
                    foreach ($explain[0] as $col => $foo) {
                        $s .= '<th>' . htmlSpecialChars($col) . '</th>';
                    }
                    $s .= "</tr>";
                    foreach ($explain as $row) {
                        $s .= "<tr>";
                        foreach ($row as $col) {
                            $s .= '<td>' . htmlSpecialChars($col) . '</td>';
                        }
                        $s .= "</tr>";
                    }
                    $s .= "</table>";
                }
                if ($source) {
                    $s .= Nette\Diagnostics\Helpers::editorLink($source[0], $source[1])->class('nette-DbConnectionPanel-source');
                }
                $s .= '</td><td>';
                foreach ($params as $param) {
                    $s .= Debugger::dump($param, TRUE);
                }
                $s .= '</td><td>' . $rows . '</td></tr>';
            }
            return empty($this->queries) ? '' : '<style class="nette-debug"> #nette-debug td.nette-DbConnectionPanel-sql { background: white !important }
			#nette-debug .nette-DbConnectionPanel-source { color: #BBB !important } </style>
			<h1 title="' . htmlSpecialChars($connection->getDsn()) . '">Queries: ' . count($this->queries) . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . ', ' . htmlSpecialChars($this->name) . '</h1>
			<div class="nette-inner nette-DbConnectionPanel">
			<table>
				<tr><th>Time&nbsp;ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>' . $s . '
			</table>
			</div>';
        }
Exemplo n.º 9
0
/**
 * Shortcut for Debugger::dump & exit()
 *
 * @author   Jan Tvrdík
 * @param    mixed
 * @param    mixed $var, ...       optional additional variable(s) to dump
 * @return   void
 */
function de($var)
{
    foreach (func_get_args() as $var) {
        Debugger::dump($var);
    }
    exit;
}
Exemplo n.º 10
0
getTab(){return'<span title="Nette\\Database '.htmlSpecialChars($this->name).'">'.'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC" />'.count($this->queries).' queries'.($this->totalTime?' / '.sprintf('%0.1f',$this->totalTime*1000).'ms':'').'</span>';}function
getPanel(){$this->disabled=TRUE;$s='';$h='htmlSpecialChars';foreach($this->queries
as$i=>$query){list($sql,$params,$time,$rows,$connection,$source)=$query;$explain=NULL;if($this->explain&&preg_match('#\s*\(?\s*SELECT\s#iA',$sql)){try{$cmd=is_string($this->explain)?$this->explain:'EXPLAIN';$explain=$connection->queryArgs("$cmd $sql",$params)->fetchAll();}catch(\PDOException$e){}}$s.='<tr><td>'.sprintf('%0.3f',$time*1000);if($explain){static$counter;$counter++;$s.="<br /><a href='#' class='nette-toggler' rel='#nette-DbConnectionPanel-row-$counter'>explain&nbsp;&#x25ba;</a>";}$s.='</td><td class="nette-DbConnectionPanel-sql">'.Helpers::dumpSql(self::$maxLength?Nette\Utils\Strings::truncate($sql,self::$maxLength):$sql);if($explain){$s.="<table id='nette-DbConnectionPanel-row-$counter' class='nette-collapsed'><tr>";foreach($explain[0]as$col=>$foo){$s.="<th>{$h($col)}</th>";}$s.="</tr>";foreach($explain
as$row){$s.="<tr>";foreach($row
as$col){$s.="<td>{$h($col)}</td>";}$s.="</tr>";}$s.="</table>";}if($source){$s.=Nette\Diagnostics\Helpers::editorLink($source[0],$source[1])->class('nette-DbConnectionPanel-source');}$s.='</td><td>';foreach($params
as$param){$s.=Debugger::dump($param,TRUE);}$s.='</td><td>'.$rows.'</td></tr>';}return
empty($this->queries)?'':'<style> #nette-debug td.nette-DbConnectionPanel-sql { background: white !important }
			#nette-debug .nette-DbConnectionPanel-source { color: #BBB !important } </style>
			<h1>Queries: '.count($this->queries).($this->totalTime?', time: '.sprintf('%0.3f',$this->totalTime*1000).' ms':'').'</h1>
			<div class="nette-inner nette-DbConnectionPanel">
			<table>
				<tr><th>Time&nbsp;ms</th><th>SQL Statement</th><th>Params</th><th>Rows</th></tr>'.$s.'
			</table>
			</div>';}}}namespace Nette\Database\Drivers{use
Exemplo n.º 11
0
 /**
  * @param  mixed
  * @return string
  */
 private function dumpHtml($var)
 {
     if (class_exists('Tracy\\Dumper')) {
         return Tracy\Dumper::toHtml($var, [Tracy\Dumper::COLLAPSE => TRUE]);
     } elseif (class_exists('Nette\\Diagnostics\\Dumper')) {
         return Nette\Diagnostics\Dumper::toHtml($var, [Nette\Diagnostics\Dumper::COLLAPSE => TRUE]);
     } else {
         return Nette\Diagnostics\Debugger::dump($var, TRUE);
     }
 }
Exemplo n.º 12
0
 * @link      http://www.radekdostal.cz
 */
use Nette\Diagnostics\Debugger;
use Nette\Forms\Form;
require '../vendor/autoload.php';
Debugger::$strictMode = TRUE;
Debugger::enable();
Form::extensionMethod('addDateTimePicker', function (Form $_this, $name, $label, $cols = NULL, $maxLength = NULL) {
    return $_this[$name] = new RadekDostal\NetteComponents\DateTimePicker\DateTimePicker($label, $cols, $maxLength);
});
$form = new Form();
$form->addDateTimePicker('datetime', 'Date and time:', 16, 16)->setRequired();
$form->addSubmit('submit', 'Send');
if ($form->isSuccess()) {
    echo '<h2>Form was submitted and successfully validated</h2>';
    Debugger::dump($form->getValues());
    exit;
}
/*else
{
  $form->setDefaults(array(
    'datetime' => date('Y-m-d H:i')
  ));
}*/
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <meta charset="UTF-8">
  <meta name="author" content="Radek Dostál">
  <title>RadekDostal\NetteComponents\DateTimePicker\DateTimePicker example</title>
Exemplo n.º 13
0
function d()
{
    if (Debug::$productionMode) {
        return;
    }
    foreach (func_get_args() as $m) {
        if (!Debug::$consoleMode && ($m instanceof \DibiResult || $m instanceof \vBuilder\Orm\Fluent)) {
            if ($m instanceof \DibiResult) {
                dt($m->fetchAll());
            } else {
                $m->test();
                $data = array();
                foreach ($m->fetchAll() as $entity) {
                    $data[] = $entity->data->getAllData();
                }
                dt($data);
            }
        } else {
            Nette\Diagnostics\Debugger::dump($m);
        }
    }
}
Exemplo n.º 14
0
	/**
	 * Submit handler for DatePickerForm.
	 *
	 * @author   Jan Tvrdík
	 * @param    Form
	 * @return   void
	 */
	public function datePickerFormSubmitted(Form $form)
	{
		$this->template->data = Debugger::dump($form->values, TRUE);
	}
Exemplo n.º 15
0
	->setType('email')
	->setAttribute('autocomplete', 'off')
	->setAttribute('placeholder', 'Optional, but Recommended')
	->addCondition($form::FILLED) // conditional rule: if is email filled, ...
		->addRule($form::EMAIL, 'Incorrect email address'); // ... then check email

$form->addSubmit('submit', 'Send');



// Step 2: Check if form was submitted?
if ($form->isSubmitted() && $form->isValid()) {
	echo '<h2>Form was submitted and successfully validated</h2>';

	$values = $form->values;
	Debugger::dump($values);

	// this is the end, my friend :-)
	exit;
}



// Step 3: Render form
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">

	<title>Nette\Forms and HTML5 | Nette Framework</title>
Exemplo n.º 16
0
function d()
{
    foreach (func_get_args() as $var) {
        \Nette\Diagnostics\Debugger::dump($var);
    }
}