if ($page->getPublication() == RESOURCE_PUBLICATION_PUBLIC) {
                $pagesIds[] = $page->getID();
            }
        }
        if ($pagesIds) {
            CMS_tree::submitToRegenerator($pagesIds, true);
            $cms_message = $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGEN, array(sizeof($pagesIds)));
        } else {
            $cms_message = $cms_language->getMessage(MESSAGE_ERROR_NO_PUBLIC_PAGE);
        }
        break;
    case 'copy':
        if (is_a($template, "CMS_pageTemplate") && !$template->hasError()) {
            //Dupplicate selected template with given label
            $label = $cms_language->getMessage(MESSAGE_PAGE_COPY_OF) . ' ' . $template->getLabel();
            $template = CMS_pageTemplatesCatalog::getCloneFromID($templateId, $label);
            $log = new CMS_log();
            $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT, $cms_user, "Template : " . $label . " (create template)");
            $content = array('success' => array('templateId' => $template->getID()));
            $cms_message = $cms_language->getMessage(MESSAGE_ACTION_DUPICATION_DONE, array($label));
            $view->setContent($content);
        } else {
            $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_TEMPLATE);
        }
        break;
}
//set user message if any
if ($cms_message) {
    $view->setActionMessage($cms_message);
}
$view->show();
Example #2
0
 /**
  * Duplicate current page into another one
  * All contents and external datas are duplicated too
  *
  * @param CMS_user user, the user processing to creation
  * @param integer templateID, a new template to duplicate the page with
  * @param boolean $dontDuplicateContent If true, the content of the page is not duplicated
  * @return CMS_page newly created, or null on error
  */
 function duplicate(&$user, $templateID = 0, $dontDuplicateContent = false)
 {
     $pg = null;
     if ($user->hasPageClearance($this->getID(), CLEARANCE_PAGE_VIEW) && $user->hasModuleClearance(MOD_STANDARD_CODENAME, CLEARANCE_MODULE_EDIT)) {
         $pg = new CMS_page();
         $pg->lock($user);
         $pg->addEdition(RESOURCE_EDITION_CONTENT, $user);
         //Which template to use?
         if (!$templateID) {
             $newTpl = CMS_pageTemplatesCatalog::getCloneFromID($this->_templateID, false, true, false, $this->_templateID);
         } else {
             $newTpl = CMS_pageTemplatesCatalog::getCloneFromID($templateID, false, true, false, $this->_templateID);
         }
         if (!is_a($newTpl, 'CMS_pageTemplate') || $newTpl->hasError()) {
             $this->raiseError("Error during template clone creation.");
         } else {
             $pg->setTemplate($newTpl->getID());
         }
         //Duplicate page base datas
         $pg->setTitle($this->getTitle(), $user);
         $pg->setLinkTitle($this->getLinkTitle(), $user);
         $pg->setDescription($this->getDescription(false, false), $user);
         $pg->setKeywords($this->getKeywords(false, false), $user);
         $pg->setPublicationDates($this->getPublicationDateStart(false), $this->getPublicationDateEnd(false));
         $pg->setReminderOn($this->getReminderOn(false, false), $user);
         $pg->setReminderOnMessage($this->getReminderOnMessage(false, false), $user);
         $pg->setCategory($this->getCategory(false, false), $user);
         $pg->setAuthor($this->getAuthor(false, false), $user);
         $pg->setReplyto($this->getReplyto(false, false), $user);
         $pg->setCopyright($this->getCopyright(false, false), $user);
         $pg->setLanguage($this->getLanguage(false, false), $user);
         $pg->setRobots($this->getRobots(false, false), $user);
         $pg->setPragma($this->getPragma(false, false), $user);
         $pg->setRefresh($this->getRefresh(false, false), $user);
         $pg->setRedirectLink($this->getRedirectLink(), $user);
         $pg->setMetas($this->getMetas(false, false), $user);
         $pg->setCodename($this->getCodename(), $user, false);
         if (SensitiveIO::isPositiveInteger($this->getReminderPeriodicity())) {
             $pg->setReminderPeriodicity($this->getReminderPeriodicity(), $user);
         }
         $pg->writeToPersistence();
         $pg->unlock();
         //Duplicate contents, get all blocks and duplicate them
         if (!$dontDuplicateContent) {
             $this->duplicateContent($user, $pg);
         }
     } else {
         $this->raiseError("User doesn't have rights to do this creation");
     }
     return $pg;
 }
Example #3
0
 function duplicatePage($user, $page, $pageToAttachTo)
 {
     global $pageDuplicated, $duplicatedCodenames, $cms_user;
     if (is_a($page, "CMS_page") && is_a($pageToAttachTo, "CMS_page") && $page->getTemplate()) {
         //check codename duplication
         $removeCodename = false;
         if ($page->getCodename()) {
             //if codename already exists in website destination, then we must remove it
             if (CMS_tree::getPageByCodename($page->getCodename(), $pageToAttachTo->getWebsite(), false, false)) {
                 $removeCodename = true;
             }
         }
         //Duplicate page template
         $tpl = $page->getTemplate();
         $tpl_copy = CMS_pageTemplatesCatalog::getCloneFromID($tpl->getID(), false, true, false, $tpl->getID());
         $_tplID = $tpl_copy->getID();
         //Create copy of given page
         $newPage = $page->duplicate($user, $_tplID);
         if ($removeCodename) {
             $newPage->setCodename('', $cms_user);
             $newPage->writeToPersistence();
             $duplicatedCodenames[] = $page->getCodename();
         }
         //Move to destination in tree
         if (is_null($newPage) || !CMS_tree::attachPageToTree($newPage, $pageToAttachTo)) {
             return null;
         }
         $pageDuplicated[] = $newPage->getID();
         //Proceed with siblings
         $sibs = CMS_tree::getSiblings($page);
         if (!$sibs || !sizeof($sibs)) {
             return $pageToAttachTo;
         } else {
             $pageToAttachTo = $newPage;
         }
         foreach ($sibs as $sib) {
             if ($user->hasPageClearance($sib->getID(), CLEARANCE_PAGE_EDIT) && !in_array($sib->getID(), $pageDuplicated)) {
                 duplicatePage($user, $sib, $pageToAttachTo);
             }
         }
     }
 }