concrete/src/Page/Page.php
protected function _duplicateAll($cParent, $cNewParent, $preserveUserID = false, Site $site = null)
    {
        $db = Database::connection();
        $cID = $cParent->getCollectionID();
        $q = 'select cID, ptHandle from Pages p left join PageTypes pt on p.ptID = pt.ptID where cParentID = ? order by cDisplayOrder asc';
        $r = $db->executeQuery($q, [$cID]);
        if ($r) {
            while ($row = $r->fetchRow()) {
                // This is a terrible hack.
                if ($row['ptHandle'] === STACKS_PAGE_TYPE) {
                    $tc = Stack::getByID($row['cID']);
                } else {
                    $tc = self::getByID($row['cID']);
                }
                $nc = $tc->duplicate($cNewParent, $preserveUserID, $site);
                $tc->_duplicateAll($tc, $nc, $preserveUserID, $site);
            }
        }
    }
protected function _duplicateAll($cParent, $cNewParent, $preserveUserID = false, Site $site = null)
    {
        $db = Database::connection();
        $cID = $cParent->getCollectionID();
        $q = 'select cID, ptHandle from Pages p left join PageTypes pt on p.ptID = pt.ptID where cParentID = ? order by cDisplayOrder asc';
        $r = $db->executeQuery($q, [$cID]);
        if ($r) {
            while ($row = $r->fetchRow()) {
                // This is a terrible hack.
                if ($row['ptHandle'] === STACKS_PAGE_TYPE) {
                    $tc = Stack::getByID($row['cID']);
                } else {
                    $tc = self::getByID($row['cID']);
                }
                $nc = $tc->duplicate($cNewParent, $preserveUserID, $site);
                $tc->_duplicateAll($tc, $nc, $preserveUserID, $site);
            }
        }
    }
protected function _duplicateAll ( $ cParent , $ cNewParent , $ preserveUserID = false , Site $ site = null ) { $ db = Database :: connection ( ) ; $ cID = $ cParent -> getCollectionID ( ) ; $ q = 'select cID, ptHandle from Pages p left join PageTypes pt on p.ptID = pt.ptID where cParentID = ? order by cDisplayOrder asc' ; $ r = $ db -> executeQuery ( $ q , [ $ cID ] ) ; if ( $ r ) { while ( $ row = $ r -> fetchRow ( ) ) { // This is a terrible hack. if ( $ row [ 'ptHandle' ] === STACKS_PAGE_TYPE ) { $ tc = Stack :: getByID ( $ row [ 'cID' ] ) ; } else { $ tc = self :: getByID ( $ row [ 'cID' ] ) ; } $ nc = $ tc -> duplicate ( $ cNewParent , $ preserveUserID , $ site ) ; $ tc -> _duplicateAll ( $ tc , $ nc , $ preserveUserID , $ site ) ; } } }
Duplicate all the child pages of a specific page which has already have been duplicated.

@param \Concrete\Core\Page\Page $originalParentPage The original parent page
@param \Concrete\Core\Page\Page $newParentPage The duplicated parent page
@param bool $preserveUserID Set to true to preserve the original page author IDs
@param \Concrete\Core\Entity\Site\Site|null $site the destination site
Duplicate all the child pages of a specific page which has already have been duplicated .