Unexpected output: Affected paths: relative - resubmit patch.
⚙ D11 INP-1313 - Add support for copying content blocks between themes
Page MenuHomeIn-Portal Phabricator

INP-1313 - Add support for copying content blocks between themes
Needs ReviewPublic

Authored by erik on Sep 25 2014, 10:31 AM.

Details

Reviewers
alex
Test Plan

Preparations

  1. login to Admin Console
  2. go to ConfigurationWebsiteThemes section
  3. set advanced theme as primary theme
  4. go to Catalog & WebsiteBrowse Website section
  5. press Content Mode button in top frame
  6. input some text into editable content block and save changes
  7. set simple theme as primary theme
  8. go to Catalog & WebsiteBrowse Website section
  9. press Content Mode button in top frame
  10. click on Privacy Policy link in the footer
  11. input some text into editable content block and save changes

Actual Test

  1. go to ConfigurationWebsiteThemes section
  2. set 'simple' theme as primary theme
  3. go to Catalog & WebsiteBrowse Website section
  4. confirm that content block is empty
  5. go to ConfigurationWebsiteThemes section
  6. confirm, that Copy Data From toolbar button is disabled
  7. select simple theme in the grid
  8. press Copy Data From toolbar button
  9. choose advanced theme from dropdown, that will appear
  10. go to Catalog & WebsiteBrowse Website section
  11. confirm that content block is filled with a text, that was entered in advanced theme
  12. click on Privacy Policy link in the footer
  13. confirm that content block is not changed - that is filled with a text, that was entered in simple theme

Diff Detail

Repository
rINP In-Portal
Branch
/in-portal/branches/5.3.x
Lint
Lint ErrorsExcuse: The comment should be broken (wrong * position) as other comments in the project to be consistent with other code. Later on (we have task for that) we'll fix all the comments at the same time.
Unit
No Unit Test Coverage

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
erik updated this revision to Diff 16.Sep 25 2014, 10:31 AM
erik edited the test plan for this revision. (Show Details)
erik added a reviewer: alex.
erik set the repository for this revision to rINP In-Portal.
erik added 1 JIRA issue(s): INP-1313.
alex requested changes to this revision.Sep 25 2014, 11:02 AM
alex edited edge metadata.
alex added inline comments.
core/admin_templates/themes/themes_list.tpl
68–69

Any reason for adding these empty lines?

core/units/themes/themes_eh.php
32

Map OnCopyData event to edit permission.

173–176

Move this to the CheckPermission method.

177–254

Move OnCopyData event content to a dedicated class with self-explanatory method names.

This revision now requires changes to proceed.Sep 25 2014, 11:02 AM
alex added a comment.Nov 23 2014, 3:12 AM

Adding comment to create corresponding "Issue Link" from JIRA Issue back to this Differential Revision.

alex retitled this revision from Copy content blocks between themes to INP-1313 - Copy content blocks between themes.Dec 7 2014, 3:31 PM
alex edited edge metadata.
alex set the repository for this revision to rINP In-Portal.Dec 7 2014, 3:41 PM
erik edited the test plan for this revision. (Show Details)Apr 1 2015, 5:03 AM
erik updated this revision to Diff 149.Apr 2 2015, 4:54 AM
erik edited edge metadata.
erik edited the test plan for this revision. (Show Details)

Cose style fixes.

alex requested changes to this revision.May 19 2015, 9:43 PM
alex edited edge metadata.
alex added inline comments.
core/units/helpers/content_block_copier.php
2

Missing licensing DocBlock and die statement on missing FULL_PATH.

48

Add $target_theme_id parameter here too.

52

If source and target themes match, then throw an LogicException.

65
  1. remove parameter in favor of constructor parameter with same name
  2. rename method to just copy
67–69

remove in favor of check in constructor

82–84

remove, because there can't be a case, where page/category doesn't have a revision

88

missing space after =

94

rename $revision to $revision_data (use Shift+F6 in PhpStorm)

104

add blank line after this one

107–110

use doUpdate method for this

114

add a space after RevisionId =

117

rename $block to $block_data

135–136

Format field list the way, that each field would be on it's own line:

138

based on condition in HAVING clause you want to get only matching records, so just:

  1. replace LEFT JOIN with JOIN
  2. remove the HAVING part
156
  1. add blank line after this line
  2. if no categories are found, then don't do implode and just exit from the method
159

add blank line after this line

