Ejemplo n.º 1
0
 function sendFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $helpdesk = $this->database->table("helpdesk")->get(1);
     $helpdesk_admin = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(1);
     $helpdesk_customer = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(2);
     $arr = array("subject" => $form->values->name, "email" => $form->values->email, "message" => $form->values->message, "ipaddress" => getenv('REMOTE_ADDR'), "helpdesk_id" => 1, 'date_created' => date("Y-m-d H:i"), 'session_id' => session_id());
     if ($this->presenter->user->isLoggedIn()) {
         $arr["users_id"] = $this->presenter->template->member->id;
     }
     if ($helpdesk->fill_phone > 0) {
         $arr["phone"] = $form->values->phone;
     }
     $this->database->table("helpdesk_messages")->insert($arr);
     $params = array('name' => $form->values->name, 'email' => $form->values->email, 'phone' => $form->values->phone, 'message' => $form->values->message, 'ipaddress' => getenv('REMOTE_ADDR'), 'time' => date("Y-m-d H:i"), 'settings' => $this->presenter->template->settings);
     $latte = new \Latte\Engine();
     $latte->setLoader(new Latte\Loaders\StringLoader());
     //$latte->setTempDirectory(__DIR__ . '/../temp');
     $email_admin = $latte->renderToString($helpdesk_admin->body, $params);
     $email_customer = (string) $latte->renderToString($helpdesk_customer->body, $params);
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->presenter->template->settings["contacts:email:hq"]);
     $mail->addTo($this->presenter->template->settings["contacts:email:hq"]);
     $mail->setHTMLBody($email_customer);
     $mailA = new \Nette\Mail\Message();
     $mailA->setFrom($this->presenter->template->settings["contacts:email:hq"]);
     $mailA->addTo($form->values->email);
     $mailA->setHTMLBody($email_admin);
     $mailer = new \Nette\Mail\SendmailMailer();
     $mailer->send($mail);
     $mailer->send($mailA);
     $this->presenter->flashMessage($this->presenter->translator->translate('messages.sign.thanksForMessage'), "error");
     $this->presenter->redirect(":Front:Contact:default");
 }
Ejemplo n.º 2
0
 public function render()
 {
     $template = $this->template;
     $template->setFile(__DIR__ . '/CalendarControl.latte');
     if ($this->presenter->getParameter('y')) {
         $template->year = $this->presenter->getParameter('y');
     } else {
         $template->year = date('Y');
     }
     if ($this->presenter->getParameter('m')) {
         $template->month = $this->presenter->getParameter('m');
     } else {
         $template->month = date('m');
     }
     $events = $this->database->table("events")->select("DAYOFMONTH(date_event) AS datestamp, MONTH(`date_event`) AS monthstamp, YEAR(`date_event`) AS yearstamp, pages.title")->having("monthstamp = ? AND yearstamp = ?", $template->month, $template->year)->order("date_event");
     foreach ($events as $event) {
         $eventDay[$event->datestamp] .= $event->title . ';';
     }
     $template->eventsDates = $eventDay;
     $template->prevMonth = date('m', mktime(0, 0, 0, $template->month - 1, 1, $template->year));
     $template->prevYear = date('Y', mktime(0, 0, 0, $template->month - 1, 1, $template->year));
     $template->nextMonth = date('m', mktime(0, 0, 0, $template->month + 1, 1, $template->year));
     $template->nextYear = date('Y', mktime(0, 0, 0, $template->month + 1, 1, $template->year));
     $dateChosen = $template->year . '-' . $template->month . '-01';
     $template->firstDayofMonth = date('N', strtotime(date($dateChosen)));
     $lastDay = date('Y-m-t', strtotime(date($dateChosen)));
     $template->lastDayofMonth = date('N', strtotime($lastDay));
     $template->daysInMonth = date('t', strtotime($lastDay));
     $template->nameMonth = $this->getMonthNameInCzech(date('n', strtotime($dateChosen)));
     $template->nameYear = date('Y', strtotime($dateChosen));
     $template->render();
 }
