/** * Creates a new version of a page including content and possible subpages. * * @param integer $uid Page uid to create new version of. * @param string $label Version label * @param integer $versionizeTree Indicating "treeLevel" - "page" (0) or "branch" (>=1) ["element" type must call versionizeRecord() directly] * @param t3lib_TCEmain $tcemainObj TCEmain object * @return void * @see copyPages() */ protected function versionizePages($uid, $label, $versionizeTree, t3lib_TCEmain $tcemainObj) { global $TCA; $uid = intval($uid); // returns the branch $brExist = $tcemainObj->doesBranchExist('', $uid, $tcemainObj->pMap['show'], 1); // Checks if we had permissions if ($brExist != -1) { // Make list of tables that should come along with a new version of the page: $verTablesArray = array(); $allTables = array_keys($TCA); foreach ($allTables as $tableName) { if ($tableName != 'pages' && ($versionizeTree > 0 || $TCA[$tableName]['ctrl']['versioning_followPages'])) { $verTablesArray[] = $tableName; } } // Remove the possible inline child tables from the tables to be versioniozed automatically: $verTablesArray = array_diff($verTablesArray, $this->getPossibleInlineChildTablesOfParentTable('pages')); // Begin to copy pages if we're allowed to: if ($tcemainObj->BE_USER->workspaceVersioningTypeAccess($versionizeTree)) { // Versionize this page: $theNewRootID = $tcemainObj->versionizeRecord('pages', $uid, $label, FALSE, $versionizeTree); if ($theNewRootID) { $this->rawCopyPageContent($uid, $theNewRootID, $verTablesArray, $tcemainObj); // If we're going to copy recursively...: if ($versionizeTree > 0) { // Get ALL subpages to copy (read permissions respected - they should NOT be...): $CPtable = $tcemainObj->int_pageTreeInfo(array(), $uid, intval($versionizeTree), $theNewRootID); // Now copying the subpages foreach ($CPtable as $thePageUid => $thePagePid) { $newPid = $tcemainObj->copyMappingArray['pages'][$thePagePid]; if (isset($newPid)) { $theNewRootID = $tcemainObj->copyRecord_raw('pages', $thePageUid, $newPid); $this->rawCopyPageContent($thePageUid, $theNewRootID, $verTablesArray, $tcemainObj); } else { $tcemainObj->newlog('Something went wrong during copying branch (for versioning)', 1); break; } } } // else the page was not copied. Too bad... } else { $tcemainObj->newlog('The root version could not be created!', 1); } } else { $tcemainObj->newlog('Versioning type "' . $versionizeTree . '" was not allowed in workspace', 1); } } else { $tcemainObj->newlog('Could not read all subpages to versionize.', 1); } }