Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sergej Logis
Document Library integration in third-party portlets
February 15, 2013 3:09 AM
Answer

Sergej Logis

Rank: New Member

Posts: 19

Join Date: October 27, 2010

Recent Posts

Hello guys.
I need to create portlet which would display images and allow to download files from Liferay Document Library.
It would be crazy to implement another CMS in portlet application, so it would be nice to reuse Liferay provided
services. What I need is to be able to upload new image/document into Document Library right from the third-party
portlet UI, and then allow user to select which image to display in portlet screen or which document to download
when button pressed in portlet (I suppose Liferay should provide link to Document Library resource).
I suppose that Document Library UI tools (dialogs) should be available as Alloy UI extensions, at least I hope they
are, and I only need to know how to invoke them from third-party portlet (javascript).
I would be very grateful for any help regarding my problem emoticon
Thank you very much!
Meera Prince
RE: Document Library integration in third-party portlets
February 15, 2013 5:15 AM
Answer

Meera Prince

Rank: Liferay Legend

Posts: 1110

Join Date: February 8, 2011

Recent Posts

HI
What is meaning of third-party portlet?
its liferay portlet or other portal portlet?
If you are developing new liferay plugin portlet then you can use DL related services classes directly. UI you can do in any manner once you summit form then in action class Use DL related local service Util classes to store or retrieve content form db.

Regards,
Meera Prince
Sergej Logis
RE: Document Library integration in third-party portlets
February 15, 2013 5:29 AM
Answer

Sergej Logis

Rank: New Member

Posts: 19

Join Date: October 27, 2010

Recent Posts

I mean it is Liferay portlet which is deployed as additional web application.
Using DL in programmatic mode is possible to upload files, however, how to select some DL resource to be
referenced from my portlet? E.g., I want to display service workflow scheme which is image. I want to allow
administrator of services (not administrator of Liferay portal!) to upload image into Liferay DL and then select
it reference to display as image in my portlet.
As far as I rememeber, Liferay has two dialogs for working with DL - file upload and reference selection, both
is available for use in Web Content creation dialog. I wonder could I access this dialogs from my portlet.
Thanks.
Sergej Logis
RE: Document Library integration in third-party portlets
March 12, 2013 2:47 AM
Answer

Sergej Logis

Rank: New Member

Posts: 19

Join Date: October 27, 2010

Recent Posts

I have found the solution. It was pretty straight-forward: I just needed to properly configure CKeditor instance in my portlet to use file browser from Liferay Portal, which in turn is connected to Documents Library. I used the following CKeditor custom configuration file in my portlet:

 1CKEDITOR.editorConfig = function(config) {
 2   
 3    if (Liferay) {
 4        var connector = encodeURIComponent(Liferay.ThemeDisplay.getPathMain() +
 5                "/portal/fckeditor?p_l_id=" + Liferay.ThemeDisplay.getPlid() +
 6                "&doAsUserId=" + Liferay.ThemeDisplay.getDoAsUserIdEncoded());
 7        config.filebrowserBrowseUrl = "/html/js/editor/ckeditor/editor/filemanager/browser/liferay/browser.html?Connector=" + connector;
 8        config.filebrowserUploadUrl = "/html/js/editor/ckeditor/editor/filemanager/browser/liferay/frmupload.html?Connector=" + connector;
 9    }
10
11    ...
12}

Also, small change to html\js\editor\ckeditor\editor\filemanager\browser\liferay\frmresourceslist.html file is required:
 1function OpenFile( fileUrl )
 2{
 3    var funcNum;
 4   
 5    // CKEditor 3+ behavior (used in portlets)
 6    if (regexp = new RegExp('[?&]' + encodeURIComponent('CKEditorFuncNum') + '=([^&]*)').exec(window.top.location.search)) {
 7        funcNum = decodeURIComponent(regexp[1]);   
 8    }
 9   
10    if (!funcNum) {
11        funcNum = 1;
12   
13        if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
14            funcNum = 2;
15        }
16    }
17
18    window.top.opener.CKEDITOR.tools.callFunction(funcNum, fileUrl);
19                   
20    window.top.close() ;
21    window.top.opener.focus() ;
22}

Hope it will be of any use to somebody emoticon