Ejemplo n.º 3
0
 /**
  * Performs an authentication.
  * @param array $credentials (string $username, string $password)
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $row = $this->database->table('user')->where('username', $username)->fetch();
     if (!$row) {
         throw new Security\AuthenticationException('Uživatel s tímto jménem neexistuje.', self::IDENTITY_NOT_FOUND);
     } elseif (!Security\Passwords::verify($password, $row->password)) {
         throw new Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL);
     } elseif (!$row->active) {
         throw new Security\AuthenticationException('Účet není aktivovaný.', self::NOT_APPROVED);
     } elseif (Security\Passwords::needsRehash($row->password)) {
         $row->update(array('password' => Security\Passwords::hash($password)));
     }
     $arr = $row->toArray();
     unset($arr['password']);
     $roles = $row->related('privilege')->fetch()->toArray();
     unset($roles['user_id']);
     //adds privileges
     array_walk($roles, function (&$value, $key) use(&$roles) {
         if ($value != NULL) {
             $value = $key . ' - ' . $value;
         }
     });
     return new Security\Identity($row->id, $roles, $arr);
 }
Ejemplo n.º 4
0
 /**
  * Page settings
  */
 function createComponentSetForm()
 {
     $pages = $this->database->table("pages")->get($this->presenter->getParameter("id"));
     $form = new \Nette\Forms\BootstrapPHForm();
     $form->setTranslator($this->presenter->translator);
     $form->getElementPrototype()->class = "form-horizontal";
     $form->getElementPrototype()->role = 'form';
     $form->getElementPrototype()->autocomplete = 'off';
     $l = $this->presenter->getParameter("l");
     $form->addHidden("id");
     $form->addHidden("l");
     $form->addHidden("slug_old");
     $form->addGroup("");
     $form->addCheckbox("public", "dictionary.main.PublishedForm");
     $form->addText("date_published", "Datum zveřejnění")->setAttribute("class", "datetimepicker");
     $form->addText("title", "dictionary.main.Title");
     $form->addText("slug", "dictionary.main.Slug");
     $form->addGroup("dictionary.main.MetaTags");
     $form->addTextArea("metadesc", "dictionary.main.MetaDesc")->setAttribute("class", "form-control");
     $form->addTextArea("metakeys", "dictionary.main.MetaKeys")->setAttribute("class", "form-control");
     if ($l == '') {
         $form->setDefaults(array("id" => $pages->id, "slug" => $pages->slug, "slug_old" => $pages->slug, "metadesc" => $pages->metadesc, "metakeys" => $pages->metakeys, "title" => $pages->title, "public" => $pages->public, "date_published" => $pages->date_published));
     } else {
         $form->setDefaults(array("id" => $pages->id, "l" => $l, "slug" => $pages->{'slug_' . $l}, "slug_old" => $pages->{'slug_' . $l}, "metadesc" => $pages->{'metadesc_' . $l}, "metakeys" => $pages->{'metakeys_' . $l}, "title" => $pages->{'title_' . $l}, "public" => $pages->public, "date_published" => $pages->date_published));
     }
     $form->onSuccess[] = $this->setFormSucceeded;
     $form->onValidate[] = $this->permissionValidated;
     $form->addSubmit("submit", "dictionary.main.Save")->setHtmlId('formxins');
     return $form;
 }
Ejemplo n.º 5
0
 function insertEventFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $date_start = \DateTime::createFromFormat('j. n. Y', $form->values->date_event);
     $date1 = $date_start->format('Y-m-d');
     $date_end = \DateTime::createFromFormat('j. n. Y', $form->values->date_event_end);
     $date2 = $date_end->format('Y-m-d');
     if ($form->values->date_event == '') {
         $dateEvent = null;
     } else {
         if ($form->values->allday) {
             $dateEvent = $date1 . ' 00:00:00';
         } else {
             $dateEvent = $date1 . ' ' . $form->values->hour_event . ':' . $form->values->minute_event;
         }
     }
     if ($form->values->date_event_end == '') {
         $dateEventEnd = null;
     } else {
         if ($form->values->allday) {
             $dateEventEnd = $date2 . ' 23:55:00';
         } else {
             $dateEventEnd = $date2 . ' ' . $form->values->hour_event_end . ':' . $form->values->minute_event_end;
         }
     }
     $this->database->table("events")->insert(array("date_event" => $dateEvent, "date_event_end" => $dateEventEnd, "all_day" => $form->values->allday, "price" => $form->values->price, "contacts_id" => $form->values->contact, "time_range" => $form->values->time_range, "capacity" => $form->values->capacity, "capacity_start" => $form->values->capacity_start, "pages_id" => $form->values->event_id));
     $this->redirect(this, array("id" => $form->values->event_id));
 }