core/units/helpers/helpers_config.php
77 ↗(On Diff #149)
  1. remove (no need to have these in 5.3)
  2. rebuild class map using in-portal classmap:rebuild command
  3. be sure to include rebuild class map in the patch
core/units/themes/themes_eh.php
53–58

remove, because we're already checking permissions thanks to code in mapPermissions method

232–233

replace with:

$ids = $this->StoreSelectedIDs($event);
234
  1. use makeClass method call to instantiate new class
  2. create object inside foreach because after other changes the constructor accepts source & destination themes
292
  1. extract GetVar result into tmp variable
  2. sanitize input to be in proper format:
    • explode by ,
    • do intval on every element (via array_map)
    • then do array_filter on a result
  3. if we end up with empty ids list, then apply FALSE as filter value
This revision now requires changes to proceed.May 19 2015, 9:43 PM
erik updated this revision to Diff 198.May 22 2015, 12:35 PM
erik edited edge metadata.

Code style fixes

alex requested changes to this revision.May 24 2015, 8:12 PM
alex edited edge metadata.
alex added inline comments.
core/units/helpers/content_block_copier.php
4–5

None of licensing comments in this project have this part (the description).

6

This should be just * @version $Id$ because actual value is assigned at commit time only.

6–16

The comment should be broken (wrong * position) as other comments in the project to be consistent with other code. Later on (we have task for that) we'll fix all the comments at the same time.

8

The 2009 year stands for year, when file was added. It should be 2015 instead.

64–65

Remove this because __construct method doesn't have a return value.

66

Change exception message to When source and target themes match.

core/units/themes/themes_eh.php
234

Usage of request variable not sanitized.

This revision now requires changes to proceed.May 24 2015, 8:12 PM
erik updated this revision to Diff 202.May 27 2015, 4:15 AM
erik edited edge metadata.

Code style fixes

alex requested changes to this revision.May 31 2015, 4:02 AM
alex edited edge metadata.
alex added inline comments.
core/units/helpers/content_block_copier.php
145–153

Please also apply filter by Type column (real templates only) to both source and target to only retrieve categories matching to TPL files. Without this categories for virtual templates (e.g. using shared design) are also retrieved, but their content blocks are shared between themes anyway.

165–168

Please also apply Type column filter (real templates only) so that we don't delete more content blocks that we're copying.

This revision now requires changes to proceed.May 31 2015, 4:02 AM
erik updated this revision to Diff 260.Aug 24 2015, 4:45 AM
erik edited edge metadata.

Added filters by Type to avoid excessive copying.

alex retitled this revision from INP-1313 - Copy content blocks between themes to INP-1313 - Add support for copying content blocks between themes.Jul 15 2016, 2:38 PM
alex edited edge metadata.
alex requested changes to this revision.Dec 5 2016, 3:09 AM
alex edited the test plan for this revision. (Show Details)
alex edited edge metadata.
alex added inline comments.
core/admin_templates/themes/themes_list.tpl
10–15

CS


wrong indentation (SPACEs used instead/in combination with of TABs)

33–47

CS


wrong indentation (SPACEs used instead/in combination with of TABs)

76

Replace with <inp2:m_IfDataExists>.


Reduces copy/paste of internal not_matched_theme_ids request parameter.

76–87

CS


wrong indentation (SPACEs used instead/in combination with of TABs)

79–81
  1. rename to not_matched_theme_element
  2. move above <inp2:m_RenderElement design="form_message">

  1. block name is too general and might overwrite other block (if any) with same name
  2. blocks are always declared, even when placed inside IF that is never executed
86

Replace with </inp2:m_IfDataExists>.


Reduces copy/paste of internal not_matched_theme_ids request parameter.

core/units/helpers/content_block_copier.php
47

Rename into $pageContentTableName (via Shift+F6 shortcut of PhpStorm).


Other properties (e.g. categoriesTableName and pageRevisionTableName) are named according to table name they represent, but not this one.

69

Add a dot (.) at the end of exception message.


CS: Each exception message must end with a dot.

117–121

Move this to deleteTargetBlocks method.


In deleteTargetBlocks method all revisions are deleted so it would be logical to reset live revision number of a category as well.

159

Move this line up to be on JOIN line without risking to violate max line length constain.

160

Use PAGE_TYPE_TEMPLATE constant instead of 2.


Use named constants, when available instead of magic numbers.

172–175

We should only delete content for matched templates (found by getMatchingTemplates method) in target theme.


CMS Content of templates in target theme, that have no match in source theme would be deleted as well.

P.S.
Test plan needs to be updated to reflect this scenario.

174

Use PAGE_TYPE_TEMPLATE constant instead of 2.


Use named constants, when available instead of magic numbers.

This revision now requires changes to proceed.Dec 5 2016, 3:10 AM
erik marked 2 inline comments as done.Apr 11 2017, 5:39 AM
erik added inline comments.
core/admin_templates/themes/themes_list.tpl
76

Not clear what reduces there. Without current simple variable check additional kDBList object (with "not-matched" special) will be created each time when themes_list template is opened.

erik marked 4 inline comments as done.Apr 11 2017, 6:00 AM
alex added inline comments.Apr 11 2017, 8:01 AM
core/admin_templates/themes/themes_list.tpl
76

I see now. Thanks for explaining.

Then you can skip this change.

86

This change can be skipped because matching change for <inp2:m_if tag is also skipped.

erik edited the test plan for this revision. (Show Details)Apr 12 2017, 5:49 AM
erik edited edge metadata.
erik updated this revision to Diff 722.Apr 12 2017, 6:06 AM
erik edited edge metadata.
erik marked 4 inline comments as done.
erik edited the test plan for this revision. (Show Details)

Made all requested CS and logic fixes.