private function _duplicateNode($id, $newParentId = null) { // Load the node data $node = new Pagstructure($id); // Duplicate node $duplicateNode = $node->createRow($node->__toArray()); $duplicateNode->id = 0; $duplicateNode->ishome = 0; // avoid two homepage $duplicateNode->status = 'draft'; // unpublish the copy if ($newParentId !== null) { $duplicateNode->parent_id = $newParentId; } $duplicateNode->datecreated = new Zend_Db_Expr("NOW()"); $duplicateNode->datemodified = new Zend_Db_Expr("NOW()"); $duplicateNode->who_modified = Sydney_Tools::who(); $duplicateNode->save(); // Duplicate node content $page = new Pagdivspage(); $pageDivs = $page->getDivs($id, false); PagdivspageOp::resetFictivePagDivsOrder(); foreach ($pageDivs as $pageDiv) { Pagdivspage::duplicate($pageDiv['pagdivs_id'], $duplicateNode->id, $pageDiv['order_pagstructure_pagdiv']); } // Access right to duplicate? // Menu presence to duplicate? // Duplicate child, if any $kids = $node->getKids($id); if (count($kids) > 0) { foreach ($kids as $kid) { $this->_duplicateNode($kid->id, $duplicateNode->id); } } return $duplicateNode->id; }
/** * JTO - #350 - Problème d'ordre avec de vieux sites * Remet à l'état initial le compteur d'ordre fictif * */ public static function resetFictivePagDivsOrder() { self::$fictivePageDivOrder = 1; }