public function render() { $template = $this->getTemplate(); $template->setFile(__DIR__ . '/pageTagsPicking.latte'); $tags = $this->tagFacade->fetchTags((new TagQuery())->indexedByTagId())->toArray(); $template->tags = $tags; $template->pageTags = isset($this->page) ? $this->page->getTags() : []; $template->render(); }
/** * @param Page $page */ private function removePageUrl(Page $page) { /** @var Url $url */ $url = $this->urlFacade->getByPath($page->getUrlPath()); if ($url !== null) { $this->cache->clean([Cache::TAGS => $url->getCacheKey()]); $this->em->remove($url); } }
public function render() { $template = $this->getTemplate(); $template->setFile(__DIR__ . '/page.latte'); $template->page = $this->page; $template->isOnlyIntroShown = $this->isOnlyIntroShown; $template->commentsCount = $this->commentsCount; $template->translate = function ($string, $count = null) { return $this->translator->translate($string, $count, [], null, $this->page->getLocaleCode()); }; $template->render(); }
protected function createComponentRemovalForm() { $form = new Form(); $form->setTranslator($this->translator->domain('pageRemoval')); $form->addText('check', 'check.label')->setRequired('check.messages.required')->addRule(Form::EQUAL, 'check.messages.notEqual', $this->page->getTitle()); $form->addSubmit('remove', 'remove.caption')->onClick[] = [$this, 'removePage']; $form->addSubmit('cancel', 'cancel.caption')->setValidationScope([])->onClick[] = [$this, 'cancelClick']; if (!$this->authorizator->isAllowed($this->user, 'page', 'remove')) { $form['remove']->setDisabled(); } $form->addProtection(); return $form; }
public function processForm(Form $form, $values) { if ($this->page->getAllowedComments() === false and !$this->authorizator->isAllowed($this->user, 'page_comment_form', 'comment_on_closed')) { $this->flashMessage('page.comments.form.messages.closedComments', FlashMessage::WARNING); $this->redirect('this#comments'); } $values['page'] = $this->page; try { $comment = $this->commentFacade->save((array) $values); $this->flashMessage('page.comments.form.messages.success', FlashMessage::SUCCESS); $this->redirect('this#comment-' . $comment->getId()); } catch (ActionFailedException $e) { $form->addError($this->translator->translate('page.comments.form.messages.error')); } }
private function fillFormBy(Page $page) { $this['pageForm']['url']->setDefaultValue($page->getUrlPath()); $this['pageForm']['publishedAt']->setDefaultValue($page->getTitle()); if ($page->getPublishedAt() !== null) { $this['pageForm']['publishedAt']->setDefaultValue($page->getPublishedAt()->format('j.n.Y H:i')); } $this['pageForm']['title']->setDefaultValue($page->getTitle()); $this['pageForm']['intro']->setDefaultValue($page->getIntro()); $this['pageForm']['text']->setDefaultValue($page->getText()); $this['pageForm']['allowedComments']->setDefaultValue($page->getAllowedComments()); $this['pageForm']['description']->setDefaultValue($page->getMetaDescription()); $this['pageForm']['keywords']->setDefaultValue($page->getMetaKeywords()); $this['pageForm']['lang']->setDefaultValue($page->getLocaleName()); }
private function findComments() { $query = (new CommentQuery())->withReactions()->byPage($this->page->getId())->indexedById(); $this->comments = $this->commentFacade->fetchComments($query)->toArray(); }
/** * @param Page $page * @throws DBALException */ public function removePage(Page $page) { $pageID = $page->getId(); $this->pageRemover->remove($page); $this->onSuccessPageRemoval($page, $pageID); }
/** * @param string $formatString * @param Page $page * @return string * @throws \Nette\Application\UI\InvalidLinkException */ private function createLogMessage($formatString, Page $page) { return sprintf($formatString, $this->user->getId(), $this->user->getUsername(), $this->linkGenerator->link('Pages:Front:Page:show', ['internal_id' => $page->getId()]), $page->isDraft() ? ' draft' : '', $page->getId(), $page->getTitle()); }
/** * @return bool */ public function isPageDraft() { return $this->page->isDraft(); }
public function onArticleRemoval(PageRemovalControl $control, Page $page) { $this->flashMessage('pageRemoval.flashMessages.success', FlashMessage::SUCCESS, null, ['name' => $page->getTitle()]); $this->redirect(':Pages:Admin:Page:overview'); }
/** * @param string $newUrlAddress * @param Page $page * @return Url * @throws UrlAlreadyExistsException */ private function redirectPageToUrl($newUrlAddress, Page $page) { $newUrlEntity = $this->createUrl($newUrlAddress); $newUrlEntity->setInternalId($page->getId()); // if we first try to save url entity, the current transaction is marked for // rollback only if there is unique constraint violation. $newUrl = $this->urlFacade->getByPath($newUrlEntity->getUrlPath()); if ($newUrl === null) { $newUrl = $this->urlFacade->saveUrl($newUrlEntity); } $oldUrl = $this->urlFacade->getById($page->getUrlId()); $this->urlFacade->linkUrls($oldUrl, $newUrl); return $newUrl; }
/** * @expectedException GuzzleHttp\Exception\RequestException */ public function testGetDescriptionOfPageTakingALongTime() { $page = new Page(self::TAKING_LONG_TIME_URL); $page->fetch()->getDescription(); }
<?php use pages\Page; include_once __DIR__ . '/../vendor/autoload.php'; $get = function ($url) { try { $page = new Page($url, 3); echo "Url: " . $url . PHP_EOL; $page->fetch(); if ($page->exists()) { echo "Title: " . $page->getTitle() . PHP_EOL; echo "Description: " . $page->getDescription() . PHP_EOL; } else { echo "Page not found." . PHP_EOL; } } catch (RuntimeException $ex) { echo $ex->getMessage() . PHP_EOL; } echo PHP_EOL . PHP_EOL; }; $get("http://www.nourdine.net/article/10"); $get("www.yahoo.com"); $get("https://www.google.com"); // redirecting $get("http://www.adam-bray.com/blog/86/Simple+CSS+3+buttons/"); $get("http://bloomwebdesign.net/2013/09/create-a-flat-website-template-htmlcss-tutorial/"); // 404 $get("http://getcomposer.org/"); // redirecting $get("http://vectorboom.com/load/tutorials/web_design/how_to_create_glass_infographics_elements_in_illustrator/7-1-0-457");