Example #1
0
 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;
 }
Example #2
0
 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());
 }
Example #3
0
 /**
  * @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());
 }
Example #4
0
 /**
  * @return string
  */
 public function getPageTitle()
 {
     return $this->page->getTitle();
 }
Example #5
0
 public function onArticleRemoval(PageRemovalControl $control, Page $page)
 {
     $this->flashMessage('pageRemoval.flashMessages.success', FlashMessage::SUCCESS, null, ['name' => $page->getTitle()]);
     $this->redirect(':Pages:Admin:Page:overview');
 }
Example #6
0
<?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");