Example #1
0
 /**
  * Create a duplicate of this node. Doesn't affect joined data - create a
  * custom overloading of this if you need such behaviour.
  *
  * @return SiteTree The duplicated object.
  */
 public function duplicate($doWrite = true)
 {
     $page = parent::duplicate(false);
     $page->Sort = 0;
     $this->extend('onBeforeDuplicate', $page);
     if ($doWrite) {
         $page->write();
     }
     $this->extend('onAfterDuplicate', $page);
     return $page;
 }
Example #2
0
 /**
  * Create a duplicate of this order/estimate as well as duplicating
  * associated items
  *
  * @param $doWrite Perform a write() operation before returning the object.  If this is true, it will create the
  *                 duplicate in the database.
  * @return DataObject A duplicate of this node. The exact type will be the type of this node.
  */
 public function duplicate($doWrite = true)
 {
     $clone = parent::duplicate($doWrite);
     // Set up items
     if ($doWrite) {
         foreach ($this->Items() as $item) {
             $item_class = $item->class;
             $clone_item = new $item_class($item->toMap(), false, $this->model);
             $clone_item->ID = 0;
             $clone_item->ParentID = $clone->ID;
             $clone_item->write();
         }
     }
     $clone->invokeWithExtensions('onAfterDuplicate', $this, $doWrite);
     return $clone;
 }
Example #3
0
 /**
  * Create a duplicate of this node. Doesn't affect joined data - create a custom overloading of this if you need
  * such behaviour.
  *
  * @param bool $doWrite Whether to write the new object before returning it
  * @return self The duplicated object
  */
 public function duplicate($doWrite = true)
 {
     $page = parent::duplicate(false);
     $page->Sort = 0;
     $this->invokeWithExtensions('onBeforeDuplicate', $page);
     if ($doWrite) {
         $page->write();
         $page = $this->duplicateManyManyRelations($this, $page);
     }
     $this->invokeWithExtensions('onAfterDuplicate', $page);
     return $page;
 }
Example #4
0
 /**
  * Create a duplicate of this node. Doesn't affect joined data - create a
  * custom overloading of this if you need such behaviour.
  *
  * @return SiteTree The duplicated object.
  */
 public function duplicate($doWrite = true)
 {
     $page = parent::duplicate($doWrite);
     $page->CheckedPublicationDifferences = $page->AddedToStage = true;
     return $page;
 }
 /**
  * Duplicates this panel. Drills down into the has_many relations
  *
  * @return DashboardPanel
  */
 public function duplicate($dowrite = true)
 {
     $clone = parent::duplicate(true);
     foreach ($this->has_many() as $relationName => $relationClass) {
         foreach ($this->{$relationName}() as $relObject) {
             $relClone = $relObject->duplicate(false);
             $relClone->DashboardPanelID = $clone->ID;
             $relClone->write();
         }
     }
     return $clone;
 }
 /**
  * Duplicate this subsite
  */
 function duplicate()
 {
     $newTemplate = parent::duplicate();
     $oldSubsiteID = Session::get('SubsiteID');
     self::changeSubsite($this->ID);
     /*
      * Copy data from this template to the given subsite. Does this using an iterative depth-first search.
      * This will make sure that the new parents on the new subsite are correct, and there are no funny
      * issues with having to check whether or not the new parents have been added to the site tree
      * when a page, etc, is duplicated
      */
     $stack = array(array(0, 0));
     while (count($stack) > 0) {
         list($sourceParentID, $destParentID) = array_pop($stack);
         $children = Versioned::get_by_stage('Page', 'Live', "\"ParentID\" = {$sourceParentID}", '');
         if ($children) {
             foreach ($children as $child) {
                 $childClone = $child->duplicateToSubsite($newTemplate, false);
                 $childClone->ParentID = $destParentID;
                 $childClone->writeToStage('Stage');
                 $childClone->publish('Stage', 'Live');
                 array_push($stack, array($child->ID, $childClone->ID));
             }
         }
     }
     self::changeSubsite($oldSubsiteID);
     return $newTemplate;
 }
Example #7
0
	/**
	 * Create a duplicate of this node. Doesn't affect joined data - create a
	 * custom overloading of this if you need such behaviour.
	 *
	 * @return SiteTree The duplicated object.
	 */
	 public function duplicate($doWrite = true) {
		$page = parent::duplicate($doWrite);
		return $page;
	}