コード例 #1
0
 function handleDeletePortrait()
 {
     $idfFolder = substr(__DIR__, 0, -27) . '/www';
     if (file_exists($idfFolder . "/images/profiles/portrait-" . $this->user->getId() . ".jpg")) {
         \App\Model\IO::remove($idfFolder . "/images/profiles/portrait-" . $this->user->getId() . ".jpg");
     }
     $this->redirect(this);
 }
コード例 #2
0
 /**
  * Delete image
  */
 function handleDelete($id)
 {
     $imageDb = $this->database->table("media")->get($this->getParameter("name"));
     $imageDb->delete();
     \App\Model\IO::remove(APP_DIR . '/media/' . $id . '/' . $imageDb->name);
     \App\Model\IO::remove(APP_DIR . '/media/' . $id . '/tn/' . $imageDb->name);
     $this->redirect(this, array("id" => $this->presenter->getParameter("name")));
 }
コード例 #3
0
 function insertFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $doc = new \App\Model\Document($this->database);
     $doc->setType(2);
     $doc->setTitle($form->values->title);
     $page = $doc->create($this->presenter->user->getId());
     \App\Model\IO::directoryMake(substr(APP_DIR, 0, -4) . '/www/media/' . $page);
     $this->presenter->redirect(":Admin:Blog:detail", array("id" => $page));
 }
コード例 #4
0
 function insertFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $doc = new \App\Model\Document($this->database);
     $doc->setType($form->values->type);
     $doc->setTitle($form->values->title);
     $doc->setPreview($form->values->preview);
     $page = $doc->create($this->presenter->user->getId(), $form->values->category);
     \App\Model\IO::directoryMake(APP_DIR . '/media/' . $page);
     $this->presenter->redirect(this, array("id" => $form->values->category, "type" => $form->values->type));
 }
コード例 #5
0
 function insertFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $doc = new \App\Model\Document($this->database);
     $doc->setType(3);
     $doc->setTitle($form->values->title);
     $doc->setSlug($form->values->title);
     $id = $doc->create($this->presenter->user->getId());
     \App\Model\IO::directoryMake(APP_DIR . '/media/' . $id);
     $this->presenter->redirect(":Admin:Events:detail", array("id" => $id));
 }
コード例 #6
0
 function handleDelete($id)
 {
     for ($a = 0; $a < count($id); $a++) {
         $product = $this->database->table("carousel")->get($id[$a]);
         $image = $product->image;
         $product->delete();
         Model\IO::remove(APP_DIR . '/images/carousel/' . $image);
         unset($image);
     }
     $this->redirect(":Admin:Appearance:carousel", array("id" => null));
 }
コード例 #7
0
 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));
 }
コード例 #8
0
 /**
  * Delete page
  */
 function handleDeletePage($id)
 {
     $page = new Model\Page($this->database);
     $pages = $page->getChildren($id);
     $pages[] = $id;
     foreach ($pages as $item) {
         echo 1;
         $doc = new Model\Document($this->database);
         $doc->delete($item);
         Model\IO::removeDirectory(APP_DIR . '/media/' . $item);
     }
     $this->redirect(this, array("id" => null, "type" => $this->getParameter("type")));
 }
コード例 #9
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);
 }
コード例 #10
0
 /**
  * Delete contact with all other tables and related page
  */
 function handleDelete($id)
 {
     for ($a = 0; $a < count($id); $a++) {
         $contacts = $this->database->table("contacts")->get($id[$a]);
         if ($contacts) {
             $page = $this->database->table("pages")->get($contacts->pages_id);
             if ($page) {
                 $doc = new \App\Model\Document($this->database);
                 $doc->delete($page->id);
                 \App\Model\IO::removeDirectory(APP_DIR . '/media/' . $page->id);
             }
         }
     }
     $this->presenter->redirect(this, array("id" => null));
 }
コード例 #11
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");
 }
コード例 #12
0
 function editSettingsSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     if (strlen($form->values->path->name) < 1) {
         $this->presenter->redirect(this, array("id" => null));
     }
     if (file_exists($_FILES['path']['tmp_name']) || is_uploaded_file($_FILES['path']['tmp_name'])) {
         copy($_FILES['path']['tmp_name'], APP_DIR . '/images/paths/' . $form->values->path->name);
         chmod(APP_DIR . '/images/paths/' . $form->values->path->name, 0644);
         chmod(APP_DIR . '/images/paths/' . $form->values->path->name, 0644);
         if (file_exists(APP_DIR . '/www/images/paths/' . $form->values->path->name)) {
             \App\Model\IO::remove(APP_DIR . '/www/images/paths/' . $form->values->path->name);
         }
         $this->database->table("settings")->get($form->values->path_id)->update(array("setvalue" => $form->values->path->name));
     }
     $this->redirect(this, array("id" => null));
 }