Ejemplo n.º 6
0
 public function render($id)
 {
     $template = $this->template;
     $template->setFile(__DIR__ . '/ContactControl.latte');
     $contact = $this->database->table("contacts")->get($id);
     $template->contact = $contact;
     $template->render();
 }
Ejemplo n.º 7
0
 public function render()
 {
     $template = $this->template;
     $template->settings = $this->presenter->template->settings;
     $template->carousel = $this->database->table("carousel")->where(array("visible" => 1))->order("sorted");
     $template->setFile(__DIR__ . '/CarouselBoxControl.latte');
     $template->render();
 }
Ejemplo n.º 8
0
 public function render($id, $style = 'sidemenu')
 {
     $template = $this->template;
     $template->setFile(__DIR__ . '/SideMenuControl.latte');
     $template->id = $id;
     $template->style = $style;
     $template->categories = $this->database->table('categories')->where('parent_id', $id);
     $template->render();
 }
Ejemplo n.º 9
0
 public function render($layer = 'front')
 {
     $template = $this->template;
     $template->setFile(__DIR__ . '/ResetPassControl.latte');
     $template->addon = $this->database->table("addons");
     $template->layer = $layer;
     $template->member = $this->presenter->template->member;
     $template->render();
 }
Ejemplo n.º 10
0
 public function render($id, $style = 'navbar')
 {
     $template = $this->template;
     $template->appDir = APP_DIR;
     $template->setFile(__DIR__ . '/NavbarMenuControl.latte');
     $template->id = $id;
     $template->style = $style;
     $template->categories = $this->database->table('menu')->where('parent_id = ?  AND (NOT id = 136)', $id);
     $template->render();
 }
Ejemplo n.º 11
0
 public function render()
 {
     $template = $this->template;
     $template->id = $this->presenter->getParameter('id');
     $template->languages = $this->database->table("languages");
     $template->langSelected = $this->presenter->getParameter("l");
     $template->arr = $this->presenter->getParameters();
     $template->settings = $this->presenter->template->settings;
     $template->setFile(__DIR__ . '/LangSelectorControl.latte');
     $template->render();
 }
Ejemplo n.º 12
0
 function insertFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $langExists = $this->database->table("languages")->where("title = ? OR code = ?", $form->values->language, $form->values->code);
     if ($langExists->count() > 0) {
         $this->presenter->flashMessage("Název jazyka nebo kód již existuje", "error");
         $this->presenter->redirect(this);
     } else {
         $this->database->table("languages")->insert(array("title" => $form->values->language, "code" => $form->values->code));
         $this->presenter->redirect(this);
     }
 }
Ejemplo n.º 13
0
 function insertFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $doc = new \App\Model\Document($this->database);
     $doc->setType(5);
     $doc->createSlug("contact-" . $form->values->name);
     $doc->setTitle($form->values->name);
     $page = $doc->create($this->presenter->user->getId());
     // create new contact
     $this->database->table("contacts")->insert(array("categories_id" => 5, "pages_id" => $page, "users_id" => $this->presenter->user->getId(), "name" => $form->values->name, "street" => $form->values->street, "zip" => $form->values->zip, "city" => $form->values->city));
     $this->presenter->redirect(":Front:Profile:addresses");
 }
 function insertFormSucceeded(\Nette\Forms\BootstrapPHForm $form)
 {
     $doc = new \App\Model\Document($this->database);
     $doc->setType(5);
     $doc->createSlug("contact-" . $form->values->user);
     $doc->setTitle($form->values->title);
     $page = $doc->create($this->presenter->user->getId());
     \App\Model\IO::directoryMake(substr(APP_DIR, 0, -4) . '/www/media/' . $page);
     $arr = array("pages_id" => $page, "type" => 1, "name" => 'contact-' . $form->values->user, "users_id" => $form->values->user);
     $this->database->table("contacts")->insert($arr);
     $this->presenter->redirect(this, array("id" => $form->values->page));
 }
Ejemplo n.º 15
0
 function editFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $arr = array("sex" => $form->values->sex, "newsletter" => $form->values->newsletter, "state" => $form->values->state);
     if ($this->presenter->template->member->username) {
         $arr["users_roles_id"] = $form->values->role;
     }
     if ($this->presenter->template->settings['members:groups:enabled']) {
         $arr["categories_id"] = $form->values->group;
     }
     $this->database->table("users")->where(array("id" => $form->values->id))->update($arr);
     $this->presenter->redirect(this, array("" => $form->values->id));
 }
