Ejemplo n.º 1
0
 /**
  * DO NOT CALL THIS METHOD! USE copyToLang() OR copyToNode() INSTEAD!
  * Copies data from another Page.
  * @param boolean $includeContent Whether to copy content. Defaults to true.
  * @param boolean $includeModuleAndCmd Whether to copy module and cmd. Defaults to true.
  * @param boolean $includeName Wheter to copy title, content title and slug. Defaults to true.
  * @param boolean $includeMetaData Wheter to copy meta data. Defaults to true.
  * @param boolean $includeProtection Wheter to copy protection. Defaults to true.
  * @param boolean $followRedirects Wheter to return a redirection page or the page its pointing at. Defaults to false, which returns the redirection page
  * @param boolean $followFallbacks Wheter to return a fallback page or the page its pointing at. Defaults to false, witch returns the fallback page
  * @param \Cx\Core\ContentManager\Model\Entity\Page Page to use as target
  * @return \Cx\Core\ContentManager\Model\Entity\Page The copy of $this or null on error
  */
 public function copy($includeContent = true, $includeModuleAndCmd = true, $includeName = true, $includeMetaData = true, $includeProtection = true, $followRedirects = false, $followFallbacks = false, $page = null)
 {
     $targetPage = null;
     if ($followRedirects && $this->getType() == self::TYPE_REDIRECT) {
         $targetPage = $this->getTargetNodeId()->getPage($this->getTargetLangId());
     }
     if ($followFallbacks && $this->getType() == self::TYPE_FALLBACK) {
         $fallbackLanguage = \FWLanguage::getFallbackLanguageIdById($this->getLang());
         $targetPage = $this->getNode()->getPage($fallbackLanguage);
     }
     if ($targetPage) {
         return $targetPage->copy($includeContent, $includeModuleAndCmd, $includeName, $includeMetaData, $includeProtection, $followRedirects, $followFallbacks);
     }
     if (!$page) {
         $page = new \Cx\Core\ContentManager\Model\Entity\Page();
     }
     if ($includeName) {
         $page->setContentTitle($this->getContentTitle());
         $page->setTitle($this->getTitle());
         $page->setSlug($this->getSlug());
     }
     $newType = $this->getType();
     if ($includeContent) {
         $page->setContent($this->getContent());
     } else {
         $newType = self::TYPE_FALLBACK;
     }
     if ($includeModuleAndCmd) {
         $page->setModule($this->getModule());
         $page->setCmd($this->getCmd());
     } else {
         $page->setCmd('');
     }
     if ($includeMetaData) {
         $page->setMetatitle($this->getMetatitle());
         $page->setMetadesc($this->getMetadesc());
         $page->setMetakeys($this->getMetakeys());
         $page->setMetarobots($this->getMetarobots());
     }
     $page->setNode($this->getNode());
     $page->setActive($this->getActive());
     $page->setDisplay($this->getDisplay());
     $page->setLang($this->getLang());
     $page->setType($newType);
     $page->setCaching($this->getCaching());
     $page->setCustomContent($this->getCustomContent());
     $page->setCssName($this->getCssName());
     $page->setCssNavName($this->getCssNavName());
     $page->setSkin($this->getSkin());
     $page->setStart($this->getStart());
     $page->setEnd($this->getEnd());
     $page->setEditingStatus($this->getEditingStatus());
     $page->setTarget($this->getTarget());
     $page->setLinkTarget($this->getLinkTarget());
     $page->setUpdatedBy(\FWUser::getFWUserObject()->objUser->getUsername());
     if ($includeProtection) {
         if (!$this->copyProtection($page, true) || !$this->copyProtection($page, false)) {
             return null;
         }
     }
     return $page;
 }