コード例 #13
0
 public function editFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $image = $form->values->the_file->name;
     $arr = array("title" => $form->values->title, "description" => $form->values->description, "uri" => $form->values->uri, "visible" => $form->values->visible);
     if ($form->values->the_file->error == 0) {
         $arr['image'] = $image;
         if (file_exists(APP_DIR . "/images/carousel/" . $image)) {
             \App\Model\IO::remove(APP_DIR . "/images/carousel/" . $image);
             \App\Model\IO::upload(APP_DIR . "/images/carousel/", $image);
         } else {
             \App\Model\IO::upload(APP_DIR . "/images/carousel/", $image);
         }
     }
     $this->database->table("carousel")->get($form->values->carousel_id)->update($arr);
     $this->redirect(this, array("carousel_id" => $form->values->carousel_id));
 }
コード例 #14
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));
 }
コード例 #15
0
 function uploadFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     if (!empty($_FILES)) {
         $ds = DIRECTORY_SEPARATOR;
         $storeFolder = 'media/' . $form->values->pages_id;
         \App\Model\IO::directoryMake(APP_DIR . $ds . $storeFolder);
         $tempFile = $_FILES['file']['tmp_name'];
         //3
         $realFile = $_FILES['file']['name'];
         //3
         $targetPath = APP_DIR . $ds . $storeFolder . $ds;
         //4
         $targetFile = $targetPath . $_FILES['file']['name'];
         //5
         move_uploaded_file($tempFile, $targetFile);
         //6
         chmod($targetFile, 0644);
         $fileSize = filesize($targetFile);
         //$fileType = pathinfo($realFile, PATHINFO_EXTENSION);
         //$fileTypeC = str_replace(array("doc", "docx", "xlsx", "xls"), array("word", "word", "excel", "excel"), $fileType);
         $checkImage = $this->database->table("media")->where(array('name' => $realFile, 'pages_id' => $form->values->id));
         // Thumbnail for images
         if (\App\Model\IO::isImage($targetFile)) {
             \App\Model\IO::directoryMake(APP_DIR . $ds . $storeFolder . $ds . 'tn', 0755);
             // thumbnails
             $image = \Nette\Utils\Image::fromFile($targetFile);
             $image->resize(400, 250, \Nette\Utils\Image::SHRINK_ONLY);
             $image->sharpen();
             $image->save(APP_DIR . '/media/' . $form->values->pages_id . '/tn/' . $realFile);
             chmod(APP_DIR . '/media/' . $form->values->pages_id . '/tn/' . $realFile, 0644);
         }
         if ($checkImage->count() == 0) {
             $this->database->table("media")->insert(array('name' => $realFile, 'pages_id' => $form->values->pages_id, 'filesize' => $fileSize, 'file_type' => 1, 'date_created' => date("Y-m-d H:i:s")));
         } else {
             echo "Nejsem reálný soubor";
         }
     }
     exit;
 }
コード例 #16
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;
 }
コード例 #17
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));
 }
コード例 #18
0
 /**
  * Delete page
  */
 function handleDelete($id)
 {
     $doc = new Model\Document($this->database);
     $doc->delete($id);
     Model\IO::removeDirectory(APP_DIR . '/media/' . $id);
     $this->redirect(":Admin:Pages:default", array("id" => null));
 }
コード例 #19
0
 /**
  * Delete image
  */
 function handleDeleteImage($id)
 {
     $this->database->table("media")->get($id)->delete();
     \App\Model\IO::remove(APP_DIR . '/media/' . $id . '/' . $this->getParameter("name"));
     \App\Model\IO::remove(APP_DIR . '/media/' . $id . '/tn/' . $this->getParameter("name"));
     $this->redirect(":Admin:Events:images", array("id" => $this->getParameter("page")));
 }
コード例 #20
0
 /**
  * Delete file
  */
 function handleDeleteFile($id)
 {
     $this->database->table("media")->get($id)->delete();
     \App\Model\IO::remove(APP_DIR . '/media/' . $id . '/' . $this->getParameter("name"));
     $this->onSave($this->getParameter("name"));
 }
コード例 #21
0
 /**
  * Delete image
  */
 function handleDeleteImage($id)
 {
     $type = $this->getParameter("type");
     \App\Model\IO::remove(APP_DIR . '/images/menu/' . $id . $type . '.png');
     $this->redirect(":Admin:Menu:detail", array("id" => $id));
 }
コード例 #22
0
 /**
  * Delete files
  */
 function handleDelete()
 {
     Model\IO::remove(APP_DIR . '/images/' . $this->getParameter("path"));
     $this->redirect(this);
 }