Ejemplo n.º 16
0
 function changePasswordFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $ppwd = $form->values->password1;
     $ppwd2 = $form->values->password2;
     $passwordEncrypted = \Nette\Security\Passwords::hash($ppwd);
     if (strcasecmp($ppwd, $ppwd2) != 0) {
         $this->presenter->flashMessage('Hesla se neshodují');
     }
     $this->database->table("users")->where(array("id" => $this->presenter->user->getId()))->update(array("password" => $passwordEncrypted));
     setcookie("calpwd", $passwordEncrypted, time() + time() + 60 * 60 * 24 * 30, "/");
     $this->presenter->redirect(this);
 }
Ejemplo n.º 17
0
 /**
  * Performs an authentication.
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $row = $this->database->table('users')->where('username', $username)->fetch();
     if (!$row) {
         throw new Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);
     }
     if ($row->password !== $this->calculateHash($password, $row->password)) {
         throw new Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);
     }
     unset($row->password);
     return new Security\Identity($row->id, $row->role, $row->toArray());
 }
 /**
  *
  * @param type $id
  * @param type $type Specifies type of category: store, media, blog, menu etc. Some categories have special needs
  */
 public function render($id, $type)
 {
     $template = $this->template;
     $template->type = $type;
     $getParams = $this->getParameters();
     unset($getParams["page"]);
     $template->args = $getParams;
     $template->setFile(__DIR__ . '/AdminCategoryPanelControl.latte');
     $template->id = $id;
     $template->idActive = $this->presenter->getParameter("id");
     $template->menu = $this->database->table('pages')->where(array('pages_types_id' => type, 'pages_id' => null));
     $template->render();
 }
Ejemplo n.º 19
0
 function changePortraitFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     // TODO peekay support for more types of images or image convertor
     $membersDb = $this->database->table("users")->where(array("id" => $this->presenter->user->getId()));
     if ($membersDb->count() > 0) {
         $uid = $membersDb->fetch()->id;
         if (file_exists(APP_DIR . '/images/profiles/portrait-' . $uid . '.jpg')) {
             \App\Model\IO::remove(APP_DIR . '/images/profiles/portrait-' . $uid . '.jpg');
             \App\Model\IO::upload(APP_DIR . '/images/profiles/', 'portrait-' . $uid . '.jpg');
         } else {
             \App\Model\IO::upload(APP_DIR . '/images/profiles/', 'portrait-' . $uid . '.jpg');
         }
     }
     $this->presenter->redirect(":Front:Profile:image");
 }
Ejemplo n.º 20
0
 function addSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $doc = new \App\Model\Document($this->database);
     $doc->setType(5);
     $doc->createSlug("contact-" . $form->values->email);
     $doc->setTitle($form->values->email);
     $page = $doc->create($this->presenter->user->getId());
     \App\Model\IO::directoryMake(substr(APP_DIR, 0, -4) . '/www/media/' . $page, 0755);
     $arr = array("users_id" => null, "pages_id" => $page, "type" => 0);
     $arr["email"] = $form->values->email;
     $arr["name"] = $form->values->email;
     $this->database->table("contacts")->insert($arr);
     $this->presenter->flashMessage("Byli jste přihlášení k odeběru newsletteru");
     $this->presenter->redirect(this);
 }
Ejemplo n.º 21
0
 function insertFormSucceeded(\Nette\Forms\BootstrapPHForm $form)
 {
     $doc = new \App\Model\Document($this->database);
     $doc->setType(5);
     $doc->createSlug("contact-" . $form->values->title);
     $doc->setTitle($form->values->title);
     $page = $doc->create($this->template->user->getId());
     \App\Model\IO::directoryMake(substr(APP_DIR, 0, -4) . '/www/media/' . $page, 0755);
     $arr = array("users_id" => null, "pages_id" => $page, "type" => $form->values->type);
     if ($form->values->type == 0) {
         $arr["name"] = $form->values->title;
     } else {
         $arr["company"] = $form->values->title;
     }
     $this->database->table("contacts")->insert($arr);
     $this->presenter->redirect(":Admin:Contacts:detail", array("id" => $page));
 }
