예제 #1
0
 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);
     }
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
 protected function _init($componentClass)
 {
     Kwf_Component_Data_Root::setComponentClass($componentClass);
     Zend_Session::$_unitTestEnabled = true;
     $this->_root = Kwf_Component_Data_Root::getInstance();
     $this->_root->setFilename('kwf/kwctest/' . $componentClass);
     if (function_exists('apc_clear_cache')) {
         apc_clear_cache('user');
     }
     Kwf_Component_Cache_Memory::getInstance()->_clean();
     Kwf_Cache_Simple::resetZendCache();
     Kwc_FulltextSearch_MetaModel::setInstance(new Kwf_Model_FnF(array('primaryKey' => 'page_id')));
     Kwf_Assets_Package_Default::clearInstances();
     Kwf_Component_LogDuplicateModel::setInstance(new Kwf_Model_FnF(array()));
     Kwf_Media_MemoryCache::getInstance()->clean();
     return $this->_root;
 }
 public static function setInstance($instance)
 {
     self::$_instance = $instance;
 }