/** * Processing of Upload Photos Form * * @Privilege('generate') * * @param Form $form */ public function uploadPhotosFormSucceded(Form $form) { $values = $form->getValues(); $event = $this->loadItem($values['id']); $calendar = $event->ref('calendar'); $year = $calendar->yearpart === 'podzim' ? $calendar->year : $calendar->year - 1; $date = substr($event->datestart, 0, 4) . substr($event->datestart, 5, 2) . substr($event->datestart, 8, 2); // check if the year dir exist. if not, create one $params = $this->context->parameters; $dirYear = $params['wwwDir'] . $params['chroniclePhotosStorage'] . '/' . $year . ($year + 1) . '/'; // check if the event dir exists. if not, create one $dir = $dirYear . $date . '/'; if (!file_exists($dir)) { mkdir($dir, 0777, TRUE); } \Tracy\Debugger::barDump($dir); // start uploading files $counter = 0; foreach ($values['upload'] as $file) { if ($file->isOK()) { if ($file->isImage()) { do { $counter += 1; //increment counter until you hit empty space for file $filePath = $dir . \Nette\Utils\Strings::padLeft($counter, 4, '0') . '.jpg'; } while (file_exists($filePath)); $image = $file->toImage(); $image->save($filePath, 85, \Nette\Image::JPEG); $this->database->table('chronicle_photos')->insert(['event_id' => $values['id'], 'order' => $counter]); $this->flashMessage("Soubor " . $file->getName() . " byl úspěšně nahrán!"); } else { $form->addError('Soubor' . $file->getName() . ' nebyl rozpoznán jako fotka.'); } } else { $form->addError('Nepodařilo se nahrát soubor:' . $file->getName()); } } //change event visibility if (!array_key_exists('showchronicle', $values)) { //user did not have the sufficient permission $showchronicle = FALSE; } else { $showchronicle = $values['showchronicle'] ? TRUE : FALSE; } $this->events->showChronicle($values['id'], $showchronicle); if (!$form->hasErrors()) { $this->redirect('default'); } }
/** * Bar dump; die; */ function bdd() { foreach (func_get_args() as $var) { Debugger::barDump($var); } die; }
/** * Tracy\Debugger::barDump() shortcut. */ function barDump($var) { foreach (func_get_args() as $arg) { Debugger::barDump($arg); } return $var; }
protected function doDump($data) { if (!class_exists('\\Tracy\\Debugger')) { return; } Debugger::barDump($data, null, $this->options); }
public function renderDefault() { $this->template->anyVariable = 'any value'; // $dao = $this->articles; $this->template->articles = $this->articles->getArticles()->findAll(); $posts = $this->EntityManager->getRepository(Posts::getClassName()); $this->template->posts = $posts->findAll(); $this->template->myparametr = $this->context->parameters['first_parametr']; // $this->template->test = $this->doSomeRefactoring('Hello world from blog'); // $post = new Posts(); // $post->title = 'New title'; // $post->text = 'New text New textNew text'; // $post->created_at = new \Nette\Utils\DateTime; // // // $this->EntityManager->persist($post); // $this->EntityManager->flush(); // $dao = $this->EntityManager->getRepository(Posts::getClassName()); // $dao->setTitle('test'); // $dao->__call('set', ['title' => 'my title']); // dump($dao->__isset('title')); // $dao->__set('title', 'test'); try { $this->checkNum(2); \Tracy\Debugger::barDump('If you see this, the number is 1 or below'); } catch (Nette\Application\BadRequestException $e) { Debugger::log('Message: ' . $e->getMessage()); var_dump($e->getMessage()); } // finally { // \Tracy\Debugger::barDump('Got here Finally'); // } }
/** * Tracy\Debugger::barDump() shortcut. * @tracySkipLocation */ function barDump($var, $title = '') { $backtrace = debug_backtrace(); $source = isset($backtrace[1]['class']) ? $backtrace[1]['class'] : basename($backtrace[0]['file']); $line = $backtrace[0]['line']; $title .= empty($title) ? '' : ' – '; return Debugger::barDump($var, $title . $source . ' (' . $line . ')'); }
/** * Invoke all cron methods */ private function invoke(array $methods) { foreach ($methods as $method) { Debugger::barDump($method->annotations, $method->name); $instance = $this->context->createInstance($method->class); callback($instance, $method->name)->invokeArgs([$this->context, $this->getParameters()]); } }
function dd($var, $title = '') { $backtrace = debug_backtrace(null); // Ready for PHP 5.4 $source = isset($backtrace[1]['class']) ? $backtrace[1]['class'] : basename($backtrace[0]['file']); $line = $backtrace[0]['line']; if ($title !== '') { $title .= ' – '; } return \Tracy\Debugger::barDump($var, $title . $source . ' (' . $line . ')'); }
public function checkAndCreateRoot() { $uid = $this->user->id; $rootFolderName = '/' . $uid; $rootFolder = $this->folder->findOneBy(array('user_id' => $uid, 'name' => $rootFolderName)); if (!$rootFolder) { $defaultQuota = $this->getDefaultQuota($this->user); \Tracy\Debugger::barDump('Creating default folder ' . $rootFolderName . ' with quota ' . $defaultQuota); $this->createFolder($rootFolderName, $defaultQuota, 'Základní uživatelská složka.'); } }
/** * @return array JSON modules and data definition */ public function getModules() { $this->resolvedConfig = []; $this->resolvedModules = []; foreach ($this->useModules as $moduleName) { $this->resolveModuleConfig($moduleName); } // so that dependendencies are required via js container with settings instead of pure requirejs definition // array is reversed to put dependents after their dependencies $this->resolvedConfig = array_reverse($this->resolvedConfig); if (class_exists('Tracy\\Debugger')) { Debugger::barDump($this->resolvedConfig, __METHOD__); } return $this->resolvedConfig; }
private function httpGet($action, $parameters = array()) { \Tracy\Debugger::barDump('SC - ' . $action . ' ' . implode(', ', $parameters)); $url = $this->storageServerURL . '/' . $action; if (!empty($parameters)) { $url = $url . '?' . http_build_query($parameters); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); $data = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $data; }
public function signInFormSuccess(\Nette\Application\UI\Form $form) { $values = $form->getValues(); \Tracy\Debugger::barDump($form); if ($values->remember) { $this->getUser()->setExpiration('+ 14 days', FALSE); } else { $this->getUser()->setExpiration('+ 20 minutes', TRUE); } try { $this->getUser()->login($values->username, $values->password); } catch (\Nette\Security\AuthenticationException $e) { $form->addError($e->getMessage()); return; } $this->redirect('Homepage:'); }
public function process(\Nette\Forms\Form $form) { if ($form->isSuccess()) { /** @var Thumbnailer */ $thumbator = $this->context->thumbator; $thumb1 = new Thumb(100, 200, './'); $thumb2 = new Thumb(400, 500, './', Thumb::FILENAME_FORMAT_ORIGINAL); $thumb3 = new Thumb(200, 100, './', Thumb::FILENAME_FORMAT_DIMENSION); $thumb4 = new Thumb(40, 50, './', Thumb::FILENAME_FORMAT_ORIGINAL | Thumb::FILENAME_FORMAT_DIMENSION); $thumb5 = new Thumb(300, 800, './', Thumb::FILENAME_FORMAT_VALUE); $thumb5->setFilename('felix the caT!!'); $thumbator->addThumb($thumb1); $thumbator->addThumb($thumb2); $thumbator->addThumb($thumb3); $thumbator->addThumb($thumb4); $thumbator->addThumb($thumb5); // Success handler $thumbator->onSuccess[] = function ($t) { Debugger::barDump('Sucess handler'); }; $thumbator->process($form->values->picture); Debugger::barDump($form->values); } }
public function render(Form $form, $mode = NULL, $control = NULL) { \Tracy\Debugger::barDump(func_get_args()); if ($this->form !== $form) { $this->form = $form; } if ($mode === 'pair') { if (is_string($control)) { $control = $form[$control]; } return $this->renderPair($control); } elseif ($mode === 'container') { return $this->renderControls($control); } elseif ($mode === 'errors') { return $this->renderAllErrors($form); } else { $errors = ''; if ($mode === NULL) { $errors = $this->renderAllErrors($form); $form->cleanErrors(); } return $errors . parent::render($form, $mode); } }
<!DOCTYPE html><link rel="stylesheet" href="assets/style.css"> <style> html { background: url(assets/arrow.png) no-repeat bottom right; height: 100%; } </style> <h1>Tracy Debug Bar demo</h1> <p>You can dump variables to bar in rightmost bottom egde.</p> <?php require __DIR__ . '/../src/tracy.php'; use Tracy\Debugger; Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/log'); $arr = array(10, 20.2, TRUE, NULL, 'hello', (object) NULL, array()); Debugger::barDump(get_defined_vars()); Debugger::barDump($arr, 'The Array'); Debugger::barDump('<a href="#">test</a>', 'String');
private function registerGlobalVariables() { Debugger::barDump('Lognuty: ' . ($this->getUser()->isLoggedIn() ? 'true' . ', id: ' . $this->getUser()->getId() : 'false')); $this->isLoggedIn = $this->getUser()->isLoggedIn(); }
public function success(EntityForm $form, $values) { Debugger::barDump($form->getEntity()); }
public function renderReview($form) { \Tracy\Debugger::barDump($form); \Tracy\Debugger::barDump($this->units); $this->template->data = $form->getValues(); if ($this->wdata->occupied) { $destination = $this->villageService->getVillage($this->wdata->id); } else { $destination = FALSE; } $this->template->destination = $destination; $this->template->wdata = $this->wdata; $this->template->setFile(__DIR__ . '/ReviewUnits.latte'); }
/** * @param $data * @param null $title * @param array $options */ function d($data, $title = null, array $options = null) { Debugger::barDump($data, $title, $options); }
/** * @param App\GameModule\DTO\Building $building * @param App\GameModule\DTO\Village $village * @return bool */ public function isThereEnoughResources($building, $village) { if ($building->getWood() < $village->getActualWood() && $building->getClay() < $village->getActualClay() && $building->getIron() < $village->getActualIron() && $building->getCrop() < $village->getActualCrop()) { return TRUE; } $woodNeeded = $building->getWood() - $village->getActualWood(); \Tracy\Debugger::barDump($village); if ($woodNeeded > 0) { $time = round($woodNeeded / ($village->getProductionWood() / 3600)); } else { $time = 0; } $clayNeeded = $building->getClay() - $village->getActualClay(); if ($clayNeeded > 0) { $timeClay = round($clayNeeded / ($village->getProductionClay() / 3600)); if ($timeClay > $time) { $time = $timeClay; } } $ironNeeded = $building->getIron() - $village->getActualIron(); if ($ironNeeded > 0) { $timeIron = round($ironNeeded / ($village->getProductionIron() / 3600)); if ($timeIron > $time) { $time = $timeIron; } } $cropNeeded = $building->getCrop() - $village->getProductionCrop(); if ($cropNeeded > 0) { $timeCrop = round($cropNeeded / ($village->getProductionCrop() / 3600)); if ($timeCrop > $time) { $time = $timeCrop; } } return time() + $time; }
/** * Вывод содержимого переменной в отладочную панель * * @param $var * @param null $title * @param array $options * * @return mixed|void */ public static function dumpBar($var, $title = null, array $options = null) { parent::$maxDepth = 15; parent::barDump($var, $title, $options); }
/** * */ public function renderDefault() { \Tracy\Debugger::barDump(__DIR__, 'aaa dir'); }
public function actionZpracujMiniatury($photoId, $sizeCat, $filename, $fileextension) { if (!$this->user->isInRole('admin')) { $this->flashMessage('Pro přístup do sekce "nástroje" musíte být přihlášen jako uživatel s administrátorskými právy.', 'fr'); $this->redirect('Sign:in'); } $resizeDimension = 1200; if ($sizeCat == 'l') { $resizeDimension = 1200; } elseif ($sizeCat == 'm') { $resizeDimension = 800; } elseif ($sizeCat == 's') { $resizeDimension = 200; } $imagesDir = __DIR__ . '/../../www/images/gallery/all/'; $currentSourceFile = $imagesDir . $filename; if ($sizeCat == 'l') { $currentSourceFile = $imagesDir . $filename; } elseif ($sizeCat == 'm') { $currentSourceFile = $imagesDir . 'thumbs/l/' . $filename; } elseif ($sizeCat == 's') { $currentSourceFile = $imagesDir . 'thumbs/m/' . $filename; } /*\Tracy\Debugger::barDump('for size:' . $sizeCat . ', resize source:' . $currentSourceFile);*/ $image = Image::fromFile($currentSourceFile); if ($sizeCat == 's') { $image->resize($resizeDimension, $resizeDimension, Image::SHRINK_ONLY | Image::FILL); } else { $image->resize($resizeDimension, $resizeDimension, Image::SHRINK_ONLY); } /*$image->sharpen();*/ $partUrlResizedFile = 'thumbs/' . $sizeCat . '/' . $filename; $resizedFile = $imagesDir . $partUrlResizedFile; if ($fileextension === 'jpg') { $image->save($resizedFile, 80, Image::JPEG); \Tracy\Debugger::barDump('jpg-compresion:' . $resizedFile); } else { $image->save($resizedFile); \Tracy\Debugger::barDump('other compresions:' . $resizedFile); } list($width, $height, $type, $html_attr) = getimagesize($resizedFile); $size = filesize($resizedFile); if ($size > 0 && $width > 0 && $height > 0) { $updating = array($sizeCat . '_size' => $size, $sizeCat . '_width' => $width, $sizeCat . '_height' => $height, $sizeCat . '_html_attr' => $html_attr); $this->database->table('vsechny_fotky')->get($photoId)->update($updating); $this->flashMessage('Výroba miniatury <strong><a href="/images/gallery/all/' . $partUrlResizedFile . '" target="_blank">' . $partUrlResizedFile . '</a></strong> se zdařila.'); if ($sizeCat == 's') { $this->redirect('Nastroje:zpracujFotky'); } else { $targetSizeCat = $sizeCat == 'l' ? 'm' : 's'; $this->redirect('Nastroje:zpracujMiniatury', $photoId, $targetSizeCat, $filename, $fileextension); } } else { $this->flashMessage('Při výrobě miniatury<strong>' . $partUrlResizedFile . '</strong>došlo k chybě.', 'fr'); $this->redirect('Nastroje:'); } }
/** * @param $data * @param $type */ public function dump($data, $type) { Debugger::barDump($data, $type); }
/** * Send dumps to BarDump * - it needs to be sent on application shutdown to make grouping possible */ public static function toBarDump() { foreach (self::$dumps as $dump) { Debugger::barDump($dump); } }
<?php require __DIR__ . '/../src/tracy.php'; use Tracy\Debugger; session_start(); // session is required for this functionality Debugger::enable(Debugger::DETECT, __DIR__ . '/log'); if (empty($_GET['redirect'])) { Debugger::barDump('before redirect'); header('Location: ' . $_SERVER['REQUEST_URI'] . '?&redirect=1'); exit; } Debugger::barDump('after redirect'); ?> <!DOCTYPE html><html class=arrow><link rel="stylesheet" href="assets/style.css"> <h1>Tracy: redirect demo</h1>
/** * Shortcut for Debugger::barDump * * @author Jan Tvrdík * @param mixed * @param mixed $var , ... optional additional variable(s) to dump * @return mixed the first dumped variable */ function bd($var, $title = NULL) { return Debugger::barDump($var, $title); }
public function renderDefault() { $this->template->groupsOutput = $this->groupsOutput; Debugger::barDump('aaa'); }
/** * @param $data * @param null $title * @param array $options */ function d($data, $title = NULL, array $options = NULL) { Debugger::barDump($data, $title, $options); }
function bd($var, $title = NULL, array $options = NULL) { \Tracy\Debugger::barDump($var, $title, $options); }