Ejemplo n.º 1
0
 /**
  * @group legacy
  */
 public function testCreateDate()
 {
     $date = $this->prophesize('\\DateTime')->reveal();
     $page = new Page();
     $page->setPublishStartDate($date);
     $this->assertEquals($date, $page->getCreateDate());
 }
Ejemplo n.º 2
0
 /**
  * @param Page $page
  */
 protected function ensureOrderByDate($page)
 {
     $items = $page->getParentDocument()->getChildren();
     $itemsByDate = array();
     /** @var $item Page */
     foreach ($items as $item) {
         $itemsByDate[$item->getDate()->format('U')][$item->getPublishStartDate()->format('U')][] = $item;
     }
     if ('asc' == $this->sortOrder) {
         ksort($itemsByDate);
     } else {
         krsort($itemsByDate);
     }
     $sortedItems = array();
     foreach ($itemsByDate as $itemsForDate) {
         if ('asc' == $this->sortOrder) {
             ksort($itemsForDate);
         } else {
             krsort($itemsForDate);
         }
         foreach ($itemsForDate as $itemsForPublishDate) {
             foreach ($itemsForPublishDate as $item) {
                 $sortedItems[$item->getName()] = $item;
             }
         }
     }
     if ($sortedItems !== $items->getKeys()) {
         $items->clear();
         foreach ($sortedItems as $key => $item) {
             $items[$key] = $item;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Affiche le fil d'Ariane d'une page.
  * 
  * @param string $html HTML
  * @return string HTML
  */
 public function filAriane(Page $page)
 {
     $filArianeHtml = '<strong class="current">' . $page->getTitle() . '</strong>';
     $pageParente = $page->getParent();
     while (null !== $pageParente && $pageParente instanceof Page) {
         $filArianeHtml = '<a href="' . $pageParente->getPath() . '">' . $pageParente->getTitle() . '</a> ' . $filArianeHtml;
         $pageParente = $pageParente->getParent();
     }
     return $filArianeHtml;
 }
Ejemplo n.º 4
0
 public function load(ObjectManager $manager)
 {
     $base = $manager->find(null, '/test/page');
     $page = new Page();
     $page->setName('homepage');
     $page->setTitle('Homepage');
     $page->setLabel('Homepage');
     $page->setPublishable(true);
     $page->setAddLocalePattern(true);
     $page->setParent($base);
     $page->setBody($this->getContent('homepage.html'));
     $manager->persist($page);
     $page = new Page();
     $page->setName('french-page');
     $page->setTitle('French Page');
     $page->setLabel('French Page');
     $page->setPublishable(true);
     $page->setAddLocalePattern(true);
     $page->setLocale('fr');
     $page->setBody($this->getContent('french-page.html'));
     $page->setParent($base);
     $manager->persist($page);
     $page = new Page();
     $page->setName('no-locale-prefix');
     $page->setTitle('No Locale Prefix');
     $page->setLabel('No Locale Prefix');
     $page->setPublishable(true);
     $page->setParent($base);
     $page->setBody($this->getContent('no-locale-prefix.html'));
     $page->setParent($base);
     $manager->persist($page);
     $manager->flush();
 }
Ejemplo n.º 5
0
 /**
  * @return Page instance with the specified information
  */
 protected function createPage(DocumentManager $manager, $parent, $name, $label, $title, $body)
 {
     $page = new Page();
     $page->setPosition($parent, $name);
     $page->setLabel($label);
     $page->setTitle($title);
     $page->setBody($body);
     $manager->persist($page);
     return $page;
 }
Ejemplo n.º 6
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $base = new Page();
     $base->setName('page');
     $base->setTitle('Simple Cms');
     $base->setLabel('Simple Cms');
     $base->setParent($root);
     $manager->persist($base);
     $page = new Page();
     $page->setName('homepage');
     $page->setTitle('Homepage');
     $page->setLabel('Homepage');
     $page->setPublishable(true);
     $page->setAddLocalePattern(true);
     $page->setParent($base);
     $page->setBody($this->getContent('homepage.html'));
     $manager->persist($page);
     $page = new Page();
     $page->setName('french-page');
     $page->setTitle('French Page');
     $page->setLabel('French Page');
     $page->setPublishable(true);
     $page->setAddLocalePattern(true);
     $page->setLocale('fr');
     $page->setBody($this->getContent('french-page.html'));
     $page->setParent($base);
     $manager->persist($page);
     $page = new Page();
     $page->setName('no-locale-prefix');
     $page->setTitle('No Locale Prefix');
     $page->setLabel('No Locale Prefix');
     $page->setPublishable(true);
     $page->setParent($base);
     $page->setBody($this->getContent('no-locale-prefix.html'));
     $page->setParent($base);
     $manager->persist($page);
     $manager->flush();
 }
Ejemplo n.º 7
0
 public function load(ObjectManager $documentManager)
 {
     if (!$documentManager instanceof DocumentManager) {
         $class = get_class($documentManager);
         throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '{$class}' given.");
     }
     $page = new Page();
     // create a new Page object (document)
     $page->setName('new_page');
     // the name of the node
     $page->setLabel('Another new Page');
     $page->setTitle('Another new Page');
     $page->setBody('I have added this page myself!');
     $simpleCmsRoot = $documentManager->find(null, '/cms/simple');
     $page->setParentDocument($simpleCmsRoot);
     // set the parent to the root
     $documentManager->persist($page);
     // add the Page in the queue
     $documentManager->flush();
     // add the Page to PHPCR
 }
Ejemplo n.º 8
0
 public function testPage()
 {
     $page = new Page(array('add_locale_pattern' => true));
     $page->setParentDocument($this->baseDocument);
     $page->setName('page-name');
     $page->setTitle('Page Title');
     $page->setLabel('Page Label');
     $page->setBody('This is body');
     $page->setPublishable(false);
     $page->setPublishStartDate(new \DateTime('2013-06-18'));
     $page->setPublishEndDate(new \DateTime('2013-06-18'));
     $page->setExtras(array('extra_1' => 'foobar', 'extra_2' => 'barfoo'));
     $this->dm->persist($page);
     $this->dm->flush();
     $this->dm->clear();
     $page = $this->dm->find(null, '/test/page-name');
     $this->assertNotNull($page);
     $this->assertTrue($page->getOption('add_locale_pattern'));
     $this->assertEquals('Page Title', $page->getTitle());
     $this->assertEquals('Page Label', $page->getLabel());
     $this->assertEquals('This is body', $page->getBody());
     $this->assertEquals(array('extra_1' => 'foobar', 'extra_2' => 'barfoo'), $page->getExtras());
     // test publish start and end
     $publishStartDate = $page->getPublishStartDate();
     $publishEndDate = $page->getPublishEndDate();
     $this->assertInstanceOf('\\DateTime', $publishStartDate);
     $this->assertInstanceOf('\\DateTime', $publishEndDate);
     $this->assertEquals('2013-06-18', $publishStartDate->format('Y-m-d'));
     $this->assertEquals('2013-06-18', $publishEndDate->format('Y-m-d'));
     // test multi-lang
     $page->setLocale('fr');
     $page->setTitle('french');
     $this->dm->persist($page);
     $this->dm->flush();
     $this->dm->clear();
     $page = $this->dm->findTranslation(null, '/test/page-name', 'fr');
     $this->assertEquals('fr', $page->getLocale());
     $this->assertEquals('french', $page->getTitle());
     // test node
     $node = $page->getNode();
     $this->assertInstanceOf('PHPCR\\NodeInterface', $node);
 }
Ejemplo n.º 9
0
 public function __construct(array $options = array())
 {
     parent::__construct($options);
     $this->seoMetadata = new SeoMetadata();
 }
Ejemplo n.º 10
0
 /**
  * Add a page
  *
  * @Route(
  *     "/add.{_format}",
  *     name="zym_content_pages_add",
  *     defaults={
  *         "_format" = "html"
  *     },
  *     methods={"GET", "POST"}
  * )
  * @Route(
  *     ".{_format}",
  *     name="zym_content_pages_post_add",
  *     defaults={
  *         "_format" = "html"
  *     },
  *     methods={"POST"}
  * )
  *
  * @View()
  * @ApiDoc(
  *     description="Add a page",
  *     section="Pages",
  *     parameters={
  *         {"name"="zym_content_page[email]", "dataType"="string", "required"=true, "description"="Email address", "readonly"=false},
  *         {"name"="zym_content_page[plainPassword][password]", "dataType"="string", "required"=true, "description"="Password", "readonly"=false},
  *         {"name"="zym_content_page[plainPassword][confirmPassword]", "dataType"="string", "required"=true, "description"="Confirm Password", "readonly"=false}
  *     }
  * )
  */
 public function addAction()
 {
     $securityContext = $this->get('security.context');
     // Check for create access
     if (!$securityContext->isGranted('CREATE', new ObjectIdentity('class', 'Symfony\\Cmf\\Bundle\\SimpleCmsBundle\\Doctrine\\Phpcr\\Page'))) {
         //throw new AccessDeniedException();
     }
     $page = new Page();
     $page->setParent(new Generic());
     $form = $this->createForm(new Form\PageType(), $page);
     $request = $this->getRequest();
     $form->handleRequest($request);
     if ($form->isValid()) {
         /** @var $documentManager DocumentManager */
         $documentManager = $this->get('doctrine_phpcr.odm.default_document_manager');
         $documentManager->persist($page);
         $documentManager->flush();
         //            return ViewResponse::createRouteRedirect(
         //                                   'zym_content_pages_show',
         //                                   array(
         //                                       'id'      => $page->getId(),
         //                                       '_format' => $request->getRequestFormat()
         //                                   ),
         //                                   Codes::HTTP_CREATED
         //                               )
         //                               ->setData(array(
         //                                   'page' => $page
         //                               ))
         //            ;
     }
     return array('form' => $form);
 }
Ejemplo n.º 11
0
 /**
  * Testing BC
  */
 public function testGetSet()
 {
     $page = new Page();
     $page->setAddLocalePattern(true);
     $this->assertEquals(true, $page->getAddLocalePattern());
 }