Ejemplo n.º 22
0
 public function render($id = null, $style = 'sidemenu', $controlName = null)
 {
     $template = $this->template;
     if ($controlName == null) {
         $controlName = 'MenuControl';
     }
     if ($this->presenter->translator->getLocale() != $this->presenter->translator->getDefaultLocale()) {
         $template->langSuffix = '_' . $this->presenter->translator->getLocale();
         $template->langPrefix = '/' . $this->presenter->translator->getLocale();
     }
     $template->setFile(__DIR__ . '/' . $controlName . '.latte');
     $template->active = strtok($_SERVER["REQUEST_URI"], '?');
     $template->id = $id;
     $template->style = $style;
     $template->categories = $this->database->table('menu')->where('parent_id', $id)->order('sorted DESC');
     $template->render();
 }
Ejemplo n.º 23
0
 function uploadFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $fileDirectory = APP_DIR . '/media/' . $form->values->id;
     \App\Model\IO::directoryMake($fileDirectory, 0755);
     if (strlen($_FILES["the_file"]["tmp_name"]) > 1) {
         $imageExists = $this->database->table("media")->where(array('name' => $_FILES["the_file"]["name"], 'pages_id' => $form->values->id));
         $fileName = $fileDirectory . '/' . $_FILES["the_file"]["name"];
         \App\Model\IO::remove($fileName);
         copy($_FILES["the_file"]["tmp_name"], $fileName);
         chmod($fileName, 0644);
         if ($imageExists->count() == 0) {
             $this->database->table("media")->insert(array('name' => $_FILES["the_file"]["name"], 'pages_id' => $form->values->id, 'description' => $form->values->description, 'filesize' => filesize($fileDirectory . '/' . $_FILES["the_file"]["name"]), 'file_type' => 1, 'date_created' => date("Y-m-d H:i:s")));
         }
         // thumbnails
         $image = \Nette\Utils\Image::fromFile($fileName);
         $image->resize(400, 250, \Nette\Utils\Image::SHRINK_ONLY);
         $image->sharpen();
         $image->save(APP_DIR . '/media/' . $form->values->id . '/tn/' . $_FILES["the_file"]["name"]);
         chmod(APP_DIR . '/media/' . $form->values->id . '/tn/' . $_FILES["the_file"]["name"], 0644);
     }
     $this->redirect(this, array("id" => $form->values->id, "category" => $form->values->category));
 }
Ejemplo n.º 24
0
 function sendLoginFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $pwd = \Nette\Utils\Random::generate(10);
     $pwdEncrypted = \Nette\Security\Passwords::hash($pwd);
     $user = $this->database->table('users')->get($form->values->contact_id);
     $this->database->table("users")->get($user->id)->update(array("password" => $pwdEncrypted));
     if ($form->values->sendmail) {
         $latte = new \Latte\Engine();
         $latte->setLoader(new \Latte\Loaders\StringLoader());
         $params = array('username' => $user->username, 'email' => $user->email, 'password' => $pwd, 'settings' => $this->presenter->template->settings);
         $helpdesk = $this->database->table("helpdesk")->get(4);
         $helpdesk_resend_login = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(8);
         $helpdesk_resend = $latte->renderToString($helpdesk_resend_login->body, $params);
         $mail = new \Nette\Mail\Message();
         $mail->setFrom($this->presenter->template->settings["site:title"] . ' <' . $this->presenter->template->settings["contacts:email:hq"] . '>')->addTo($user->email)->setHTMLBody($helpdesk_resend);
         $mailer = new \Nette\Mail\SendmailMailer();
         $mailer->send($mail);
     } else {
         $this->presenter->flashMessage("pass", "success");
     }
     $this->presenter->redirect(this, array("id" => $form->values->contact_id, "pdd" => $pwd));
 }
Ejemplo n.º 25
0
 /**
  * Generate slug
  */
 function generate($slugToGenerate)
 {
     $slug = Strings::webalize($slugToGenerate);
     $slugNameOne = $this->database->table("pages")->where("slug", $slug);
     if ($slugNameOne->count() == 0) {
         return $slug;
     }
     $max = 0;
     $slugName = $this->database->table("pages")->where("slug LIKE ?", '%' . $slug);
     if ($slugName->count() > 0) {
         $slugs = array_values($slugName->fetchPairs("slug", "slug"));
         while (in_array(++$max . '-' . $slug, $slugs)) {
         }
         return $max . '-' . $slug;
     } else {
         return $slug;
     }
 }
