Index: core/units/themes/themes_eh.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/units/themes/themes_eh.php (revision 15965) +++ core/units/themes/themes_eh.php (revision ) @@ -29,6 +29,7 @@ $permissions = Array( 'OnChangeTheme' => Array('self' => true), + 'OnCopyData' => Array('self' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); @@ -161,6 +162,103 @@ } /** + * Copies content blocks between themes + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnCopyData(kEvent $event) + { + if (!$this->Application->isAdminUser) { + return; + } + + $source_theme_id = $this->Application->GetVar('copy_from'); + $this->StoreSelectedIDs($event); + $ids=$this->getSelectedIDs($event); + $table_name = $this->Application->getUnitConfig('c')->getTableName(); + $content_table_name = $this->Application->getUnitConfig('content')->getTableName(); + $page_revision_table_name = $this->Application->getUnitConfig('page-revision')->getTableName(); + $not_matched_theme_ids = Array (); + + foreach($ids as $target_theme_id) + { + if ( $target_theme_id == $source_theme_id ) { + continue; + } + + // get matching templates + $sql = 'SELECT source.LiveRevisionNumber, source.CategoryId AS SourceCategoryId, target.CategoryId AS TargetCategoryId, source.Template + FROM ' . $table_name . ' source + LEFT JOIN ' . $table_name . ' target + ON target.ThemeId = ' . $target_theme_id . ' AND target.Template = source.Template + WHERE source.ThemeId = ' . $source_theme_id . ' + HAVING NOT ISNULL(TargetCategoryId)'; + $matches = $this->Conn->Query($sql); + + if ( count($matches) ) { + // delete all target blocks + $sql = 'SELECT CategoryId + FROM ' . $table_name . ' + WHERE ThemeId = ' . $target_theme_id; + $target_categories = implode(',', $this->Conn->GetCol($sql)); + $sql = 'DELETE FROM ' . $content_table_name . ' + WHERE PageId IN (' . $target_categories . ')'; + $this->Conn->Query($sql); + $sql = 'DELETE FROM ' . $page_revision_table_name . ' + WHERE PageId IN (' . $target_categories . ')'; + $this->Conn->Query($sql); + + foreach ($matches as $match) { + if ( !$match['LiveRevisionNumber'] ) { + continue; + } + + $sql = 'SELECT * + FROM ' . $page_revision_table_name . ' + WHERE PageId = ' . $match['SourceCategoryId'] . ' AND RevisionNumber =' . $match['LiveRevisionNumber']; + $revision = $this->Conn->GetRow($sql); + + if ( !$revision ) { + continue; + } + + $revision['PageId'] = $match['TargetCategoryId']; + $revision['RevisionNumber'] = 1; + $live_revision_id = $revision['RevisionId']; + unset($revision['RevisionId']); + $this->Conn->doInsert($revision, $page_revision_table_name); + $new_revision_id = $this->Conn->getInsertID(); + + $sql = 'UPDATE ' . $table_name . ' + SET LiveRevisionNumber = 1 + WHERE CategoryId = ' . $match['TargetCategoryId']; + $this->Conn->Query($sql); + + $sql = 'SELECT * + FROM ' . $content_table_name . ' + WHERE PageId = ' . $match['SourceCategoryId'] . ' AND RevisionId =' . $live_revision_id; + $blocks = $this->Conn->Query($sql); + + foreach ($blocks as $block) { + $block['RevisionId'] = $new_revision_id; + $block['PageId'] = $match['TargetCategoryId']; + unset($block['PageContentId']); + $this->Conn->doInsert($block, $content_table_name); + } + } + } else { + $not_matched_theme_ids[] = $target_theme_id; + } + } + + if ( count($not_matched_theme_ids) ) { + $event->setRedirectParam('not_matched_theme_ids',implode(',', $not_matched_theme_ids)); + } + } + + /** * Apply system filter to themes list * * @param kEvent $event @@ -194,6 +292,10 @@ if ( strlen($themes) ) { $themes = explode('|', substr($themes, 1, -1)); $object->addFilter('domain_filter', '%1$s.ThemeId IN (' . implode(',', $themes) . ')'); + } + + if ( $event->Special == 'not-matched' ) { + $object->addFilter('not_matched_filter', '%1$s.ThemeId IN (' . $this->Application->GetVar('not_matched_theme_ids') . ')'); } } } Index: core/units/themes/themes_config.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/units/themes/themes_config.php (revision 15965) +++ core/units/themes/themes_config.php (revision ) @@ -59,7 +59,7 @@ 'themes_list' => Array ( 'prefixes' => Array ('theme_List'), 'format' => "!la_tab_Themes!", - 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'refresh', 'view', 'dbl-click'), + 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'refresh', 'view', 'dbl-click', 'copy'), ), 'themes_edit_general' => Array ( \ No newline at end of file Index: core/admin_templates/themes/themes_list.tpl IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/admin_templates/themes/themes_list.tpl (revision 15965) +++ core/admin_templates/themes/themes_list.tpl (revision ) @@ -7,6 +7,12 @@ @@ -54,9 +75,21 @@ + + + + +
  • +
    +
      + +
    +
    +
    + \ No newline at end of file Index: core/install/english.lang IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- core/install/english.lang (revision 15965) +++ core/install/english.lang (revision ) @@ -287,6 +287,7 @@ cmVxdWlyZWQgY29sdW1ucyBtaXNzaW5n Um9vdCBzZWN0aW9uIG9mIHRoZSBtb2R1bGUocykgY2FuIG5vdCBiZSBkZWxldGVkIQ== U2VsZWN0IGF0IGxlYXN0IG9uZSBpdGVtIHRvIG1vdmU= + U29tZSBvZiB0aGVtZXMgd2VyZW4ndCBtYXRjaGVk VGVtcGxhdGUgZmlsZSBpcyBtaXNzaW5n Q29weWluZyBvcGVyYXRpb24gaW4gVGVtcG9yYXJ5IHRhYmxlcyBoYXMgZmFpbGVkLiBQbGVhc2UgY29udGFjdCB3ZWJzaXRlIGFkbWluaXN0cmF0b3Iu UmVjb3JkIGlzIG5vdCB1bmlxdWU= @@ -1609,6 +1610,7 @@ Q2xvbmUgVXNlcnM= Q2xvc2U= Q29weQ== + Q29weSBEYXRhIEZyb20= Q3V0 RGVjbGluZQ== RGVsZXRl