public function renderDetail() { $this->template->userDat = $this->userDat; $this->template->articles = $this->articleManager->getArticleByUser($this->userDat->id); if (!$this->template->userDat) { throw new \Nette\Application\BadRequestException(); } }
public function handlePublishNewWriter($id = '') { if (!$this->user->isAllowed('Article', 'add') || !is_numeric($id)) { throw new Nette\Application\BadRequestException(); } $returnId = $this->articleManager->publicNewWriter($id); $this->flashMessage('Článek úspěšně přidán'); $this->redirect('Article:UpdateArticle', $returnId); }
public function renderDefault($category = '') { $selectedCategory = $this->articleManager->getCategory($category); if (!$selectedCategory) { throw new BadRequestException(); } $this->template->selectedCategory = $selectedCategory; $this->template->categories = $this->articleManager->findCategories(); $this->template->articles = $this->articleManager->findAllInCategory($category, $this->language); }
public function handleDislikeArticle($id) { if ($this->user->isAllowed('Article', 'like')) { if ($this->articleManager->userDislikeArticle($id, $this->user->id)) { // todo: if ajax, redraw component $this->redirect('this'); } else { $this->redirect('this'); } } }
public function renderArticle($url) { if (!\App\Helper\Helper::isIndexBot()) { $this->articleManager->viewForArticleUrl($url, $this->getSession()); } $this->template->serial = $this->articleDat->ref('underSerial'); if ($this->template->serial) { $this->template->articleInSerial = $this->articleManager->getArticlesUnderSerial($this->template->serial->articleOrder); } $this->template->article = $this->articleDat; }
/** * @param $queryString */ public function prepareFulltext($queryString) { if (!$this->queryPrepared) { if (Strings::length($queryString) > 2) { $this->template->searchResults = $this->articleManager->findFulltext($queryString); } elseif (Strings::length($queryString) > 0) { $this->template->searchStatus = 'too-short'; } $this->queryPrepared = TRUE; } }
public function match(Nette\Http\IRequest $httpRequest) { $appRequest = parent::match($httpRequest); if (empty($appRequest->parameters)) { return null; } if (!$this->articleManager->getArticleUrl($appRequest->parameters['url'])) { return null; } return $appRequest; }
/** * @param Form $form * @throws ForbiddenRequestException */ public function articleFormSucceeded(Form $form) { $v = $form->getValues(); if (!$this->user->isAllowed('Article', 'add') || !$this->user->isAllowed('Article', 'edit')) { throw new ForbiddenRequestException(); } $tags = []; if ($v->tags !== '') { $articleTags = explode(',', $v->tags); $tags = $this->articleManager->createTagsAndReturnIds($articleTags); } // type if ($v->type != 'default') { $type = $this->articleManager->addTag($v->type, 'type'); } else { $type = NULL; } if (empty($this->article)) { $article = $this->articleManager->addArticle($v->title, $v->content, $v->language, $tags, $type, $this->getUser()->getId()); $this->flashMessage('Article was added'); $this->redirect('edit', $article->id); } else { $this->articleManager->editArticle($this->article->id, $v->title, $v->content, $v->language, $tags, $type, $this->getUser()->getId()); $this->flashMessage('Article was updated'); $this->redirect('edit', $this->article->id); } }
/** * @param Form $form * @throws ForbiddenRequestException */ public function articleFormSucceeded(Form $form) { $v = $form->getValues(); if (!$this->user->isAllowed('Article', 'add') || !$this->user->isAllowed('Article', 'edit')) { throw new ForbiddenRequestException(); } $tags = []; if ($v->tags !== '') { $articleTags = explode(',', $v->tags); $tags = $this->articleManager->createTagsAndReturnIds($articleTags); } // type if ($v->type != 'default') { $type = $this->articleManager->addTag($v->type, 'type'); } else { $type = NULL; } if ($v->draft) { $draft = TRUE; } else { $draft = FALSE; } if (empty($this->article)) { $article = $this->articleManager->addArticle($v->title, $v->content, $draft, $v->language, $tags, $type, $this->getUser()->getId()); $this->versionManager->addVersionToArticle($v->version, $article->id); $this->flashMessage('Article was added'); $this->redirect('Detail:default', $article->id, $article->slug); } else { // file upload if ($v->file->isOk()) { /** @var \Nette\Http\FileUpload $file */ $file = $v->file; // TODO : refactor $this->imageStorage->setNamespace("knowledgebase"); $filename = uniqid() . '.' . (pathinfo($file->name, PATHINFO_EXTENSION) ?: 'png'); $image = $this->imageStorage->save($file->getContents(), $filename); $returnPath = pathinfo($image->file, PATHINFO_BASENAME); $note = ''; if ($v->fileNote) { $note = $v->fileNote; } $status = $this->articleManager->assignImageToArticle($this->article->id, $returnPath, "knowledgebase", $note); if ($status) { $this->flashMessage('Image was uploaded'); } } $this->article = $this->articleManager->editArticle($this->article->id, $v->title, $v->content, $draft, $v->language, $tags, $type, $this->getUser()->getId()); // .. Update version $this->versionManager->updateVersion($v->version, $this->article->id); $this->flashMessage('Article was updated'); if (isset($form['sendAndView']) && $form['sendAndView']->isSubmittedBy()) { $this->redirect('Detail:default', $this->article->id, $this->article->slug); } else { $this->redirect('Edit:edit', $this->article->id); } } }
public function newWriterFormSucceeded($form, $values) { if (!$this->presenter->user->isLoggedIn()) { try { $this->captchaManager->checkCaptcha($values->captcha); } catch (\Exception $e) { $this->presenter->flashMessage($e->getMessage()); $this->presenter->redirect('this'); } $values->byUser = null; } else { $values->contact = $this->presenter->user->getIdentity()->mail; $values->byUser = $this->presenter->user->id; } try { $this->articleManager->addNewWriter($values); } catch (\Exception $e) { $form->addError($e->getMessage()); } }
private function create() { $form = new Form(); $form->addText('title', 'Titulek')->setRequired('Zadejte titulek')->setAttribute('placeholder', 'Zadejte titulek'); if ($this->user->isAllowed(self::RES, 'moderate')) { $users = $this->userManager->getUserList(); $form->addSelect('byUser', 'Za uživatele', ['0' => 'Neregistrovaný'] + $users['deleted'] + $users['allowed'])->setValue($this->user->id); $form->addText('byUnregUser', 'Za neregistrovaného uživatele'); } $form->addTextArea('description', 'Popis')->setRequired('Zadejte popis'); $form->addTextArea('text', 'Článek')->setRequired('Zadejte článek'); $form->addText('keyWords', 'Klíčová slova'); $form->addCheckbox('commentsAllow', 'Povolit komentáře'); $form->addCheckbox('voteAllow', 'Povolit hlasování'); $form->addUpload('photo', 'Náhledová fotka'); if ($this->setSection) { $form->addSelect('underSection', 'Hlavní sekce', $this->articleManager->getMainSectionList())->setValue($this->setSection); if ($this->setSubsection) { $form->addSelect('underSubSection', 'Podsekce', $this->articleManager->getSubSectionList($this->setSection))->setValue($this->setSubsection); if ($this->setSerial) { $form->addSelect('underSerial', 'Serial', $this->articleManager->getSerialList($this->setSubsection))->setValue($this->setSerial); } else { $form->addSelect('underSerial', 'Serial', $this->articleManager->getSerialList($this->setSubsection))->setPrompt('Vyberte'); } } else { $form->addSelect('underSubSection', 'Podsekce', $this->articleManager->getSubSectionList($this->setSection))->setPrompt('Vyberte podsekci'); $form->addSelect('underSerial', 'Serial')->setPrompt('Vyberte podsekci'); } } else { $form->addSelect('underSection', 'Hlavní sekce', $this->articleManager->getMainSectionList())->setPrompt('Vyberte hlavní sekci'); $form->addSelect('underSubSection', 'Podsekce')->setPrompt('Vyberte hlavní sekci'); $form->addSelect('underSerial', 'Serial')->setPrompt('Vyberte hlavní sekci'); } if ($this->user->isAllowed('Section', 'moderate')) { } if ($this->user->isAllowed(self::RES, 'publish')) { $form->addCheckbox('published', 'Publikovaný ihned'); } $form->addSubmit('submitArticle', 'Odeslat')->setValidationScope(false); return $form; }
public function renderArticleList() { $this->template->public = $this->articleManager->getNewArticleList($this->publicPaginator); $this->template->notPublic = $this->articleManager->getNotPublicArticleList($this->notPublicPaginator); $this->template->deleted = $this->articleManager->getDeltedArticleList($this->deletedPaginator); }
protected function beforeRender() { parent::beforeRender(); $this->template->menu = $this->articleManager->getSectionList(); }
public function renderDefault() { $this->template->categories = $this->articleManager->findCategories(); }