Ejemplo n.º 26
0
 function dropFileUploadFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     if (!empty($_FILES)) {
         $ds = DIRECTORY_SEPARATOR;
         $storeFolder = 'media/' . $form->values->pages_id;
         \App\Model\IO::directoryMake(APP_DIR . $ds . $storeFolder, 0755);
         $tempFile = $_FILES['file']['tmp_name'];
         $realFile = $_FILES['file']['name'];
         $targetPath = APP_DIR . $ds . $storeFolder . $ds;
         $targetFile = $targetPath . $_FILES['file']['name'];
         move_uploaded_file($tempFile, $targetFile);
         chmod($targetFile, 0644);
         $fileSize = filesize($targetFile);
         $checkImage = $this->database->table("media")->where(array('name' => $realFile, 'pages_id' => $form->values->id));
         if ($checkImage->count() == 0) {
             $this->database->table("media")->insert(array('name' => $realFile, 'pages_id' => $form->values->pages_id, 'filesize' => $fileSize, 'file_type' => 0, 'date_created' => date("Y-m-d H:i:s")));
         } else {
             echo "Nejsem reálný soubor";
         }
     }
     exit;
 }
Ejemplo n.º 27
0
	<hr>

	<?php 
// CONNECTION & NDBT
$connection = new \Nette\Database\Connection('mysql:host=127.0.0.1;dbname=sources_test', 'root', 'root');
$cacheMemoryStorage = new \Nette\Caching\Storages\MemoryStorage();
$structure = new \Nette\Database\Structure($connection, $cacheMemoryStorage);
$conventions = new \Nette\Database\Conventions\DiscoveredConventions($structure);
$context = new \Nette\Database\Context($connection, $structure, $conventions, $cacheMemoryStorage);
// APPLICATION
$application = new Mesour\UI\Application();
$application->setRequest($_REQUEST);
$application->run();
// SELECTION
$selection = $context->table('users');
$selection->select('users.*')->select('group.name group_name')->select('group.type group_type')->select('group.date group_date');
// SOURCE
$source = new \Mesour\Filter\Sources\NetteDbFilterSource('users', 'id', $selection, $context, ['group_name' => 'group.name', 'group_type' => 'group.type', 'group_date' => 'group.date']);
// FILTER
$filter = new \Mesour\UI\Filter('test', $application);
$filter->setSource($source);
$filter->addTextFilter('action', 'Status', [0 => 'Inactive', 1 => 'Active'])->setMainFilter(false);
$filter->setCustomReference('action', [0 => 'Inactive', 1 => 'Active']);
$filter->addTextFilter('name', 'Name');
$filter->addNumberFilter('amount', 'Amount');
$filter->addDateFilter('last_login', 'Last login');
$filter->addTextFilter('group_name', 'Group name');
$filter->addTextFilter('has_pro', 'Bool value');
$filter->addDateFilter('timestamp', 'Timestamp');
$filter->onRender[] = function (Mesour\UI\Filter $_filter) use($source) {
Ejemplo n.º 28
0
<?php

require __DIR__ . '/../print_benchmark_result.php';
if (@(!(include __DIR__ . '/vendor/autoload.php'))) {
    echo 'Install Nette using `composer install`';
    exit(1);
}
$useCache = TRUE;
date_default_timezone_set('Europe/Prague');
$connection = new Nette\Database\Connection('mysql:dbname=employees', 'root', '');
$cacheStorage = new Nette\Caching\Storages\FileStorage(__DIR__ . '/temp');
$dao = new Nette\Database\Context($connection, new Nette\Database\Reflection\DiscoveredReflection($connection, $useCache ? $cacheStorage : NULL), $useCache ? $cacheStorage : NULL);
$time = -microtime(TRUE);
ob_start();
foreach ($dao->table('employees')->limit(500) as $employe) {
    echo "{$employe->first_name} {$employe->last_name} ({$employe->emp_no})\n";
    echo "Salaries:\n";
    foreach ($employe->related('salaries') as $salary) {
        echo $salary->salary, "\n";
    }
    echo "Departments:\n";
    foreach ($employe->related('dept_emp') as $department) {
        echo $department->dept->dept_name, "\n";
    }
}
ob_end_clean();
print_benchmark_result('NDB 2.1', 'Nette: ' . Nette\Framework::VERSION);
Ejemplo n.º 29
0
 function editAddressFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $this->database->table("contacts")->where(array("id" => $form->values->contacts_id))->update(array("name" => $form->values->name, "street" => $form->values->street, "zip" => $form->values->zip, "city" => $form->values->city));
     $this->presenter->redirect(":Front:Profile:address", array("id" => $form->values->id));
 }
Ejemplo n.º 30
0
 protected function getTable()
 {
     return $this->database->table($this->tableName);
 }