/**
  *
  * Copy page from one place to another
  */
 private function _copyPage()
 {
     global $site;
     $site->requireConfig('standard/menu_management/remotes.php');
     $answer = array();
     if (!isset($_REQUEST['websiteId'])) {
         trigger_error("Website id is not set");
         return false;
     }
     $websiteId = $_REQUEST['websiteId'];
     if (!isset($_REQUEST['zoneName'])) {
         trigger_error("Zone name is not set");
         return false;
     }
     $zoneName = $_REQUEST['zoneName'];
     if (!isset($_REQUEST['languageId'])) {
         trigger_error("Language id is not set");
         return false;
     }
     $languageId = $_REQUEST['languageId'];
     if (!isset($_REQUEST['pageId'])) {
         trigger_error("Page id is not set");
         return false;
     }
     $pageId = $_REQUEST['pageId'];
     if (!isset($_REQUEST['destinationPageId'])) {
         trigger_error("Destination page id is not set");
         return false;
     }
     $destinationPageId = $_REQUEST['destinationPageId'];
     if (!isset($_REQUEST['destinationPageType'])) {
         trigger_error("Destination page type is not set");
         return false;
     }
     $destinationPageType = $_REQUEST['destinationPageType'];
     if (!isset($_REQUEST['destinationLanguageId'])) {
         trigger_error("Destination language id is not set");
         return false;
     }
     $destinationLanguageId = $_REQUEST['destinationLanguageId'];
     if (!isset($_REQUEST['destinationZoneName'])) {
         trigger_error("Destination zone name is not set");
         return false;
     }
     $destinationZoneName = $_REQUEST['destinationZoneName'];
     //check if destination page exists
     $destinationZone = $site->getZone($destinationZoneName);
     if ($destinationPageType == 'zone') {
         $rootElementId = Db::rootContentElement($destinationZone->getId(), $destinationLanguageId);
         if (!$rootElementId) {
             trigger_error('Can\'t find root zone element.');
             return false;
         }
         $destinationPage = $destinationZone->getElement($rootElementId);
     } else {
         $destinationPage = $destinationZone->getElement($destinationPageId);
     }
     if (!$destinationPage) {
         trigger_error("Destination page does not exist");
         return false;
     }
     if ($websiteId == 0) {
         //local page
         $children = Db::pageChildren($destinationPage->getId());
         $destinationPosition = count($children);
         //paste at the bottom
         Model::copyPage($pageId, $destinationPage->getId(), $destinationPosition);
     } else {
         //remote page
         $remotes = Remotes::getRemotes();
         $remote = $remotes[$websiteId - 1];
         $data = array('pageId' => $pageId);
         $remotePages = $this->_remoteRequest($remote, 'getData', $data);
         $this->_createPagesRecursion($destinationPage->getId(), $remotePages);
         $contentManagementSystem = new \Modules\standard\content_management\System();
         $contentManagementSystem->clearCache(BASE_URL);
         $answer['data'] = $data;
     }
     $answer['status'] = 'success';
     $answer['destinationPageId'] = $destinationPage->getId();
     $this->_printJson($answer);
 }
Example #2
0
 /**
  * Copy page
  *
  * @param int $pageId
  * @param int $destinationParentId
  * @param int $destinationPosition
  * @return int
  */
 public static function copyPage($pageId, $destinationParentId, $destinationPosition)
 {
     return Model::copyPage($pageId, $destinationParentId, $destinationPosition);
 }