public function duplicate($nc = null, $preserveUserID = false) { if (!is_object($nc)) { // There is not necessarily need to provide the parent // page for the duplicate since for stacks, that is // always the same page. $nc = Page::getByPath(STACKS_PAGE_PATH); } $page = parent::duplicate($nc, $preserveUserID); // we have to do this because we need the area to exist before we try and add something to it. $a = Area::getOrCreate($page, STACKS_AREA_NAME); $db = Loader::db(); $v = array($page->getCollectionName(), $page->getCollectionID(), $this->getStackType()); $db->Execute('insert into Stacks (stName, cID, stType) values (?, ?, ?)', $v); // Make sure we return an up-to-date record return Stack::getByID($page->getCollectionID()); }
/** * Duplicate this UserDefinedForm page, and its form fields. * Submissions, on the other hand, won't be duplicated. * * @return Page */ public function duplicate() { $page = parent::duplicate(); foreach($this->Fields() as $field) { $newField = $field->duplicate(); $newField->ParentID = $page->ID; $newField->write(); } return $page; }
/** * Duplicate this UserDefinedForm page, and its form fields. * Submissions, on the other hand, won't be duplicated. * * @return Page */ public function duplicate($doWrite = true) { $page = parent::duplicate($doWrite); // the form fields if ($this->Fields()) { foreach ($this->Fields() as $field) { $newField = $field->duplicate(); $newField->ParentID = $page->ID; $newField->write(); } } // the emails if ($this->EmailRecipients()) { foreach ($this->EmailRecipients() as $email) { $newEmail = $email->duplicate(); $newEmail->FormID = $page->ID; $newEmail->write(); } } return $page; }
/** * Duplicate this UserDefinedForm page, and its form fields. * Submissions, on the other hand, won't be duplicated. * * @return Page */ public function duplicate($doWrite = true) { $page = parent::duplicate($doWrite); // the form fields if ($this->Fields()) { foreach ($this->Fields() as $field) { $newField = $field->duplicate(); $newField->ParentID = $page->ID; $newField->write(); $this->afterDuplicateField($page, $field, $newField); } } // the emails if ($this->EmailRecipients()) { foreach ($this->EmailRecipients() as $email) { $newEmail = $email->duplicate(); $newEmail->FormID = $page->ID; $newEmail->write(); } } // Rewrite CustomRules if ($page->Fields()) { foreach ($page->Fields() as $field) { // Rewrite name to make the CustomRules-rewrite below work. $field->Name = $field->ClassName . $field->ID; $rules = unserialize($field->CustomRules); if (count($rules) && isset($rules[0]['ConditionField'])) { $from = $rules[0]['ConditionField']; if (array_key_exists($from, $this->fieldsFromTo)) { $rules[0]['ConditionField'] = $this->fieldsFromTo[$from]; $field->CustomRules = serialize($rules); } } $field->Write(); } } return $page; }
<?php $this->addScript('/admin/js/ckeditor/ckeditor.js'); $this->addScript('/admin/js/ckeditor/adapters/jquery.js'); $objPage = new Page($this->objLanguage); $objForm = new Form($this->objUrl); $objValidation = new Validation($this->objLanguage); $expected = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity'); $required = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity'); if (isset($_POST['name'])) { $array = $objForm->post2Array($expected, 'content', array('identity' => 'sanitise')); if (array_key_exists('identity', $array) && !empty($array['identity']) && $objPage->duplicate($array['identity'])) { $objValidation->add2Errors('identity', 'identity_taken'); } if ($objValidation->isValid($array, $required)) { if ($objPage->add($array)) { Helper::redirect($this->objUrl->getCurrent(array('a', 'id')) . '/a/index'); } } } require_once 'header.php'; ?> <h1><?php echo $this->objLanguage->labels[9]; ?> </h1> <form method="post"> <table class="tbl_insert"> <tr>