public function duplicate($source, $target, Zend_ProgressBar $progressBar = null) { $contexts = Kwf_Component_Layout_Abstract::getInstance($target->componentClass)->getContexts($target); $supportedContexts = Kwf_Component_Layout_Abstract::getInstance($target->componentClass)->getSupportedContexts(); if ($contexts && $supportedContexts) { foreach ($contexts as $context) { if (!in_array($context, $supportedContexts)) { throw new Kwf_Component_Exception_IncompatibleContexts("Duplicating component in incompatible context"); } } } Kwf_Component_LogDuplicateModel::getInstance()->import(Kwf_Model_Abstract::FORMAT_ARRAY, array(array('source_component_id' => $source->dbId, 'target_component_id' => $target->dbId))); if ($source->getComponent()->getOwnModel() && $source->dbId != $target->dbId) { $this->_duplicateOwnRow($source, $target); } $s = array('ignoreVisible' => true); foreach ($source->getChildComponents($s) as $c) { if ($c->generator->hasSetting('inherit') && $c->generator->getSetting('inherit') && $c->generator->hasSetting('unique') && $c->generator->getSetting('unique') && $source->componentId != $c->parent->componentId) { continue; } else { if (!$c->generator->hasSetting('inherit') && !Kwf_Component_Generator_Abstract::hasInstance($target->componentClass, $c->generator->getGeneratorKey())) { continue; } else { if ($c->generator->getGeneratorFlag('pageGenerator')) { continue; } } } $c->generator->duplicateChild($c, $target, $progressBar); } }
public function duplicate($source, $target, Zend_ProgressBar $progressBar = null) { Kwf_Component_LogDuplicateModel::getInstance()->import(Kwf_Model_Abstract::FORMAT_ARRAY, array(array('source_component_id' => $source->dbId, 'target_component_id' => $target->dbId))); if (($model = $source->getComponent()->getOwnModel()) && $source->dbId != $target->dbId) { $row = $model->getRow($source->dbId); if ($row) { $targetRow = $model->getRow($target->dbId); if ($targetRow) { $targetRow->delete(); } $newRow = $row->duplicate(array('component_id' => $target->dbId)); } } $s = array('ignoreVisible' => true); foreach ($source->getChildComponents($s) as $c) { if ($c->generator->hasSetting('inherit') && $c->generator->getSetting('inherit') && $c->generator->hasSetting('unique') && $c->generator->getSetting('unique') && $source->componentId != $c->parent->componentId) { continue; } else { if (!$c->generator->hasSetting('inherit') && !Kwf_Component_Generator_Abstract::hasInstance($target->componentClass, $c->generator->getGeneratorKey())) { continue; } else { if ($c->generator->getGeneratorFlag('pageGenerator')) { continue; } } } $c->generator->duplicateChild($c, $target, $progressBar); } }