示例#1
0
 /**
  * Function to load data
  *
  * @param \Doctrine\Common\Persistence\ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $entityPage = new Page();
     $entityPage->setLft(0);
     $entityPage->setRgt(0);
     $manager->persist($entityPage);
     //        $manager->flush();
 }
示例#2
0
 /**
  * Update alias for page
  * @param \CMS\Bundle\AdminBundle\Entity\Page $page
  */
 public function updateAlias(\CMS\Bundle\AdminBundle\Entity\Page $page)
 {
     $pageLanguages = $this->_em->getRepository($this->_entityName)->findBy(array('page' => $page->getId()));
     if (is_array($pageLanguages) && count($pageLanguages) > 0) {
         foreach ($pageLanguages as $pageLanguage) {
             $alias = $this->getAliasByName($pageLanguage->getName());
             $aliasOk = false;
             while (!$aliasOk) {
                 $plTemp = $this->_em->getRepository($this->_entityName)->findOneBy(array('alias' => $alias));
                 if (!$plTemp) {
                     $aliasOk = true;
                 } else {
                     if ($pageLanguage->getId() != $plTemp->getId()) {
                         $alias .= '-' . $pageLanguage->getId();
                     } else {
                         $aliasOk = true;
                     }
                 }
             }
             $pageLanguage->setAlias($alias);
             $this->_em->persist($pageLanguage);
             $this->_em->flush();
         }
     }
 }
示例#3
0
 /**
  * Reset the unique is_home and is_showreel of the Page
  *
  * @param \CMS\Bundle\AdminBundle\Entity\Page $page        	
  */
 private function resetUnique(\CMS\Bundle\AdminBundle\Entity\Page $page)
 {
     if ($page->getIsHome()) {
         $this->getDoctrine()->getRepository("CMSAdminBundle:Page")->resetIsHome();
         $page->setIsHome(1);
     }
     if ($page->getIsShowreel()) {
         $this->getDoctrine()->getRepository("CMSAdminBundle:Page")->resetIsShowreel();
         $page->setIsShowreel(1);
     }
 }
示例#4
0
 /**
  * @param \CMS\Bundle\AdminBundle\Entity\Page $page the page
  */
 public function moveDown(\CMS\Bundle\AdminBundle\Entity\Page $page)
 {
     //get the area upper
     $entityManager = $this->_em;
     $pageArray = array('id' => $page->getId(), 'lft' => $page->getLft(), 'rgt' => $page->getRgt());
     $repositor = $entityManager->getRepository('CMSAdminBundle:Page');
     $pageUnder = $repositor->findOneArrayBy(array('lft' => $pageArray['rgt'] + 1));
     if ($pageUnder) {
         $del1 = $pageArray['rgt'] - $pageArray['lft'];
         $del2 = $pageUnder['rgt'] - $pageUnder['lft'];
         //calculate new lft, rgt of 2 node and swap
         $pageUnder['lft'] = $pageArray['lft'];
         $pageUnder['rgt'] = $pageArray['lft'] + $del2;
         $pageArray['lft'] = $pageUnder['rgt'] + 1;
         $pageArray['rgt'] = $pageArray['lft'] + $del1;
         $end = 0;
         //save new order
         $repositor->postOrderTraversal($pageUnder, $pageUnder['lft'], $end);
         $repositor->postOrderTraversal($pageArray, $pageArray['lft'], $end);
     }
 }