Skip to content

033 Export Import of fully mapped components

Llewellyn van der Merwe edited this page Dec 19, 2018 · 14 revisions

Readings We're happy to announce a new feature That's been added To be advanced component builder for Joomla This feature Is a feature I suppose can Can become very Useful In the future of JCB It allows you to export A component Out of JCB And not only The components information but everything attached to it So If a component has Admin views link to it and does admin views have Fields link to it and those Fields Hatfield types linked And Dosa Component has site views in custom admin views And those suck sitefusion custom admin views has templates and layouts And dynamic gets And all these various linked concepts to a component Is exported Now The way that you will export a component Is you simply click on Diss export component And obviously you need to select The component or components that you would like to export Now There's a few things to say when When we want to export a component There are two ways in which we export a component one is An encrypted way And the other is non encrypted Let me show you that in the code So I like you to understand exactly how it works So we have a method here called smart export Builder Now Smart export builder gets fired at the very end Of the Compilation or rather the built Where all the data has now been extracted from the database And it's now 1 Big array Of objects Now Basically in this function Called Get Smart export Is where this data extrusion takes place During this process We actually Take A I will take a Count of a specific value And that values name is export key So in this for each We are looping Through the are the components that you've selected so if you selected more than one Then it will check whether there is an export key For that component now let me show you where that is a set in the user interface When you open a component It has a tab called settings And At the bottom of the right-hand column it has a new A field called export key How you can put any value in here If you leave this value empty And you export only this component Then the component will not be encrypted If you add A value to this field And you export this component it will encrypt That in Kop that components Data The database values It will not encrypt Attached files or folders or images That are part of this component it will only encrypt The data from the database Now Having said that If you select multiple components And any one of them has a key Then it will encrypt All the components Ok And I'll explain again in the code how this Is done So we go back to the code Hey in the code Basically were asking does this component have an export key If it's true and it is a string We actually Disc this key is encrypted in a database So we first check That it is able to be decrypted And then we decrypt the key And then we add it To the key array With the components ID So basically we are building up an array Of each components key Know if a component does not have a key It simply ignored this little script and it continues building its data set Then Once all the data set of all components of finished We basically get to the Smart export builder I set spoke coffee you know When we started looking at the code Now in this Smart export builder we are simply asking have we found any keys If we have found any keys We are gonna explode Implode The array And converted to MD5 string Very simple We will then use this MD5 string With An EAP s Encryption Cypher To lock the data So there is the data No above here we already changed the whole dataset To a serialised string So we have a string in this variable And here we are basically encrypting the whole string And now In this variable we have the encrypted value If we don't have any keys Even if that means if none of the components that was selected Had any kiss set Then it will default to Simply Do a base64 encode And that is swell then gets written to do the file That's part of the package So that is how It exports the data I'm too much about the actual mechanics that's happening here In the bottom of the file You're welcome to obviously look through it And if you see any room for improvement You're welcome to make a pull request This this is obviously the first try Ok so it exports the data and then checks whether we have any keys So if you have For example exporting 5 Components And all five components have keys In all 5 keys will Basically create a very long String And then that whole string will be changed into an MD5 string which is 32 characters And that 32 characters is then used to encrypt the data No not to worry This actual key Which we then end up using to do the encryption Will be shown to you in the interface after the you know after the the data is being export Ok so let's go back to To the to the user interface and let's export a component Ok so I have this component And it has a key And I have other components that has no keys at this stage So I'll select this one as a demonstration And then I'll click export component And as you can see A generated a key for me Which I can then use To import This package into another JCB I can import it into the same JCB But it's obviously not necessary So I could use it as a backup Now It is storing the compiled package in The temporary folder at this stage I am Working too Determine whether we should actually make this placement of the file the namek So that you could change it Because I think it will be ideal if it automatically becomes a kind of backup method So we even thinking of setting up a timer that could run backups Of your components using this method Anyway that's future planning that's not Gotta be happening Soon though Ok so You have an exported component At the moment if you if you are data sets on not too big and your memory Settings on your PHP and so forth is allowing this kind of compilation You could select all components And Export them The same will be the result Since I have only one component set with a key They all will be Basically encrypted With the same key And they all be stored in this package so I have just now While talking to you Exported all my components Into this one package How to demonstrate the importing of this data set I have a Blank website ready So let's go there So here's my blank website Basically it has no special JCB components The first thing I'll do is I'm gonna install JCB I'm gonna install it from From get up So I'm going to get Hub And then I will Open the releases And I'll just copy the link To this latest release And go back here Paste that in here And basically install it Ok then still Asian was successful Now I'm gonna go to Component Builder Then I'll open the components And as you can see I have only the demo component here And I would like to basically Move all these components that I have Over to this new install Ok So I'm gonna click on import components Then I'm gonna browse to that The package that we've just exported And then I'm gonna upload it Now We have two features here This Force local update Basically what it will do Is on normal circumstances if you do a import The The import function looks at the data that are currently in this In this current JCB install So for example We talking about field types we talking about Fields we talking about admin views and side views If it finds a side view that is being installed That it is already in the current Database It looks at the last modified date And then by that determines whether The current installed version is newer If it's newer It will by Default ignore the new data and not install it Now sometimes you might get a package where you would like to force that it updates The current data even though it may be all the data So this is why we have to switch you can then click yes to force the update Now We have a key for this package so we'll leave this to yes I'll basically is come over here and copy that key This key will then always be necessary if you're importing this package And that will be it and we'll click continue It might take a time since this is quite a huge dataset So you could just patiently wait And it last it is installed it tells us that the install is being successful You might get these warnings Now what is warnings is really telling you Is that During the install Obviously you realise that Lots of ideas Will change I mean We are working with a database that creates ID is as the new item is added And since these are the ID is used to link into the various components and views and places All these ideas must be remapped Now We have been able to actually Find a very well formulated algorithm to To resolve this problem So it remaps all the ideas But sometimes There are certain ideas that hasn't you know it's not possible to remap And so we are basically telling you hear about them And so you could see that the target field in the admin views Has a mismatch in the field With ID 244 now you can go back to the old install And try and find out what happened there And most the time when I have reviewed this usually it is because that specific field Is no longer published or is no longer available some reason So this is just giving you a heads up of any changes that may have occurred And then you can actually go to these various places and manually Fix them Most of the time these warnings will not show and everything will just say All is ok But if there is warnings and errors to Simply read the messages slowly and close Closely And I'm sure you'll be able to resolve it Quite easily Well that is a demonstration of the new feature Now just to show you that it actually does work I'm didn't mention before but it actually Removes all the customer files as well as custom folders As well as all the images for admin view side view and Wherever To the new install so it moved it into its right place So if that is true we should be able to go to the compiler Select any of the components And It should load that components image share I should be able to just click Ok compile And it should be able to Simply compile that component After compilation I could simply click installing the component Obviously if this component was correctly mapped Previously And I would to go to that component now I would see that Everything about the component is right and it works well And That is really This new feature in action I really hope that it will be as useful to you as it's gonna be to me And that you will have fun with it I must tell you I suppose that at some point We could even start looking at selling map components I have a number of components that was made for specific Purposes But could be easily adapted for others And so I'm starting to look at the idea of selling map to components Obviously It's a little difficult because it's basically selling The rights to it in a way that you could resell it So I'm not sure what would be the price tag all that Anyway We'll see Thank you for watching

Clone this wiki locally