revolution icon indicating copy to clipboard operation
revolution copied to clipboard

Refactor modStaticResource to conform with modMediaSource

Open lokamaya opened this issue 13 years ago • 2 comments

lokamaya created Redmine issue ID 9153

Discussion: http://forums.modx.com/thread/80492/static-resources-and-media-sources

modStaticResource has been in MODx for a long time, modMediaSource is a new comers. And both are native features of MODx, so we need to refactor the core code to make them comply each other.

As for note, since 2.2.1-pl modResource has a new properties field that proposed to store JSON format data.

  • Tracker: http://tracker.modx.com/issues/6651

We could use this properties field to store MediaSource properties or MediaSource ID. For example store mediaSource ID in modStaticResource properties in the following format:

{"mediaSourceID":"1"}

where "n" is the ID of mediaSource .

h2. Refactoring Step

Backend Manager

  • check if/else: modStaticResource
  • get MediaSource ID from modStaticResource properties (if any)
  • mediaSourceID > 0: get MediaSource properties
  • modMediaSource fired:
  • if modStaticResource MediaSource properties not empty: set default modMediaSource properties
  • if modMediaSource ID changed: get MediaSource ID
  • modStaticResource saved:
  • resource content (static resource) = file
  • resource properties = {"mediaSourceID":"n"} (where n: MediaSource ID)
  • save!

Frontend Client

  • check if/else: modStaticResource
  • get MediaSource ID from modStaticResource properties (if any)
  • mediaSourceID > 0: get MediaSource properties
  • if basePath not empty && basePathRelative is true: file = modxpath/basePath/file
  • elseif basePath not empty && basePathRelative is false: file = basePath/file
  • else: file = modxpath/file
  • get the file

lokamaya avatar Nov 21 '12 10:11 lokamaya

:+1: for the idea, i'm just not sure about the idea of using resource properties to store the source ID.

Also, as written in https://github.com/modxcms/revolution/issues/11385#issuecomment-57774870, it should be possible to handle Media Source ID with form customization

rtripault avatar Oct 07 '14 11:10 rtripault

Can this be reconsidered for 3.x?

ghost avatar Jan 08 '19 18:01 ghost